Convert PDF to 300 pixels per inch TIFF

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?

Generally, the syntax would be with properties {name:"output.file"}.

Specifically, save doesn’t offer any properties — only in and as options.

Also, resolution doesn’t really work that way. Do you mean that you want the image to be 2550 x 3300 pixels (given a letter-sized page)?

Also, resolution doesn’t really work that way. Do you mean that you want the image to be 2550 x 3300 pixels (given a letter-sized page)?

Yes, exactly!

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.

1 Like

Well, thanks. Not really great news, but sometimes we simply need to know about limitations.

Yeah, after a hundred attempts to understand how to make it work, I simply deleted another such a script that I worked on for 3 days.

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:

Its DPI is described as 72 pixels per inch for some reason, though online tools properly detect it is 144. Is it a bug or what?

It looks like Preview simply always shows you pixel dimensions at 72 ppi.

Your TIFF will be 864x648 pixels at 144 ppi.

No, after I have uploaded that TIFF to online tool, set there 144 pixels per inch and then downloaded it, Preview shows 144 and not 72.

and what pixel dimensions does Preview show?

They are the same, 1728 x 1296 pixels (the dimensions of original Pages document and its PDF copy is 12 x 9 inches).

Just in case, here is a screenshot:

image

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:

Preview did export your TIFF at 144 ppi - but shows you pixel dimensions at 72 ppi after you open the image, for some reason.

Photoshop can open PDF with specific DPI image.

And…some Objective-C program will do it without Photoshop.

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.

1 Like

It seems it is somewhat unusual, right? Which reasons might be for this, what do you think?

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:

% mutool draw -o output%d.png -r 300 './dir/original.pdf' 1-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.

https://imagemagick.org/Usage/basics/#density

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.

1 Like

Mockman and leo_r. Thanks for the information.

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.

1 Like

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.

2 Likes