Page 1 of 1

Trying to set the DPI via PHP not working right

Posted: 2008-12-04T10:33:07-07:00
by jaxdevil
I am trying to set the DPI of my image to 600dpi , it starts off as a full page image with 72dpi but with the pixels set to a number so that when I convert it to 600dpi it will print to a regular 8.5"x11" page. I cannot figure out how to set the DPI, the closest I have come is with -density 600, and when I do that it makes the DPI extremely high. I couldn't figure out why it would pick the number it did for DPI, then I resized the image in photoshop to 1" and it showed the resolution as 600dpi then. So it is basically condensing the image into 600dpi, but also making it only 1" wide. Anyone know how can I set the image to be 600dpi without making the size 1"?


The code I am using is below:

Code: Select all

<?php
exec("convert -density 600 -units pixelsperinch test.png test.pdf");
?>
Thank you,
SK

Re: Trying to set the DPI via PHP not working right

Posted: 2008-12-04T14:34:21-07:00
by jaxdevil
Ok, I finally got it to work. With one snag, that I have a band-aid for but I really need to figure out how to do it correctly and not hacked like I am.

Here is the code I am using now. I had to set Density AND Resize, but also I had to make the height less than or equal to 6000 or it would do the whole 34768.34 DPI thing.

Code: Select all

exec("convert -density 600 -resize x6000 -units pixelsperinch test.jpg test.pdf");
If I make the actual pixel size taller than that, i.e. the image is actually 6084 pixels and if I set that to x6084 in the conversion it does the gigantic DPI thing. Anyone know why it has to resize smaller than the original or rather smaller than or equal to 6000?

Thanks,
SK