Project

quirc

0.02
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Ruby bindings for C library quirc that extracts and decode QR images
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 5.0
~> 1.0
~> 1.4.1
 Project Readme

Quirc bindings for Ruby

Quirc is a small C library for extracting and decode QR codes from images. This project is a Ruby binding for that library with the library embedded.

Example

You have to supply a ChunkyPNG object or a binary string of the grayscale image with width and height.

require 'chunky_png'
require 'quirc'

img = ChunkyPNG::Image.from_file('path_to_image.png')
res = Quirc.decode(img).first
puts res.payload
require 'base64'
require 'zlib'
require 'quirc'

encoded = <<~EOD
  eJzt0kEOwyAMRNHe/9LpFo1mwK1IYqQ/mwQDfl5wXYQQQgghT+cziZ7Tb+Ue
  7vvurL76Vvvhvuvqu0jvqHoP9wx3dh73fHdWxz3Hrc5TvYfbx01RP83j7uH2
  cCtzuf+7g7uvr74ZrY9r967cedxebrrjZtK9tMbt4Y7+L/V/Tdzn3DRH+td5
  0hq3h5veR+qjNTcPbh+3Mpd7Qzt6497vat+Voe9Oa7j93GpdrXGt+7i9XO3j
  +jknzYB7huvmGM+7GXHPcWeOM3B7upV5Rlvvun3cHm6K+qt5qibucy4hhBBC
  yN58AXWDGDc=
EOD

img = Zlib::Inflate.inflate(Base64.decode64(encoded))
res = Quirc.decode(img, 120, 120).first
puts res.payload

License

This software is licensed under the MIT License. View the license.