Pixelmator Proで1024×1024 pixelの画像をmacOSのアプリケーションアイコン素材用に各サイズにリサイズして連続書き出しするAppleScriptです。
Pixelmator ProのAppleScriptプログラミングコンテスト優勝賞品Pixelmator Pro。非破壊画像処理を行い、GPUベースの高速な処理を行うPixelmator Proを実務的な画像処理に使うとどんな感じなのか、いろいろ調べていたらアイコン書き出し用の複数同時解像度書き出し機能などはついていなかったので、さくっと作ってみました。
Photoshopを操作して各種解像度書き出しを行うよりも高速に感じます(厳密にベンチマークを計測したわけではないんですけれども)。
AppleScript名:Pixelmator Proでアイコン書き出しv2.scptd |
— – Created by: Takaaki Naganoya – Created on: 2020/10/19 — – Copyright © 2020 Piyomaru Software, All Rights Reserved — use AppleScript version "2.4" — Yosemite (10.10) or later use framework "Foundation" use scripting additions set resolList to {1024, 512, 256, 128, 64, 32, 16} set aTargFileBase to (choose file name with prompt "Select Export base name") as string tell application "Pixelmator Pro" if (exists of document 1) = false then display dialog "There is no document" buttons {"OK"} default button 1 with icon 1 return end if tell the front document set aWidth to width set aHeight to height if {aWidth, aHeight} is not equal to {1024.0, 1024.0} then display dialog "Wrong Image Size (1024×1024 required)" buttons {"OK"} default button 1 with icon 2 with title "Size Error" return end if repeat with i in resolList resize image width i height i resolution 72 algorithm bilinear export to file (aTargFileBase & "_" & (i as string) & "x" & (i as string) & ".png") as PNG undo end repeat end tell end tell |
More from my site
(Visited 295 times, 1 visits today)
Fredrik says:
The Fredrik method of your code :)
“`
set resList to {1024, 512, 256, 128, 64}
set theTarget to (choose file name with prompt “”) as string
my exportToFile:theTarget option:resList format:”jpeg”
on exportToFile:_targetPath option:_imageSize format:_imageFormat
set theTarget to _targetPath as string
tell application “Pixelmator Pro”
tell front document
set {theWidth, theHeight} to {width, height}
if {theWidth, theHeight} is not equal to {1024, 1024} then
set errorLog to “Check if the imageSize is correct 1024×1024”
error errorLog number -128
end if
repeat with i in _imageSize
resize image width i height i resolution 72 algorithm bilinear
if (_imageFormat = “png”) then
export to file (theTarget & “-” & (i as string) & “x” & (i as string) & “.png”) as PNG
end if
if (_imageFormat = “tiff”) then
export to file (theTarget & “-” & (i as string) & “x” & (i as string) & “.tiff”) as TIFF
end if
if (_imageFormat = “jpeg”) then
export to file (theTarget & “-” & (i as string) & “x” & (i as string) & “.jpeg”) as JPEG
end if
if (_imageFormat = “heic”) then
export to file (theTarget & “-” & (i as string) & “x” & (i as string) & “.heic”) as HEIC
end if
if (_imageFormat = “gif”) then
export to file (theTarget & “-” & (i as string) & “x” & (i as string) & “.gif”) as GIF
end if
if (_imageFormat = “jpeg2000”) then
export to file (theTarget & “-” & (i as string) & “x” & (i as string) & “.jpeg”) as JPEG2000
end if
if (_imageFormat = “bmp”) then
export to file (theTarget & “-” & (i as string) & “x” & (i as string) & “.bmp”) as BMP
end if
if (_imageFormat = “webp”) then
export to file (theTarget & “-” & (i as string) & “x” & (i as string) & “.webp”) as WebP
end if
if (_imageFormat = “svg”) then
export to file (theTarget & “-” & (i as string) & “x” & (i as string) & “.svg”) as SVG
end if
if (_imageFormat = “pdf”) then
export to file (theTarget & “-” & (i as string) & “x” & (i as string) & “.pdf”) as PDF
end if
if (_imageFormat = “psd”) then
export to file (theTarget & “-” & (i as string) & “x” & (i as string) & “.psd”) as PSD
end if
if (_imageFormat = “pxd”) then
export to file (theTarget & “-” & (i as string) & “x” & (i as string) & “.pxd”) as Pixelmator Pro
end if
end repeat
end tell
end tell
end exportToFile:option:format:
“`