@algora-ventures/justvectorize
v0.1.1
Published
Vectorize images — turn PNG, JPG and WebP into SVG, PDF, EPS, AI or DXF with the JustVectorize API. Library and CLI, zero dependencies.
Maintainers
Readme
@algora-ventures/justvectorize
Vectorize images from Node.js or the command line. Turn PNG, JPG and WebP into SVG, PDF, EPS, AI or DXF with the JustVectorize API.
- Zero dependencies, ESM and CommonJS, full TypeScript types
- Every documented tracer option: palettes, color limits, background removal, stroke styles for cutters and plotters, output sizing
- Automatic retries on rate limits and transient errors
- A CLI for one-off and batch conversions
1. Get an API key
The package calls the JustVectorize API, so you need a key:
- Sign in at justvectorize.com/account.
- Open the API keys panel and create a key (
jv_live_…). - Put it in an environment variable:
export JUSTVECTORIZE_API_KEY=jv_live_xxxxxxxxxxxxxxxxxxxxxxxxOne production trace costs one credit. image_mode: "test" is free, so you can integrate before you subscribe. See pricing.
Keep the key server-side. It spends your credits. Use it from your backend or scripts, never in browser JavaScript, a mobile app or a committed config file.
2. Install
npm install @algora-ventures/justvectorizeRequires Node.js 18.17 or newer.
3. Vectorize
import { JustVectorize } from "@algora-ventures/justvectorize";
const client = new JustVectorize({ apiKey: process.env.JUSTVECTORIZE_API_KEY });
// Trace and save. The format comes from the extension.
await client.vectorizeToFile("logo.png", "logo.svg", { max_colors: 4, remove_bg: true });apiKey defaults to process.env.JUSTVECTORIZE_API_KEY, so new JustVectorize() works when the variable is set.
CommonJS:
const { JustVectorize } = require("@algora-ventures/justvectorize");Methods
| Method | Returns |
| --- | --- |
| vectorize(image, options?) | { fileUrl, operationId, format }: a temporary download link (about 30 days) |
| vectorizeToBuffer(image, options?) | the above plus data (Uint8Array) and contentType |
| vectorizeToString(image, options?) | the file as text. Use it for SVG markup |
| vectorizeToFile(image, outPath, options?) | writes the file, returns the result plus path |
image can be a file path, an http(s) URL, a Buffer / Uint8Array / ArrayBuffer, or a Blob / File.
Every method takes a third argument, { signal, timeout, fileName }, to cancel a call, override its timeout, or name the upload.
There's also a shorthand that reads the key from the environment:
import { vectorize } from "@algora-ventures/justvectorize";
const { fileUrl } = await vectorize("photo.jpg", { format: "pdf" });Examples
// Inline SVG markup
const svg = await client.vectorizeToString(buffer, { format: "svg", n_colors: 3 });
// A laser / plotter cut file: one stroke per edge, real-world units
await client.vectorizeToFile("sketch.jpg", "sketch.dxf", {
draw_style: "stroke_edges",
dxf_units: "mm",
width: 100,
unit: "mm",
});
// Lock output to brand colors
await client.vectorizeToFile("logo.png", "logo.pdf", {
palette: ["#000000", { color: "#ff5c00", tolerance: 0.1 }],
});
// Free test trace while you integrate
await client.vectorize("logo.png", { image_mode: "test" });Options use the API's own names. The full list is in the parameter reference, and your editor autocompletes them.
Client options
new JustVectorize({
apiKey: "jv_live_…", // default: process.env.JUSTVECTORIZE_API_KEY
timeout: 120_000, // ms per call
maxRetries: 2, // on 429, 5xx and network errors
fetch: customFetch, // default: global fetch
});Errors
Failures throw JustVectorizeError with the HTTP status:
import { JustVectorizeError } from "@algora-ventures/justvectorize";
try {
await client.vectorize("logo.png");
} catch (error) {
if (error instanceof JustVectorizeError && error.status === 402) {
// out of credits
}
}| Status | Meaning | | --- | --- | | 400 | No file, an unreadable image, or bad palette JSON | | 401 | Missing, invalid or revoked API key | | 402 | Out of API credits | | 413 | Image over 20 MB | | 422 | An option is the wrong type, out of range or unknown | | 429 / 5xx | Retried automatically, then thrown |
Failed requests are not charged.
CLI
npx @algora-ventures/justvectorize logo.png # → logo.svg
npx @algora-ventures/justvectorize logo.png -o logo.pdf --max-colors 3 --remove-bg
npx @algora-ventures/justvectorize sketch.jpg -f dxf --draw-style stroke_edges --dxf-units mm
npx @algora-ventures/justvectorize *.png -o vectors/ --image-mode test # batch, free
npx @algora-ventures/justvectorize logo.png --url # print the link onlyThe CLI reads JUSTVECTORIZE_API_KEY, or takes --api-key. It accepts any tracer option as --kebab-case or --snake_case. Run npx @algora-ventures/justvectorize --help to see them all.
Links
- API docs
- Pricing
- Support: [email protected]
MIT © Algora Ventures Limited
