The Image Processing API enables users to resize, convert, and adjust the quality of image files, while ensuring secure access through API key authentication and preventing abuse with rate and size limits.
Processes an uploaded image file with options for resizing, format conversion, and quality adjustment.
Parameters
- Headers:
api-key
(required): API key for authentication.
- Query Parameters:
file
(required): The image file to process (max size: 10 MB).width
(optional): The desired width of the output image. Can be specified in pixels (e.g.,400
) or percentage (e.g.,50%
).height
(optional): The desired height of the output image. Can be specified in pixels or percentage.format
(optional): The target format for the output image. Supported formats includewebp
,jpg
,jpeg
,png
,bmp
,avif
,tiff
,gif
,heic
, andheif
.quality
(optional): Compression level or quality of the output image. Valid values are between0
and100
(default is100
).
Example Request
curl -X POST "https://api.bestimageapi.com/v1/img/process?width=50%&format=png&quality=80" \ -H "api-key: YOUR_API_KEY" \ -H "Content-Type: multipart/form-data" \ -F "file=@image-file.jpg" \ --output new-image-file.png
Response
- Success (200 OK):
- Returns the processed image file as a downloadable attachment.
- Error:
400 Bad Request
: Invalid inputs (e.g., unsupported format, missing required parameters).413 Payload Too Large
: File size exceeds 10 MB limit.403 Forbidden
: Invalid or missing API key.429 Too Many Requests
: Rate limit exceeded.500 Internal Server Error
: Unexpected server error.
Checks the health status of the API service.
Parameters
- Headers:
api-key
(required): API key for authentication.
Example Request
curl -X GET "https://api.bestimageapi.com/v1/health" \ -H "api-key: YOUR_API_KEY"
Response
- Success (200 OK)
- Error:
403 Forbidden
: Invalid or missing API key.429 Too Many Requests
: Rate limit exceeded.
Resizing:
- Adjusts the dimensions of the image based on provided width and/or height while maintaining aspect ratio if only one dimension is specified.
Format Conversion:
- Converts images to supported formats such as PNG, JPEG, WebP, and more.
Quality Compression:
- Compresses or optimizes images to a desired quality level.
API Key Authentication:
- All requests must include a valid API key in the
api-key
header.- Invalid or missing keys will result in a
403 Forbidden
response.
Rate Limiting:
- Up to 60 requests per minute.
- Exceeding this limit will result in a
429 Too Many Requests
response.
The API provides clear error messages and appropriate HTTP status codes:
400 Bad Request
- Invalid inputs or parameters.
403 Forbidden
- Unauthorized access due to missing or invalid API key.
413 Payload Too Large
- File size exceeds the 10 MB limit.
429 Too Many Requests
- Rate limit exceeded.
500 Internal Server Error
- Unexpected issues on the server side.
The following image formats are supported:
- Input:
webp
,jpg
,jpeg
,png
,bmp
,avif
,tiff
,gif
,heif
,heic
.- Output:
webp
,jpg
,jpeg
,png
,bmp
,avif
,tiff
,gif
,heif
,heic
.
- Maximum file size for uploads: 10 MB (Free trial is 1 MB).
- Rate limit: Up to 60 requests per minute.
- Requires at least one parameter (
width
,height
,format
, orquality
) for processing requests.
Resizing an Image
curl -X POST "https://api.bestimageapi.com/v1/img/process?width=400" \ -H "api-key: YOUR_API_KEY" \ -F "file=@image-file.jpg" \ --output new-image-file.jpg
Converting an Image Format
curl -X POST "https://api.bestimageapi.com/v1/img/process?format=webp" \ -H "api-key: YOUR_API_KEY" \ -F "file=@image-file.jpg" \ --output new-image-file.webp
Adjusting Image Quality
curl -X POST "https://api.bestimageapi.com/v1/img/process?quality=80" \ -H "api-key: YOUR_API_KEY" \ -F "file=@image-file.jpg" \ --output new-image-file.jpg
Combining Everything in a Single Request
curl -X POST "https://api.bestimageapi.com/v1/img/process?quality=80&format=webp&width=400" \ -H "api-key: YOUR_API_KEY" \ -F "file=@image-file.jpg" \ --output new-image-file.webp
For issues or questions, please contact the BestImageAPI support team at support@bestimageapi.com.