« | Home | »

Acorn Is Scriptable!

I oscillate between Acorn and Pixelmator on the Mac – its great to have two competent alternatives to Photoshop. Pixelmator is my current fav on the iPad Pro (there’s nothing like using it’s object removal with the Apple Pencil). However, today Acorn has me on the Mac because it is scriptable. Whipped up this little script to generate images for Script Debugger 6 release notes:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

on downsampleImage(theFile)
    local destFolderHFSPath
    tell application "Finder"
        set destFolderHFSPath to get folder "Web" of desktop as string
    end tell
    tell application "Acorn"
        tell (open theFile)
            local imageName, imageWidth, imageHeight
            set {imageName, imageHeight, imageWidth} to {name, height, width}
            --  Create 1x down sampled image
            web export width (imageWidth * 0.328) height (imageHeight * 0.328) as PNG in file (destFolderHFSPath & imageName & ".png")
            --  Create 2x down sampled image
            web export width (imageWidth * 0.65) height (imageHeight * 0.65) as PNG in file (destFolderHFSPath & imageName & "@2x.png")
            close saving no
        end tell
    end tell
end downsampleImage

on open theFiles
    repeat with aFile in theFiles
        downsampleImage(contents of aFile)
    end repeat
end open

No fuss, it just worked.

About this entry