Skip to content
pdfconversionapi

HEIC to PNM API

POST a HEIC to /v2/convert/heic/to/pnm and get the decoded photo as uncompressed RGB bytes behind a text header. The header is the classic binary PPM form, P6 followed by the width, height and 255; the 400 × 300 sample makes a 360,015-byte file.

Endpoint
POST /v2/convert/heic/to/pnm
Accepts
heic
Sample timing
25 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/heic/to/pnm \
  -H "Authorization: Bearer $PDFCONVERSIONAPI_KEY" \
  -F File=@harbor-dusk.heic \
  -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 OK25 ms median1 file, 352 KB
{
  "ConversionCost": 1,
  "ConversionTime": 0.025,
  "Files": [
    {
      "FileName": "harbor-dusk.pnm",
      "FileExt": "pnm",
      "FileSize": 360015,
      "FileData": "UDYKNDAwIDMwMCAyNTUKGCFY…"
    }
  ]
}

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 harbor-dusk.pnm, rendered by the API
Input
harbor-dusk.heic (22 KB)
Output
harbor-dusk.pnm (352 KB)
Source
A harbor at dusk that we drew ourselves, saved as a 400 x 300 HEIC stored sideways with a rotation flag and made-up camera and GPS tags. (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
ImageWidthintegerScales the photo first; 200 gives a 90,015-byte file whose header reads 200 150.Values: 1–20000
ImageHeightintegerTarget height, or a bounding box together with ImageWidth.Values: 1–20000
ScaleProportionsboolean, default truefalse allows both sizes to distort the photo.
ScaleIfLargerboolean, default falsetrue prevents enlargement past the photo's own size.
ScaleImageboolean, default truefalse takes a top-left crop of the requested size.
AlphaColorstring, default whiteBackground for transparent pixels, since the file has three channels. An opaque photo like the sample is unchanged; a HEIC with an alpha plane is blended onto this color.Values: #RRGGBB, R,G,B or white, black, red, green, blue, gray
BackgroundColorstring, default whiteUsed as the background when AlphaColor is not sent.
ColorSpaceenum, default defaultgray and monochrome write a one-channel graymap instead: the header starts with P5 and the full-size file is 120,015 bytes. monochrome holds only 0 and 255.Values: default, rgb, gray, monochrome
FileNamestringBase name of the .pnm.
StoreFileboolean, default falsetrue keeps the file for 3 hours and returns a link.

What carries over, and what doesn't

Kept

  • Every decoded pixel: reading the file back through our PNM to PNG route gave a PNG byte-identical to our HEIC to PNG output
  • The upright view, from the rotation flag in the HEIC
  • A plain layout: 15 header bytes, then 300 rows of 400 pixels, three bytes each, top row first
  • Acceptance by both readers we tried, each showing the same pixels as our PNG of the HEIC

Lost or not yet supported

  • Compression: 360,015 bytes, 16 times the HEIC.
  • EXIF and XMP, including the sample's GPS tags.
  • Transparency. The file has no alpha channel; a HEIC with one is blended onto AlphaColor.
  • Correct tones for Display P3-tagged HEIC files, which the decoder stretches.

Limits

  • One HEIC per request, at most 100,000,000 pixels.
  • Requests up to 10 MB on the Free plan or 100 MB on paid plans; 120 seconds per conversion.
  • Values are 8 bits per channel: the header's maximum value is 255.

Where teams use it

Feeding image-processing code

Research code and command-line tools that read portable anymaps need no image decoder. Converting HEIC here keeps HEVC decoding out of that code.

Comparing decoders byte for byte

With a 15-byte header and raw rows, two PNM files from different decoders can be compared directly, pixel by pixel.

Questions

Which PNM variant is it?

Binary PPM. The file starts P6, a newline, then 400 300 255 (width, height and maximum value) and another newline; red, green and blue bytes follow for each pixel. With ColorSpace=gray or monochrome it is a P5 graymap with one byte a pixel.

How do I read it without a library?

Read the magic number and the three numbers after it, skip the single whitespace byte that ends the header, then read width × height × 3 bytes: red, green and blue for each pixel, row by row from the top.

Does the PNM keep the photo's metadata?

No. The header has room for comments, but none are written, and the sample's EXIF block with camera name and GPS position is dropped.

Convert your first HEIC file in a minute.