Skip to content

gutschilla/qrcoder

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QRCoder

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)

About

A Rust NIF for creating SVG QR codes

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Elixir 86.3%
  • Rust 13.7%