{"id":25460975,"url":"https://github.com/peterjakubowski/pillow-metadata","last_synced_at":"2025-07-30T23:06:50.296Z","repository":{"id":267187820,"uuid":"900490327","full_name":"peterjakubowski/Pillow-Metadata","owner":"peterjakubowski","description":"Python class that transforms XMP and Exif metadata into a standardized Python dataclass data structure from a Pillow (PIL) source image.","archived":false,"fork":false,"pushed_at":"2025-02-09T00:42:52.000Z","size":89,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-09T01:28:41.441Z","etag":null,"topics":["class","exif","metadata","pillow","python","python-image-library","xml","xmp"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peterjakubowski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-08T22:25:34.000Z","updated_at":"2025-02-09T00:42:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"74a7f911-398f-48a3-b117-96782dc0054b","html_url":"https://github.com/peterjakubowski/Pillow-Metadata","commit_stats":null,"previous_names":["peterjakubowski/pillow-metadata"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterjakubowski%2FPillow-Metadata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterjakubowski%2FPillow-Metadata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterjakubowski%2FPillow-Metadata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterjakubowski%2FPillow-Metadata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peterjakubowski","download_url":"https://codeload.github.com/peterjakubowski/Pillow-Metadata/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239412462,"owners_count":19634016,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["class","exif","metadata","pillow","python","python-image-library","xml","xmp"],"created_at":"2025-02-18T05:05:38.764Z","updated_at":"2025-02-18T05:05:40.526Z","avatar_url":"https://github.com/peterjakubowski.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pillow-Metadata\n\nPython class that transforms XMP and Exif metadata into a standardized Python dataclass data structure from a Pillow (PIL) source image.\n\n\n## Background\n\nI created this Python class to more easily extract image metadata in Python without depending on other packages like python-xmp-toolkit, which requires Exempi; and PyExif, which requires exiftool. Especially for simple read tasks, I wanted a tool that utilized Pillow, the Python Imaging Library. Pillow has methods to read metadata from images, this class will simply take the data returned by these methods and reformat it into a dataclass that is easier to work with.\n\nThe two Pillow methods used for metadata extraction are:\n\n* PIL.Image.info['xmp']: Returns the image's XMP packet in XML form.\n\n* PIL.Image.getexif(): Returns a dictionary of the image's Exif values where the keys are numbers that must be looked up using the PIL.Image.ExifTags module.\n\nThere is also a separate Pillow method, .getxmp(), that returns a dictionary containing the XMP tags. This method requires defusedxml to be installed, and I am not fond of the resulting structure.\n\nThis class parses the XMP XML and creates a dataclass data structure where the class names are the XMP prefix and attributes are the XMP local name. This class also takes the Exif dictionary and replaces the numeric keys with Exif tag names. The resulting class contains the combined XMP and Exif metadata.\n\n## Usage\n\n```commandline\nfrom pillow_metadata.metadata import Metadata\nfrom PIL import Image\n\n# open an image using Pillow\npil_img = Image.open(img_path)\n\n# construct a new Metadata object based on the PIL Image.\nmeta = Metadata(pil_img)\n\n# retrieve the image's filename (path)\n# same as pil_img.filename\nfilename = meta.filename\n\n# retrieve a list of keywords applied to the image\nkeywords = meta.metadata.dc.subject\n\n# retrieve the image's create date\nxmp_date = meta.metadata.xmp.CreateDate\nphotoshop_date = meta.metadata.photoshop.DateCreated\nexif_date = meta.metadata.exif.DateTimeOriginal\n\n# get the image's capture date\ncapture_date = meta.get_capture_date()\n\n```\n\n## Installation\n\nInstall with pip using the link to the github project.\n\n```commandline\npip install https://github.com/peterjakubowski/Pillow-Metadata/archive/main.zip\n\n```\n\n## Dependencies\n\nThe following package versions were used when this was last updated, the use of different versions has not been tested and may affect the functionality of the tool.\n\n```commandline\nPython 3.12.8\nPillow 11.0.0\nlxml 5.3.0\npython-dateutil 2.9.0.post0\n\n```\n\n## Additional Info\n\n[XMP namespace definitions](https://developer.adobe.com/xmp/docs/XMPNamespaces/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterjakubowski%2Fpillow-metadata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeterjakubowski%2Fpillow-metadata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterjakubowski%2Fpillow-metadata/lists"}