CDN delivery is separate from this API client. To serve optimized images from the CDN, use a delivery namespace and either Convertly Storage file ids/slugs or an origin source for your deployed asset URLs. See Image CDN setup.
Create a client
Convert a file
Conversion options
| Option | Type | Description |
|---|---|---|
compression | string | Image compression preset: high, balanced, ultra. |
resize | string | Resize strategy: fit, fill, cover, contain. |
resizeWidth | int | Target width in pixels. |
resizeHeight | int | Target height in pixels. |
autoOrient | bool | Auto-rotate based on EXIF. Default true. |
mono | bool | For SVG tracing: true for monochrome, false for color. |
saveToStorage | bool | Save the output to Convertly Storage. |
'mono' => true only when you want monochrome tracing.
Compress a file
Compression options
| Option | Type | Description |
|---|---|---|
mode | string | quality (1-100) or target-size (bytes). |
quality | int | 1-100 quality level when mode is quality. |
stripMetadata | bool | Remove EXIF and metadata. |
saveToStorage | bool | Save the output to Convertly Storage. |
Media tools
Use the genericmediaTool() method for any Convertly media tool endpoint:
thumbnail, pdf-preview, image-to-pdf, strip-metadata, poster-frame, extract-audio, watermark, inspect, trim, gif, storyboard, transform, remove-background.
Pass 'async' => 'true' in $fields for longer media-tool work. Async tool responses include a jobId; use getJob($jobId) to poll completion.
Convertly Storage
The WordPress-bundled SDK also exposes storage helpers used by the plugin:'') for root-level storage listings. Use null only when you intentionally want the API default behavior.
Batch jobs
Upload multiple files in a single batch job:Job management
Error handling
Every method returns a consistent response array:- Missing API key:
['ok' => false, 'error' => 'Missing Convertly API key.'] - Missing cURL extension:
['ok' => false, 'error' => 'Convertly uploads require the PHP cURL extension.'] - Unreadable file:
['ok' => false, 'error' => 'File is not readable.'] - HTTP errors:
['ok' => false, 'status' => 429, 'error' => 'Rate limit exceeded.']
WordPress integration
The WordPress plugin is built on this SDK, so plugin behavior and standalone PHP behavior stay aligned. You can use the sameConvertlyClient class in custom WordPress themes or plugins:
Method reference
| Method | Description |
|---|---|
new ConvertlyClient($apiKey, $baseUrl?) | Create a client. Default base URL is https://convertly.sh. |
hasApiKey() | Check if an API key was provided. |
convertFile($path, $format, $options?) | Convert a file to another format. |
compressFile($path, $options?) | Compress an image or document. |
mediaTool($tool, $path, $fields?) | Call any media tool endpoint. |
createJob($paths, $fields) | Create a batch job with multiple files. |
getJob($jobId) | Get a job by ID. |
getJobs($limit?) | List recent jobs. Default limit is 20. |
getFiles($folderId?, $limit?, $offset?, $search?) | List Convertly Storage files. Empty string lists root files. |
getFolders($parentId?, $search?) | List Convertly Storage folders. Empty string lists root folders. |
uploadFile($path, $folderId?) | Upload a local file into Convertly Storage. |