• Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting the DPI value on a generated PNG image

 
Janus Engstrøm
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have some graphs which I've rendered into some BufferedImages. These images are now going to be saved to disk as .PNG files as they must be loss less in the quality of the graphs. These files are to be used for publishing in various magazines, and these magazines have a requirement that the images must have a DPI of 600. Unfortunately, Windows saves with a DPI of 96, so I have to change this meta data.

I've spent the whole day on Google, trying to figure out what to do. The best post regarding the topic seems to be this one: http://www.tracemodeler.com/articles/aging-bugs-and-setting-dpi-with-java-image-io/
-but the author doesn't really post the answer, he mainly outlines the problems.

I've gotten it to work for JPG's:



-but I can't use JPG's due to its limitations in regards to graphs, charts, etc.

As far as I can see, I need to change the meta data for the PNG files to set the DPI values, but first of all I can't find the value in the Tree as the page at tracemodeler.com talks about ... and next I can't really see how to make changes in the Nodes of this Tree. Please see below.




All very confusing, reading this post is probably confusing as well... but, please, is there anyone out there who knows what to do here? How do I change the DPI value of a PNG image within Java?


Best regards,

Janus
 
Mike Peters
Ranch Hand
Posts: 67
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you can change the PNG-file directly. http://www.libpng.org/pub/png/spec/1.1/PNG-Contents.html and especially http://www.libpng.org/pub/png/spec/1.1/PNG-Chunks.html#C.pHYs
 
Janus Engstrøm
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply, Mike.

I would really prefer not to change the metadata directly in the .PNGs, so if nothing else works I would go that way.

But I've found the solution (yeah!) and the name of the solution is JAI:




Best regards,

Janus
 
Mike Peters
Ranch Hand
Posts: 67
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Janus, very useful information!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!