1200x1200px PNG, which I want to convert to PDF (1.3 or up) and have it print out at 600dpi. So without resampling that would mean I would have a pixel worth of data for each dot on the paper output. So it would be printed as a 2x2 inch image with the 1.44M pixels.
As this will be run on a webserver I need to minimize the CPU time and would like to prevent any resampling whenever possible. Which brings me to the first question:
I have several options, from which I don't know what is best to choose?
- change the dpi setting before converting to pdf
- change the dpi setting after conversion to pdf
- change the dpi setting during conversion to pdf
Then the actual commands which I've tried so far but not always giving the expected output
Setting the density before conversion I think should be done this way:
Code: Select all
$ convert -units PixelsPerInch 1200x1200px.png -density 600 1200x1200px-changedensity.png
$ identify -verbose 1200x1200px-changedensity.png |head -7
Image: 1200x1200px-changedensity.png
Format: PNG (Portable Network Graphics)
Class: PseudoClass
Geometry: 1200x1200+0+0
Resolution: 236.22x236.22
Print size: 5.08001x5.08001
Units: PixelsPerCentimeter
...
Number pixels: 1.44M
Pixels per second: 72MB
$ convert 1200x1200px-changedensity.png -format pdf 1200x1200px-changedensity.pdf
$ identify -verbose 1200x1200px-changedensity.pdf |head -7
Image: 1200x1200px-changedensity.pdf
Format: PDF (Portable Document Format)
Class: DirectClass
Geometry: 144x144+0+0
Resolution: 72x72
Print size: 2x2
Units: Undefined
...
Filesize: 2.89KB
Number pixels: 20.7K
Pixels per second: 207.36TB
Setting the density after the PDF conversion seems not only to change dpi setting, but also resample the image I think.
Code: Select all
$ convert 1200x1200px.png -format pdf 1200x1200px.pdf
$ identify -verbose 1200x1200px.pdf |head -7
Image: 1200x1200px.pdf
Format: PDF (Portable Document Format)
Class: DirectClass
Geometry: 1200x1200+0+0
Resolution: 72x72
Print size: 16.6667x16.6667
Units: Undefined
...
Filesize: 11KB
Number pixels: 1.44M
Pixels per second: 36MB
$ convert -units PixelsPerInch 1200x1200px.pdf -density 600 1200x1200px-changedensity2.pdf
$ identify -verbose 1200x1200px-changedensity2.pdf |head -7
Image: 1200x1200px-changedensity.pdf
Format: PDF (Portable Document Format)
Class: DirectClass
Geometry: 144x144+0+0
Resolution: 72x72
Print size: 2x2
Units: Undefined
....
Filesize: 2.89KB
Number pixels: 20.7K
Pixels per second: 207.36TB
Code: Select all
$ convert -set units PixelsPerInch 1200x1200px.png -density 600 -format pdf 1200x1200px-changedensity3.pdf
$ identify -verbose 1200x1200px-changedensity3.pdf |head -7
Image: 1200x1200px-changedensity3.pdf
Format: PDF (Portable Document Format)
Class: DirectClass
Geometry: 144x144+0+0
Resolution: 72x72
Print size: 2x2
Units: Undefined
...
Filesize: 2.89KB
Number pixels: 20.7K
Pixels per second: 2.074MB
Ok, so far identify seems to show the correct output, but when looking at the filelevel I see this:
Code: Select all
$ ls -lah 1200x1200px-c*.pdf
-rw-r--r-- 1 user staff 5.3K May 22 16:55 1200x1200px-changedensity.pdf
-rw-r--r-- 1 user staff 4.2M May 22 17:14 1200x1200px-changedensity2.pdf
-rw-r--r-- 1 user staff 8.2K May 22 17:20 1200x1200px-changedensity3.pdf
I also tried several other command, but it is still unclear which command give me the end result which I need without changing the data and loading my server.
P.S. this will be run/executed through PHP eventually, so any advice is also welcome. However I would like to get the needed commands correct at first.