スクスニップ

AppleScriptの断片をここに書く

画像のカラースペースを調べる

=== ↑ 書籍の JavaScriptAppleScript に翻訳しています ===

書籍 2-7 画像:02 RGB画像があるか調べる

f:id:mikomaya:20200615162915p:plain

画像のカラースペースは image クラスの space プロパティが保持しています。

用語辞書で color プロパティはf:id:mikomaya:20200615163208p:plain

space (text, r/o) : The color space.

r/o = リードオンリーとなっていますので、変更はできません。

tell application "Adobe InDesign CC 2019"
    tell active document
        activate
        set the selection to {}
        repeat with myObj in page items
            set the selection to myObj
            if class of myObj is rectangle then
                set mySpace to imageColorSpace(myObj) of me
                display dialog mySpace
                -- > RGB, CMYK, Lab, グレースケール
            end if
        end repeat
    end tell
end tell


-- 画像のカラースペースを返す
on imageColorSpace(myObj)
    tell application "Adobe InDesign CC 2019"
        -- class image のリストが帰ってくる
        set myImages to all graphics of myObj
        
        --properties of aImage -- class image のすべてのプロパティ
        set aImage to item 1 of myImages
        space of aImage -- 戻り値 = 画像のカラースペース
    end tell
end imageColorSpace

MacOS Catarina 10.15.5 Adobe InDesign CC 2019

▼サンプルファイル

www.dropbox.com