smarnach / pyexiftool

a Python library to communicate with an instance of Phil Harvey's excellent ExifTool command-line application.
Other
270 stars 111 forks source link

Read from BytesIO image? #33

Open apiszcz opened 3 years ago

apiszcz commented 3 years ago

Is it possible to retrieve exiftools metadata from a BytesIO object? I am trying the following, with error below.

img = Image.open('bus.jpg')
buf = io.BytesIO()
img.save(buf, 'jpeg')
imgbytes = buf.getvalue()
exif = exiftool.ExifTool.get_metadata(imgbytes)
pprint.pprint(exif)
 testexif.py
Traceback (most recent call last):
  File "C:\test\testexif.py", line 8, in <module>
    exif = exiftool.ExifTool.get_metadata(imgbytes)
TypeError: get_metadata() missing 1 required positional argument: 'filename'
sylikc commented 2 years ago

I don't think we can pipe data to exiftool because we're already using it for commands https://exiftool.org/forum/index.php?topic=3098.0