Skip to content
pdfconversionapi

Compress JPG API

POST a JPEG to /v2/convert/jpg/to/compress and get a re-encoded JPEG at quality 75 (or your ImageQuality), with metadata removed. If the new file isn't smaller, you get the original bytes back. The sample at quality 70 went from 25,110 to 15,409 bytes.

Endpoint
POST /v2/convert/jpg/to/compress
Accepts
jpg
Sample timing
3 ms median of 5 runsHow we measure
Request size
Up to 10 MB on the Free plan or 100 MB on paid plans, all files together

Request and response

Every sample below ran against the API before this page was published. Set PDFCONVERSIONAPI_KEY to your key and run it as is.

curl -sS -X POST \
  https://api.pdfconversionapi.com/v2/convert/jpg/to/compress \
  -H "Authorization: Bearer $PDFCONVERSIONAPI_KEY" \
  -F File=@trailhead-sign.jpg \
  --form-string ImageQuality=70 \
  -o response.json

# FileData is base64. Save the first file in converted/,
# or print the JSON error.
if jq -e '.Files' response.json > /dev/null; then
  mkdir -p converted
  name=$(jq -r '.Files[0].FileName' response.json)
  jq -r '.Files[0].FileData' response.json \
    | base64 --decode > "converted/$name"
else
  cat response.json
fi
200 OK3 ms median1 file, 15 KB
{
  "ConversionCost": 1,
  "ConversionTime": 0.003,
  "Files": [
    {
      "FileName": "trailhead-sign.jpg",
      "FileExt": "jpg",
      "FileSize": 15409,
      "FileData": "/9j/4AAQSkZJRgABAgAAAQAB…"
    }
  ]
}

Response from our test run on 2026-11-03. ConversionTime shows the median of 5 runs. FileData is shortened here; the real response carries the whole file as base64.

The sample, converted

The same file the code sends. Download the input and the output and compare them yourself.

First page of trailhead-sign.jpg, rendered by the API
Input
trailhead-sign.jpg (25 KB)
Output
trailhead-sign.jpg (15 KB)
Source
A drawn mountain trailhead with a wooden sign and a QR code, made by us for these pages and saved at JPEG quality 92 with an EXIF block, an sRGB color profile and 300 dpi. (CC0-1.0). How it was made
Made by
2026-11-04, API build 9eeeb0640aba

Parameters

Send these as form fields next to the file. Names are case-insensitive. If you set one of the documented options below that we don't support yet, the request fails with a 400 that names it instead of returning a file made without it.

ParameterWhat it does
ImageQualityinteger, default 75Quality of the re-encode. On the sample: 40 gave 10,929 bytes, 60 gave 13,159, 70 gave 15,409 and 75 gave 16,411. At 90 the result would have been bigger, so the original came back.Values: 1–100
ImageWidthintegerShrink while compressing: 200 gave a 200 × 150 file of 6,558 bytes. Any size request turns off the never-bigger check.Values: 1–20000
ImageHeightintegerTarget height, or with a width the box the photo must fit.Values: 1–20000
ScaleProportionsboolean, default truefalse with both sizes stretches to them exactly.
ScaleIfLargerboolean, default falsetrue keeps photos narrower than ImageWidth at their own size.
ScaleImageboolean, default truefalse crops the requested size from the top-left corner.
AlphaColorstring, default whiteOnly matters when the upload is a PNG with transparency (the route reads files by content): transparent pixels are blended onto this color before the JPEG is written.Values: Color name, #RRGGBB or R,G,B
FileNamestringOutput name; .jpg is always the extension.
StoreFileboolean, default falsetrue returns a 3-hour link instead of the file data.

Not supported yet

Setting one of these to anything but its default returns 400.

OptionWhat to do instead
CompressionLevelConvertAPI's default, Extreme, is accepted; Good or Lossless return 400 "CompressionLevel is not supported yet for jpg/to/compress". Use ImageQuality.
CompressionPercentageAny value returns 400; there is no target-percentage mode.
CompressionFileSizeAny value returns 400; there is no target-size search.

What carries over, and what doesn't

Kept

  • Pixel size, unless you resize
  • Color detail: the new JPEG is written without chroma subsampling (4:4:4)
  • The original JPEG, byte for byte, whenever re-encoding wouldn't shrink it (EXIF and profile included in that case)
  • The upright view of phone photos: a re-encoded file has its pixels turned by the EXIF orientation, so a 300 × 200 test photo tagged Orientation 6 came back 200 × 300

Lost or not yet supported

  • Metadata on files that do get smaller: the sample lost its EXIF block, sRGB profile and 300 dpi value.
  • A little quality: it is a second lossy encode.
  • Progressive and grayscale encodings: output is baseline, three-channel RGB.

Limits

  • One JPEG per request.
  • Upload size up to 10 MB on the Free plan or 100 MB on paid plans.
  • 100,000,000 pixels per image.
  • No target file size or percentage; quality is the control.
  • 120 seconds per conversion.

Where teams use it

Lighter uploads in a media library

Run each camera or phone JPEG through compression before storing it. Files that were already tight come back unchanged, so a batch never grows.

Shrinking and compressing for e-mail or forms

Send ImageWidth with the quality to get a photo small enough for an attachment limit in one request.

Questions

Can compression make my file bigger?

Not a JPEG, unless you resize. When the re-encoded JPEG is the same size or larger, the API returns your upload unchanged: a JPEG already saved at quality 40 (9,253 bytes) came back byte-identical. With ImageWidth or ImageHeight set, the check is skipped, and that same file at its own width grew to 14,374 bytes. A PNG upload always comes back as a JPEG, even a larger one.

What quality is used by default?

75. For the sample that saved 35% (25,110 to 16,411 bytes). The default output is byte-identical to jpg-to-jpg with ImageQuality=75.

Does ConvertAPI's CompressionLevel work?

Only its default, Extreme. Other levels, CompressionPercentage and CompressionFileSize return 400 so a request never silently does something else. Lower ImageQuality for more compression.

Is EXIF removed?

On every file that gets re-encoded, yes, along with the ICC profile and DPI. A file returned unchanged keeps everything it had.

Can I send a PNG here?

Yes. It is decoded, blended onto AlphaColor (white by default) and written as a JPEG; the sticker sample became a 17,346-byte .jpg. You always get the JPEG, even when it is bigger than the PNG: a 138-byte 64 × 64 PNG of one flat color came back as a 740-byte JPEG. For lossless PNG compression use compress-png.

Convert your first JPG file in a minute.