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.
gem install Rdmtx
- libdmtx
- rmagick
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.
rdmtx.new
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 pixelsModuleSize
is the size of one module in number of pixelsSizeRequest
has to be one of pre-defined constants like:DmtxSymbolSquareAuto
,DmtxSymbol10x10
, etc.. Seeext/rdmtx/Rdmtx.c
for a full listing of the possible values.
rdmtx.decode(Image, Timeout)
Decodes the rmagick image object Image
within Timeout
.
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
rvm use 2.7@ruby-dmtx
gem build Rdmtx.gemspec
gem install ./Rdmtx-0.5.0.gem
./test.rb
./test.rb output.png
gem push Rdmtx-0.5.0.gem