rmagick 2.16.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rmagick might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/.appveyor.yml +19 -0
- data/.circleci/config.yml +56 -0
- data/.rubocop.yml +8 -335
- data/.rubocop_todo.yml +255 -0
- data/.ruby-version +1 -0
- data/.travis.yml +6 -49
- data/CHANGELOG.md +23 -0
- data/CONTRIBUTING.md +34 -0
- data/Gemfile +0 -6
- data/README.textile +11 -3
- data/Rakefile +23 -15
- data/before_install_linux.sh +12 -15
- data/doc/ex/InitialCoords.rb +4 -4
- data/doc/ex/NewCoordSys.rb +4 -4
- data/doc/ex/OrigCoordSys.rb +2 -2
- data/doc/ex/PreserveAspectRatio.rb +34 -34
- data/doc/ex/RotateScale.rb +7 -7
- data/doc/ex/Skew.rb +7 -7
- data/doc/ex/Use01.rb +1 -1
- data/doc/ex/Use02.rb +4 -4
- data/doc/ex/Use03.rb +2 -2
- data/doc/ex/ViewBox.rb +4 -4
- data/doc/ex/affine.rb +5 -5
- data/doc/ex/affine_transform.rb +3 -3
- data/doc/ex/arc.rb +9 -9
- data/doc/ex/arcpath.rb +2 -2
- data/doc/ex/arcs01.rb +6 -6
- data/doc/ex/arcs02.rb +8 -8
- data/doc/ex/axes.rb +11 -11
- data/doc/ex/baseline_shift01.rb +5 -5
- data/doc/ex/bilevel_channel.rb +1 -1
- data/doc/ex/blur_image.rb +1 -1
- data/doc/ex/border.rb +1 -1
- data/doc/ex/bounding_box.rb +11 -11
- data/doc/ex/cbezier1.rb +12 -12
- data/doc/ex/cbezier2.rb +13 -13
- data/doc/ex/cbezier3.rb +13 -13
- data/doc/ex/cbezier4.rb +13 -13
- data/doc/ex/cbezier5.rb +13 -13
- data/doc/ex/cbezier6.rb +19 -19
- data/doc/ex/channel.rb +2 -2
- data/doc/ex/chop.rb +2 -2
- data/doc/ex/circle.rb +7 -7
- data/doc/ex/circle01.rb +2 -2
- data/doc/ex/clip_path.rb +6 -6
- data/doc/ex/coalesce.rb +6 -6
- data/doc/ex/color_fill_to_border.rb +8 -8
- data/doc/ex/color_floodfill.rb +8 -8
- data/doc/ex/color_histogram.rb +2 -2
- data/doc/ex/color_reset.rb +2 -2
- data/doc/ex/colors.rb +4 -4
- data/doc/ex/compose_mask.rb +2 -2
- data/doc/ex/composite.rb +39 -39
- data/doc/ex/composite_layers.rb +1 -2
- data/doc/ex/contrast.rb +3 -3
- data/doc/ex/crop.rb +2 -2
- data/doc/ex/crop_with_gravity.rb +5 -5
- data/doc/ex/cubic01.rb +12 -12
- data/doc/ex/cubic02.rb +22 -22
- data/doc/ex/cycle_colormap.rb +3 -3
- data/doc/ex/dissolve.rb +0 -0
- data/doc/ex/drawcomp.rb +8 -9
- data/doc/ex/drop_shadow.rb +4 -4
- data/doc/ex/ellipse.rb +9 -9
- data/doc/ex/ellipse01.rb +3 -3
- data/doc/ex/enhance.rb +2 -2
- data/doc/ex/evenodd.rb +19 -19
- data/doc/ex/fill_pattern.rb +3 -3
- data/doc/ex/flatten_images.rb +1 -1
- data/doc/ex/font_styles.rb +13 -13
- data/doc/ex/fonts.rb +2 -6
- data/doc/ex/frame.rb +1 -1
- data/doc/ex/get_multiline_type_metrics.rb +3 -3
- data/doc/ex/get_pixels.rb +4 -6
- data/doc/ex/get_type_metrics.rb +26 -25
- data/doc/ex/gradientfill.rb +2 -2
- data/doc/ex/grav.rb +12 -12
- data/doc/ex/gravity.rb +14 -16
- data/doc/ex/group.rb +11 -11
- data/doc/ex/hatchfill.rb +2 -2
- data/doc/ex/image.rb +9 -9
- data/doc/ex/implode.rb +2 -2
- data/doc/ex/line.rb +10 -10
- data/doc/ex/line01.rb +7 -7
- data/doc/ex/mask.rb +0 -0
- data/doc/ex/matte_fill_to_border.rb +3 -3
- data/doc/ex/matte_floodfill.rb +2 -2
- data/doc/ex/matte_replace.rb +3 -3
- data/doc/ex/median_filter.rb +2 -2
- data/doc/ex/mono.rb +2 -2
- data/doc/ex/morph.rb +1 -1
- data/doc/ex/mosaic.rb +7 -5
- data/doc/ex/motion_blur.rb +1 -1
- data/doc/ex/negate_channel.rb +0 -0
- data/doc/ex/nested_rvg.rb +2 -2
- data/doc/ex/nonzero.rb +19 -19
- data/doc/ex/opacity.rb +9 -9
- data/doc/ex/path.rb +17 -17
- data/doc/ex/pattern1.rb +4 -4
- data/doc/ex/pattern2.rb +2 -2
- data/doc/ex/polaroid.rb +0 -1
- data/doc/ex/polygon.rb +7 -7
- data/doc/ex/polygon01.rb +7 -7
- data/doc/ex/polyline.rb +7 -7
- data/doc/ex/polyline01.rb +8 -8
- data/doc/ex/posterize.rb +0 -0
- data/doc/ex/qbezierpath.rb +16 -16
- data/doc/ex/quad01.rb +6 -6
- data/doc/ex/quantize-m.rb +2 -2
- data/doc/ex/random_threshold_channel.rb +1 -1
- data/doc/ex/rect01.rb +2 -2
- data/doc/ex/rect02.rb +3 -3
- data/doc/ex/rectangle.rb +6 -6
- data/doc/ex/reduce_noise.rb +2 -2
- data/doc/ex/remap.rb +0 -0
- data/doc/ex/resize_to_fill.rb +0 -0
- data/doc/ex/resize_to_fit.rb +0 -0
- data/doc/ex/roll.rb +1 -1
- data/doc/ex/rotate.rb +8 -8
- data/doc/ex/rotate_f.rb +1 -1
- data/doc/ex/roundrect.rb +6 -6
- data/doc/ex/rubyname.rb +4 -4
- data/doc/ex/rvg_clippath.rb +3 -3
- data/doc/ex/rvg_linecap.rb +7 -7
- data/doc/ex/rvg_linejoin.rb +7 -7
- data/doc/ex/rvg_opacity.rb +5 -5
- data/doc/ex/rvg_pattern.rb +8 -8
- data/doc/ex/rvg_stroke_dasharray.rb +2 -2
- data/doc/ex/sepiatone.rb +0 -0
- data/doc/ex/shadow.rb +6 -6
- data/doc/ex/shear.rb +2 -2
- data/doc/ex/skewx.rb +8 -8
- data/doc/ex/skewy.rb +9 -9
- data/doc/ex/smile.rb +5 -4
- data/doc/ex/sparse_color.rb +0 -4
- data/doc/ex/splice.rb +1 -1
- data/doc/ex/stegano.rb +4 -5
- data/doc/ex/stroke_dasharray.rb +10 -10
- data/doc/ex/stroke_fill.rb +2 -2
- data/doc/ex/stroke_linecap.rb +12 -12
- data/doc/ex/stroke_linejoin.rb +12 -12
- data/doc/ex/stroke_width.rb +11 -11
- data/doc/ex/swirl.rb +2 -2
- data/doc/ex/text.rb +6 -6
- data/doc/ex/text01.rb +4 -4
- data/doc/ex/text_align.rb +5 -5
- data/doc/ex/text_antialias.rb +2 -2
- data/doc/ex/text_styles.rb +8 -8
- data/doc/ex/text_undercolor.rb +4 -4
- data/doc/ex/texture_fill_to_border.rb +8 -8
- data/doc/ex/texture_floodfill.rb +8 -8
- data/doc/ex/texturefill.rb +2 -2
- data/doc/ex/threshold.rb +2 -2
- data/doc/ex/to_blob.rb +1 -1
- data/doc/ex/translate.rb +8 -8
- data/doc/ex/transparent.rb +6 -6
- data/doc/ex/transpose.rb +0 -0
- data/doc/ex/transverse.rb +0 -0
- data/doc/ex/tref01.rb +6 -6
- data/doc/ex/triangle01.rb +2 -2
- data/doc/ex/trim.rb +2 -2
- data/doc/ex/tspan01.rb +5 -5
- data/doc/ex/tspan02.rb +5 -5
- data/doc/ex/tspan03.rb +5 -5
- data/doc/ex/unsharp_mask.rb +3 -3
- data/doc/ex/viewex.rb +5 -5
- data/doc/ex/vignette.rb +0 -0
- data/doc/ex/watermark.rb +6 -6
- data/doc/ex/wet_floor.rb +2 -2
- data/doc/ex/writing_mode01.rb +12 -12
- data/doc/ex/writing_mode02.rb +12 -12
- data/examples/constitute.rb +1 -1
- data/examples/crop_with_gravity.rb +5 -5
- data/examples/demo.rb +6 -7
- data/examples/describe.rb +8 -10
- data/examples/find_similar_region.rb +3 -3
- data/examples/histogram.rb +192 -201
- data/examples/identify.rb +62 -73
- data/examples/image_opacity.rb +0 -1
- data/examples/import_export.rb +1 -1
- data/examples/pattern_fill.rb +3 -4
- data/examples/rotating_text.rb +5 -4
- data/examples/spinner.rb +5 -5
- data/examples/thumbnail.rb +3 -3
- data/examples/vignette.rb +5 -5
- data/ext/RMagick/extconf.rb +213 -230
- data/ext/RMagick/rmagick.c +1 -0
- data/ext/RMagick/rmagick.h +26 -29
- data/ext/RMagick/rmdraw.c +3 -38
- data/ext/RMagick/rmenum.c +36 -0
- data/ext/RMagick/rmimage.c +166 -10
- data/ext/RMagick/rminfo.c +7 -2
- data/ext/RMagick/rmkinfo.c +247 -0
- data/ext/RMagick/rmmain.c +96 -0
- data/ext/RMagick/rmutil.c +4 -0
- data/lib/rmagick/version.rb +3 -3
- data/lib/rmagick_internal.rb +226 -308
- data/lib/rvg/clippath.rb +2 -4
- data/lib/rvg/container.rb +25 -22
- data/lib/rvg/deep_equal.rb +11 -11
- data/lib/rvg/describable.rb +2 -2
- data/lib/rvg/embellishable.rb +60 -66
- data/lib/rvg/misc.rb +122 -128
- data/lib/rvg/pathdata.rb +15 -17
- data/lib/rvg/rvg.rb +41 -44
- data/lib/rvg/stretchable.rb +22 -28
- data/lib/rvg/stylable.rb +10 -10
- data/lib/rvg/text.rb +164 -165
- data/lib/rvg/transformable.rb +15 -15
- data/lib/rvg/units.rb +2 -2
- data/rmagick.gemspec +9 -33
- data/spec/rmagick/draw_spec.rb +5 -6
- data/spec/rmagick/image/blue_shift_spec.rb +1 -3
- data/spec/rmagick/image/channel_entropy_spec.rb +9 -0
- data/spec/rmagick/image/composite_spec.rb +2 -4
- data/spec/rmagick/image/constitute_spec.rb +2 -4
- data/spec/rmagick/image/dispatch_spec.rb +1 -3
- data/spec/rmagick/image/from_blob_spec.rb +1 -3
- data/spec/rmagick/image/ping_spec.rb +1 -3
- data/spec/rmagick/image/properties_spec.rb +0 -2
- data/spec/rmagick/image/read_spec.rb +28 -0
- data/spec/spec_helper.rb +7 -1
- data/spec/support/issue_200/app.rb +8 -0
- data/test/Image1.rb +70 -70
- data/test/Image2.rb +369 -361
- data/test/Image3.rb +64 -63
- data/test/ImageList1.rb +796 -792
- data/test/ImageList2.rb +43 -44
- data/test/Image_attributes.rb +26 -48
- data/test/Import_Export.rb +71 -77
- data/test/Info.rb +30 -31
- data/test/Magick.rb +47 -46
- data/test/Pixel.rb +24 -24
- data/test/Preview.rb +7 -6
- data/test/test_all_basic.rb +15 -7
- data/test/tmpnam_test.rb +3 -3
- metadata +57 -18
data/lib/rvg/transformable.rb
CHANGED
@@ -7,12 +7,12 @@ module Magick
|
|
7
7
|
# Transforms is an Array with a deep_copy method.
|
8
8
|
# During unit-testing it also has a deep_equal method.
|
9
9
|
class Transforms < Array #:nodoc:
|
10
|
-
def deep_copy(
|
10
|
+
def deep_copy(_h = nil)
|
11
11
|
copy = self.class.new
|
12
12
|
each { |transform| copy << [transform[0], transform[1].dup] }
|
13
13
|
copy
|
14
14
|
end
|
15
|
-
end
|
15
|
+
end # class Transform
|
16
16
|
|
17
17
|
# Transformations are operations on the coordinate system.
|
18
18
|
# All the transformations defined within a container (an RVG object
|
@@ -30,7 +30,7 @@ module Magick
|
|
30
30
|
@transforms.each { |transform| gc.__send__(transform[0], *transform[1]) }
|
31
31
|
end
|
32
32
|
|
33
|
-
def initialize(*
|
33
|
+
def initialize(*_args)
|
34
34
|
super()
|
35
35
|
@transforms = Transforms.new
|
36
36
|
end
|
@@ -82,19 +82,19 @@ module Magick
|
|
82
82
|
def rotate(angle, *args)
|
83
83
|
begin
|
84
84
|
case args.length
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
85
|
+
when 0
|
86
|
+
@transforms << [:rotate, [Float(angle)]]
|
87
|
+
when 2
|
88
|
+
cx = Float(args[0])
|
89
|
+
cy = Float(args[1])
|
90
|
+
@transforms << [:translate, [cx, cy]]
|
91
|
+
@transforms << [:rotate, [angle]]
|
92
|
+
@transforms << [:translate, [-cx, -cy]]
|
93
|
+
else
|
94
|
+
raise ArgumentError, "wrong number of arguments (#{args.length} for 1 or 3)"
|
95
95
|
end
|
96
96
|
rescue ArgumentError
|
97
|
-
raise ArgumentError, "arguments must be convertable to float (got #{[angle, *args].collect
|
97
|
+
raise ArgumentError, "arguments must be convertable to float (got #{[angle, *args].collect(&:class).join(', ')})"
|
98
98
|
end
|
99
99
|
yield(self) if block_given?
|
100
100
|
self
|
@@ -121,6 +121,6 @@ module Magick
|
|
121
121
|
yield(self) if block_given?
|
122
122
|
self
|
123
123
|
end
|
124
|
-
end
|
124
|
+
end # module Transformable
|
125
125
|
end # class RVG
|
126
126
|
end # module Magick
|
data/lib/rvg/units.rb
CHANGED
data/rmagick.gemspec
CHANGED
@@ -2,13 +2,6 @@ require 'date'
|
|
2
2
|
require 'English'
|
3
3
|
require './lib/rmagick/version'
|
4
4
|
|
5
|
-
def v(version)
|
6
|
-
Gem::Version.new(version)
|
7
|
-
end
|
8
|
-
|
9
|
-
RUBY = v(RUBY_VERSION.dup)
|
10
|
-
RUBYGEMS = v(Gem::VERSION.dup)
|
11
|
-
|
12
5
|
Gem::Specification.new do |s|
|
13
6
|
s.name = 'rmagick'
|
14
7
|
s.version = Magick::VERSION
|
@@ -22,9 +15,9 @@ Gem::Specification.new do |s|
|
|
22
15
|
|
23
16
|
tracked_files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
24
17
|
file_exclusion_regex = %r{(\Alib/rvg/to_c.rb)}
|
25
|
-
files = tracked_files.reject{|file| file[file_exclusion_regex] }
|
18
|
+
files = tracked_files.reject { |file| file[file_exclusion_regex] }
|
26
19
|
test_files = files.grep(%r{^(test|spec|features)/})
|
27
|
-
executables = files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
|
+
executables = files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
28
21
|
|
29
22
|
s.files = files
|
30
23
|
s.test_files = test_files
|
@@ -32,32 +25,15 @@ Gem::Specification.new do |s|
|
|
32
25
|
s.require_paths << 'ext' << 'deprecated'
|
33
26
|
|
34
27
|
s.rubyforge_project = 'rmagick'
|
35
|
-
s.extensions = %w
|
28
|
+
s.extensions = %w[ext/RMagick/extconf.rb]
|
36
29
|
s.has_rdoc = false
|
37
30
|
s.required_ruby_version = ">= #{Magick::MIN_RUBY_VERSION}"
|
38
31
|
s.requirements << "ImageMagick #{Magick::MIN_IM_VERSION} or later"
|
39
32
|
|
40
|
-
s.add_development_dependency '
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
if RUBY < v('2.0.0')
|
47
|
-
s.add_development_dependency 'json', '~> 1.0'
|
48
|
-
end
|
49
|
-
|
50
|
-
if RUBY >= v('1.9.2')
|
51
|
-
s.add_development_dependency 'rubocop', '~> 0.33.0'
|
52
|
-
end
|
53
|
-
|
54
|
-
if RUBY >= v('2.2.0')
|
55
|
-
s.add_development_dependency 'test-unit', '~> 2'
|
56
|
-
end
|
57
|
-
|
58
|
-
if RUBYGEMS < v('1.8.25')
|
59
|
-
s.add_development_dependency 'rake-compiler', '~> 0.8.0'
|
60
|
-
else
|
61
|
-
s.add_development_dependency 'rake-compiler'
|
62
|
-
end
|
33
|
+
s.add_development_dependency 'rake-compiler', '~> 1.0'
|
34
|
+
s.add_development_dependency 'rspec', '~> 3.8'
|
35
|
+
s.add_development_dependency 'rspec_junit_formatter', '~> 0.4.1'
|
36
|
+
s.add_development_dependency 'rubocop', '0.64.0'
|
37
|
+
s.add_development_dependency 'simplecov', '~> 0.16.1'
|
38
|
+
s.add_development_dependency 'test-unit', '~> 2.5'
|
63
39
|
end
|
data/spec/rmagick/draw_spec.rb
CHANGED
@@ -81,11 +81,10 @@ RSpec.describe Magick::Draw do
|
|
81
81
|
describe '#marshal_dump', '#marshal_load' do
|
82
82
|
it 'marshals without an error' do
|
83
83
|
skip 'this spec fails on some versions of ImageMagick'
|
84
|
-
rose = Magick::Image.read('rose:').first
|
85
84
|
granite = Magick::Image.read('granite:').first
|
86
85
|
s = granite.to_blob { self.format = 'miff' }
|
87
86
|
granite = Magick::Image.from_blob(s).first
|
88
|
-
blue_stroke = Magick::Image.new(20,20) { self.background_color = 'blue' }
|
87
|
+
blue_stroke = Magick::Image.new(20, 20) { self.background_color = 'blue' }
|
89
88
|
s = blue_stroke.to_blob { self.format = 'miff' }
|
90
89
|
blue_stroke = Magick::Image.from_blob(s).first
|
91
90
|
|
@@ -120,12 +119,12 @@ RSpec.describe Magick::Draw do
|
|
120
119
|
|
121
120
|
describe '#fill_pattern' do
|
122
121
|
it 'accepts an Image argument' do
|
123
|
-
img = Magick::Image.new(20,20)
|
122
|
+
img = Magick::Image.new(20, 20)
|
124
123
|
expect { draw.fill_pattern = img }.not_to raise_error
|
125
124
|
end
|
126
125
|
|
127
126
|
it 'accepts an ImageList argument' do
|
128
|
-
img = Magick::Image.new(20,20)
|
127
|
+
img = Magick::Image.new(20, 20)
|
129
128
|
ilist = Magick::ImageList.new
|
130
129
|
ilist << img
|
131
130
|
expect { draw.fill_pattern = ilist }.not_to raise_error
|
@@ -138,12 +137,12 @@ RSpec.describe Magick::Draw do
|
|
138
137
|
|
139
138
|
describe '#stroke_pattern' do
|
140
139
|
it 'accepts an Image argument' do
|
141
|
-
img = Magick::Image.new(20,20)
|
140
|
+
img = Magick::Image.new(20, 20)
|
142
141
|
expect { draw.stroke_pattern = img }.not_to raise_error
|
143
142
|
end
|
144
143
|
|
145
144
|
it 'accepts an ImageList argument' do
|
146
|
-
img = Magick::Image.new(20,20)
|
145
|
+
img = Magick::Image.new(20, 20)
|
147
146
|
ilist = Magick::ImageList.new
|
148
147
|
ilist << img
|
149
148
|
expect { draw.stroke_pattern = ilist }.not_to raise_error
|
@@ -1,6 +1,5 @@
|
|
1
1
|
RSpec.describe Magick::Image, '#blue_shift' do
|
2
|
-
|
3
|
-
let(:img) { Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first }
|
2
|
+
let(:img) { Magick::Image.read(IMAGES_DIR + '/Button_0.gif').first }
|
4
3
|
|
5
4
|
it 'returns a new Image' do
|
6
5
|
res = img.blue_shift
|
@@ -12,5 +11,4 @@ RSpec.describe Magick::Image, '#blue_shift' do
|
|
12
11
|
expect { img.blue_shift(2) }.not_to raise_error
|
13
12
|
expect { img.blue_shift(2, 3) }.to raise_error(ArgumentError)
|
14
13
|
end
|
15
|
-
|
16
14
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
RSpec.describe Magick::Image, '#channel_entropy' do
|
2
|
+
let(:img) { Magick::Image.read(IMAGES_DIR + '/Button_0.gif').first }
|
3
|
+
|
4
|
+
it 'returns a channel entropy', supported_after('6.9.0') do
|
5
|
+
res = img.channel_entropy
|
6
|
+
puts "res = #{res.inspect}"
|
7
|
+
expect(res).to eq([0.5285857222715863])
|
8
|
+
end
|
9
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
RSpec.describe Magick::Image, '#composite' do
|
2
|
-
|
3
|
-
let(:
|
4
|
-
let(:img2) { Magick::Image.read(IMAGES_DIR+'/Button_1.gif').first }
|
2
|
+
let(:img1) { Magick::Image.read(IMAGES_DIR + '/Button_0.gif').first }
|
3
|
+
let(:img2) { Magick::Image.read(IMAGES_DIR + '/Button_1.gif').first }
|
5
4
|
let(:composite_ops) do
|
6
5
|
[
|
7
6
|
Magick::UndefinedCompositeOp,
|
@@ -136,5 +135,4 @@ RSpec.describe Magick::Image, '#composite' do
|
|
136
135
|
img1.composite(img2, Magick::CenterGravity, Magick::OverCompositeOp)
|
137
136
|
end.to raise_error(Magick::DestroyedImageError)
|
138
137
|
end
|
139
|
-
|
140
138
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
RSpec.describe Magick::Image, '#constitute' do
|
2
|
-
|
3
|
-
let(:img) { Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first }
|
2
|
+
let(:img) { Magick::Image.read(IMAGES_DIR + '/Button_0.gif').first }
|
4
3
|
let(:pixels) { img.dispatch(0, 0, img.columns, img.rows, 'RGBA') }
|
5
4
|
|
6
5
|
it 'returns an equivalent image to the given pixels' do
|
@@ -9,7 +8,6 @@ RSpec.describe Magick::Image, '#constitute' do
|
|
9
8
|
# can't compare it directly to the original image.
|
10
9
|
expect(res.columns).to eq img.columns
|
11
10
|
expect(res.rows).to eq img.rows
|
12
|
-
expect(pixels.all? { |v|
|
11
|
+
expect(pixels.all? { |v| v >= 0 && v <= Magick::QuantumRange }).to be true
|
13
12
|
end
|
14
|
-
|
15
13
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
RSpec.describe Magick::Image, '#dispatch' do
|
2
|
-
|
3
|
-
let(:img) { Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first }
|
2
|
+
let(:img) { Magick::Image.read(IMAGES_DIR + '/Button_0.gif').first }
|
4
3
|
|
5
4
|
it 'expects exactly 5 or 6 arguments' do
|
6
5
|
expect { img.dispatch }.to raise_error(ArgumentError)
|
@@ -14,5 +13,4 @@ RSpec.describe Magick::Image, '#dispatch' do
|
|
14
13
|
img.dispatch(0, 0, 20, 20, 'RGBA', false, false)
|
15
14
|
end.to raise_error(ArgumentError)
|
16
15
|
end
|
17
|
-
|
18
16
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
RSpec.describe Magick::Image, '#from_blob' do
|
2
|
-
|
3
|
-
let(:img) { Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first }
|
2
|
+
let(:img) { Magick::Image.read(IMAGES_DIR + '/Button_0.gif').first }
|
4
3
|
let(:blob) { img.to_blob }
|
5
4
|
|
6
5
|
it 'returns an image equal to the original' do
|
@@ -10,5 +9,4 @@ RSpec.describe Magick::Image, '#from_blob' do
|
|
10
9
|
expect(res.first).to be_instance_of(Magick::Image)
|
11
10
|
expect(res.first).to eq img
|
12
11
|
end
|
13
|
-
|
14
12
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
RSpec.describe Magick::Image, '#ping' do
|
2
|
-
|
3
2
|
it 'returns an image from the source, omitting pixel data' do
|
4
|
-
res = Magick::Image.ping(IMAGES_DIR+'/Button_0.gif')
|
3
|
+
res = Magick::Image.ping(IMAGES_DIR + '/Button_0.gif')
|
5
4
|
expect(res).to be_instance_of(Array)
|
6
5
|
image = res.first
|
7
6
|
expect(image).to be_instance_of(Magick::Image)
|
@@ -10,5 +9,4 @@ RSpec.describe Magick::Image, '#ping' do
|
|
10
9
|
expect(image.rows).to eq 120
|
11
10
|
expect(image.filename).to match(/Button_0.gif/)
|
12
11
|
end
|
13
|
-
|
14
12
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
RSpec.describe Magick::Image, '#properties' do
|
2
|
-
|
3
2
|
let(:img) { Magick::Image.new(20, 20) }
|
4
3
|
let(:freeze_error) { RUBY_VERSION[/^1\.9|^2/] ? RuntimeError : TypeError }
|
5
4
|
|
@@ -25,5 +24,4 @@ RSpec.describe Magick::Image, '#properties' do
|
|
25
24
|
img.freeze
|
26
25
|
expect { img['d'] = 'str_4' }.to raise_error(freeze_error)
|
27
26
|
end
|
28
|
-
|
29
27
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'timeout'
|
2
|
+
|
3
|
+
RSpec.describe Magick::Image, '#read' do
|
4
|
+
describe 'issue #200' do
|
5
|
+
before do
|
6
|
+
# pid = Process.spawn File.join(SUPPORT_DIR, 'issue_200', 'app.rb'), err: :close, out: :close
|
7
|
+
# begin
|
8
|
+
# Timeout.timeout(1) do
|
9
|
+
# _, @status = Process.waitpid2 pid
|
10
|
+
# end
|
11
|
+
# rescue Timeout::Error
|
12
|
+
# Process.kill('KILL', pid)
|
13
|
+
# _, @status = Process.waitpid2 pid
|
14
|
+
# end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'not hangs with nil argument' do
|
18
|
+
skip
|
19
|
+
expect(@status.signaled?).to be_falsey
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'raise error with nil argument' do
|
23
|
+
skip
|
24
|
+
expect(@status.success?).to be_truthy
|
25
|
+
expect { Magick::Image.read(nil) }.to raise_error(Magick::ImageMagickError, /unable to open image nil/)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
require 'rmagick'
|
2
2
|
|
3
|
-
root_dir = File.expand_path('
|
3
|
+
root_dir = File.expand_path('..', __dir__)
|
4
4
|
IMAGES_DIR = File.join(root_dir, 'doc/ex/images')
|
5
|
+
SUPPORT_DIR = File.join(root_dir, 'spec', 'support')
|
6
|
+
|
7
|
+
def supported_after(version)
|
8
|
+
magick_lib_version = Magick::Magick_version.split[1].split('-').first
|
9
|
+
:skip if Gem::Version.new(magick_lib_version) < Gem::Version.new(version)
|
10
|
+
end
|
data/test/Image1.rb
CHANGED
@@ -5,25 +5,25 @@ require 'test/unit'
|
|
5
5
|
require 'test/unit/ui/console/testrunner' unless RUBY_VERSION[/^1\.9|^2/]
|
6
6
|
|
7
7
|
class Image1_UT < Test::Unit::TestCase
|
8
|
-
FreezeError = RUBY_VERSION[/^1\.9|^2/] ? RuntimeError : TypeError
|
9
|
-
|
10
8
|
def setup
|
11
9
|
@img = Magick::Image.new(20, 20)
|
12
10
|
end
|
13
11
|
|
14
12
|
def test_read_inline
|
15
|
-
img = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
|
13
|
+
img = Magick::Image.read(IMAGES_DIR + '/Button_0.gif').first
|
16
14
|
blob = img.to_blob
|
17
15
|
encoded = [blob].pack('m*')
|
18
16
|
res = Magick::Image.read_inline(encoded)
|
19
17
|
assert_instance_of(Array, res)
|
20
18
|
assert_instance_of(Magick::Image, res[0])
|
21
19
|
assert_equal(img, res[0])
|
20
|
+
assert_raise(ArgumentError) { Magick::Image.read(nil) }
|
21
|
+
assert_raise(ArgumentError) { Magick::Image.read("") }
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_spaceship
|
25
|
-
img0 = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
|
26
|
-
img1 = Magick::Image.read(IMAGES_DIR+'/Button_1.gif').first
|
25
|
+
img0 = Magick::Image.read(IMAGES_DIR + '/Button_0.gif').first
|
26
|
+
img1 = Magick::Image.read(IMAGES_DIR + '/Button_1.gif').first
|
27
27
|
sig0 = img0.signature
|
28
28
|
sig1 = img1.signature
|
29
29
|
# since <=> is based on the signature, the images should
|
@@ -59,11 +59,11 @@ class Image1_UT < Test::Unit::TestCase
|
|
59
59
|
|
60
60
|
def test_adaptive_resize
|
61
61
|
assert_nothing_raised do
|
62
|
-
res = @img.adaptive_resize(10,10)
|
62
|
+
res = @img.adaptive_resize(10, 10)
|
63
63
|
assert_instance_of(Magick::Image, res)
|
64
64
|
end
|
65
65
|
assert_nothing_raised { @img.adaptive_resize(2) }
|
66
|
-
assert_raise(ArgumentError) { @img.adaptive_resize(10,10,10) }
|
66
|
+
assert_raise(ArgumentError) { @img.adaptive_resize(10, 10, 10) }
|
67
67
|
assert_raise(ArgumentError) { @img.adaptive_resize }
|
68
68
|
end
|
69
69
|
|
@@ -95,13 +95,13 @@ class Image1_UT < Test::Unit::TestCase
|
|
95
95
|
assert_instance_of(Magick::Image, res)
|
96
96
|
end
|
97
97
|
assert_nothing_raised { @img.adaptive_threshold(2) }
|
98
|
-
assert_nothing_raised { @img.adaptive_threshold(2,4) }
|
99
|
-
assert_nothing_raised { @img.adaptive_threshold(2,4,1) }
|
100
|
-
assert_raise(ArgumentError) { @img.adaptive_threshold(2,4,1,2) }
|
98
|
+
assert_nothing_raised { @img.adaptive_threshold(2, 4) }
|
99
|
+
assert_nothing_raised { @img.adaptive_threshold(2, 4, 1) }
|
100
|
+
assert_raise(ArgumentError) { @img.adaptive_threshold(2, 4, 1, 2) }
|
101
101
|
end
|
102
102
|
|
103
103
|
def test_add_compose_mask
|
104
|
-
mask = Magick::Image.new(20,20)
|
104
|
+
mask = Magick::Image.new(20, 20)
|
105
105
|
assert_nothing_raised { @img.add_compose_mask(mask) }
|
106
106
|
assert_nothing_raised { @img.delete_compose_mask }
|
107
107
|
assert_nothing_raised { @img.add_compose_mask(mask) }
|
@@ -137,15 +137,15 @@ class Image1_UT < Test::Unit::TestCase
|
|
137
137
|
end
|
138
138
|
|
139
139
|
def add_delete_profile
|
140
|
-
img = Magick::Image.read('cmyk.jpg'),first
|
140
|
+
img = Magick::Image.read('cmyk.jpg'), first
|
141
141
|
assert_nothing_raised { img.add_profile('cmyk.icm') }
|
142
142
|
assert_nothing_raised { img.add_profile('srgb.icm') }
|
143
|
-
img.each_profile { |name,
|
143
|
+
img.each_profile { |name, _value| assert_equal('icc', name) }
|
144
144
|
assert_nothing_raised { img.delete_profile('icc') }
|
145
145
|
end
|
146
146
|
|
147
147
|
def test_affine_matrix
|
148
|
-
affine = Magick::AffineMatrix.new(1, Math::PI/6, Math::PI/6, 1, 0, 0)
|
148
|
+
affine = Magick::AffineMatrix.new(1, Math::PI / 6, Math::PI / 6, 1, 0, 0)
|
149
149
|
assert_nothing_raised { @img.affine_transform(affine) }
|
150
150
|
assert_raise(TypeError) { @img.affine_transform(0) }
|
151
151
|
res = @img.affine_transform(affine)
|
@@ -174,23 +174,23 @@ class Image1_UT < Test::Unit::TestCase
|
|
174
174
|
end
|
175
175
|
|
176
176
|
def test_auto_gamma
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
177
|
+
res = nil
|
178
|
+
assert_nothing_raised { res = @img.auto_gamma_channel }
|
179
|
+
assert_instance_of(Magick::Image, res)
|
180
|
+
assert_not_same(@img, res)
|
181
|
+
assert_nothing_raised { res = @img.auto_gamma_channel Magick::RedChannel }
|
182
|
+
assert_nothing_raised { res = @img.auto_gamma_channel Magick::RedChannel, Magick::BlueChannel }
|
183
|
+
assert_raise(TypeError) { @img.auto_gamma_channel(1) }
|
184
184
|
end
|
185
185
|
|
186
186
|
def test_auto_level
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
187
|
+
res = nil
|
188
|
+
assert_nothing_raised { res = @img.auto_level_channel }
|
189
|
+
assert_instance_of(Magick::Image, res)
|
190
|
+
assert_not_same(@img, res)
|
191
|
+
assert_nothing_raised { res = @img.auto_level_channel Magick::RedChannel }
|
192
|
+
assert_nothing_raised { res = @img.auto_level_channel Magick::RedChannel, Magick::BlueChannel }
|
193
|
+
assert_raise(TypeError) { @img.auto_level_channel(1) }
|
194
194
|
end
|
195
195
|
|
196
196
|
def test_auto_orient
|
@@ -217,11 +217,11 @@ class Image1_UT < Test::Unit::TestCase
|
|
217
217
|
assert_nothing_raised { @img.bilevel_channel(100, Magick::AllChannels) }
|
218
218
|
assert_raise(TypeError) { @img.bilevel_channel(100, 2) }
|
219
219
|
res = @img.bilevel_channel(100)
|
220
|
-
assert_instance_of(Magick::Image,
|
220
|
+
assert_instance_of(Magick::Image, res)
|
221
221
|
end
|
222
222
|
|
223
223
|
def test_blend
|
224
|
-
@img2 = Magick::Image.new(20,20) {self.background_color = 'black'}
|
224
|
+
@img2 = Magick::Image.new(20, 20) { self.background_color = 'black' }
|
225
225
|
assert_nothing_raised { @img.blend(@img2, 0.25) }
|
226
226
|
res = @img.blend(@img2, 0.25)
|
227
227
|
assert_instance_of(Magick::Image, res)
|
@@ -245,24 +245,24 @@ class Image1_UT < Test::Unit::TestCase
|
|
245
245
|
def test_blur_channel
|
246
246
|
assert_nothing_raised { @img.blur_channel }
|
247
247
|
assert_nothing_raised { @img.blur_channel(1) }
|
248
|
-
assert_nothing_raised { @img.blur_channel(1,2) }
|
249
|
-
assert_nothing_raised { @img.blur_channel(1,2, Magick::RedChannel) }
|
250
|
-
assert_nothing_raised { @img.blur_channel(1,2, Magick::RedChannel, Magick::BlueChannel, Magick::GreenChannel, Magick::OpacityChannel) }
|
251
|
-
assert_nothing_raised { @img.blur_channel(1,2, Magick::CyanChannel, Magick::MagentaChannel, Magick::YellowChannel, Magick::BlackChannel) }
|
252
|
-
assert_nothing_raised { @img.blur_channel(1,2, Magick::GrayChannel) }
|
253
|
-
assert_nothing_raised { @img.blur_channel(1,2, Magick::AllChannels) }
|
254
|
-
assert_raise(TypeError) { @img.blur_channel(1,2,2) }
|
248
|
+
assert_nothing_raised { @img.blur_channel(1, 2) }
|
249
|
+
assert_nothing_raised { @img.blur_channel(1, 2, Magick::RedChannel) }
|
250
|
+
assert_nothing_raised { @img.blur_channel(1, 2, Magick::RedChannel, Magick::BlueChannel, Magick::GreenChannel, Magick::OpacityChannel) }
|
251
|
+
assert_nothing_raised { @img.blur_channel(1, 2, Magick::CyanChannel, Magick::MagentaChannel, Magick::YellowChannel, Magick::BlackChannel) }
|
252
|
+
assert_nothing_raised { @img.blur_channel(1, 2, Magick::GrayChannel) }
|
253
|
+
assert_nothing_raised { @img.blur_channel(1, 2, Magick::AllChannels) }
|
254
|
+
assert_raise(TypeError) { @img.blur_channel(1, 2, 2) }
|
255
255
|
res = @img.blur_channel
|
256
|
-
assert_instance_of(Magick::Image,
|
256
|
+
assert_instance_of(Magick::Image, res)
|
257
257
|
end
|
258
258
|
|
259
259
|
def test_blur_image
|
260
260
|
assert_nothing_raised { @img.blur_image }
|
261
261
|
assert_nothing_raised { @img.blur_image(1) }
|
262
|
-
assert_nothing_raised { @img.blur_image(1,2) }
|
263
|
-
assert_raise(ArgumentError) { @img.blur_image(1,2,3) }
|
262
|
+
assert_nothing_raised { @img.blur_image(1, 2) }
|
263
|
+
assert_raise(ArgumentError) { @img.blur_image(1, 2, 3) }
|
264
264
|
res = @img.blur_image
|
265
|
-
assert_instance_of(Magick::Image,
|
265
|
+
assert_instance_of(Magick::Image, res)
|
266
266
|
end
|
267
267
|
|
268
268
|
def test_black_threshold
|
@@ -273,16 +273,16 @@ class Image1_UT < Test::Unit::TestCase
|
|
273
273
|
assert_nothing_raised { @img.black_threshold(50, 50, 50, 50) }
|
274
274
|
assert_raise(ArgumentError) { @img.black_threshold(50, 50, 50, 50, 50) }
|
275
275
|
res = @img.black_threshold(50)
|
276
|
-
assert_instance_of(Magick::Image,
|
276
|
+
assert_instance_of(Magick::Image, res)
|
277
277
|
end
|
278
278
|
|
279
279
|
def test_border
|
280
280
|
assert_nothing_raised { @img.border(2, 2, 'red') }
|
281
281
|
assert_nothing_raised { @img.border!(2, 2, 'red') }
|
282
|
-
res = @img.border(2,2, 'red')
|
283
|
-
assert_instance_of(Magick::Image,
|
282
|
+
res = @img.border(2, 2, 'red')
|
283
|
+
assert_instance_of(Magick::Image, res)
|
284
284
|
@img.freeze
|
285
|
-
assert_raise(FreezeError) { @img.border!(2,2, 'red') }
|
285
|
+
assert_raise(FreezeError) { @img.border!(2, 2, 'red') }
|
286
286
|
end
|
287
287
|
|
288
288
|
def test_change_geometry
|
@@ -296,9 +296,9 @@ class Image1_UT < Test::Unit::TestCase
|
|
296
296
|
end
|
297
297
|
|
298
298
|
def test_changed?
|
299
|
-
# assert_block { !@img.changed? }
|
300
|
-
# @img.pixel_color(0,0,'red')
|
301
|
-
# assert_block { @img.changed? }
|
299
|
+
# assert_block { !@img.changed? }
|
300
|
+
# @img.pixel_color(0,0,'red')
|
301
|
+
# assert_block { @img.changed? }
|
302
302
|
end
|
303
303
|
|
304
304
|
def test_channel
|
@@ -397,10 +397,10 @@ class Image1_UT < Test::Unit::TestCase
|
|
397
397
|
end
|
398
398
|
|
399
399
|
def test_clut_channel
|
400
|
-
img = Magick::Image.new(20,20) {self.colorspace = Magick::GRAYColorspace}
|
401
|
-
clut = Magick::Image.new(20,1) {self.background_color = 'red'}
|
400
|
+
img = Magick::Image.new(20, 20) { self.colorspace = Magick::GRAYColorspace }
|
401
|
+
clut = Magick::Image.new(20, 1) { self.background_color = 'red' }
|
402
402
|
res = nil
|
403
|
-
assert_nothing_raised {res = img.clut_channel(clut)}
|
403
|
+
assert_nothing_raised { res = img.clut_channel(clut) }
|
404
404
|
assert_same(res, img)
|
405
405
|
assert_nothing_raised { img.clut_channel(clut, Magick::RedChannel) }
|
406
406
|
assert_nothing_raised { img.clut_channel(clut, Magick::RedChannel, Magick::BlueChannel) }
|
@@ -411,22 +411,22 @@ class Image1_UT < Test::Unit::TestCase
|
|
411
411
|
assert_raise(ArgumentError) { @img.color_fill_to_border(-1, 1, 'red') }
|
412
412
|
assert_raise(ArgumentError) { @img.color_fill_to_border(1, 100, 'red') }
|
413
413
|
assert_nothing_raised do
|
414
|
-
res = @img.color_fill_to_border(@img.columns/2, @img.rows/2, 'red')
|
414
|
+
res = @img.color_fill_to_border(@img.columns / 2, @img.rows / 2, 'red')
|
415
415
|
assert_instance_of(Magick::Image, res)
|
416
416
|
end
|
417
417
|
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
418
|
-
assert_nothing_raised { @img.color_fill_to_border(@img.columns/2, @img.rows/2, pixel) }
|
418
|
+
assert_nothing_raised { @img.color_fill_to_border(@img.columns / 2, @img.rows / 2, pixel) }
|
419
419
|
end
|
420
420
|
|
421
421
|
def test_color_floodfill
|
422
422
|
assert_raise(ArgumentError) { @img.color_floodfill(-1, 1, 'red') }
|
423
423
|
assert_raise(ArgumentError) { @img.color_floodfill(1, 100, 'red') }
|
424
424
|
assert_nothing_raised do
|
425
|
-
res = @img.color_floodfill(@img.columns/2, @img.rows/2, 'red')
|
425
|
+
res = @img.color_floodfill(@img.columns / 2, @img.rows / 2, 'red')
|
426
426
|
assert_instance_of(Magick::Image, res)
|
427
427
|
end
|
428
428
|
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
429
|
-
assert_nothing_raised { @img.color_floodfill(@img.columns/2, @img.rows/2, pixel) }
|
429
|
+
assert_nothing_raised { @img.color_floodfill(@img.columns / 2, @img.rows / 2, pixel) }
|
430
430
|
end
|
431
431
|
|
432
432
|
def test_color_histogram
|
@@ -460,16 +460,16 @@ class Image1_UT < Test::Unit::TestCase
|
|
460
460
|
# IndexError b/c @img is DirectClass
|
461
461
|
assert_raise(IndexError) { @img.colormap(0) }
|
462
462
|
# Read PseudoClass image
|
463
|
-
pc_img = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
|
463
|
+
pc_img = Magick::Image.read(IMAGES_DIR + '/Button_0.gif').first
|
464
464
|
assert_nothing_raised { pc_img.colormap(0) }
|
465
465
|
ncolors = pc_img.colors
|
466
|
-
assert_raise(IndexError) { pc_img.colormap(ncolors+1) }
|
466
|
+
assert_raise(IndexError) { pc_img.colormap(ncolors + 1) }
|
467
467
|
assert_raise(IndexError) { pc_img.colormap(-1) }
|
468
|
-
assert_nothing_raised { pc_img.colormap(ncolors-1) }
|
468
|
+
assert_nothing_raised { pc_img.colormap(ncolors - 1) }
|
469
469
|
res = pc_img.colormap(0)
|
470
470
|
assert_instance_of(String, res)
|
471
471
|
|
472
|
-
#test 'set' operation
|
472
|
+
# test 'set' operation
|
473
473
|
assert_nothing_raised do
|
474
474
|
old_color = pc_img.colormap(0)
|
475
475
|
res = pc_img.colormap(0, 'red')
|
@@ -502,16 +502,16 @@ class Image1_UT < Test::Unit::TestCase
|
|
502
502
|
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
503
503
|
assert_nothing_raised { @img.color_reset!(pixel) }
|
504
504
|
assert_raise(TypeError) { @img.color_reset!([2]) }
|
505
|
-
assert_raise(ArgumentError)
|
505
|
+
assert_raise(ArgumentError) { @img.color_reset!('x') }
|
506
506
|
@img.freeze
|
507
507
|
assert_raise(FreezeError) { @img.color_reset!('red') }
|
508
508
|
end
|
509
509
|
|
510
510
|
def test_combine
|
511
|
-
r = Magick::Image.new(20,20) { self.background_color = 'red' }
|
512
|
-
g = Magick::Image.new(20,20) { self.background_color = 'green' }
|
513
|
-
b = Magick::Image.new(20,20) { self.background_color = 'blue' }
|
514
|
-
a = Magick::Image.new(20,20) { self.background_color = 'transparent' }
|
511
|
+
r = Magick::Image.new(20, 20) { self.background_color = 'red' }
|
512
|
+
g = Magick::Image.new(20, 20) { self.background_color = 'green' }
|
513
|
+
b = Magick::Image.new(20, 20) { self.background_color = 'blue' }
|
514
|
+
a = Magick::Image.new(20, 20) { self.background_color = 'transparent' }
|
515
515
|
assert_nothing_raised { Magick::Image.combine(r) }
|
516
516
|
assert_nothing_raised { Magick::Image.combine(r, g) }
|
517
517
|
assert_nothing_raised { Magick::Image.combine(r, g, b) }
|
@@ -529,8 +529,8 @@ class Image1_UT < Test::Unit::TestCase
|
|
529
529
|
end
|
530
530
|
|
531
531
|
def test_compare_channel
|
532
|
-
img1 = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
|
533
|
-
img2 = Magick::Image.read(IMAGES_DIR+'/Button_1.gif').first
|
532
|
+
img1 = Magick::Image.read(IMAGES_DIR + '/Button_0.gif').first
|
533
|
+
img2 = Magick::Image.read(IMAGES_DIR + '/Button_1.gif').first
|
534
534
|
assert_nothing_raised { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric) }
|
535
535
|
assert_nothing_raised { img1.compare_channel(img2, Magick::MeanSquaredErrorMetric) }
|
536
536
|
assert_nothing_raised { img1.compare_channel(img2, Magick::PeakAbsoluteErrorMetric) }
|
@@ -558,8 +558,8 @@ class Image1_UT < Test::Unit::TestCase
|
|
558
558
|
end
|
559
559
|
end
|
560
560
|
|
561
|
-
if
|
562
|
-
IMAGES_DIR = '../doc/ex/images'
|
563
|
-
FILES = Dir[IMAGES_DIR+'/Button_*.gif']
|
564
|
-
Test::Unit::UI::Console::TestRunner.run(
|
561
|
+
if $PROGRAM_NAME == __FILE__
|
562
|
+
IMAGES_DIR = '../doc/ex/images'
|
563
|
+
FILES = Dir[IMAGES_DIR + '/Button_*.gif']
|
564
|
+
Test::Unit::UI::Console::TestRunner.run(Image1UT) unless RUBY_VERSION[/^1\.9|^2/]
|
565
565
|
end
|