0

We are detecting faces from the video. Subsequently we are generating images from every face detected. We need to record the image timestamp.

We observed that the parameter (modified) needs to read from the image properties.

I've tried with the below snippet:

import EXIF
from PIL import Image
from PIL.ExifTags import TAGS

def get_exif(fn):
    ret = {}
    i = Image.open(fn)
    info = i._getexif()
    for tag, value in info.items():
        decoded = TAGS.get(tag, tag)
        ret[decoded] = value
    return ret


photo_path = "test.jpg"
data = get_exif(photo_path)

It is returning blank. Please suggest a solution.

khelwood
  • 55,782
  • 14
  • 81
  • 108
  • Is your image file in the same directory as your script? Otherwise, you should provide the real path or relative path. – Chamin Wickramarathna Sep 05 '17 at 13:52
  • its in the same directory – Avinaash Gollapudi Sep 06 '17 at 04:22
  • What do you mean by „blank“? Does `test.jpg` actually _have_ EXIF data stored? How did you check this? – BlackJack Sep 06 '17 at 13:09
  • Actually the image is generated from MP4 file. it has only "modified time" it does not have complete EXIF data – Avinaash Gollapudi Sep 07 '17 at 08:14
  • Which library is used (name, version)? What is the error message (if any)? Is the library able to read incomplete metadata? Which metadata are mandatory? – mcepl Sep 07 '17 at 08:35
  • What do you mean by „modified time“? Which EXIF tag holds this information? The _DateTime_ tag is understood by `PIL`. Is `data` really empty? Which program did you use to check that the tag is actually in the file? – BlackJack Sep 12 '17 at 14:25

0 Answers0