I am trying to add a watermark outside the image, creating firstly a padding place.
a) How can I do that? My imagemagick command have problem. Do not
cover all my image files eg. "DSC_5568 - DSC_5588_fused.jpg" did not add padding.
b) I can combine the two separate commands?
c) I want to do that in bulk
My imagemagick commands:
for pic in DSC*.*; do convert -background black -extent 0%x0%+0+100 $pic ${pic//.*}-padded.jpg; done
for pic in DSC*padded.*; do composite -dissolve 100% -gravity SouthEast watermark.png $pic ${pic//.*}-marked.jpg; done
example filenames:
"DSC_5568.JPG, DSC_5568 - DSC_5588_fused.jpg.... etc."
You really should provide sample input and expected output images, but I think you want this:
convert INPUT.JPG -background black -extent 0%x0%+0+100 -gravity southeast watermark.png -compose dissolve -composite RESULT.JPG
You may need to add this -define:
... watermark.png -define compose:args=100 -compose dissolve -composite ...
If that works, I would make a COPY of all your files in a spare directory and do the whole lot in parallel with GNU Parallel:
parallel 'convert {} -background black -extent 0%x0%+0+100 -gravity southeast watermark.png -compose dissolve -composite {.}-marked.jpg' ::: *.jpg
Or, if you prefer a simple bash for loop:
for f in DSC* ; do
convert "$f" -background black -extent 0%x0%+0+100 -gravity southeast watermark.png -compose dissolve -composite "${f//.*}-marked.jpg"
done
I found out how to process all my image files, using "" on the specified filenames.
for pic in DSC*.*; do convert -background black -extent 0%x0%+0+100 "$pic" "${pic//.*}-padded.jpg"; done
for pic in DSC*-padded.*; do composite -dissolve 100% -gravity SouthEast watermark.png "$pic" "${pic//.*}-marked.jpg"; done
Related
I'm trying to Create a thumbnail from GIF 1st command and then merge another image on top of it 2nd command.
1st command:-
convert -thumbnail 398x398 -auto-orient -quality 85 giphy.gif[0] output.jpg
2nd command:- convert -size 1920x1080 xc:none output.jpg -blur 5x4 -composite out1.png -gravity center -composite outfinal.png
I've tried using like this but didn't work out:
convert -thumbnail 398x398 -auto-orient -quality 85 giphy.gif[0] output.jpg | convert -size 398x398 xc:none output.jpg -blur 5x4 -composite out1.png -gravity center -composite outfinal.png
Image extracted from gif:-
2nd image:
Final output as merge two images :
Thank you:)
This is a pretty easy way to do it:
convert -gravity center background.jpg -blur 5x4 \
\( yinyang.png -resize 130x78\! \) \
-composite result.jpg
I put a spurious -resize 130x78\! in there so you can see where to do extra operations that only affect the little "yin yang" picture in the middle - you can obviously remove it.
Maybe I can explain the logic... the first line of the command deals with the background, the second line deals with the overlay. So, first, load up the background picture and make all the edits you want to it, i.e. blurring. Then start some "aside-processing" in parentheses which loads up the "yin yang" and applies some edits to that exclusively without affecting the background image. Then, when you are happy with the overlay, exit the parentheses and take the result of the "aside-processing" and overlay it on top of the background. It overlays into the centre because I set the gravity beforehand.
Hope that helps.
Added in response to your comment... if you want to do the extraction as well, just do that in the "aside-processing":
convert -gravity center \
giphy.gif[0] -thumbnail 398x398 -auto-orient -blur 5x4 \
\( yin yang -resize 300x100\! \) \
-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 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
How can I blend AND translate at the same time ?
Something like this : http://www.imagemagick.org/Usage/layers/#flatten but in such a way that the images are transparent.
I was trying :
composite -blend 90 -page +0+0 input01.jpg -page +500+0 input02.jpg -resize x400 outputSimpleMosaicBlend01.
but this did not work.
So if I have two input images:
Then how can I get an image that looks like the composite image below ?
Any suggestions how to do this programatically (not manually) with ImageMagick ? Or some other tools ?
I would like to create several thousands of composite images like that (for an animation) and I would like to automate the process.
The problem is that I can find examples that overlay images and that translate images but I cannot find examples that do these two operations simultaneously.
This is the main goal of this question, to give such code/script examples, how to do that with image manipulation tools like ImageMagick programmatically.
EDIT:
Things that I tried and did not work:
convert a.jpg -geometry +100+0 b.jpg -compose blend -composite result.jpg
gives:
I tried
convert -background none a.jpg -geometry +100+0 b.jpg -compose blend -composite result.jpg
too which gives the same result.
I got this :
with this
convert -background none input01.jpg input02.jpg -geometry +1200+0 -compose blend -define compose:args=50 -composite result.jpg
command.
It's getting close ! Thanks Mark!
A slightly different way of doing this is to set the width of the output image using -extent and then to overlay the right hand image using -gravity East to align it to the right edge - seems a fraction more intuitive to me - but go with whatever works for you!
convert a.jpg -background white -extent 2800x \
\( b.jpg -resize 150% -alpha on -channel A -evaluate set 50% +channel \) \
-gravity east -composite result.jpg
Thanks to Snigbo, the following command :
convert input02.jpg \( input01.jpg -resize 150% -alpha Opaque -channel A -evaluate Multiply 0.5 +channel -set page +1200+30 \) -background White -layers merge a.jpg
produces:
I have the following ImageMagick code that makes a poster out of 3 images, and it works well, however I would like to have a different -extent value for each of the 3 images. How would I do this? Any help would be much appreciated.
exec("montage -background black $img_1 $img_2 $img_3 -geometry 390x620+5+5 -gravity center -extent 396x626^ $img_out");
I still don't understand what you are trying to achieve, but I think the following might help you get where you are trying to go - hopefully!
I would tend to use convert rather than montage, so let's create three different size images, red, green and blue
convert -size 120x200 xc:red red.png
convert -size 200x300 xc:lime green.png
convert -size 80x120 xc:blue blue.png
they look like this
Now I try and make a poster, using a different shade of grey background for each "picture" and a different size and hope you can adapt that to your needs:
convert -gravity center \
\( -background gray70 red.png -extent 800x300 \) \
\( -background gray40 green.png -extent 300x300 \) \
\( -background gray10 blue.png -extent 100x300 \) \
+append result.png