# `QrScanner`
[🔗](https://github.com/sukidhar/qr_scanner/blob/v0.1.0/lib/qr_scanner.ex#L1)

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](https://github.com/rxing-core/rxing) (a port of ZXing / zxing-cpp) with
[rqrr](https://github.com/WanzenBug/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

# `result`

```elixir
@type result() :: {:ok, [QrScanner.Code.t()]} | {:error, atom()}
```

# `decode`

```elixir
@spec decode(binary()) :: result()
```

Decodes QR codes from PNG or JPEG bytes.

# `decode_gray`

```elixir
@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`.

# `scan`

```elixir
@spec scan(Path.t()) :: result()
```

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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
