rbpdf 1.19.8 → 1.20.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 +4 -4
- data/CHANGELOG +5 -0
- data/README.md +6 -2
- data/lib/core/mini_magick.rb +101 -0
- data/lib/core/rmagick.rb +5 -3
- data/lib/rbpdf.rb +91 -31
- data/lib/rbpdf/version.rb +1 -1
- data/lib/unicode_data.rb +1 -0
- data/rbpdf.gemspec +2 -1
- data/test/input.jpg +0 -0
- data/test/json: +0 -0
- data/test/output.png +0 -0
- data/test/rbpdf_cell_test.rb +2 -2
- data/test/rbpdf_html_test.rb +3 -3
- data/test/rbpdf_http_test.rb +1 -2
- data/test/rbpdf_image_rmagick_test.rb +2 -2
- data/test/test.rb +22 -0
- metadata +12 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b80cab6ce3fb2d7d57010d42f7b82963ad0c467
|
4
|
+
data.tar.gz: 26efc4e45882f2a043d848e730f2f754209c7ae2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43c758cd4cb263758ee0177d8fe1548d4afeb5acf8956702f5c87d4b1bb041e142342150c86050713205c06be2e8754fd68857a90256dc621c26db14456382a4
|
7
|
+
data.tar.gz: 59cca68008ee2c668f8fe04ed905bcb0cd22e95dd08439ca5ba26e2e45f1020aca89e5632533e882525b01b1521cf0679b3e839939129290d44e5872bfed058f
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -15,8 +15,8 @@ A template plugin allowing the inclusion of ERB-enabled RBPDF template files.
|
|
15
15
|
* HTML tag support.
|
16
16
|
* CSS minimum support.
|
17
17
|
* Image
|
18
|
-
- 8bit PNG image support without RMagick library.
|
19
|
-
- PNG(with alpha channel)/JPEG/GIF image support. (use RMagick library)
|
18
|
+
- 8bit PNG image support without MiniMagick/RMagick library.
|
19
|
+
- PNG(with alpha channel)/JPEG/GIF image support. (use MiniMagick or RMagick library)
|
20
20
|
|
21
21
|
|
22
22
|
##
|
@@ -29,6 +29,10 @@ RBPDF is distributed via RubyGems, and can be installed the usual way that you i
|
|
29
29
|
|
30
30
|
If you are using image file, it is recommended you install:
|
31
31
|
```
|
32
|
+
gem install mini_magick
|
33
|
+
```
|
34
|
+
or
|
35
|
+
```
|
32
36
|
gem install rmagick
|
33
37
|
```
|
34
38
|
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# The MIT License
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
#
|
21
|
+
# This implements native php methods used by tcpdf, which have had to be
|
22
|
+
# reimplemented within Ruby.
|
23
|
+
|
24
|
+
module Rbpdf
|
25
|
+
|
26
|
+
def getimagesize(filename)
|
27
|
+
return nil unless File.exist?(filename)
|
28
|
+
|
29
|
+
out = Hash.new
|
30
|
+
type = File::extname(filename)
|
31
|
+
if type == '.png'
|
32
|
+
open(filename,'rb') do |f|
|
33
|
+
# Check signature
|
34
|
+
return false if (f.read(8)!=137.chr + 'PNG' + 13.chr + 10.chr + 26.chr + 10.chr)
|
35
|
+
# Read header chunk
|
36
|
+
f.read(4)
|
37
|
+
return false if (f.read(4)!='IHDR')
|
38
|
+
out[0] = freadint(f)
|
39
|
+
out[1] = freadint(f)
|
40
|
+
out[2] = 'PNG'
|
41
|
+
out[3] = "height=\"#{out[1]}\" width=\"#{out[0]}\""
|
42
|
+
out['mime'] = 'image/png'
|
43
|
+
end
|
44
|
+
|
45
|
+
return out
|
46
|
+
end
|
47
|
+
|
48
|
+
unless Object.const_defined?(:MiniMagick)
|
49
|
+
Error('No Mini Magick: Non-PNG file is not supported.: ' + filename);
|
50
|
+
return false
|
51
|
+
end
|
52
|
+
|
53
|
+
image = MiniMagick::Image.open(filename)
|
54
|
+
|
55
|
+
width = image.width
|
56
|
+
height = image.height
|
57
|
+
|
58
|
+
out[0] = width
|
59
|
+
out[1] = height
|
60
|
+
|
61
|
+
# These are actually meant to return integer values But I couldn't seem to find anything saying what those values are.
|
62
|
+
# So for now they return strings. The only place that uses this at the moment is the parsejpeg method, so I've changed that too.
|
63
|
+
case image.mime_type
|
64
|
+
when "image/gif"
|
65
|
+
out[2] = "GIF"
|
66
|
+
when "image/jpeg"
|
67
|
+
out[2] = "JPEG"
|
68
|
+
when "image/png"
|
69
|
+
out[2] = "PNG"
|
70
|
+
when " image/vnd.wap.wbmp"
|
71
|
+
out[2] = "WBMP"
|
72
|
+
when "image/x-xpixmap"
|
73
|
+
out[2] = "XPM"
|
74
|
+
end
|
75
|
+
out[3] = "height=\"#{height}\" width=\"#{width}\""
|
76
|
+
out['mime'] = image.mime_type
|
77
|
+
|
78
|
+
# This needs work to cover more situations
|
79
|
+
# I can't see how to just list the number of channels with ImageMagick / mini_magick
|
80
|
+
case image["%[channels]"].downcase
|
81
|
+
when 'cmyk'
|
82
|
+
out['channels'] = 4
|
83
|
+
when 'rgb', 'rgba', 'srgb', 'srgba' # Mac OS X : sRGB
|
84
|
+
out['channels'] = 3
|
85
|
+
if image.colorspace.downcase == 'pseudoclassgray' # PseudoClassGray
|
86
|
+
out['channels'] = 0
|
87
|
+
else
|
88
|
+
out['channels'] = 3
|
89
|
+
end
|
90
|
+
when 'gray', 'graya'
|
91
|
+
out['channels'] = 0
|
92
|
+
else
|
93
|
+
out['channels'] = 0
|
94
|
+
end
|
95
|
+
|
96
|
+
out['bits'] = image["%[depth]"].to_i
|
97
|
+
|
98
|
+
out
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
data/lib/core/rmagick.rb
CHANGED
@@ -53,8 +53,10 @@ module Rbpdf
|
|
53
53
|
|
54
54
|
image = Magick::ImageList.new(filename)
|
55
55
|
|
56
|
-
|
57
|
-
|
56
|
+
width = image.columns
|
57
|
+
height = image.rows
|
58
|
+
out[0] = width
|
59
|
+
out[1] = height
|
58
60
|
|
59
61
|
# These are actually meant to return integer values But I couldn't seem to find anything saying what those values are.
|
60
62
|
# So for now they return strings. The only place that uses this at the moment is the parsejpeg method, so I've changed that too.
|
@@ -70,7 +72,7 @@ module Rbpdf
|
|
70
72
|
when "image/x-xpixmap"
|
71
73
|
out[2] = "XPM"
|
72
74
|
end
|
73
|
-
out[3] = "height=\"#{
|
75
|
+
out[3] = "height=\"#{height}\" width=\"#{width}\""
|
74
76
|
out['mime'] = image.mime_type
|
75
77
|
|
76
78
|
# This needs work to cover more situations
|
data/lib/rbpdf.rb
CHANGED
@@ -53,21 +53,29 @@ require 'rbpdf-font'
|
|
53
53
|
require 'erb'
|
54
54
|
|
55
55
|
begin
|
56
|
-
|
57
|
-
|
58
|
-
# https://github.com/gemhome/rmagick/pull/141
|
59
|
-
require 'rmagick' unless Object.const_defined?(:Magick)
|
56
|
+
require 'mini_magick' unless Object.const_defined?(:MiniMagick)
|
57
|
+
require 'core/mini_magick'
|
60
58
|
rescue LoadError
|
61
|
-
#
|
59
|
+
# MiniMagick is not available
|
62
60
|
end
|
63
61
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
62
|
+
unless Object.const_defined?(:MiniMagick)
|
63
|
+
begin
|
64
|
+
# RMagick 2.14.0
|
65
|
+
# [DEPRECATION] requiring "RMagick" is deprecated. Use "rmagick" instead
|
66
|
+
# https://github.com/gemhome/rmagick/pull/141
|
67
|
+
require 'rmagick' unless Object.const_defined?(:Magick)
|
68
|
+
rescue LoadError
|
69
|
+
# RMagick is not available
|
70
|
+
end
|
69
71
|
|
70
|
-
|
72
|
+
begin
|
73
|
+
require 'RMagick' unless Object.const_defined?(:Magick)
|
74
|
+
rescue LoadError
|
75
|
+
# RMagick is not available
|
76
|
+
end
|
77
|
+
require 'core/rmagick'
|
78
|
+
end
|
71
79
|
|
72
80
|
# Needed to run the test suite outside of a Rails environment.
|
73
81
|
require 'rubygems' if RUBY_VERSION < '1.9' # Ruby 1.8.7
|
@@ -4782,7 +4790,7 @@ class RBPDF
|
|
4782
4790
|
# * explicit width and height (expressed in user unit)
|
4783
4791
|
# * one explicit dimension, the other being calculated automatically in order to keep the original proportions
|
4784
4792
|
# * no explicit dimension, in which case the image is put at 72 dpi
|
4785
|
-
# Supported formats are PNG images whitout RMagick library and JPEG and GIF images supported by RMagick.
|
4793
|
+
# Supported formats are PNG images whitout RMagick/MiniMagick library and JPEG and GIF images supported by RMagick/MiniMagick.
|
4786
4794
|
# For JPEG, all flavors are allowed:
|
4787
4795
|
# * gray scales
|
4788
4796
|
# * true colors (24 bits)
|
@@ -4808,7 +4816,7 @@ class RBPDF
|
|
4808
4816
|
# * M: middle-right for LTR or middle-left for RTL
|
4809
4817
|
# * B: bottom-right for LTR or bottom-left for RTL
|
4810
4818
|
# * N: next line
|
4811
|
-
# [@param mixed :resize] If true resize (reduce) the image to fit :w and :h (requires RMagick library); if false do not resize; if 2 force resize in all cases (upscaling and downscaling).
|
4819
|
+
# [@param mixed :resize] If true resize (reduce) the image to fit :w and :h (requires RMagick/MiniMagick library); if false do not resize; if 2 force resize in all cases (upscaling and downscaling).
|
4812
4820
|
# [@param int :dpi] dot-per-inch resolution used on resize
|
4813
4821
|
# [@param string :palign]
|
4814
4822
|
# Allows to center or align the image on the current line. Possible values are:
|
@@ -4984,7 +4992,7 @@ class RBPDF
|
|
4984
4992
|
end
|
4985
4993
|
info=send(mtd, file);
|
4986
4994
|
end
|
4987
|
-
if info == 'pngalpha' and ismask == false and Object.const_defined?(:Magick)
|
4995
|
+
if info == 'pngalpha' and ismask == false and (Object.const_defined?(:MiniMagick) or Object.const_defined?(:Magick))
|
4988
4996
|
info = ImagePngAlpha(file, x, y, w, h, 'PNG', link, align, resize, dpi, palign)
|
4989
4997
|
if false != info
|
4990
4998
|
return true
|
@@ -4992,7 +5000,22 @@ class RBPDF
|
|
4992
5000
|
end
|
4993
5001
|
end
|
4994
5002
|
if !info
|
4995
|
-
if Object.const_defined?(:
|
5003
|
+
if Object.const_defined?(:MiniMagick)
|
5004
|
+
# MiniMagick library
|
5005
|
+
|
5006
|
+
### T.B.D ### TCPDF 5.0.000 ###
|
5007
|
+
# if type == 'SVG'
|
5008
|
+
# else
|
5009
|
+
img = MiniMagick::Image.open(file)
|
5010
|
+
# end
|
5011
|
+
if resize
|
5012
|
+
img.resize("#{neww}x#{newh}")
|
5013
|
+
end
|
5014
|
+
img.format 'jpeg'
|
5015
|
+
tmpname = Tempfile.new(File::basename(file), @@k_path_cache)
|
5016
|
+
tmpname.binmode
|
5017
|
+
tmpname.print img.to_blob
|
5018
|
+
elsif Object.const_defined?(:Magick)
|
4996
5019
|
# RMagick library
|
4997
5020
|
|
4998
5021
|
### T.B.D ### TCPDF 5.0.000 ###
|
@@ -5008,13 +5031,12 @@ class RBPDF
|
|
5008
5031
|
tmpname.binmode
|
5009
5032
|
jpeg_quality = @jpeg_quality
|
5010
5033
|
tmpname.print img.to_blob { self.quality = jpeg_quality }
|
5011
|
-
tmpname.fsync
|
5012
|
-
|
5013
|
-
info = parsejpeg(tmpname.path)
|
5014
|
-
tmpname.close(true)
|
5015
5034
|
else
|
5016
5035
|
return false
|
5017
5036
|
end
|
5037
|
+
tmpname.fsync
|
5038
|
+
info = parsejpeg(tmpname.path)
|
5039
|
+
tmpname.close(true)
|
5018
5040
|
end
|
5019
5041
|
|
5020
5042
|
if info == false
|
@@ -5135,13 +5157,32 @@ class RBPDF
|
|
5135
5157
|
protected :parsejpeg
|
5136
5158
|
|
5137
5159
|
def imageToPNG(file)
|
5138
|
-
|
5139
|
-
|
5140
|
-
|
5141
|
-
img
|
5160
|
+
if Object.const_defined?(:MiniMagick)
|
5161
|
+
# MiniMagick library
|
5162
|
+
|
5163
|
+
img = MiniMagick::Image.open(file)
|
5164
|
+
img.format 'png' # convert to PNG from gif
|
5165
|
+
if ['rgba', 'srgba', 'graya'].include?(img["%[channels]"].downcase)
|
5166
|
+
img.combine_options do |mogrify|
|
5167
|
+
mogrify.alpha 'off'
|
5168
|
+
end
|
5169
|
+
if ['rgba', 'srgba', 'graya'].include?(img["%[channels]"].downcase)
|
5170
|
+
return false
|
5171
|
+
end
|
5172
|
+
end
|
5173
|
+
elsif Object.const_defined?(:Magick)
|
5174
|
+
# RMagick library
|
5175
|
+
|
5176
|
+
img = Magick::ImageList.new(file)
|
5177
|
+
img.format = 'PNG' # convert to PNG from gif
|
5142
5178
|
if img.alpha?
|
5143
|
-
|
5179
|
+
img.alpha Magick::DeactivateAlphaChannel # PNG alpha channel delete
|
5180
|
+
if img.alpha?
|
5181
|
+
return false
|
5182
|
+
end
|
5144
5183
|
end
|
5184
|
+
else
|
5185
|
+
return false
|
5145
5186
|
end
|
5146
5187
|
|
5147
5188
|
#use a temporary file....
|
@@ -5180,11 +5221,11 @@ class RBPDF
|
|
5180
5221
|
elsif (ct==3)
|
5181
5222
|
colspace='Indexed';
|
5182
5223
|
else
|
5183
|
-
if Object.const_defined?(:Magick)
|
5224
|
+
if Object.const_defined?(:MiniMagick) or Object.const_defined?(:Magick)
|
5184
5225
|
# alpha channel
|
5185
5226
|
return 'pngalpha'
|
5186
5227
|
else
|
5187
|
-
Error('No RMagick: Alpha channel not supported: ' + file);
|
5228
|
+
Error('No RMagick/MiniMagick : Alpha channel not supported: ' + file);
|
5188
5229
|
end
|
5189
5230
|
end
|
5190
5231
|
if (f.read(1).unpack('C')[0] != 0)
|
@@ -5197,10 +5238,10 @@ class RBPDF
|
|
5197
5238
|
end
|
5198
5239
|
|
5199
5240
|
if (bpc>8)
|
5200
|
-
if Object.const_defined?(:Magick)
|
5241
|
+
if Object.const_defined?(:MiniMagick) or Object.const_defined?(:Magick)
|
5201
5242
|
return false
|
5202
5243
|
else
|
5203
|
-
Error('No RMagick: 16-bit depth not supported: ' + file)
|
5244
|
+
Error('No RMagick/MiniMagick : 16-bit depth not supported: ' + file)
|
5204
5245
|
end
|
5205
5246
|
end
|
5206
5247
|
|
@@ -5256,9 +5297,28 @@ class RBPDF
|
|
5256
5297
|
protected :parsepng
|
5257
5298
|
|
5258
5299
|
def image_alpha_mask(file)
|
5259
|
-
|
5260
|
-
|
5261
|
-
|
5300
|
+
if Object.const_defined?(:MiniMagick)
|
5301
|
+
# MiniMagick library
|
5302
|
+
|
5303
|
+
img = MiniMagick::Image.open(file)
|
5304
|
+
img.format('png')
|
5305
|
+
if ['rgba', 'srgba', 'graya'].include?(img["%[channels]"].downcase)
|
5306
|
+
img.combine_options do |mogrify|
|
5307
|
+
mogrify.channel 'matte'
|
5308
|
+
mogrify.separate '+matte'
|
5309
|
+
end
|
5310
|
+
else
|
5311
|
+
return false
|
5312
|
+
end
|
5313
|
+
elsif Object.const_defined?(:Magick)
|
5314
|
+
# RMagick library
|
5315
|
+
|
5316
|
+
img = Magick::ImageList.new(file)
|
5317
|
+
if img.alpha?
|
5318
|
+
img.alpha Magick::ExtractAlphaChannel # PNG alpha channel Mask
|
5319
|
+
else
|
5320
|
+
return false
|
5321
|
+
end
|
5262
5322
|
else
|
5263
5323
|
return false
|
5264
5324
|
end
|
data/lib/rbpdf/version.rb
CHANGED
data/lib/unicode_data.rb
CHANGED
data/rbpdf.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
# Copyright (c) 2011-
|
2
|
+
# Copyright (c) 2011-2019 NAITOH Jun
|
3
3
|
# Released under the MIT license
|
4
4
|
# http://www.opensource.org/licenses/MIT
|
5
5
|
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.files = Dir.glob("lib/rbpdf/version.rb") +
|
20
20
|
Dir.glob("lib/*.rb") +
|
21
21
|
Dir.glob("lib/core/rmagick.rb") +
|
22
|
+
Dir.glob("lib/core/mini_magick.rb") +
|
22
23
|
Dir.glob("test/*") +
|
23
24
|
["Rakefile", "rbpdf.gemspec", "Gemfile",
|
24
25
|
"CHANGELOG", "test_unicode.rbpdf", "README.md", "LICENSE.TXT", "MIT-LICENSE",
|
data/test/input.jpg
ADDED
Binary file
|
data/test/json:
ADDED
Binary file
|
data/test/output.png
ADDED
Binary file
|
data/test/rbpdf_cell_test.rb
CHANGED
@@ -221,11 +221,11 @@ class RbpdfTest < Test::Unit::TestCase
|
|
221
221
|
pdf = RBPDF.new('P', 'mm', 'A4', true, "UTF-8", true)
|
222
222
|
|
223
223
|
str = 'test'.force_encoding('UTF-8')
|
224
|
-
|
224
|
+
pdf.removeSHY(str)
|
225
225
|
assert_equal 'UTF-8', str.encoding.to_s
|
226
226
|
|
227
227
|
str = 'test'.force_encoding('ASCII-8BIT')
|
228
|
-
|
228
|
+
pdf.removeSHY(str)
|
229
229
|
assert_equal 'ASCII-8BIT', str.encoding.to_s
|
230
230
|
end
|
231
231
|
end
|
data/test/rbpdf_html_test.rb
CHANGED
@@ -14,13 +14,13 @@ class RbpdfHtmlTest < Test::Unit::TestCase
|
|
14
14
|
|
15
15
|
# get text count and x_pos from pdf page
|
16
16
|
def get_html_text_position_x(page, regrep_text, x_pos_exp=nil)
|
17
|
-
count_line, count_text, x_pos,
|
17
|
+
count_line, count_text, x_pos, _y_pos = get_html_text_position(page, regrep_text, x_pos_exp)
|
18
18
|
return count_line, count_text, x_pos
|
19
19
|
end
|
20
20
|
|
21
21
|
# get text count and y_pos from pdf page
|
22
22
|
def get_html_text_position_y(page, regrep_text)
|
23
|
-
count_line, count_text,
|
23
|
+
count_line, count_text, _x_pos, y_pos = get_html_text_position(page, regrep_text)
|
24
24
|
return count_line, count_text, y_pos
|
25
25
|
end
|
26
26
|
|
@@ -143,7 +143,7 @@ class RbpdfHtmlTest < Test::Unit::TestCase
|
|
143
143
|
page = pdf.get_page
|
144
144
|
assert_equal 1, page
|
145
145
|
|
146
|
-
|
146
|
+
_count_line, count_text, _xpos = pdf.get_html_text_position_x(1, /ABCD/) # Header
|
147
147
|
assert_equal 1, count_text
|
148
148
|
end
|
149
149
|
|
data/test/rbpdf_http_test.rb
CHANGED
@@ -21,8 +21,6 @@ class RbpdfHttpTest < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
test "Image get image file test" do
|
24
|
-
utf8_japanese_aiueo_str = "\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a"
|
25
|
-
|
26
24
|
images = [
|
27
25
|
# file_name, error_message
|
28
26
|
['logo_rbpdf_8bit.png', nil],
|
@@ -32,6 +30,7 @@ class RbpdfHttpTest < Test::Unit::TestCase
|
|
32
30
|
]
|
33
31
|
# no use
|
34
32
|
#if RUBY_VERSION >= '2.0' # Ruby 1.9.2/1.9.3
|
33
|
+
# utf8_japanese_aiueo_str = "\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a"
|
35
34
|
# images << 'logo_rbpdf_8bit_' + utf8_japanese_aiueo_str + '.png'
|
36
35
|
#end
|
37
36
|
|
@@ -17,7 +17,7 @@ class RbpdfTest < Test::Unit::TestCase
|
|
17
17
|
|
18
18
|
data(images)
|
19
19
|
test "image getimagesize test" do |data|
|
20
|
-
if data[:use_magick] and !Object.const_defined?(:Magick)
|
20
|
+
if data[:use_magick] and (!Object.const_defined?(:Magick) and !Object.const_defined?(:MiniMagick))
|
21
21
|
return
|
22
22
|
end
|
23
23
|
|
@@ -68,7 +68,7 @@ class RbpdfTest < Test::Unit::TestCase
|
|
68
68
|
img.format = 'PNG' # convert to PNG from gif
|
69
69
|
assert_equal true, img.alpha?
|
70
70
|
|
71
|
-
img.alpha
|
71
|
+
img.alpha Magick::DeactivateAlphaChannel # PNG alpha channel delete
|
72
72
|
assert_equal false, img.alpha?
|
73
73
|
end
|
74
74
|
|
data/test/test.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'mini_magick'
|
2
|
+
|
3
|
+
# => {"red"=>"8-bit", "green"=>"8-bit", "blue"=>"8-bit", "alpha"=>"8-bit"}
|
4
|
+
# `mogrify -alpha on -red off -green off -blue off /tmp/mini_magick20190806-29273-5pt5pu.png`
|
5
|
+
# convert drawn.png -channel matte -separate +matte matte.png
|
6
|
+
#img = MiniMagick::Image.open('input.jpg')
|
7
|
+
img = MiniMagick::Image.open('png_test_alpha.png')
|
8
|
+
#img.format('png')
|
9
|
+
img.combine_options do |mogrify|
|
10
|
+
# mogrify.alpha 'on'
|
11
|
+
# mogrify.red 'off'
|
12
|
+
# mogrify.green 'off'
|
13
|
+
# mogrify.blue 'off'
|
14
|
+
mogrify.channel 'matte'
|
15
|
+
mogrify.separate '+matte'
|
16
|
+
# convert.channel 'matte'
|
17
|
+
# convert.separate '+matte'
|
18
|
+
# mogrify.alpha 'on'
|
19
|
+
# mogrify.channel 'a'
|
20
|
+
# mogrify.evaluate 'set', '25%'
|
21
|
+
end
|
22
|
+
img.write('output.png')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbpdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NAITOH Jun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlentities
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- MIT-LICENSE
|
95
95
|
- README.md
|
96
96
|
- Rakefile
|
97
|
+
- lib/core/mini_magick.rb
|
97
98
|
- lib/core/rmagick.rb
|
98
99
|
- lib/htmlcolors.rb
|
99
100
|
- lib/rbpdf.rb
|
@@ -103,6 +104,8 @@ files:
|
|
103
104
|
- rbpdf.gemspec
|
104
105
|
- test/err_font1.rb
|
105
106
|
- test/err_font2.rb
|
107
|
+
- test/input.jpg
|
108
|
+
- 'test/json:'
|
106
109
|
- test/logo_rbpdf_8bit .png
|
107
110
|
- test/logo_rbpdf_8bit+ .png
|
108
111
|
- test/logo_rbpdf_8bit.gif
|
@@ -113,6 +116,7 @@ files:
|
|
113
116
|
- test/logo_rbpdf_mono_gray.png
|
114
117
|
- test/logo_rbpdf_mono_rgb.jpg
|
115
118
|
- test/logo_rbpdf_mono_rgb.png
|
119
|
+
- test/output.png
|
116
120
|
- test/png_test_alpha.png
|
117
121
|
- test/png_test_msk_alpha.png
|
118
122
|
- test/png_test_non_alpha.png
|
@@ -139,6 +143,7 @@ files:
|
|
139
143
|
- test/rbpdf_transaction_test.rb
|
140
144
|
- test/rbpdf_viewerpreferences_test.rb
|
141
145
|
- test/rbpdf_write_test.rb
|
146
|
+
- test/test.rb
|
142
147
|
- test/test_helper.rb
|
143
148
|
- test_unicode.rbpdf
|
144
149
|
- utf8test.txt
|
@@ -169,13 +174,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
174
|
version: '0'
|
170
175
|
requirements: []
|
171
176
|
rubyforge_project:
|
172
|
-
rubygems_version: 2.
|
177
|
+
rubygems_version: 2.6.10
|
173
178
|
signing_key:
|
174
179
|
specification_version: 4
|
175
180
|
summary: RBPDF via TCPDF.
|
176
181
|
test_files:
|
177
182
|
- test/err_font1.rb
|
178
183
|
- test/err_font2.rb
|
184
|
+
- test/input.jpg
|
185
|
+
- 'test/json:'
|
179
186
|
- test/logo_rbpdf_8bit .png
|
180
187
|
- test/logo_rbpdf_8bit+ .png
|
181
188
|
- test/logo_rbpdf_8bit.gif
|
@@ -186,6 +193,7 @@ test_files:
|
|
186
193
|
- test/logo_rbpdf_mono_gray.png
|
187
194
|
- test/logo_rbpdf_mono_rgb.jpg
|
188
195
|
- test/logo_rbpdf_mono_rgb.png
|
196
|
+
- test/output.png
|
189
197
|
- test/png_test_alpha.png
|
190
198
|
- test/png_test_msk_alpha.png
|
191
199
|
- test/png_test_non_alpha.png
|
@@ -212,5 +220,5 @@ test_files:
|
|
212
220
|
- test/rbpdf_transaction_test.rb
|
213
221
|
- test/rbpdf_viewerpreferences_test.rb
|
214
222
|
- test/rbpdf_write_test.rb
|
223
|
+
- test/test.rb
|
215
224
|
- test/test_helper.rb
|
216
|
-
has_rdoc:
|