Page 1 of 1
Alpha multiplying broken since upgrade to 7.x
Posted: 2017-12-07T05:06:15-07:00
by olidem
Hi,
I used to combine one PNG image (with transparent pixels) with another matting image (to blend the image to transparent at the bottom).
This command worked fine with IM 6.x
Code: Select all
convert tmp.png test-gradient.png -channel A -compose Multiply -composite out.png
Now, I am just getting an almost white image. Can you please help me?
Maybe also a link to the great collection of IM examples for Version 7 would help me, I cannot find it, only the 6.x edition.
Thanks in advance
Oliver
Re: Alpha multiplying broken since upgrade to 7.x
Posted: 2017-12-07T10:57:01-07:00
by fmw42
I have tested a number of versions of IM 6 with:
Code: Select all
convert logo: \( -size 640x480 gradient: \) -channel A -compose multiply -composite +channel tmp.png
and do not get any change of the logo: image.
What exact version of IM 6 did you use? and what platform?
I believe what you really want is:
IM 6
Code: Select all
convert logo: \( -size 640x480 gradient: \) -alpha off -compose copy_opacity -composite tmp.png
IM 7
Code: Select all
magick logo: \( -size 640x480 gradient: \) -alpha off -compose copy_opacity -composite tmp.png
Re: Alpha multiplying broken since upgrade to 7.x
Posted: 2017-12-07T17:59:51-07:00
by snibgo
olidem wrote:Now, I am just getting an almost white image. Can you please help me?
To help you, we need to know what version(s) of IM you are using, and we need links to your input images. Otherwise, we can only guess.
Re: Alpha multiplying broken since upgrade to 7.x
Posted: 2017-12-07T19:39:23-07:00
by fmw42
This also works currently
Code: Select all
convert logo: \( -size 640x480 gradient: -alpha copy \) -alpha on -channel A -compose multiply -composite +channel tmp.png
Re: Alpha multiplying broken since upgrade to 7.x
Posted: 2017-12-07T23:19:21-07:00
by olidem
Ok, this is the test-gradient.pgn (I hope it did not destroy alpha channel by uploading)
https://imgur.com/v7BggBK
Then this is the tmp.png
https://imgur.com/v6tNBHF
Both images do have an alpha channel with transparent regions, and I want to combine them, i.e. let the image of the woman fade to transparent at the bottom part.
The result should look like this:
https://imgur.com/mV5StA8
I cannot track back my old im version, must have been some homebrew'd 6.x version, now I have
Code: Select all
ImageMagick 7.0.7-9 Q16 x86_64 2017-11-03
THANKS IN ADVANCE!
Re: Alpha multiplying broken since upgrade to 7.x
Posted: 2017-12-07T23:25:02-07:00
by olidem
fmw42 wrote: ↑2017-12-07T10:57:01-07:00
IM 7
Code: Select all
magick logo: \( -size 640x480 gradient: \) -alpha off -compose copy_opacity -composite tmp.png
Well, my gradient is some hand-drawn custom shape, and as far as I understand your command, this would create a generic gradient?
And if you look at my uploaded pictures, I really want a
pixelwise multiplication of alpha values.
BTW, was my command (which looks way simpler than your suggestions), was it wrong? It did what it should for me...
Re: Alpha multiplying broken since upgrade to 7.x
Posted: 2017-12-08T00:14:40-07:00
by fmw42
This works fine for me on IM 6.9.9.25 Q16 Mac OSX
Code: Select all
convert image.png mask.png -channel a -compose multiply -composite +channel tmp.png
I think you forgot to enable all channels at the end using +channel.
Re: Alpha multiplying broken since upgrade to 7.x
Posted: 2017-12-10T03:51:16-07:00
by olidem
Well as I said, on IM 6.x it even worked without the +channel.
But my installation was upgraded to 7.x, and not it does not work anymore, neither with nor without the +channel.
This is my result:
https://imgur.com/2yiOmu3
Re: Alpha multiplying broken since upgrade to 7.x
Posted: 2017-12-10T08:20:33-07:00
by GeeMack
olidem wrote: ↑2017-12-10T03:51:16-07:00But my installation was upgraded to 7.x, and not it does not work anymore, neither with nor without the +channel.
I can get identical results to your first example command using your sample images and running this command with IM 6.9.9...
Code: Select all
convert tmp.png test-gradient.png -channel A -compose dstin -composite out6.png
Then to get that to work using IM 7.0.7 I just have to add "+swap" after the input images to reverse their order like this...
Code: Select all
magick tmp.png test-gradient.png +swap -channel A -compose dstin -composite out7.png
That gives me a result identical to your original command and the IM6 command I used above. I understand the alpha channel handling has been reversed in IM7, so if I encounter an issue with alpha, I can often resolve it by reversing or negating my mask, or reversing the order of the input images. Maybe this approach will be helpful.
Re: Alpha multiplying broken since upgrade to 7.x
Posted: 2017-12-10T08:50:57-07:00
by olidem
Wooohoooo! GeeMack Great! In fact, dstin did the job!
But can somebody explain this? Why is multiply not the correct operator????
Re: Alpha multiplying broken since upgrade to 7.x
Posted: 2017-12-10T12:29:28-07:00
by fmw42
I believe there is a bug in IM 7. The command should work in either version.
tmp.png:
test-gradient.png:
IM 6.9.9.26: This works fine
Code: Select all
convert tmp.png test-gradient.png -channel A -compose multiply -composite +channel out6.png
IM 7.0.7.14: This does not work
Code: Select all
magick tmp.png test-gradient.png -channel A -compose multiply -composite +channel out7.png
Re: Alpha multiplying broken since upgrade to 7.x
Posted: 2017-12-11T03:34:19-07:00
by olidem
Ah, so I found a bug
Should I file a bug report somewhere?
Another thing: still you all first refer to the 6.x version. Is there any reason why people are migrating to slowly to 7.x?
Anyway, the dstin-workaround seems to work (I still do not know why).
Thank you all for your help!
Re: Alpha multiplying broken since upgrade to 7.x
Posted: 2017-12-11T11:07:44-07:00
by fmw42
I have already reported the bug.
Most Linux distros still come with IM 6 and very old versions at that. They are slow to upgrade. There are some difference between IM 6 and IM 7.
Re: Alpha multiplying broken since upgrade to 7.x
Posted: 2017-12-12T16:32:24-07:00
by magick
Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @
https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @
https://www.imagemagick.org/download/beta/ by sometime tomorrow
Re: Alpha multiplying broken since upgrade to 7.x
Posted: 2017-12-19T00:27:16-07:00
by fmw42
Seems to work fine in IM 7.0.7.15