tuan.ng
tuan.ng

Reputation: 21

Setting opacity of each image drawn on canvas with imagemagick

I have the command below which takes multiple image sources and draw it onto 1 output.png file.

Convert img1.jpg -resize 1000x1000! 
-draw "image over 169,555 875,109 'img1.png'"  
-draw "image over 29,55 375,209 'img2.png'"
-draw "image over 129,525 15,29 'img3.png'"
png24:output.png 

Is there a way to set the opacity of each of the images being drawn? where some might have opacity of 60% , while others have 100%

I tried this but doesn't work:

Convert img1.jpg -resize 1000x1000! 
\( -alpha set -channel A -evaluate set 60% \) -draw "image over 169,555 875,109 'img1.png'"  
\( -alpha set -channel A -evaluate set 100% \) -draw "image over 29,55 375,209 'img2.png'"
\( -alpha set -channel A -evaluate set 90% \) -draw "image over 129,525 15,29 'img3.png'"
png24:output.png 

Thanks in advance

Upvotes: 0

Views: 627

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 208052

I think you want something like this...

convert img1.jpg -resize 1000x1000!  \
\( img1.png -alpha set -channel A -evaluate set  60% -resize 707x447 \) -geometry +169+109 -composite \
\( img2.png -alpha set -channel A -evaluate set 100% -resize 347x155 \) -geometry +29+55   -composite \
\( img3.png -alpha set -channel A -evaluate set  90% -resize 115x497 \) -geometry +15+29   -composite \
png24:output.png

enter image description here

Upvotes: 1

Related Questions