Archive for the 'Photoshop CS3' Category

02/21 PhotoshopでRGB→CMYK、CMYK→RGB変換

PhotoshopでRGB⇄CMYKの色変換を行うAppleScriptです。

choose colorで選択した色を、Photoshopを用いてRGB⇄CMYKの色変換を行うものです。PhotoshopをAppleScriptから制御して画像フォーマットを変換させるのは「よくある使い方」ですが、Mac OS X 10.6でColorSync Scriptingが廃止されたいまとなっては、色空間の変換を行う処理エンジンとして使うケースもけっこうあります。

CMYKへの色変換を行う機能がまともにないOS向けに、RGB⇄CMYK変換のテーブルを作成するさいの処理エンジンとして使ってみたりと、割と大活躍しています。InDesignと違って、AppleScriptから連続してコントロールしてもクラッシュしにくい、というのもいいところです。

スクリプト名:PhotoshopでRGB→CMYK、CMYK→RGB変換
–色選択
set {rCol, gCol, bCol} to choose color

–16ビット値→8ビット値 変換
set rCol to rCol div 256
set gCol to gCol div 256
set bCol to bCol div 256

set aCMYK to retCMYKfromRGBnumList(rCol, gCol, bCol) of me
–> {0, 82, 82, 0} –結果は選択した色によって異なります。返ってくる値が4つの数字で構成されることを示しています

copy aCMYK to {cNum, mNum, yNum, kNum}

set bRGB to retRGBfromCMYKnumList(cNum, mNum, yNum, kNum) of me
–> {154, 192, 57}–結果は選択した色によって異なります。返ってくる値が3つの数字で構成されることを示しています

–与えられたテキストをRGBデータと評価してCMYK値を返す
on retCMYKfromRGBnumList(rNum, gNum, bNum)
  
  
tell application "Adobe Photoshop CS3"
    set myCMYKColor to convert color {class:RGB color, red:rNum, green:gNum, blue:bNum} to CMYK
    
    
set cyanNum to cyan of myCMYKColor
    
set magentaNum to magenta of myCMYKColor
    
set yellowNum to yellow of myCMYKColor
    
set kuroNum to black of myCMYKColor
  end tell
  
  
set cyanNum to round cyanNum rounding as taught in school –四捨五入
  
set magentaNum to round magentaNum rounding as taught in school –四捨五入
  
set yellowNum to round yellowNum rounding as taught in school –四捨五入
  
set kuroNum to round kuroNum rounding as taught in school –四捨五入
  
  
return {cyanNum, magentaNum, yellowNum, kuroNum}
  
end retCMYKfromRGBnumList

–与えられたCMYKデータをRGBに変換して返す
on retRGBfromCMYKnumList(cNum, mNum, yNum, kNum)
  
  
tell application "Adobe Photoshop CS3"
    set myRGBColor to convert color {class:CMYK color, cyan:cNum, magenta:mNum, yellow:yNum, black:kNum} to RGB
    
    
set redNum to red of myRGBColor
    
set greenNum to green of myRGBColor
    
set blueNum to blue of myRGBColor
  end tell
  
  
set redNum to round redNum rounding as taught in school –四捨五入
  
set greenNum to round greenNum rounding as taught in school –四捨五入
  
set blueNum to round blueNum rounding as taught in school –四捨五入
  
  
  
return {redNum, greenNum, blueNum}
  
end retRGBfromCMYKnumList

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

12/20 与えられたテキストをPhotoshopでRGBデータと評価してCMYK値を返す

「XX, XX, XX」の形式のテキストをparseして、RGBデータとして評価し、Photoshop CS3でRGB→CMYKの変換を行うAppleScriptです。

AppleScriptObjCでカラーデータを入力するプログラムを作っていて、CMYK→RGBの変換は割とすぐできたのですが、RGB→CMYKで手こずり……PhotoshopならAppleScript3行でできてしまう処理。そこで、データをメール経由で収集したあとに手元のプログラムで(Photoshopの機能を用いて)変換することに。

非常に簡単で楽勝でした。

スクリプト名:与えられたテキストをPhotoshopでRGBデータと評価してCMYK値を返す
set aData to "64, 128, 0"
set {cNum, mNum, yNum, kNum} to retCMYKfromRGBstr(aData)
–> {87, 36, 100, 2}

–与えられたテキストをRGBデータと評価してCMYK値を返す
on retCMYKfromRGBstr(aData)
  if aData = "" then return {false, false, false, false}
  
  
set {rDat, gDat, bDat} to divideABC(aData, ",") of me
  
  
  
tell application "Adobe Photoshop CS3"
    set myCMYKColor to convert color {class:RGB color, red:rDat, green:gDat, blue:bDat} to CMYK
    
    
set cyanNum to cyan of myCMYKColor
    
set magentaNum to magenta of myCMYKColor
    
set yellowNum to yellow of myCMYKColor
    
set kuroNum to black of myCMYKColor
  end tell
  
  
set cyanNum to round cyanNum rounding as taught in school –四捨五入
  
set magentaNum to round magentaNum rounding as taught in school –四捨五入
  
set yellowNum to round yellowNum rounding as taught in school –四捨五入
  
set kuroNum to round kuroNum rounding as taught in school –四捨五入
  
  
return {cyanNum, magentaNum, yellowNum, kuroNum}
  
end retCMYKfromRGBstr

–文字列をparseする(R,G,B)の文字データを処理するためのもの
on divideABC(aStr, aDelim)
  set curDelim to AppleScript’s text item delimiters
  
set AppleScript’s text item delimiters to aDelim
  
set tList to every text item of aStr
  
set AppleScript’s text item delimiters to curDelim
  
  
copy tList to {item1, item2, item3}
  
try
    set item1 to item1 as integer
    
set item2 to item2 as integer
    
set item3 to item3 as integer
  on error
    return false
  end try
  
  
return {item1, item2, item3}
end divideABC

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

これを、Photoshop CS3からPhotoshop Elements 6に変更してみたら……きちんと動作するのですが、計算結果がPhotoshop CS3とは異なりました。

スクリプト名:与えられたテキストをPhotoshop ElementsでRGBデータと評価してCMYK値を返す
set aData to "64, 128, 0"
set {cNum, mNum, yNum, kNum} to retCMYKfromRGBstr(aData)
–> {77, 27, 100, 14}

–与えられたテキストをRGBデータと評価してCMYK値を返す
on retCMYKfromRGBstr(aData)
  if aData = "" then return {false, false, false, false}
  
  
set {rDat, gDat, bDat} to divideABC(aData, ",") of me
  
  
  
tell application id "com.adobe.PhotoshopElements" –Phothop Elements
    set myCMYKColor to convert color {class:RGB color, red:rDat, green:gDat, blue:bDat} to CMYK
    
    
set cyanNum to cyan of myCMYKColor
    
set magentaNum to magenta of myCMYKColor
    
set yellowNum to yellow of myCMYKColor
    
set kuroNum to black of myCMYKColor
  end tell
  
  
set cyanNum to round cyanNum rounding as taught in school –四捨五入
  
set magentaNum to round magentaNum rounding as taught in school –四捨五入
  
set yellowNum to round yellowNum rounding as taught in school –四捨五入
  
set kuroNum to round kuroNum rounding as taught in school –四捨五入
  
  
return {cyanNum, magentaNum, yellowNum, kuroNum}
  
end retCMYKfromRGBstr

–文字列をparseする(R,G,B)の文字データを処理するためのもの
on divideABC(aStr, aDelim)
  set curDelim to AppleScript’s text item delimiters
  
set AppleScript’s text item delimiters to aDelim
  
set tList to every text item of aStr
  
set AppleScript’s text item delimiters to curDelim
  
  
copy tList to {item1, item2, item3}
  
try
    set item1 to item1 as integer
    
set item2 to item2 as integer
    
set item3 to item3 as integer
  on error
    return false
  end try
  
  
return {item1, item2, item3}
end divideABC

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

11/10 Photoshop CS3でオープン中の画像の中央のドットの色を取得して確認する

Photoshop CS3でオープン中の画像の中央のドットの色を取得して、choose color命令で表示します。

col1.jpg

色のプレビューを行うのに、HTMLでも作ってSafariでオープンさせようかなどと考えていたのですが、冗談半分でchoose colorコマンドにdefault colorを指定してみたら構文確認をパスして……思ったとおりの動作をして驚きました。

Photoshop CS3だけでなく、後継バージョンでも、Photoshop Elementsでも実行できるものと思われます。

col2.jpg

メモ:choose colorコマンドで色のプレビューが行える

スクリプト名:Photoshop CS3でオープン中の画像の中央のドットの色を取得する
tell application “Adobe Photoshop CS3″
  –注意:ドキュメントをあらかじめオープンしておくこと
  
tell current document
    
    
set hNum to height –高さ
    
set wNum to width –幅
    
    
set x1 to 0
    
set y1 to 0
    
set x2 to wNum
    
set y2 to hNum
    
    
set xCenter to x1 + (x2 - x1) / 2
    
set yCenter to y1 + (y2 - y1) / 2
    
    
–Color Samplerを作成して指定座標の色情報を取得する
    
set aSampler to make new color sampler with properties {class:color sampler, position:{xCenter, yCenter}}
    
set colValues to color sampler color of aSampler
    
–> {class:RGB color, red:177.996108949416, green:24.0, blue:34.0}
    
delete aSampler –samplerをとっとと削除する
    
    
set rVal to (red of colValues) * 256
    
set gVal to (green of colValues) * 256
    
set bVal to (blue of colValues) * 256
    
    
–choose colorを使って、指定した色のプレビューを行う
    
choose color default color {rVal, gVal, bVal}
    
  end tell
end tell

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

08/07 Photoshop CS3でファイルパスがらみのバグが……

InDesign CS3で書き出したEPSをPhotoshop CS3でオープンして、InDesign CS3上で取得しておいた座標値をもとにPhotoshop CS3上でEPSの該当部分を切り抜いてJPEGで保存……という、他愛もないAppleScriptをMac OS X 10.4上で作っては大量の画像切り抜きを自動で行わせていたのですが……

なんと、Photoshop CS3をAppleScriptから操作したときに「一定階層以上のフォルダより下にあるファイルをオープンできない」というバグに遭遇しました。フルパスの長さが一定の文字数を超えると、

 error ”Adobe Photoshop CS3 でエラーが起きました:ファイル 不特定のオブジェクト が見つかりませんでした。” number -43

というエラーメッセージが表示されるばかり。原因がまったく分かりませんでした。

解決にまる1日以上かかってしまいましたが…………「1階層上のフォルダを経由してEPSをオープンさせると問題ない」ことに気づき、深く脱力。

 「もしかしたら、ほかにもあるかもしれない?」

Twitter上に情報を流してみたら、反応がありました。さらにすごいバグを教えていただけました……

「フルパス中に全角の数字あるいは全角のアルファベットが入っているとPhotoshopからファイルのオープンができない」

…………アドビのバグには慣れっこになっていたつもりでしたが、まだまだ甘かったようです。せめて、最新のPhotoshop CS5.5(使ったことがない)上とか、Adobe Photoshop Elements 9 Editor(使ったことがない)上では再現しないことを祈るばかりです。

07/19 Photoshopで選択範囲を切り抜く

Photoshop CS3で、画像の選択範囲を切り抜くAppleScriptです。

あらかじめオープンしておいた画像の一部を選択しておき、本Scriptを実行すると選択部分だけを切り抜きます。

■実行前
ps1_before.jpg

■実行後
ps1_after.jpg

スクリプト名:Photoshopで選択範囲を切り抜く
–選択範囲で切り抜く
tell application "Adobe Photoshop CS3"
  tell document 1
    
    
set aSel to selection
    
try
      set {x1, y1, x2, y2} to bounds of selection
    on error
      set {x1, y1, x2, y2} to {0, 0, 0, 0}
      
return
    end try
    
    
crop bounds {x1, y1, x2, y2}
    
  end tell
end tell

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

07/12 Photoshopで指定座標のカラー値をRGB値で返す

Photoshop CS3で、指定座標のカラーをRGB値で返すAppleScriptです。

Photoshopで指定座標のカラー値を取得できると、処理の幅が大きく広がります。かなり独特な方法なので、これはサンプルがないと分りづらいところです。

いきなり何の断りもなくRGB値を取り出していますが、画像の色空間(カラースペース)がRGBになっていることを前提としています。

スクリプト名:指定座標のカラー値をRGB値で返す
tell application “Adobe Photoshop CS3″
  tell current document
    set {x1, y1, x2, y2} to bounds of selection
  end tell
end tell

set xCenter to x1 + (x2 - x1) / 2
set yCenter to y1 + (y2 - y1) / 2
set aList to getColValOnSpecifiedPosition(xCenter, yCenter) of me
–> {252, 156, 88}

–指定座標のカラー値をRGB値で返す
on getColValOnSpecifiedPosition(xPos, yPos)
  tell application “Adobe Photoshop CS3″
    tell current document
      –Color Samplerを作成して指定座標の色情報を取得する
      
set aSampler to make new color sampler with properties {class:color sampler, position:{xPos, yPos}}
      
      
set rgbValues to color sampler color of aSampler
      
      
set rgb_rCol to red of rgbValues
      
set rgb_gCol to green of rgbValues
      
set rgb_bCol to blue of rgbValues
      
      
–四捨五入
      
set rgb_rCol to round rgb_rCol rounding as taught in school
      
set rgb_gCol to round rgb_gCol rounding as taught in school
      
set rgb_bCol to round rgb_bCol rounding as taught in school
      
      
      
–Color Samplerを削除(Max 4個なので作ったらすぐに削除)
      
delete aSampler
      
      
return {rgb_rCol, rgb_gCol, rgb_bCol}
      
    end tell
  end tell
end getColValOnSpecifiedPosition

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

02/04 Photoshopでオープンしている画像から、選択部分のサイズをもとに画像分割を行う

Photoshop CS3でオープンしている画像のうち、選択したエリアを1つの単位として、画像を順次分割して保存するAppleScriptです。

image_segment.jpg

Photoshop CS3で作成しましたが、Photoshop CS4/CS5やPhotoshop Elementsでも同様に稼働することが期待されます(tellブロックのアプリケーション名を書き換えるだけ)。

「分割」といっていますが、コピー&ペーストで新規画像を作成するため、分割前のオリジナル画像を破壊することはありません。

Photoshop形式の画像を作成するとか、EPS書き出しをするとか、厳密なカラーマッチングを行いたいとか、そういう用途であればPhotoshopをAppleScriptからコントロールすることに意義はありますが、この程度の「画像の細分化」だけならコマンドライン系のツールを使ったほうがいいような気もします。

Photoshopを使ったのは、とりあえず身近なところに転がっているのと、画像中の指定矩形をコピー&ペーストする機能があるからで……単純かつ機械的な画像処理が目的なら、別のアプリケーションを使ってもよいでしょう。

スクリプト名:Photoshopでオープンしている画像から、選択部分のサイズをもとに画像分割を行う
set outFol to choose folder with prompt “出力先のフォルダを選択”

tell application “Adobe Photoshop CS3″
  if (count every document) = 0 then
    display dialog “画像をオープンして、切り取り最小部分を選択した状態で実行してください。” buttons {“OK”} default button 1 with icon 1
    
return
  end if
  
  
tell document 1
    –選択部分のサイズを取得
    
try
      set {sx1, sy1, sx2, sy2} to bounds of selection
    on error
      –選択部分が存在していなかった場合  
      
display dialog “画像をオープンして、切り取り最小部分を選択した状態で実行してください。” buttons {“OK”} default button 1 with icon 1
      
return
    end try
    
set sWidth to sx2 - sx1
    
set sHeight to sy2 - sy1
    
    
–画像全体のサイズ
    
set widNum to width
    
set heiNum to height
    
    
–画像全体における選択部分の分割個数を収録
    
set selNumX to widNum / sWidth
    
set selNumX to round selNumX rounding as taught in school
    
set selNumX to selNumX as integer
    
    
set selNumY to heiNum / sHeight
    
set selNumY to round selNumY rounding as taught in school
    
set selNumY to selNumY as integer
  end tell
end tell

set outCount to 1

repeat with y from 0 to (selNumY - 1)
  repeat with X from 0 to (selNumX - 1)
    set cX1 to (X * sWidth)
    
set cX2 to ((X + 1) * sWidth)
    
    
set cY1 to (y * sHeight)
    
set cY2 to ((y + 1) * sHeight)
    
    
    
set aName to outCount as string
    
    
–指定エリアを新規保存
    
savePolygonToNewFile(cX1, cY1, cX2, cY2, outFol, aName) of me
    
    
set outCount to outCount + 1
  end repeat
end repeat

–Photoshopで指定座標の内容をコピーして新規ファイルで保存
on savePolygonToNewFile(x1, y1, x2, y2, aFol, aName)
  
  
makePhotoshopSelectionRegion(x1, y1, x2, y2) of me
  
  
tell application “Adobe Photoshop CS3″
    activate
    
copy
    
set newDoc to make new document with properties {height:(y2 - y1), width:(x2 - x1)}
    
tell newDoc
      paste
    end tell
  end tell
  
  
set newFilePath to (aFol as string) & aName & “.jpg”
  
  
tell application “Adobe Photoshop CS3″
    set myOptions to {class:JPEG save options, embed color profile:true, format options:progressive, quality:12, scans:3}
    
save newDoc in file newFilePath as JPEG with options myOptions appending lowercase extension with copying
    
close newDoc saving no
  end tell
  
end savePolygonToNewFile

–Photoshop上で指定矩形を選択する
on makePhotoshopSelectionRegion(x1, y1, x2, y2)
  tell application “Adobe Photoshop CS3″
    tell current document
      select region {{x1, y1}, {x2, y1}, {x2, y2}, {x1, y2}} combination type replaced
    end tell
  end tell
end makePhotoshopSelectionRegion

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

02/04 フォルダ内の画像ファイルを順次Numbersのセルに貼り付ける

指定フォルダ内に入っている画像を順次Numbersのドキュメントに貼り付けるAppleScriptです。

指定フォルダ内の画像をPhotoshopで順次オープンして、Numbersのドキュメントに貼り付けます。

Numbersには画像を貼り込むような命令は用意されていないので、GUI Scripting経由でペーストを行います。

スクリプト名:フォルダ内の画像ファイルを順次Numbersのセルに貼り付ける
property aRange : “B”

set aFol to choose folder with prompt “Numbersに貼り付ける画像が入っているフォルダを選択してください”

tell application “Finder”
  set aList to (every file of aFol) as alias list
end tell

set aLen to length of aList

tell application “Numbers”
  tell document 1
    tell sheet 1
      tell table 1
        set row count to aLen + 5
      end tell
    end tell
  end tell
end tell

set aCounter to 2

repeat with i in aList
  tell application “Adobe Photoshop CS3″
    activate
    
open i
    
set d1Doc to (a reference to current document)
    
    
tell d1Doc
      select all
      
copy
    end tell
    
    
tell document 1
      close saving no
    end tell
    
  end tell
  
  
  
set aRangeStr to aRange & (aCounter as string) & “:” & aRange & (aCounter as string)
  
  
tell application “Numbers”
    tell document 1
      tell sheet 1
        tell table 1
          set selection range to range aRangeStr
        end tell
      end tell
    end tell
  end tell
  
  
activate application “Numbers”
  
tell application “System Events”
    tell process “Numbers”
      keystroke “v” using {command down}
    end tell
  end tell
  
  
  
set aCounter to aCounter + 1
  
end repeat

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

07/17 Photoshopで複数画像の「差の絶対値」を計算するテスト v3

Photoshopで、2つのフォルダに入っている同名のファイル同士を「差の絶対値」(difference)で比較して、演算結果をPhotoshop形式で指定のフォルダに保存するAppleScriptです。

画像出力するプログラムの実行テストを行っていて、各種パラメータを変更した状態で演算。それぞれ、演算結果にシリアル番号を付けて保存……そうした演算テストを異なるOSのマシン上で行って、その結果が合っているかどうかを確認したい場合に双方の内容を「差の絶対値」(difference)で計算して画像保存します。

前に、Windows版のアプリケーションをMac OS Xに移植するという仕事をしたときに、変更可能なパラメータをすべての組み合わせで数百通り計算し、その結果をファイルに出力するようAppleScriptで外部からコントロールしていました。そこまでは、「プログラムのテストをAppleScript(GUI Scripting)で自動化できてよかった」という話だったのですが……困ったのが、それらの結果をどうやって付け合わせるか、ということでした。

そこで、Photoshopを使って「差の絶対値」でWindows版とMac版の演算結果を比較。同じなら真っ黒になりますが、差があれば明るいピクセルが出てきます。当時は、Photoshopで画像のヒストグラムを簡単に取得できることには気付いていなかったため、Finder上に画像をならべてプレビューアイコンの画像から「このあたりで違いが出ている」などと目視で判断していました。

いまでは、Photoshopでヒストグラムを取得することなど、朝飯前であるため……この演算結果からヒストグラムを取得し、「どの画像がどのぐらい違っていた」というデータを自動で取得できるようになったというわけです。なお、本サンプルではヒストグラムの取得と集計は盛り込んでおりません。

本プログラムは、PhotoshopをAppleScriptから操作する基本的な動作を数多く含んでいます。とくに、レイヤー合成モードを「差の絶対値」に設定する方法は海外のWebを探しまわっても見つからなかったので、非常に有用なものと思われます。

スクリプト名:Photoshopで複数画像の「差の絶対値」を計算するテスト v3

set doc1Folder to choose folder with prompt “画像1フォルダを選択してください”
set doc2Folder to choose folder with prompt “画像2フォルダを選択してください”
set outFol to choose folder with prompt “合成画像の出力用フォルダを指定してください”

set doc1FolderStr to doc1Folder as string
set doc1FolderStr to doc1FolderStr as Unicode text

set doc2FolderStr to doc2Folder as string
set doc2FolderStr to doc2FolderStr as Unicode text

set outFolStr to outFol as string
set outFolStr to outFolStr as Unicode text

tell application “Finder”
  tell folder doc1Folder
    set doc1Files to name of every file whose name ends with “.jpg”
  end tell
  
  
tell folder doc2Folder
    set doc2Files to name of every file whose name ends with “.jpg”
  end tell
  
  
if (length of doc1Files) is not equal to (length of doc2Files) then
    display dialog “エラー:画像1側と画像2側のファイル数が異なります”
    
return
  end if
end tell

–Photoshop CS3のRulerをPixelに設定
changeRulerToPXL() of me

set fLen to length of doc1Files

repeat with i from 1 to fLen
  set doc1Name to (contents of item i of doc1Files)
  
set doc2Name to (contents of item i of doc2Files)
  
  
–ファイル名が違っていた場合にはエラー
  
if doc1Name is not equal to doc2Name then
    display dialog “2つの画像フォルダに入っているファイル名が違っています” buttons {“OK”} default button 1 with icon 1
    
return
  end if
  
  
set doc1FilePath to doc1FolderStr & doc1Name
  
set doc2FilePath to doc2FolderStr & doc2Name
  
  
set savePath to outFolStr & (contents of item i of doc1Files)
  
  
tell application “Adobe Photoshop CS3″
    activate
    
    
–画像1をオープン
    
open (doc1FilePath as alias) showing dialogs never
    
set d1Doc to (a reference to current document)
    
    
tell d1Doc
      –サイズなどを取得
      
set hSize to height
      
set wSize to width
      
set aResol to resolution
      
      
–内容をすべてコピーしてクローズ    
      
select all
      
copy
      
close without saving
    end tell
    
    
–画像1と同じサイズの画像を新規作成する
    
set newDoc to make new document with properties {name:“composed_image”, width:wSize, height:hSize, resolution:aResol, mode:RGB, bits per channel:eight, initial fill:transparent, color profile kind:none, pixel aspect ratio:1.0}
    
tell newDoc
      set a1Layer to (make new art layer with properties {name:“doc1″})
      
set current layer to a1Layer
      
tell a1Layer
        paste –画像1をペースト
      end tell
    end tell
    
    
–画像2をオープン
    
open (doc2FilePath as alias) showing dialogs never
    
set d2Doc to (a reference to current document)
    
    
–内容をすべてコピーしてクローズ    
    
tell d2Doc
      select all
      
copy
      
close without saving
    end tell
    
    
tell newDoc
      set a2Layer to (make new art layer with properties {name:“doc2″})
      
set current layer to a2Layer
      
tell a2Layer
        paste
      end tell
      
      
set current layer to layer 1
      
      
–レイヤー1の合成フォーマットを「差の絶対値」に
      
tell layer 1
        set blend mode to difference
      end tell
      
      
      
set savedDoc to (save in file savePath as Photoshop format) –一度保存すると、それまでのドキュメントへの参照が無効になるので、再度参照を取得
    end tell
    
    
tell savedDoc to close without saving
    
  end tell
  
end repeat

–Photoshopの定規単位をpixelに変更
on changeRulerToPXL()
  tell application “Adobe Photoshop CS3″ to setRulerPref(pixel units) of me
end changeRulerToPXL

–Photoshopの定規単位を設定
–パラメータ1:cm units/inch units/mm units/percent units/pica units/pixel units/point units
on setRulerPref(myRuler)
  tell application “Adobe Photoshop CS3″
    set ruler units of settings to myRuler
  end tell
end setRulerPref

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

04/23 Photoshop CS3で指定アクションセット内のアクション一覧を取得する

Photoshop CS3で、指定のアクションセット内のアクション名称一覧を取得するAppleScriptです。

元になったJavaScriptの仕様をひきずってファイル経由でアクション名称をやりとりしていますが、書き換えれば値渡しでも大丈夫なはずです。

スクリプト名:Photoshop CS3で指定アクションセット内のアクション一覧を取得する
set aRes to getPSCS3ActionName("初期設定のアクション") of me
–> {"ビネット (選択範囲)", "フレームチャンネル (50 pixel)", "木製 (50 pixel)", "キャストシャドウ (文字)", "水面 (文字)", "カスタムRGBからグレースケール", "溶けた鉛", "クリッピングパスの作成(選択範囲)", "セピアトーン (レイヤー)", "クワドラントカラー", "Photoshop PDF 形式で保存", "グラデーションマップ"}

–Photoshop CS3の指定アクションセット内のアクション名称を取得する
on getPSCS3ActionName(actionSetName)
  tell application "Adobe Photoshop CS3"
    set jsText to "#target photoshop
var outFile = File(\"~/desktop/.psaclist.txt\");
outFile.open(\"w\");
var aList = getActions(’" & actionSetName & "’);
for(var z in aList) {
outFile.writeln(aList[z]);
}
outFile.close();

function getActions(aset) {
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
var i = 1;
var names = [];
if (!aset) {
throw \"Action set must be specified\";
}
while (true) {
var ref = new ActionReference();
ref.putIndex(cTID(\"ASet\"), i);
var desc;
try {
desc = executeActionGet(ref);
} catch (e) {
break; // all done
}
if (desc.hasKey(cTID(\"Nm \"))) {
var name = desc.getString(cTID(\"Nm \"));
if (name == aset) {
var count = desc.getInteger(cTID(\"NmbC\"));
var names = [];
for (var j = 1; j <= count; j++) {
var ref = new ActionReference();
ref.putIndex(cTID(’Actn’), j);
ref.putIndex(cTID(’ASet’), i);
var adesc = executeActionGet(ref);
var actName = adesc.getString(cTID(’Nm ‘));
names.push(actName);
}
break;
}
}
i++;
}
return names;
};
"

    set display dialogs to never
    
try
      do javascript (jsText)
      
set setFound to true
    on error number 8800
      set setFound to false
    end try
  end tell
  
  
try
    do shell script "sync"
    
set sRes to do shell script "cat ~/desktop/.psaclist.txt"
    
do shell script "rm ~/desktop/.psaclist.txt"
    
    
if sRes is not equal to false then
      set sRes to paragraphs of sRes
    end if
    
    
return sRes
  on error
    return false
  end try
end getPSCS3ActionName

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

04/23 Photoshop CS3でアクションセット一覧を取得する

Photoshop CS3で、アクションセットの名称一覧を取得するAppleScriptです。

Photoshopで、アクション名称およびそのフォルダ的な位置づけにあるアクションセットの名称を取得するような機能はAppleScriptからは利用できません。そこで、JavaScriptで取得する方法を調べて、そのコードをAppleScriptからdo JavaScript命令で呼び出してみました。

例によって、ダブルクォートのエスケープ部分に入っている「¥」マークは、実際にはバックスラッシュです。AppleScriptリンクをクリックした場合には正しい文字が入りますが、HTMLのコードでそのまま参照する場合には注意が必要になります。

元のJavaScriptがファイル出力するように出来ていたので、とりあえず一時ファイルに書き出すようにしてshell script経由で読み取って、AppleScriptでリストにしています。

yyyeyoyycyayee2010-04-23-10905e.jpeg

スクリプト名:Photoshop CS3でアクションセット一覧を取得する
set aRes to getPSCS3ActionSetName() of me
if aRes is not equal to false then
  set aList to paragraphs of aRes
end if
–> {”初期設定のアクション”, “DM用アクション”}

–Photoshop CS3のアクションセット名称を取得する
on getPSCS3ActionSetName()
  tell application “Adobe Photoshop CS3″
    set jsText to “#target photoshop
var actionList = getActionSets();
var outFile = File(\”~/desktop/.action_set.txt\”);
outFile.open(\”w\”);     
for(var a in actionList){
outFile.writeln(actionList[a]);
}
outFile.close();

function getActionSets() {
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
var i = 1;
var sets = [];
while (true) {
var ref = new ActionReference();
ref.putIndex(cTID(\”ASet\”), i);
var desc;
var lvl = $.level;
$.level = 0;
try {
desc = executeActionGet(ref);
} catch (e) {
break; // all done
} finally {
$.level = lvl;
}
if (desc.hasKey(cTID(\”Nm \”))) {
var set = {};
set.index = i;
set.name = desc.getString(cTID(\”Nm \”));
set.toString = function() { return this.name; };
set.count = desc.getInteger(cTID(\”NmbC\”));
set.actions = [];
for (var j = 1; j < = set.count; j++) {
var ref = new ActionReference();
ref.putIndex(cTID(’Actn’), j);
ref.putIndex(cTID(’ASet’), set.index);
var adesc = executeActionGet(ref);
var actName = adesc.getString(cTID(’Nm ‘));
set.actions.push(actName);
}
sets.push(set);
}
i++;
}
return sets;
};


    set display dialogs to never
    
    
try
      do javascript (jsText)
      
set setFound to true
    on error number 8800
      set setFound to false
    end try
  end tell
  
  
try
    do shell script “sync”
    
set sRes to do shell script “cat ~/desktop/.action_set.txt”
    
do shell script “rm ~/desktop/.action_set.txt”
    
return sRes
  on error
    return false
  end try
end getPSCS3ActionSetName

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

04/18 Photoshop CS3のアクションセットを削除する

Photoshop CS3の、指定名称のアクションセットを削除するAppleScriptです。

アクションセットは、アクションをまとめたフォルダのようなものですが……指定のアクションセットが存在すれば削除を実行してtrueを返します。存在しなかったり削除に失敗した場合にはfalseを返します。

AppleScript Users MLに流れていたオリジナル版はPhotoshop CS4用でしたが、本ルーチンはCS3用に修正を加えて実行確認を行ったものです。「CS3」となっている箇所を「CS4」に書き換えればPhotoshop CS4でも動作します。

プログラムリスト中の、Javascript指定部分の「¥」マークは、実際にはバックスラッシュです。AppleScript作成リンクをクリックした場合にはバックスラッシュを含んだ正しい内容が転送されますが、HTML版を参照する場合には間違えないよう気を付けてください。

action1.jpg
▲削除前のアクションセット一覧

action2.jpg
▲削除後のアクションセット一覧

スクリプト名:Photoshop CS3のアクションセットを削除する
set aRes to deletePSCS3Action(“delete action”) of me
–> true –存在しており、削除を実行できた場合
–> false –存在しない場合

–Photoshop CS3のアクションセットを削除する
on deletePSCS3Action(actionSetName)
  tell application “Adobe Photoshop CS3″
    set display dialogs to never
    
activate
    
try
      do javascript (
var setName = new ActionReference();
setName.putName(charIDToTypeID( \”ASet\”), \”"
& actionSetName & “\” );
var deleteSet = new ActionDescriptor();
deleteSet.putReference( charIDToTypeID(\”null\”), setName );
executeAction(charIDToTypeID( \”Dlt \”), deleteSet, DialogModes.NO);”
)
      set setFound to true
    on error number 8800
      set setFound to false
    end try
  end tell
  
return setFound as boolean
end deletePSCS3Action

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

12/23 Photoshop CS3で指定エリアを切り出して新規保存

Photoshop CS3上で現在オープンしている画像から指定座標の範囲の内容を別画像として保存するAppleScriptです。

指定フォルダ内の画像をすべて処理するために、その1枚分の画像処理部分を試作したものです。あらかじめPhotoshopで画像をオープンしておかないとエラーになります。

ただ……Adobeのアプリケーションは、連続して処理を行わせると必ずクラッシュするもの(断言)なので、AppleScriptでクラッシュ検出処理を行うようにして、Photoshop CS3のクラッシュに備えることが重要です。

InDesignやPhotoshopなど、JavaScriptでもコントロールできるようになっていますが、動作原理上、クラッシュからのリカバリを行うにはやはりAppleScriptで外部からコントロールしたほうが便利なように思います。人がそばについて監視していないと動かせないのでは、夜間に勝手に仕事をさせておくわけにいきません。

スクリプト名:Photoshop CS3で指定エリアを切り出して新規保存
set {x1, y1} to {259, 40}
set {x2, y2} to {639, 242}

makePhotoshopSelectionRegion(x1, y1, x2, y2) of me

tell application “Adobe Photoshop CS3″
  activate
  
copy
  
set newDoc to make new document with properties {height:(y2 - y1), width:(x2 - x1)}
  
tell newDoc
    paste
  end tell
end tell

set newFilePath to (choose file name) as string

tell application “Adobe Photoshop CS3″
  set myOptions to {class:JPEG save options, embed color profile:true, format options:progressive, quality:12, scans:3}
  
save newDoc in newFilePath as JPEG with options myOptions appending lowercase extension with copying
  
close document 1 saving no
end tell

–Photoshop上で指定矩形を選択する
on makePhotoshopSelectionRegion(x1, y1, x2, y2)
  tell application “Adobe Photoshop CS3″
    tell current document
      select region {{x1, y1}, {x2, y1}, {x2, y2}, {x1, y2}} combination type replaced
    end tell
  end tell
end makePhotoshopSelectionRegion

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

12/23 Photoshop上で指定矩形を選択する

Photoshop CS3上で現在オープンしている画像に対して、指定矩形座標を選択するAppleScriptです。

選択範囲を取得するのは簡単なのに、選択範囲を作成するのにはけっこう骨が折れました。Photoshp CS3のAppleScript用語辞書を調べ、Adobeが配布しているPhotoshopのScripting Guide(情報量が多い割に、サンプルScriptがイケてないのは何故?)を調べ、AppleScript Users MLの過去ログを調べ……意外と、欲しい情報というのは転がっていないもので……。

selectコマンドでパラメータを指定するというのは意外でした。さらに、座標の指定方法が四隅すべての座標を必要とするとは……。

スクリプト名:Photoshop上で指定矩形を選択する

makePhotoshopSelectionRegion(259, 36, 639, 242) of me

–Photoshop上で指定矩形を選択する
on makePhotoshopSelectionRegion(x1, y1, x2, y2)
  tell application “Adobe Photoshop CS3″
    tell current document
      select region {{x1, y1}, {x2, y1}, {x2, y2}, {x1, y2}} combination type replaced
    end tell
  end tell
end makePhotoshopSelectionRegion

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

12/23 Photoshop CS3から画像の選択範囲を取得する

Photoshop CS3で画像の選択範囲の座標を取得するAppleScriptです。

ps1.jpg

大量の画像から、同じ箇所を切り取って別フォルダに別名で保存したいような場合に、最初にサンプル用の画像を1枚オープンしておいて、その画像上で選択範囲を作成しておき、AppleScriptを実行すると選択範囲の座標情報を学習。指定フォルダの画像をオープンして、最初に指定した選択範囲を切り出して別のフォルダに保存する(以下、繰り返し)……といった処理のための下調べのために作成してみました。

selectionのboundsを取得すれば選択範囲は分るのですが、何も選択していなかった場合にはこの動作を行うとエラーになってしまうため、try文でエラートラップを仕掛けておき、エラー時には何も選択されていないものと見なし、{0,0,0,0}を返します。

ps21.jpg

スクリプト名:Photoshop CS3から画像の選択範囲を取得する
tell application “Adobe Photoshop CS3″
  tell document 1
    set aSel to selection
    
try
      set {x1, y1, x2, y2} to bounds of selection
    on error
      set {x1, y1, x2, y2} to {0, 0, 0, 0}
    end try
  end tell
end tell

–> {209.0, 96.0, 777.0, 312.0}

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

12/12 画像のヒストグラムの中央値を求める

Photoshop/Photoshop Elementsで画像のヒストグラムを求めた結果から、その中央値を求めるAppleScriptです。

ヒストグラムという言葉の定義を考えると、「度数分布を表した柱状グラフ」ということになるわけですが……このままだとピンと来ないので、Photoshop上のヒストグラムについて具体的にいえば、「画像の明度を256段階に分けて、それぞれの明度に該当するドット数をカウントしてグラフ化したもの」です。

その中央値を求めるということは、画像中の明度分布の平均値がどのあたりにあるか算出するための試みを行うというわけで、画像のレベル自動変更といった処理をにらんで作ってみました。

ここで用いたサンプル画像だと、中央値がレベル140ということなので、

hist1.jpg

こんな感じです。なんとなく、こんな感じかといわれればこんな感じなのですが、この中央値をもってサンプル画像が明るいか暗いかは判断つきかねるところです。

hist2.jpg

実際、この中央値が140の画像はちょっと暗めのものだったので……中央値を求めてもこの用途には使えなさそうです。何か別の用途には使えるかもしれません。

画像の自動レベル補正については、PhotoshopのAppleScript用語辞書にadjustコマンドが用意されており、

スクリプト名:Photoshop CS3で画像の明度レベル自動補正
tell application “Adobe Photoshop CS3″
  tell document 1
    tell art layer 1
      adjust using automatic levels
    end tell
  end tell
end tell

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

このぐらいでさくっと実行できるのですが、Photoshopの自動補正程度ではぜんぜん役立ちません。

別途、レベル自動補正のための処理を考え、そちらで実現した次第です。

スクリプト名:ヒストグラムの中央値を求める
set bList to {8, 110, 232, 314, 388, 401, 516, 730, 832, 737, 667, 832, 1097, 1478, 1668, 1454, 872, 670, 505, 444, 437, 395, 318, 340, 335, 400, 445, 498, 527, 570, 620, 681, 713, 766, 801, 835, 856, 972, 1139, 1311, 1412, 1153, 969, 955, 909, 839, 859, 975, 1003, 1087, 1001, 948, 911, 1018, 1120, 1067, 1131, 1092, 1139, 1119, 1036, 1037, 970, 980, 916, 889, 807, 831, 809, 822, 817, 799, 882, 828, 932, 848, 910, 1018, 1112, 1223, 1449, 1646, 1891, 1925, 2141, 2978, 4092, 4816, 4368, 3673, 2876, 1964, 1610, 1420, 1478, 1386, 1328, 1207, 1247, 1298, 1261, 1250, 1354, 1475, 1361, 1409, 1766, 2476, 3686, 5015, 6218, 6639, 6322, 6007, 6414, 7525, 8596, 9065, 9560, 11121, 11976, 11515, 11668, 12823, 14802, 16467, 18105, 21367, 25910, 27244, 25368, 24587, 24538, 23670, 21556, 21098, 24165, 26423, 24957, 22997, 23679, 24743, 23797, 21897, 22037, 22317, 21025, 18623, 18966, 19382, 18671, 16789, 15486, 16482, 17025, 15849, 14893, 16760, 18356, 17653, 14952, 14055, 14657, 14746, 14015, 14080, 14864, 15049, 13967, 11706, 11014, 9662, 8178, 6149, 5889, 5296, 4059, 3136, 2813, 2136, 1236, 711, 581, 510, 468, 436, 457, 388, 435, 355, 385, 398, 373, 361, 333, 372, 355, 338, 287, 296, 295, 327, 270, 296, 262, 245, 240, 250, 210, 231, 222, 245, 230, 243, 249, 223, 204, 232, 225, 257, 248, 228, 260, 252, 219, 255, 283, 302, 274, 270, 343, 353, 325, 338, 401, 435, 509, 503, 497, 576, 581, 553, 476, 345, 224, 110, 59, 26, 13, 15, 7, 0, 0, 0, 0, 0}

–リスト要素の合計を計算する
set iCount to 0
repeat with i in bList
  set iCount to iCount + i
end repeat
set halfVal to iCount div 2 –画像の全画素のドット数で数えて中央の要素を計算(何個目のドットが中央か)

–ドット個数の中央値を超える要素をループで検出する
set iiCount to 0
set iiCounter to 1
repeat with i in bList
  set iiCount to iiCount + i
  
if iiCount is not less than halfVal then
    exit repeat
  end if
  
set iiCounter to iiCounter + 1
end repeat

iiCounter –暗いドットから明るいドットまですべて順番に並べて、個数的に真ん中のものの明るさが求められる
–> 140

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

06/07 Photoshop Elementsで画像をぼかしてリサイズしてシャープネスをかける

Photoshop Elementsには、Photoshop CS3と同等のAppleScript用語辞書が搭載されており、AppleScriptからコントロールするかぎりはほぼ同等のソフトに見えます。

そこで、Photoshop ElementsがGUI側に用意していない機能をAppleScriptから操作するテストを行ってみました。

ブログに画面キャプチャを掲載するときによくやっているのが、一度ぼかしフィルタをかけてからリサイズ(縮小)し、リサイズ後にシャープネス・フィルタをかけるという作業です。

Photoshop上では、「イメージ」メニューの「画像解像度」コマンドを呼び出し、仕上がりのピクセルサイズを指定してリサイズできます。

ele3.jpg

ele4.jpg

ところが、Photoshop Elementsで「イメージ」メニューから「サイズ変更」→「画像解像度」を実行しても、仕上がりサイズをピクセルで指定することができません。

ele1.jpg

ele2.jpg

そこで、この操作をPhotoshop CS3に対して実行するAppleScriptを記述。

スクリプト名:Photoshop CS3で画像をぼかしをかけてからリサイズしてシャープに
tell application Adobe Photoshop CS3
  set oldUnits to ruler units of settings
  
set ruler units of settings to pixel units
  
tell document 1
    set w to width
    
set curRes to resolution
    
    
set newWidth to 450 ターゲットサイズ(横幅)
    
    
filter layer 1 using blur ぼかしフィルタ
    
resize image width newWidth resolution curRes resample method bicubic sharper
    
filter layer 1 using sharpen シャープフィルタ
    
  end tell
  
set ruler units of settings to oldUnits
end tell

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

うまく動いたら、tell ブロックの対象アプリケーションを「Adobe Photoshop CS3」から「Adobe Photoshop Elements」に変更し、コンパイル(構文確認)。

スクリプト名:Photoshop Elementsで画像をぼかしをかけてからリサイズしてシャープに
tell application Adobe Photoshop Elements
  set oldUnits to ruler units of settings
  
set ruler units of settings to pixel units
  
tell document 1
    set w to width
    
set curRes to resolution
    
    
set newWidth to 450 ターゲットサイズ(横幅)
    
    
filter layer 1 using blur ぼかしフィルタ
    
resize image width newWidth resolution curRes resample method bicubic sharper
    
filter layer 1 using sharpen シャープフィルタ
    
  end tell
  
set ruler units of settings to oldUnits
end tell

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

これで、実際に問題なく動作しました。Photoshopで大量の画像を定型処理しなくてはならないような場合、Mac miniあたりの安価なマシンをかき集めてきて、Photoshopをマシンの台数分だけ用意して分散処理するのは費用的になかなか難しいケースもありますが、Photoshop Elementsであればかなりお安いのでなかなかよさそうです。

06/02 Photoshop Elementsでオープン中の画像のヒストグラムを取得する

Photoshop Elements(Photoshop CS1〜CS3も可)で、オープン中の画像のヒストグラムを取得するAppleScriptです。

photo1.jpg

こんな画像をオープンしているときのヒストグラムは……

photo2.jpg

のような状態になっており、その256段階の数値をAppleScriptから取得できます。

2つの画像を「差の絶対値」で差分検出した後に、ヒストグラムを数値で取得できれば「どの程度違う部分があるのか」を検出できます。「差の絶対値」で演算すると、2枚の画像の同じ部分は黒く、そうでない部分は他の色になるため……「黒くない」部分の分布状況をヒストグラムから取得すれば、どの程度違うのかを数値で表現可能になります。AppleScriptで画像処理を行う上で非常に重要な技術です。

なお、ヒストグラムは本Scriptのように画像から直接取得できるほか、チャンネル(channel)ごとにも取得できるようになっています。「赤の色成分が多い画像の場合には○○の処理をする」とか「ヒストグラムが暗い方に偏っているので明るくする」といった処理もできそうです。

スクリプト名:Photoshop Elementsでオープン中の画像のヒストグラムを取得する
tell application Adobe Photoshop Elements
  tell document 1
    set c to count every channel
    
set histList to histogram
  end tell
end tell

histList
> {0, 0, 0, 0, 0, 1, 3, 27, 91, 264, 425, 724, 888, 819, 604, 585, 474, 422, 467, 486, 478, 464, 472, 524, 483, 473, 460, 438, 441, 378, 384, 298, 256, 229, 200, 164, 148, 134, 137, 129, 113, 122, 111, 109, 116, 109, 131, 112, 134, 115, 95, 108, 115, 120, 135, 113, 124, 107, 123, 115, 128, 107, 153, 128, 113, 148, 129, 136, 135, 152, 146, 126, 144, 163, 173, 164, 152, 172, 181, 161, 176, 175, 179, 203, 203, 191, 226, 201, 234, 214, 240, 240, 206, 223, 248, 260, 263, 278, 250, 273, 281, 283, 302, 304, 295, 285, 238, 280, 277, 268, 301, 314, 334, 366, 369, 398, 414, 471, 501, 571, 595, 643, 704, 629, 624, 627, 620, 564, 661, 689, 765, 789, 862, 848, 878, 990, 988, 1037, 1127, 1230, 1354, 1474, 1752, 1973, 1806, 1288, 760, 579, 613, 629, 743, 756, 756, 771, 805, 902, 958, 993, 925, 922, 911, 1000, 1243, 1300, 1405, 1386, 1423, 1217, 662, 418, 239, 148, 122, 116, 115, 119, 94, 90, 89, 79, 69, 81, 57, 81, 43, 61, 47, 65, 48, 44, 46, 40, 40, 55, 39, 44, 34, 41, 44, 56, 45, 33, 33, 33, 40, 28, 28, 30, 23, 27, 20, 22, 14, 15, 9, 7, 8, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

05/28 Photoshop Elements 6のAS辞書はPhotoshop CS3と同じ

Photoshop Elements 6を買ってきて、AppleScript用語辞書を調べたところ……Photoshop CS3とまったく同じでした。Elementsにはアクション記録/実行用のインタフェース(メニューやパレット)はないものの、「do action」命令も存在している状態です。

do action v : play an action from the Actions Palette
do action text : the name of the action to play (note that the case of letters in the Action name is important and must match the case of the name in the Actions palette)
from text : the name of the action set containing the action being played (note that the case of letters in the Action Set name is important and must match the case of the name in the Actions palette)

ただ、そうはいってもアクションを指定しようがないので、実行はできないはずです。

Photoshop Elements 6用のScriptは、tellブロックのアプリケーション名をPhotoshop CS3に変更すれば、ほとんどの場合そのまま動きます。