Giter Club home page Giter Club logo

ruby-dmtx's Introduction

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

ruby-dmtx's People

Contributors

nittarab avatar srijan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ruby-dmtx's Issues

Issues during instalation

Hi,

Have you seen the error bellow?

gem install Rdmtx -v '0.2.2'
Building native extensions.  This could take a while...
ERROR:  Error installing Rdmtx:
	ERROR: Failed to build gem native extension.

    /Users/alberto/.rbenv/versions/2.2.5/bin/ruby -r ./siteconf20170508-70874-93ho0q.rb extconf.rb
checking for main() in -ldmtx... no
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling Rdmtx.c
Rdmtx.c:26:10: fatal error: 'dmtx.h' file not found
#include <dmtx.h>
         ^
1 error generated.
make: *** [Rdmtx.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/alberto/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/Rdmtx-0.2.2 for inspection.
Results logged to /Users/alberto/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-16/2.2.0-static/Rdmtx-0.2.2/gem_make.out

Regards

Issues with M1

I'm testing our application on the new M1 machines and ran into an issue with this Gem when loading up my application.

dlopen(/Users/silas/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/Rdmtx-0.4.0/lib/Rdmtx.bundle, 0x0009): symbol not found in flat namespace '_dmtxDecodeCreate' - /Users/silas/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/Rdmtx-0.4.0/lib/Rdmtx.bundle (LoadError)

I've googled around, but not finding anything helpful. This extension is pretty thin so I'm not sure if it's related to this repo or not.

Error installing with latest imagemagick: Can't install RMagick 2.16.0. Can't find MagickWand.h.

Looks like it's compatible with an older version of imagemagick, but not the latest one from homebrew:

gem install Rdmtx

Fetching: rmagick-2.16.0.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing Rdmtx:
    ERROR: Failed to build gem native extension.

    current directory: /Users/andrew/.rvm/gems/ruby-2.1.5@project/gems/rmagick-2.16.0/ext/RMagick
/Users/andrew/.rvm/rubies/ruby-2.1.5/bin/ruby -r ./siteconf20170823-69648-5nbwsd.rb extconf.rb
checking for gcc... yes
checking for Magick-config... no
checking for pkg-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... no
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no

Can't install RMagick 2.16.0. Can't find MagickWand.h.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/andrew/.rvm/rubies/ruby-2.1.5/bin/ruby

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/Users/andrew/.rvm/gems/ruby-2.1.5@project/extensions/x86_64-darwin-16/2.1.0/rmagick-2.16.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/andrew/.rvm/gems/ruby-2.1.5@project/gems/rmagick-2.16.0 for inspection.
Results logged to /Users/andrew/.rvm/gems/ruby-2.1.5@project/extensions/x86_64-darwin-16/2.1.0/rmagick-2.16.0/gem_make.out

Doesn't work storing data to string and Tempfile

[2] pry(main)> Rdmtx.new.encode("Hello you !!", 5, 5).to_blob
Magick::ImageMagickError: no decode delegate for this image format `' @ error/blob.c/ImageToBlob/1553
from (pry):2:in `to_blob'
[3] pry(main)> Rdmtx.new.encode("Hello you !!", 5, 5).write(Tempfile.new)
Magick::ImageMagickError: no encode delegate for this image format `' @ error/constitute.c/WriteImage/1176
from (pry):3:in `write'

RMagick version required

RMagick 4 with ruby 2.6+ has an incompatibility issue with MacOS systems. Can it be updated to 4.1.x ? That also adds support to Imagemagick 7. As was beeing discussed here rmagick/rmagick#483

If needed, how could I make that change locally, test it and create a PR for that?

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.