メタデータを利用してインデザインを開かずに、1色/カラー判定。
前回に引き続き、
今回は、インデザインを1色/カラー判定。
よく分かっていないシェルスクリプトと、
雑なアップルスクリプトとで実験的に作ったスクリプトです。
もっとスマートに書く方法があると思いますが、
とりあえず参考までに。
【作成方法】
ユーティリティ > AppleScript エディタを起動。
下記のAppleScriptコードを入力して、
アプリケーション形式で「indd_Color_Check」などの適当な名前で保存。
▼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 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 |
on open dorp set fileColorList to {} repeat with dorpFile in dorp set theFilePath to dorpFile as string set inddName to name of (info for dorpFile) set POSIXpath to quoted form of POSIX path of dorpFile set Separation to "----------------------------------------------" try set XMPtext to do shell script "sed -n '/xmpTPg:Colorants/=' " & POSIXpath if XMPtext = "" then try set XMPtext to do shell script "sed -n '/xapTPg:Colorants/=' " & POSIXpath end try end if if XMPtext = "" then set myText to "No info" set ColorCheck to "▷▷▷ カラーが混じっている可能性があります。" set infoText to return & inddName & return & Separation & return & (myText as text) & return & ColorCheck & return else set XMPtextCount to count paragraphs of XMPtext set NumberList to {} set i to 1 repeat (XMPtextCount / 2) times set i to (i + 2) set j to {i - 2, i - 1} set the end of NumberList to j end repeat set infoList to {} repeat with T from 1 to (count NumberList) set paragraph1 to item 1 of item T of NumberList set paragraph2 to item 2 of item T of NumberList set T1 to paragraph paragraph1 of XMPtext set T2 to paragraph paragraph2 of XMPtext set the end of infoList to my shellRoutine(T1, T2, POSIXpath) end repeat set infoText to inddName & return & (infoList as text) end if set infoText to return & (infoText as text) & Separation & return on error set infoText to "シェルスクリプトで問題が発生。2" & return & return end try set the end of fileColorList to return & infoText & return end repeat if fileColorList ≠ "" then tell application "TextEdit" activate set text of (make new document) to (fileColorList as text) end tell else activate display dialog "No info" end if end open on shellRoutine(T1, T2, POSIXpath) try set swatchNameTEXT to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:swatchName>\\(.*\\)<\\/xmpG:swatchName>/\\1/p' " & POSIXpath set modeTEXT to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:mode>\\(.*\\)<\\/xmpG:mode>/\\1/p' " & POSIXpath set typeTEXT to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:type>\\(.*\\)<\\/xmpG:type>/\\1/p' " & POSIXpath set cyanTEXT to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:cyan>\\(.*\\)<\\/xmpG:cyan>/\\1/p' " & POSIXpath set magentaTEXT to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:magenta>\\(.*\\)<\\/xmpG:magenta>/\\1/p' " & POSIXpath set yellowTEXT to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:yellow>\\(.*\\)<\\/xmpG:yellow>/\\1/p' " & POSIXpath set blackTEXT to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:black>\\(.*\\)<\\/xmpG:black>/\\1/p' " & POSIXpath if swatchNameTEXT = "" then try set swatchNameTEXT to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:swatchName>\\(.*\\)<\\/xapG:swatchName>/\\1/p' " & POSIXpath set modeTEXT to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:mode>\\(.*\\)<\\/xapG:mode>/\\1/p' " & POSIXpath set typeTEXT to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:type>\\(.*\\)<\\/xapG:type>/\\1/p' " & POSIXpath set cyanTEXT to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:cyan>\\(.*\\)<\\/xapG:cyan>/\\1/p' " & POSIXpath set magentaTEXT to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:magenta>\\(.*\\)<\\/xapG:magenta>/\\1/p' " & POSIXpath set yellowTEXT to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:yellow>\\(.*\\)<\\/xapG:yellow>/\\1/p' " & POSIXpath set blackTEXT to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:black>\\(.*\\)<\\/xapG:black>/\\1/p' " & POSIXpath end try end if set swatchNameTEXT to repChar(swatchNameTEXT, return, ", ") of me set modeTEXT to repChar(modeTEXT, return, ", ") of me set typeTEXT to repChar(typeTEXT, return, ", ") of me set cyanTEXT to repChar(cyanTEXT, return, ", ") of me set magentaTEXT to repChar(magentaTEXT, return, ", ") of me set yellowTEXT to repChar(yellowTEXT, return, ", ") of me set blackTEXT to repChar(blackTEXT, return, ", ") of me set Separation to "----------------------------------------------" set myText to Separation & return & swatchNameTEXT & return & modeTEXT & return & typeTEXT & return & cyanTEXT & return & magentaTEXT & return & yellowTEXT & return & blackTEXT & return on error set myText to "シェルスクリプトで問題が発生。1" & return & return end try return myText end shellRoutine --文字置換ルーチン on repChar(origText, targStr, repStr) set {txdl, AppleScript's text item delimiters} to {AppleScript's text item delimiters, targStr} set temp to text items of origText set AppleScript's text item delimiters to repStr set res to temp as text set AppleScript's text item delimiters to txdl return res end repChar |
【使い方】
作成したスクリプトに調べたいインデザインファイルを
ドラッグ&ドロップすると下図のように表示されます。
▼結果例(カラー全情報取得)
同じような情報が繰り返されていますが、
イラストレーターや画像の配置で情報が変わっていくようです。
▼ExifToolを使用したカラー情報取得例。
上にある複数あるカラー情報のうち最後の情報だけを取得しているみたいです。
▼AppleScript(1色/カラー判定タイプ、ドラッグ&ドロップタイプ)
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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
on open dorp set fileColorList to {} repeat with dorpFile in dorp set theFilePath to dorpFile as string set inddName to name of (info for dorpFile) set POSIXpath to quoted form of POSIX path of dorpFile set Separation to "----------------------------------------------" try set XMPtext to do shell script "sed -n '/xmpTPg:Colorants/=' " & POSIXpath if XMPtext = "" then try set XMPtext to do shell script "sed -n '/xapTPg:Colorants/=' " & POSIXpath end try end if if XMPtext = "" then set myText to "No info" set ColorCheck to "▷▷▷ カラーが混じっている可能性があります。" set infoText to return & inddName & return & Separation & return & (myText as text) & return & ColorCheck & return else set XMPtextCount2 to count paragraphs of XMPtext set XMPtextCount1 to XMPtextCount2 - 1 set paragraph1 to XMPtextCount1 set paragraph2 to XMPtextCount2 set T1 to paragraph paragraph1 of XMPtext set T2 to paragraph paragraph2 of XMPtext try set swatchNameTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:swatchName>\\(.*\\)<\\/xmpG:swatchName>/\\1/p' " & POSIXpath set modeTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:mode>\\(.*\\)<\\/xmpG:mode>/\\1/p' " & POSIXpath set typeTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:type>\\(.*\\)<\\/xmpG:type>/\\1/p' " & POSIXpath set cyanTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:cyan>\\(.*\\)<\\/xmpG:cyan>/\\1/p' " & POSIXpath set magentaTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:magenta>\\(.*\\)<\\/xmpG:magenta>/\\1/p' " & POSIXpath set yellowTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:yellow>\\(.*\\)<\\/xmpG:yellow>/\\1/p' " & POSIXpath set blackTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xmpG:black>\\(.*\\)<\\/xmpG:black>/\\1/p' " & POSIXpath if swatchNameTEXT0 = "" then try set swatchNameTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:swatchName>\\(.*\\)<\\/xapG:swatchName>/\\1/p' " & POSIXpath set modeTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:mode>\\(.*\\)<\\/xapG:mode>/\\1/p' " & POSIXpath set typeTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:type>\\(.*\\)<\\/xapG:type>/\\1/p' " & POSIXpath set cyanTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:cyan>\\(.*\\)<\\/xapG:cyan>/\\1/p' " & POSIXpath set magentaTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:magenta>\\(.*\\)<\\/xapG:magenta>/\\1/p' " & POSIXpath set yellowTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:yellow>\\(.*\\)<\\/xapG:yellow>/\\1/p' " & POSIXpath set blackTEXT0 to do shell script "echo | sed -n -e '" & T1 & ", " & T2 & "s/^.*<xapG:black>\\(.*\\)<\\/xapG:black>/\\1/p' " & POSIXpath end try end if set swatchNameTEXT to repChar(swatchNameTEXT0, return, ", ") of me set modeTEXT to repChar(modeTEXT0, return, ", ") of me set typeTEXT to repChar(typeTEXT0, return, ", ") of me set cyanTEXT to repChar(cyanTEXT0, return, ", ") of me set magentaTEXT to repChar(magentaTEXT0, return, ", ") of me set yellowTEXT to repChar(yellowTEXT0, return, ", ") of me set blackTEXT to repChar(blackTEXT0, return, ", ") of me set cyanCount to 0 repeat with cyanNo from 1 to (count (paragraphs of cyanTEXT0)) set cyanAns to paragraph cyanNo of cyanTEXT0 if cyanAns = "100" then set cyanCount to cyanCount + 1 else if cyanAns = "0" then else set cyanCount to cyanCount + 1 end if end repeat set magentaCount to 0 repeat with magentaNo from 1 to (count (paragraphs of magentaTEXT0)) set magentaAns to paragraph magentaNo of magentaTEXT0 if magentaAns = "100" then set magentaCount to magentaCount + 1 else if magentaAns = "0" then else set magentaCount to magentaCount + 1 end if end repeat set yellowCount to 0 repeat with yellowNo from 1 to (count (paragraphs of yellowTEXT0)) set yellowAns to paragraph yellowNo of yellowTEXT0 if yellowAns = "100" then set yellowCount to yellowCount + 1 else if yellowAns = "0" then else set yellowCount to yellowCount + 1 end if end repeat set myText to Separation & return & swatchNameTEXT & return & modeTEXT & return & typeTEXT & return & cyanTEXT & return & magentaTEXT & return & yellowTEXT & return & blackTEXT & return on error set myText to "シェルスクリプトで問題が発生。" & return & return end try set swatchNameCheck to repChar(swatchNameTEXT0, return, "") of me set swatchNameCheck to repChar(swatchNameCheck, "黒", "") of me set swatchNameCheck to repChar(swatchNameCheck, "紙色", "") of me set swatchNameCheck to repChar(swatchNameCheck, "レジストレーション", "") of me set swatchNameCheck to repChar(swatchNameCheck, "白", "") of me set swatchNameCheck to repChar(swatchNameCheck, "C=0 M=0 Y=0 ", "") of me set modeCheck to repChar(modeTEXT0, return, "") of me set modeCheck to repChar(modeCheck, "CMYK", "") of me set typeCheck to repChar(typeTEXT0, return, "") of me set typeCheck to repChar(typeCheck, "Process", "") of me if ((swatchNameCheck = "") or (swatchNameCheck begins with "K=")) and (modeCheck = "") and (typeCheck = "") and (cyanCount ≤ 1) and (magentaCount ≤ 1) and (yellowCount ≤ 1) then set ColorCheck to "▷▷▷ おそらくグレースケールです。" else set ColorCheck to "▷▷▷ カラーが混じっている可能性があります。" end if set infoText to return & inddName & return & (myText as text) & Separation & return & ColorCheck & return end if end try set the end of fileColorList to return & infoText & return end repeat if fileColorList ≠ "" then tell application "TextEdit" activate set text of (make new document) to (fileColorList as text) end tell else activate display dialog "No info" end if end open --文字置換ルーチン on repChar(origText, targStr, repStr) set {txdl, AppleScript's text item delimiters} to {AppleScript's text item delimiters, targStr} set temp to text items of origText set AppleScript's text item delimiters to repStr set res to temp as text set AppleScript's text item delimiters to txdl return res end repChar |
▼結果例(1色/カラー判定付き)
【注意点】
分版プレビューで1色になっていても、
カラーのスウォッチが存在していて、
それが文字スタイル、段落スタイルなどで、
カラー設定が自動になっているなどの際にも
カラー情報(判定)に影響してしまうようです。
マスターページ上のカラーオブジェクトにも反応します。
また、仕様上、「黒100%」のような
独自の名前のスウォッチを、
オブジェクトに適用していると、
カラーと判定してしまいます。
まあ、どちらも余計なスウォッチは削除してしまえば解決するのですけど…
なお、今回のスクリプトのカラー判定は、
あくまでインデザインファイル単体に対してのものです。
配置されているイラストレーターや画像の
1色/カラー判定は別に行う必要があります。
イラストレーターの1色/カラー判定には、下記情報を参考にしてください。
参考情報
メタデータを利用してイラストレーターを開かずに、1色/カラー判定。