View Single Post
Old 05-18-2024, 12:45 PM   #18
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,740
Karma: 24031403
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by KevinH View Post
What are people's thoughts on this.
Since IPTC metadata seems to be less commonly used than EXIF metadata, a compromise might be grabbing the ImageDescription EXIF metadata entry with Pillow.

This requires only a few lines of code:
Spoiler:
Code:
# -*- coding: utf-8 -*-
import sys, os
from io import BytesIO
from PIL import Image

def run(bk):
    imgdata = bk.readfile('Image1219.jpg')
    img = Image.open(BytesIO(imgdata)).convert('L')
    image_description = None
    exif = img.getexif()
    # 270 = ImageDescription
    if exif and 270 in exif:
        image_description = exif[270]
        print(image_description)

    return 0

def main():
  print ("I reached main when I should not have\n")
  return -1

if __name__ == "__main__":
  sys.exit(main())


The code will return the string: A Prince looks out between the bars of a prison window.
(It refers to this image provided by the OP.)

IMHO, automatically extracting some human generated description with Acess-Aide is better than extracting no description at all.

@oston would extracting the ImageDescription information be helpful to you?
Doitsu is offline   Reply With Quote