2011/07/06 指定のデジカメ画像のExif情報から指定のプロパティを取得する
指定のデジカメ画像のExif情報から指定のプロパティを取得するAppleScriptです。
デジカメ画像のExif情報を取得する場合には、Image Events経由でアクセスすることになりますが……実際に使ってみると、クラッシュしまくるImage Events。AppleScriptの実行をApple純正のアプリケーションが阻害するというあり得ない現象が頻発。
そこで、Image Eventsをアテにしないで、sipsコマンドをAppleScriptから呼び出すことにしてみました。Image Eventsはsipsを呼び出しているAS用インタフェース・アプリケーションですが、この調子ではAppleScriptによる並列処理などを考えるとsipsをダイレクトに呼び出した方がご利益が大きそうです。
指定できるプロパティ値については、Terminal上でsipsコマンドのhelpを見て確認してください。
Special property keys:
all binary data
allxml binary data
Image property keys:
dpiHeight float
dpiWidth float
pixelHeight integer (read-only)
pixelWidth integer (read-only)
typeIdentifier string (read-only)
format string jpeg | tiff | png | gif | jp2 | pict | bmp | qtif | psd | sgi | tga
formatOptions string default | [low|normal|high|best|
space string (read-only)
samplesPerPixel integer (read-only)
bitsPerSample integer (read-only)
creation string (read-only)
make string
model string
software string (read-only)
description string
copyright string
artist string
profile binary data
hasAlpha boolean (read-only)
Profile property keys:
description utf8 string
size integer (read-only)
cmm string
version string
class string (read-only)
space string (read-only)
pcs string (read-only)
creation string
platform string
quality string normal | draft | best
deviceManufacturer string
deviceModel integer
deviceAttributes0 integer
deviceAttributes1 integer
renderingIntent string perceptual | relative | saturation | absolute
creator string
copyright string
md5 string (read-only)
| スクリプト名:retExifAttributeData v2 |
| set aFile to choose file set aRes to retExifAttributeData(aFile, “model”) of me –> “GR Digital “ set bRes to retExifAttributeData(aFile, “formatOptions”) of me –> “default” –SIPSコマンドで指定のデジカメ画像のExif情報(プロパティ)を取得する on retExifAttributeData(aFile, aParam) set aPOSIX to quoted form of POSIX path of aFile set aRes to do shell script “sips –getProperty “ & aParam & ” “ & aPOSIX set aList to paragraphs of aRes set anItem to contents of last item of aList set colonPos to (offset of “:” in anItem) + 2 set eRes to text colonPos thru -1 of anItem return eRes end retExifAttributeData |