ImageMagick 6 Liquid Rescale: Alpha Channel Gets Discarded

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
squish
Posts: 2
Joined: 2015-05-13T09:42:36-07:00
Authentication code: 6789

ImageMagick 6 Liquid Rescale: Alpha Channel Gets Discarded

Post by squish »

There is a bug in ImageMagick 6 where the liquid rescale function discards the opacity channel of an image. What seems to happen is that liblqr is being passed the image with the alpha channel, but ImageMagick forgets to take it back after the transformation, because of a typo.

Here's a patch:
http://pastebin.com/nH3xE2ty
I also changed the contorted "if(image->matte != MagickFalse)" to "if(image->matte == MagickTrue)". I guess I could simply write "if(image->matte)" but I'm not sure what the coding conventions are for ImageMagick.

Finally, I have no idea what happens in ImageMagick 7. It might be nice if someone with ImageMagick 7 could test the -liquid-rescale function on an image with transparency to see if it is retained.

There are also a few more issues with the liquid rescale function, and I plan opening new threads for them.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: ImageMagick 6 Liquid Rescale: Alpha Channel Gets Discarded

Post by dlemstra »

We have fixed the issue that you reported and this will be fixed in ImageMagick 6.9.1-3. We are also going to make some other changes. Not sure if they will be in for the next release but we will changing the data type that is used to 'talk' with liblqr depending on the build of ImageMagick (Q8/Q16/HDRI).
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
squish
Posts: 2
Joined: 2015-05-13T09:42:36-07:00
Authentication code: 6789

Re: ImageMagick 6 Liquid Rescale: Alpha Channel Gets Discarded

Post by squish »

Thanks for fixing the bug and reviewing the function.

Another issue with the liquid rescale function in both IM 6 and 7 is that there is this block of code that is unneeded and makes the function act incorrectly when resizing to a size equal to or larger than 200%.

It`s the block of code that starts by "if ((columns >= (2*image->columns)) || (rows >= (2*image->rows)))" and claims to "Honor liquid resize size limitations". This is unneeded, at least in the recent versions of liblqr, since if asked to rescale a image to 200% or more, it would automatically do it in multiple steps. And even if there was such a limitation, the correct way to handle it would be for ImageMagick to apply the liquid-rescale multiple times, not how it currently does it.

Everything should continue working if the block is simply removed.
Post Reply