• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Setting the DPI value on a generated PNG image

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 67
Eclipse IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Eclipse IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Janus, very useful information!
 
We find this kind of rampant individuality very disturbing. But not this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic