API Documentation
Image Optimization API
Overview
The Image Optimization API allows you to optimize images by compressing them to reduce file size. This API supports various image formats, and clients can upload an image for optimization.
Endpoint
Request
- Method :
POST
- URL :
https://api.femto.cypherx.in/optimize-image
- Headers
Authorization: Bearer YOUR_API_KEY
Content-Type: multipart/form-data
- Body
level: "ultra" | "default"
- Default :
"default"
- Description : The level of optimization to be performed on the image. The default level is
"default"
. The"ultra"
level performs more aggressive optimization on the image, but it may take more time to process. - Example :
level: "ultra"
- Default :
Request Body
- Form Data
- Key :
image
- Value : Binary Image Data
- Key :
The maximum allowed image size is 75 MB. And the supported image formats are: jpg, jpeg, png, heif, avif, webp, tiff, gif, svg, RAW files (cr2, nef, arw, dng).
Response
- Status Code :
200 OK
- Headers
Content-Type: image/YOUR_IMAGE_FORMAT
Response Body
- Value : Binary Image Data
Error Response
-
Status Code :
400 Bad Request
- Headers
Content-Type: text/plain
- Body :
File type not supported
- Headers
-
Status Code :
401 Unauthorized
- Headers
Content-Type: application/json
- Body
- Headers
-
Status Code :
413 Payload Too Large
- Headers
Content-Type: application/json
- Body
- Headers
-
Status Code :
500 Internal Server Error
- Headers
Content-Type: text/plain
- Body :
Internal Server Error
- Headers
Request Examples
Here are some sample requests in different programming languages.
cURL
The optimized image will be saved in the current directory with the name optimized_image.png
.
JavaScript
In Node.js
- Install the
axios
andform-data
packages.
In Browser
Python
- Install the
requests
package.