Normalises supported OCR inputs into a Vix.Vips.Image.t() and an associated
raw pixel buffer suitable for handing to the Tesseract NIF.
Supported inputs:
%Vix.Vips.Image{}— used directly.A binary that is an existing file path — loaded with
Vix.Vips.Image.new_from_file/1.A binary containing encoded image data (PNG, JPEG, TIFF, …) — loaded with
Vix.Vips.Image.new_from_buffer/1.
Summary
Functions
Returns a tightly-packed 8-bit pixel buffer for image, ready to feed to
the Tesseract NIF.
Loads input as a Vix.Vips.Image.t().
Types
@type t() :: Vix.Vips.Image.t() | Path.t() | binary()
An accepted OCR input. See the moduledoc for resolution rules.
Functions
@spec to_pixel_buffer(Vix.Vips.Image.t()) :: {:ok, map()} | {:error, term()}
Returns a tightly-packed 8-bit pixel buffer for image, ready to feed to
the Tesseract NIF.
The image is normalised in two ways:
Down-cast to 8 bits per band when needed.
Constrained to 1 band (grayscale) or 3 bands (RGB). 4-band RGBA images are flattened against an opaque white background; 2-band images are reduced to grayscale.
Arguments
imageis aVix.Vips.Image.t().
Returns
{:ok, %{pixels: binary, width: pos_integer, height: pos_integer, bytes_per_pixel: 1 | 3, bytes_per_line: pos_integer}}on success.{:error, reason}on failure.
@spec to_vimage(t()) :: {:ok, Vix.Vips.Image.t()} | {:error, term()}
Loads input as a Vix.Vips.Image.t().
Arguments
inputis one of the values described in the moduledoc.
Returns
{:ok, image}on success.{:error, reason}if the input cannot be interpreted as an image.