escpos-image 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -1
- data/examples/IMG_20160610_232415_HDR.jpg +0 -0
- data/lib/escpos/image.rb +7 -3
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b32b7a8a327a517beb7c504154b0135289717d6c
|
4
|
+
data.tar.gz: 8cec75b0d76afd3d48300ce28b6a0d4775d0d50d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cb733d74f1898ea67a2115c22411120a7b3f174d0026aae89d2bf39fa65bf7f5f54a676e5264f9438e19834ad2399ff1aee651f5f1441b70bd3a6f36ff3e5b1
|
7
|
+
data.tar.gz: f0224fb12fb5de2d285166d933afe665c2ce6152e5cf78c8c88203c9844e7db159fb01413955ccf478e893b575ab61c33ad85162f7e5193df6e75345fdd8d5a7
|
data/README.md
CHANGED
@@ -18,6 +18,10 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install escpos-image
|
20
20
|
|
21
|
+
## Examples
|
22
|
+
|
23
|
+

|
24
|
+
|
21
25
|
## Usage
|
22
26
|
|
23
27
|
```ruby
|
@@ -25,7 +29,11 @@ Or install it yourself as:
|
|
25
29
|
|
26
30
|
image = Escpos::Image.new 'path/to/image.png'
|
27
31
|
# to use automatic conversion to monochrome format (requires mini_magick gem) use:
|
28
|
-
image = Escpos::Image.new 'path/to/image.png',
|
32
|
+
image = Escpos::Image.new 'path/to/image.png', {
|
33
|
+
convert_to_monochrome: true,
|
34
|
+
dither: true, # the default
|
35
|
+
extent: true, # the default
|
36
|
+
}
|
29
37
|
|
30
38
|
@printer.write image.to_escpos
|
31
39
|
|
@@ -35,6 +43,7 @@ image = Escpos::Image.new 'path/to/image.png', convert_to_monochrome: true
|
|
35
43
|
# with serial port printer it can be sent directly to the serial port
|
36
44
|
|
37
45
|
@printer.to_base64 # returns base64 encoded ESC/POS data
|
46
|
+
```
|
38
47
|
|
39
48
|
## Contributing
|
40
49
|
|
Binary file
|
data/lib/escpos/image.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Escpos
|
2
2
|
class Image
|
3
3
|
|
4
|
-
VERSION = "0.0.
|
4
|
+
VERSION = "0.0.2"
|
5
5
|
|
6
6
|
def initialize(image_path, opts = {})
|
7
7
|
if opts.fetch(:convert_to_monochrome, false)
|
@@ -55,6 +55,10 @@ module Escpos
|
|
55
55
|
|
56
56
|
private
|
57
57
|
|
58
|
+
# !!!
|
59
|
+
# Please note that MiniMagick gem is not required _intentionally_
|
60
|
+
# This makes the gem more lightweight by making this dependency optional
|
61
|
+
# !!!
|
58
62
|
def require_mini_magick!
|
59
63
|
unless defined?(MiniMagick)
|
60
64
|
begin
|
@@ -70,9 +74,9 @@ module Escpos
|
|
70
74
|
image.flatten
|
71
75
|
image.grayscale 'Rec709Luma'
|
72
76
|
if opts.fetch(:dither, true)
|
73
|
-
image.monochrome
|
74
|
-
else
|
75
77
|
image.monochrome '+dither'
|
78
|
+
else
|
79
|
+
image.monochrome
|
76
80
|
end
|
77
81
|
if opts.fetch(:extent, true)
|
78
82
|
image.extent "#{(image.width/8.0).round*8}x#{(image.height/8.0).round*8}"
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Svoboda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- bin/console
|
97
97
|
- bin/setup
|
98
98
|
- escpos-image.gemspec
|
99
|
+
- examples/IMG_20160610_232415_HDR.jpg
|
99
100
|
- lib/escpos/helpers.rb
|
100
101
|
- lib/escpos/image.rb
|
101
102
|
- test/fixtures/tux_alpha.png
|
@@ -122,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
123
|
version: '0'
|
123
124
|
requirements: []
|
124
125
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.
|
126
|
+
rubygems_version: 2.6.4
|
126
127
|
signing_key:
|
127
128
|
specification_version: 4
|
128
129
|
summary: A ruby implementation of ESC/POS (thermal) printer image command specification.
|