4

I have a photo community (www.jungledragon.com) that allows users to upload photos. My platform is PHP/CodeIgniter.

As part of the upload process I'm already reading EXIF info using PHP's exif_read_data function, which works fine. I read camera details and show these on an info tab.

On top of that, user's are expected to manually set the photo title, description and tags on the website after uploading the photo. However, some users manage these fields in their image management program, for example Lightroom. It would be great if I could read those as well, uploading would become a total joy.

I already improved my EXIF reading to read the "caption", this way users don't have to set the image title after uploading anymore. Now I'm looking to read keywords, which is where I am stuck. Here's a partial screenshot of an image in Lightroom:

enter image description here

I can read the Metadata, but how do I read the keywords? The fact that it is not inside metadata makes me wonder if it's at all possible? I've tried reading every value I can get (ANY_TAG, IFD0, EXIF, APP12) using exif_read_data, but the keywords are not to be found.

Any thoughts?

skaffman
  • 398,947
  • 96
  • 818
  • 769
Fer
  • 4,116
  • 16
  • 59
  • 102
  • I think you should inspect the images with some other software so that you can rule out any limitations in the php metadata reading. Also, how is LR configured for exporting keywords? see e.g. http://lightroomsecrets.com/2010/11/keywords-and-exported-images/ – Anders Forsgren Aug 13 '11 at 21:46
  • Thanks. I actually downloaded a photo that one user uploaded to my site of which he claimed it has keywords. The screenshot I included shows that same photo imported into LR. I think that verifies that the file contains it? – Fer Aug 13 '11 at 22:39
  • Hi Ferdy. This is an old post now. Was the problem ever resolved? I'm looking to save keywrods from LR too, plus a bunch of other metadata values. Lots of sample code I've seen suggest reading the APP13 array, but I don't seem to have that in my test images. – M61Vulcan May 24 '19 at 17:01
  • @M61Vulcan Scroll down, the answer is there. – Fer May 24 '19 at 21:20
  • Thanks for your quick reply on this old topic. The link to foto.biz is no longer valid and the php.net iptcparse explanation keeps referencing 'APP13' which I don't have in my metadata. I have found the keywords together with the Lightroom Title and Caption in IFD0.ExtensibleMetadataPlatform: as a big long unformatted string (about 266 characters depending on image) but when I beging to cut up the string it becomes 12,917 characters with tons of other metadata in it. Presumeably there's some hidden character somewhere. It's out of the scope of this question in any case. I'll get back to it. – M61Vulcan May 26 '19 at 11:17

3 Answers3

6

As suggested you may have to use another method of reading metadata.

http://www.foto-biz.com/Lightroom/Exif-vs-iptc-vs-xmp

Image keywords may be stored in IPTC and not in EXIF. I don't know if there is a standard platform method for reading iptc but a quick google shows this

http://php.net/manual/en/function.iptcparse.php

Anders Forsgren
  • 10,827
  • 4
  • 40
  • 77
  • Thanks, very useful. Will give this a try and report back soon. – Fer Aug 15 '11 at 08:04
  • 1
    It works :) The official example of the iptcparse function gave me the results I needed instantly. Thanks so much! – Fer Aug 15 '11 at 12:50
1

After a long research, i found the solution to get keywords exported by lightroom in a jpg file :

$image = getimagesize($imagepath, $info);
if(isset($info['APP13']))
{
    $iptc = iptcparse($info['APP13']);
    $keywordcount = count($iptc["2#025"]);
    for ($i=0; $i<$keywordcount; $i++)
    { 
        echo "keyword : " . $iptc["2#025"][$i] . "<br/>";
    }
}
Laurent
  • 11
  • 1
1

Try using PEL, a much more comprehensive library than exif_read_data() for exif data.

r0nny1l
  • 172
  • 1
  • 8
  • Thanks for the suggestion, but can PEL be installed without command line? The reason I ask is because of my host. – Fer Aug 13 '11 at 22:18
  • I had the same problem, so I just downloaded the source, and uploaded it to somewhere on my server. – r0nny1l Aug 14 '11 at 09:10