PrawnEx.Image.PNG (prawn_ex v0.4.0)

Copy Markdown View Source

Decodes PNG (8-bit truecolor RGB or RGBA, non-interlaced) to raw RGB bytes for PDF embedding (/DeviceRGB, /FlateDecode).

RGBA pixels are composited on white. Indexed, grayscale, and interlaced PNGs return {:error, {:unsupported_png, _}}.

Summary

Functions

Loads PNG from path (string) or raw PNG binary.

Functions

load(data)

@spec load(String.t() | binary()) :: {:ok, map()} | {:error, term()}

Loads PNG from path (string) or raw PNG binary.

Returns {:ok, %{data: rgb_binary, width: w, height: h, filter: :flate}} or {:error, reason}.