Sunday excursion: image workflow

--------------------------------------------- -- Applescript: -- Depends on an installation of ImageMagick (convert). -- This script assumes 'convert' is in /opt/local/bin -- Please check where your installation is located -- [type: 'which convert' in the terminal] and amend -- the 'convertIt' and 'makeThumb' routines as necessary. -- Purpose: -- ImageMagick script for downsizing to a maximum height -- of 600 px (width proportional), stripping EXIF data, -- stretching the contrast/values non-linearly and saving -- as a 75% quality JPEG (so best for photos, poor for text). -- Also creates a thumbnail (100px high) using similar routines. -- Usage: -- Highlight one or more image files in the Finder & run -- the script. Alternately, save the script as an application -- from ScriptEditor ('Save as...') and drop files on the -- application icon. -- No rights claimed or warranties offered -- petergallagher.com.au, March 2009 ---------------------------------------------- -- script was clicked on run tell application "Finder" if selection is {} then set finderSelection to folder of the front window as string else set finderSelection to selection as alias list end if end tell convert(finderSelection) end run -- files drag-dropped onto script on open (theList) convert(theList) end open -- bail out of error on quit continue quit end quit -- the main routine on convert(listOfAliases) try tell application "Finder" repeat with oneItem in listOfAliases set itemProp to properties of oneItem set itemPath to quoted form of POSIX path of oneItem set destFold to quoted form of POSIX path of ¬ (container of itemProp as alias) set itemExtension to name extension of oneItem set dotOffs to the offset of itemExtension in itemPath set itemName to text 1 thru (dotOffs - 2) of itemPath tell me to convertIt(itemPath, itemName) tell me to makeThumb(itemPath, itemName) end repeat end tell on error errMsg display dialog "Error --> " & return & errMsg & return & "Usage --> Highlight files in finder and run this script, or save this script as an application and drop files on it." quit end try end convert on convertIt(theFilePath, theFileName) set myConvScript to ¬ "/opt/local/bin/convert -filter Lanczos -strip -resize 'x600>' -sigmoidal-contrast 2,50 -unsharp 0.5x0.5+0.2+0.0 -quality 75 " & theFilePath & " " & theFileName & "_mod.jpg" & "'" try do shell script (myConvScript) on error errMsg display dialog errMsg end try end convertIt on makeThumb(theFilePath, theFileName) set myThumbScript to "/opt/local/bin/convert -strip -resize 'x100>' -sigmoidal-contrast 2,50 -unsharp 0.5x0.5+0.5+0.0 " & theFilePath & " " & theFileName & "_tmb.jpg" & "'" try do shell script (myThumbScript) on error errMsg display dialog errMsg end try end makeThumb

No Comments

Leave a Reply

Your email is never shared.Required fields are marked *