To start using the CheetahO image optimization API you need to sign up for CheetahO API services and obtain your unique API key.
Calling method | Parameters |
---|
POST | URL to call: http://api.cheetaho.com/api/v1/media {“key “: “your api key”, “lossy “:1, “url “: “http://yourdomain.com/path_to_image/file.jpg”} JSON Encoded parameters, as follows key – Your API key.url – image URL to optimize.lossy – image compression type.quality – custom image qualityresize – parameter to resize imagecreateWebP – enable image compresion to WebP.
|
API Parameters
Parameter | Description |
---|
key | Your API key, as provided in your CheetahO control panel. |
url
| The URL where the original image is located. This needs to be a valid URL. |
lossy
| Controls whether the image compression will use a lossy or lossless algorithm. 0 – Lossless compression. Choose this option when you do not want to lose any of the original image’s details. The new image will be identical to the original but smaller in size.
1 – Lossy compression. The compressed image is not 100% identical to the original. If you want to have a better compression rate, use this settings.
|
quality
| This works only if lossy = 1 For the JPEG image format, specifying a quality level of 1 will produce the lowest image quality (highest compression level), whereas a quality of 100 will give you the best quality but the least compression. |
resize
| CheetahO can help you to resize images and create thumbnails for your applications. CheetahO will first resize the given image and then optimize it. The resize option needs a few parameters to be passed, such as the desired width and/or height , as well as a mandatory strategy property. |
resize[strategy]
| The strategy property can have one of the following values: exact – Resize to exact width and height. Aspect ratio will not be maintained.portrait – Exact height will be set, width will be adjusted according to aspect ratio.landscape – Exact width will be set, height will be adjusted according to aspect ratio.auto – The best strategy (portrait or landscape) will be selected according to its aspect ratio.fit – This option will crop and resize your images to fit the desired width and height.crop – This option will crop an image to the exact size you specify.
|
createWebP
| WebP is a new image format introduced by Google. According to Google, WebP images are almost 26% smaller. To recompress your JPEG, PNG files into WebP format simply set "createWebP": true flag in your request. |
API Return
Field | Meaning |
---|
error | Contains the status message for the call. The status itself is an object with two fields: Code – This is a numeric code identifying the outcome of the call. Can be: 200 – No errors, image processed, download URL available.304 – Not Found. The file is no longer available.400 – Bad request. Invalid image URL. Please make sure the URL is properly urlencoded or points to a valid image file.401 – Unauthorized. Invalid API key. Check it in CheetahO panel.403 – Account has been temporarily suspended. Check your quota. Maybe you’ll need to subscribe to a higher plan to increase your quota.413 – Requested file size too large. The maximum file size is limited by you plan.415 – Bad file type.500 – Encountered an unexpected error and we can not finish your request.
Message – A text message explaining what the code stands for.
|
data | destURL – Download URL for optimized image.originalSize – Size of the original image newSize – Size of compressed image savedBytes – Size of saved data. validTill – Timestamp how long the file is valid.webPfileURL – will return webp file path if parameter was "createWebP": true . If no image value will be false
|
We’re here to help! Get in touch and we’ll get back to you as soon as we can.