SVG to PNM API
POST an SVG to /v2/convert/svg/to/pnm and get its rendering as raw RGB samples behind a P6 (binary PPM) header. The sample at ImageWidth=150 is 67,515 bytes: a 15-byte header, then 150 × 150 × 3 bytes of pixels.
- Endpoint
- POST /v2/
convert/ svg/ to/ pnm - Accepts
- svg
- Sample timing
- 3 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/pnm \
-H "Authorization: Bearer $PDFCONVERSIONAPI_KEY" \
-F File=@water-day-icon.svg \
--form-string ImageWidth=150 \
-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/pnm",
headers={"Authorization": f"Bearer {key}"},
files=[("File", open("water-day-icon.svg", "rb"))],
data={
"ImageWidth": "150",
},
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", "150");
const url = "https://api.pdfconversionapi.com/v2/convert/svg/to/pnm";
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.003,
"Files": [
{
"FileName": "water-day-icon.pnm",
"FileExt": "pnm",
"FileSize": 67515,
"FileData": "UDYKMTUwIDE1MCAyNTUK////…"
}
]
}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.pnm (66 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 | Pixel width of the render; the sample halves the 300 px icon to 150.Values: 1–20000 |
ImageHeightinteger | Pixel height of the render, alone or as part of a box with ImageWidth.Values: 1–20000 |
ScaleProportionsboolean, default true | false distorts the drawing to the exact width and height. |
ScaleIfLargerboolean, default false | true ignores sizes larger than the SVG's own. |
ScaleImageboolean, default true | false takes a top-left crop of an unscaled render. |
AlphaColorstring, default white | The color transparent parts are blended onto, because the file has no alpha. #F3EFE6 gave (243, 239, 230) corners.Values: Color names (white, black, red, green, blue, gray), #RRGGBB or R,G,B |
BackgroundColorstring, default white | Blending color when AlphaColor is not sent; black turned the corners to (0, 0, 0).Values: Same as AlphaColor |
ColorSpaceenum, default default | gray and monochrome write a one-channel PGM (P5) instead: 22,515 bytes at the sample's 150 px. monochrome thresholds after transparency is blended, so every pixel is 0 or 255, the shadow included (8,928 black and 13,572 white at 150 px). cmyk returns 400.Values: default, rgb, gray, monochrome |
FileNamestring | Name of the .pnm without extension. |
StoreFileboolean, default false | Return a URL valid for 3 hours. |
What carries over, and what doesn't
Kept
- The rendered pixels, blended on white: the sample equals the 150 px PNG render composited on white, with no difference at all
- The shadow as blended color: under the tile the sample reads (230, 235, 235)
- Plain 8-bit values, three bytes per pixel, rows from the top
Lost or not yet supported
- Transparency: the alpha channel is blended away.
- Bit-packed output:
monochromestill spends one byte per pixel, as there is no PBM option. - Size: 67,515 bytes against 11,895 for a PNG of the same render.
- Physical size; Netpbm has no DPI field.
- Text in fonts not installed on our servers.
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.
- Renders over 100,000,000 pixels return 413.
- Sizes from 1 to 20,000 px per side.
- 504 after 120 seconds of conversion.
Where teams use it
Feeding drawings to code that reads raw RGB
LED matrix drivers, e-paper tools and vision tests can read the pixels straight after the header without an image decoder. Render the SVG at the device's pixel size.
Golden images for rendering tests
Keep the PPM of a known SVG in your test suite and compare bytes on every run. Any change in how the drawing renders shows up as a byte difference.
Questions
What exactly is in the header?
Two short text lines: P6, then width, height and maximum value (150 150 255), 15 bytes for the sample. The pixel data follows directly, red, green and blue for each pixel.
How do I keep the transparent area dark?
Send AlphaColor=black (or any color). Partly transparent pixels are blended with it too, so a shadow fades into that color instead of white.
Does ColorSpace=gray give me a PGM file?
Yes. gray and monochrome both write P5 with one byte per pixel: at 300 px the file is 90,015 bytes, against 270,015 for the color P6.
Convert your first SVG file in a minute.