madam.vector module

class madam.vector.SVGMetadataProcessor(config: Optional[Mapping[str, Any]] = None)[source]

Bases: madam.core.MetadataProcessor

Represents a metadata processor that handles Scalable Vector Graphics (SVG) data.

It is assumed that the SVG XML uses UTF-8 encoding.

__init__(config: Optional[Mapping[str, Any]] = None) → None[source]

Initializes a new SVGMetadataProcessor.

Parameters:config – Mapping with settings.
combine(file: IO, metadata: Mapping[str, Mapping[KT, VT_co]]) → IO[source]

Returns a byte stream whose contents represent the specified file where the specified metadata was added.

Parameters:
  • metadata (Mapping) – Mapping of the metadata format to the metadata dict
  • file (IO) – Container file
Returns:

file-like object with combined content

Return type:

IO

formats

The metadata formats which are supported.

Returns:supported metadata formats
Return type:set[str]
read(file: IO) → Mapping[str, Mapping[KT, VT_co]][source]

Reads the file and returns the metadata.

The metadata that is returned is grouped by type. The keys are specified by format.

Parameters:file (IO) – File-like object to be read
Returns:Metadata contained in the file
Return type:Mapping
Raises:UnsupportedFormatError – if the data is corrupt or its format is not supported
strip(file: IO) → IO[source]

Removes all metadata of the supported type from the specified file.

Parameters:file (IO) – file-like that should get stripped of the metadata
Returns:file-like object without metadata
Return type:IO
class madam.vector.SVGProcessor(config: Optional[Mapping[str, Any]] = None)[source]

Bases: madam.core.Processor

Represents a processor that handles Scalable Vector Graphics (SVG) data.

__init__(config: Optional[Mapping[str, Any]] = None) → None[source]

Initializes a new SVGProcessor.

Parameters:config – Mapping with settings.
can_read(file: IO) → bool[source]

Returns whether the specified MIME type is supported by this processor.

Parameters:file (IO) – file-like object to be tested
Returns:whether the data format of the specified file is supported or not
Return type:bool
read(file: IO) → madam.core.Asset[source]

Returns an Asset object whose essence is identical to the contents of the specified file.

Parameters:file (IO) – file-like object to be read
Returns:Asset with essence
Return type:Asset
Raises:UnsupportedFormatError – if the specified data format is not supported
shrink(asset: madam.core.Asset) → madam.core.Asset[source]

Shrinks the size of an SVG asset.

Parameters:asset (Asset) – Media asset to be shrunk
Returns:Shrunk vector asset
Return type:Asset