How can I batch convert image files and PDFs to TIFF?

Solution 1:

You can use sips:

for i in *; do sips -s format tiff $i --out $i.tif; done

Bash.

Solution 2:

Automator

You can batch convert these files by:

  1. Open Automator from /Applications

  2. Create a new Workflow

  3. Drag the Get Specified Finder Items to the workflow builder.

  4. Drag the Change Type of Images to the workflow builder. This will prompt you to add the Copy Finder Items action as a backup option. That's up to you.

  5. Click the Add... button in the Get Specified Items action and select all your picture files.

  6. Select the desired image type in the Change Type of Images.

  7. Click the Run button.

  8. Enjoy your batch converted photos!

In the end, your Automator window should look like this:

enter image description here

Solution 3:

However, the Automator solution by @Matt Love will not convert multipage PDF files to individual TIFFs. You would need to run two separate Automator workflows, one to convert PDF files to images and one to change the format of image files. As an alternative, you might consider using AppleScript with Mac OS X's built-in Image Events.

Unlike a simple Automator workflow, the script given below (syntax-colorized version here) converts images and PDF files to TIFF, does error reporting and does not break down when failing to handle some files. Before running the script, select the files to be processed in Finder.

EDIT: For multi-page PDFs, only page 1 is converted.

# this script converts all PDFs and images selected in Finder
# to the TIFF format and appends .tif to the file name

set t to (time of (current date))
tell application "Finder" to set sel to selection
set errors to {}
tell application "Image Events"
    repeat with img_file in sel
        try
            set img_file to img_file as text
            set img to open img_file
            save img as TIFF in (img_file & ".tif")
            if (class of result) is not file then error "could not convert to TIFF"
            close img
        on error errMsg
            set errors to errors & ((name of (info for (img_file as alias)) & ": " & errMsg & "\n") as text)
            try
                close img
            end try
        end try
    end repeat
end tell

# error report
set errcount to length of errors
set msg to (((length of sel) - errcount) as text) & " files converted to TIFF in " & ¬
    (((time of (current date)) - t) as text) & " seconds.\n\n"
if errors is not {} then
    set msg to msg & errcount & " errors occurred: \n" & errors as text
end if
display dialog msg

Solution 4:

Next to an Automator script or a commercial tool to solve for multi-page PDFs, another option is to use ImageMagick's convert tool. For example executing the following from the same directory:

for i in *; do magick convert -density 300 ./$i -depth 8 ./$i.tiff; done