Skip to content

ISCC - SVG Processing#

SVG handling module.

svg_rasterize(fp, max_size=_SVG_MAX_RENDER_SIZE) #

Rasterize an SVG file to a PIL Image via resvg.

Renders at native size when it fits within max_size, caps oversized SVGs.

Parameters:

Name Type Description Default
fp

Filepath to SVG file.

required
max_size

Maximum pixel dimension on any side (default 4096).

_SVG_MAX_RENDER_SIZE

Returns:

Type Description

Rasterized image as PIL Image object

svg_meta_extract(fp) #

Extract metadata from SVG file.

Extracts from ISCC namespace in RDF, SVG native elements, and Dublin Core/CC in RDF, with ISCC namespace taking highest priority.

Parameters:

Name Type Description Default
fp

Filepath to SVG file.

required

Returns:

Type Description

Metadata mapped to IsccMeta schema

svg_meta_embed(fp, meta) #

Embed metadata into a copy of the SVG file.

Writes to SVG native elements (title, desc) and RDF/Dublin Core in the metadata element, mirroring the image module's dual ISCC+DC strategy.

Parameters:

Name Type Description Default
fp

Filepath to source SVG file.

required
meta

Metadata to embed into SVG.

required

Returns:

Type Description

Filepath to the new SVG file with updated metadata

svg_meta_delete(fp) #

Delete all metadata from SVG file (in place).

Removes title, desc, and metadata elements from the SVG XML.

Parameters:

Name Type Description Default
fp

Filepath to SVG file.

required

svg_thumbnail(fp, img=None, **options) #

Create a thumbnail for an SVG file.

Parameters:

Name Type Description Default
fp

Filepath to SVG file.

required
img

Pre-rasterized PIL Image to reuse (avoids re-rasterization).

None
options

Keyword arguments forwarded to sdk_opts: image_thumbnail_size - Size of the larger side of the thumbnail in pixels. Default: 128

{}

Returns:

Type Description

Thumbnail image as PIL Image object