mirror of
https://github.com/gryf/pygtktalog.git
synced 2025-12-17 11:30:19 +01:00
Added EXIF tag handling for images.
This commit is contained in:
@@ -10,6 +10,7 @@ import re
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import mimetypes
|
import mimetypes
|
||||||
|
|
||||||
|
import exifread
|
||||||
from pycatalog.dbobjects import File, TYPE
|
from pycatalog.dbobjects import File, TYPE
|
||||||
from pycatalog import dbcommon
|
from pycatalog import dbcommon
|
||||||
from pycatalog.logger import get_logger
|
from pycatalog.logger import get_logger
|
||||||
@@ -216,9 +217,22 @@ class Scan(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def _image(self, fobj, filepath):
|
def _image(self, fobj, filepath):
|
||||||
# exif?
|
"""Read exif if exists, add it to description"""
|
||||||
|
with open(filepath, 'rb') as obj:
|
||||||
|
exif = exifread.process_file(obj)
|
||||||
|
if not exif:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
data = []
|
||||||
|
# longest key + 2, since we need a colon and a space after it
|
||||||
|
longest_key = max([len(k) for k in exif]) + 2
|
||||||
|
for key in exif:
|
||||||
|
if 'thumbnail' in key.lower() and isinstance(exif[key], bytes):
|
||||||
|
data.append(f"{key + ':' :<{longest_key}}thumbnail present")
|
||||||
|
continue
|
||||||
|
data.append(f"{key + ':' :<{longest_key}}{exif[key]}")
|
||||||
|
fobj.description = "\n".join(data)
|
||||||
|
|
||||||
def _video(self, fobj, filepath):
|
def _video(self, fobj, filepath):
|
||||||
"""
|
"""
|
||||||
Make captures for a movie. Save it under uniq name.
|
Make captures for a movie. Save it under uniq name.
|
||||||
|
|||||||
Reference in New Issue
Block a user