@genqr/image-sharp
v0.1.2
Published
Sharp image I/O and preprocessing backend for GenQR
Downloads
500
Readme
@genqr/image-sharp
Sharp-based ImageBackend for @genqr/core. Provides image reading, decode preprocessing, and PNG writing on Node.js.
Install
npm install @genqr/image-sharp @genqr/coreRequires Node.js 20 or newer. Sharp is a native dependency; prebuilt binaries cover common platforms, otherwise a local build toolchain is needed.
Usage
import { createSharpImageBackend } from '@genqr/image-sharp'
const backend = createSharpImageBackend()
const raster = await backend.read('input.png')
await backend.write(raster, 'output.png')Contract
read(input): accepts a file path or encoded bytes. Sharp decodes PNG, JPEG, WebP, and other formats supported by the installed Sharp build. Returns an RGBARasterImage. Raw unencoded RGBA bytes are not accepted.preprocess(raster, options): appliesresize,brightness,contrast,blur, andgrayscale. Brightness and contrast are multipliers around1.write(raster, path): encodes the RGBA raster and always writes PNG bytes, regardless of the file extension. There is no JPEG/WebP writer.perspectiveisfalse; perspective transforms are handled inside@genqr/core.
