Sitemap

Amicuk Programming Answers

How do I get the caption (Description) out of an image's metadata?

2015-10-11   Views:0

Advertisement

Taking a break from a monstrous project that has had me tied up for days, I have embarked upon what I thought would be a bit of light relief (hah!). A colleague asked me for an easy way to get captions into InDesign. So I started scripting there, ask

Taking a break from a monstrous project that has had me tied up for days, I have embarked upon what I thought would be a bit of light relief (hah!).
A colleague asked me for an easy way to get captions into InDesign. So I started scripting there, asking for the "description of the link xmp".
This was not forthcoming and a search of the InDesign scripting forum yielded the information that in order to get this information it was necessary to open the doc in Photoshop, save it and re-link. This indeed does work, but it is a waste of time in the file-saving stage and also degrades the image, as we have a jpg workflow.
So I thought that if I was going to have to got to Photoshop anyway, why not have the script go straight there, open the doc, ask for the description and close without saving?
Photoshop so far has jealously guarded its XMP information.
In Applescript I ask go "set theData to raw data of XMP metadata of document 1" and there it is in the event log, but in forbidding red type. I try adding "as string" and it appears twice, once in friendly black type, enclosed in quotes, and then the red stuff. However I find myself refused access to the information in the variable.
AS or JS solutions welcome...

The replay answer
Advertisement
tell application "Adobe InDesign CS2"
activate
tell active document
set This_Selection to get selection
try
if This_Selection ≠ {} then
if length of This_Selection ≠ 1 then
display dialog "You have more than 1 item seleted!!!" giving up after 2
else
if class of item 1 of This_Selection is image then
set This_Image to item 1 of This_Selection
end if
if class of item 1 of This_Selection is rectangle then
set This_Image to image 1 of item 1 of This_Selection
end if
set Image_Path to file path of item link of (item 1 of This_Image)
set MDLS_Result to my Get_XMP_Description(Image_Path)
set {ASTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, " = "}
set Image_Desc to text item 2 of MDLS_Result
set AppleScript's text item delimiters to ASTID
display dialog Image_Desc giving up after 2
end if
else
display dialog "You have 0 items seleted!!!" giving up after 2
end if
on error
display dialog "This rectange contains NO image!!!" giving up after 2
end try
end tell
end tell
on Get_XMP_Description(File_Path)
try
do shell script "/usr/bin/mdls -name kMDItemDescription " & quoted form of POSIX path of File_Path
return the result
on error
return false
end try
end Get_XMP_Description

Go to See the other 25 answers

How do I get the caption (Description) out of an image's metadata?

Category:DefaultRelease time:2015-10-11Views:130

Taking a break from a monstrous project that has had me tied up for days, I have embarked upon what I thought would be a bit of light relief (hah!). A colleague asked me for an easy way to get captions into InDesign. So I started scripting there, ask[More]

Exporting Metadata (caption information) from JPEGS to a comma separated value (CSV) file

Category:DefaultRelease time:2015-10-11Views:130

Here is my dilemma. I am an archivist at an arts organization and we are in the process of digitizing many of our materials to post them on the web and make them available to internet users. One of the principle components of our collection is a larg[More]

IPhoto 9.6 does not include photo description in export file

Category:DefaultRelease time:2015-10-11Views:130

My system is current with OS X Yosemite 10.10.1, iPhoto 9.6, Preview 8.0 The caption/description does not export from iPhoto. I have not exported files from previous iPhoto versions expecting the file to contain the iPhoto Caption/Description. This i[More]

Hot
Developed an application using LabVIEW 6.1 and LabVIEW Report Generation Toolkit for Microsoft Office 1.0.1. From there, tried to build a shared application for use with the LabVIEW Run Time Engine. The Run Time version functions properly until "New [More]
I recently bought a 6070 phone. I had no problem of connecting this to my computer (XP Home SP 2) for 6.81.13.0, using cable CA-42. But then I got the mad idea to look for an update and installed 6.84.10.3 (should work for 6070 according to what they [More]
Hi,      is there any provision in po where i can see the total of all the quantities and values that i have entered. example: material          QTY              Price ABC                20                 10 xyz                 13                  2 [More]
this has been going for a long time -- cannot open an email from my inbox -- it hangs and hangs -- tried cntr-click to open in a new tab -- same hanging. various results when it stops attempting: error code 7 -- or totally blank screen -- or "were wo [More]
How do i fix my plist to have only iPhone 4 and iPhone 4s as my binary keeps complaining that I made it for both iPhone and iPad, when I ment to make it for iPhone only.In Xcode, set your Targets iOS Application Target Devices to iPhone; you must hav [More]
Hello everyone, My hard drive crashed a few months ago, and I did not have a back up. So I now have this jam packed iPhone and a brand new iTunes library. I recently downloaded some new songs to the library (like that Blackberry commercial 'All You N [More]
how do i remove my credit card information from my ccount so that i may use my redeem moneyYou've followed the instructions on the HT1918 page that you posted from for removing credit card details ? If you don't get the 'none' option on your account [More]
When I sync my iPhone to my PC the times for my appointments are one hour earlier on my iPhone. So if I have a 10 am meeting, it is showing up as a 9 am meeting on my iPhone. Any help would be appreciated.Hey MCW120, Do you have the Time Zone set cor [More]
Hi, I have been using my macbook pro as a home media server, hosting most content on the macbook with ipod touch, ipads, and appletv streaming/sharing content.  I have run out of space on both the macbook pro and the apple tv and am looking to moving [More]
Hi There, I have been trying to find an answer for 1 day. I don't know ehre to look next. I am creating a CMP entity bean. I have created all the set and get mehtods as abstract functions. I have added a ejbCreate and a matching ejbPostCreate. The cl [More]