Compress Image
Image → Compress Image
The Compress Image API reduces image file size while keeping acceptable quality. You send the image as Base64 (docContent), docName, and optionally imageType (JPG, PNG), compressionLevel (Max, Medium, Low), and async. The API returns the compressed image. Use the tester below to try it; more details are in the sections that follow.
Try the Compress Image API
Endpoint: POST /api/v2/CompressImage · Required: api-key, docContent, docName
Use the form below to send your API key and image (Base64). Choose output format and compression level; the response is the compressed image. No code required—fill the fields and click Send request.
Overview, parameters, and use cases
- Overview
- Parameters
- Use cases
What is Compress Image?
This endpoint compresses an image to reduce file size. You provide the image (Base64), docName, and optionally imageType (JPG or PNG) and compressionLevel (Max, Medium, Low). The API returns a smaller file while preserving usable quality. Use async for large images.
Key features
- Format – Output as JPG or PNG via imageType.
- Compression level – Max, Medium, or Low to balance size vs. quality.
- Async – Use async for large images to avoid timeouts.
Use when you need smaller images for web, email, or storage. Combine with Resize Image or Convert Image Format in a pipeline.
API parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| api-key | string | Yes | Your PDF4me API key, Base64 encoded. Get it from the dashboard. |
| docContent | base64 | Yes | Image file content (Base64). Supported: JPG, PNG. |
| docName | string | Yes | Output image file name (e.g. output.jpg). |
| imageType | string | No | Output format: JPG or PNG. |
| compressionLevel | string | No | Max, Medium, or Low. |
| async | boolean | No | Enable asynchronous processing. |
When to use Compress Image
- Web and email – Shrink images for faster loading or smaller attachments.
- Storage – Reduce file size for archives or thumbnails.
- Pipelines – Use after Create Image from PDF or Resize Image before upload or distribution.
For request/response schemas and code samples, see Compress Image in the PDF4me API docs.
Prerequisites
Before using this endpoint, make sure you have:
- A valid PDF4me API key (Get your API Key)
- An image file (JPG, PNG) in Base64 format
Response Format
The API returns a compressed image file with the specified format and compression level.