Skip to main content

Dynamic XMP embed/read/remove orchestration for Swarmauri handlers.

Project description

Swarmauri logotype

EmbedXMP

PyPI - Downloads Repository views Supported Python versions License Latest release


EmbedXMP collects every installed EmbedXmpBase implementation, discovers them via Swarmauri's dynamic registry, and exposes a unified manager that can embed, read, or remove XMP packets without worrying about container formats.

Features

  • Dynamic discovery – lazily imports modules named swarmauri_xmp_* and collects subclasses registered under EmbedXmpBase.
  • Unified interface – delegates to the first handler whose supports method confirms compatibility with the payload.
  • Convenience wrappers – module-level helpers (embed, read, remove) keep high-level workflows succinct.
  • Async-friendly APIs – integrate inside event loops without blocking when calling out to plugin hooks.
  • Media-format coverage – load handlers for PNG, GIF, JPEG, SVG, WEBP, TIFF, PDF, and MP4 assets through extras.

Installation

Using uv

uv add EmbedXMP

Using pip

pip install EmbedXMP

Usage

from pathlib import Path

from EmbedXMP import EmbedXMP, embed, embed_file, read, read_file_xmp

manager = EmbedXMP()
image = Path("example.png")
packet = """<x:xmpmeta xmlns:x='adobe:ns:meta/'><rdf:RDF>...</rdf:RDF></x:xmpmeta>"""

# Embed into the file in place.
embed_file(image, packet)

# Inspect metadata via the manager API.
xmp_text = manager.read(image.read_bytes(), str(image))
print(xmp_text)

# Remove metadata from the file when it is no longer required.
manager.remove(image.read_bytes(), str(image))

Note You can provide either a path or a hint keyword argument when calling embed, read, or remove to help the manager pick the correct handler. The values are interchangeable as long as they match when both are supplied.

Async orchestration

EmbedXMP's manager can be shared inside asynchronous workflows by deferring media-aware work to plugin hooks:

import asyncio
from pathlib import Path

from EmbedXMP import EmbedXMP, embed


async def embed_all(paths: list[str], packet: str) -> None:
    manager = EmbedXMP()
    for path in paths:
        data = Path(path).read_bytes()
        await asyncio.to_thread(embed, data, packet, hint=path)


asyncio.run(embed_all(["one.png", "two.svg"], "<x:xmpmeta>...</x:xmpmeta>"))

Project Resources

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

embedxmp-0.1.4.dev13.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

embedxmp-0.1.4.dev13-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file embedxmp-0.1.4.dev13.tar.gz.

File metadata

  • Download URL: embedxmp-0.1.4.dev13.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for embedxmp-0.1.4.dev13.tar.gz
Algorithm Hash digest
SHA256 b2b8c22eb43cfed56888d83d8ff05427da8a38379844932a700b4e9dc984c6a6
MD5 c445d2463a3cd918c438e1ccd1c7627e
BLAKE2b-256 425ccfb2e2dfef483d452840baa56675545551de729ce54ee207a2e7835fa9d9

See more details on using hashes here.

File details

Details for the file embedxmp-0.1.4.dev13-py3-none-any.whl.

File metadata

  • Download URL: embedxmp-0.1.4.dev13-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for embedxmp-0.1.4.dev13-py3-none-any.whl
Algorithm Hash digest
SHA256 ceca3d4dd3a5f1b68cdbc3386d8034771d4f59ec45dcb308b546b9d359104a0d
MD5 15e9e0afbfb23162f0c23a4e8286f1e5
BLAKE2b-256 c9f25b12184125f2c153b259298fab8d8cf9f2a426cd5b3283d44611c3f6ce2c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page