• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Reading IPTC and EXIF information from photos
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading IPTC and EXIF information from photos


  • Subject: Re: Reading IPTC and EXIF information from photos
  • From: wayne melrose <email@hidden>
  • Date: Tue, 11 Oct 2011 09:43:46 +0200


On Oct 11, 2011, at 8:20 AM, Jan Erik Moström wrote:

On Monday, October 10, 2011 at 19:53 , wayne melrose wrote:

On Oct 10, 2011, at 6:36 PM, Jan Erik Moström wrote:
Is there some other way of getting the IPTC/EXIF info other than
'mdls', is there for example a scripting addition that would get the
info for me?


Excuse my ignorance.. but are you saying you can't get the info from mdls or don't want to use that tool?  
I think that mdls can give me everything (can't test for headline at the moment) but I want to see if there is some other way of reading the info so I can make a decision what to use.

I'm also thinking that launching a shell, calling mdls and getting it to generate a plist, and then interpret that plist in Applescript (using one of the XML scripting additions) might take some extra time if I have many photos to process. (but I'm perhaps missing a better way of doing it?)

Right now - mdls is my top candidate but I want to see if there is something else out there.

- jem
_______________________________________________


I hope you find this useful, I did something like this a while ago, of course, can't find the code.. So I've rebuilt it..  I think this a bit different.. This looks a bit dirty, but if you call on this function, you'll get an applescript record as the result. then you can just call on the variable, which matches the mdls name .. 


set recordResult to getMDLSDetails("/Users/me/Pictures/IMG_0123.JPG")
set intHeight to kMDItemPixelHeight of recordResult

on getMDLSDetails(strFilePath)


set strCommandResult to do shell script "mdls " & (quoted form of strFilePath)
set strCommandResult to replaceText(strCommandResult, "," & return, ", ")
set strCommandResult to replaceText(strCommandResult, "(" & return, "")
set strCommandResult to replaceText(strCommandResult, return & ")", "")


set lstItems to paragraphs of strCommandResult
set lstScriptItems to {}
repeat with strLine in lstItems


if strLine contains "Date" then --> convert to strings
set strLine to replaceText(strLine, "=", "=\"") & "\""
else if strLine contains "kMDItemContentTypeTree" then --> create list
set strLine to replaceText(strLine, "=", "={") & "}"
else if strLine contains "kMDItemFSName" then --> seems to be a bug in mdls
set strLine to strLine & "\""
end if
set strLine to replaceText(strLine, "=", ":")
set lstScriptItems to lstScriptItems & strLine
end repeat
set AppleScript's text item delimiters to ", "


set strScript to lstScriptItems as string
set AppleScript's text item delimiters to ""
set strScript to "{" & strScript & "}"


return run script strScript


end getMDLSDetails

on replaceText(strText, strCharactersToReplace, strReplacementCharacters)
set AppleScript's text item delimiters to strCharactersToReplace
set lstOriginalTextItems to text items of strText
set AppleScript's text item delimiters to strReplacementCharacters
set strResult to lstOriginalTextItems as string
set AppleScript's text item delimiters to ""
return strResult as Unicode text
end replaceText

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Reading IPTC and EXIF information from photos
      • From: Jan Erik Moström <email@hidden>
References: 
 >Reading IPTC and EXIF information from photos (From: Jan Erik Moström <email@hidden>)
 >Re: Reading IPTC and EXIF information from photos (From: wayne melrose <email@hidden>)
 >Re: Reading IPTC and EXIF information from photos (From: Jan Erik Moström <email@hidden>)

  • Prev by Date: Re: Reading IPTC and EXIF information from photos
  • Next by Date: Re: Inoperative Dialog
  • Previous by thread: Re: Reading IPTC and EXIF information from photos
  • Next by thread: Re: Reading IPTC and EXIF information from photos
  • Index(es):
    • Date
    • Thread