-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Saving an RGB image as PNG can result in a grayscale image #150
Comments
I would also note that I think this is a defect with upstream ImageMagick rather than this package since writing a lossless image should be round-tripable. But I think there's little chance of upstream changing this default since it's clear they probably went out of their way to have the current behavior. That said, we should at least have a way to control the behavior in this package, and maybe even change the default if it's reasonably easy to do and there are no major objections. |
If I have an RGB image where it so happens that for each pixel, all the channel values are the same, then saving it as a PNG results in a grayscale image.
Minimal example to reproduce:
And I get something like
"/tmp/tmpbfYfcd: PNG image data, 1 x 1, 1-bit grayscale, non-interlaced"
.I've looked around, and this seems to be a default optimization ImageMagick performs when saving PNGs in order to produce the smallest PNG possible.
The resultant workaround is to "convert" the file back to RGB by explicitly setting the PNG color type to RGB, such as by doing this in Julia:
This obviously an extremely hacky workaround. I would much prefer to control the output color type directly when saving the image; this workaround would get even uglier if trying to save to an arbitrary IO stream instead of directly to a file.
Version info:
Project status:
The text was updated successfully, but these errors were encountered: