Skip to content

pggalaviz/qrcoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

5069098 · Nov 23, 2019

History

14 Commits
Sep 21, 2018
Sep 21, 2018
Nov 18, 2019
Nov 18, 2019
Sep 21, 2018
Sep 21, 2018
Sep 21, 2018
Nov 20, 2019
Jan 21, 2019
Nov 20, 2019
Nov 23, 2019
Nov 18, 2019

Repository files navigation

QRCoder

Build Status

An Elixir Rust NIF to create SVG QR codes. It's a wrapper around qrcode-rust.

Installation

You can find QRCoder in Hex.pm and you can add it to your project dependencies:

# mix.exs
def deps do
  [
    {:qr_coder, "~> 0.1.0"}
  ]
end

Usage

You can then call the function:

{:ok, svg} = QRCoder.generate_svg("Elixir is awesome")

This will return a tuple where svg is black & white svg binary:

alt text

You can change the dark color by providing a valid HEX color:

{:ok, svg} = QRCoder.generate_svg("Elixir is awesome", "#21ABA5")

alt text

You can then save it:

{:ok, svg} = QRCoder.generate_svg("Elixir is awesome")
File.write("/your/path/qrcode.svg", svg)

Or just return the binary:

# inside a Phoenix controller
{:ok, svg} = QRCoder.generate_svg("Elixir is awesome")

conn
|> put_resp_header("content-type", "image/svg+xml")
|> put_resp_header("cache-control", "private")
|> send_resp(200, svg)