8

I am using GraphicsMagick and currently running into the following issue:

when executing

gm identify <filename>.png

I'm getting the following error:

gm identify: CgBI: unknown critical chunk (<filename>.png)
gm identify: Request did not return an image.

This is a png extracted from an iPhone. Though it may not contain an actual image, I do need the image info.

Tried opening it with several editors:

  1. The png does open in Paint with the right height x width but as completely white.
  2. The png does not open in GIMP, saying it might be corrupted
  3. The png does open in Paint.net with the right height x width as a transparent image

Using the debug parameter provides the following line:

libpng-1.5.14 error: CgBI: unknown critical chunk

I'm running the latest GraphicsMagick (1.3.18).

Does anyone know what's going on, and how I will be able to get this to return the image info?

Thanks in advance.

Glenn Randers-Pehrson
  • 11,940
  • 3
  • 37
  • 61
bknopper
  • 1,193
  • 12
  • 28

2 Answers2

7

The PNG you are trying to read has been run through Apple's "Xcode" version of pngcrush, which creates files that aren't PNGs. I believe Apple's pngcrush also has the capability of undoing the damage and more-or-less restoring the original PNG, using the "-revert-iphone-optimizations" option, although it's not mathematically possible to restore the color channels exactly for transparent or semitransparent pixels.

Glenn Randers-Pehrson
  • 11,940
  • 3
  • 37
  • 61
  • This indeed may be the problem. Do you know how I should proceed to recover the original PNG through pngcrush (or at least undo the damage)? – bknopper Dec 19 '13 at 07:57
  • 1
    See this [iPhone Dev Wiki article](http://iphonedevwiki.net/index.php/CgBI_file_format#Decoding) about decoding such PNG files. – rdvdijk Dec 19 '13 at 15:30
  • You have to use Apple's pngcrush, not the real pngcrush. I don't know the exact option but it's something like "-revert-iphone". See the Wiki referenced in rdvdijk's answer above. – Glenn Randers-Pehrson Dec 19 '13 at 16:48
  • 1
    A full story, plus a remedy, can be found at my website as well: http://www.jongware.com/pngdefry.html – Jongware Mar 29 '14 at 19:58
3

set in xcode build setting this flag to NO

Remove Text Metadata From PNG Files = NO

Muhammad Shauket
  • 2,643
  • 19
  • 40