Title: QImage cannot read (most) of my images Post by: katzenzakis on February 03, 2021, 03:00:39 AM I am evaluating QImage, which seems a very capable app. However it cannot read most of my image files. It fails with a "Report zero pixels as height or width" message (see attached). I have also attached XPlorer2 (WinExplorer replacement) view showing it's reading of dimensions etc and view of actual files. The files can be read with no faults by Xplorer2, ImageEye, Photoshop, Paint etc. I cannot find any logs which may indicate the actual reason for failure. Certainly the zero pixels error message is spurious.
My app is FractalCanvas an app written in java which generates PNG files in 24 bit RGB format (using PNGJ library). Title: Re: QImage cannot read (most) of my images Post by: katzenzakis on February 03, 2021, 03:01:47 AM Here is an example image file
Title: Re: QImage cannot read (most) of my images Post by: BrianPrice on February 05, 2021, 11:04:00 AM The file wouldn't open in Photoshop either, see screenshot. It opened in Affinity Designer, and it opened in QI when I re-exported it.
Title: Re: QImage cannot read (most) of my images Post by: katzenzakis on February 08, 2021, 06:49:37 AM It opens OK in CS6 but not in the latest version. The "unexpected EOF" may be a clue as to why QImage fails. Resaving files from CS6 is a workaround....
Title: Re: QImage cannot read (most) of my images Post by: admin on February 08, 2021, 02:22:41 PM I looked at the PNG and there does appear to be some sort of formatting error. When I read the header to determine things like color space, resolution, etc. there is an error reading the header and the information is not returned. At that point, I get an empty image so Qimage reports zero pixels in width/height. I'll see if there is an easy way to work around it and still read the image but there may be nothing I can do as it looks like a corrupted PNG.
Regards, Mike Title: Re: QImage cannot read (most) of my images Post by: katzenzakis on February 09, 2021, 07:07:12 AM Thanks for the pointers. I found the problem. In refactoring to use multiple cores, I had moved adding the comment section to after generating the image. Most programs seem to ignore this but some are a little more sensitive. With the comment section back before the image chunks, QImage and the new Photoshop can read all of my files.
Title: Re: QImage cannot read (most) of my images Post by: admin on February 09, 2021, 06:59:59 PM Sounds good. I could see how having comments after the image chunks could cause a problem in some apps as that doesn't appear to follow the PNG spec, at least from my quick look at the general specs:
https://en.wikipedia.org/wiki/Portable_Network_Graphics Looks like all critical and ancillary chunks are supposed to appear in the header... before the image chunks. Thanks for the followup though. That would explain why, when I traced the code in Qimage, it looked like some of the header/image reading functions were getting "invalid" data. Mike |