Read a grayscale png.

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
wizard29
Posts: 58
Joined: 2014-03-21T00:40:16-07:00
Authentication code: 6789
Location: Russia, Saint Petersburg
Contact:

Read a grayscale png.

Post by wizard29 »

Hi, everyone.

After last update of IM I found a some weird behaviour of file opening. The grayscale image is opened as totally white image but it is wrong.

Before I used IM "6,9,0,7" version and Magick++ API under OS Windows 7 and everything works fine for png images.
Now I try to use the IM "6,9,1,3" version.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Read a grayscale png.

Post by glennrp »

I wasn't able to reproduce the problem on Ubuntu commandline interface with IM-6.9.1-3 downloaded today. What is your libpng version? run "convert -list format | grep PNG" to find out.
wizard29
Posts: 58
Joined: 2014-03-21T00:40:16-07:00
Authentication code: 6789
Location: Russia, Saint Petersburg
Contact:

Re: Read a grayscale png.

Post by wizard29 »

libpng version is 1.6.12.
wizard29
Posts: 58
Joined: 2014-03-21T00:40:16-07:00
Authentication code: 6789
Location: Russia, Saint Petersburg
Contact:

Re: Read a grayscale png.

Post by wizard29 »

convert.exe utility makes the same result (convert.exe grayscale.png grayscale.jpg).
wizard29
Posts: 58
Joined: 2014-03-21T00:40:16-07:00
Authentication code: 6789
Location: Russia, Saint Petersburg
Contact:

Re: Read a grayscale png.

Post by wizard29 »

By the way, the same issue I have under Mac OS X 10.10.3.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Read a grayscale png.

Post by glennrp »

I relinked my IM-6.9.1-3 with libpng-1.16.12 but still could not replicate your result. I'm getting the expected scribbly drawing.
pngcheck doesn't show anything peculiar about the file:
  • glenn.rp> pngcheck -v *7.png
    File: h777.png (12176 bytes)
    chunk IHDR at offset 0x0000c, length 13
    426 x 227 image, 8-bit grayscale, non-interlaced
    chunk pHYs at offset 0x00025, length 9: 2835x2835 pixels/meter (72 dpi)
    chunk iCCP at offset 0x0003a, length 792
    profile name = Photoshop ICC profile, compression method = 0 (deflate)
    compressed profile = 769 bytes
    chunk cHRM at offset 0x0035e, length 32
    White x = 0.31269 y = 0.32899, Red x = 0.63999 y = 0.33001
    Green x = 0.3 y = 0.6, Blue x = 0.15 y = 0.05999
    chunk IDAT at offset 0x0038a, length 11250
    zlib: deflated, 32K window, maximum compression
    chunk IEND at offset 0x02f88, length 0
    No errors detected in h777.png (6 chunks, 87.4% compression).
Perhaps there is some problem with the color managment chunks (iCCP and cHRM). During conversion
to JPEG format, the cHRM chunk gets discarded but the iCCP chunk is copied into the JPEG.
wizard29
Posts: 58
Joined: 2014-03-21T00:40:16-07:00
Authentication code: 6789
Location: Russia, Saint Petersburg
Contact:

Re: Read a grayscale png.

Post by wizard29 »

Glenn,
Thank you for the response. I think you right. Looks like a conversion problem.

Could someone to clarify this issue?
wizard29
Posts: 58
Joined: 2014-03-21T00:40:16-07:00
Authentication code: 6789
Location: Russia, Saint Petersburg
Contact:

Re: Read a grayscale png.

Post by wizard29 »

When I tried to make conversion from grayscale.png to grayscale1.png I get a warning message that looks like:
convert.exe: profile 'icc': 'GRAY': Gray color space not permitted on RGB PNG `g
rayscale1.png' @ warning/png.c/MagickPNGWarningHandler/1656.

And totally white grayscale1.png as result.
wizard29
Posts: 58
Joined: 2014-03-21T00:40:16-07:00
Authentication code: 6789
Location: Russia, Saint Petersburg
Contact:

Re: Read a grayscale png.

Post by wizard29 »

if I try to convert:
convert.exe grayscale.tif grayscale1.png
everything works as expected. But I get the same warning exception.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Read a grayscale png.

Post by snibgo »

"identify -verbose" shows it contains an ICC profile. Depending on what you are trying to do, you might want to convert it to sRGB and strip the profile:

Code: Select all

convert grayscale.tif -profile sRGB.icc -strip out.tif
snibgo's IM pages: im.snibgo.com
wizard29
Posts: 58
Joined: 2014-03-21T00:40:16-07:00
Authentication code: 6789
Location: Russia, Saint Petersburg
Contact:

Re: Read a grayscale png.

Post by wizard29 »

Snigbo,
Thank you.

The problem is conversion from the grayscale.png. For other grayscale images everything works as expected. I have checked:
grayscale.bmp
grayscale.jpg
grayscale.png
grayscale.tif

All works as I expected except the grayscale.png. I make conversion from all grayscale.* images to the sRGB color space.
wizard29
Posts: 58
Joined: 2014-03-21T00:40:16-07:00
Authentication code: 6789
Location: Russia, Saint Petersburg
Contact:

Re: Read a grayscale png.

Post by wizard29 »

I ran the "identify" utility for the grayscale.png. Result of color map looks weird. Perhaps it is not substantively:

png.txt
jpg.txt
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Read a grayscale png.

Post by snibgo »

Your png.txt and jpg.txt both contain:

Code: Select all

    icc:description: Dot Gain 20%
    icc:manufacturer: Dot Gain 20%
So they contain embedded profiles and have NOT been converted to sRGB.

When you convert to bmp or other format that can't store colour profiles, the embedded profile is silently ignored.

So your bmp version looks different (on Firefox on my computer) to your png version. Firefox recognises the profile and converts it to sRGB.
snibgo's IM pages: im.snibgo.com
wizard29
Posts: 58
Joined: 2014-03-21T00:40:16-07:00
Authentication code: 6789
Location: Russia, Saint Petersburg
Contact:

Re: Read a grayscale png.

Post by wizard29 »

The "convert.exe grayscale.png -profile sRGB.icc grayscale1.png" gives expected result.
wizard29
Posts: 58
Joined: 2014-03-21T00:40:16-07:00
Authentication code: 6789
Location: Russia, Saint Petersburg
Contact:

Re: Read a grayscale png.

Post by wizard29 »

Thank you,
Snigbo.
Post Reply