Page 1 of 1

Paste an image without it's transparency.

Posted: 2013-12-21T05:45:17-07:00
by Dus
I've searched the fora for a way to paste one image onto another and in this thread viewtopic.php?f=1&t=23858 I found:

Code: Select all

convert backgroundimage foregroundimage -gravity center -compose over -composite resultimage
Which works except the transparency of the "foregroundimage" gets copied as well. Meaning part of the non-transparent area of the "backgroundimage" has now become semi-transparent. (transparency getting averaged it seems).

How can I copy the foregroundimage while keeping non-transparent parts of the backgroundimage non-transparent?
I use ImageMagick-6.8.4-10-Q16-x86-windows and all images are pngs made using

Code: Select all

convert input.bmp mask.bmp -compose CopyOpacity -composite result.png

Re: Paste an image without it's transparency.

Posted: 2013-12-21T05:56:52-07:00
by snibgo
You can turn off the alpha channel in foregroundimage. All pixels from foregroundimage will be opaque.

Code: Select all

convert backgroundimage ( foregroundimage -alpha off ) -gravity center -compose over -composite resultimage
If you don't use parentheses, alpha is turned off in both images:

Code: Select all

convert backgroundimage foregroundimage -alpha off -gravity center -compose over -composite resultimage
See http://www.imagemagick.org/script/comma ... .php#alpha

Re: Paste an image without it's transparency.

Posted: 2013-12-21T06:45:32-07:00
by Dus
If I turn alpha channel off in the foregroundimage I see a big white blob where the other (background) image should be.

Maybe this is a better way to say it:
foregroundimage transparent area + backgroundimage non-transparent area = non-transparent backgroundimage and
foregroundimage non-transparent area + backgroundimage transparent area = non-transparent foregroundimage

The non-transparent parts should not overlap and overlapping transparency parts can stay transparent.

BTW:

Code: Select all

mogrify -gravity center -draw "image Over 0,0 0,0 'transparent0.png'"
also gives semi-transparent images.

Re: Paste an image without it's transparency.

Posted: 2013-12-21T08:07:53-07:00
by snibgo
Sorry, I don't understand what you want. You can post sample images to dropbox.com or similar and paste the links here, then explain what you want.