-
Notifications
You must be signed in to change notification settings - Fork 329
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
Add option to zopflipng to not change the colorspace #34
Comments
I just ran into the issue, where I had some images in grayscale+alpha mode, which FWIW, I wouldn't mind having an option so that I can at least enforce preserving the color mode in these situations. But IMO |
At least the issue, I experienced only seems to happen with rather small images, and it seems to be a bug, as that code path while handling different color modes only considers RGB and RGBA. Fixing it is trivial: diff --git a/src/zopflipng/zopflipng_lib.cc b/src/zopflipng/zopflipng_lib.cc
index b93bb18..0a72059 100644
--- a/src/zopflipng/zopflipng_lib.cc
+++ b/src/zopflipng/zopflipng_lib.cc
@@ -239,7 +239,10 @@ unsigned TryOptimize(
// Too small for tRNS chunk overhead.
if (w * h <= 16 && profile.key) profile.alpha = 1;
state.encoder.auto_convert = 0;
- state.info_png.color.colortype = (profile.alpha ? LCT_RGBA : LCT_RGB);
+ if (profile.colored)
+ state.info_png.color.colortype = (profile.alpha ? LCT_RGBA : LCT_RGB);
+ else
+ state.info_png.color.colortype = (profile.alpha ? LCT_GREY_ALPHA : LCT_GREY);
state.info_png.color.bitdepth = 8;
state.info_png.color.key_defined = (profile.key && !profile.alpha);
if (state.info_png.color.key_defined) { Adding an option to never change the color mode, would be another story though. |
#130 ? |
Output to a generic that implements Write
Original issue reported on code.google.com by
[email protected]
on 14 Jan 2014 at 4:33Attachments:
The text was updated successfully, but these errors were encountered: