API Endpoint Access URL
https://api.pixlab.io/compress
Get Your API Key & Try COMPRESS Now ↗Description
Set the compression quality for JPEG and PNG images using the COMPRESS API endpoint. Optimize image sizes for faster loading and better user experience. Set the compression quality for a given image (Mostly JPEG & PNG).
HTTP Methods
GET, POST
HTTP Parameters
Required
Fields | Type | Description |
---|---|---|
img |
URL | Input image URL. If you want to upload your image directly from your app, submit a multipart/form-data POST request. |
quality |
Integer | Image compression quality. Must be between 1-100. |
key |
String | Your PixLab API Key ↗. You can also embed your key in the WWW-Authenticate: HTTP header and omit this parameter. |
Optional
Fields | Type | Description |
---|---|---|
blob |
Boolean | By default, returns a JSON Object with the output image URL. Set to true to receive the raw image binary instead. |
POST Request Body
Use when submitting POST requests instead of GET:
Allowed Content-Types:
multipart/form-data
application/json
Use multipart/form-data
for direct image uploads (see examples). For JSON, the image must be hosted elsewhere. Call store first if you need to upload an image before compression.
HTTP Response
Fields | Type | Description |
---|---|---|
status |
Integer | Status code 200 indicates success, any other code indicates failure. |
link |
URL | Link to the compressed image output stored on our CDN unless custom S3 keys are configured (see your dashboard ↗ for configuration). |
id |
String | Unique identifier for the processed image. |
error |
String | Detailed error message when status ≠ 200. |
The API returns application/json
by default when the optional blob parameter is omitted. When blob mode is enabled, the endpoint returns raw image binary data instead of JSON.
Required
All requests must include authentication credentials and target image URL or file.
Optional
Compression parameters including quality, format conversion, and blob mode can be specified to customize output.
Code Samples
# Refer to the PixLab Github Repository at: https://github.com/symisc/pixlab for the full list of production ready code samples...
// Refer to the PixLab Github Repository at: https://github.com/symisc/pixlab for the full list of production ready code samples...
# Refer to the PixLab Github Repository at: https://github.com/symisc/pixlab for the full list of production ready code samples...
# Refer to the PixLab Github Repository at: https://github.com/symisc/pixlab for the full list of production ready code samples...
Similar API Endpoints
encrypt, encipher, decrypt, decipher, strip, setorientation, setopt