Skip to content
pdfconversionapi

JPG to GIF API

POST a JPEG to /v2/convert/jpg/to/gif and get a one-frame GIF89a back in the JSON. GIF holds at most 256 colors, so the sample's 9,143 decoded colors were mapped onto a palette of 253, and the file came out at 51,714 bytes, about twice the JPEG.

Endpoint
POST /v2/convert/jpg/to/gif
Accepts
jpg
Sample timing
81 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/gif \
  -H "Authorization: Bearer $PDFCONVERSIONAPI_KEY" \
  -F File=@trailhead-sign.jpg \
  -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 OK81 ms median1 file, 51 KB
{
  "ConversionCost": 1,
  "ConversionTime": 0.081,
  "Files": [
    {
      "FileName": "trailhead-sign.gif",
      "FileExt": "gif",
      "FileSize": 51714,
      "FileData": "R0lGODlhkAEsAYAAAAAAAAAA…"
    }
  ]
}

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.gif, rendered by the API
Input
trailhead-sign.jpg (25 KB)
Output
trailhead-sign.gif (51 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
ImageWidthintegerWidth of the GIF. Fewer pixels is the main way to a smaller GIF: 200 px wide made the sign 200 × 150 and 17,720 bytes.Values: 1–20000
ImageHeightintegerHeight of the GIF. ImageHeight=150 also gives 200 × 150; with ImageWidth it caps both dimensions and keeps 4:3.Values: 1–20000
ScaleProportionsboolean, default trueWhen both sizes are sent, false makes the GIF exactly that size, stretching the photo (200 × 200 here).
ScaleIfLargerboolean, default falsetrue keeps the JPEG's own size when the request asks for more; an 800 px request otherwise yields a 143,357-byte GIF.
ScaleImageboolean, default truefalse cuts a top-left region of the requested size out of the photo with no resampling.
ImageInterpolationboolean, default falseAccepted with either value for ConvertAPI compatibility. Resizing always uses a Lanczos3 filter, so the bytes do not change.
ImageResolutionintegerAccepted, but a GIF has no DPI field: 300 gave the same 51,714 bytes as no value.Values: 10–800
ColorSpaceenum, default defaultgray builds the palette from gray tones. For the sample that made the file larger, 61,736 bytes.Values: default, rgb, gray, monochrome; cmyk returns 400
TransparentColorstringOne exact color becomes the GIF's transparent index. A JPEG rarely has large areas of one exact value: #FFFFFF matched 9 pixels of the sample.Values: Color name, #RRGGBB or R,G,B
FileNamestringBase name of the output; trailhead-sign.gif when left out.
StoreFileboolean, default falsetrue returns a download URL, valid for 3 hours, instead of base64.

Not supported yet

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

OptionWhat to do instead
PersistAnimationA JPEG gives one frame. true, the documented default, is accepted; false returns 400 "PersistAnimation is not supported yet for JPG → GIF".
AnimationDelayOnly the default, 100, is accepted. AnimationDelay=50 returns 400.
AnimationIterationsOnly the default, 0, is accepted. AnimationIterations=3 returns 400.

What carries over, and what doesn't

Kept

  • Pixel size and the 4:3 shape (unless you resize)
  • The upright view of a phone photo: a 300 × 200 test photo tagged EXIF Orientation 6 came back as a 200 × 300 GIF, turned as the tag says
  • Overall color: average error after palette mapping was about 1 level out of 255 per channel on the sample
  • Hard-edged detail: the QR code on the sign still scanned from the GIF with our QR reader
  • CMYK, grayscale and progressive JPEGs as inputs

Lost or not yet supported

  • Color depth. 253 palette entries had to stand in for 9,143 distinct colors; the worst pixel moved by 34 levels in the blue channel.
  • Compactness. The GIF is 51,714 bytes against 25,110 for the JPEG, because GIF's compression suits flat art better than photos.
  • EXIF data, the sRGB profile and the 300 dpi setting.

Limits

  • One JPEG, one GIF, one frame per request.
  • Uploads up to 10 MB on the Free plan or 100 MB on paid plans.
  • At most 100,000,000 pixels per image (413).
  • 1 to 20,000 px for width and height targets.
  • 120 s per conversion before a 504.

Where teams use it

Inputs for systems that take GIF and nothing else

If a forum, an e-mail template builder or an embedded viewer accepts GIF only, convert at upload time and scale down with ImageWidth so the 256-color file stays small.

Frames for an animation built elsewhere

The API returns one frame per call. Convert each JPEG to a GIF frame of the same size here, then assemble the animation with your own tool.

Questions

Why is the GIF bigger than the JPEG?

GIF compresses repeated palette indexes without loss, which works on logos and line art, not on photo noise. The sample went from 25,110 to 51,714 bytes. Resizing helps most: at 200 × 150 it was 17,720 bytes.

Can I combine several JPEGs into an animated GIF?

Not with this route. It takes exactly one file and writes one frame; the ConvertAPI animation options are accepted only at their defaults and other values return 400.

How many colors does the GIF use?

Up to 256, picked for each image. The sample's palette used 253 entries. There is no option to ask for fewer colors.

Can part of the photo be transparent?

Only by exact color with TransparentColor, and JPEG compression scatters near-identical values. On the sample, #FFFFFF made 9 pixels transparent. For a cut-out, start from a PNG with real transparency and use png-to-gif.

Convert your first JPG file in a minute.