YOGA Python Library

YOGA Image Optimizer is based on YOGA that is a Python library and a CLI tool to convert and optimize images and 3D models.

YOGA features a simple Python API to optimize image. Here is a basic example:

import yoga.image
yoga.image.optimize("./input.png", "./output.png")

You can also pass options to the optimize() function:

yoga.image.optimize("./input.png", "./output.png", options={
    "output_format": "orig",         # "orig"|"auto"|"jpeg"|"png"|"webp"|"webpl"
    "resize": "orig",                # "orig"|[width,height]
    "jpeg_quality": 0.84,            # 0.00-1.0
    "webp_quality": 0.90,            # 0.00-1.0
    "opacity_threshold": 254,        # 0-255
    "png_slow_optimization": False,  # True|False

Read more in the YOGA's official documentation: