- Select images
- Select destination folder
- Enter short side resolution
- Select export format
The script then resizes each image and exports it to the destination folder.
tell application "Pixelmator Pro"
activate
-- Prompt for resize resolution
repeat
set dialogResult to (display dialog "Enter short side resolution in pixels:" default answer "1080")
try
set userNumber to (text returned of dialogResult) as integer
exit repeat
end try
display dialog "Needs a valid integer." buttons {"Enter again", "Cancel"} default button 1
end repeat
-- Prompt for files to process
set originalImages to choose file with prompt ¬
"Select the images to resize:" with multiple selections allowed
-- Prompt for the export location
set exportLocation to choose folder with prompt ¬
"Select the folder where you'd like export the images:"
-- Prompt for the export format
set exportFormatChoices to {"JPEG 100%", "JPEG 80%", "PNG"}
set exportFormat to choose from list exportFormatChoices with prompt ¬
"Select export format:" default items {"JPEG 100%"}
-- Prompt for the export format
set sharpenChoices to {"No", "A bit", "A lot"}
set sharpenFormat to choose from list sharpenChoices with prompt ¬
"Sharpen after resize?" default items {"No"}
-- Loop over images
repeat with a from 1 to number of originalImages
set currentImage to open item a of originalImages
-- Resize
if width of currentImage < height of currentImage then
tell currentImage to resize image width userNumber algorithm lanczos
else
tell currentImage to resize image height userNumber algorithm lanczos
end if
-- Sharpen
if ((sharpenFormat as string) is equal to "A bit") then
tell the color adjustments of layer 1 of currentImage
set its sharpen to 50
set its sharpen radius to 1
end tell
else if ((sharpenFormat as string) is equal to "A lot") then
tell the color adjustments of layer 1 of currentImage
set its sharpen to 100
set its sharpen radius to 1.6
end tell
end if
-- Export
set exportName to name of currentImage & "-" & (userNumber as text)
if ((exportFormat as string) is equal to "JPEG 100%") then
export currentImage to file ((exportLocation as text) & ¬
exportName & ".jpg") as JPEG with properties {compression factor:100}
else if ((exportFormat as string) is equal to "JPEG 80%") then
export currentImage to file ((exportLocation as text) & ¬
exportName & ".jpg") as JPEG with properties {compression factor:80}
else if ((exportFormat as string) is equal to "PNG") then
export currentImage to file ((exportLocation as text) & ¬
exportName & ".png") as PNG
end if
close currentImage without saving
end repeat
display notification (number of originalImages as text) & ¬
" images have been resized." with title "Pixelmator Pro"
end tell