We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Does anyone know of a method to set the Metadata of a PNG to a specific value (such as 300 DPI) when saving from a PGraphics? I'm hoping it will be possible.
Answers
Hmm. Well, PNG format supports physical size in the phys chunk -- it isn't quite DPI, because it is in meters, but close.
I don't know if you can generate metadata like that through saveImage. If not, perhaps you might call an external tool to add the metadata after the image is saved into a file ?
https://stackoverflow.com/a/27336389
Okay, I slapped this together and, well, it works:
(and by slapped together, I mean I stole bits of code and duct taped them together)
Thanks for sharing this solution!
I haven't gone through the toBufferedImage and saveGridImage code in detail, but some quick feedback:
ifthat contains acontinueand has noelse-- this does nothing unless there are side-effects to the test, so you can delete it. Also, you have aforloop that ends in abreak-- this will never loop, so just drop theforand execute the loop setup as normal normal lines of code.test.png-- I pointed it at a common Processing resource.setup()and then exits, no need to define adraw()So: