StagesRead
DataToImage
Raw image bytes into an Image record, without re-encoding them.
- Import
import { DataToImage } from '@stabrise/scaledp'- Group
- Read
- Reads
- bytes
- Writes
- image
- Needs
- nothing
The entry point for a pipeline that starts from an image rather than a PDF. It wraps the bytes as they are and probes the dimensions, so wrapping a 40 MB scan costs a header read rather than a full decode.
import { Pipeline, DataToImage } from '@stabrise/scaledp'
import { PaddleTextRecognizer } from '@stabrise/scaledp/ocr'
const rows = await new Pipeline([
new DataToImage(),
new PaddleTextRecognizer(),
]).transform(pngFile)imageType is recorded on the output; the bytes pass through unchanged, so
declaring 'jpeg' for a PNG mislabels it rather than converting it. resolution
is the DPI to record when the row does not already carry one — it is metadata,
not a resample.
Zero bytes throw ImageError('Empty image data'), which under the default error
contract becomes an Image with that message in exception.
Parameters
| Parameter | Type | Default | Meaning |
|---|---|---|---|
imageType | 'png' | 'webp' | 'jpeg' | 'png' | Encoding recorded on the output; the bytes pass through unchanged. |
resolution | number | 0 | DPI to record when the row carries no resolution field. 0 leaves it unknown. |