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 & HelpOther Libraries › PDF Output Sizing
Page Index Toggle Pages: 1
PDF Output Sizing (Read 405 times)
PDF Output Sizing
Aug 29th, 2008, 10:49pm
 
Hi,

Okay I've got one for you. What's with the sizing of output directed to a PDF? Following is a small code extract to give you the general idea of what's going on?

import processing.pdf.*;
String urltest = "filenamehere";
PImage img;
void setup(){
   img = loadImage(urltest);
   size(img.width,img.height,PDF,"filetest2.pdf");
   noLoop();
}  // end setup

void draw() {
paintimg();  // CALL THE OUTPUT ROUTINE
exit();
}  // end draw


What happens is as I work with small images and write them to the PDF all is fine. However, when I get to an image that is almost as large as my screen, the resulting image in the PDF seems to be about 35% larger than my screen.

The killer is the picture I really want to process is
2775 x 4463, 72dpi. When I try to open the PDF in Photoshop (which takes almost 2 hours just to get to the rasterize dialog) Photoshop says the picture size is 11563 x 18596 pixels. When I open the PDF in Reader, the PDF is complete and based on the zoom values, it looks like Photoshop is correct on the pixel size.

So why this vast inflation in size which seems to scale up as the raw image grows in size. I tried using images at both 72 and 300dpi but that appears to make no difference.

I tried using two different dpi versions because looking at the difference in size, the output is 4.1668 times larger than the input - a factor that is approximately the same as the factor difference between 72 and 300dpi.


Thanks.

Jim
Re: PDF Output Sizing
Reply #1 - Aug 30th, 2008, 3:19am
 
I suspect that's nothing to do with Processing, and it's just the weird ways that Photoshop handles opening and rasterizing PDF files (both in terms of resolution and the time it takes to render them).

(Of course if that's not the case, please post a bug with a test case that shows the problem.)

Also fwiw, don't use loadImage() before size()... size() needs to be the first thing in setup().
Re: PDF Output Sizing
Reply #2 - Aug 30th, 2008, 4:02am
 
Hi Ben,

fry wrote on Aug 30th, 2008, 3:19am:
I suspect that's nothing to do with Processing, and it's just the weird ways that Photoshop handles opening and rasterizing PDF files (both in terms of resolution and the time it takes to render them).


According to the doc the output is a vector PDF so based on the size and the number of line statements issued, I'm not to surprised at how long it takes PS to open. However, looking at the same PDF in Reader leads me to believe that Adobe is accurately reporting the size.

fry wrote on Aug 30th, 2008, 3:19am:
Also fwiw, don't use loadImage() before size()... size() needs to be the first thing in setup().


Rats. That really dings the usefulness of the height and width fields because that means that before I load any image, I am going to have to go into a separate image app and manually find out what it's dimensions are and manually enter them into Processing. Being able to use the two fields to set size is so much more elegant.

Note in my prior version of the program I didn't use draw() - only setup() and all worked fine except for the sizing issue. I then modded the program to use draw() to see if that would make any difference but it did not.

Just tested placing size() first - it makes no difference in the outcome so I think I'll stick with loading first.

One more test and that will be to just do the draw commands without loading any image to see if that has any impact.

Jim
Re: PDF Output Sizing
Reply #3 - Aug 30th, 2008, 4:32am
 
AND LET THIS BE A LESSON TO YOU!

I just pulled all references to PImage from my program keeping only the draw statements. My results were exactly the same as previously.

Now, I noticed that when I opened the PDF in Photoshop I was presented with a dialog on how to size the image and I was presented with a default image size in pixels and a dpi setting. Previously I had "fixed" the image by changing the pixel count - surprised that the values I was shown did not match the values I had specified during creation of the PDF - I assumed  that the values being displayed were the actual specs inherent in the document itself.

The "Ah Ha" moment was when I changed the default dpi setting from 300 to 72 and the pixel dimensions then changed to the "correct" dimensions.  

I am going to assume (there's that word again) that Photoshop acted as it did because the default value for print resolution is 300dpi and that Photoshop by default treats PDFs as print documents.

Page Index Toggle Pages: 1