Concepts
Formats
Which image format to choose for the web, what "original" means, and every input and output the API accepts.
Image formats for the web
Set the output format with image.format on a compress request.
| Format | Choose it when | Keep in mind |
|---|---|---|
avif | You want the smallest file for photos and can serve a fallback to old browsers. | Supported by current versions of Chrome, Edge, Firefox and Safari. Always lossy here. Keeps transparency. |
webp | You want one modern format that every current browser reads, with transparency or animation. | Usually smaller than JPEG and PNG, usually larger than AVIF. Lossless at quality 96 and above. |
jpg | The image must open everywhere: email clients, old software, print shops. | No transparency. Transparent areas are filled with white. |
png | Screenshots, logos and drawings with flat colour and sharp edges, or when you need exact pixels. | Large for photos. Lossless at quality 96 and above, palette-reduced below that. |
A common setup is AVIF first, WebP second and JPEG last, offered with the HTML <picture> element. Send the same source file three times with three values of image.format.
heic and gif are also accepted as output formats. Browsers other than Safari do not display HEIC. GIF is limited to 256 colours and has no quality setting.
What "original" resolves to
image.format defaults to original, which keeps the input's format where that format is a sensible output, and picks the nearest one where it is not.
| Input | Output with original |
|---|---|
| JPEG | JPEG |
| PNG | PNG |
| BMP | PNG |
| TIFF | PNG |
| WebP | WebP |
| AVIF | AVIF |
| HEIC | HEIC, which needs HEIC output enabled on the account |
| GIF | GIF |
| Camera RAW (CR2, NEF, ARW, DNG, ORF, RW2, RAF) | JPEG |
For audio, audio.format=original keeps MP3, OGG, Opus, WAV and FLAC inputs in their own format. Any other input becomes AAC in an .m4a file. The audio default is aac, not original.
The response always states the format that was written: the Smol-Output-Format header on a direct request, and output_format in the result object.
What the API changes in an image
- Orientation. A rotation stored as a tag is applied to the pixels, so the image displays the right way up in every viewer.
- Colour. An image with a wide-gamut profile, such as Display P3 or Adobe RGB, is converted to sRGB through its profile.
- Transparency. Kept in formats that support it. Flattened onto white when the output is JPEG.
- Animation. Kept when an animated GIF or WebP is written as GIF or WebP. For any other output format the first frame is used, and the result carries a warning.
- Size. By default an image larger than 2000 by 2000 pixels is shrunk to fit inside that box. Smaller images are not enlarged. Turn this off with
image.resize=false. - Metadata. Removed by default.
image.strip_metadata=falseskips the removal. PNG output is the exception in both directions. See Metadata.
How the file type is detected
The type is read from the file's content, not from its name. A PNG named photo.jpg is handled as a PNG. The file name is used in two cases:
- To tell apart formats that share a container. A DNG and a TIFF start with the same bytes, as do a DOCX and a DOCM.
- For text formats, which have no signature: CSV, TSV, JSON, NDJSON, HTML and Markdown. These need a file name with the right extension.
Send the name with ?filename= or a Content-Disposition header on a direct request, or with input.filename on a job. A file that cannot be identified is refused with unsupported_input.
Compress: inputs and outputs
| Kind | Inputs | Outputs | Option |
|---|---|---|---|
| Image | JPEG, PNG, WebP, AVIF, HEIC, GIF, TIFF, BMP, camera RAW (CR2, NEF, ARW, DNG, ORF, RW2, RAF) | original, jpg, png, webp, avif, heic, gif | image.format |
| PDF without a password | None | ||
| Video | MP4, MOV, AVI, MKV, WebM, FLV, WMV, M4V, MPG, 3GP | mp4, mov, webm, mkv, with codec h265, h264 or vp9 | video.format, video.codec |
| Audio | MP3, AAC, WAV, FLAC, M4A, OGG, Opus, WMA | aac, m4a, mp3, ogg, opus, wav, flac, alac, original | audio.format |
aac and m4a both write AAC audio in an .m4a file. ogg and opus both write Opus audio, in an .ogg or an .opus file. alac writes lossless audio in an .m4a file.
Office documents, tables and fonts cannot be compressed. They can be converted.
Convert: inputs and outputs
Set the target with convert.to, or ?to= in a query string.
| Kind | Inputs | Targets |
|---|---|---|
| Image | JPEG, PNG, WebP, AVIF, HEIC, GIF, TIFF, BMP | jpg, png, webp, avif, heic, tiff, bmp, gif, pdf |
| PDF without a password | png, jpg (one page per request) | |
| Word document | DOC, DOCX, DOCM, DOT, DOTX, ODT, OTT, RTF, FODT | pdf, docx, odt, rtf, txt, html |
| Spreadsheet | XLS, XLSX, XLSM, XLSB, XLT, XLTX, ODS, OTS, FODS | pdf, xlsx, ods, csv, html |
| Presentation | PPT, PPTX, PPTM, PPS, PPSX, POT, POTX, ODP, OTP, FODP | pdf, pptx, odp |
| Video | MP4, MOV, AVI, MKV, WebM, FLV, WMV, M4V, MPG, 3GP | mp4, mov, webm, mkv |
| Audio | MP3, AAC, WAV, FLAC, M4A, OGG, Opus, WMA | m4a, mp3, wav, flac, ogg |
| Table | CSV, TSV, JSON, NDJSON, HTML, Markdown | csv, tsv, json, ndjson, html, md, xlsx |
| Font | TTF, OTF, WOFF, WOFF2 | ttf, otf, woff, woff2 |
- Camera RAW files cannot be converted. Use compress, which decodes them to JPEG, PNG, WebP, AVIF or HEIC.
- A font conversion changes the container only. The outlines and tables inside the font are kept.
- In a table conversion every cell is text.
- A target outside the list for the file's kind is refused with unsupported_target.
Strip metadata: inputs
Strip metadata accepts images and PDFs. The output has the same format as the input. Any other kind is refused with unsupported_input.
Direct request or job
| Kind | Direct request | Job |
|---|---|---|
| Image | Yes, up to 25 MB | Yes |
| Yes, up to 25 MB | Yes | |
| Audio | Yes, up to 25 MB | Yes |
| Table | Yes, up to 25 MB | Yes |
| Font | Yes, up to 25 MB | Yes |
| Video | No | Yes |
| Word document, spreadsheet, presentation | No | Yes |
A video or an office document sent to a direct endpoint is refused with use_async_job. See Large files and jobs for the job flow. The same lists are available to code at GET /v1/capabilities.