Skip to content
pdfconversionapi

TGA to PNG API

POST a .tga file to /v2/convert/tga/to/png and get a PNG back as base64 in the JSON. Run-length-encoded, color-mapped and grayscale TGAs all decode, bottom-up or top-down, and the PNG keeps every pixel and alpha value.

Endpoint
POST /v2/convert/tga/to/png
Accepts
tga
Sample timing
1 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/tga/to/png \
  -H "Authorization: Bearer $PDFCONVERSIONAPI_KEY" \
  -F File=@shield-icon.tga \
  -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 OK1 ms median1 file, 3.9 KB
{
  "ConversionCost": 1,
  "ConversionTime": 0.001,
  "Files": [
    {
      "FileName": "shield-icon.png",
      "FileExt": "png",
      "FileSize": 4030,
      "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 shield-icon.png, rendered by the API
Input
shield-icon.tga (16 KB)
Output
shield-icon.png (3.9 KB)
Source
A 256 x 256 pixel-art shield icon with a transparent background and a half-transparent shadow, drawn by us and saved as a 32-bit run-length-encoded TGA. (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 in pixels, with the height following the texture's aspect ratio. The resampling filter is Lanczos3, which softens hard pixel edges: the 12-color shield sent with ImageWidth=512 came back with 2,182 distinct colors.Values: 1–20000
ImageHeightintegerTarget height in pixels. Sent together with ImageWidth, the pair is a box the TGA is fitted inside.Values: 1–20000
ScaleProportionsboolean, default truefalse stretches the texture to exactly ImageWidth × ImageHeight instead of fitting it in that box.
ScaleIfLargerboolean, default falsetrue only ever shrinks. ImageWidth=1000 with this flag returned the 256 px shield untouched, as the same 4,030-byte PNG.
ScaleImageboolean, default truefalse cuts instead of scaling: ImageWidth=200 and ImageHeight=100 gave the top-left 200 × 100 region of the sprite.
ColorSpaceenum, default defaultgray writes an 8-bit gray-plus-alpha PNG (2,417 bytes for the shield); monochrome sets each pixel to black or white at level 128 and keeps the alpha. rgb turns a grayscale TGA into a color PNG and drops an alpha channel no pixel uses, while truecolors changes nothing.Values: default (same as truecolors), rgb (or srgb), gray (or grayscale), monochrome; cmyk returns 400
ImageResolutionintegerAdds a pHYs chunk with this DPI. A TGA header has no resolution field, so without this parameter the PNG has none.Values: 10–800
TransparentColorstringMakes every pixel of exactly this color fully transparent. #966034 cleared all 13,216 wood-colored pixels of the shield and left their RGB values in place.Values: #RRGGBB, R,G,B or white, black, red, green, blue, gray
FileNamestringBase name of the result. Without it, shield-icon.tga comes back as shield-icon.png.
StoreFileboolean, default falsetrue keeps the PNG for 3 hours and answers with a download URL instead of FileData.

What carries over, and what doesn't

Kept

  • Every pixel and alpha value: all 65,536 pixels of the sample, including the 3,664 shadow pixels at alpha 112, match the TGA
  • The right way up. The sample is stored bottom-up, the TGA default; the same shield saved top-down gave a byte-identical PNG
  • The TGA's channel layout: 32-bit gives RGBA, 24-bit gives RGB, grayscale gives 8-bit gray, gray with alpha gives gray-alpha
  • Run-length-encoded data (image types 9, 10 and 11) and color-mapped files, whose palette is expanded to full color

Lost or not yet supported

  • The image ID string (32 bytes in the sample) and the TGA 2.0 footer. The PNG holds only IHDR, IDAT and IEND chunks.
  • The 1-bit alpha of 16-bit TGAs. A 64 × 48 test file with eight transparent columns came back as an RGB PNG with no transparency.
  • The palette of a color-mapped TGA. It is written as a truecolor PNG, not an indexed one.
  • Crisp edges when you resize. There is no nearest-neighbor option, so pixel art scaled up or down gets soft, blended edges.

Limits

  • One TGA per request.
  • Requests up to 10 MB on the Free plan or 100 MB on paid plans, all files and fields together.
  • 100,000,000 pixels per image. The header is read first, so a 59-byte TGA claiming 12000 × 9000 pixels got a 413 at once.
  • Resize targets from 1 to 20,000 px per side, but the result counts against the 100,000,000-pixel cap too: the shield at ImageWidth=20000 returned 413, at 10,000 it converted.
  • 120 seconds per conversion, then 504.

Where teams use it

Texture previews in a web asset library

Browsers don't display TGA. Converting textures and sprites to PNG when they are uploaded lets a web asset library or review page show them, transparency included.

Render frames for docs and tickets

If a render or capture step saves frames as TGA, converting them gives files that wikis, docs sites and issue trackers accept, with the pixels unchanged.

One format for mixed legacy assets

Old game folders mix RLE, color-mapped, grayscale and 16-bit TGAs. Sending each through this route leaves you with 8-bit PNGs that one decoder can read.

Questions

Why is the PNG smaller than my TGA?

TGA's run-length encoding only shortens runs of identical pixels, while PNG filters each row and then deflates it. The shield went from 16,376 bytes as an RLE TGA to 4,030 bytes as a PNG with identical pixels. Saved as an uncompressed 32-bit TGA, the same picture takes 262,188 bytes.

Are bottom-left and top-left TGAs both handled?

Yes. The origin bit in the image descriptor byte is read and the rows are put in display order. The sample is stored bottom-up; a copy saved with a top-left origin produced the very same PNG, byte for byte.

Can I upscale pixel art without blurring it?

Not with this API today. Every resize uses Lanczos3, and ImageInterpolation=false does not change that: the bytes were identical with and without it. Convert at the original size and scale with nearest neighbor in your own code.

What if the upload is not really a TGA?

TGA files have no magic number, so this route reads unknown bytes as TGA. Formats that do have a signature are recognized first: a PNG posted here converted normally. Plain text got a 422 with 'the input file could not be read: it is not a TGA image, or one whose color type can't be read', and the first half of the sample got 'the input file could not be read: the image is cut short: its data ends before its last pixel'.

Does ConvertAPI offer TGA to PNG?

Not in the ConvertAPI catalogue of 328 services we compared against on 2026-11-02, which has no TGA input. Our request uses the same multipart File field and the response the same Files[] JSON as ConvertAPI-style image conversions.

Convert your first TGA file in a minute.