{"id":10169,"library":"python-xmp-toolkit","title":"Python XMP Toolkit","description":"Python XMP Toolkit (version 2.1.0) provides Python bindings for Adobe's XMP Toolkit SDK by wrapping the Exempi C++ library. It enables reading, writing, and manipulating XMP (Extensible Metadata Platform) metadata in various file formats (e.g., JPEG, TIFF, PDF). The library maintains an active release cadence, with recent updates focusing on stability and compatibility with newer Exempi versions.","status":"active","version":"2.1.0","language":"en","source_language":"en","source_url":"https://github.com/python-xmp-toolkit/python-xmp-toolkit","tags":["image processing","metadata","xmp","exif","media"],"install":[{"cmd":"pip install python-xmp-toolkit","lang":"bash","label":"Install package"}],"dependencies":[{"reason":"The underlying C++ library for XMP manipulation. Must be installed on the system (e.g., `sudo apt-get install libexempi` or `sudo apt-get install libexempi-dev` on Debian/Ubuntu, `brew install exempi` on macOS).","package":"libexempi","optional":false}],"imports":[{"note":"The primary module name changed from `xmp_toolkit` to `libxmp` in version 2.0.0.","wrong":"from xmp_toolkit import XMPFiles","symbol":"XMPFiles","correct":"from libxmp import XMPFiles"},{"note":"The primary module name changed from `xmp_toolkit` to `libxmp` in version 2.0.0.","wrong":"from xmp_toolkit import XMPMeta","symbol":"XMPMeta","correct":"from libxmp import XMPMeta"},{"note":"The constants object was renamed from `XMPConsts` to `consts` and moved to the `libxmp` module in version 2.0.0.","wrong":"from xmp_toolkit import XMPConsts","symbol":"consts","correct":"from libxmp import consts"}],"quickstart":{"code":"from libxmp import XMPMeta, consts\n\n# Create a new XMP metadata object\nxmp = XMPMeta()\n\n# Set properties in the Dublin Core namespace\nxmp.set_property(consts.NS_DC, \"title\", \"My Awesome Photo\")\nxmp.set_property(consts.NS_DC, \"creator\", \"Jane Doe\")\n\n# Add items to an array property (e.g., keywords)\nxmp.append_array_item(consts.NS_DC, \"subject\", \"landscape\", None, consts.XMP_ARRAY_LAST_ITEM)\nxmp.append_array_item(consts.NS_DC, \"subject\", \"mountains\", None, consts.XMP_ARRAY_LAST_ITEM)\n\n# Get a property\ntitle = xmp.get_property(consts.NS_DC, \"title\")\nprint(f\"Title: {title}\")\n\n# Iterate over array items\nprint(\"Subjects:\")\nfor i in range(xmp.count_array_items(consts.NS_DC, \"subject\")):\n    # Array items are 1-indexed in XMP\n    item = xmp.get_array_item(consts.NS_DC, \"subject\", i + 1) \n    print(f\"- {item}\")\n\n# Serialize XMP to RDF/XML string\nrdf_string = xmp.dump_as_rdf()\nprint(\"\\n--- XMP as RDF ---\")\nprint(rdf_string)\nprint(\"------------------\")","lang":"python","description":"This quickstart demonstrates how to create, manipulate, and serialize XMP metadata using the `XMPMeta` class, which handles XMP data in memory. It covers setting properties, adding array items, retrieving values, and converting the XMP object to an RDF/XML string."},"warnings":[{"fix":"Update all imports from `xmp_toolkit` to `libxmp`. Review the new API for `XMPFiles`, `XMPMeta`, and constants (now `consts`) to adapt method calls.","message":"Version 2.0.0 introduced significant breaking changes, primarily renaming the main module from `xmp_toolkit` to `libxmp` and overhauling the API. Code written for 1.x will not work directly with 2.x.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Install `libexempi` (or `libexempi-dev`) via your system's package manager (e.g., `sudo apt-get install libexempi-dev` on Debian/Ubuntu, `brew install exempi` on macOS) before using `python-xmp-toolkit`.","message":"This Python library requires the Exempi C++ library to be installed on your system. It is not bundled and will cause runtime errors if missing.","severity":"gotcha","affected_versions":"all"},{"fix":"Always use `try-except` blocks to handle `libxmp.exempi.ExempiError` when dealing with file operations. Verify file paths and permissions before attempting to open or modify XMP data.","message":"When working with `XMPFiles`, ensure the target file path exists and that your application has the necessary read/write permissions. Opening files for update (e.g., `open_for_update=True`) requires write access.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Change your import statements from `from xmp_toolkit import ...` to `from libxmp import ...`.","cause":"Attempting to import from the old `xmp_toolkit` module after upgrading to version 2.0.0 or later.","error":"ImportError: cannot import name 'XMPFiles' from 'xmp_toolkit'"},{"fix":"Install Exempi on your system. For Debian/Ubuntu: `sudo apt-get install libexempi-dev`. For macOS (Homebrew): `brew install exempi`. Ensure your system's dynamic linker can find the library.","cause":"The underlying C++ Exempi library is not installed or not discoverable in your system's library paths.","error":"libxmp.exempi.ExempiError: Exempi library not found."},{"fix":"Verify the file path is correct and the file exists. Check file permissions for read/write access depending on your operation. Use absolute paths where possible.","cause":"The file specified for `XMPFiles` does not exist, or the provided path is incorrect, or there are insufficient permissions to access it.","error":"libxmp.exempi.ExempiError: Could not open file (no such file or directory)"}]}