Hi, all.
Actually there are only 2 of images. So the original task in photoshop terms looks like:
1. open image (layer 0)
2. paste another image (layer 1), i.e. logo
3. set "layer 1" blending mode to Lighten
4. set "layer 1" opacity to 40%
My idea on how to do the same in IM is
1. compose img0 and img1 in the way like (i.e. steps 1-3 above)
composite.exe img1.png -gravity southeast -geometry +20+15 -compose lighten img0.jpg tmpresult.jpg
2. Here I need to apply the step (4). One way is to do something like this:
composite.exe tmpresult.jpg -dissolve 40% img0.jpg theresult.jpg
3. Delete temporary file:
del tmpresult.jpg
Which is not really good. Here we need to create a temporary file + extra jpeg resave operation.
So, the question is: Is there any way to do the same using just 1 command (without creating a temporary file) ?
Just read several manual pages and didn't find any solution.
Composing of 3 images (or yet another watermarking)
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Composing of 3 images (or yet another watermarking)
see parenthesis and clone processing to get it into one step.
see
http://www.imagemagick.org/Usage/basics/#image_seq
http://www.imagemagick.org/Usage/basics/#clone
NOTE: composite syntax has images after the arguments.
composite argument overlayimage backgroundimage outputimage
you can use convert syntax also but input images come first and are in reverse order
convert backgroundimage overlayimage -compose lighten -composite
but -blend must done using composite rather than convert
see http://www.imagemagick.org/Usage/compose/
Have not studied your processing - just commenting on syntax and how to do in one step
see
http://www.imagemagick.org/Usage/basics/#image_seq
http://www.imagemagick.org/Usage/basics/#clone
NOTE: composite syntax has images after the arguments.
composite argument overlayimage backgroundimage outputimage
you can use convert syntax also but input images come first and are in reverse order
convert backgroundimage overlayimage -compose lighten -composite
but -blend must done using composite rather than convert
see http://www.imagemagick.org/Usage/compose/
Have not studied your processing - just commenting on syntax and how to do in one step
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: Composing of 3 images (or yet another watermarking)
Try something like this:
Pete
Code: Select all
composite img1.jpg -gravity SouthEast img0.jpg -blend 40 theresult.jpg
Pete
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Composing of 3 images (or yet another watermarking)
At this time neither of the composite operators -dissolve or -blend are available in "convert". However the two operators are relatively simple. make each image semi-transparent by multiplying their alpha channels by the appropriate value, then composite using 'over' for a -dissolve and 'plus' for a -blend.
For example... this 40% blend
is equivalent to...
The -depth ensures we get a more accurate result in the images.
Yes these operators should really be made available in "convert". Possibly with the ability to take a longer list of 'alpha channel multipliers' to allow combining more than two images at a time. (What should it do if the number of modifiers does not match the number of images given?)
For a equal 50/50 blend, see -average
For example... this 40% blend
Code: Select all
composite src.jpg dest.jpg -blend 40 result.jpg
Code: Select all
convert -depth 16 \
\( dest.jpg -matte -channel A -evaluate multiply .6 +channel \) \
\( src.jpg -matte -channel A -evaluate multiply .4 +channel \) \
-compose plus -composite result.jpg
Yes these operators should really be made available in "convert". Possibly with the ability to take a longer list of 'alpha channel multipliers' to allow combining more than two images at a time. (What should it do if the number of modifiers does not match the number of images given?)
For a equal 50/50 blend, see -average
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Composing of 3 images (or yet another watermarking)
Thanks, all!
So, now it looks like:
Or, finally, with gravity/geometry:
One more thing. Is there way to calculate the 0.6 value automatically based on 0.4 value ?
For example, if I need to bring out the 0.4 as a parameter to commandline.
So, now it looks like:
Code: Select all
convert -depth 16 ( img0.jpg -matte -channel A -evaluate multiply .6 +channel ) ( ( -compose lighten -composite img1.png img0.jpg ) -matte -channel A -evaluate multiply .4 +channel ) -compose plus -composite result.jpg
Code: Select all
convert -depth 16 ( img0.jpg -matte -channel A -evaluate multiply .6 +channel ) ( ( -compose lighten -composite -gravity southeast -geometry +20+15 img0.jpg img1.png ) -matte -channel A -evaluate multiply .4 +channel +geometry ) -compose plus -composite result.jpg
For example, if I need to bring out the 0.4 as a parameter to commandline.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Composing of 3 images (or yet another watermarking)
One way,
fact1=0.6
fact2=`convert xc: -format "%[fx:1-$fact1]" info:`
Then put $fact1 and $fact2 in your command line in place of 0.6 and 0.4
see fx escapes http://www.imagemagick.org/Usage/transform/#fx_escapes
fact1=0.6
fact2=`convert xc: -format "%[fx:1-$fact1]" info:`
Then put $fact1 and $fact2 in your command line in place of 0.6 and 0.4
see fx escapes http://www.imagemagick.org/Usage/transform/#fx_escapes