Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When trying to read a large PNG file, GraphicsMagick command

gm convert pallaso1.png pallars-sobira.jpg

just displays this error

c:\progs\GraphicsMagick\gm convert: Read Exception (PALLASO1.PNG).

I have the latest GM version, GraphicsMagick 1.3.12 2010-03-08 Q16 . I have tried execution with -debug all option and the captured log is

11:03:31 0:01 0.000u 6688 module.c/OpenModule/1447/Configure:
  Searching for module "PNG" using file name "IM_MOD_RL_PNG_.dll"
11:03:31 0:01 0.000u 6688 module.c/FindMagickModule/672/Configure:
  Searching for coder module file "IM_MOD_RL_PNG_.dll" ...
11:03:31 0:01 0.000u 6688 module.c/FindMagickModule/706/Configure:
  Searching for module file "IM_MOD_RL_PNG_.dll" in path "C:\Program Files\GraphicsMagick\"
11:03:31 0:01 0.000u 6688 utility.c/IsAccessible/2842/Configure:
  Found: C:\Program Files\GraphicsMagick\IM_MOD_RL_PNG_.dll
11:03:31 0:01 0.000u 6688 module.c/OpenModule/1469/Configure:
  Opening module at path "C:\Program Files\GraphicsMagick\IM_MOD_RL_PNG_.dll" ...
11:03:31 0:01 0.000u 6688 module.c/OpenModule/1505/Configure:
  Function "RegisterPNGImage" in module "PNG" at address 67750000
11:03:31 0:01 0.000u 6688 module.c/OpenModule/1522/Configure:
  Function "UnregisterPNGImage" in module "PNG" at address 677491A0
11:03:31 0:01 0.000u 6688 blob.c/OpenBlob/2361/Blob:
  Opening Blob for image 0x00B2DDB8 using ReadBinary mode ...
11:03:31 0:01 0.000u 6688 blob.c/OpenBlob/2544/Blob:
    I/O buffer set to 16384 bytes
11:03:31 0:01 0.000u 6688 blob.c/OpenBlob/2564/Blob:
    opened file "PALLASO1.PNG" as FileStream blob 0x00B2F7AC
11:03:31 0:01 0.000u 6688 blob.c/OpenBlob/2577/Blob:
    read 2053 magic header bytes
11:03:31 0:01 0.000u 6688 blob.c/CloseBlob/856/Blob:
  Closing FileStream blob 00B2F7AC
11:03:31 0:01 0.000u 6688 pixel_cache.c/DestroyCacheInfo/1733/Cache:
  destroy cache 
11:03:31 0:01 0.000u 6688 blob.c/DestroyBlob/989/Blob:
  Destroy blob, image=00B2DDB8, filename="PALLASO1.PNG"
11:03:31 0:01 0.000u 6688 constitute.c/ReadImage/8235/Blob:
  Magick=PNG, Filename=PALLASO1.PNG
11:03:31 0:01 0.000u 6688 constitute.c/ReadImage/8347/Coder:
  Invoking "PNG" decoder (Portable Network Graphics) subimage=0 subrange=0
11:03:31 0:01 0.000u 6688 png.c/ReadPNGImage/2785/Coder:
  enter ReadPNGImage()
11:03:31 0:01 0.000u 6688 blob.c/OpenBlob/2361/Blob:
  Opening Blob for image 0x00B2DDB8 using ReadBinary mode ...
11:03:31 0:01 0.000u 6688 blob.c/OpenBlob/2544/Blob:
    I/O buffer set to 16384 bytes
11:03:31 0:01 0.000u 6688 blob.c/OpenBlob/2564/Blob:
    opened file "PALLASO1.PNG" as FileStream blob 0x00B2F7AC
11:03:31 0:01 0.000u 6688 blob.c/OpenBlob/2577/Blob:
    read 2053 magic header bytes
11:03:31 0:01 0.000u 6688 png.c/ReadOnePNGImage/1610/Coder:
    enter ReadOnePNGImage()
11:03:31 0:01 0.000u 6688 png.c/ReadOnePNGImage/1762/Coder:
      PNG width: 2725, height: 3739
11:03:31 0:01 0.000u 6688 png.c/ReadOnePNGImage/1766/Coder:
      PNG color_type: 3, bit_depth: 8
11:03:31 0:01 0.000u 6688 png.c/ReadOnePNGImage/1769/Coder:
      PNG compression_method: 0
11:03:31 0:01 0.000u 6688 png.c/ReadOnePNGImage/1772/Coder:
      PNG interlace_method: 0, filter_method: 0
11:03:31 0:01 0.000u 6688 png.c/ReadOnePNGImage/2111/Coder:
      Reading PNG PLTE chunk: number_colors: 256.
11:03:31 0:01 0.000u 6688 png.c/ReadOnePNGImage/2181/Coder:
      Reading PNG IDAT chunk(s)
11:03:31 0:01 0.000u 6688 png.c/ReadOnePNGImage/2193/Coder:
      Converting PNG pixels to pixel packets
11:03:31 0:01 0.000u 6688 resource.c/AcquireMagickResource/224/Resource:
  pixels +9.7MP/----/409.6MP
11:03:31 0:01 0.000u 6688 resource.c/AcquireMagickResource/224/Resource:
  memory +97.2MB/97.2MB/1.6GB
11:03:31 0:01 0.000u 6688 pixel_cache.c/OpenCache/3050/Cache:
  open PALLASO1.PNG[0] (97.2M)
11:03:31 0:01 0.250u 6688 png.c/PNGWarningHandler/1364/Coder:
    libpng-1.2.43 warning: Expected 8 bytes; found 0 bytes
11:03:31 0:01 0.250u 6688 png.c/PNGWarningHandler/1369/Coder:
  Expected 8 bytes; found 0 bytes (PALLASO1.PNG)
11:03:31 0:01 0.250u 6688 png.c/PNGErrorHandler/1350/Coder:
    libpng-1.2.43 error: Read Exception
11:03:31 0:01 0.250u 6688 png.c/PNGErrorHandler/1353/Coder:
  Read Exception (PALLASO1.PNG)
11:03:31 0:01 0.250u 6688 png.c/ReadOnePNGImage/1680/Coder:
    exit ReadOnePNGImage() with error.
11:03:31 0:01 0.250u 6688 blob.c/CloseBlob/856/Blob:
  Closing FileStream blob 00B2F7AC
11:03:31 0:01 0.250u 6688 resource.c/LiberateMagickResource/752/Resource:
  memory -97.2MB/0B/1.6GB
11:03:31 0:01 0.250u 6688 pixel_cache.c/DestroyCacheInfo/1733/Cache:
  destroy cache PALLASO1.PNG[0]
11:03:31 0:01 0.250u 6688 blob.c/DestroyBlob/989/Blob:
  Destroy blob, image=00B2DDB8, filename="PALLASO1.PNG"
11:03:31 0:01 0.250u 6688 png.c/ReadPNGImage/2833/Coder:
  exit ReadPNGImage() with error.
11:03:31 0:01 0.250u 6688 constitute.c/ReadImage/8366/Coder:
  Returned from "PNG" decoder, returned image is NULL!
c:\progs\GraphicsMagick\gm convert: Read Exception (PALLASO1.PNG).
11:03:31 0:01 0.250u 6688 magick.c/DestroyMagick/153/Configure:
  Destroy Magick
11:03:31 0:01 0.250u 6688 module.c/UnloadModule/2180/Configure:
  Unloading "JPEG" module ...
11:03:31 0:01 0.250u 6688 module.c/UnloadModule/2180/Configure:
  Unloading "PNG" module ...

Edit: I can reproduce this problem with a complete set of image files, in fact all of the image files from the same map publisher have the same problem. And the same files look good with different image viewers and image editors. It's just GM that complains on them.

The hex dump of the file header is here

0000  89504E470D0A1A0A-0000000D49484452 ëPNG........IHDR
0010  00000AA500000E9B-0803000000861588 ...Ñ...ø.....å.ê
0020  EC00000300504C54-45C65D5FF8C7C87C ý....PLTEã]_°Ã╚|
0030  66697B4F56CB7F8E-AE848CEA91AACA4C fi{OV╦⌂Ä«äîÛæ¬╩L
0040  75D593A8E5749ABE-6281F8C8D8D8628D uıô¿ÕtÜ¥bü°╚ÏÏbì
0050  E5B7C89A385FD4A6-B8300818CA3171E6 ÕÀ╚Ü8_Ȫ©0..╩1qµ
0060  498B4F0D2A711940-331724C40A65E80E IïO.*q.@3.$─.eÞ.
0070  7DE8C8D8D40A7696-0C57F3D8E8B891AB }Þ╚ÏÈ.vû.W¾ÏÞ©æ½
0080  180818D8C2D8F8E8-F89979AC4A2A82AC ...Ï┬Ï°Þ°Öy¼J*é¼
0090  A7BA080818E8E8F8-BDC7D8CED8E8D8E8 º║...ÞÞ°¢ÃÏ╬ÏÞÏÞ
00A0  F88BA7BA7A97A9AF-D7F00B202C8FCCEE °ïº║zù®»Î­. ,Å╠¯
00B0  C8E8F85FB5D371C7-E73A64737DB8CDA2 ╚Þ°_ÁËqÃþ:ds}©═ó
00C0  B8C00EB4E722363C-B8E8F609A8CC91C8 ©└.┤þ"6<©Þ÷.¿╠æ╚
00D0  D33EAABD61A4B109-A5B74F8F94324C4E Ë>¬¢añ▒.ÑÀOÅö2LN
00E0  76B1B70B939CB0D6-D80818186D94947F v▒À.ô£░ÍÏ...möö⌂
00F0  A8A8C8E8E8DCF8F8-C8D8D8D8E8E86668 ¿¿╚ÞÞ▄°°╚ÏÏÏÞÞfh

Any idea why this happens? some hints to determine and solve the problem? might it be a bug in gm?

share|improve this question
add comment

1 Answer

libpng-1.2.43 warning: Expected 8 bytes; found 0 bytes

Any idea why this happens?

Either the PNG image does not conform to the standard or libpng-1.2.43 has a bug. I would first investigate the former hypothesis (bad PNG).

  • Can other graphics programs load the PNG file?
  • What does a hex dump of the first 100 bytes show?
  • Can you upload the image to a public image repository?

I recommend you check the integrity of the PNG file


Update: a quick look at the hex dump:

The first eight bytes 89504E470D0A1A0A are the standard PNG header and are correct.

The PNG header should be followed by a "chunk". Each chunk has four parts: length, header, data and checksum.

Chunk 1
The length is a four byte unsigned integer 0000000D meaning 13 bytes of data.
The header is 49484452 or "IHDR" which is defined as a 13 byte chunk.
The data is 00 00 0A A5 00 00 0E 9B 08 03 00 00 00
The checksum is 861588EC

Chunk 2
The length is 00000300 (768 decimal)
the header is 504C5445 "PLTE" (a palette of 100 three-byte RGB values)
The data is C65D5FF8C7C87C…

So it certainly looks valid, although there could be a problem later on.

I would check the whole file using the pngcheck program referred to above.

share|improve this answer
    
Thanks for the suggestion. I am editing my question with more info on the file, which looks good in all the image editors and viewers I have tried it on. –  PA. Oct 3 '11 at 10:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.