Jump to content

Paint.NET fails to save the PHYS chunk into png files - Ouch


woofster

Recommended Posts

I have been fighting this for.... tooo long.

We have some CMS software that terminates whenever we try to insert a png that was saved with paint.net. We discovered that the Microsoft Photo Editor and ifranview created png files that worked OK, but Paint.net ... trouble.

After extensive research, we believe we found the answer: Paint.NET does not save the image DPI into the PHYS chunk in PNG files.

This section of the PNG file is documented here:

http://www.libpng.org/pub/png/book/chapter11.html (search for "Physical Pixel Dimensions (pHYs)")

Any chance support for this PNG element will be added to Paint.NET ?

Thanks!

Link to comment
Share on other sites

All I know is that I hand the DPI* to the PNG codec in System.Drawing and whatever happens there is how it works. As far as I knew, this was just plopped into the EXIF data.

Does regular Paint (mspaint.exe) work? I think it uses the same GDI+ codec.

* Actually, internally we store DPU (dots-per-unit) and DPU Units (pixel, centimeter, inch). When DPU Unit is pixel, then DPU is always 1, and cannot be changed. But, the document format itself disallows setting this to pixels -- that enumeration value is reserved for the UI. (as far as I recall)

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

mspaint.exe.... let's please not set the bar so loooooooooow....

Macromedia fireworks, photoshop, and ifranview all save png files with the "phys" block in it.

mspaint.exe and paint.net do not save this block.

Unfortunately, some apps (esp for web rendering) look for it... and some blow up when it isn't there.

Some example png files attached (see the file names for explanation). You can open the files with a hex editor and look for the "phys" tag (only present in the fireworks and ifranview examples -- oops, can't add a 4th example, so no ifranview example on this post).

27620_eff13a520ab71cac975a2d29f45a41f9

27620_90ff50feb60cec9080e22a9ce171eaec

27620_a2d85ccdc806c6bca0cf1f4769473abb

Link to comment
Share on other sites

Well, the DPI should be there but I suppose it's just stored in the EXIF data. I don't have any plans right now to change how Paint.NET saves PNG files. I'd have to completely replace the PNG codec (GDI+ has minimal support for, to be honest, everything), and that's not something to be done lightly.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Is this something a filetype plugin could fix?

 

The Doctor: There was a goblin, or a trickster, or a warrior... A nameless, terrible thing, soaked in the blood of a billion galaxies. The most feared being in all the cosmos. And nothing could stop it, or hold it, or reason with it. One day it would just drop out of the sky and tear down your world.
Amy: But how did it end up in there?
The Doctor: You know fairy tales. A good wizard tricked it.
River Song: I hate good wizards in fairy tales; they always turn out to be him.

Link to comment
Share on other sites

I'm certainly no expert when it comes to FileType plugins, but I'm thinking no. You would have to make the plugin use a different extension (such as .pngx or something) and rename any files appropriately. Otherwise, Paint.NET's built-in PNG filetype would take precedence.

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...