I want to resize watermark.png but i dont want to chnage original watermark.png ! i want to get watermark.png and resize it and add on image.png but
I don't want to save resized file in watermark.png!
composite -gravity southeast -geometry +10+10 -dissolve 70% watermark.png image.png image-watermarked.png
Assume you have two images, both 400x250 like this:
background.png
watermark.png
Then you probably want something like this:
convert background.png \( watermark.png -resize 100x \) -gravity southeast -composite result.png
Hopefully you can see that the parentheses prevent the -resize from applying to the background.
If you want to use a dissolve, you can do that like this:
convert background.png \( watermark.png -resize 100x \) \
-gravity southeast -define compose:args=20% \
-compose dissolve -composite result.png
I found it ... ill make another resized image and delete it...
convert watermark.png -scale 30% watermark2.png
composite -gravity southeast -geometry +10+10 -dissolve 70% watermark2.png image.png image-watermarked.png
rm -rf ./man/tnx-v2.png
another answer (this has -colorize for dissolve)
convert image.png \( watermark.png -scale 50% -colorize 50% \) -gravity southeast -composite image-watermarked.png
Related
I want to add a watermark logo.png to the nature.jpg with ImageMagick, I use the following commands:
magick nature.jpg logo.png -gravity southeast -geometry +10+10 -composite nature-wm.jpg
convert nature.jpg -resize 50% nature-50%.jpg
magick nature-50%.jpg logo.png -gravity southeast -geometry +10+10 -composite nature-50%-wm.jpg
As you can see, the watermark is smaller when adding it to an image which has large width and height, but this is not what I expected, what I expected is that the watermark can always occupy a fixed percentage of the main image, anyone know how to do this?
logo image
original image
Original image with watermark added
50% width and height of the original image(nature-50%.jpg)
nature-50%.jpg with watermark added(the logo in nature-50%.jpg looks bigger than in the original image)
Update
I want to rotate the watermark, but my approach is not what I expected, it's weird
magick nature.jpg -set option:logowidth "%[fx:int(w*0.25)]" \
\( logo.png -resize "%[logowidth]x" -rotate 45 \) \
-gravity southeast -geometry +10+10 -composite result.jpg
I would do that by loading the background, calculating the width of the logo relative to that (here I used 0.25 as my factor), then loading the logo and resizing before compositing:
magick background.jpg -set option:logowidth "%[fx:int(w*0.25)]" \
\( logo.png -resize "%[logowidth]x" \) \
-gravity southeast -geometry +10+10 -composite result.jpg
Regarding changing the transparency, per your comment, you could make the logo 30% opaque like this:
magick background.jpg -set option:logowidth "%[fx:int(w*0.25)]" \( logo.png -resize "%[logowidth]x" -channel A -fx "u*0.3" \) -gravity southeast -geometry +10+10 -composite result.jpg
Currently, with ImageMagick I apply watermark.png on top of picture.jpg in the center using:
convert -size 700x1300 -composite picture.jpg watermark.png -gravity center -geometry 700x1300 output.jpg
This nicely overlays my watermark in the middle of the image. However, I want to achieve this effect in the top-left, center, and bottom-right. I've tried combining multiple -composites with no result. I would like to avoid calling 3 different commands to avoid the extra overhead it introduces, but I'm starting to believe it isn't possible without doing so.
What can I do to achieve the three watermark positions in one command, NorthWest, Center and SouthEast?
Hold the watermark image in a memory register with "-write mpr:watermark", then recall it into your command for the second and third composite. Here's a simple example of how that works...
convert watermark.png -write mpr:watermark input.png +swap \
-gravity center -composite mpr:watermark -gravity northwest -composite \
mpr:watermark -gravity southeast -composite output.png
Set the geometry before each composite if necessary to give the mark some padding from the corners.
In Imagemagick, there is a -gravity setting that allows you to put the watermark in various locations specified by the compass directions. See http://www.imagemagick.org/script/command-line-options.php#gravity. However, your syntax is not proper and may fail for use with IM 7. The proper syntax is to read the input image first. So your command should be
convert background watermark -gravity center -compose over -composite output
Change center to one of the other gravity settings such as northwest or southeast
Also your -size does nothing in your command. If you want to use -size WxH xc:somecolor, then you would use that in place of the background.
If you want to resize, then do not use -geometry. That is typically used for offsetting the gravity placement. Use -resize WxH if you want to resize the result.
See
http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/layers/#convert
I would modify GeeMack's answer just slightly so it reads a bit more symmetric:
convert watermark.png -write mpr:watermark +delete \
input.png \
mpr:watermark -gravity center -compose over -composite \
mpr:watermark -gravity northwest -compose over -composite \
mpr:watermark -gravity southeast -compose over -composite \
output.png
EDITED: to followup with OP question. If you need to resize the watermark, then do
convert watermark.png -resize 700x1300 -write mpr:watermark +delete \
input.png \
mpr:watermark -gravity center -compose over -composite \
mpr:watermark -gravity northwest -compose over -composite \
mpr:watermark -gravity southeast -compose over -composite \
output.png
I have the following files:
background.jpg
element1.jpg
element2.jpg
I would like to take element1.jpg, resize it to 300x300, place it on background.jpg, and then take element2.jpg, resize it to 400x400 and place it on the background. I would NOT like the background to be resized.
This is my current command. It appears that resize 400x400! is applied to all the previous images in memory (background.jpg and element1.jpg), instead of one specific image.
convert background.jpg -page +0+0 -resize 300x300! element1.jpg -page +0+0 -resize 400x400! element2.jpg -layers flatten output.jpg
Is there a way to accomplish this without creating a tmp folder to save "middle steps" and have it done all in one command? Or, is there a way to use "brackets" to specify which commands to run first?
You can use parentheses to ensure operators only apply to specific images, like this:
convert background.jpg \
\( element1.jpg -resize NNN \) -composite \
\( element2.jpg -resize MMM \) -composite result.jpg
So, if we create 3 test images, all the same size at 600x400 pixels:
convert -size 600x400 xc:red red.png
convert -size 600x400 xc:yellow yellow.png
convert -size 600x400 xc:blue blue.png
We can now individually resize and position them:
convert blue.png \
\( red.png -resize 80x50! \) -geometry +20+100 -composite \
\( yellow.png -resize 200x200! \) -geometry +200+150 -composite result.png
I have an image with a couple of transparent boxes. I need to insert some specific images in to the transparent boxes. I tried several convert commands but couldn't end up with a solution.
I am using Windows 10 and imagemagick is working on my CLI with no issues. Hope someone can point me into the right direction.
Let's say this 500x400 image is your starting image and it has transparent holes in it at 10,10 and 250,250.
Now, let's say you have two Mr Beans, bean1.jpg and bean2.jpg like this:
Let's lay it out on a red background so you can see what is going on. We'll resize bean1.jpg and place him in the area of the top-left transparent hole, then we'll set up bean2.jpg for the bottom-right transparent hole:
convert -size 500x400 xc:red \
\( bean1.jpg -resize 101x101! -geometry +10+10 \) -composite \
\( bean2.jpg -resize 131x131! -geometry +250+250 \) -composite \
result.png
Now let's do that again, but this time, overlay the original image so the Beans peek through it:
convert -size 500x400 xc:red \
\( bean1.jpg -resize 101x101! -geometry +10+10 \) -composite \
\( bean2.jpg -resize 131x131! -geometry +250+250 \) -composite \
image.png -composite result.png
On Windows, you have to change the backslashes into carets, so \( becomes ^( and \) becomes ^).
I would like to crop image and flatten it over a second canvas.
for instance, my image1 crop would be=>
-crop 20x800+450+0
and I would like to put it at the position of my second image.
-page 0+0
this just doesn't work=>
convert -page 0+0 image1.jpg -crop 20x800+450+0 -layers flatten image2.jpg
how could I do this ?
thanks in advance
I find your question very hard to understand, but let's assume you have this:
# a canvas
convert -size 1200x1200 xc:gray canvas.png
and an image:
convert -size 1000x1000 gradient:red-blue image1.png
Then I am guessing you want this:
convert canvas.png \( image1.png -crop 20x800+450+0 \) -composite result.png
That works because the default -gravity is NorthWest, if you wanted it elsewhere you can do things like this:
convert canvas.png \( image1.png -crop 20x800+450+0 \) -gravity east -composite result.png
Or this, with an up-down offset from the South side:
convert canvas.png \( image1.png -crop 20x800+450+0 \) -gravity south -geometry +0+50 -composite result.png
Or with a left-right offset from the West side:
convert canvas.png \( image1.png -crop 20x800+450+0 \) -gravity west -geometry +100 -composite result.png
Or maybe you want to rotate the extracted crop before overlaying it:
convert canvas.png \( image1.png -crop 20x800+450+0 -rotate 90 \) -gravity north -geometry +0+20 -composite result.png
Or maybe you were trying to do it this way:
convert canvas.png -respect-parentheses \( -page +300+50 image1.png -crop 20x800+450+0 \) -layers flatten result.png