Processing Image Data

This tutorial was used to create the script steps below. Devices like digital cameras and smartphones use the EXIF standard to save image files. This standard includes many useful tags in the photo including the date and time of image creation, make and model of the device, focal length and other properties of the camera, and GPS information.

Processing steps below also taken from this medium article.

from exif import Image
with open('processing-image-data/IMG_0564.jpeg', "rb") as src:
    img = Image(src)
    if img.has_exif:
        info = f"has the EXIF {img.exif_version}"
    else:
        info = "does not contain any EXIF information"
    print(f"Image {src.name}: {info}")
Image processing-image-data/IMG_0564.jpeg: has the EXIF 0232
all_img_attributes = img.list_all()
all_img_attributes
['make',
 'model',
 'x_resolution',
 'y_resolution',
 'resolution_unit',
 'software',
 'datetime',
 '_exif_ifd_pointer',
 '_gps_ifd_pointer',
 'exposure_time',
 'f_number',
 'exposure_program',
 'photographic_sensitivity',
 'exif_version',
 'datetime_original',
 'datetime_digitized',
 'offset_time',
 'offset_time_original',
 'offset_time_digitized',
 'shutter_speed_value',
 'aperture_value',
 'brightness_value',
 'exposure_bias_value',
 'metering_mode',
 'flash',
 'focal_length',
 'subject_area',
 'maker_note',
 'subsec_time',
 'subsec_time_original',
 'subsec_time_digitized',
 'pixel_x_dimension',
 'pixel_y_dimension',
 'sensing_method',
 'scene_type',
 'exposure_mode',
 'white_balance',
 'focal_length_in_35mm_film',
 'lens_specification',
 'lens_make',
 'lens_model',
 'gps_latitude_ref',
 'gps_latitude',
 'gps_longitude_ref',
 'gps_longitude',
 'gps_altitude_ref',
 'gps_altitude',
 'gps_speed_ref',
 'gps_speed',
 'gps_img_direction_ref',
 'gps_img_direction',
 'gps_dest_bearing_ref',
 'gps_dest_bearing',
 'gps_horizontal_positioning_error']
for attribute in all_img_attributes:
    try:
        print(f"{attribute:30}: {img[attribute]}")
    except:
        pass
make                          : Apple
model                         : iPhone 12 Pro
x_resolution                  : 72.0
y_resolution                  : 72.0
resolution_unit               : 2
software                      : 15.0
datetime                      : 2021:09:26 12:38:40
_exif_ifd_pointer             : 234
_gps_ifd_pointer              : 2346
exposure_time                 : 0.008264462809917356
f_number                      : 1.6
exposure_program              : 2
photographic_sensitivity      : 50
exif_version                  : 0232
datetime_original             : 2021:09:26 12:38:40
datetime_digitized            : 2021:09:26 12:38:40
offset_time                   : -07:00
offset_time_original          : -07:00
offset_time_digitized         : -07:00
shutter_speed_value           : 6.922789819228348
aperture_value                : 1.3561438092556088
brightness_value              : 4.822726012201886
exposure_bias_value           : 0.0
metering_mode                 : 5
flash                         : Flash(flash_fired=False, flash_return=<FlashReturn.NO_STROBE_RETURN_DETECTION_FUNCTION: 0>, flash_mode=<FlashMode.COMPULSORY_FLASH_SUPPRESSION: 2>, flash_function_not_present=False, red_eye_reduction_supported=False, reserved=0)
focal_length                  : 4.2
subject_area                  : 0
subsec_time                   : 892
subsec_time_original          : 892
subsec_time_digitized         : 892
pixel_x_dimension             : 4032
pixel_y_dimension             : 3024
sensing_method                : 2
exposure_mode                 : 0
white_balance                 : 0
focal_length_in_35mm_film     : 26
lens_specification            : (1.5399999618512084, 6.0, 1.6, 2.4)
lens_make                     : Apple
lens_model                    : iPhone 12 Pro back triple camera 4.2mm f/1.6
gps_latitude_ref              : N
gps_latitude                  : (35.0, 49.0, 19.57)
gps_longitude_ref             : W
gps_longitude                 : (121.0, 22.0, 10.33)
gps_altitude_ref              : 0
gps_altitude                  : 345.975988700565
gps_speed_ref                 : K
gps_speed                     : 0.0
gps_img_direction_ref         : T
gps_img_direction             : 92.0939483707152
gps_dest_bearing_ref          : T
gps_dest_bearing              : 92.0939483707152
gps_horizontal_positioning_error: 4.697008468896606