Documentation: Custom Image Quality

CheetahO allows override default lossy image optimization quality. We allow to specify a custom image quality for JPEGs, PNGs and even GIF images. Image quality value is accepted from 1 to 100.

The quality level of 1 will produce the lowest image quality and highest compression level, whereas a quality of 100 will give you the best quality but the least compression. We estimate that JPEGs with a quality lower than 25 will, in many cases, be unusable.

For PNG and GIF image formats work similarly for the most part. However, since both are lossless image formats, a range of techniques including colour palette quantization (reducing the colour palette) and dithering (the use of adjacent pixels of different colors to give the appearance of. So, a lower quality value will apply fewer colours and more dithering. The highest quality will preserve the most colours and make the least use of dithering.

To use lossy optimization algorithms with custom quality param, simply set the "quality" property in your request JSON, together with the "compression": "lossy" flag as an example below:

{
    "compression":"lossy",
    "keep_exif":1,
    "web_p":false,
    "files":["https://example.com/image_path.jpg"],
    "wait":true,
    "quality":50
}

cURL example:

curl --location --request POST 'https://api.cheetaho.com/api/v2/media/optimization' \
--header 'Accept: application/json' \
--header 'key: api_key' \
--header 'Content-Type: application/json' \
--data-raw '{
    "compression":"lossy",
    "keep_exif":1,
    "web_p":false,
    "files":["https://example.com/image_path.jpg"],
    "wait":true,
    "quality":50
}'