Rotate photos using exiftool and AppleScript

Oct 26, '09 07:30:03AM

Contributed by: Anonymous

I often have to rotate my photos to the proper orientation, because my camera doesn't have position sensor. I'd like to do this operation without loss of quality, so I discovered exiftool, which simply rewrites some exif tags. The exiftool itself is a command line application, so I've created a simple GUI in AppleScript. The script is follows:

on open filenames
	set question to display dialog "Exiftool rotating tool frontend
Which side to rotate?" buttons {"Left", "Right", "Cancel"} default button 1
	set answer to button returned of question
	
	if answer is equal to "Cancel" then
		tell me to quit
	end if
	
	if answer is equal to "Left" then
		set orientation to "8"
	else
		set orientation to "6"
	end if
	
	repeat with fn in filenames
		set filename to POSIX path of fn
		do shell script "exiftool -n -Orientation=" & orientation & " '" & filename & "'  >>~/Library/Logs/exiftool.log 2>>~/Library/Logs/exiftool.eror.log"
	end repeat
end open
Save the script as an application and simply drag the image (it should also work for multiple images) on the app. You will be asked which side to rotate. It may happen that you will have to adjust to values in the script (8 and 6); these values work with my camera. I personally use the app as an external editor for iPhoto.

Comments (8)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20091009130431630