TGA to WebP API
POST a TGA to /v2/convert/tga/to/webp and get a lossless WebP back as base64. Alpha is kept, including partial transparency, and the shield sample is under a tenth of its RLE TGA's size.
- Endpoint
- POST /v2/
convert/ tga/ to/ webp - 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/webp \
-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
fiimport base64
import os
import requests
key = os.environ["PDFCONVERSIONAPI_KEY"]
response = requests.post(
"https://api.pdfconversionapi.com/v2/convert/tga/to/webp",
headers={"Authorization": f"Bearer {key}"},
files=[("File", open("shield-icon.tga", "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 = "shield-icon.tga";
form.append("File", new Blob([await readFile(file)]), file);
const url = "https://api.pdfconversionapi.com/v2/convert/tga/to/webp";
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.001,
"Files": [
{
"FileName": "shield-icon.webp",
"FileExt": "webp",
"FileSize": 1204,
"FileData": "UklGRqwEAABXRUJQVlA4TKAE…"
}
]
}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
- shield-icon.tga (16 KB)
- Output
- shield-icon.webp (1.2 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.
| Parameter | What it does |
|---|---|
ImageWidthinteger | Width of the WebP in pixels. Resampling blends new colors into flat art, so the 128 px version of the shield (7,026 bytes) is bigger than the full-size one.Values: 1–16384 for WebP (the API accepts up to 20000) |
ImageHeightinteger | Height of the WebP; combined with a width, the texture fits inside both.Values: 1–16384 |
ScaleProportionsboolean, default true | false fills the exact width × height you give, distorting if it must. |
ScaleIfLargerboolean, default false | true refuses to enlarge: textures already smaller than the target keep their size. |
ScaleImageboolean, default true | false crops a width × height window from the top-left instead of resampling (382 bytes for a 200 × 100 crop). |
ColorSpaceenum, default default | gray converts the colors to luminance and keeps the shield's transparency in an alpha channel: 746 bytes, 524 with monochrome.Values: default, rgb, gray, monochrome; cmyk returns 400 |
TransparentColorstring | Clears pixels of exactly this color to transparent before encoding, for TGAs that use a key color instead of an alpha channel.Values: #RRGGBB, R,G,B or a basic color name |
FileNamestring | Output name without .webp. |
StoreFileboolean, default false | Keep the WebP on our side for 3 hours and get a URL back. |
What carries over, and what doesn't
Kept
- Every pixel bit for bit: the sample decodes back to the TGA's 65,536 RGBA values with no difference
- Partial transparency: the 3,664 shadow pixels keep alpha 112, unlike a GIF
- Size and orientation of the texture, whatever the TGA's origin corner
- The texture's opacity: 24-bit and grayscale TGAs, and 32-bit ones whose pixels are all opaque, come back as RGB WebPs with no alpha channel (1,090 bytes for a 24-bit copy of the shield)
Lost or not yet supported
- Nothing in the pixels, but the TGA's image ID text and footer are not carried over.
- No lossy WebP.
ImageQualityis ignored on this route, and the file is the same lossless one. - No resolution: WebP has no DPI field, so
ImageResolutionis checked for range and then dropped.
Limits
- One TGA per request.
- WebP is limited to 16,384 px per side. A 16,385 px wide TGA returned 413
WebP images can be at most 16,384 pixels on a side, and this one is 16,385×2. - 100,000,000 pixels per input image; larger headers get a 413 before decoding.
- Requests up to 10 MB on the Free plan or 100 MB on paid plans, all files and fields together.
- 120 seconds per conversion.
Where teams use it
Sprites and icons for a web game
Browsers load WebP but not TGA. Converting a game's art pack gives lossless files with alpha, and for flat-colored sprites they are a fraction of the RLE TGA size.
Serving textures in a web viewer
A model or material viewer in the browser needs its texture maps in a web format. Lossless WebP keeps the exact values that normal or mask maps depend on.
Questions
Is the WebP lossless?
Yes, always. The encoder writes the lossless WebP format (VP8L), and decoding the sample's WebP gives exactly the TGA's pixels, alpha included.
How much smaller is WebP than TGA?
It depends on the art. The shield is 16,376 bytes as an RLE TGA, 4,030 as a PNG and 1,204 as a lossless WebP. Smooth gradients compress less well than flat pixel art.
Can I make a smaller, lossy WebP?
Not on this route today: ImageQuality is ignored. Shrinking the dimensions with ImageWidth is the only size control, and on pixel art the resampled file can end up larger than the full-size one.
Why did a very wide texture fail?
The WebP format stores width and height in 14 bits, so 16,384 px is the most it can hold per side. A 16,384 × 2 TGA converted; 16,385 × 2 returned 413, and the same request with ImageWidth=16384 converted. Scale it down with ImageWidth, or choose PNG.
Convert your first TGA file in a minute.