Decodes QR codes from full page images: scans, rendered PDF pages, phone photos.
Decoding runs in a Rust NIF on a dirty CPU scheduler, using rxing (a port of ZXing / zxing-cpp) with rqrr as a fallback.
Every function returns {:ok, codes} with one QrScanner.Code per QR code found
({:ok, []} if there are none), or {:error, reason} for unreadable input.
iex> {:ok, [code]} = QrScanner.scan("page-03.png")
iex> code.text
"91GWPF-T6T000-001WT2"
iex> code.rotation
180
Summary
Functions
Decodes QR codes from PNG or JPEG bytes.
Decodes QR codes from a raw 8-bit grayscale buffer, one byte per pixel, row by row.
Reads an image file (PNG or JPEG) and decodes every QR code in it.
Types
@type result() :: {:ok, [QrScanner.Code.t()]} | {:error, atom()}
Functions
Decodes QR codes from PNG or JPEG bytes.
@spec decode_gray(binary(), pos_integer(), pos_integer()) :: result()
Decodes QR codes from a raw 8-bit grayscale buffer, one byte per pixel, row by row.
This skips image decoding, e.g. for the output of pdftoppm -gray converted to
raw pixels. Returns {:error, :size_mismatch} if byte_size(pixels) != width * height.
Reads an image file (PNG or JPEG) and decodes every QR code in it.
Returns {:error, posix} (e.g. :enoent) if the file can't be read and
{:error, :invalid_image} if it isn't a PNG or JPEG.