Unable to open PNG file with kview or PictureViewer; opens fine with other viewers

StackOverflow https://stackoverflow.com/questions/16678455

  •  30-05-2022
  •  | 
  •  

Question

I have a PNG file created using libPNG library. The file opens perfectly on Windows picture viewer and MS Paint, but opening with kview (on Linux RHEL5) or QuickTime PictureViewer (on Windows) fails - the former reports a "libpng read error whereas the latter reports the file as being corrupted. A similar problem is seen when trying to process the PNG using ImageMagick library on Linux. Given that the PNG opens fine on some applications, it doesn't seem that the file is really corrupted; I therefore suspect some problem with version compatibility, but I am not sure. I tried searching the web but couldn't find any information on the root cause or a solution to this problem. Can someone please guide me on this?

Was it helpful?

Solution

Judging from the example image you posted in the comments, the problem is that your PNG lacks the ending IEND chunk -something you can test by opening it with tweakpng and inspecting the structure visually, or choosing "Check Validity-F5". It is somewhat predictable that those kind of PNG are displayed by some viewers and rejected by others.

If you are using libpng, it seems you forgot to call png_write_end()

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top