SVG to TGA API
POST an SVG to /v2/convert/svg/to/tga to get an uncompressed 32-bit Targa with alpha. The sample is drawn at ImageWidth=256: 262,162 bytes, an 18-byte header and then 4 bytes for each of its 65,536 pixels.
- Endpoint
- POST /v2/
convert/ svg/ to/ tga - Accepts
- svg
- Sample timing
- 8 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/svg/to/tga \
-H "Authorization: Bearer $PDFCONVERSIONAPI_KEY" \
-F File=@water-day-icon.svg \
--form-string ImageWidth=256 \
-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/svg/to/tga",
headers={"Authorization": f"Bearer {key}"},
files=[("File", open("water-day-icon.svg", "rb"))],
data={
"ImageWidth": "256",
},
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 = "water-day-icon.svg";
form.append("File", new Blob([await readFile(file)]), file);
form.append("ImageWidth", "256");
const url = "https://api.pdfconversionapi.com/v2/convert/svg/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.008,
"Files": [
{
"FileName": "water-day-icon.tga",
"FileExt": "tga",
"FileSize": 262162,
"FileData": "AAACAAAAAAAAAAAAAAEAASAo…"
}
]
}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
- water-day-icon.svg (2.1 KB)
- Output
- water-day-icon.tga (256 KB)
- Source
- An app icon for a fictional plant-watering reminder, with two gradients, a soft drop shadow and a text label, which we drew by hand. (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 | Texture width; the vectors are drawn at that size. The sample sends 256 for a power-of-two texture.Values: 1–20000 |
ImageHeightinteger | Texture height, with the width derived unless you send both.Values: 1–20000 |
ScaleProportionsboolean, default true | false stretches to the exact width and height, for non-square textures from square art. |
ScaleIfLargerboolean, default false | true prevents enlarging past the SVG's own size. |
ScaleImageboolean, default true | false returns a top-left crop of the unscaled render (100 × 100 gave 40,018 bytes). |
TransparentColorstring | Pixels of exactly this color get alpha 0. white clears 491 pixels at the sample's 256 px (695 at the icon's own 300 px), the white letters among them.Values: Color names (white, black, red, green, blue, gray), #RRGGBB or R,G,B |
ColorSpaceenum, default default | gray and monochrome change the colors but keep 32 bits per pixel. cmyk returns 400.Values: default, rgb, gray, monochrome |
FileNamestring | Name for the .tga. |
StoreFileboolean, default false | true gives a link valid for 3 hours. |
What carries over, and what doesn't
Kept
- Every pixel and alpha value: decoding the TGA by hand gave exactly the PNG render at 256 px
- Partial transparency, so the soft shadow stays soft
- Top-to-bottom row order (image descriptor 0x28), so nothing comes out upside down
- Sharp edges at the texture size
Lost or not yet supported
- Compactness: 262,162 bytes, where a PNG of the same 256 px render takes 22,434.
- A TGA 2.0 footer or extension area, so no author or date fields.
- A DPI or aspect field.
- Text in uninstalled fonts and images that are linked rather than embedded.
Limits
- One SVG 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 at most per render (413).
- Each side at most 65,535 px: an SVG declaring a width of 65536 returned 413 "TGA images can be at most 65,535 pixels on a side, and this one is 65,536×2".
- Width and height from 1 to 20,000.
- 120 seconds per conversion, 504 after that.
Where teams use it
Game UI and decal textures
Engines and modding tools that import TGA can take icons and decals drawn as SVG, rendered at the texture size the engine expects, with a real alpha channel.
Overlays for video tools
Video and compositing software that accepts Targa stills with alpha can use a logo or lower-third graphic rendered from SVG at the frame's pixel size.
Questions
Is the TGA compressed?
No. It is image type 2, uncompressed true color: 262,162 bytes for 256 × 256, nearly 12 times the PNG of the same pixels. If file size matters more than a plain layout, re-save it with run-length encoding in another tool.
Will a strict TGA reader open the file?
It should: an uncompressed file has no run-length packets for a reader to trip over. Three readers we tried opened the sample, and the two we compared pixel by pixel gave exactly the PNG render.
Which way up are the rows stored?
From the top. The image descriptor byte is 0x28: the origin bit says top-left, and the low bits say 8 bits of alpha per pixel.
Convert your first SVG file in a minute.