angrybeanie_wagtail/env/lib/python3.12/site-packages/willow/optimizers/cwebp.py

35 lines
941 B
Python
Raw Normal View History

2025-07-25 21:32:16 +10:00
from typing import ClassVar
from .base import OptimizerBase
__all__ = ["Cwebp"]
class Cwebp(OptimizerBase):
"""https://developers.google.com/speed/webp/docs/cwebp"""
library_name: ClassVar[str] = "cwebp"
image_format: ClassVar[str] = "webp"
@classmethod
def get_check_library_arguments(cls) -> list[str]:
# running just cwebp gives basic infor and returns a zero exit code
return []
@classmethod
def get_command_arguments(
cls, file_path: str, progressive: bool = False
) -> list[str]:
return [
"-m",
"6", # inspect all encoding possibilities for best file size
"-mt", # use multithreading if possible
"-pass",
"10", # max number of passes
"-q",
"75", # compression factor. 100 produces the highest quality.
file_path,
"-o",
file_path,
]