We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Saving a PImage at high DPI
Page Index Toggle Pages: 1
Saving a PImage at high DPI (Read 1491 times)
Saving a PImage at high DPI
Jun 14th, 2006, 7:07pm
 
Hi,
I would like to save a PImage at 254 (or any arbitrary number) DPI, and I'm not exactly sure on how I would do this. I know that I would create an image with the resolution width*dpi,height*dpi where width and height are in inches, but I really have no clue on how to get it to save. I presume that this feature is not simply part of processing (although PImage.setDPI() would be nice Wink and quite useful for designers who want to export finished works for print). How would I go about saving a PImage as a high resolution tga or jpeg?
Re: Saving a PImage at high DPI
Reply #1 - Jun 14th, 2006, 8:25pm
 
Is this what you are looking for?

http://www.processing.org/reference/save_.html
Re: Saving a PImage at high DPI
Reply #2 - Jun 16th, 2006, 7:55pm
 
No, I'm trying to save a PImage, not the window (or a portion of it), and I would like to be able to specify the DPI of the image.
Re: Saving a PImage at high DPI
Reply #3 - Jun 16th, 2006, 9:31pm
 
You can't specify the DPI, just the size in pixels. You can work out how big you want it to be in pixels by taking your DPI and multiplying it by the physical size you want.

Re: Saving a PImage at high DPI
Reply #4 - Jun 16th, 2006, 10:36pm
 
Have you checked out the Libraries page There are several different libs for exporting to different formats from Processing.

http://processing.org/reference/libraries/
Re: Saving a PImage at high DPI
Reply #5 - Jun 17th, 2006, 1:34pm
 
Ok, so now I finally have everything working: I increased the RAM/Stack size,
I have the image in a BufferedImage and can save it as a PNG with:
javax.imageio.ImageIO.write(img, "png", new File(savePath(filename)));

but I would like to use com.sun.media.jai which would allow me to set the meta data of the PNG, which includes "setPhysicalDimension" which can set the dots per meter (0.o), and thus allow me to specify the resolution. Here's the Java code:

PNGEncodeParam png = PNGEncodeParam.getDefaultEncodeParam(bufImage);
png.setPhysicalDimension(round(dpi*39.370079), round(dpi*39.370079), 1);
JAI.create("filestore", bufImage, filename+".png", "PNG");

How would I use the code in Processing?
Re: Saving a PImage at high DPI
Reply #6 - Jun 20th, 2006, 3:28pm
 
add the jai jar to your sketch (sketch -> add file, or drag it into the sketch window). then add the code you just wrote to your sketch.
Page Index Toggle Pages: 1