Page 1 of 2

Read Keywords from JPG

Posted: 2010-06-17T12:06:45-07:00
by brethomp
I'm using the ImageMagickObject in a classic ASP environment. What I would like to do is read the keywords that other programs have put in there (like Adobe Bridge and Picasa) out of JPG files . With TIF files I have it working, using "identify" and "%[IPTC:2:25]", but with JPG files this field seems to be blank, unless the JPG originated from a TIF that had keywords in it. Where can I find the keywords in JPG files?

ImageMagick-6.6.2-3-Q16

Re: Read Keywords from JPG

Posted: 2010-06-17T12:12:35-07:00
by magick
The metadata in JPEG image files are typically encoded in the EXIF profile rather than IPTC.

Re: Read Keywords from JPG

Posted: 2010-06-17T12:31:38-07:00
by brethomp
Thanks for the reply. I couldn't find any keywords in the EXIF data. I built a loop to go through all of the EXIF "tags" that are listed on this site http://www.imagemagick.org/script/escape.php. Are there other EXIF "tags" that the keywords could be under? I did also try %[EXIF:*], and didn't see any keywords there either.

Re: Read Keywords from JPG

Posted: 2010-06-17T13:16:04-07:00
by Drarakel
Are you sure that your JPG file contains the keywords?
You can use "identify -verbose file.jpg" to display most of the metadata.

Re: Read Keywords from JPG

Posted: 2010-06-17T14:08:04-07:00
by brethomp
Yep, there are definitely keywords in the files, since Adobe Bridge can see them. Further research is leading me to believe that the keywords I am looking for are not stored in EXIF or IPTC. It appears that Adobe and Microsoft have a different place to store them called XMP. Can ImageMagick read XMP?

Re: Read Keywords from JPG

Posted: 2010-06-17T14:11:34-07:00
by snibgo
convert in.jpg out.xmp

Re: Read Keywords from JPG

Posted: 2010-06-17T14:33:14-07:00
by Bonzo
We might be looking at the same brethomp thing see viewtopic.php?f=1&t=16454

How did you input your keywords ?

If you open the image in a program like Notepad++ or a hex editor are they in an XML portion at the end of the file ?

Re: Read Keywords from JPG

Posted: 2010-06-17T15:00:56-07:00
by brethomp
Bonzo,

Yes, if I open the JPG images in Notepad, I can find my keywords in the file. They are in a XML looking portion of the file, but in my case near the beginning of the file. In this format:

Code: Select all

<dc:subject>
    <rdf:Bag>
        <rdf:li>Keyword 1</rdf:li>
        <rdf:li>Keyword 2</rdf:li>
        <rdf:li>Keyword 3</rdf:li>
    <rdf:Bag>
</dc:Subject>
Edit: I missed one of your questions. The keywords were entered using Adobe Bridge.

Re: Read Keywords from JPG

Posted: 2010-06-17T15:04:30-07:00
by snibgo
Post a sample.

Re: Read Keywords from JPG

Posted: 2010-06-18T05:53:04-07:00
by brethomp
snibgo wrote:Post a sample.
Is it possible to post files on this forum?

Re: Read Keywords from JPG

Posted: 2010-06-18T06:27:21-07:00
by brethomp
snibgo wrote:convert in.jpg out.xmp
Thanks snibgo, this works, but not optimal. The resulting "out.xmp" file is a text file containing only the XMP metadata. Now I just have to parse the XMP file to get the keywords...

Re: Read Keywords from JPG

Posted: 2010-06-18T06:39:01-07:00
by Drarakel
brethomp wrote:Is it possible to post files on this forum?
Don't think so - at least not as fresh user.(?)
FAQ
But you could use one of the various file hosting sites.

Re: Read Keywords from JPG

Posted: 2010-06-18T07:58:10-07:00
by brethomp
snibgo wrote:convert in.jpg out.xmp
This method only seems to work with JPG files.

Re: Read Keywords from JPG

Posted: 2010-06-18T09:09:24-07:00
by Drarakel
No, it works with other formats, too - TIF/PNG/etc. But it's possible for some special files that a certain profile isn't recognized.

Re: Read Keywords from JPG

Posted: 2010-06-18T10:43:52-07:00
by Bonzo
It worked with a jpg file where the data was around line 54 but not on a CR2 file where the data was at the end on line 186187. Both lots of data were added to the image using Microsoft pro photo tools. No idea why my data was in the image or at the end and and brethomp had his at the start.

I have not had any experiance of this but thought an xmp file was a file linked to and image not part of the image file. Will need some more investigation.