Re: IPTC information via AppleScript
Re: IPTC information via AppleScript
- Subject: Re: IPTC information via AppleScript
- From: Paul Welch <email@hidden>
- Date: Sat, 6 Apr 2002 00:06:46 +0100
On Wed, 3 Apr 2002, Ron Bishop <email@hidden> wrote:
>
Is it possible to gain access to the IPTC information in an image file via
>
AppleScript (without additional software like iViewMedia Pro or Graphic
>
Converter)? I know you can with php and perl, but I'm looking for an
>
AppleScript solution.
>
>
Thanks,
>
>
Ron Bishop
>
Macintosh Systems Administrator
Hi Ron,
I've had some success extracting the IPTC info from the resource fork
('ANPA' resource, as written by Photoshop, Graphic Converter etc)
using the 'Satimage' OSAX, (which I believe is now carbonised for
OSX, If I'm wrong here, I'm sure Emmanuel will correct me) and then
parsing the resulting info using AppleScript's TIDs.
The example below may be of some use to you (watch out for the line breaks).
--start script
set IC02 to (ASCII character 28) & (ASCII character 2)
extractIPTC(alias "My Disk:My Pic File", IC02)
on extractIPTC(targetPic, IC02)
set textItems to {}
try
set retrievedInfo to LoadResource 10000 type "ANPA"
from alias targetPic as string
set theText to (text 10 thru -1 of retrievedInfo)
set saveDelims to AppleScript's text item delimiters
try
set AppleScript's text item delimiters to {IC02}
set textItems to the text items of theText
on error
set AppleScript's text item delimiters to saveDelims
end try
set AppleScript's text item delimiters to saveDelims
end try
repeat with thisField in textItems
try
set fieldID to (first character of thisField)
if fieldID is "x" then
set Caption to (text 4 thru -1 of
(thisField as string))
else if fieldID is "P" then
set Byline to (text 4 thru -1 of
(thisField as string))
else if fieldID is "Z" then
set district to (text 4 thru -1 of
(thisField as string))
else if fieldID is "7" then
set theDate to (text 4 thru -1 of
(thisField as string))
else if fieldID is "t" then
set copyright to (text 4 thru -1 of
(thisField as string))
end if
end try
end repeat
return {Caption, Byline, district, theDate, copyright}
end extractIPTC
--end script
cheers,
Paul Welch
--
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.