Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Python 3: working with files and digital assets/Image/EXIF data

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

EXIF Data Requirement %pip install pillow pip install pillow Retrieval of data Code Snippetimage exif information tutorial.ipynb https://gist.github.com/KentVejrupMadsen/b8ea88a377d4f83f0460d1c9635e505f 2023-07-12 Gist en: from PIL import Image from PIL.ExifTags import TAGS as exif_tags # location of the image you want to extract the exif information from location_of_file: str = '' def retrievement_of_exif_table( exif_information ) -> dict: exif_table: dict = {} for key, value in exif_information.items(): exif_label = exif_tags.get(key) if not( exif_label is None ): exif_table[exif_label] = value return exif_table exif_table = {} with Image.open(location_of_file) as image: exif_table = retrievement_of_exif_table( image.getexif() ) Retrieval of GPS Location Code snippet:from PIL.ExifTags import GPS, GPSTAGS # ..... def convert_gps_information( information ) -> dict: gps_information: dict = {} for key in information.keys(): gps_label = GPSTAGS.get(key) gps_information[gps_label] = information[key] return gps_information def retrievement_of_exif_table( exif_information ) -> dict: # ..... for key, value in exif_information.items(): exif_label = exif_tags.get(key) if exif_label == 'GPSInfo': value = convert_gps_information( exif_information.get_ifd( key ) ) # ..... Footnotes