pythonimage-processingpython-imaging-librarylightroompyexiv2

image title tag missing in PIL and pyexiv2 after Lightroom export


Lightroom allows to modify photo's Title and ImageDescription tags. Title is a non-conform EXIF tag, so it is saved it somewhere else, but not in the EXIF tags directly.

I want to parse image tags using Python. I tried using PIL and pyexiv2. Neither can retrieve image title from the EXIF tags, though it can be seen in Windows' File properties/details window.

I use Python 2.7.2 32bit on Windows 7 home.

Any ideas?


Solution

  • Strange that no-one could help, but I have figured it out by now.

    JPG image information is stored in EXIF and IPTC tags. Adobe Lightroom stores title and image description in IPTC.Application.Caption & IPTC.Application.ImageDescription tags. Adobe Photoshop stores headline and image description in IPTC.Application.Headline & IPTC.Application.ImageDescription respectively. These tags can be easily extracted using pyexiv2:

    import pyexiv2
    
    # read image
    metadata = pyexiv2.ImageMetadata(path_to_image)
    metadata.read()
    
    # now the metadata has been parsed and is ready to be extracted
    title = metadata[Iptc.Application2.Caption][0]
    imageDescription = metadata[Iptc.Application2.ImageDescription][0]
    

    See here for more info to IPTC tags in pyexiv2.