Pixelmator Pro AppleScript to export Honda e wallpaper images. Details: https://www.hondaeforums.com/viewtopic.php?f=8&t=255&p=11087#p11087
This file contains 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
set currentTimestamp to do shell script "date +%s" | |
set exportFile to (path to desktop as text) & "honda_e_wallpaper_" & currentTimestamp & ".jpg" | |
tell application "Pixelmator Pro" | |
activate | |
tell application "System Events" to tell process "Pixelmator Pro" to click menu item "Duplicate" of its menu of menu bar item "File" of menu bar 1 | |
set sourceDoc to the front document | |
set targetDoc to make new document with properties {width:3840, height:720} | |
tell sourceDoc | |
set visible of (first layer whose name is "Left menu") to false | |
set visible of (first layer whose name is "Right menu") to false | |
merge all | |
draw selection bounds {0, 0, 1920, 720} | |
copy | |
end tell | |
tell targetDoc | |
paste | |
tell application "System Events" to tell process "Pixelmator Pro" to click menu item "Left Edges" of its menu of menu item "Align Objects" of its menu of menu bar item "Arrange" of menu bar 1 | |
end tell | |
tell sourceDoc | |
draw selection bounds {1980, 0, 1920, 720} | |
copy | |
close saving no | |
end tell | |
tell targetDoc | |
paste | |
tell application "System Events" to tell process "Pixelmator Pro" to click menu item "Right Edges" of its menu of menu item "Align Objects" of its menu of menu bar item "Arrange" of menu bar 1 | |
end tell | |
export targetDoc to file exportFile as JPEG with properties {compression factor:100} | |
tell targetDoc to close saving no | |
end tell | |
delay 1 -- Otherwise Pixelmator Pro steals focus. | |
tell application "Finder" | |
activate | |
reveal file exportFile | |
-- Files must be under 10 MB per https://www.hondaeforums.com/viewtopic.php?f=8&t=255&sid=1f8deef3056f1cb10a40eb64152544cb#p2162. | |
-- We conservatively assume MB and not MiB. | |
set maxBytes to 10 * 1000 * 1000 - 1 | |
set bytes to size of (info for file exportFile) | |
if bytes > maxBytes then | |
set MB to bytes / 1000 / 1000 | |
set roundedMB to (round (MB * 100)) / 100 | |
display alert "Note that this file is over the 10 MB limit (the file size is " & roundedMB & " MB)." buttons {"Well, that sucks"} | |
end if | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment