Compress an image
Endpoints
POST /compress
Upload an image, compress it immediately, and return the optimized file as base64.
POST
Compress an image
Overview
Use this endpoint when you want SmartPNG to compress a single image synchronously and return the optimized file in the same response.Notes
- The request must be
multipart/form-data. api_keyandfileare required.- One successful compression consumes one credit.
- The response includes
compressed_dataas base64 and the updatedcredits_remainingvalue.
Body
multipart/form-data
Response
Compression successful
Example:
true
Example:
"a1b2c3d4-e5f6-7890-abcd-ef1234567890"
Available options:
completed Example:
"completed"
Example:
"Image compressed successfully"
Base64-encoded compressed image
Example:
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
Example:
125678
Example:
78456
Example:
37.56
Example:
499
