Finderで画像ファイルの色空間を一覧表示する方法
通常は、画像ファイルを選択して、
OS X > メニューバー > ファイル > 情報を見る
でファイル個別に色空間は確認できますが、
フォルダーの中をリスト表示にして、まとめて確認することはできません。
そこで今回は、スクリプトを使用して
画像ファイルの色空間を一覧表示にしてチェックする方法を紹介します。
▼AppleScript(ノーマルタイプ)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
set fileUpperLimit to 500 --ファイル数の上限値 tell application "Finder" activate set result1 to display dialog "●メニューから選択してください。" & return & "" buttons {"キャンセル", "コメント削除", "色空間を取得する"} default button 3 giving up after 60 if not (exists Finder window 1) then return set current view of Finder window 1 to list view --リストビューに変更 set allFile to (files of Finder window 1) if (count of allFile) > fileUpperLimit then --ファイル数が上限値を超えた場合は中止。 activate display dialog "ファイル数が上限値の" & fileUpperLimit & "個を超えました。" & return & "作業を中止します。" buttons {"OK"} default button 1 giving up after 55 with icon 1 return end if if button returned of result1 = "キャンセル" then return else if button returned of result1 = "コメント削除" then repeat with i in allFile set comment of i to "" end repeat else if button returned of result1 = "色空間を取得する" then repeat with i in allFile set iPOSIX to quoted form of POSIX path of (i as Unicode text) set theSpace to do shell script "mdls -raw -name kMDItemColorSpace " & iPOSIX if theSpace as Unicode text = "(null)" then set theSpace to "" set comment of i to theSpace end repeat else return end if activate display dialog "終了しました。" buttons {"OK"} default button 1 giving up after 55 with icon 1 end tell |
▼AppleScript(EPS画像対応タイプ。ExifToolをインストールする必要あり。)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
set fileUpperLimit to 500 --ファイル数の上限値 tell application "Finder" activate set result1 to display dialog "●メニューから選択してください。" & return & "" buttons {"キャンセル", "コメント削除", "色空間を取得する"} default button 3 giving up after 60 if not (exists Finder window 1) then return set current view of Finder window 1 to list view --リストビューに変更 set allFile to (files of Finder window 1) if (count of allFile) > fileUpperLimit then --ファイル数が上限値を超えた場合は中止。 activate display dialog "ファイル数が上限値の" & fileUpperLimit & "個を超えました。" & return & "作業を中止します。" buttons {"OK"} default button 1 giving up after 55 with icon 1 return end if if button returned of result1 = "キャンセル" then return else if button returned of result1 = "コメント削除" then repeat with i in allFile set comment of i to "" end repeat else if button returned of result1 = "色空間を取得する" then repeat with i in allFile set ext to name extension of i set iPOSIX to quoted form of POSIX path of (i as Unicode text) if ext = "eps" then try set theSpace to do shell script "/usr/local/bin/exiftool -s -s -s -ColorMode " & iPOSIX on error set theSpace to "" end try else set theSpace to do shell script "mdls -raw -name kMDItemColorSpace " & iPOSIX if theSpace as Unicode text = "(null)" then set theSpace to "" end if set comment of i to theSpace end repeat else return end if activate display dialog "終了しました。" buttons {"OK"} default button 1 giving up after 55 with icon 1 end tell |
▼AppleScript(EPS画像対応タイプ。要ExifTool。プログレスバー付き。(要OSX10.10以降))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
--プログレスバーつきのため、OSX10.10以降が必要。 set fileUpperLimit to 500 --ファイル数の上限値 tell application "Finder" if not (exists Finder window 1) then return activate set result1 to display dialog "●メニューから選択してください。" & return & "" buttons {"キャンセル", "コメント削除", "色空間を取得する"} default button 3 giving up after 60 my doProgressBar("準備中です…", "…") set current view of Finder window 1 to list view --リストビューに変更 set allFile to files of Finder window 1 set allFileCount to count of allFile if allFileCount > fileUpperLimit then --ファイル数が上限値を超えた場合は中止。 activate display dialog "ファイル数が上限値の" & fileUpperLimit & "個を超えました。" & return & "作業を中止します。" buttons {"OK"} default button 1 giving up after 55 with icon 1 return end if if button returned of result1 = "キャンセル" then return else if button returned of result1 = "コメント削除" then my doProgressBarStart("コメント削除中です。", allFileCount) repeat with i from 1 to allFileCount set comment of item i of allFile to "" my doProgressBarRoop(i, allFileCount) end repeat else if button returned of result1 = "色空間を取得する" then my doProgressBarStart("色空間を取得中です。", allFileCount) repeat with i from 1 to allFileCount my doProgressBarRoop(i, allFileCount) set ext to name extension of item i of allFile set iPOSIX to quoted form of POSIX path of (item i of allFile as Unicode text) if ext = "eps" then try set theSpace to do shell script "/usr/local/bin/exiftool -s -s -s -ColorMode " & iPOSIX --https://ten-artai.com/2014/08/267/ if theSpace = "" then try set theImageData to do shell script "/usr/local/bin/exiftool -s -s -s -ImageData " & iPOSIX set theSpace to my imageData2ColorSpace(theImageData) on error set theSpace to "" end try end if end try else set theSpace to do shell script "mdls -raw -name kMDItemColorSpace " & iPOSIX if theSpace as Unicode text = "(null)" then set theSpace to "" end if set comment of item i of allFile to theSpace end repeat else return end if end tell --imageDataからカラーモードを取得 on imageData2ColorSpace(theSpace) set colorSpaceList to {"", "grayscale", "Lab", "RGB", "CMYK"} set text item delimiters to " " set colorSpaceNumber to text item 4 of (text items of theSpace) set theSpace to item (colorSpaceNumber + 1) of colorSpaceList return theSpace end imageData2ColorSpace on doProgressBar(myDescription, additionalDescription) activate set progress description to myDescription set progress additional description to additionalDescription set progress total steps to -1 delay 0.01 end doProgressBar on doProgressBarStart(myDescription, maxCount) activate set progress description to myDescription set progress total steps to maxCount end doProgressBarStart on doProgressBarRoop(nowCount, maxCount) --activate set progress additional description to "進捗状況:" & (round (nowCount / maxCount) * 100) & "%" set progress completed steps to nowCount end doProgressBarRoop |
▼AppleScript(EPS画像対応タイプ。要ExifTool。プログレスバー付き(要OSX10.10以降)。indd,aiなどのバージョン情報追加)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
--プログレスバーつきのため、OSX10.10以降が必要。 set fileUpperLimit to 500 --ファイル数の上限値 tell application "Finder" if not (exists Finder window 1) then return activate set result1 to display dialog "●メニューから選択してください。" & return & "" buttons {"キャンセル", "コメント削除", "色空間+ver.を取得する"} default button 3 giving up after 60 my doProgressBar("準備中です…", "…") set current view of Finder window 1 to list view --リストビューに変更 set allFile to files of Finder window 1 set allFileCount to count of allFile if allFileCount > fileUpperLimit then --ファイル数が上限値を超えた場合は中止。 activate display dialog "ファイル数が上限値の" & fileUpperLimit & "個を超えました。" & return & "作業を中止します。" buttons {"OK"} default button 1 giving up after 55 with icon 1 return end if if button returned of result1 = "キャンセル" then return else if button returned of result1 = "コメント削除" then my doProgressBarStart("コメント削除中です。", allFileCount) repeat with i from 1 to allFileCount set comment of item i of allFile to "" my doProgressBarRoop(i, allFileCount) end repeat else if button returned of result1 = "色空間+ver.を取得する" then my doProgressBarStart("色空間を取得中です。", allFileCount) repeat with i from 1 to allFileCount my doProgressBarRoop(i, allFileCount) set ext to name extension of item i of allFile set thekind to kind of item i of allFile set inf to info for (item i of allFile) as alias set longVer to long version of inf set fileCreator to file creator of inf set iPOSIX to quoted form of POSIX path of (item i of allFile as Unicode text) if thekind contains "InDesign® C" or ext = "indd" then --InDesignの場合 try set theSpace to do shell script "/usr/local/bin/exiftool -s -s -s -CreatorTool " & iPOSIX on error set theSpace to "" end try else if thekind contains "Adobe Illustrator " or fileCreator = "ART5" then --Illustratorの場合 --thekind:Adobe Illustrator Document/Adobe Illustrator 書類 if longVer ≠ "" then set theSpace to longVer --info forで取得 else try --exiftoolで取得 set Creator to do shell script "/usr/local/bin/exiftool -s -s -s -Creator " & iPOSIX & " | sed -e 's/Adobe Illustrator(R) //'" set CreatorVersion to do shell script "/usr/local/bin/exiftool -s -s -s -CreatorVersion " & iPOSIX set theSpace to "保存 v." & Creator & " 作成 v." & CreatorVersion as Unicode text on error set theSpace to "" end try end if else if ext = "pdf" then --pdfの場合 try set pdfPageCount to do shell script "/usr/local/bin/exiftool -s -s -s -PageCount " & iPOSIX set PDFXConformance to do shell script "/usr/local/bin/exiftool -s -s -s -GTS_PDFXConformance " & iPOSIX set theSpace to "pageCount:" & pdfPageCount & " " & PDFXConformance --as Unicode text on error set theSpace to "" end try else if ext = "eps" then --eps画像の場合 try set theSpace to do shell script "/usr/local/bin/exiftool -s -s -s -ColorMode " & iPOSIX --set theSpace to theSpace & " " & (do shell script "/usr/local/bin/exiftool -s -s -s -Software " & iPOSIX) on error set theSpace to "" end try else --その他の画像 set theSpace to do shell script "mdls -raw -name kMDItemColorSpace " & iPOSIX if theSpace as Unicode text = "(null)" then set theSpace to "" --set theCreator to do shell script "mdls -raw -name kMDItemCreator " & iPOSIX --if theCreator as Unicode text = "(null)" then set theCreator to "" --set theSpace to theSpace & " " & theCreator end if set comment of item i of allFile to theSpace end repeat else return end if end tell on doProgressBar(myDescription, additionalDescription) activate set progress description to myDescription set progress additional description to additionalDescription set progress total steps to -1 delay 0.01 end doProgressBar on doProgressBarStart(myDescription, maxCount) activate set progress description to myDescription set progress total steps to maxCount end doProgressBarStart on doProgressBarRoop(nowCount, maxCount) --activate set progress additional description to "進捗状況:" & (round (nowCount / maxCount) * 100) & "%" set progress completed steps to nowCount end doProgressBarRoop |
【使い方】
ユーティリティ > AppleScript エディタ(スクリプトエディタ)を起動。
上記のアップルスクリプトを入力して「色空間」などの名前で
アプリケーション形式でデスクトップなどに保存します。
フォルダーを開いた状態で、ツールバーの部分を右クリック。
「ツールバーをカスタマイズ…」をクリックして、
作成したスクリプトをドラッグ&ドロップで登録します。
フォルダーをリスト表示させた状態で、
「名前」タブのところを右クリックして、
「コメント」の項目にチェックを入れて表示されるようにします。
そして、作成したスクリプトを実行させます。
ちょっと時間はかかりますが、
フォルダーの中に画像ファイルが入っていれば、
コメント欄に色空間が表示されるようになります。
【注意点】
EPS画像の色空間は取得できません。(ノーマルタイプ)
色空間の情報取得には時間がかかるため、
デフォルトでファイル数の上限値を500にしてあります。
色空間は、mdlsコマンドを使用して取得しています。
リアルタイムの情報ではないでの色空間を変えた場合は、
情報を更新する必要があります。
モノクロ2階調の色空間も「Gray」と表示されるので、
詳細な情報は、Adobe Bridgeなどで調べてください。
ExifToolをインストールしたのに、
EPS画像の色空間が取得できない場合は、
ユーティリティ > ターミナル を起動させ、
「which exiftool」と入力して、
実際のexiftoolのアドレスを取得して、
アップルスクリプト内の
「/usr/local/bin/exiftool」のところを書き換えてください。
【参考情報】
はじめまして、こんにちは
先ほど別の方からこのサイトを紹介いただきました。
私はDTP業務を生業としています。その中で画像のカラーモード別に仕分ける作業がありまして、以前はimagefinderというユーティリティを大変便利に使わせていただいていたのですが、OSに非対応になってから別の策を模索しています。
現在は直接画像を開いて確認したりBridgeのフィルターで判別しますが、Bridgeですと判別後の「Finderで表示」が一度で複数ファイルに適用出来ませんので正直あまり使えません。
DTPFileCheckerも使ったりしましたがこれも同様で複数ファイルの選択が出来ませんでした。
やりたいことは「RGB/CMYKごとにFinderでラベルをつける」です。これを極力時間と手数をかけずに行いたいです。
そこで紹介いただいたのがこちらのサイトのスクリプトです。
実行してみて思いました。「これだ‥!」
作ったスクリプトをツールバーに登録さえすれば良くて時間も手間もかかりません。あとはファイルを選んでラベルを付けるだけです。
とてもとても便利です。助かりました。ありがとうございます!
‥ですがひとつ確認があります。
いくつかのフォルダで試していたところ、コメントタブに色空間が表示されるものされないものが出てしまいました。
何が違うのか私には分からないのですが、漏れなく表示がされるように出来たりしますでしょうか。
※表示がされなかった画像を開いて再保存して再度実行した場合は表示されました。
MacOSはSonoma 14.2.1です。
使わせていただいたスクリプトは、
「AppleScript(EPS画像対応タイプ。要ExifTool。プログレスバー付き。(要OSX10.10以降))」になります。
もし何かご助言いただけるようでしたら何卒よろしくお願いいたします。
EPSファイルですと、カラーモードを取得できない場合があるようですが、
コメントを見ますと、EPSファイル限定という訳ではなさそうですね。
EPSファイルであれば、下記のリンク先の方法で簡易的に情報を取得できそうですので、
一応、コードを追加してみました。
その他に、メタデータの破損も考えられるかも知れません。
Spotlightのインデックスの再作成もお試しください。
https://ten-artai.com/2014/08/267/
tetsuさん お世話になっております。
返信が遅くなってしまって大変申し訳ございません。
スクリプトを実行して表示がされない場合、複数回繰り返すことで成功することもあるようです。新たに追記してくださったスクリプトの方でもそのあたりの変化はないように思います。
ですが!いずれにしましてもこのスクリプトを使うことによって今までよりも効率が上がったことは間違いありません。私はすでに大変重宝していて職場チーム内でも共有し始めています。本当にありがとうございます!!
共有している中で「?」となったことがありまして、、、MacOS Sonomaでは普通に機能していると思いますが、Monteray積んでる数台では「デスクトップフォルダのファイルにアクセスしようとしています。」【許可しない】【OK】がファイルの数だけ聞かれます。Sonomaでもこれは聞かれますが、ほんの数回程度でそれほど気にはなりません。またMontereyでは色空間情報を取得出来ないファイル数も多くなっています。これはOSの違いが挙動の違いに表れているのか、Macの設定が何か違うのか、まで辿り着いてはいません。
また何か分かりましたら教えていただけますと幸いです。
最終的には色空間情報別にタグを付けて画像ファイルを管理しています。CMYK:オレンジ、RGB:グリーンみたいな感じです。ちょっと調べて勉強してみようかなと思っていますが、そもそも色空間とタグをスクリプト使って紐づけることなんて出来るのでしょうか。もしここまで出来たらさらにHAPPYが上乗せです。
「複数回繰り返すことで成功する」ということですので、
どのような作業工程なのか分かりませんが
Spotlightのインデックスが作成されていないタイミングで色空間を取得しているのではないでしょうか。
set theSpace to do shell script “mdls -raw -name kMDItemColorSpace ” & iPOSIX
if theSpace as Unicode text = “(null)” then set theSpace to “”
の箇所を下記のコードに書き換えてみてください。要ExifTool。
↓
try
set theSpace to do shell script “/usr/local/bin/exiftool -s -s -s -ColorMode ” & iPOSIX
on error
set theSpace to “”
end try
if theSpace = “CMYK” then
set label index of (item i of allFile) to 1
else if theSpace = “RGB” then
set label index of (item i of allFile) to 6
end if
もしくは、
end repeatの上に、
delay 0.01
を追加することで動作が改善する可能性もあります。
MacOSのバージョンに関しては、そこまで新しいOSを使用していないので分かりませんが、
スクリプトの新規保存を試した方がいいかも知れません。
スクリプトエディタ > ファイル > 新規 > 今まで使用していたコードをコピペ > アプリケーションとして保存
MacOS > システム環境設定 > セキュリティとプライバシー > 各種セキュリティ設定。