Indexed-mode images not exported correctly from PLTE headed indexed png
Environment/Versions
- GIMP version: v2.10.36
- Package: https://download.gimp.org/gimp/v2.10/windows/gimp-2.10.36-setup.exe
- Operating System: Windows 10 Pro (Version 22H2 (Build 19045.3693))
Description of the bug
PNG images created in Paint.NET create problems when one attempts to save the PNG as-is or converts to another image format. Problems range from the alpha channel color setting itself into the foreground in any places with transparency, to the image itself being inverted(?) and causing what used to not be transparent to be transparent and all the original transparent spaces being populated with inverted(?) color(s), etc.
Reproduction
Is the bug reproducible? Yes.
Reproduction steps:
- Open a PNG image created by Paint.NET in GIMP.
- Save the image as-is as a PNG image, or attempt to convert to a different image format (targa in my case).
- View the image with a viewer or an editor to see the results, and or check the image data via a hex editor.
…
Expected result:
In the case of PNG: When loading and saving a PNG image that was created with Paint.NET, the saved image should be converted to a standard PNG (if chosen) and not lead to any strange issues with the original image information being stored incorrectly.
In the case of TGA: (Format I use and convert to regularly) When loading and converting a PNG image created by Paint.NET into GIMP's targa format, the saved image shouldn't be compressed in any way (unless I specify to use RLE compression by choice).
Actual result:
PNG images created by Paint.NET and saved as-is when loaded in GIMP and or converted to a different image format causes the image information to be stored and or handled incorrectly.
Additional information
Interestingly enough, if you attempt to convert a Paint.NET based PNG image to targa within GIMP, even if you don't specify to use RLE compression, it gets applied anyways, however if you load the newly converted targa image, then save it as-is (overwriting the original that was loaded) or create a separate targa image, and proceed to not use RLE compression, the saved result will lead to an uncompressed targa image.
The workaround? Load the Paint.NET generated PNG image in Paint.NET, then save the image as a different format (targa in my case), then the information is handled correctly and can be loaded and handled properly when using GIMP. This works in standard workloads, but when it comes to batch conversions, this becomes an issue, Paint.NET doesn't have batch capabilities nor does it have script/plug-in functions to work with in general.
Paint.NET PNG images do not appear to be standard, there seems to be an additional header called "PLTE" applied before the IDAT chunk header. I also noticed that PLTE based PNG images are compressed more than a standard PNG image, which is great for those seeking something smaller, but I think this compression is the root cause of the issues with GIMP acting up with them, which implies that GIMP isn't capable of properly handling the format well at all. This to me seems serious enough of an issue to warrant a fix either through compatibility support or through proper conversion support (or both if you just want to make GIMP a well flexible solution more than it already is).
Image I created for testing:Untitled.tga
Converted to PNG via GIMP:Untitled_PNG-Standard
Converted to PNG via Paint.NETUntitled_PNG-PLTE
Paint.NET PNG saved as-is with GIMP:Untitled_PNG-PLTE_GIMP
Paint.NET PNG converted to TGA via GIMP:Untitled_PNG-PLTE_GIMP.tga