QRex

Hex.pmHex DocsLicense

QRex is a high-performance QR code detection and decoding library for Elixir, powered by Rust NIFs.

Features

Installation

Add qrex to your list of dependencies in mix.exs:

def deps do
  [
    {:qrex, "~> 0.1.0"}
  ]
end

Usage

Basic Example

# Read an image file
image_bytes = File.read!("path/to/image.png")

# Detect and decode QR codes
case QRex.detect_qr_codes(image_bytes) do
  {:ok, results} ->
    # Process each detected QR code
    Enum.each(results, fn
      {:ok, qr_code} ->
        IO.puts "Found QR code: #{qr_code.text}"
        IO.puts "Version: #{qr_code.version}"
        IO.puts "Bounds: #{inspect(qr_code.bounds)}"
      
      {:error, reason} ->
        IO.puts "Failed to decode QR code: #{reason}"
    end)
    
  {:error, reason} ->
    IO.puts "Failed to process image: #{reason}"
end

QR Code Information

The decoded QR code struct (QRex.QRCode) contains:

Platform Support

QRex provides pre-compiled NIFs for:

For other platforms, the library will attempt to compile from source. You'll need:

Building from Source

To force building from source, set the environment variable:

export RUSTLER_PRECOMPILATION_QREX_BUILD=1
mix deps.compile qrex --force

Performance

QRex is designed for high performance, leveraging Rust's speed and safety features:

License

Licensed under: