Can extra alpha channels be found without opening a Photoshop document?
Not that I can see in Image Events or in Photoshop or Bridge.
Our database backup downloads a corrupt low-res file if the Photoshop file contains any alpha channels. So it would help to find them first before uploading.
set i to choose file
tell application "Image Events"
launch
open i
tell image 1
set alpha to value of metadata tag "hasAlpha"
end tell
close image 1
end tell
The built-in «sips» command can check whether an image has an alpha channel or not:
set imgpath to quoted form of "/Library/Desktop Pictures/Nature/Aurora.jpg"
set output to (do shell script "sips -g hasAlpha " & imgpath)
if output contains "hasAlpha: no" then
return false
else if output contains "hasAlpha: yes" then
return true
end if
I am now trying to make a list of those files in a certain folder which contain alpha channels.
I am running an AppleScript where I am getting an error
“Image Events got an error: Can’t make value of metadata tag "hasAlpha" into type reference.”
from this line
set MyAlpha to value of metadata tag “hasAlpha”
What am I missing? Any ideas?
Where in the Image Events AppleScript dictionary is alpha shown? Is alpha channel data under metadata?
–Herb Ripka
Greendale, WI
to MakeList(ProcessFolder)
tell application "Finder"
set filelist to (files of entire contents of alias ProcessFolder whose name extension is "tif" as list)
return filelist
end tell
end MakeList
to GetDimensions(TheFile)
tell application "Image Events"
launch
set MyImage to open alias TheFile
set MyResolution to resolution of MyImage
set MyColorspace to color space of MyImage
set MyAlpha to value of metadata tag "hasAlpha"
set InfoList to name of MyImage & " " & MyResolution & " " & MyColorspace & " " & MyAlpha & return
close MyImage
end tell
return InfoList
end GetDimensions
set ProcessFolder to (choose folder) as string
set filelist to MakeList(ProcessFolder)
set MyList to ""
repeat with AnItem in filelist as list
set MyList to MyList & (GetDimensions(AnItem as string))
end repeat
tell application "TextEdit"
activate
make new document at beginning with properties {text:MyList as Unicode text}
end tell
You forgot the reference to the image like in the lines before
.
set MyAlpha to value of metadata tag "hasAlpha" of MyImage
.
or use a tell block
.
set MyImage to open alias TheFile
tell MyImage
set MyResolution to resolution
set MyColorspace to color space
set MyAlpha to value of metadata tag "hasAlpha"
end tell
.