tag on Exif PIL Python

在 Python 下讀 Exif 有好些種方法,我慣用的 PIL 也有一些未公開的方法可以支援:

#-*- coding: UTF-8 -*-

from glob import glob

import Image
from ExifTags import TAGS

files = glob(u"*.JPG")
im = Image.open(files[0])
rawexif = im._getexif()
exif = dict([(TAGS.get(k,0), rawexif[k]) for k in rawexif])
for k in sorted(exif.keys()):
    print k, exif[k]

不過不知道怎麼用 PIL 儲存修改過的 Exif。jpeg.py 可以儲存 exif,不過現在抓不下來。算了,我還不想自己刻。

Posted by yungyuc at 13:49, 0 comment, 0 trackback.
Navigate
Add a trackback
Add a comment

Your name. (required)

Your personal website. (optional)

Your email address. Will not show in page. (suggested, but optional)

Text format is "Plain Text".

Enter "AWnGK"
© hover year to navigate month: powered by django