abstract_api.image_processing.image_processing module#

class abstract_api.image_processing.image_processing.ImageProcessing(api_key: str | None = None)[source]#

Bases: BaseService[ImageProcessingResponse]

AbstractAPI image processing service.

Used to convert, compress, or optimize an image.

Attributes:

_subdomain: Image processing service subdomain.

upload(image: BinaryIO, lossy: bool | None = None, quality: int | None = None, resize: BaseStrategy | None = None) ImageProcessingResponse[source]#

Converts, compresses, or optimizes an image.

Args:
image: The image to be processed, it should be a file-like or a

file opened in binary reading mode.

lossy: If True, the API will perform a lossy compression on the

image, reducing the size massively with a small drop in image quality. If False, the image size will only be reduced slightly (10% - 20% at most), but there will be no reduction in image quality. The default value is False if this is not provided.

quality: This is an integer between 0 and 100 that determines

the quality level for lossy compression. If not submitted it will be determined intelligently by AbstractAPI. Generally a quality above 95 is useless and may result in an image that is larger than the input image, and a quality below 25 will result in an image so low in quality that it will be useless.

resize: This is an instance of BaseStrategy subclasses that

specifies how to resize the image. If not provided, we will only compress the image as desired.

Returns:

ImageProcessingResponse representing API call response.

url(url: str, lossy: bool | None = None, quality: int | None = None, resize: BaseStrategy | None = None) ImageProcessingResponse[source]#

Converts, compresses, or optimizes an image in the given URL.

Args:
url: The URL of the image that you would like to edit.

Note that is cannot be more than 32 MB in size.

lossy: If True, the API will perform a lossy compression on the

image, reducing the size massively with a small drop in image quality. If False, the image size will only be reduced slightly (10% - 20% at most), but there will be no reduction in image quality. The default value is False if this is not provided.

quality: This is an integer between 0 and 100 that determines

the quality level for lossy compression. If not submitted it will be determined intelligently by AbstractAPI. Generally a quality above 95 is useless and may result in an image that is larger than the input image, and a quality below 25 will result in an image so low in quality that it will be useless.

resize: This is an instance of BaseStrategy subclasses that

specifies how to resize the image. If not provided, we will only compress the image as desired.

Returns:

ImageProcessingResponse representing API call response.