Skip to content
pdfconversionapi

HDR to TGA API

POST a .hdr to /v2/convert/hdr/to/tga and get a type 2 Targa: uncompressed, 8 bits per channel plus an alpha byte that is always 255 for a Radiance input. Rows are stored from the top.

Endpoint
POST /v2/convert/hdr/to/tga
Accepts
hdr
Sample timing
23 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/tga \
  -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 OK23 ms median1 file, 313 KB
{
  "ConversionCost": 1,
  "ConversionTime": 0.023,
  "Files": [
    {
      "FileName": "lakeside-sunset-sky.tga",
      "FileExt": "tga",
      "FileSize": 320018,
      "FileData": "AAACAAAAAAAAAAAAkAHIACAo…"
    }
  ]
}

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.tga, rendered by the API
Input
lakeside-sunset-sky.hdr (90 KB)
Output
lakeside-sunset-sky.tga (313 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
ImageWidthintegerWidth after scaling; ImageWidth=120 gave a 120 × 60 Targa of 28,818 bytes.Values: 1–20000
ImageHeightintegerHeight after scaling; ImageHeight=100 came back 200 × 100, 80,018 bytes.Values: 1–20000
ScaleProportionsboolean, default truefalse stretches into the exact box: 200 × 200 is 160,018 bytes.
ScaleIfLargerboolean, default falsetrue blocks enlargement; ImageWidth=800 by itself produced 1,280,018 bytes.
ScaleImageboolean, default truefalse crops the upper-left 200 × 100 (80,018 bytes).
ColorSpaceenum, default defaultGray or black-and-white values, still 32 bits per pixel and 320,018 bytes. rgb keeps the alpha byte too.Values: default, rgb, gray, monochrome; cmyk returns 400
TransparentColorstringSets alpha to 0 where a pixel matches exactly; #FFFFFF hits 333 clipped pixels, 101 at the sun and 232 along its streak on the lake.Values: #RRGGBB, R,G,B or a color name
FileNamestringOutput name, lakeside-sunset-sky.tga by default.
StoreFileboolean, default falsetrue gives a 3-hour URL.

What carries over, and what doesn't

Kept

  • The decoded pixels at 8 bits: the Targa matches the BMP route value for value
  • Top-left row order, flagged in the image descriptor
  • Raw pixels right after the 18-byte header, 4 bytes each, with no packets to decode

Lost or not yet supported

  • Size: 320,018 bytes, 3.5 times the run-length coded 92,651-byte .hdr.
  • Range above 1.0 and the 16-bit precision of the decode.
  • One byte per pixel on an alpha channel that carries nothing for a sky.
  • The file's EXPOSURE and other header lines.

Limits

  • One input file per request.
  • 10 MB on the Free plan or 100 MB on paid plans including fields.
  • 100,000,000 pixels or a 413.
  • 1 to 20,000 px per side when resizing.
  • A Targa side can't exceed 65,535 px: a 70,000 × 8 .hdr returned 413 TGA images can be at most 65,535 pixels on a side, and this one is 70,000×8.
  • 120 seconds.

Where teams use it

Skybox and background textures

Game mods and engines that import Targa backgrounds can take a converted sky panorama. Resize it with ImageWidth to a texture size in the same request.

Tools with simple loaders

A Targa reader is short to write, so small in-house tools can load a converted sky without also needing an RGBE decoder.

Questions

Why is there an alpha channel?

This route always writes 32-bit Targa, and ColorSpace=rgb does not remove the alpha byte. For a Radiance input every alpha value is 255, so the sky is fully opaque wherever the alpha is used.

Can I get a run-length compressed Targa?

No, the output is always type 2, uncompressed, with no option for type 10. That is 320,018 bytes for the 400 × 200 sky: 18 bytes of header and 4 bytes per pixel.

Is there a Targa 2.0 footer?

No. The file stops after the last pixel, with no TRUEVISION-XFILE footer, no ID field and no color map. Byte 17, the image descriptor, is 0x28: rows run from the top-left, with 8 alpha bits.

Convert your first HDR file in a minute.