Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pggalaviz/qrcoder
A Rust NIF for creating SVG QR codes
https://github.com/pggalaviz/qrcoder
elixir nif qr-code qr-generator qrcode qrcode-generator rust svg
Last synced: 3 months ago
JSON representation
A Rust NIF for creating SVG QR codes
- Host: GitHub
- URL: https://github.com/pggalaviz/qrcoder
- Owner: pggalaviz
- License: mit
- Created: 2018-09-21T17:52:14.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-23T23:07:23.000Z (about 5 years ago)
- Last Synced: 2024-09-17T20:17:56.843Z (5 months ago)
- Topics: elixir, nif, qr-code, qr-generator, qrcode, qrcode-generator, rust, svg
- Language: Elixir
- Homepage: https://hex.pm/packages/qr_coder
- Size: 23.4 KB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# QRCoder
[![Build Status](https://travis-ci.org/pggalaviz/qrcoder.svg?branch=master)](https://travis-ci.org/pggalaviz/qrcoder)
An Elixir Rust NIF to create SVG QR codes.
It's a wrapper around [qrcode-rust](https://github.com/kennytm/qrcode-rust).## Installation
You can find **QRCoder** in [Hex.pm](https://hex.pm/packages/qr_coder) and you can
add it to your project dependencies:```elixir
# mix.exs
def deps do
[
{:qr_coder, "~> 0.1.0"}
]
end
```
## UsageYou can then call the function:
```elixir
{:ok, svg} = QRCoder.generate_svg("Elixir is awesome")
```
This will return a `tuple` where **svg** is black & white svg binary:![alt text](./examples/basic.svg "Basic QR Code")
You can change the dark color by providing a valid HEX color:
```elixir
{:ok, svg} = QRCoder.generate_svg("Elixir is awesome", "#21ABA5")
```
![alt text](./examples/custom.svg "Custom QR Code")You can then save it:
```elixir
{:ok, svg} = QRCoder.generate_svg("Elixir is awesome")
File.write("/your/path/qrcode.svg", svg)
```Or just return the binary:
```elixir
# 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)
```