Open Source Python Metadata Library
Free & open source Python library to read, edit and update metadata of documents.
What is pyExifTool?
The pyExifTool Python library is a lightweight wrapper around the popular ExifTool utility, enabling users to interact with file metadata programmatically. With support for various file formats, including PDFs, images, videos, and audio files, pyexiftool provides the ability to read, write, and delete metadata using the powerful features of ExifTool. The library is designed to leverage the command-line capabilities of ExifTool while offering a Pythonic interface for ease of use. In this page, we will discuss how developers can use pyExifTool API in their Python applications to work with metadata of files.
Getting Started with pyExifTool
In order to you pyExifTool, you need to install Python 3.6+ version and ExifTool on your system. So, first install Python and then use below commands to install pyExifTool on your machine using pip and virtual environment.
python -m pip install -U pyexiftool
1. Checkout the source code from Github repository git clone git://github.com/sylikc/pyexiftool.git
2. Run setup.py to install the module from source python setup.py install [--user|--prefix=]
Reading Metadata of PDF and other Files
pyExifTool provides you support for reading metadata of a variety of file formats such as PDF, BMP, JPEG, DOCX, XLSX and many others. The API lets you read the metadata information of a file using the get_metadata method. Check the below code snippet where we read the metadata information from a PDF file.
Output
Below screenshot displays the metadata of the PDF file:
Updating Metadata of PDF and Other File Formats
You can also update the metadata of a PDF or any other document using the pyExifTool. The tool lets you update the metadata fields such as author, producer, subject, title, etc. by setting the tags. This is as shown in the following sample code.
Conclusion
In conclusion, pyExifTool Python is a powerful Python library for reading and updating the metadata of different type of documents. It is based on the ExifTool that supports multiple file formats for reading/writing metadata. Python application developers can use it to develop programs that can read and write a document's metadata in easy steps.