escpos-image 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36d745212fbf5f8f6b32fe00942ca3e76a82ddd67d9e57135b77b7ae159debbe
4
- data.tar.gz: 8cd8ce72f04f2c80c2057178088cc7eeb4468ebf16553918a2e54332aade82af
3
+ metadata.gz: de2960bc176604bf0825f60825d35c108893f8ce910260cdf11cc88ef9a7a957
4
+ data.tar.gz: 43a94f1d177e673cf2f69f92622e3bc88dee9c42e12247699bbc7583dc212829
5
5
  SHA512:
6
- metadata.gz: cb264d2de0adba6dfa565c6cd441c509a459e28d0a408dacba9c2deabd9f2094f8aebf48f6d71957d0991e49da0fff0322aa6faecbb76e58cddd68af07e3c09e
7
- data.tar.gz: c6fb9548e36938b6880eff29aa3da56ab25f57c51f0ced7e3b6d881eeb35bae2e51910f8573fd791b4d1f52d25899d3a9e05cff78c2176baa5b01b7899250e3a
6
+ metadata.gz: 136e197c9a11b27f24b285007d872b20375d78dccdb23dbdbbb54b4d2399e189f385faf170485fccd4a07bb2e3125d1a1c589d57c5b10e22b2e89f2c6443af17
7
+ data.tar.gz: 9246f0d02eccfe08b9df69682efd542705edfe7421a13e1ec77e0d21fe7af9cab0c05d7b2a7f8f924012dfeff44939a1f48171fd6211bd07e404d434a660658b
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [Build Status](https://gitlab.com/escpos/escpos-image/pipelines)
2
+
1
3
  # Escpos-image
2
4
 
3
5
  A ruby implementation of ESC/POS (thermal) printer image command specification.
@@ -32,6 +34,7 @@ or
32
34
  $ gem install chunky_png
33
35
  ## Examples
34
36
 
37
+ ![](https://github.com/escpos/escpos-image/blob/master/examples/IMG_20190225_162935.jpg)
35
38
  ![](https://github.com/escpos/escpos-image/blob/master/examples/IMG_20160610_232415_HDR.jpg)
36
39
 
37
40
  ## Usage
@@ -50,6 +53,7 @@ image = Escpos::Image.new 'path/to/image.png', {
50
53
 
51
54
  # The constructor accepts an instance of:
52
55
  # - String (path to image)
56
+ # - File
53
57
  # - ChunkyPNG::Image
54
58
  # - MiniMagick::Image
55
59
 
@@ -67,7 +71,7 @@ image = Escpos::Image.new 'path/to/image.png', {
67
71
 
68
72
  | ChunkyPng | MiniMagick |
69
73
  | --- | --- |
70
- | PNG | PNG, JPG, BMP, ... (everything supported by MiniMagick) |
74
+ | PNG | PNG, JPG, GIF, BMP, TIF, PCX, ... (everything supported by MiniMagick) |
71
75
 
72
76
  When using `ChunkyPng` processor, `chunky_png` gem has to be installed or added to the Gemfile and when using `MiniMagick` processor, `mini_magick` gem has to be installed or added to the Gemfile, this makes the gem more lightweight by making dependencies optional and based on chosen image processor.
73
77
 
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "mini_magick"
27
27
  spec.add_development_dependency "chunky_png"
28
28
 
29
- spec.add_dependency "escpos", ">= 0.0.9"
29
+ spec.add_dependency "escpos", ">= 0.0.10"
30
30
  end
@@ -9,7 +9,7 @@ module Escpos
9
9
 
10
10
  class Image
11
11
 
12
- VERSION = "0.0.10"
12
+ VERSION = "0.0.11"
13
13
 
14
14
  attr_reader :processor, :options
15
15
 
@@ -10,6 +10,8 @@ module Escpos
10
10
  @image = begin
11
11
  if image_or_path.is_a?(ChunkyPNG::Image)
12
12
  image_or_path
13
+ elsif image_or_path.is_a?(File)
14
+ ChunkyPNG::Image.from_file(image_or_path.path)
13
15
  elsif image_or_path.is_a?(String)
14
16
  ChunkyPNG::Image.from_file(image_or_path)
15
17
  else
@@ -10,6 +10,8 @@ module Escpos
10
10
  @image = begin
11
11
  if image_or_path.is_a?(::MiniMagick::Image)
12
12
  image_or_path
13
+ elsif image_or_path.is_a?(File)
14
+ ::MiniMagick::Image.open(image_or_path.path)
13
15
  elsif image_or_path.is_a?(String)
14
16
  ::MiniMagick::Image.open(image_or_path)
15
17
  else
@@ -1,24 +1,25 @@
1
1
  require_relative '../../test_helper'
2
2
 
3
3
  class ImageTest < Minitest::Test
4
+
4
5
  def setup
5
6
  @printer = Escpos::Printer.new
6
7
  end
7
8
 
8
- # TODO photos of results
9
- # TODO USB with option print tests (dev dependency)
10
-
11
9
  def test_image
12
10
  image_path = File.join(__dir__, '../../fixtures/tux_mono.png')
13
- image = Escpos::Image.new image_path,
11
+ image_file = File.new image_path
12
+ image = Escpos::Image.new image_file,
14
13
  processor: "MiniMagick"
14
+ image_file.close
15
15
 
16
16
  @printer << image
17
17
  @printer << "\n" * 10
18
18
  @printer.cut!
19
19
  image.processor.image.write(File.join(__dir__, "../../results/#{__method__}.png"))
20
20
  file = File.join(__dir__, "../../results/#{__method__}.txt")
21
- #IO.binwrite file, @printer.to_escpos
21
+ #@printer.save file
22
+
22
23
  assert_equal IO.binread(file), @printer.to_escpos
23
24
  end
24
25
 
@@ -34,7 +35,8 @@ class ImageTest < Minitest::Test
34
35
  image.processor.image.metadata = {}
35
36
  image.processor.image.save(File.join(__dir__, "../../results/#{__method__}.png"))
36
37
  file = File.join(__dir__, "../../results/#{__method__}.txt")
37
- #IO.binwrite file, @printer.to_escpos
38
+ #@printer.save file
39
+
38
40
  assert_equal IO.binread(file), @printer.to_escpos
39
41
  end
40
42
 
@@ -5,5 +5,4 @@ require 'minitest/autorun'
5
5
  require 'pp'
6
6
 
7
7
  require 'escpos'
8
- require 'chunky_png'
9
8
  require File.expand_path('../../lib/escpos/image.rb', __FILE__)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: escpos-image
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Svoboda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-24 00:00:00.000000000 Z
11
+ date: 2019-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 0.0.9
89
+ version: 0.0.10
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 0.0.9
96
+ version: 0.0.10
97
97
  description: A ruby implementation of ESC/POS (thermal) printer image command specification.
98
98
  email:
99
99
  - jan@mluv.cz
@@ -112,6 +112,7 @@ files:
112
112
  - bin/setup
113
113
  - escpos-image.gemspec
114
114
  - examples/IMG_20160610_232415_HDR.jpg
115
+ - examples/IMG_20190225_162935.jpg
115
116
  - lib/escpos/errors.rb
116
117
  - lib/escpos/helpers.rb
117
118
  - lib/escpos/image.rb
@@ -145,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
146
  - !ruby/object:Gem::Version
146
147
  version: '0'
147
148
  requirements: []
148
- rubygems_version: 3.0.2
149
+ rubygems_version: 3.0.3
149
150
  signing_key:
150
151
  specification_version: 4
151
152
  summary: A ruby implementation of ESC/POS (thermal) printer image command specification.