Image Helpers

compress_image(image_buffer, quality=85, max_width=None, max_height=None)

Compresses an image with the given parameters.

Parameters:
  • image_buffer (BinaryIO | bytes) – Buffer representation of an image, also accepts BinaryIO.

  • quality (int, default: 85) – Quality to apply to the image (JPEG compression).

  • max_width (int | float | None, default: None) – Maximum bound for the width.

  • max_height (int | float | None, default: None) – Maximum bound for the height.

Return type:

bytes

Returns: