Skip to content
pdfconversionapi

HDR to PNM API

POST a .hdr to /v2/convert/hdr/to/pnm and get a binary PPM with the magic number P6 and a maxval of 255. The shared-exponent pixels are decoded, clipped at 1.0 and stored as three plain bytes each, row by row from the top.

Endpoint
POST /v2/convert/hdr/to/pnm
Accepts
hdr
Sample timing
22 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/hdr/to/pnm \
  -H "Authorization: Bearer $PDFCONVERSIONAPI_KEY" \
  -F File=@lakeside-sunset-sky.hdr \
  -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 OK22 ms median1 file, 234 KB
{
  "ConversionCost": 1,
  "ConversionTime": 0.022,
  "Files": [
    {
      "FileName": "lakeside-sunset-sky.pnm",
      "FileExt": "pnm",
      "FileSize": 240015,
      "FileData": "UDYKNDAwIDIwMCAyNTUKECFh…"
    }
  ]
}

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 lakeside-sunset-sky.pnm, rendered by the API
Input
lakeside-sunset-sky.hdr (90 KB)
Output
lakeside-sunset-sky.pnm (234 KB)
Source
A sunset sky panorama we drew in code and saved as a 400 × 200 Radiance RGBE file with run-length scanlines; the sun disc is 60.0. (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
ImageWidthintegerTarget width. ImageWidth=120 gave a 120 60 255 header and 21,614 bytes.Values: 1–20000
ImageHeightintegerTarget height; ImageHeight=100 gave 200 × 100 in 60,015 bytes.Values: 1–20000
ScaleProportionsboolean, default truefalse makes a 200 × 200 box exact, 120,015 bytes.
ScaleIfLargerboolean, default falsetrue turns off upscaling, which otherwise writes 960,015 bytes for ImageWidth=800.
ScaleImageboolean, default truefalse crops a corner of the requested size instead of scaling.
ColorSpaceenum, default defaultgray and monochrome switch to a one-channel P5 file of 80,015 bytes; monochrome holds only 0 and 255.Values: default, rgb, gray, monochrome; cmyk returns 400
FileNamestringStem of the .pnm file name.
StoreFileboolean, default falseLink valid for 3 hours instead of inline bytes.

What carries over, and what doesn't

Kept

  • The image in reading order: 400 × 200 RGB triplets right after the 15-byte header
  • Values from 0 to 1 rounded to 8 bits: the zenith pixel is (16, 33, 97)
  • A fully opaque picture, as in the source

Lost or not yet supported

  • The shared exponent and all range above 1.0; the sun and the middle of its reflection are (255, 255, 255).
  • 16-bit depth: the maxval is 255.
  • Size: 240,015 bytes, 2.6 times the run-length coded .hdr.

Limits

  • One .hdr per conversion.
  • Total request size 10 MB on the Free plan or 100 MB on paid plans.
  • Up to 100,000,000 pixels.
  • -Y … +X … orientation only.
  • Stops after 120 seconds.

Where teams use it

Datasets for vision research

Code that trains or tests on sky and lighting images can read raw RGB behind a text header. A PPM copy of each .hdr loads with a few lines of code.

Command-line pipelines

Netpbm-style tools chain on raw pixel files. Converting the Radiance image once lets the rest of a shell pipeline work without RGBE support.

Questions

What does the header look like?

Two short lines: P6, then 400 200 255 for width, height and maxval. The 240,000 pixel bytes follow directly.

Does AlphaColor do anything here?

No. PNM output is flattened onto AlphaColor, but a Radiance file has no transparent pixels, so the result is byte-identical with or without it.

Can I keep values above 1.0?

No. PPM stores integers up to its maxval, and this route clips the decoded light to 1.0 before writing 255. Keep the .hdr for the full range.

Convert your first HDR file in a minute.