0
votes

I'm trying to reduce the channel-bit-depth of PNGs from 8 to 4 using Magick++. I'm using the following code to do this:

Image * img = new Image("./image8.png");
img->channelDepth(ChannelType::AllChannels,4);
img->write("./image4.png");

For color-images, this works great. But for grayscale images, ImageMagick does something strange. It squeezes the whole content into the left half of the image and displays random pixels in the right half.

For example this baboon here: enter image description here

turns into this with the code above:enter image description here

Does anybody have an explanation for this behavior and/or an idea how I can solve this?

Or is this maybe even a bug of image magick?

1
Looks like a bug. What version of ImageMagick are you using? The current version (6.9.2-8) doesn't exhibit the bug when running it from the commandline: "convert 5koQD.png -depth 4 depth4.png"Glenn Randers-Pehrson
I'm also not able to reproduce with Magick++ 6.9.2 Q16emcconville
Oh well, my version is a few months old, so I'm going to try the newest version. Would be great if it just was a bug and is already fixed :)Van Coding
You were right guys! The newest verision of ImageMagick does not have this bug anymore. Thanks :) I'm not sure if I should delete this question now or ask you to post an answer to this... What do you think?Van Coding

1 Answers

2
votes

Looks like a bug in your version of ImageMagick. The current version (6.9.2-8) doesn't exhibit the bug when running it from the commandline: "convert 5koQD.png -depth 4 depth4.png"