Transformers

Transformers expose a uniform API to apply transformations to files.

They are called by variations and delegate actual transformations to processors.

class anchor.services.transformers.BaseTransformer(transformations: dict[str, Any])

Bases: object

Interface for a transformer.

Subclasses need to implement process().

process(file, format: str)

Given a buffer and an output format, returns an open temporary file with the resulting file after applying the transformations in this object.

transform(file, format: str)

Applies transformation to the given file and yields a temporary file in the specified format.

class anchor.services.transformers.ImageTransformer(*args, processor_class: type[BaseProcessor] = None, **kwargs)

Bases: BaseTransformer

process(file, format: str)

Given a buffer and an output format, returns an open temporary file with the resulting file after applying the transformations in this object.