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 +4 -4
- data/README.md +5 -1
- data/escpos-image.gemspec +1 -1
- data/examples/IMG_20190225_162935.jpg +0 -0
- data/lib/escpos/image.rb +1 -1
- data/lib/escpos/image_processors/chunky_png.rb +2 -0
- data/lib/escpos/image_processors/mini_magick.rb +2 -0
- data/test/lib/escpos/image_test.rb +8 -6
- data/test/test_helper.rb +0 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de2960bc176604bf0825f60825d35c108893f8ce910260cdf11cc88ef9a7a957
|
4
|
+
data.tar.gz: 43a94f1d177e673cf2f69f92622e3bc88dee9c42e12247699bbc7583dc212829
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
data/escpos-image.gemspec
CHANGED
Binary file
|
data/lib/escpos/image.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
38
|
+
#@printer.save file
|
39
|
+
|
38
40
|
assert_equal IO.binread(file), @printer.to_escpos
|
39
41
|
end
|
40
42
|
|
data/test/test_helper.rb
CHANGED
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.
|
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
|
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.
|
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.
|
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.
|
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.
|