Last active
April 29, 2022 03:05
-
-
Save nrivard/d222e059066515a0f885de3266807813 to your computer and use it in GitHub Desktop.
Automate iOS App Store icons using Pixelmator Pro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use scripting additions | |
set desktopPath to (path to desktop as text) | |
set folderPath to desktopPath & "exports" | |
set exportFolder to "" | |
tell application "Finder" | |
if (exists folder folderPath) is false then | |
make new folder at desktopPath with properties {name:"exports"} | |
end if | |
set exportFolder to folder folderPath | |
end tell | |
tell application "Pixelmator Pro" | |
tell front document to set fileName to name | |
set imageBaseName to (exportFolder as text) & my removeExtension(fileName) | |
# asumes initial image is 1024 x 1024, otherwise move this to the sizes loop below | |
export the front document to file (imageBaseName & ".png") as PNG with properties {compression factor:100} | |
set sizes to {180, 167, 152, 120, 76} | |
repeat with size in sizes | |
tell the front document to resize image width size height size resolution 72 algorithm ml super resolution | |
export the front document to file (imageBaseName & "@" & (size as text) & ".png") as PNG with properties {compression factor:100} | |
tell the front document to undo | |
end repeat | |
end tell | |
# removes the file extension from the passed in `fileName` (of type `string`) | |
on removeExtension(fileName) | |
set oldDelimiters to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to {"."} | |
set fileName to (text items 1 through -2 of fileName as list) as string | |
set AppleScript's text item delimiters to oldDelimiters | |
return fileName | |
end removeExtension |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment