QRCodeEx

Simple QR Code Generator written in Elixir with no other dependencies.

This project is a fork and a successor of SiliconJungles/eqrcode. It adds the following functionallity:

We tried to keep the project api compatible with SiliconJungles/eqrcode.

Installation

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

Using QRCodeEx (Basic Usage)

You can use QRCodeEx to generate QR Code in SVG or PNG format.

qr_code_content = "your_qr_code_content"

# To SVG
qr_code_content
|> QRCodeEx.encode()
|> QRCodeEx.svg()

# To PNG
qr_code_content
|> QRCodeEx.encode()
|> QRCodeEx.png()

Note that the PNG format is only the binary. You still have to write the data to a file:

qr_code_png =
  qr_code_content
  |> QRCodeEx.encode()
  |> QRCodeEx.png()

File.write("path/where/you/want/to/save.png", qr_code_png, [:binary])

You should be able to see the file generated in the path you specified.

Image Rendering Options

SVG

You can pass in options into QRCodeEx.svg():

qr_code_content
|> QRCodeEx.encode()
|> QRCodeEx.svg(color: "#03B6AD", shape: "circle", width: 300, background_color: "#FFF")

You can specify the following attributes of the QR code:

Default options are [color: "#000", shape: "square", background_color: "#FFF"].

PNG

You can specify the following attributes of the QR code:

By default, QR code size will be dynamically generated based on the input string.

ASCII

You can also render the QRCode in your console:

qr_code_content
|> QRCodeEx.encode()
|> QRCodeEx.render()

Credits

License

This project is Licensed under the MIT License.