Using applescript to get EFIX data from a tiff

I would like to use applescript to look at all of the tiff files in a folder and tell me which ones were saved with pixel order set to per channel as opposed to interleaved. I narrowed it down to the EXIF tag 284 being either Planar or Chunky!
Does anyone know of a way to talk directly to the tiff and get its EXIF tag 284 setting without having to open each one in photoshop?
This gets me a bunch of info but not what i need

tell application "Finder"
set theFile to selection as string--I have a tiff selected
set myFileData to read file theFile
end tell

17 inch MacBook Pro (intel), Mac OS X (10.5.8)

Posted on Nov 7, 2010 4:38 PM

Reply
6 replies

Nov 7, 2010 5:31 PM in response to brifilone

I don't have any such files on my machine to test, but it's pretty easy to get the EXIF data of an image via AppleScript's Image Events:

set theFile to (choose file) --> or however you choose to identify the file
tell application "Image Events"
set theMetadata to metadata tags of (open theFile)
end tell


Once you do this it should be easy enough to work out the appropriate metadata tag that you're looking for.

Nov 7, 2010 6:19 PM in response to Camelot

I will give this a try I already came up with a way to do it in Photoshop but if I don't have to open the files I would rather not.

I know there are a bunch of unneeded things in here but I was stepping thru the process making sure I was getting all the right answers
tell application "Finder"
--I would make this into a drop app
set aFile to selection as alias
set theProps to properties of aFile
get label index of theProps
end tell
tell application "Finder"
set theFile to aFile as alias
set theFileName to name of theFile
end tell
tell application "Adobe Photoshop CS2"
open theFile
set theProps to properties of current document
set theInfo to info of theProps
set theEfix to EXIF of theInfo
set thePixList to item 10 of theEfix
set theAnswer to item 2 of thePixList
if theAnswer = "Planar" then
set MarkIt to true
else
set MarkIt to false
end if
close current document
end tell
if MarkIt = true then
tell application "Finder"
set properties of aFile to {label index:1}
end tell
end if

Nov 7, 2010 8:09 PM in response to brifilone

I'd be interested to see the result once you try my version that doesn't require Photoshop.

One observation on your script:

set thePixList to item 10 of theEfix


I think this is incredibly dangerous. I don't deal a lot with images/EXIF data, but this script requires that the data you're looking for is in the 10th EXIF tag. That seems vulnerable to me - what if there was more (or less) EXIF data in a particular image? or the tags were in a different order?

As far as I'm aware there is no defined standard for which tags exist, nor in which order, so relying on the 10th item seems like asking for trouble, especially since you don't check that the first field of this tag is the one you're looking for - you're only checking the value, and if that is not 'Planar' you're assuming it is 'Chunky'. Your script would clearly fail if the 10th tag was a date, or image resolution, or copyright note, or some such (all of which would result in a 'Chunky' image because the value is not 'Planar').

Nov 7, 2010 8:36 PM in response to Camelot

Hmm I did not consider that the data would be returned in different lengths, just assumed the info I wanted would always be item 10 but thanks for forewarning me about that possibility.
when i ran your request of the metadata of the document it came back with
{
metadata tag "hasAlpha" of image "I am interleaved copy 23.tif",
metadata tag "path" of image "I am interleaved copy 23.tif",
metadata tag "dpiWidth" of image "I am interleaved copy 23.tif",
metadata tag "creation" of image "I am interleaved copy 23.tif",
metadata tag "pixelWidth" of image "I am interleaved copy 23.tif",
metadata tag "samplesPerPixel" of image "I am interleaved copy 23.tif",
metadata tag "typeIdentifier" of image "I am interleaved copy 23.tif",
metadata tag "software" of image "I am interleaved copy 23.tif",
metadata tag "ExifColorSpace" of image "I am interleaved copy 23.tif",
metadata tag "pixelHeight" of image "I am interleaved copy 23.tif",
metadata tag "format" of image "I am interleaved copy 23.tif",
metadata tag "bitsPerSample" of image "I am interleaved copy 23.tif",
metadata tag "formatOptions" of image "I am interleaved copy 23.tif",
metadata tag "space" of image "I am interleaved copy 23.tif",
metadata tag "dpiHeight" of image "I am interleaved copy 23.tif"
}

there did not seem to be any indicator what the PlanarConfiguration was (Chunky or Planar)

Nov 8, 2010 11:10 AM in response to brifilone

The script, as written, is only showing the names of the various tags. I would expect that the one you're looking for is either 'format' or 'formatOptions'.

It shouldn't be hard to extract the name/value combinations of the metadata tags which should make it clearer:

set theMetadata to {name, value} of metadata tags of (open theFile)


Now you'll have a list of the tag names and tag values, which should help.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Using applescript to get EFIX data from a tiff

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.