Rasterling (Rasterling v0.1.0)

Copy Markdown View Source

Decodes PNG, baseline/progressive JPEG, the first GIF frame, and BMP on the BEAM.

No third-party NIFs, executables, network requests or runtime dependencies. Standard OTP :zlib decompresses PNG data. Output is eight-bit RGBA.

Summary

Functions

Decodes encoded bytes into {:ok, image} or {:error, %Rasterling.Error{}}.

Reads at most :max_bytes + 1 bytes from a local file, then decodes them.

Functions

decode(bytes, opts \\ [])

@spec decode(binary(), keyword()) ::
  {:ok, Rasterling.Image.t()} | {:error, Rasterling.Error.t()}

Decodes encoded bytes into {:ok, image} or {:error, %Rasterling.Error{}}.

Options: :max_bytes, :max_pixels, :timeout (milliseconds) and :max_memory_bytes (worker heap budget). All must be positive integers. The GC-checked worker budget includes shared reference-counted binaries. It is not a process RSS or VM-wide memory guarantee.

decode!(bytes, opts \\ [])

Like decode/2, but raises Rasterling.Error on failure.

open(path, opts \\ [])

Reads at most :max_bytes + 1 bytes from a local file, then decodes them.