Extract IPTC tags from images within iPhoto

Hello all!

I’m a recent switcher and totally new to Applescript, though I’m not new to programing (I’m an analyst-programer myself). I searched for this information every where, but I can’t find anything (except paying software). So, here’s my little project :

I want to be able to extract (read) IPTC tags, more specifically keywords (tags that a user puts to categorize his images), in order to recreate those tags as categories in iPhoto. This, from pictures imported in iPhoto. The objective is to facilitate the switching of users from PC to Mac, especially those with tons of pictures stored in Adobe Photoshop Album. Album 2 (and Photoshop CS, using the File Browser) have the option to write these tags to files. Any user could simply write them and this little script would be called to extract the tags, and reconstruct the hierarchy in iPhoto automatically. This project, if it works, will allow several persons to switch easily from Windows to Mac.

I’ve looked at Caption buddy but the commands it uses only extract the title and caption of the images. I have no clue how to extract the keyword(s). I’ve also looked at the scripts found on Apple’s Applescript website, but they’re for iPhoto 2 and are giving me error message (i.e. the JPG object does not understand the… ).

What’s more frustrating (from my point of view) is that if you do a Get Info on an image which contains IPTC tags, the Finder will show them!!! So, under Mac OS, there must a way to manipulate this info without relying on a 3rd party software.

So, my specific questions :

  • Anybody knows where to start ? (just kidding I already got two books on AppleScript and will read them next week-end) :slight_smile:
  • Is there web resources that explains how to do this (I search AppleScript IPTC, Metadata, IPDC, nothing)
  • Routines I could modify to extract the data ?
  • I saw a Metadata Tag inside the dictionary of Image Events but I don’t understand how to use it. Any help there as well ?

Thanks a lot for any help you can give me!

Ray

Model: PowerMac G5 dual pro 1.8Ghz
AppleScript: 1.10
Browser: Safari 412
Operating System: Mac OS X (10.4)

Just wondering what OS are you running? Is it Tiger? I ask because I don’t see IPTC tags with Get Info and I am running 10.3.9. The “Image Events” metadata tags are not what you expect. At least not what I expected when I first saw the entry in the dictionary. Metadata tags are mostly the image properties (color space, height, width…) wrapped up as a list of records.
In any event, you should have a copy of GraphicConverter in your Applications/Utilities directory. Its been included with every version of OS X that I have used. It is a wonderful utility but I find the object model odd. All of the things that I think of as properties of the image are found as properties of the “window” in GraphicConverter. Try this:

   set f_ref to alias "some:path:to:a:file"

   tell application "GraphicConverter"
        open f_ref  -- This doesn't return a result.  I hate that
        tell window 1
             set doc_keywords to IPTC keywords
             close saving no
        end tell
   end tell

I'm sure that there are also UNIX shell options available and I'd be shocked if someone didn't offer those solutions before this thread is done.

Browser: Safari 312
Operating System: Mac OS X (10.3.9)

OK, I never noticed the operating system information in your original post. Must be part of the new web site. Since you are using 10.4, try:

set image_info to info for alias “some:file:path”

I don’t have 10.4 available currently but, in the past, “info for” has returned everything available in the Finder window “Get Info”.

Browser: Safari 312
Operating System: Mac OS X (10.3.9)

Thanks a lot, that has got me on the right track. However, this solution doesn’t show what I want. I’ve prepared a screen capture I uploaded on my Pbase account :

http://www.pbase.com/carbone/image/43207414

What I’m seeking is under the More Info section, under the Keywords tag.

Also, why is that when I search for info in the dictionary for the Finder, I never found this property… ?

info brought information window, not info alone.

Thanks again,

Ray

Model: PowerMac G5 dual pro 1.8Ghz
AppleScript: 1.10
Browser: Safari 412
Operating System: Mac OS X (10.4)

Since I’m not the sharpest tack in the pack, let me ask you this. For “Picture 1.jpg”, does “Michael” show up under the “File Info” in Photoshop somewhere?

Browser: Safari 312
Operating System: Mac OS X (10.3.9)

Hi,

Yes, it does. In both Photoshop CS2 and Preview

http://www.pbase.com/carbone/image/43222655

(then click next at the top right corner, you’ll see the same thing in Preview).

Ray

Model: PowerMac G5 dual pro 1.8Ghz
AppleScript: 1.10
Browser: Safari 412
Operating System: Mac OS X (10.4)

I’ve uploaded two utilities that do what you want to:

http://scriptbuilders.net/files/iphotoiptckeywordimportexportutilities1.0.html

They use GraphicConverter and Keyword Assistant for iPhoto to do the bulk of the work and Applesccript studio to display a progress bar.