Menu

Skip to content
AppleScriptの穴
  • Home
  • Products
  • Docs
  • Events
  • Forum
  • About This Blog
  • License
  • 仕事依頼

AppleScriptの穴

Useful & Practical AppleScript archive. Click '★Click Here to Open This Script' Link to download each AppleScript

Pixelmator Proでアイコン書き出しv2

Posted on 10月 19, 2020 by Takaaki Naganoya

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

★Click Here to Open This Script 

More from my site

  • Pixelmator ProのSVG to PNG変換Pixelmator ProのSVG to PNG変換
  • Pixelmator Pro v2.0.2/2.0.3のAppleScript用語辞書変更点Pixelmator Pro v2.0.2/2.0.3のAppleScript用語辞書変更点
  • Pixelmator Pro v2.0.1でAppleScript用語辞書に命令語追加Pixelmator Pro v2.0.1でAppleScript用語辞書に命令語追加
  • 指定文字のシフトJIS内文字かのチェック指定文字のシフトJIS内文字かのチェック
  • 指定した文字で囲まれたキーワードの色を置換する指定した文字で囲まれたキーワードの色を置換する
  • 構成要素を指定して漢字検索 v3構成要素を指定して漢字検索 v3
Posted in file Image | Tagged 10.14savvy 10.15savvy 11.0savvy Pixelmator Pro | 1 Comment

1 thoughts on “<span>Pixelmator Proでアイコン書き出しv2</span>”

  1. 10/23/20
    7:55 AM
    2020年10月23日
    7:55 AM

    Reply

    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:
    “`

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

電子書籍(PDF)をオンラインストアで販売中!

Google Search

Popular Posts

  • Numbersで選択中の表のセルの範囲を背景色で頻度集計
  • mouseClickを用いて指定座標をクリック
  • 指定文字のシフトJIS内文字かのチェック
  • Numbersで選択範囲のセルのデータを取得して重複データを抽出
  • DSCaptureで画面キャプチャ
  • Automator Actionを実行
  • ファイルパスの変換(Alias→POSIX path→NSURL→POSIX path→file→Alias)
  • 配列の指定要素を検索する(テキスト)
  • 指定ファイルの拡張子を取得する
  • 画面上の指定座標にマウスカーソルを強制移動させてクリック
  • POSIX pathからファイル名と親フォルダを抽出
  • Numbers書類の表のフィルタ状態のトグル切り替え
  • ディスプレイの設定切り替えをAppleScriptでも行えるSwitchResX
  • 頭のいいタイマー割り込み実行
  • CotEditorのScript集、PowerPack & Basic Packをv2.0にアップデート
  • 【基礎】AppleScriptの実行を(操作により)中断する
  • Safariで表示中のWebページの最終更新日時を取得
  • Keynote書類のテキスト色を置換
  • Elgato Stream DeckをAppleScriptでフル活用
  • Markdown書類をメモ.appに新規エントリで登録する

Tags

10.11savvy (1109) 10.12savvy (1249) 10.13savvy (1388) 10.14savvy (513) 10.15savvy (304) 11.0savvy (113) CotEditor (48) Finder (43) iTunes (25) Keynote (61) NSAlert (59) NSAlertSecondButtonReturn (16) NSArray (50) NSBitmapImageRep (20) NSBundle (19) NSButton (33) NSColor (48) NSDictionary (26) NSFileManager (23) NSFont (18) NSImage (40) NSJSONSerialization (21) NSMutableArray (61) NSMutableDictionary (21) NSPredicate (36) NSRunningApplication (55) NSScreen (30) NSScrollView (22) NSString (114) NSURL (93) NSURLRequest (22) NSUTF8StringEncoding (30) NSUUID (18) NSView (33) NSWindow (17) NSWorkspace (19) Numbers (42) Pages (16) Safari (34) System Events (16) WKUserContentController (20) WKUserScript (19) WKUserScriptInjectionTimeAtDocumentEnd (17) WKWebView (21) WKWebViewConfiguration (21)

カテゴリー

  • AirDrop
  • AirPlay
  • Animation
  • AppleScript Application on Xcode
  • Bluetooth
  • boolean
  • Bug
  • Calendar
  • call by reference
  • Clipboard
  • Code Sign
  • Color
  • Custom Class
  • dialog
  • drive
  • exif
  • file
  • File path
  • filter
  • folder
  • Font
  • GAME
  • geolocation
  • GUI
  • GUI Scripting
  • History
  • How To
  • Icon
  • Image
  • Input Method
  • Internet
  • JavaScript
  • JSON
  • JXA
  • Keychain
  • Language
  • list
  • Locale
  • Machine Learning
  • Markdown
  • Menu
  • Metadata
  • MIDI
  • MIME
  • Natural Language Processing
  • Network
  • news
  • Noification
  • Notarization
  • Number
  • OCR
  • OSA
  • PDF
  • Peripheral
  • PRODUCTS
  • QR Code
  • Raw AppleEvent Code
  • Record
  • recursive call
  • regexp
  • Release
  • Remote Control
  • Require Control-Command-R to run
  • REST API
  • RTF
  • Sandbox
  • Screen Saver
  • Script Libraries
  • sdef
  • search
  • Security
  • shell script
  • Sort
  • Sound
  • Spellchecker
  • Spotlight
  • SVG
  • System
  • Tag
  • Telephony
  • Text
  • Text to Speech
  • timezone
  • Tools
  • Update
  • URL
  • UTI
  • Web Contents Control
  • WiFi
  • XML
  • XML-RPC
  • イベント(Event)
  • 未分類

アーカイブ

  • 2021年2月
  • 2021年1月
  • 2020年12月
  • 2020年11月
  • 2020年10月
  • 2020年9月
  • 2020年8月
  • 2020年7月
  • 2020年6月
  • 2020年5月
  • 2020年4月
  • 2020年3月
  • 2020年2月
  • 2020年1月
  • 2019年12月
  • 2019年11月
  • 2019年10月
  • 2019年9月
  • 2019年8月
  • 2019年7月
  • 2019年6月
  • 2019年5月
  • 2019年4月
  • 2019年3月
  • 2019年2月
  • 2019年1月
  • 2018年12月
  • 2018年11月
  • 2018年10月
  • 2018年9月
  • 2018年8月
  • 2018年7月
  • 2018年6月
  • 2018年5月
  • 2018年4月
  • 2018年3月
  • 2018年2月

https://piyomarusoft.booth.pm/items/301502

メタ情報

  • 登録
  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org
Proudly powered by WordPress
Theme: Flint by Star Verte LLC