Documentation

Help & Knowledgebase

Image compression

In this section, we will focus on how to compress your image a different format using the optional_parameters in the Cloudimage URL. By default, the generated image has the same format and compression as the origin image. You can decide to override the default format as documented below.

http(s)://company.cloudimg.io/operation/size/optional_parameters/original_image_url

Output Format

You can change the output format by using one of the values descibed below:

Value Format Description
tpng PNG output a image/png image
tgif GIF output a image/gif image
tjpg JPG output a image/jpeg image
twebp WebP output a image/webp image -- only supported by some browsers, mainly Chrome.
An example:

https://demo.cloudimg.io/crop/400x320/tpng/sample.li/bag.jpg

If you want to enable WebP by default on all images processed by Cloudimage, please contact us. By enabling WebP bydefault, images will be delivered as WebP to Chrome or WebP-compatible clients, and JPEG will be delivered to other clients.

JPEG Specific Options

Value Description
q[1..100] JPG quality index, between 1 and 100 (example: q95)
i1 Sets JPG interlacing mode

https://demo.cloudimg.io/crop/400x320/q50/sample.li/bag.jpg

PNG Specific Options

Value Description
png-lossy-[q] Define PNG quality and if lossy PNG can be used. (example: png-lossy-30)
png-lossless Force PNG as lossless. This is currently the default value. (example: png-lossless)

Example:

Value Filesize Result Link
png-lossy-20 ~ 1KB https://demo.cloudimg.io/height/30/png-lossy-20/sample.li/logo-cloudimg-black.png
png-lossy-80 ~ 2KB https://demo.cloudimg.io/height/30/png-lossy-80/sample.li/logo-cloudimg-black.png
png-lossless ~ 4KB https://demo.cloudimg.io/height/30/png-lossless/sample.li/logo-cloudimg-black.png

WEBP Specific Options

Value Description
webp-lossy-[q] Define WEBP as lossy, and set its quality
webp-lossless-[q] Define WEBP as lossless, and set its compression quality

Example:

Note that you can only see these images on a webp-compatible browser such as Chrome.

Value Filesize Result Link
webp-lossy-20 ~ 1KB https://demo.cloudimg.io/height/30/twebp.webp-lossy-20/sample.li/logo-cloudimg-black.png
webp-lossy-80 ~ 2KB https://demo.cloudimg.io/height/30/twebp.webp-lossy-80/sample.li/logo-cloudimg-black.png

Combine options

In some cases, you want to finetune the compression of some specific images such as logos. You can totally combine PNG and WEBP options to create options patterns such as : webp-lossy-21.png-lossy-30 which will deliver a WEBP with quality 21 on webp-compatible browsers, and a lossy PNG with quality 30 for other browsers.

https://demo.cloudimg.io/height/50/webp-lossy-21.png-lossy-30/sample.li/logo-cloudimg-black.png

Need more compression options ?

Do not hesitate to contact us in case you need more compression options.