it's not clear for me why should an exception should be raised if exif data is not present, it can be initialized like jpeg loader or at least a dedicated exception can be raised instead. The current behavior is making it hard to handle if there is no exif.
def get_exif(data):
if data[0:4] != b"RIFF" or data[8:12] != b"WEBP":
raise ValueError("Not WebP")
if data[12:16] != b"VP8X":
raise ValueError("doesnot have exif")
i think this behavior in jpeg loader, is more natural:
def load(input_data, key_is_name=False):
"""
py:function:: piexif.load(filename)
Return exif data as dict. Keys(IFD name), be contained, are "0th", "Exif", "GPS", "Interop", "1st", and "thumbnail". Without "thumbnail", the value is dict(tag name/tag value). "thumbnail" value is JPEG as bytes.
:param str filename: JPEG or TIFF
:return: Exif data({"0th":dict, "Exif":dict, "GPS":dict, "Interop":dict, "1st":dict, "thumbnail":bytes})
:rtype: dict
"""
exif_dict = {"0th":{},
"Exif":{},
"GPS":{},
"Interop":{},
"1st":{},
"thumbnail":None}
exifReader = _ExifReader(input_data)
if exifReader.tiftag is None:
return exif_dict
Hi
it's not clear for me why should an exception should be raised if exif data is not present, it can be initialized like jpeg loader or at least a dedicated exception can be raised instead. The current behavior is making it hard to handle if there is no exif.
i think this behavior in jpeg loader, is more natural: