Bug 385384

Summary: Some PNG files produced by acdsee can't be displayed
Product: [Applications] okular Reporter: Alexander Trufanov <trufanovan>
Component: generalAssignee: Okular developers <okular-devel>
Status: RESOLVED FIXED    
Severity: normal CC: nate, simonandric5
Priority: NOR    
Version: 1.2.70   
Target Milestone: ---   
Platform: Debian stable   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: test png image

Description Alexander Trufanov 2017-10-05 06:10:18 UTC
Created attachment 108176 [details]
test png image

Hi,
I've got a png file that could be opened in gwenview, GIMP and ImageMagick. But can't be viewed in Okular. My app had the same problem so I dig into gwenview sourcecode to find the solution and now would like to share my findings.

As gwenview my app uses Qt's QImage/QImageReader to load this png file. And Qt uses libpng1.6.28-1 that prints in std::cout "libpng error: Read Error" in both cases. But gwenview ignores this error and still able to show image. Bcs instead of `void QImage::load(...)` or `QImage QImageReader::read()` it invokes `bool QImageReader::read(QImage *)`. And it ignores its result value if returned QImage is valid.

This allowed me to workaround problem in my app.

Gwenviews code: 
The log error [here](https://github.com/KDE/gwenview/blob/1259680d9295bf4d36f481d9a2002639738ff00d/lib/document/loadingdocumentimpl.cpp#L317) but as loadImageData() is a void function and mImage still contains valid image the app displays it as usual.

My assumption is that png has incomplete or incorrect set of flags in header so libpng reports error while still loads image data to RAM.

A test png is attached.
I was told that this was a tiff file (result of scanning) that was converted to png with acdsee v3.1 under Win.
Comment 1 Nate Graham 2017-10-12 04:53:26 UTC
Thanks for the bug and the investigation. Please feel free to submit a patch on http://phabricator.kde.org/!
Comment 2 Alexander Trufanov 2017-11-07 17:57:45 UTC
The workaround is proposed on https://phabricator.kde.org/D8415