Skip to content
pdfconversionapi

PNG to PNG API

POST a PNG to /v2/convert/png/to/png to resize it or rewrite it without its metadata, losslessly. The sample makes a 128 px thumbnail of the 300 px sticker, transparency and all, in 21,271 bytes.

Endpoint
POST /v2/convert/png/to/png
Accepts
png
Sample timing
2 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/png/to/png \
  -H "Authorization: Bearer $PDFCONVERSIONAPI_KEY" \
  -F File=@garden-plot-badge.png \
  --form-string ImageWidth=128 \
  -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 OK2 ms median1 file, 21 KB
{
  "ConversionCost": 1,
  "ConversionTime": 0.002,
  "Files": [
    {
      "FileName": "garden-plot-badge.png",
      "FileExt": "png",
      "FileSize": 21271,
      "FileData": "iVBORw0KGgoAAAANSUhEUgAA…"
    }
  ]
}

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 garden-plot-badge.png, rendered by the API
Input
garden-plot-badge.png (39 KB)
Output
garden-plot-badge.png (21 KB)
Source
A round garden-plot sticker with a QR code, a transparent background and a soft drop shadow, drawn by us for these pages. (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 new PNG. 128 makes the sticker 128 × 128; 150 made it 25,701 bytes.Values: 1–20000
ImageHeightintegerHeight, or a box with ImageWidth: 200 × 100 gives 100 × 100 for square art.Values: 1–20000
ScaleProportionsboolean, default truefalse distorts to fill the exact box.
ScaleIfLargerboolean, default falsetrue stops small PNGs from being enlarged when you batch-process to one width.
ScaleImageboolean, default truefalse crops the top-left ImageWidth × ImageHeight instead of scaling, without any resampling.
ImageInterpolationboolean, default falseBoth values accepted; resampling always uses Lanczos3.
ImageResolutionintegerWrites a pHYs chunk. The input's own 144 dpi is otherwise dropped.Values: 10–800
ColorSpaceenum, default defaultgray stores gray plus alpha (25,288 bytes for the sample); monochrome stores pure black or white plus alpha (14,034 bytes). rgb drops an alpha channel no pixel uses and turns gray into color: an opaque RGBA copy of the sticker came back as 8-bit RGB, 43,579 bytes instead of 48,546.Values: default, rgb, gray, monochrome; cmyk returns 400
TransparentColorstringPixels of exactly this color become fully transparent. #FFFFFF added 13,373 transparent pixels to the sticker's 21,347.Values: Color name, #RRGGBB or R,G,B
FileNamestringOutput name; defaults to the upload's, garden-plot-badge.png.
StoreFileboolean, default falsetrue returns a 3-hour link instead of base64.

What carries over, and what doesn't

Kept

  • Every pixel and alpha value when no resize is asked for
  • 16-bit depth, for both grayscale and RGB PNGs
  • Soft transparency when resizing, since alpha is resampled with the color
  • The upright view of a PNG tagged with an EXIF orientation: a 300 × 200 test PNG tagged Orientation 6 came back 200 × 300, turned as the tag says

Lost or not yet supported

  • Size, sometimes. Without a resize the sample grew from 40,051 to 49,783 bytes; for a smaller identical-pixel file use compress-png.
  • Text chunks, the pHYs resolution (unless ImageResolution is set) and color profiles.
  • Palette storage: a palette PNG is rewritten as 8-bit RGBA, or as 8-bit RGB when it has no transparent index.
  • Animation: an animated PNG becomes a still of its first frame.

Limits

  • One PNG per request.
  • Request bodies up to 10 MB on the Free plan or 100 MB on paid plans.
  • Up to 100,000,000 pixels.
  • Resize range 1 to 20,000 px.
  • 120 seconds per conversion.

Where teams use it

Thumbnails of transparent art

Logos, stickers and UI icons keep their alpha and soft edges at the smaller size, so they still sit cleanly on any background.

Cleaning PNGs before publishing

Text chunks, such as an author, a description or software notes, are not written to the new file. The sample's description chunk is gone from the output.

Knocking out a flat background color

Screenshots and exported charts on a solid white or colored background can get that exact color made transparent with TransparentColor.

Questions

Why is my PNG bigger after converting?

This route rewrites the pixels with a general-purpose PNG encode, not an optimizer. The sample went from 40,051 to 49,783 bytes with identical pixels. compress-png is built for size and got the same pixels into 33,394 bytes.

Does it keep transparency when resizing?

Yes. The 128 px sample still has fully clear corners and a soft shadow.

Can I upload a JPEG to this route?

Yes. The file is identified by its content, not its name, so a JPEG saved as .png converts to a PNG (122,875 bytes for our sign photo). A file that is not an image returns 422 with "Invalid PNG signature".

What does TransparentColor do to anti-aliased edges?

Nothing. Only pixels of exactly that color are cleared; edge pixels blended toward it keep their color and opacity.

Convert your first PNG file in a minute.