« [valueForKeyPath] pathExtension | トップページ | [プレビュー]ファイル名順にして開き直す »

[Image Events]FileとAliasによる挙動

要はこの違いです

set strImageFilePath to "/Library/User Pictures/Animals/Eagle.tif"

set fileImageFilePath to POSIX file strImageFilePath
---> file "

set aliasImageFilePath to (POSIX file strImageFilePath) as alias
---> alias "



結論を先に
1:ファイル単体:Fileパス形式でImage Eventsに渡す
2:リスト形式の場合:aliasリスト形式でImage Eventsに渡す
これが現時点での使用方法なのかなと



例 ファイルが単体の場合


fileだと各種値を取得できます
set strImageFilePath to "/Library/User Pictures/Animals/Eagle.tif"

set fileImageFilePath to POSIX file strImageFilePath
---> file "

tell application "Image Events"
launch
set objImage to open fileImageFilePath
set listResolution to (resolution of objImage) as list
set listDimensions to (dimensions of objImage) as list
set strR to item 1 of listResolution as text
set strW to item 1 of listDimensions as text
set strH to item 2 of listDimensions as text
set strColorSpace to (color space of objImage) as text
set strFileType to (file type of objImage) as text
set strFileName to (name of objImage) as text
##set strEmbeddedProfileof to name of (embedded profile of objImage)
close objImage
end tell

##########
tell application "Image Events"
launch
open file "Macintosh HD:Library:User Pictures:Animals:Eagle.tif"
--> image "Eagle.tif"
get resolution of image "Eagle.tif"
--> {72.0, 72.0}
get dimensions of image "Eagle.tif"
--> {512, 512}
get color space of image "Eagle.tif"
--> RGB
get file type of image "Eagle.tif"
--> TIFF
get name of image "Eagle.tif"
--> "Eagle.tif"
close image "Eagle.tif"
end tell


エイリアスをOPENすると値は取得できません。

set strImageFilePath to "/Library/User Pictures/Animals/Eagle.tif"

set aliasImageFilePath to (POSIX file strImageFilePath) as alias
---> alias "

tell application "Image Events"
launch
set objImage to open aliasImageFilePath
set listResolution to (resolution of objImage) as list
set listDimensions to (dimensions of objImage) as list
set strR to item 1 of listResolution as text
set strW to item 1 of listDimensions as text
set strH to item 2 of listDimensions as text
set strColorSpace to (color space of objImage) as text
set strFileType to (file type of objImage) as text
set strFileName to (name of objImage) as text
##set strEmbeddedProfileof to name of (embedded profile of objImage)
close objImage
end tell

###
#missing valueとなって値を取得できません



リスト形式の場合


フォルダの中にあるファイルのリスト
set strImageDIr to "/Library/User Pictures/Animals"

set aliasImageDIr to (POSIX file strImageDIr) as alias
---> alias "Macintosh HD:Library:User Pictures:Animals:"

tell application "Finder"
set objEveryDoc to (every file of aliasImageDIr)
end tell
--->get every file of alias "Macintosh HD:Library:User Pictures:Animals:"
--> {document file }


フォルダの中にあるファイルのエイリアスのリスト

tell application "Finder"
set listAliasPath to every file in aliasImageDIr as alias list
end tell
-->get every file of alias "Macintosh HD:Library:User Pictures:Animals:"
--> {alias }




ファイルのリストの場合
set strImageDIr to "/Library/User Pictures/Animals"

set aliasImageDIr to (POSIX file strImageDIr) as alias
---> alias "Macintosh HD:Library:User Pictures:Animals:"

tell application "Finder"
set objEveryDoc to (every file of aliasImageDIr)
end tell

tell application "Image Events"
launch
set objImage to open (item 1 of objEveryDoc)
set listResolution to (resolution of objImage) as list
set listDimensions to (dimensions of objImage) as list
set strR to item 1 of listResolution as text
set strW to item 1 of listDimensions as text
set strH to item 2 of listDimensions as text
set strColorSpace to (color space of objImage) as text
set strFileType to (file type of objImage) as text
set strFileName to (name of objImage) as text
##set strEmbeddedProfileof to name of (embedded profile of objImage)
close objImage
end tell

###
#イメージファイルを対応のアプリで開いてしまいますので、値を取れません。



エリアスリストの場合は期待通りの動作となります


set strImageDIr to "/Library/User Pictures/Animals"

set aliasImageDir to (POSIX file strImageDIr) as alias
---> alias "Macintosh HD:Library:User Pictures:Animals:"

tell application "Finder"
set listAliasPath to every file in aliasImageDir as alias list
end tell

tell application "Image Events"
launch
set objImage to open item 1 of listAliasPath
set listResolution to (resolution of objImage) as list
set listDimensions to (dimensions of objImage) as list
set strR to item 1 of listResolution as text
set strW to item 1 of listDimensions as text
set strH to item 2 of listDimensions as text
set strColorSpace to (color space of objImage) as text
set strFileType to (file type of objImage) as text
set strFileName to (name of objImage) as text
##set strEmbeddedProfileof to name of (embedded profile of objImage)
close objImage
end tell

tell application "Image Events"
launch
open alias "Macintosh HD:Library:User Pictures:Animals:Eagle.tif"
--> image "Eagle.tif"
get resolution of image "Eagle.tif"
--> {72.0, 72.0}
get dimensions of image "Eagle.tif"
--> {512, 512}
get color space of image "Eagle.tif"
--> RGB
get file type of image "Eagle.tif"
--> TIFF
get name of image "Eagle.tif"
--> "Eagle.tif"
close image "Eagle.tif"
end tell

|

« [valueForKeyPath] pathExtension | トップページ | [プレビュー]ファイル名順にして開き直す »

AppleScript Image Events」カテゴリの記事