Can’t open certain PNG images, krita refuses with an error: “Unknown error…”. There is no rhyme or reason to this and I can’t pinpoint the problem, it’s neither resolution, size or extension. Probably something in the code. No other application have issues with files in question, just krita. I also can save them in PSD trough photoshop and open that in krita as a workaround.
One of the files krita have troubles with - https://dropmefiles.com/baDEe
Hi
On my side, not possible to open the file with Geeqie or Gimp.
Both consider file as invalid.
Krita return the message libpng error: iTXt: chunk data is too large
(but you need to execute Krita from console to get the message, as the message is returned to error stream by libpng)
Looking the file, the iTXt
chunk contains ~22MB of XML data… that’s just crazy.
Looking deeper about these data, it’s seems that photoshop store some extra information to file:
XML:com.adobe.xmp.....<?xpacket begin="." id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c148 79.164036, 2019/08/13-01:06:57 ">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/" xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#" xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmp:CreatorTool="Adobe Photoshop CC 2019 (Windows)" xmp:CreateDate="202
0-10-16T23:17:01+09:00" xmp:MetadataDate="2020-12-29T19:41:14+03:00" xmp:ModifyDate="2020-12-29T19:41:14+03:00" xmpMM:InstanceID="xmp.iid:c790ffa3-0263-f846-a118-108ac6db967a" xmpMM:DocumentID="adobe:docid:photoshop:6aa3b8ec-dbe0-224f-b5fe-9a0be8518e38" xmpMM:OriginalDocumentID="xmp.did:522b7b2e-23f6-0d41-a17d-206d2ecc01ee" photoshop:ColorMode="3
" dc:format="image/png">
<xmpMM:History>
<rdf:Seq>
<rdf:li stEvt:action="created" stEvt:instanceID="xmp.iid:522b7b2e-23f6-0d41-a17d-206d2ecc01ee" stEvt:when="2020-10-16T23:17:01+09:00" stEvt:softwareAgent="Adobe Photoshop CC 2019 (Windows)"/>
<rdf:li stEvt:action="saved" stEvt:instanceID="xmp.iid:a8b55d82-2676-c142-8081-2724f5b2f672" stEvt:when="2020-10-16T23:17:01+09:00" stEvt:softwareAgent="Adobe Photoshop CC 2019 (Windows)" stEvt:changed="/"/>
<rdf:li stEvt:action="saved" stEvt:instanceID="xmp.iid:c790ffa3-0263-f846-a118-108ac6db967a" stEvt:when="2020-12-29T19:41:14+03:00" stEvt:softwareAgent="Adobe Photoshop 21.0 (Windows)" stEvt:changed="/"/>
</rdf:Seq>
</xmpMM:History>
<photoshop:DocumentAncestors>
<rdf:Bag>
<rdf:li>0</rdf:li>
<rdf:li>00004BD9B88877208E379E8DD31FEEA2</rdf:li>
<rdf:li>0000515995CA7B3EEA99CA1008D30D20</rdf:li>
...
<rdf:li>xmp.did:fff4b386-160b-45d7-8975-29ceef56c88c</rdf:li>
<rdf:li>xmp.id:1D328185C366E211A575B3112223C242</rdf:li>
<rdf:li>xmp.id:431719A10E2068118C14BA56883396C7</rdf:li>
<rdf:li>xmp.id:A2A918B357206811822AF8825C3D3DDC</rdf:li>
</rdf:Bag>
</photoshop:DocumentAncestors>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end="r"?>
=> Around ~390000 line of this in chunk…
Looking XMP Specification about <photoshop:DocumentAncestors>
markup, page 32: “if the source document for a copy-and-paste or place operation has a document ID, that ID is added to this list in the destination document’s XMP”
Not really sure to understand what it really means and why photoshop generate a such amount of data…
I’m not surprised to see a such chunk content can’t be properly parsed by software (here, problem seems to came from library libpng so not sure that problem of invalid files can be solved in Krita…)
But I’m surprised to see that a such chunk is not ignored (easy to do: just jump to next chunk) because chunk is technically valid (maximum allowed size is not reached) and other chunk in file are valid too.
If I remove the invalid chunk, png file is now correct, do only ~29KB size, and can be read by Krita (and other software I have)
Grum999
Are these “certain png images” created by Photoshop then?
Maybe it’s in the Export options or some other options in there.
GIMP, Inkscape, Darktable, RawTherapee and my standard image viewer can not open that .png file.
What applications do you have that can open that .png file?
Gimp and RawTherapee also use libpng and return the same error libpng error: iTXt: chunk data is too large
But something strange: I can read png file with a PyQt QImageReader class…
Not sure to understand why, as PyQt also use libpng
Didn’t took a look in Krita source code to check if Krita use a Qt QImageReader or do a direct call to libpng library’s functions…
Grum999
@Gnomforce, history in file tells:
created 2020-10-16T23:17:01+09:00 Adobe Photoshop CC 2019 (Windows)
saved 2020-10-16T23:17:01+09:00 Adobe Photoshop CC 2019 (Windows)
saved 2020-12-29T19:41:14+03:00 Adobe Photoshop 21.0 (Windows)
If you still have original png file saved with photoshop CC 2019, can you tell us their file size, and if you open/save them with photoshop 21, did the size changed ?
It’s not a forum to help about photoshop problems, but if your goal is to switch to Krita and your not able to use files saved by photoshop, we can try to find a solution
I don’t know Photoshop now, but it might have an option to not save XMP Metadata in (PNG) files.
Grum999
So, it’s simply a rare case caused by photoshop and not a krita related issue? Thank you for that info, its good to know. Unfortunately the file was not created by me and I know nothing about how it was saved, I never encountered similar issues, that’s why I was not sure what’s causing this. By the way SAI and SonyVegas opens this just fine, blender have issues, don’t have anything else to open the images with from my end.
Data saved by photoshop are technically valid, but:
- It’s just crazy, and saving 22MB of useless metadata for a 30KB image might be a bug on photoshop side
- It’s not a Krita related issue, but a libpng related issue
This means that all softwares using the libpng (or the same version of libpng) might have the problem
On my side I consider it’s an issue because if libpng consider the chunk being too large, the iTXt chunk is optional and only contains informative data that softwares don’t need to be able to read and display image.
Don’t know if it’s possible or not to tell libpng to ignore this…
Blender also use libpng and returns the same error message about chunk data too large…
Grum999
Krita uses libpng directly. PNG_USER_CHUNK_MALLOC_MAX is a libpng config variable, so it depends on how libpng is configured whether big chunks can be read. The default value seems to be 8000000 bytes, or 8 MB.
Note that krita brush presets are also PNG files with the parameters contained in the iTXt chunk, and that might be quite a bit of xml data as well.
ETA: I’m looking into a workaround by removing any “user limits”:
png_set_chunk_malloc_max(png_ptr, 0);
I guess that depends on the build of libpng, Qt and PyQt, because when I checked with gwenview, which uses qimageio, I couldn’t load the png file either – and I’ve checked Qt’s png reader code and ours, and everything is setup for error handling the same way.
That worked: Remove the "png user limits" when reading/write png files (12721ada) · Commits · Graphics / Krita · GitLab
(Note that this is a bit dangerous, a hand-crafted png file with a chunk that’s bigger than your computer can handle will likely crash krita or make your computer run out of memory: and since such a chunk can still be very small when compressed you might notice it from the file. But since we’ve always said no to artificial limits, I think it’s the right thing to do. I’m also patching the version of Qt we use in our builds.)
Maybe version differs, I don’t know.
On my side, using my plugin BuliCommander on Krita appimage (PyQt 5.13 I think) using QImage to read png files, is able to open and display the png file.
Maybe qt/pyqt compilation options are not the same and/or version of library is not the same…
Grum999
This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.