26 lines
629 B
Python
26 lines
629 B
Python
import sys
|
|
import zlib
|
|
import json
|
|
import piexif
|
|
from PIL import Image
|
|
import uu
|
|
from io import BytesIO
|
|
|
|
def zlib_uudecode(databytes):
|
|
''' uudecode databytes and decompress the result with zlib '''
|
|
inbuff = BytesIO(databytes)
|
|
outbuff = BytesIO()
|
|
uu.decode(inbuff, outbuff)
|
|
return zlib.decompress(outbuff.getvalue())
|
|
|
|
faceId = int(sys.argv[1])
|
|
path = f'faces/{"{:02d}".format(faceId % 10)}'
|
|
|
|
img = Image.open(f'{path}/{faceId}.jpg')
|
|
exif_dict = piexif.load(img.info["exif"])
|
|
compressed_str = exif_dict["Exif"][piexif.ExifIFD.UserComment]
|
|
|
|
str = zlib_uudecode(compressed_str)
|
|
json = json.loads(str)
|
|
print(json)
|