Input parameters
url- image url or location on server- required
from_url- true if image url- required if
url
- required if
images- array with requests for compression- required
images request:
width- in pixels- if not set, width will preserve
height- in pixels- if not set, height will preserve
extension- set ouput format- if not set, same extension as source will be used
quality- set quality compressionmode- resizing strategymethod- resizing methodbackground- set the background color, if necessary- for fill mode, or for png transparent images optimized to non-transparent format
- can be formatted in HEX #fff or #ffffff, rgb(255, 255, 255) or rgba(255, 255, 255, 0))
- default white
lossless- set lossless compression- used for webp output only
- set losslees to true if you want best quality and size doesn't matter (parameter quality is ignored)
watermark- url of watermark image- if you want to add watermark into output image
watermark_position- watermark positionwatermark_size- in percent
The extension property can have one of the following values:
jpgpngwebpgifsvg- only if source is svg toocss- only if source is css too (no need to enter, css will output always as css)js- only if source is js too (no need to enter, js will output always as js)
The quality property can have one of the following values:
auto- default, if not set- auto quality is highly recommended
X- quality in percentage (integer)
The mode property can have one of the following values:
auto- default, if not setfillcropexact- if width or height not set (or 0), then aspect ratio is used
The method property can have one of the following values:
LANCZOS- default, if not setNEARESTBOXBILINEARHAMMINGBICUBIC
The background property examples:
#fff#ffffffrgb(255, 255, 255)rgba(255, 255, 255, 0)
The lossless property examples:
true
The watermark_position property can have one of the following values:
c- centertl- top lefttr- top rightbl- bottom leftbr- bottom right (default, if not set)
The watermark_size property examples:
100- cover all image10- 10 % (default, if not set)
Response:
As source we can handle not only jpg, png, webp, gif. But almost all graphics format like heic, bmp, ico, jp2, tiff, eps, psd, pic, and much more. Feel free to try your files. We can handle svg file too. And we can do minify css and js files. Support for avif file is under construction.
The extra array is experimental:
white- white color ratio in percentage