I need to convert an existing PDF document into TIFF.
The following code works, -
tell application "Preview"
activate
open POSIX file "/Users/john/Desktop/12.pdf"
save front document in file "Macintosh HD:Users:john:Desktop:12.tiff"
end tell
but the resulting TIFF is 72 pixels per inch, whereas I want it to be 300.
I have tried to change the last line to
save front document in file "Macintosh HD:Users:john:Desktop:12.tiff {with options: ...}"
save front document in file "Macintosh HD:Users:john:Desktop:12.tiff {with properties: ...}"
but this doesnât seem to work. How it can be achieved?
I looked at the Preview dictionary and didnât see any way to do this directly with Preview.
You can do this with Preview with GUI scripting (by way of file > export menu) but getting the GUI scripting to work correctly is a bit involved and error prone.
If the PDF contains one page only, you can do what you want with the sips command-line utility (with recent versions of macOS) and with ASObjC. If the PDF contains multiple pages, you could use ASObjC and create one TIFF for each PDF page.
So, unfortunately, not a lot of good choices. Unless you have a large number of PDFâs to process, I would just do this manually with Preview.
Guys, buy the way, maybe someone knows why when I convert PDF to TIFF using Preview (I donât talk about any automation currently but simply a manual File > ExportâŚ), the resulting image is described by Preview as 72 PPI no matter which PPI settings I have used when export.
That is, I take some PDF, open it in Preview, export it as, for example, 144 pixels per inch TIFF and here is what I see if I open this TIFF in Preview and press Command-I:
so as far as I understand, the online tool just bumped the resolution to 144 yet again. i can reproduce the same behavior in Preview after exporting from Preview to TIFF at 144 ppi same way as you did, then bumping the resolution to 144 again in Photoshop.
so the values Preview showed you originally are not wrong, albeit they do look misleading after you asked to save at 144 ppi:
When saving a PDF at a resolution higher than 72 pixels per inch, Preview changes the image dimensions instead of the image resolution. Thus, for example, a PDF with a page size of 8.5 x 11 inches has image dimensions of 8.5 x 11 inches if saved as a TIFF at 72 pixel per inch and image dimensions of 35.42 x 45.83 inches if saved as a TIFF at 300 pixels per inch. To see this, open a TIFF in Preview and select Tools > Adjust Size.
As you are aware, the imageâs width and height in pixels are the important data. The first TIFF image mentioned above has a pixel width/height of 612/792 and the second TIFF image has a pixel width/height of 2550/3300.
What most people refer to as resolution (sometimes known as density) doesnât really have any meaning for a standalone image. Note that nobodyâs display is 72 dpi anymore. I think the 72 ppi thing is really just a lowest common denominator, of sorts, as it matches the concept of points as well as the long-standing default on macs.
To add a bit to othersâ experiments, if you use imagemagick to change an imageâs resolution, it seems to be ignored by most other software as well.
If I needed to control the pixel dimensions of an exported pdf, I would install mutool/mupdfâ , which has a âdrawâ mode that allows you to output pdf pages to a png (and other formats but not tiff) and set the dimensions. They seem to have added a simple muraster tool as well for this very purpose.
A shell command to do so might look like this â this example would export pages 1 to 3:
Leave out the page range at the end to export the entire document. Of course, when you open a resulting image in preview, the general info will indicate that it is a 72dpi image but it will have a lot of pixels. Some other tool could likely be engaged to convert the pngs to tiffs, assuming the need.
â Available using macports and presumably other rpm type systems
What is âevery inch of an imageâ unless it is printed on some fixed area. Note as well, that much of this discussion here is about metadata and not the actual image dimensions. Some software, e.g. photoshop, may use that metadata rather than the dimensions depending upon the activity but that doesnât change the image.
You might find this explanation a little more expansive. Note that after this section, there is a brief note on photoshop as well.
One last experiment you might try. Create an image that has the number of pixels that an inch of your screen real estate contains. My mac display (15.4âł retina) has 221 pixels per linear inch (in the context of the screen, PPI is meaningful). Display the image at âactual sizeâ then measure it with a ruler. It will measure one inch across. Display it on a different screen and it will not be.
In real life, DPI and PPI are used interchangeably, and they both refer to pixels-per-inch. Originally DPI did indeed refer exclusively to âprinter dots per inchâ. But by mid-90s this gradually morphed into describing âpixels per inchâ (due to various changes in technologies, which Iâm not eloquent enough to describe).
The term PPI - which is technically more accurate - was brought into widespread use by Adobe with the release of Adobe CS suite in early 2000s, where they started using âPPIâ in the actual UI of the software.
Still, like I mentioned, in the real world these terms are used interchangeably and refer to âpixels per inchâ and nothing else.
The purpose of my post was to respond to the OPâs question (see below) of why Preview does not change Image:DPI when a PDF is saved as a TIFF at a resolution of 300 ppi. Clearly, I confused rather than clarified this issue, and Iâll delete my earlier post.
i donât think you confused anything any more than itâs already confusing by itself. dpi/ppi IS a confusing subject with the roots of confusion going deep into the history of the desktop publishing and printing industries.
Adobe does confuse people with their definition of PPI/DPI you quoted. They donât mention that in actual real life these terms are interchangeable. Without this clarification, people can misinterpret resolution values labeled as DPI (which, in overwhelming majority of use cases, mean exactly the same as PPI).
Preview itself adds yet another level of confusion with its misleading - even if correct - representation of the pixel and resolution values after saving the image at the desired resolution.