@lacspace/image
Generate images without AI — draw gradients, patterns and placeholders, resize and crop, then export to PNG, JPEG, WebP or SVG with an exact file-size budget (KB/MB). Zero-dependency and isomorphic: native Canvas in the browser, pure-JS PNG (zlib) and baseline JPEG encoders in Node, plus a fit() that binary-searches quality to hit a size ceiling.
npm i @lacspace/imageUsage
import { gradient, encode, fit, formatBytes } from "@lacspace/image";
const bg = gradient(1200, 630, {
angle: 90,
stops: [{ offset: 0, color: "#22d3ee" }, { offset: 1, color: "#6366f1" }],
}).pattern("dots", { size: 32 });
// Export in any format
const png = await encode(bg, { format: "png" });
// …or hit an exact file-size budget
const small = await fit(bg, { format: "jpeg", maxSize: "120kb" });
console.log(formatBytes(small.size), "at q", small.quality);Exports 12
SurfacegradientradialpatternencodefitencodePngencodeJpegrasterizeSvgparseSizeformatBytesparseColorKeywords
imageimage-generatorpngjpegwebpsvgresize-imagetarget-file-sizegradientcanvasno-ai