I have a lot .jpeg
, .png
and .pdf
Files and I want to convert all of them to .tiff
all at once.
How can I do this?
You can use sips
:
for i in *; do sips -s format tiff $i --out $i.tif; done
Bash.
for i in *; do sips -s format tiff $i --out $i.tif; done
. Otherwise you'll get Error: Unsupported output format tif
Commented
Jul 27, 2017 at 23:39
You can batch convert these files by:
Open Automator from /Applications
Create a new Workflow
Drag the Get Specified Finder Items to the workflow builder.
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.
Click the Add... button in the Get Specified Items action and select all your picture files.
Select the desired image type in the Change Type of Images.
Click the Run button.
Enjoy your batch converted photos!
In the end, your Automator window should look like this:
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
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
brew install imagemagick
first if you haven't already
On a Mac, you can also cd into the directory of your image, and use:
sips -s format tiff input.pdf --out output.tiff
Source: http://www.mactricksandtips.com/2008/07/convert-images-using-terminal.html
I believe you could construct such a custom workflow using the commercial program GraphicConverter (US $40). You would use it a stand-alone program, but it also has certain functions that can be used in Automator workflows.
Here is some information from GraphicConverter's page explaining their batch processing image editing functions.
Batch conversion with additional functions
GraphicConverter offers you sophisticated batch processing which fully automates repetitive tasks applied to a selection of pictures:
- Convert all the selected source pictures easily and quickly into a new format - regardless of whether there are 5 or 5,000 picture files; you just define the type of conversion and set the details
- During the conversion process you can apply up to 60 additional batch functions such as rotation, resize, change the resolution, etc.
- Automate the removal of the Mac OS Ressourcefork before documents are uploaded if there are compatibility problems when the picture files are placed in the internet
- Create catalogs in HTML format for publication in the internet and adjust the colors, sizes, etc. to your individual requirements (see examples)
- Rename a selection of documents according to special criteria quickly and easily
- Join pictures together (e.g. for QuickTime VR)
- Insert or extract IPTC information into or out of a variety of document formats
- and much more ...