Hi,
I have 2 test scenarios:
First converting 16 bit Grayscale produces, 48 bit RGB.
Second converting 8 bit Grayscale produces, 24 bit RGB.
Tested using this image:
16 bit grayscale: http://cosmin.users.sourceforge.net/tes ... 6g_lin.png
8 bit grayscale: http://upload.wikimedia.org/wikipedia/c ... _image.png
performing these convert commands:
convert grayscale16.png grayscale16_2.png
Changes bit depth to 48 bit RGB
convert grayscale8.png grayscale8_2.png
changes bit depth to 24 bit RGB
I tested using ImageMagick 6.9.1-4
Debugged into png.c and seems like ping_have_color is defaulted to MagickTrue, and never gets set to MagickFalse, or somehow the logic needs to set ping_color_type=(png_byte) PNG_COLOR_TYPE_GRAY;
Converting grayscale png affects bit depth
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Converting grayscale png affects bit depth
IM does not seem to honor -define png:color-type=0 when using it in your convert, either.
The PNG developer glennrp will have to take a look and inform us further.
The PNG developer glennrp will have to take a look and inform us further.
Re: Converting grayscale png affects bit depth
Thank you! I already PM Glen.
Re: Converting grayscale png affects bit depth
It's due to a recent change to avoid inspecting every pixel; there was a complaint that it was too costly.albertisi wrote:Hi,
Debugged into png.c and seems like ping_have_color is defaulted to MagickTrue, and never gets set to MagickFalse, or somehow the logic needs to set ping_color_type=(png_byte) PNG_COLOR_TYPE_GRAY;
Re: Converting grayscale png affects bit depth
Yes Glen, I was complaining about it...
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Converting grayscale png affects bit depth
Glenn,
Perhaps you can still do what you did to speed up things, but respect the -define png:color-type=0 when used to process it so it keeps the grayscale.
Perhaps you can still do what you did to speed up things, but respect the -define png:color-type=0 when used to process it so it keeps the grayscale.
Re: Converting grayscale png affects bit depth
Here is the updated png.c.
All i did was flipped the ping_have_color default value from MagickTrue to MagickFalse. It fixes my problem with performance, and bit depth. Tested it in my workflows with different images.
My patch is here:
File: png.c
line: 7969
Not sure how to submit it, so i am posting it here.
All i did was flipped the ping_have_color default value from MagickTrue to MagickFalse. It fixes my problem with performance, and bit depth. Tested it in my workflows with different images.
My patch is here:
File: png.c
line: 7969
Code: Select all
ping_have_blob=MagickFalse;
ping_have_cheap_transparency=MagickFalse;
ping_have_color=MagickFalse; //MagickTrue; //Set Default to False, for Grayscale img handling
ping_have_non_bw=MagickTrue;
ping_have_PLTE=MagickFalse;