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)
Open in builder

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

ParameterTypeDefaultMeaning
imageType'png' | 'webp' | 'jpeg''png'Encoding recorded on the output; the bytes pass through unchanged.
resolutionnumber0DPI to record when the row carries no resolution field. 0 leaves it unknown.

On this page