rqrcode-with-patches 0.5.5 → 0.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9837d6427a26ac797834219b246f4e9efd5e59a
4
- data.tar.gz: dfa07d676b0084f75aac78ae13d51ab6b23cfdfa
3
+ metadata.gz: abc10cb5ee81f0afc70beb9f0e0cd9890bb02755
4
+ data.tar.gz: c16250d3b3d9d06007bd23158dd9038b16b6a41c
5
5
  SHA512:
6
- metadata.gz: e2b433a5481255b1fc13f46194274af6d994969794b47860aa06aedc8f9a4918ffaccc5f68329636892d977b1004e48058bca50f36f2e5236e296fc1712f03e0
7
- data.tar.gz: b5ac381cfc7e18301be81f86eeb446c1408fa97000c2c64da38bf9c2d2c1e5f6202027a644fbd0273256da4d9fbf1da3eaa450534ced13984e49b9a73b08d033
6
+ metadata.gz: 267298865c535f3e34cf1770829fd022f3db3378d29af1fbda2631b123024d73cebb0ccf34cf555258fdb684b5cd0ea773fb4b651930ad54d288c9d3d7d3c731
7
+ data.tar.gz: aff62020abe5b791b088b7d205a994bbba96bb3182fcfe8a3876053c288c0198bbce58411fba54daefd8b40d06d5b31c6bd412a7a099ea26d3e46ed7b0f7deb2
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ - 2.1.0
5
+ - 2.0.0
6
+ - 1.9.3
7
+ - 1.8.7
8
+ - jruby-18mode
9
+ - jruby-19mode
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ *0.6.0* (Jun 2, 2015)
2
+
3
+ - Improved png rendering. Previous png rendering could result in hard to scan qrcodes.
4
+ *Big thanks to Bart Jedrocha*
5
+
1
6
  *0.5.5* (Apr 25, 2015)
2
7
 
3
8
  - Fixed major bug. The rs block data was missing resulting in qr codes failing to be generated.
data/Gemfile CHANGED
@@ -1,5 +1,9 @@
1
- source 'http://rubygems.org'
2
- gemspec
1
+ source 'https://rubygems.org'
3
2
 
3
+ gem "chunky_png"
4
4
 
5
- gem "chunky_png"
5
+ group :test, :development do
6
+ gem 'rake'
7
+ gem 'test-unit'
8
+ gem 'minitest'
9
+ end
data/README.md CHANGED
@@ -1,10 +1,17 @@
1
- # rQRCode, Encode QRCodes
1
+ # rQRCode, Encode QRCodes
2
+
3
+ [![Build Status](https://travis-ci.org/bjornblomqvist/rqrcode.svg?branch=master)](https://travis-ci.org/bjornblomqvist/rqrcode)
2
4
 
3
5
  I have republished this gem as rqrcode-with-patches as Duncan seams to have abandoned the project.
4
6
  You can find the original project here: http://github.com/whomwah/rqrcode
5
7
 
6
8
  ## Short changelog
7
9
 
10
+ *0.6.0* (Jun 2, 2015)
11
+
12
+ - Improved png rendering. Previous png rendering could result in hard to scan qrcodes.
13
+ *Big thanks to Bart Jedrocha*
14
+
8
15
  *0.5.5* (Apr 25, 2015)
9
16
 
10
17
  - Fixed major bug. The rs block data was missing resulting in qr codes failing to be generated.
@@ -8,10 +8,25 @@ module RQRCode
8
8
 
9
9
  # Render the PNG from the Qrcode.
10
10
  #
11
- # Options:
12
- # module_px_size - Image size, in pixels.
11
+ # There are two sizing algoritams.
12
+ #
13
+ # - Original that can result in blurry and hard to scan images
14
+ # - Google's Chart API inspired sizing that risizes the module size to fit within the given image size.
15
+ #
16
+ # The Googleis one will be used when no options are given or when the new size option is used.
17
+ #
18
+ # Options:
13
19
  # fill - Background ChunkyPNG::Color, defaults to 'white'
14
20
  # color - Foreground ChunkyPNG::Color, defaults to 'black'
21
+ #
22
+ # *Googleis*
23
+ # size - Total size of PNG in pixels. The module size is calculated so it fits. (defaults to 90)
24
+ # border_modules - Width of white border around in modules. (defaults to 4).
25
+ #
26
+ # -- DONT USE border_modules OPTION UNLESS YOU KNOW ABOUT THE QUIET ZONE NEEDS OF QR CODES --
27
+ #
28
+ # *Original*
29
+ # module_px_size - Image size, in pixels.
15
30
  # border - Border thickness, in pixels
16
31
  #
17
32
  # It first creates an image where 1px = 1 module, then resizes.
@@ -24,30 +39,53 @@ module RQRCode
24
39
  :resize_exactly_to => false,
25
40
  :fill => 'white',
26
41
  :color => 'black',
42
+ :size => 120,
27
43
  :border_modules => 4,
28
44
  :file => false,
29
45
  :module_px_size => 6
30
46
  }
47
+
48
+ googleis = options.length == 0 || (options[:size] != nil)
49
+
31
50
  options = default_img_options.merge(options) # reverse_merge
32
51
 
33
52
  fill = ChunkyPNG::Color(options[:fill])
34
53
  color = ChunkyPNG::Color(options[:color])
35
54
  output_file = options[:file]
36
- border = options[:border_modules]
37
- total_border = border * 2
38
- module_px_size = if options[:resize_gte_to]
39
- (options[:resize_gte_to].to_f / (self.module_count + total_border).to_f).ceil.to_i
55
+
56
+ module_px_size = nil
57
+ border_px = nil
58
+ png = nil
59
+
60
+ if googleis
61
+ total_image_size = options[:size]
62
+ border_modules = options[:border_modules]
63
+
64
+ module_px_size = (total_image_size.to_f / (self.module_count + 2 * border_modules).to_f).floor.to_i
65
+
66
+ img_size = module_px_size * self.module_count
67
+
68
+ remaining = total_image_size - img_size
69
+ border_px = (remaining / 2.0).floor.to_i
70
+
71
+ png = ChunkyPNG::Image.new(total_image_size, total_image_size, fill)
40
72
  else
41
- options[:module_px_size]
42
- end
43
- border_px = border * module_px_size
44
- total_border_px = border_px * 2
45
- resize_to = options[:resize_exactly_to]
73
+ border = options[:border_modules]
74
+ total_border = border * 2
75
+ module_px_size = if options[:resize_gte_to]
76
+ (options[:resize_gte_to].to_f / (self.module_count + total_border).to_f).ceil.to_i
77
+ else
78
+ options[:module_px_size]
79
+ end
80
+ border_px = border * module_px_size
81
+ total_border_px = border_px * 2
82
+ resize_to = options[:resize_exactly_to]
46
83
 
47
- img_size = module_px_size * self.module_count
48
- total_img_size = img_size + total_border_px
84
+ img_size = module_px_size * self.module_count
85
+ total_img_size = img_size + total_border_px
49
86
 
50
- png = ChunkyPNG::Image.new(total_img_size, total_img_size, fill)
87
+ png = ChunkyPNG::Image.new(total_img_size, total_img_size, fill)
88
+ end
51
89
 
52
90
  self.modules.each_index do |x|
53
91
  self.modules.each_index do |y|
@@ -60,8 +98,11 @@ module RQRCode
60
98
  end
61
99
  end
62
100
  end
101
+
102
+ if !googleis && resize_to
103
+ png = png.resize(resize_to, resize_to)
104
+ end
63
105
 
64
- png = png.resize(resize_to, resize_to) if resize_to
65
106
 
66
107
  if output_file
67
108
  png.save(output_file,{ :color_mode => ChunkyPNG::COLOR_GRAYSCALE, :bit_depth =>1})
@@ -1,3 +1,3 @@
1
1
  module RQRCode
2
- VERSION = "0.5.5"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rqrcode-with-patches
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bjorn Blomqvist and others
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-04-25 00:00:00.000000000 Z
12
+ date: 2015-06-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chunky_png
@@ -67,6 +67,7 @@ extra_rdoc_files:
67
67
  - LICENSE
68
68
  files:
69
69
  - .gitignore
70
+ - .travis.yml
70
71
  - CHANGELOG
71
72
  - Gemfile
72
73
  - LICENSE