HEIF to TGA API
POST a .heif to /v2/convert/heif/to/tga and get an uncompressed Targa (image type 2) with an 8-bit alpha channel. Clear pixels take as much room as opaque ones, so the 320 × 320 sticker is 409,618 bytes, 36 times the 11,269-byte HEIF.
- Endpoint
- POST /v2/
convert/ heif/ to/ tga - Accepts
- heif
- 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/heif/to/tga \
-H "Authorization: Bearer $PDFCONVERSIONAPI_KEY" \
-F File=@succulent-sticker.heif \
-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
fiimport base64
import os
import requests
key = os.environ["PDFCONVERSIONAPI_KEY"]
response = requests.post(
"https://api.pdfconversionapi.com/v2/convert/heif/to/tga",
headers={"Authorization": f"Bearer {key}"},
files=[("File", open("succulent-sticker.heif", "rb"))],
timeout=180,
)
result = response.json()
if not response.ok:
raise SystemExit(f"{result['Code']}: {result['Message']}")
os.makedirs("converted", exist_ok=True)
for file in result["Files"]:
path = os.path.join("converted", file["FileName"])
with open(path, "wb") as out:
out.write(base64.b64decode(file["FileData"]))
print(path, file["FileSize"], "bytes")
import { mkdir, readFile, writeFile } from "node:fs/promises";
import { join } from "node:path";
const form = new FormData();
const file = "succulent-sticker.heif";
form.append("File", new Blob([await readFile(file)]), file);
const url = "https://api.pdfconversionapi.com/v2/convert/heif/to/tga";
const key = process.env.PDFCONVERSIONAPI_KEY;
const response = await fetch(url, {
method: "POST",
headers: { Authorization: `Bearer ${key}` },
body: form,
});
const result = await response.json();
if (!response.ok) {
throw new Error(`${result.Code}: ${result.Message}`);
}
await mkdir("converted", { recursive: true });
for (const file of result.Files) {
const path = join("converted", file.FileName);
await writeFile(path, Buffer.from(file.FileData, "base64"));
console.log(path, file.FileSize, "bytes");
}
{
"ConversionCost": 1,
"ConversionTime": 0.023,
"Files": [
{
"FileName": "succulent-sticker.tga",
"FileExt": "tga",
"FileSize": 409618,
"FileData": "AAACAAAAAAAAAAAAQAFAASAo…"
}
]
}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.

- Input
- succulent-sticker.heif (11 KB)
- Output
- succulent-sticker.tga (400 KB)
- Source
- A potted succulent sticker that we drew ourselves, with a transparent background and a soft shadow, saved as a 320 x 320 HEIF with an alpha plane. (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.
| Parameter | What it does |
|---|---|
ImageWidthinteger | Scales the sticker; 200 gave 160,018 bytes.Values: 1–20000 |
ImageHeightinteger | Target height, or a box with ImageWidth.Values: 1–20000 |
ScaleProportionsboolean, default true | false stretches to both sizes. |
ScaleIfLargerboolean, default false | true leaves smaller images unscaled. |
ScaleImageboolean, default true | false crops the top-left area. |
ColorSpaceenum, default default | gray and monochrome change only the color values: the alpha byte is kept (72,482 pixels stay clear) and the file stays 409,618 bytes.Values: default, rgb, gray, monochrome |
TransparentColorstring | Sets alpha to 0 for pixels of exactly this color as well; #C4623B cleared 5,931 pot pixels.Values: #RRGGBB, R,G,B or a basic color name |
FileNamestring | Base name of the .tga. |
StoreFileboolean, default false | true returns a link valid for 3 hours. |
What carries over, and what doesn't
Kept
- Every RGBA value: read back, the Targa matched the HEIF to PNG output on all 102,400 pixels
- Straight (unpremultiplied) alpha: the shadow's center is stored as (35, 21, 8) with alpha 112
- Top-left row order, set in the descriptor byte
Lost or not yet supported
- Compression: the clear background costs four bytes a pixel like everything else, 409,618 bytes against 11,269 for the HEIF.
- The TGA 2.0 footer and extension area.
- Correct tones for HEIF files that embed a Display P3 profile.
Limits
- One HEIF per request, up to 100,000,000 decoded pixels.
- A Targa side can't exceed 65,535 px: a 70,000 × 64 image sent as .heif returned 413
TGA images can be at most 65,535 pixels on a side, and this one is 70,000×64. - Requests up to 10 MB on the Free plan or 100 MB on paid plans; 120 seconds per conversion.
- Output is always 32-bit and uncompressed; no 24-bit or run-length option.
- AV1-coded HEIF (AVIF) returns 422.
Where teams use it
Decals and UI sprites for game engines
Engines and modding tools that import Targa read its alpha channel as the sprite's mask. A cut-out saved as HEIF converts with its mask and soft edges.
Titles and lower thirds for video software
Some video titling and compositing tools take TGA with alpha for overlays. The straight alpha values keep a shadow's softness when the overlay is placed.
Questions
Will game and video tools read this Targa?
It uses the plainest form of the format: image type 2, uncompressed, 32 bits a pixel with 8 alpha bits, rows from the top. Both readers we tried opened the sample and returned the same RGBA values as heif/to/png, soft shadow included.
Is the alpha premultiplied?
No. Each pixel keeps its decoded color and its own alpha: a shadow pixel is dark brown at 112/255 opacity, not a mid-gray at full opacity.
How does the Targa compare with the bitmap?
They hold the same RGBA values in almost the same space: 409,618 bytes for this Targa and 409,722 for the HEIF to BMP output. Both store four bytes a pixel without compression; only the headers differ, 18 bytes against 122.
Convert your first HEIF file in a minute.