|
-- このスクリプトは、72dpi 以上の解像度のイメージを含むファイルを、72dpi
の解像度にダウンサンプルして保存します。
tell application "Finder"
activate
set myFolder to choose folder with prompt "イメージが保存されているフォルダを選択してください。"
set myResults to choose folder with prompt "保存用フォルダを選択してください。"
set nFiles to count folder myFolder each file
end tell
tell application "Canvas
8"
activate
set newdoc to make new document with properties {document type:illustration}
end tell
repeat with i from 1 to nFiles
tell application "Finder"
set f to file i of myFolder
set fName to get name of f
end tell
tell application "Canvas 8"
set obj to place (myFolder as string)
& fName into document newdoc at position {100, 100}
set oType to get object type of obj
if oType = "Image" then
set img to convert obj to image
if get resolution of img > 72 then
set image resolution of img to 72 without preserving data
save newdoc in (myResults as string) & "new_"
& fName as jpeg with useSelection
end if
end if
delete obj
end tell
end repeat
tell application "Canvas
8"
quit
end tell
|

Canvas 8 に含まれているサンプルスクリプトを開く
4つのサンプルスクリプトが、「Canvas 8」フォルダ内の「スクリプト」サブフォルダに含まれています。
ダウンサンプル用のスクリプトを開くには、「Downsample」というファイルをダブルクリックして、「Script
Editor」を開きます。

備考: 含まれているスクリプトと上記のスクリプトは多少異なるところがありますが、実行される作業はほとんど同じです。
上記のスクリプトをダウンロードするには、ここを
クリックしてください。
AppleScript は、テキスト ベースなので、「Script Editor」に上記のコードテキストをコピー/ペーストすることも可能です。
- Script Editor を開きます。
- 「ファイル」メニューから「新規スクリプト」を選択します。
- Webブラウザに表示されている上記のコードをコピーし、Script Editorの下の欄にペーストします。
- <構文確認>ボタンをクリックして、ペーストしたコードが正しいかどうかチェックすることができます。
- 最後に、「ファイル」メニューから「別名で保存」を選択し、スクリプト名を付けて「コンパイル済みスクリプト」として保存します。
備考: Canvas 用のスクリプトを作成および編集するには、Mac OS にAppleScript がインストールされていなければなりません。
次は、AppleScript のコードを見てみましょう。
|