ondrej-tucek

ondrej-tucek

Hi folks!

We’ve just finished (me and @smita) our new QRCode library for Elixir. Now you can generate QR code whenever you’ll want… :tada:

Basic usage looks like:

iex> qr = QRCode.create("Hello World")
iex> qr |> Result.and_then(&QRCode.Svg.save_as(&1,"/path/to/hello.svg"))
{:ok, "/path/to/hello.svg"}

If you want to change, for example, ecc level and the color of QR code you can write

iex> settings = %QRCode.SvgSettings{qrcode_color: {17, 170, 136}}
iex> qr = QRCode.create("quiz_string", :high)
iex> qr |> Result.and_then(&QRCode.Svg.save_as(&1, "/path/to/quiz.svg", settings))
{:ok, "/path/to/quiz.svg"}

Let’s try to decode the QR code above by your QR reader. You can find the result below…

Notes

  • this library was developed only for Byte mode
  • as side project was developed MatrixReloaded library for manipulating with matrices and vectors

Comments, what improve, what make better,.. are welcome.

Happy QR coding.

quiz_string =

Find what you love and let it kill you.
Charles Bukowski

Showing Posts 1 to 1

ondrej-tucek

ondrej-tucek OP

QRCode v3.0.0 is out!

See news below:

Changed

  • The main usage is now simplified:

    # QRCode.create() has default :low error correction and :byte mode
    "your_string" 
    |> QRCode.create() 
    |> QRCode.render() 
    |> QRCode.save("/tmp/qr_code.svg")
    

    Instead of QRCode.save(), you can use a function QRCode.to_base64() to encode QR to base 64.

  • In SVG settings was changed the option :format with type :none or :indent on :structure with :minify (default value) or :readable for more clearer using. The variable :structure now reflects the structure of svg file. The final svg can be minified using by :minify or :readable and thus little bit larger.

Added

  • Alphanumeric mode, thank for mpichette contribution.

    # QRCode.render() has default :svg and SvgSettings
    "your_string" 
    |> QRCode.create(:low, :alphanumeric) 
    |> QRCode.render() 
    |> QRCode.save("/tmp/qr_code.svg")
    
  • Embedded image to svg. Support embedded image are only type: jpeg, jpg, png, or svg.

    # image = {".../path/to/name.type", size}, where size must be positive integer and means how embedded image will be large in the final svg file
    iex> alias QRCode.Render.SvgSettings
    iex> image = {"/docs/elixir.svg", 100}
    iex> qr_color = {17, 170, 136}
    iex> svg_settings = %SvgSettings{qrcode_color: qr_color, image: image, structure: :readable}
    %QRCode.Render.SvgSettings{
      background_color: "#ffffff",
      background_opacity: nil,
      image: {"/docs/elixir.svg", 100},
      qrcode_color: {17, 170, 136},
      scale: 10,
      structure: :readable
    }
    iex> "your_string"
          |> QRCode.create()
          |> QRCode.render(:svg, svg_settings)
          |> QRCode.save("/tmp/qr-with-image.svg")
      {:ok, "/tmp/qr-with-image.svg"}
    

  • Png render. You can save the QR to png file.

    # You can use PngSettings similar as above in QRCode.render(:svg) 
    ...
    |> QRCode.render(:png) 
    |> QRCode.save("/tmp/qr_code.png")
    

More information and examples will find on hex.pm or check the Github library.

— All posts loaded —

Where Next? Top

Trending in Announcing Top

wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 11030 135
New
shahryarjb
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly. One of i...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
fuelen
Hi all! I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas. You...
New

Other Trending Topics Top

mudasobwa
I am seeing a lot of aplications of Argumentum ad Vericundiam in software discussions. They do link some piece of writing and point us to...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
akoutmos
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New
matt-savvy
Is there a word for the ~> symbol used in Version strings? Do you also just call it a Squiggle Arrow™ ?!
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews