SVG handler for embedding and extracting XMP packets in Swarmauri runtimes.
Project description
swarmauri_xmp_svg
swarmauri_xmp_svg provides the SVGXMP handler so vector graphics can embed, retrieve, and remove RDF/XML metadata via <metadata> elements.
Features
- Registry ready – derives from
EmbedXmpBaseso Swarmauri runtimes discover it through the dynamic registry. - XML aware – uses
ElementTreeto place metadata deterministically as the first child of<svg>. - Text fallback – gracefully injects raw strings when the SVG cannot be parsed structurally.
Installation
# pip
pip install swarmauri_xmp_svg
# uv
uv add swarmauri_xmp_svg
Usage
from pathlib import Path
from swarmauri_xmp_svg import SVGXMP
handler = SVGXMP()
svg_path = Path("example.svg")
xmp_packet = """<x:xmpmeta xmlns:x='adobe:ns:meta/'><rdf:RDF>...</rdf:RDF></x:xmpmeta>"""
# Insert metadata into the SVG root element
updated_bytes = handler.write_xmp(svg_path.read_bytes(), xmp_packet)
svg_path.write_bytes(updated_bytes)
# Read the packet back
restored_xml = handler.read_xmp(updated_bytes)
print(restored_xml)
# Remove it if necessary
clean_bytes = handler.remove_xmp(updated_bytes)
Why it works
- XML aware – parsing via
ElementTreeensures metadata lands as the first child under<svg>. - Resilient fallback – gracefully degrades to text insertion when the document cannot be parsed as XML.
- Registry ready – inherits from
EmbedXmpBase, making runtime discovery effortless.
Project Resources
- Source: https://github.com/swarmauri/swarmauri-sdk
- License: Apache 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swarmauri_xmp_svg-0.1.1.dev32.tar.gz.
File metadata
- Download URL: swarmauri_xmp_svg-0.1.1.dev32.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2932b055edfbba2aed1f87ba4fd184a604683f00576027666a801c100d140437
|
|
| MD5 |
0e4b99300458b1e333bba39677fe9e08
|
|
| BLAKE2b-256 |
f47ea1fddef9b6facd5d83a736483363eae8dabf49559d923939cb9a9668c831
|
File details
Details for the file swarmauri_xmp_svg-0.1.1.dev32-py3-none-any.whl.
File metadata
- Download URL: swarmauri_xmp_svg-0.1.1.dev32-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de0103e5916b3cca3492672b30e48738c02f9d2ac4e1bf81f5fec6c9dcd42e65
|
|
| MD5 |
14bfbb5a572c376ee609fbf5d45f7ea0
|
|
| BLAKE2b-256 |
06389dac36277bf787b7360e27c228a24b77f30e0b416054f0e742f1b73e0287
|