machinevisiontoolbox.Image.metadata

Image.metadata(key=None)

Get image EXIF metadata

Parameters:

key (str, optional) – metadata key

Returns:

image metadata

Return type:

dict, int, float, str

Get image metadata from EXIF headers.

Example:

>>> from machinevisiontoolbox import Image
>>> img = Image.Read('church.jpg')
>>> meta = img.metadata()  # get all metadata as a dict
>>> len(meta)
38
>>> meta
{'ResolutionUnit': 2, 'ExifOffset': 188, 'Make': 'Panasonic', 'Model': 'DMC-FZ30', 'Software': 'Ver.1.0  ', 'Orientation': 1, 'DateTime': '2009:08:22 15:50:06', 'XResolution': 72.0, 'YResolution': 72.0, 'ExifVersion': b'0220', 'FlashPixVersion': b'0100', 'CompressedBitsPerPixel': 4.0, 'DateTimeOriginal': '2009:08:22 15:50:06', 'DateTimeDigitized': '2009:08:22 15:50:06', 'ExposureBiasValue': 0.0, 'MaxApertureValue': 3.0, 'MeteringMode': 5, 'LightSource': 0, 'Flash': 16, 'FocalLength': 7.4, 'ColorSpace': 1, 'ExifImageWidth': 1280, 'DigitalZoomRatio': 0.0, 'FocalLengthIn35mmFilm': 37, 'SceneCaptureType': 0, 'ExifImageHeight': 851, 'Contrast': 0, 'Saturation': 0, 'Sharpness': 0, 'SensingMethod': 2, 'ExposureTime': 0.0025, 'FNumber': 8.0, 'ExposureProgram': 2, 'CustomRendered': 0, 'ISOSpeedRatings': 80, 'ExposureMode': 0, 'WhiteBalance': 0, 'GainControl': 0}
>>> meta['FocalLength']
7.4
>>> img.metadata('FocalLength')  # get specific metadata item
7.4
Note:

Metadata items will be converted, where possible, to int or float values.