[Resolved]possible bug -alpha IM 6.7.8.6 Q16

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 25572
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

[Resolved]possible bug -alpha IM 6.7.8.6 Q16

Post by fmw42 » 2012-07-30T11:58:12-07:00

IM 6.7.8.6 Q16 Mac OSX Snow Leopard.

I am trying to create an image with an alpha channel via -alpha copy, then turn off alpha, process the base image, then turn alpha on again. But the result has no alpha channel.


convert -size 128x128 gradient:"gray(255)-gray(0)" -write 1tmp1.png \
-alpha copy -write 1tmp2.png \
-alpha off -write 1tmp3.png \
-fill red -colorize 100% -write 1tmp4.png \
-alpha on 1tmp5.png

1tmp.png has an alpha channel, but 1tmp6 does not. The result is the red, base image without a gradient alpha channel.

Is this a bug or am I misunderstanding something?
Last edited by fmw42 on 2012-08-25T22:44:09-07:00, edited 1 time in total.

User avatar
magick
Site Admin
Posts: 11065
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug -alpha IM 6.7.8.6 Q16

Post by magick » 2012-07-30T17:23:51-07:00

Do you get the correct results with MIFF? Try
  • convert -size 128x128 gradient:"gray(255)-gray(0)" -write 1tmp1.miff \
    -alpha copy -write 1tmp2.miff \
    -alpha off -write 1tmp3.miff \
    -fill red -colorize 100% -write 1tmp4.miff \
    -alpha on 1tmp5.miff
If so, its possible PNG deletes the alpha channel if its entirely opaque. If you feel this is wrong behavior, contact Glenn about supporting an opaque alpha channel.

User avatar
fmw42
Posts: 25572
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -alpha IM 6.7.8.6 Q16

Post by fmw42 » 2012-07-30T18:00:50-07:00

magick wrote:Do you get the correct results with MIFF? Try
  • convert -size 128x128 gradient:"gray(255)-gray(0)" -write 1tmp1.miff \
    -alpha copy -write 1tmp2.miff \
    -alpha off -write 1tmp3.miff \
    -fill red -colorize 100% -write 1tmp4.miff \
    -alpha on 1tmp5.miff
If so, its possible PNG deletes the alpha channel if its entirely opaque. If you feel this is wrong behavior, contact Glenn about supporting an opaque alpha channel.

The result from MIFF is horribly striped (very fine vertical black/white lines) and no red color. I am not even sure I know what is happening there, but looking at the intermediate images, it goes horribly wrong just after the -colorize 100% step, see 1tmp4.miff


It is not a PNG issue. I get the same constant red result with TIFF as PNG.

The proper result should look like a gradient going from transparent to red as in the following:

convert \( -size 128x128 gradient:"gray(255)-gray(0)" -write 2tmp1.png \) \
\( -clone 0 -fill red -colorize 100% -write 2tmp2.png \) \
+swap -alpha off -compose copy_opacity -composite 2tmp3.png


My guess is that it is the -colorize 100% that is overriding the alpha channel or setting it to opaque whether on or off.

As my script used to work a long time ago, I think this has been a problem for quite some time. In the mean-time, I changed my script to use the latter approach. But I think this is a bug and should be fixed, nevertheless.



Try these two tests and you will see that both output images have no alpha channel.

convert logo: -transparent white -alpha off -fill red -colorize 100% -alpha on 1tmp1.png
convert logo: -transparent white -fill red -colorize 100% 1tmp2.png

User avatar
fmw42
Posts: 25572
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -alpha IM 6.7.8.6 Q16

Post by fmw42 » 2012-08-23T10:19:53-07:00

Has anything been decided or done about this issue?

In IM 6.7.9.1 Q16, this still produces an all red image with no transparency.

convert logo: -transparent white -alpha off -channel rgb -fill red -colorize 100% -channel rgba -alpha on tmp1.png


It would be nice, if it worked as it did a long time ago and just affected the non-alpha channels when the alpha is turned off and then on again after the processing. Just like

convert logo: -transparent white -alpha off -channel rgb -fx "u=red" -alpha on tmp2.png

or

convert logo: -transparent white -alpha off -channel rgb -evaluate set 0 -fill red -opaque black -alpha on tmp3.png

User avatar
magick
Site Admin
Posts: 11065
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug -alpha IM 6.7.8.6 Q16

Post by magick » 2012-08-23T15:41:25-07:00

Look for a patch in ImageMagick 6.7.9-2 Beta and let us know if it fixes the problem. Thanks.

User avatar
fmw42
Posts: 25572
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -alpha IM 6.7.8.6 Q16

Post by fmw42 » 2012-08-23T17:54:59-07:00

magick wrote:Look for a patch in ImageMagick 6.7.9-2 Beta and let us know if it fixes the problem. Thanks.
Thanks very much. Both these now work in the latest beta


imb convert logo: -transparent white -alpha off -channel rgb -fill red -colorize 100% -channel rgba -alpha on 1tmp1.png

imb convert logo: -transparent white -alpha off -fill red -colorize 100% -alpha on 1tmp2.png

Post Reply