[Resizing] Discarded RGB values when alpha is zero

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Locked
loremipsum
Posts: 2
Joined: 2020-03-26T09:01:14-07:00
Authentication code: 1152

[Resizing] Discarded RGB values when alpha is zero

Post by loremipsum »

Hello everyone!

I have an issue with the Magick++ API (v7.0.10.2) when I try to resize an RGBA image. I noticed that in the output, when the alpha is zero for a pixel, all RGB components are erased and set to zero for that pixel. This is problematic because the image contains valuable data even when the pixels are completely transparent, and that information is lost.

Code: Select all

Magick::Image input(input_file);
if (options.flip_image) {
    input.flip();
}
input.resize(Magick::Geometry(image.px_width, image.px_height));
Magick::Blob blob;
input.write(&blob, "RGBA");
I get the same incorrect behavior using the command line util:

Code: Select all

$ convert in.png -resize 512x512 out.png
But I was able to get the proper resizing using this:

Code: Select all

$ convert in.png -channel RGBA -separate -resize 512x512 -combine out.png
My question is: how do I apply this to the Magick++ API?

EDIT:

Here is an image example:

Source image
RGBA with alpha as transparency : Image
RGB channels only : Image (notice the three dots)
Alpha channel alone : Image

Destination image (scaled down by half its size)
RGBA with alpha as transparency : Image
RGB channels only : Image (the three dots are lost!)

Thanks for you help!

Locked