A ruby implementation of ESC/POS (thermal) printer image command specification.
Add this line to your application's Gemfile:
gem 'escpos-image'
And then execute:
$ bundle
Or install it yourself as:
$ gem install escpos-image
@printer = Escpos::Printer.new
image = Escpos::Image.new 'path/to/image.png'
# to use automatic conversion to monochrome format (requires mini_magick gem) use:
image = Escpos::Image.new 'path/to/image.png', {
convert_to_monochrome: true,
dither: true, # the default
extent: true, # the default
}
@printer.write image.to_escpos
@printer.to_escpos # returns ESC/POS data ready to be sent to printer
# on linux this can be piped directly to /dev/usb/lp0
# with network printer sent directly to printer socket
# with serial port printer it can be sent directly to the serial port
@printer.to_base64 # returns base64 encoded ESC/POS data
Bug reports and pull requests are welcome on GitHub at https://github.com/escpos/escpos-image.
- Fork it ( https://github.com/escpos/escpos-image/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request