A working code example for checking whether an image is print-ready using the Printcart Preflight API. Get a 5-star DPI rating in real time, or run a full print-readiness check (DPI, bleed, color mode, fonts) on a real file — before a customer's order goes to production. Runs on Node.js/TypeScript via @printcart/sdk-core, and needs a Printcart API key to call the real API.
git clone https://github.com/Printcart/printcart-preflight-sdk.git
cd printcart-preflight-sdk
npm install
cp .env.example .env # add your PRINTCART_API_KEY
npm startimport { createPrintcartClient } from '@printcart/sdk-core'
const printcart = createPrintcartClient({ apiKey: process.env.PRINTCART_API_KEY! })
// Free, instant — no file upload needed.
const score = await printcart.preflight.dpiScore({
widthPx: 4000,
heightPx: 3000,
canvasWidthInches: 30,
canvasHeightInches: 20,
productType: 'photo_on_canvas',
})
console.log(score.data.stars, score.data.label) // e.g. 4, "Good"Two modes, matching two different use cases:
- DPI Score (
preflight.dpiScore) — a free, synchronous check computed purely from pixel dimensions and canvas size. Use this for instant UI feedback while a customer is still choosing a size. - Full check (
preflight.createCheck) — validates a real file: DPI, bleed, color mode (RGB vs. CMYK), and embedded fonts. Runs as a report you can fetch/list/delete. From a report,preflight.createAiJobcan auto-fix issues (upscale, add bleed, convert color mode) as a separate AI job.
DPI Score is free. The full check is metered per your plan (no per-call token charge). AI fix jobs are billed separately — see the image upscale example for that flow specifically.
What's the difference between DPI Score and a full preflight check? DPI Score only needs pixel dimensions + target size — no file download, near-instant, free. A full check downloads and inspects the actual file for DPI, bleed, color mode, and fonts, and returns a structured report with any issues found.
What product types are supported for DPI scoring?
photo_on_canvas, poster, wallpaper, framed_print, wrapping_paper, stock_canvas — each has its own minimum-PPI threshold.
Can this auto-fix a low-DPI or wrong-color-mode file, not just flag it?
Yes — preflight.createAiJob takes a report and applies fixes (upscale_resolution_2x/_4x, add_bleed, remove_transparency, sharpen_edges, resize_to_spec, convert_color_mode) as a billed async job you poll to completion.
Does this replace a human prepress reviewer? No — it catches the common, mechanically-detectable issues (low resolution, wrong color mode, missing bleed) before a file reaches production. It's a pre-check, not a full prepress replacement.
Where's the full API reference?
This repo is a runnable example, not the full docs. For every field and endpoint, see the @printcart/sdk-core package.
@printcart/sdk-core— the full SDK (also covers background removal, image upscale, face crop, bulk QR, face matching)- Image upscale example — the AI-fix-job flow this repo's
createAiJobcall feeds into - Background removal example
- printcart.com — the Print-on-Demand platform this API belongs to
The example code in this repo is MIT. The Printcart API itself and @printcart/sdk-core require a Printcart account and API key to use — see printcart-sdk's LICENSE (Business Source License 1.1).