Setting DPI for PNG files

I have a bunch of charts created using the Java charting toolkit I wrote - these are mostly black and white charts, with blocks in aqua and sometimes other colors. They are currently saved as JPG files, and I want to paste them into a book, which I am preparing to print on request.

The book is an OpenOffice ODT file that will later be converted to PDF.

I am currently using JPG files, but the printer he uses requires 300 DPI, so I changed my chart tool to set xDensity and yDensity to 300, and resUnits to 1 using getAsTree () and then expand the chart 3 times (300/96). IMO result looks good!

Unfortunately, someone on another forum indicated that line charts are "fuzzed" in JPG files, so I suggested switching to PNG or possibly BMP files, both of which can be inserted ODT files.

My problem is that BMP does not have DPI, and PNGMetadata does not seem to support getAsTree (). Can someone point me in the right direction? Thanks.

+6
dpi png
source share
3 answers

I decided not to try to do this programmatically. Instead, I create the original chart in PNG, and then convert it to 300 DPI using Irfanview. Irfanview's capabilities allow me to convert up to 300 DPI, scale to compensation and set the series to scale in just one operation - and across multiple files at the same time. This seems to be the best solution, but thanks anyway anyway!

0
source share

I do not understand the getAsTree () part, but, answering the question that appears in the header, setting the dpi for PNG files, you can use the imagemagick conversion tool:

convert -density 300 -units pixelsperinch infile.jpg outfile.png 
+19
source share

PNG, BMP and dozens of other image formats do not compress your diagrams - compression is probably due to your commentator. JPEG files are great for photos, but suck on charts.

You might want to learn SVG and other vector formats. Or, if your environment allows you to export 0% JPEG compression and convert them to another format for lossless playback at 300DPI.

Hope this helps!

+3
source share

All Articles