PIL / Pillow Image
This modules contain helper function to deal with PIL / Pillow Images.
Note
Please note that the [PIL]
(pillow) extra dependency must be installed
to allow functions from this module to work.
- pyguetzli.pil_image.process_pil_image(image, quality=95)[source]
Generates an optimized JPEG from a PIL image. If the image has an alpha channel (transparency), it will be overlaid on a black background.
- Parameters:
image – the PIL image
quality – the output JPEG quality (default 95)
- Returns:
Optimized JPEG bytes
- Return type:
bytes
- Raises:
ImportError – PIL / Pillow cannot be imported.
import pyguetzli from PIL import Image image = Image.open("./test/image.jpg") optimized_jpeg = pyguetzli.process_pil_image(image)