Coder Social home page Coder Social logo

img2zpl's Introduction

img2zpl

gem downloads

Ruby library to convert images to usable & printable ZPL code

Installation

Add the gem to your Gemfile:

gem 'img2zpl'

And then run bundle install

Or install it yourself with:

gem install img2zpl

Usage

require 'img2zpl'

img = Img2Zpl::Image.open('foo.jpg')
zpl = img.to_zpl #=> "^GFA, ... ^FS"

Using ImageMagick commands

The Img2Zpl::Image class inherits from the MiniMagick::Image class provied by the minimagick gem. So you have the same control when it comes to modifying the image before converting to ZPL.

Example:

img = Img2Zpl::Image.open('foo.png')

img.flatten
img.trim
img.resize '100x100'

zpl = img.to_zpl

Options

When calling the .to_zpl method there a number of optional parameters you can pass to further customize the resulting image:

  • black_threshold: A value between 0 and 1 that sets the darkness threshold which determines how dark a pixel should be in order to become black in the resulting b/w image. Use larger value for a more saturated image and smaller value for a less saturated one. Default: 0.5
  • invert: set to true to invert which pixels are set to black and which are set to white.
  • compress: set to false to not perform the ACSII compression in the resulting ^GF string. For larger images the uncompressed string can become very long, so use caution.

Example:

zpl = img.to_zpl black_threshold: 0.65, invert: true

Contributing

See CONTRIBUTING.md

Copyright

© 2019, Michael King and Contributors.

MIT License, see LICENSE

img2zpl's People

Contributors

mtking2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

scinote-eln

img2zpl's Issues

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.