Hi,
I'm having trouble blending/composing two transparent png images
I'm using: (though I've tried a few other ways too)
composite -compose over -geometry +10+10 top.png background.png output.png
The output is mostly right, but the top image loses it's alpha transparency.
Is there a way to blend the top image into the background?
I've looked at -layers merge, but then the transparency of the base image cuts out the overlay..
Composing Transparent Images
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Composing Transparent Images
What version of IM, on what platform?
I suggest you don't use the "composite" program. Instead use "magick" (for IM v7) or "convert" (for IM v6). With those, use the "-composite" operator, and list the two inputs in the opposite order:
Does that do what you want? The result alpha at each pixel depends on the alphas of both inputs.
Perhaps you want "-compose Blend".
I suggest you don't use the "composite" program. Instead use "magick" (for IM v7) or "convert" (for IM v6). With those, use the "-composite" operator, and list the two inputs in the opposite order:
Code: Select all
convert background.png top.png -geometry +10+10 -compose Over -composite output.png
Perhaps you want "-compose Blend".
snibgo's IM pages: im.snibgo.com
Re: Composing Transparent Images
I'm still getting the same thing. Alpha on the overlay image is lost..
I'm using im 6.7.2
This is what I'm getting (with grid added to show transparency)
Vs. this is what I want
If I try to use the blend compose it doesn't compose properly
I'm using im 6.7.2
This is what I'm getting (with grid added to show transparency)
Vs. this is what I want
If I try to use the blend compose it doesn't compose properly
Re: Composing Transparent Images
Here you go
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Composing Transparent Images
V6.7.2 is very old. It may have a bug. Even if it doesn't, I suggest you upgrade.
If you want the output size to be the same as the first input, use "-composite":
If you want the output size to be the smallest that contains all the input images, use "-layers merge". This needs one input to be repaged. If you don't want to flatten against a background colour, you need "-background none".
If you want the output size to be the same as the first input, use "-composite":
Code: Select all
magick DQk2r9I.png Ws9m2Ky.png -geometry +200+10 -compose Over -composite circs2a.png
If you want the output size to be the smallest that contains all the input images, use "-layers merge". This needs one input to be repaged. If you don't want to flatten against a background colour, you need "-background none".
Code: Select all
magick DQk2r9I.png ( Ws9m2Ky.png -repage +200+10 ) -background None -compose Over -layers merge circs2b.png
snibgo's IM pages: im.snibgo.com
Re: Composing Transparent Images
Thanks, I was afraid of that, as it breaks some other scripts I use.