rmagick 2.13.4 → 2.16.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 +4 -4
- data/.editorconfig +14 -0
- data/.hound.yml +2 -0
- data/.rspec +1 -0
- data/.rubocop.yml +340 -0
- data/.simplecov +27 -0
- data/.travis.yml +29 -12
- data/CHANGELOG.md +915 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/CONTRIBUTING.md +31 -3
- data/Gemfile +3 -0
- data/README.textile +94 -4
- data/Rakefile +57 -45
- data/before_install_linux.sh +26 -6
- data/deprecated/RMagick.rb +6 -0
- data/doc/comtasks.html +1 -1
- data/doc/draw.html +7 -4
- data/doc/ex/InitialCoords.rb +16 -17
- data/doc/ex/NewCoordSys.rb +21 -23
- data/doc/ex/OrigCoordSys.rb +8 -10
- data/doc/ex/PreserveAspectRatio.rb +182 -183
- data/doc/ex/RotateScale.rb +27 -28
- data/doc/ex/Skew.rb +27 -27
- data/doc/ex/Use01.rb +7 -8
- data/doc/ex/Use02.rb +11 -12
- data/doc/ex/Use03.rb +7 -7
- data/doc/ex/ViewBox.rb +16 -18
- data/doc/ex/adaptive_threshold.rb +4 -5
- data/doc/ex/add_noise.rb +4 -5
- data/doc/ex/affine.rb +4 -4
- data/doc/ex/affine_transform.rb +4 -4
- data/doc/ex/arc.rb +10 -10
- data/doc/ex/arcpath.rb +7 -8
- data/doc/ex/arcs01.rb +10 -10
- data/doc/ex/arcs02.rb +36 -38
- data/doc/ex/average.rb +5 -5
- data/doc/ex/axes.rb +4 -4
- data/doc/ex/baseline_shift01.rb +11 -12
- data/doc/ex/bilevel_channel.rb +2 -3
- data/doc/ex/blur_image.rb +2 -2
- data/doc/ex/border.rb +2 -2
- data/doc/ex/bounding_box.rb +9 -11
- data/doc/ex/cbezier1.rb +3 -4
- data/doc/ex/cbezier2.rb +3 -4
- data/doc/ex/cbezier3.rb +3 -4
- data/doc/ex/cbezier4.rb +3 -4
- data/doc/ex/cbezier5.rb +2 -3
- data/doc/ex/cbezier6.rb +3 -3
- data/doc/ex/channel.rb +10 -11
- data/doc/ex/charcoal.rb +2 -2
- data/doc/ex/chop.rb +2 -2
- data/doc/ex/circle.rb +3 -3
- data/doc/ex/circle01.rb +6 -7
- data/doc/ex/clip_path.rb +12 -12
- data/doc/ex/coalesce.rb +32 -35
- data/doc/ex/color_fill_to_border.rb +6 -6
- data/doc/ex/color_floodfill.rb +2 -2
- data/doc/ex/color_histogram.rb +17 -18
- data/doc/ex/color_reset.rb +2 -2
- data/doc/ex/colorize.rb +2 -2
- data/doc/ex/colors.rb +30 -30
- data/doc/ex/compose_mask.rb +8 -9
- data/doc/ex/composite.rb +14 -16
- data/doc/ex/composite_layers.rb +15 -15
- data/doc/ex/composite_tiled.rb +5 -7
- data/doc/ex/contrast.rb +12 -12
- data/doc/ex/crop.rb +3 -3
- data/doc/ex/crop_with_gravity.rb +13 -17
- data/doc/ex/cubic01.rb +18 -20
- data/doc/ex/cubic02.rb +64 -67
- data/doc/ex/cycle_colormap.rb +2 -2
- data/doc/ex/dissolve.rb +2 -3
- data/doc/ex/drawcomp.rb +34 -34
- data/doc/ex/drop_shadow.rb +8 -8
- data/doc/ex/edge.rb +2 -2
- data/doc/ex/ellipse.rb +4 -4
- data/doc/ex/ellipse01.rb +10 -11
- data/doc/ex/emboss.rb +2 -2
- data/doc/ex/enhance.rb +2 -2
- data/doc/ex/equalize.rb +2 -2
- data/doc/ex/evenodd.rb +31 -32
- data/doc/ex/fill_pattern.rb +12 -15
- data/doc/ex/flatten_images.rb +13 -13
- data/doc/ex/flip.rb +2 -2
- data/doc/ex/flop.rb +2 -2
- data/doc/ex/font_styles.rb +21 -23
- data/doc/ex/fonts.rb +14 -14
- data/doc/ex/frame.rb +3 -3
- data/doc/ex/gaussian_blur.rb +2 -2
- data/doc/ex/get_multiline_type_metrics.rb +6 -7
- data/doc/ex/get_pixels.rb +13 -14
- data/doc/ex/get_type_metrics.rb +26 -31
- data/doc/ex/gradientfill.rb +12 -12
- data/doc/ex/grav.rb +4 -5
- data/doc/ex/gravity.rb +61 -60
- data/doc/ex/group.rb +16 -16
- data/doc/ex/hatchfill.rb +10 -10
- data/doc/ex/image.rb +29 -31
- data/doc/ex/implode.rb +17 -17
- data/doc/ex/level.rb +2 -2
- data/doc/ex/level_colors.rb +4 -4
- data/doc/ex/line.rb +4 -5
- data/doc/ex/line01.rb +11 -13
- data/doc/ex/mask.rb +7 -8
- data/doc/ex/matte_fill_to_border.rb +2 -3
- data/doc/ex/matte_floodfill.rb +2 -3
- data/doc/ex/matte_replace.rb +2 -3
- data/doc/ex/median_filter.rb +2 -2
- data/doc/ex/modulate.rb +2 -2
- data/doc/ex/mono.rb +4 -4
- data/doc/ex/morph.rb +7 -8
- data/doc/ex/mosaic.rb +15 -15
- data/doc/ex/motion_blur.rb +2 -2
- data/doc/ex/negate.rb +2 -2
- data/doc/ex/negate_channel.rb +2 -2
- data/doc/ex/nested_rvg.rb +11 -11
- data/doc/ex/nonzero.rb +31 -32
- data/doc/ex/normalize.rb +2 -2
- data/doc/ex/oil_paint.rb +2 -2
- data/doc/ex/opacity.rb +3 -3
- data/doc/ex/ordered_dither.rb +2 -2
- data/doc/ex/path.rb +4 -5
- data/doc/ex/pattern1.rb +10 -10
- data/doc/ex/pattern2.rb +7 -7
- data/doc/ex/polaroid.rb +13 -14
- data/doc/ex/polygon.rb +6 -7
- data/doc/ex/polygon01.rb +10 -12
- data/doc/ex/polyline.rb +4 -5
- data/doc/ex/polyline01.rb +11 -13
- data/doc/ex/posterize.rb +2 -2
- data/doc/ex/preview.rb +3 -4
- data/doc/ex/qbezierpath.rb +5 -5
- data/doc/ex/quad01.rb +23 -25
- data/doc/ex/quantize-m.rb +5 -5
- data/doc/ex/radial_blur.rb +2 -2
- data/doc/ex/raise.rb +2 -2
- data/doc/ex/random_threshold_channel.rb +2 -2
- data/doc/ex/rect01.rb +6 -7
- data/doc/ex/rect02.rb +9 -11
- data/doc/ex/rectangle.rb +3 -4
- data/doc/ex/reduce_noise.rb +2 -2
- data/doc/ex/remap.rb +7 -8
- data/doc/ex/remap_images.rb +9 -11
- data/doc/ex/resize_to_fill.rb +3 -5
- data/doc/ex/resize_to_fit.rb +3 -5
- data/doc/ex/roll.rb +2 -2
- data/doc/ex/rotate.rb +6 -7
- data/doc/ex/rotate_f.rb +2 -2
- data/doc/ex/roundrect.rb +4 -5
- data/doc/ex/rubyname.rb +11 -11
- data/doc/ex/rvg_clippath.rb +5 -7
- data/doc/ex/rvg_linecap.rb +25 -26
- data/doc/ex/rvg_linejoin.rb +25 -26
- data/doc/ex/rvg_opacity.rb +10 -11
- data/doc/ex/rvg_pattern.rb +15 -15
- data/doc/ex/rvg_stroke_dasharray.rb +6 -7
- data/doc/ex/segment.rb +2 -2
- data/doc/ex/sepiatone.rb +2 -3
- data/doc/ex/shade.rb +2 -2
- data/doc/ex/shadow.rb +2 -3
- data/doc/ex/shave.rb +2 -2
- data/doc/ex/shear.rb +3 -3
- data/doc/ex/sketch.rb +2 -3
- data/doc/ex/skewx.rb +4 -5
- data/doc/ex/skewy.rb +3 -3
- data/doc/ex/smile.rb +113 -113
- data/doc/ex/solarize.rb +2 -2
- data/doc/ex/sparse_color.rb +29 -30
- data/doc/ex/splice.rb +2 -3
- data/doc/ex/spread.rb +2 -2
- data/doc/ex/stegano.rb +34 -34
- data/doc/ex/stroke_dasharray.rb +4 -5
- data/doc/ex/stroke_fill.rb +4 -5
- data/doc/ex/stroke_linecap.rb +3 -3
- data/doc/ex/stroke_linejoin.rb +3 -3
- data/doc/ex/stroke_width.rb +3 -3
- data/doc/ex/swirl.rb +2 -2
- data/doc/ex/text.rb +4 -4
- data/doc/ex/text01.rb +7 -8
- data/doc/ex/text_align.rb +2 -2
- data/doc/ex/text_antialias.rb +9 -10
- data/doc/ex/text_styles.rb +11 -13
- data/doc/ex/text_undercolor.rb +2 -2
- data/doc/ex/texture_fill_to_border.rb +6 -6
- data/doc/ex/texture_floodfill.rb +2 -2
- data/doc/ex/texturefill.rb +10 -11
- data/doc/ex/threshold.rb +2 -2
- data/doc/ex/to_blob.rb +4 -5
- data/doc/ex/translate.rb +6 -6
- data/doc/ex/transparent.rb +5 -5
- data/doc/ex/transpose.rb +2 -2
- data/doc/ex/transverse.rb +2 -2
- data/doc/ex/tref01.rb +11 -12
- data/doc/ex/triangle01.rb +5 -6
- data/doc/ex/trim.rb +1 -2
- data/doc/ex/tspan01.rb +8 -9
- data/doc/ex/tspan02.rb +9 -11
- data/doc/ex/tspan03.rb +9 -11
- data/doc/ex/unsharp_mask.rb +2 -2
- data/doc/ex/viewex.rb +19 -21
- data/doc/ex/vignette.rb +2 -2
- data/doc/ex/watermark.rb +15 -16
- data/doc/ex/wave.rb +2 -2
- data/doc/ex/wet_floor.rb +17 -18
- data/doc/ex/writing_mode01.rb +8 -9
- data/doc/ex/writing_mode02.rb +8 -8
- data/doc/ilist.html +1 -1
- data/doc/usage.html +8 -8
- data/examples/constitute.rb +6 -6
- data/examples/crop_with_gravity.rb +13 -17
- data/examples/demo.rb +305 -305
- data/examples/describe.rb +27 -28
- data/examples/find_similar_region.rb +16 -16
- data/examples/histogram.rb +228 -232
- data/examples/identify.rb +165 -167
- data/examples/image_opacity.rb +4 -4
- data/examples/import_export.rb +10 -10
- data/examples/pattern_fill.rb +9 -9
- data/examples/rotating_text.rb +13 -14
- data/examples/spinner.rb +18 -19
- data/examples/thumbnail.rb +13 -14
- data/examples/vignette.rb +8 -9
- data/ext/RMagick/extconf.rb +489 -367
- data/ext/RMagick/rmagick.c +11 -4
- data/ext/RMagick/rmagick.h +4 -0
- data/ext/RMagick/rmdraw.c +49 -18
- data/ext/RMagick/rmenum.c +18 -7
- data/ext/RMagick/rmfill.c +4 -1
- data/ext/RMagick/rmilist.c +49 -13
- data/ext/RMagick/rmimage.c +196 -59
- data/ext/RMagick/rminfo.c +33 -10
- data/ext/RMagick/rmmain.c +18 -6
- data/ext/RMagick/rmmontage.c +12 -4
- data/ext/RMagick/rmpixel.c +18 -5
- data/ext/RMagick/rmstruct.c +108 -31
- data/ext/RMagick/rmutil.c +50 -26
- data/lib/rmagick/version.rb +4 -3
- data/lib/rmagick_internal.rb +1159 -1176
- data/lib/rvg/clippath.rb +36 -39
- data/lib/rvg/container.rb +115 -124
- data/lib/rvg/deep_equal.rb +46 -50
- data/lib/rvg/describable.rb +41 -47
- data/lib/rvg/embellishable.rb +384 -410
- data/lib/rvg/misc.rb +697 -714
- data/lib/rvg/paint.rb +42 -47
- data/lib/rvg/pathdata.rb +120 -125
- data/lib/rvg/rvg.rb +213 -213
- data/lib/rvg/stretchable.rb +159 -162
- data/lib/rvg/stylable.rb +109 -117
- data/lib/rvg/text.rb +9 -24
- data/lib/rvg/transformable.rb +120 -127
- data/lib/rvg/units.rb +58 -61
- data/rmagick.gemspec +46 -15
- data/spec/rmagick/ImageList1_spec.rb +24 -0
- data/spec/rmagick/draw_spec.rb +156 -0
- data/spec/rmagick/image/blue_shift_spec.rb +16 -0
- data/spec/rmagick/image/composite_spec.rb +140 -0
- data/spec/rmagick/image/constitute_spec.rb +15 -0
- data/spec/rmagick/image/dispatch_spec.rb +18 -0
- data/spec/rmagick/image/from_blob_spec.rb +14 -0
- data/spec/rmagick/image/ping_spec.rb +14 -0
- data/spec/rmagick/image/properties_spec.rb +29 -0
- data/spec/spec_helper.rb +4 -0
- data/test/Image1.rb +529 -727
- data/test/Image2.rb +1291 -1299
- data/test/Image3.rb +978 -981
- data/test/ImageList1.rb +7 -9
- data/test/ImageList2.rb +346 -350
- data/test/Image_attributes.rb +683 -686
- data/test/Import_Export.rb +25 -30
- data/test/Info.rb +339 -343
- data/test/Magick.rb +250 -253
- data/test/Pixel.rb +107 -110
- data/test/Preview.rb +48 -53
- data/test/test_all_basic.rb +15 -11
- data/test/tmpnam_test.rb +3 -3
- data/wercker.yml +10 -0
- metadata +77 -10
- data/ChangeLog +0 -816
- data/lib/RMagick.rb +0 -1
- data/test/Draw.rb +0 -121
@@ -0,0 +1,156 @@
|
|
1
|
+
class Magick::Draw
|
2
|
+
def self._dummy_img_
|
3
|
+
@@_dummy_img_
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
RSpec.describe Magick::Draw do
|
8
|
+
let(:draw) { Magick::Draw.new }
|
9
|
+
|
10
|
+
describe '._dummy_img_' do
|
11
|
+
it 'works' do
|
12
|
+
# initially this variable is not defined.
|
13
|
+
expect { Magick::Draw._dummy_img_ }.to raise_error(NameError)
|
14
|
+
|
15
|
+
# cause it to become defined. save the object id.
|
16
|
+
draw.get_type_metrics('ABCDEF')
|
17
|
+
dummy = nil
|
18
|
+
expect { dummy = Magick::Draw._dummy_img_ }.not_to raise_error
|
19
|
+
|
20
|
+
expect(dummy).to be_instance_of(Magick::Image)
|
21
|
+
|
22
|
+
# ensure that it is always the same object
|
23
|
+
draw.get_type_metrics('ABCDEF')
|
24
|
+
dummy2 = nil
|
25
|
+
expect { dummy2 = Magick::Draw._dummy_img_ }.not_to raise_error
|
26
|
+
expect(dummy).to eq dummy2
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#kerning=' do
|
31
|
+
it 'assigns without raising an error' do
|
32
|
+
expect { draw.kerning = 1 }.not_to raise_error
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#kerning' do
|
37
|
+
it 'accepts a valid parameter without raising an error' do
|
38
|
+
expect { draw.kerning(1) }.not_to raise_error
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'raises an error when given an invalid parameter' do
|
42
|
+
expect { draw.kerning('a') }.to raise_error(ArgumentError)
|
43
|
+
expect { draw.kerning([]) }.to raise_error(TypeError)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#interline_spacing=' do
|
48
|
+
it 'assigns without raising an error' do
|
49
|
+
expect { draw.interline_spacing = 1 }.not_to raise_error
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#interline_spacing' do
|
54
|
+
it 'accepts a valid parameter without raising an error' do
|
55
|
+
expect { draw.interline_spacing(1) }.not_to raise_error
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'raises an error when given an invalid parameter' do
|
59
|
+
expect { draw.interline_spacing('a') }.to raise_error(ArgumentError)
|
60
|
+
expect { draw.interline_spacing([]) }.to raise_error(TypeError)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#interword_spacing=' do
|
65
|
+
it 'assigns without raising an error' do
|
66
|
+
expect { draw.interword_spacing = 1 }.not_to raise_error
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#interword_spacing' do
|
71
|
+
it 'accepts a valid parameter without raising an error' do
|
72
|
+
expect { draw.interword_spacing(1) }.not_to raise_error
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'raises an error when given an invalid parameter' do
|
76
|
+
expect { draw.interword_spacing('a') }.to raise_error(ArgumentError)
|
77
|
+
expect { draw.interword_spacing([]) }.to raise_error(TypeError)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#marshal_dump', '#marshal_load' do
|
82
|
+
it 'marshals without an error' do
|
83
|
+
skip 'this spec fails on some versions of ImageMagick'
|
84
|
+
rose = Magick::Image.read('rose:').first
|
85
|
+
granite = Magick::Image.read('granite:').first
|
86
|
+
s = granite.to_blob { self.format = 'miff' }
|
87
|
+
granite = Magick::Image.from_blob(s).first
|
88
|
+
blue_stroke = Magick::Image.new(20,20) { self.background_color = 'blue' }
|
89
|
+
s = blue_stroke.to_blob { self.format = 'miff' }
|
90
|
+
blue_stroke = Magick::Image.from_blob(s).first
|
91
|
+
|
92
|
+
draw.affine = Magick::AffineMatrix.new(1, 2, 3, 4, 5, 6)
|
93
|
+
draw.decorate = Magick::LineThroughDecoration
|
94
|
+
draw.encoding = 'AdobeCustom'
|
95
|
+
draw.gravity = Magick::CenterGravity
|
96
|
+
draw.fill = Magick::Pixel.from_color('red')
|
97
|
+
draw.stroke = Magick::Pixel.from_color('blue')
|
98
|
+
draw.stroke_width = 5
|
99
|
+
draw.fill_pattern = granite
|
100
|
+
draw.stroke_pattern = blue_stroke
|
101
|
+
draw.text_antialias = true
|
102
|
+
draw.font = 'Arial-Bold'
|
103
|
+
draw.font_family = 'arial'
|
104
|
+
draw.font_style = Magick::ItalicStyle
|
105
|
+
draw.font_stretch = Magick::CondensedStretch
|
106
|
+
draw.font_weight = Magick::BoldWeight
|
107
|
+
draw.pointsize = 12
|
108
|
+
draw.density = '72x72'
|
109
|
+
draw.align = Magick::CenterAlign
|
110
|
+
draw.undercolor = Magick::Pixel.from_color('green')
|
111
|
+
draw.kerning = 10.5
|
112
|
+
draw.interword_spacing = 3.75
|
113
|
+
|
114
|
+
draw.circle(20, 25, 20, 28)
|
115
|
+
dumped = nil
|
116
|
+
expect { dumped = Marshal.dump(draw) }.not_to raise_error
|
117
|
+
expect { Marshal.load(dumped) }.not_to raise_error
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe '#fill_pattern' do
|
122
|
+
it 'accepts an Image argument' do
|
123
|
+
img = Magick::Image.new(20,20)
|
124
|
+
expect { draw.fill_pattern = img }.not_to raise_error
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'accepts an ImageList argument' do
|
128
|
+
img = Magick::Image.new(20,20)
|
129
|
+
ilist = Magick::ImageList.new
|
130
|
+
ilist << img
|
131
|
+
expect { draw.fill_pattern = ilist }.not_to raise_error
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'does not accept arbitrary arguments' do
|
135
|
+
expect { draw.fill_pattern = 1 }.to raise_error(NoMethodError)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe '#stroke_pattern' do
|
140
|
+
it 'accepts an Image argument' do
|
141
|
+
img = Magick::Image.new(20,20)
|
142
|
+
expect { draw.stroke_pattern = img }.not_to raise_error
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'accepts an ImageList argument' do
|
146
|
+
img = Magick::Image.new(20,20)
|
147
|
+
ilist = Magick::ImageList.new
|
148
|
+
ilist << img
|
149
|
+
expect { draw.stroke_pattern = ilist }.not_to raise_error
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'does not accept arbitrary arguments' do
|
153
|
+
expect { draw.stroke_pattern = 1 }.to raise_error(NoMethodError)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
RSpec.describe Magick::Image, '#blue_shift' do
|
2
|
+
|
3
|
+
let(:img) { Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first }
|
4
|
+
|
5
|
+
it 'returns a new Image' do
|
6
|
+
res = img.blue_shift
|
7
|
+
expect(res).to be_instance_of(Magick::Image)
|
8
|
+
expect(res).not_to eq img
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'accepts one argument' do
|
12
|
+
expect { img.blue_shift(2) }.not_to raise_error
|
13
|
+
expect { img.blue_shift(2, 3) }.to raise_error(ArgumentError)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
RSpec.describe Magick::Image, '#composite' do
|
2
|
+
|
3
|
+
let(:img1) { Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first }
|
4
|
+
let(:img2) { Magick::Image.read(IMAGES_DIR+'/Button_1.gif').first }
|
5
|
+
let(:composite_ops) do
|
6
|
+
[
|
7
|
+
Magick::UndefinedCompositeOp,
|
8
|
+
Magick::NoCompositeOp,
|
9
|
+
Magick::AddCompositeOp,
|
10
|
+
Magick::AtopCompositeOp,
|
11
|
+
Magick::BumpmapCompositeOp,
|
12
|
+
Magick::ClearCompositeOp,
|
13
|
+
Magick::ColorizeCompositeOp,
|
14
|
+
Magick::CopyBlueCompositeOp,
|
15
|
+
Magick::CopyCompositeOp,
|
16
|
+
Magick::CopyGreenCompositeOp,
|
17
|
+
Magick::CopyOpacityCompositeOp,
|
18
|
+
Magick::CopyRedCompositeOp,
|
19
|
+
Magick::CopyCyanCompositeOp,
|
20
|
+
Magick::CopyMagentaCompositeOp,
|
21
|
+
Magick::CopyYellowCompositeOp,
|
22
|
+
Magick::CopyBlackCompositeOp,
|
23
|
+
Magick::DarkenCompositeOp,
|
24
|
+
Magick::DifferenceCompositeOp,
|
25
|
+
Magick::DisplaceCompositeOp,
|
26
|
+
Magick::DissolveCompositeOp,
|
27
|
+
Magick::DstAtopCompositeOp,
|
28
|
+
Magick::DstCompositeOp,
|
29
|
+
Magick::DstInCompositeOp,
|
30
|
+
Magick::DstOutCompositeOp,
|
31
|
+
Magick::DstOverCompositeOp,
|
32
|
+
Magick::HueCompositeOp,
|
33
|
+
Magick::InCompositeOp,
|
34
|
+
Magick::LightenCompositeOp,
|
35
|
+
Magick::LuminizeCompositeOp,
|
36
|
+
Magick::MinusCompositeOp,
|
37
|
+
Magick::ModulateCompositeOp,
|
38
|
+
Magick::MultiplyCompositeOp,
|
39
|
+
Magick::OutCompositeOp,
|
40
|
+
Magick::OverCompositeOp,
|
41
|
+
Magick::OverlayCompositeOp,
|
42
|
+
Magick::PlusCompositeOp,
|
43
|
+
Magick::ReplaceCompositeOp,
|
44
|
+
Magick::SaturateCompositeOp,
|
45
|
+
Magick::ScreenCompositeOp,
|
46
|
+
Magick::SrcAtopCompositeOp,
|
47
|
+
Magick::SrcCompositeOp,
|
48
|
+
Magick::SrcInCompositeOp,
|
49
|
+
Magick::SrcOutCompositeOp,
|
50
|
+
Magick::SrcOverCompositeOp,
|
51
|
+
Magick::SubtractCompositeOp,
|
52
|
+
Magick::ThresholdCompositeOp,
|
53
|
+
Magick::XorCompositeOp,
|
54
|
+
Magick::BlendCompositeOp,
|
55
|
+
Magick::ColorBurnCompositeOp,
|
56
|
+
Magick::ColorDodgeCompositeOp,
|
57
|
+
Magick::ExclusionCompositeOp,
|
58
|
+
Magick::HardLightCompositeOp,
|
59
|
+
Magick::SoftLightCompositeOp
|
60
|
+
]
|
61
|
+
end
|
62
|
+
let(:gravity) do
|
63
|
+
[
|
64
|
+
Magick::NorthEastGravity,
|
65
|
+
Magick::EastGravity,
|
66
|
+
Magick::SouthWestGravity,
|
67
|
+
Magick::SouthGravity,
|
68
|
+
Magick::SouthEastGravity
|
69
|
+
]
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'raises an error given invalid arguments' do
|
73
|
+
expect { img1.composite }.to raise_error(ArgumentError)
|
74
|
+
expect { img1.composite(img2) }.to raise_error(ArgumentError)
|
75
|
+
expect do
|
76
|
+
img1.composite(img2, Magick::NorthWestGravity)
|
77
|
+
end.to raise_error(ArgumentError)
|
78
|
+
expect { img1.composite(2) }.to raise_error(ArgumentError)
|
79
|
+
expect { img1.composite(img2, 2) }.to raise_error(ArgumentError)
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'when given 3 arguments' do
|
83
|
+
it 'works when 2nd argument is a gravity' do
|
84
|
+
composite_ops.each do |op|
|
85
|
+
gravity.each do |grav|
|
86
|
+
expect { img1.composite(img2, grav, op) }.not_to raise_error
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'raises an error when 2nd argument is not a gravity' do
|
92
|
+
expect do
|
93
|
+
img1.composite(img2, 2, Magick::OverCompositeOp)
|
94
|
+
end.to raise_error(TypeError)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'when given 4 arguments' do
|
99
|
+
it 'works when 4th argument is a composite operator' do
|
100
|
+
# there are way too many CompositeOperators to test them all, so just try
|
101
|
+
# few representative ops
|
102
|
+
composite_ops.each do |op|
|
103
|
+
expect { img1.composite(img2, 0, 0, op) }.not_to raise_error
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'returns a new Magick::Image object' do
|
108
|
+
res = img1.composite(img2, 0, 0, Magick::OverCompositeOp)
|
109
|
+
expect(res).to be_instance_of(Magick::Image)
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'raises an error when 4th argument is not a composite operator' do
|
113
|
+
expect { img1.composite(img2, 0, 0, 2) }.to raise_error(TypeError)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'when given 5 arguments' do
|
118
|
+
it 'works when 2nd argument is gravity and 5th is a composite operator' do
|
119
|
+
composite_ops.each do |op|
|
120
|
+
gravity.each do |grav|
|
121
|
+
expect { img1.composite(img2, grav, 0, 0, op) }.not_to raise_error
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'raises an error when 2nd argument is not a gravity' do
|
127
|
+
expect do
|
128
|
+
img1.composite(img2, 0, 0, 2, Magick::OverCompositeOp)
|
129
|
+
end.to raise_error(TypeError)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'raises an error when the image has been destroyed' do
|
134
|
+
img2.destroy!
|
135
|
+
expect do
|
136
|
+
img1.composite(img2, Magick::CenterGravity, Magick::OverCompositeOp)
|
137
|
+
end.to raise_error(Magick::DestroyedImageError)
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
RSpec.describe Magick::Image, '#constitute' do
|
2
|
+
|
3
|
+
let(:img) { Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first }
|
4
|
+
let(:pixels) { img.dispatch(0, 0, img.columns, img.rows, 'RGBA') }
|
5
|
+
|
6
|
+
it 'returns an equivalent image to the given pixels' do
|
7
|
+
res = Magick::Image.constitute(img.columns, img.rows, 'RGBA', pixels)
|
8
|
+
# The constituted image is in MIFF format so we
|
9
|
+
# can't compare it directly to the original image.
|
10
|
+
expect(res.columns).to eq img.columns
|
11
|
+
expect(res.rows).to eq img.rows
|
12
|
+
expect(pixels.all? { |v| 0 <= v && v <= Magick::QuantumRange }).to be true
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
RSpec.describe Magick::Image, '#dispatch' do
|
2
|
+
|
3
|
+
let(:img) { Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first }
|
4
|
+
|
5
|
+
it 'expects exactly 5 or 6 arguments' do
|
6
|
+
expect { img.dispatch }.to raise_error(ArgumentError)
|
7
|
+
expect { img.dispatch(0) }.to raise_error(ArgumentError)
|
8
|
+
expect { img.dispatch(0, 0) }.to raise_error(ArgumentError)
|
9
|
+
expect { img.dispatch(0, 0, img.columns) }.to raise_error(ArgumentError)
|
10
|
+
expect do
|
11
|
+
img.dispatch(0, 0, img.columns, img.rows)
|
12
|
+
end.to raise_error(ArgumentError)
|
13
|
+
expect do
|
14
|
+
img.dispatch(0, 0, 20, 20, 'RGBA', false, false)
|
15
|
+
end.to raise_error(ArgumentError)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
RSpec.describe Magick::Image, '#from_blob' do
|
2
|
+
|
3
|
+
let(:img) { Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first }
|
4
|
+
let(:blob) { img.to_blob }
|
5
|
+
|
6
|
+
it 'returns an image equal to the original' do
|
7
|
+
expect(blob).to be_instance_of(String)
|
8
|
+
res = Magick::Image.from_blob(blob)
|
9
|
+
expect(res).to be_instance_of(Array)
|
10
|
+
expect(res.first).to be_instance_of(Magick::Image)
|
11
|
+
expect(res.first).to eq img
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
RSpec.describe Magick::Image, '#ping' do
|
2
|
+
|
3
|
+
it 'returns an image from the source, omitting pixel data' do
|
4
|
+
res = Magick::Image.ping(IMAGES_DIR+'/Button_0.gif')
|
5
|
+
expect(res).to be_instance_of(Array)
|
6
|
+
image = res.first
|
7
|
+
expect(image).to be_instance_of(Magick::Image)
|
8
|
+
expect(image.format).to eq 'GIF'
|
9
|
+
expect(image.columns).to eq 127
|
10
|
+
expect(image.rows).to eq 120
|
11
|
+
expect(image.filename).to match(/Button_0.gif/)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
RSpec.describe Magick::Image, '#properties' do
|
2
|
+
|
3
|
+
let(:img) { Magick::Image.new(20, 20) }
|
4
|
+
let(:freeze_error) { RUBY_VERSION[/^1\.9|^2/] ? RuntimeError : TypeError }
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
img['a'] = 'str_1'
|
8
|
+
img['b'] = 'str_2'
|
9
|
+
img['c'] = 'str_3'
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'allows assignment of arbitrary properties' do
|
13
|
+
expect(img['a']).to eq 'str_1'
|
14
|
+
expect(img['b']).to eq 'str_2'
|
15
|
+
expect(img['c']).to eq 'str_3'
|
16
|
+
expect(img['d']).to be nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'returns a hash of assigned properties' do
|
20
|
+
expected_properties = { 'a' => 'str_1', 'b' => 'str_2', 'c' => 'str_3' }
|
21
|
+
expect(img.properties).to eq(expected_properties)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'raises an error when trying to assign properties to a frozen image' do
|
25
|
+
img.freeze
|
26
|
+
expect { img['d'] = 'str_4' }.to raise_error(freeze_error)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/spec/spec_helper.rb
ADDED