Giter VIP home page Giter VIP logo

eqrcode's Introduction

EQRCode

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

Installation

def deps do
  [
    {:eqrcode, "~> 0.1.10"}
  ]
end

Using EQRCode (Basic Usage)

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

qr_code_content = "your_qr_code_content"

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

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

screenshot-defaults

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
  |> EQRCode.encode()
  |> EQRCode.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 EQRCode.svg():

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

screenshot-circle-color

You can specify the following attributes of the QR code:

  • color: In hexadecimal format. The default is #000

  • background_color: In hexadecimal format or :transparent. The default is #FFF.

  • shape: Only square or circle. The default is square

  • width: The width of the QR code in pixel. Without the width attribute, the QR code size will be dynamically generated based on the input string.

  • viewbox: When set to true, the SVG element will specify its height and width using viewBox, instead of explicit height and width tags.

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

PNG

You can specify the following attributes of the QR code:

  • color: In binary format in the RGB order. The default is <<0, 0, 0>>

  • background_color: In binary format or :transparent. The default is <<255, 255, 255>>

  • width: The width of the QR code in pixel. (the actual size may vary, due to the number of modules in the 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
|> EQRCode.encode()
|> EQRCode.render()

Credits

We reused most of the code from sunboshan/qrcode to generate the matrix required to render the QR Code. We also reference rqrcode on how to generate SVG from the QR Code matrix.

Copyright and License

Copyright (c) 2014 Silicon Jungles

This library is released under the MIT License. See the LICENSE.md file.

eqrcode's People

Contributors

nthock avatar nkezhaya avatar abousquet avatar 0x8b avatar moogle19 avatar mtrudel avatar siliconavengers avatar scarfacedeb avatar astjohn avatar dcdourado avatar kianmeng avatar maltoe avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.