Skip to content

Latest commit

 

History

History
88 lines (63 loc) · 1.69 KB

README.md

File metadata and controls

88 lines (63 loc) · 1.69 KB

This is a gem enabled version with some additional features of the ruby wrapper for libdmtx that can be found at: https://github.com/dmtx/dmtx-wrappers

The original README file is renamed as libdmtx-README.

Installation

gem install Rdmtx

Dependencies

  • libdmtx
  • rmagick

Example

require 'rmagick'
require 'Rdmtx'
rdmtx = Rdmtx.new
i = rdmtx.encode("Hello you !!", 5, 5)
i.write("output.png")

See test.rb for a decode example.

API

Create new Rdmtx object

rdmtx.new

Encoding

rdmtx.encode(String, MarginSize, ModuleSize, SizeRequest)

Creates and returns an rmagick image object by encoding String with (optional arguments) margin MarginSize, module ModuleSize, and request a particular size of the output SizeRequest.

  • MarginSize is the margin in number of pixels
  • ModuleSize is the size of one module in number of pixels
  • SizeRequest has to be one of pre-defined constants like: DmtxSymbolSquareAuto, DmtxSymbol10x10, etc.. See ext/rdmtx/Rdmtx.c for a full listing of the possible values.

Decoding

rdmtx.decode(Image, Timeout)

Decodes the rmagick image object Image within Timeout.

Development Environment

Dependencies

sudo apt install software-properties-common
sudo apt-add-repository -y ppa:rael-gc/rvm
sudo apt update
sudo apt install rvm
sudo apt install libmagickwand-dev libdmtx-dev
rvm install 2.7

Build gem

rvm use 2.7@ruby-dmtx
gem build Rdmtx.gemspec

Install and test local gem

gem install ./Rdmtx-0.5.0.gem
./test.rb
./test.rb output.png

Upload to rubygems

gem push Rdmtx-0.5.0.gem