rmagick-windows 2.16.1
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 +7 -0
- data/.editorconfig +14 -0
- data/.gitignore +23 -0
- data/.hound.yml +2 -0
- data/.rspec +1 -0
- data/.rubocop.yml +340 -0
- data/.simplecov +27 -0
- data/.travis.yml +60 -0
- data/CHANGELOG.md +915 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/CONTRIBUTING.md +50 -0
- data/Doxyfile +1514 -0
- data/Gemfile +10 -0
- data/LICENSE +20 -0
- data/README.textile +257 -0
- data/Rakefile +188 -0
- data/before_install_linux.sh +32 -0
- data/before_install_osx.sh +2 -0
- data/deprecated/RMagick.rb +6 -0
- data/doc/.cvsignore +1 -0
- data/doc/comtasks.html +287 -0
- data/doc/constants.html +1581 -0
- data/doc/css/doc.css +299 -0
- data/doc/css/popup.css +34 -0
- data/doc/css/ref.css +67 -0
- data/doc/draw.html +3272 -0
- data/doc/ex/InitialCoords.rb +22 -0
- data/doc/ex/NewCoordSys.rb +30 -0
- data/doc/ex/OrigCoordSys.rb +16 -0
- data/doc/ex/PreserveAspectRatio.rb +204 -0
- data/doc/ex/RotateScale.rb +36 -0
- data/doc/ex/Skew.rb +38 -0
- data/doc/ex/Use01.rb +15 -0
- data/doc/ex/Use02.rb +20 -0
- data/doc/ex/Use03.rb +16 -0
- data/doc/ex/ViewBox.rb +31 -0
- data/doc/ex/adaptive_threshold.rb +9 -0
- data/doc/ex/add_noise.rb +16 -0
- data/doc/ex/affine.rb +48 -0
- data/doc/ex/affine_transform.rb +20 -0
- data/doc/ex/arc.rb +49 -0
- data/doc/ex/arcpath.rb +32 -0
- data/doc/ex/arcs01.rb +28 -0
- data/doc/ex/arcs02.rb +59 -0
- data/doc/ex/average.rb +15 -0
- data/doc/ex/axes.rb +64 -0
- data/doc/ex/baseline_shift01.rb +17 -0
- data/doc/ex/bilevel_channel.rb +8 -0
- data/doc/ex/blur_image.rb +12 -0
- data/doc/ex/border.rb +10 -0
- data/doc/ex/bounding_box.rb +42 -0
- data/doc/ex/cbezier1.rb +41 -0
- data/doc/ex/cbezier2.rb +41 -0
- data/doc/ex/cbezier3.rb +41 -0
- data/doc/ex/cbezier4.rb +42 -0
- data/doc/ex/cbezier5.rb +42 -0
- data/doc/ex/cbezier6.rb +53 -0
- data/doc/ex/channel.rb +25 -0
- data/doc/ex/charcoal.rb +12 -0
- data/doc/ex/chop.rb +29 -0
- data/doc/ex/circle.rb +33 -0
- data/doc/ex/circle01.rb +16 -0
- data/doc/ex/clip_path.rb +60 -0
- data/doc/ex/coalesce.rb +57 -0
- data/doc/ex/color_fill_to_border.rb +29 -0
- data/doc/ex/color_floodfill.rb +28 -0
- data/doc/ex/color_histogram.rb +47 -0
- data/doc/ex/color_reset.rb +11 -0
- data/doc/ex/colorize.rb +16 -0
- data/doc/ex/colors.rb +64 -0
- data/doc/ex/compose_mask.rb +22 -0
- data/doc/ex/composite.rb +133 -0
- data/doc/ex/composite_layers.rb +53 -0
- data/doc/ex/composite_tiled.rb +21 -0
- data/doc/ex/contrast.rb +36 -0
- data/doc/ex/crop.rb +31 -0
- data/doc/ex/crop_with_gravity.rb +42 -0
- data/doc/ex/cubic01.rb +43 -0
- data/doc/ex/cubic02.rb +91 -0
- data/doc/ex/cycle_colormap.rb +21 -0
- data/doc/ex/dissolve.rb +12 -0
- data/doc/ex/drawcomp.rb +42 -0
- data/doc/ex/drop_shadow.rb +60 -0
- data/doc/ex/edge.rb +11 -0
- data/doc/ex/ellipse.rb +45 -0
- data/doc/ex/ellipse01.rb +21 -0
- data/doc/ex/emboss.rb +11 -0
- data/doc/ex/enhance.rb +28 -0
- data/doc/ex/equalize.rb +11 -0
- data/doc/ex/evenodd.rb +42 -0
- data/doc/ex/fill_pattern.rb +23 -0
- data/doc/ex/flatten_images.rb +36 -0
- data/doc/ex/flip.rb +11 -0
- data/doc/ex/flop.rb +11 -0
- data/doc/ex/font_styles.rb +32 -0
- data/doc/ex/fonts.rb +20 -0
- data/doc/ex/frame.rb +12 -0
- data/doc/ex/gaussian_blur.rb +11 -0
- data/doc/ex/get_multiline_type_metrics.rb +41 -0
- data/doc/ex/get_pixels.rb +47 -0
- data/doc/ex/get_type_metrics.rb +141 -0
- data/doc/ex/gradientfill.rb +27 -0
- data/doc/ex/grav.rb +45 -0
- data/doc/ex/gravity.rb +80 -0
- data/doc/ex/group.rb +26 -0
- data/doc/ex/hatchfill.rb +27 -0
- data/doc/ex/image.rb +44 -0
- data/doc/ex/images/Apple.miff +0 -0
- data/doc/ex/images/Ballerina.jpg +0 -0
- data/doc/ex/images/Ballerina3.jpg +0 -0
- data/doc/ex/images/Button_0.gif +0 -0
- data/doc/ex/images/Button_1.gif +0 -0
- data/doc/ex/images/Button_2.gif +0 -0
- data/doc/ex/images/Button_3.gif +0 -0
- data/doc/ex/images/Button_4.gif +0 -0
- data/doc/ex/images/Button_5.gif +0 -0
- data/doc/ex/images/Button_6.gif +0 -0
- data/doc/ex/images/Button_7.gif +0 -0
- data/doc/ex/images/Button_8.gif +0 -0
- data/doc/ex/images/Button_9.gif +0 -0
- data/doc/ex/images/Button_A.gif +0 -0
- data/doc/ex/images/Button_B.gif +0 -0
- data/doc/ex/images/Button_C.gif +0 -0
- data/doc/ex/images/Button_D.gif +0 -0
- data/doc/ex/images/Button_E.gif +0 -0
- data/doc/ex/images/Button_F.gif +0 -0
- data/doc/ex/images/Button_G.gif +0 -0
- data/doc/ex/images/Button_H.gif +0 -0
- data/doc/ex/images/Button_I.gif +0 -0
- data/doc/ex/images/Button_J.gif +0 -0
- data/doc/ex/images/Button_K.gif +0 -0
- data/doc/ex/images/Button_L.gif +0 -0
- data/doc/ex/images/Button_M.gif +0 -0
- data/doc/ex/images/Button_N.gif +0 -0
- data/doc/ex/images/Button_O.gif +0 -0
- data/doc/ex/images/Button_P.gif +0 -0
- data/doc/ex/images/Button_Q.gif +0 -0
- data/doc/ex/images/Button_R.gif +0 -0
- data/doc/ex/images/Button_S.gif +0 -0
- data/doc/ex/images/Button_T.gif +0 -0
- data/doc/ex/images/Button_U.gif +0 -0
- data/doc/ex/images/Button_V.gif +0 -0
- data/doc/ex/images/Button_W.gif +0 -0
- data/doc/ex/images/Button_X.gif +0 -0
- data/doc/ex/images/Button_Y.gif +0 -0
- data/doc/ex/images/Button_Z.gif +0 -0
- data/doc/ex/images/Cheetah.jpg +0 -0
- data/doc/ex/images/Coffee.wmf +0 -0
- data/doc/ex/images/Flower_Hat.jpg +0 -0
- data/doc/ex/images/Gold_Statue.jpg +0 -0
- data/doc/ex/images/Hot_Air_Balloons.jpg +0 -0
- data/doc/ex/images/Hot_Air_Balloons_H.jpg +0 -0
- data/doc/ex/images/Leaf.miff +0 -0
- data/doc/ex/images/No.wmf +0 -0
- data/doc/ex/images/Polynesia.jpg +0 -0
- data/doc/ex/images/Red_Rocks.jpg +0 -0
- data/doc/ex/images/Rocks_On_Beach.miff +0 -0
- data/doc/ex/images/Shorts.jpg +0 -0
- data/doc/ex/images/Snake.wmf +0 -0
- data/doc/ex/images/Violin.jpg +0 -0
- data/doc/ex/images/Yellow_Rose.miff +0 -0
- data/doc/ex/images/big-duck.gif +0 -0
- data/doc/ex/images/duck.gif +0 -0
- data/doc/ex/images/duck0.gif +0 -0
- data/doc/ex/images/duck1.gif +0 -0
- data/doc/ex/images/duck10.gif +0 -0
- data/doc/ex/images/duck11.gif +0 -0
- data/doc/ex/images/duck12.gif +0 -0
- data/doc/ex/images/duck13.gif +0 -0
- data/doc/ex/images/duck14.gif +0 -0
- data/doc/ex/images/duck15.gif +0 -0
- data/doc/ex/images/duck2.gif +0 -0
- data/doc/ex/images/duck3.gif +0 -0
- data/doc/ex/images/duck4.gif +0 -0
- data/doc/ex/images/duck5.gif +0 -0
- data/doc/ex/images/duck6.gif +0 -0
- data/doc/ex/images/duck7.gif +0 -0
- data/doc/ex/images/duck8.gif +0 -0
- data/doc/ex/images/duck9.gif +0 -0
- data/doc/ex/images/graydient230x6.gif +0 -0
- data/doc/ex/images/image_with_profile.jpg +0 -0
- data/doc/ex/images/logo400x83.gif +0 -0
- data/doc/ex/images/model.miff +0 -0
- data/doc/ex/images/notimplemented.gif +0 -0
- data/doc/ex/images/smile.miff +0 -0
- data/doc/ex/images/spin.gif +0 -0
- data/doc/ex/implode.rb +34 -0
- data/doc/ex/level.rb +11 -0
- data/doc/ex/level_colors.rb +11 -0
- data/doc/ex/line.rb +41 -0
- data/doc/ex/line01.rb +21 -0
- data/doc/ex/mask.rb +35 -0
- data/doc/ex/matte_fill_to_border.rb +39 -0
- data/doc/ex/matte_floodfill.rb +32 -0
- data/doc/ex/matte_replace.rb +39 -0
- data/doc/ex/median_filter.rb +28 -0
- data/doc/ex/modulate.rb +11 -0
- data/doc/ex/mono.rb +23 -0
- data/doc/ex/morph.rb +25 -0
- data/doc/ex/mosaic.rb +35 -0
- data/doc/ex/motion_blur.rb +11 -0
- data/doc/ex/negate.rb +11 -0
- data/doc/ex/negate_channel.rb +9 -0
- data/doc/ex/nested_rvg.rb +21 -0
- data/doc/ex/nonzero.rb +42 -0
- data/doc/ex/normalize.rb +11 -0
- data/doc/ex/oil_paint.rb +11 -0
- data/doc/ex/opacity.rb +37 -0
- data/doc/ex/ordered_dither.rb +11 -0
- data/doc/ex/path.rb +63 -0
- data/doc/ex/pattern1.rb +25 -0
- data/doc/ex/pattern2.rb +26 -0
- data/doc/ex/polaroid.rb +27 -0
- data/doc/ex/polygon.rb +23 -0
- data/doc/ex/polygon01.rb +21 -0
- data/doc/ex/polyline.rb +22 -0
- data/doc/ex/polyline01.rb +21 -0
- data/doc/ex/posterize.rb +8 -0
- data/doc/ex/preview.rb +8 -0
- data/doc/ex/qbezierpath.rb +52 -0
- data/doc/ex/quad01.rb +34 -0
- data/doc/ex/quantize-m.rb +25 -0
- data/doc/ex/radial_blur.rb +9 -0
- data/doc/ex/raise.rb +8 -0
- data/doc/ex/random_threshold_channel.rb +13 -0
- data/doc/ex/rect01.rb +14 -0
- data/doc/ex/rect02.rb +20 -0
- data/doc/ex/rectangle.rb +34 -0
- data/doc/ex/reduce_noise.rb +28 -0
- data/doc/ex/remap.rb +11 -0
- data/doc/ex/remap_images.rb +19 -0
- data/doc/ex/resize_to_fill.rb +8 -0
- data/doc/ex/resize_to_fit.rb +8 -0
- data/doc/ex/roll.rb +9 -0
- data/doc/ex/rotate.rb +44 -0
- data/doc/ex/rotate_f.rb +14 -0
- data/doc/ex/roundrect.rb +33 -0
- data/doc/ex/rubyname.rb +30 -0
- data/doc/ex/rvg_clippath.rb +12 -0
- data/doc/ex/rvg_linecap.rb +42 -0
- data/doc/ex/rvg_linejoin.rb +40 -0
- data/doc/ex/rvg_opacity.rb +18 -0
- data/doc/ex/rvg_pattern.rb +26 -0
- data/doc/ex/rvg_stroke_dasharray.rb +11 -0
- data/doc/ex/segment.rb +11 -0
- data/doc/ex/sepiatone.rb +7 -0
- data/doc/ex/shade.rb +11 -0
- data/doc/ex/shadow.rb +30 -0
- data/doc/ex/shave.rb +15 -0
- data/doc/ex/shear.rb +10 -0
- data/doc/ex/sketch.rb +17 -0
- data/doc/ex/skewx.rb +51 -0
- data/doc/ex/skewy.rb +47 -0
- data/doc/ex/smile.rb +125 -0
- data/doc/ex/solarize.rb +11 -0
- data/doc/ex/sparse_color.rb +54 -0
- data/doc/ex/splice.rb +8 -0
- data/doc/ex/spread.rb +11 -0
- data/doc/ex/stegano.rb +55 -0
- data/doc/ex/stroke_dasharray.rb +42 -0
- data/doc/ex/stroke_fill.rb +10 -0
- data/doc/ex/stroke_linecap.rb +44 -0
- data/doc/ex/stroke_linejoin.rb +48 -0
- data/doc/ex/stroke_width.rb +49 -0
- data/doc/ex/swirl.rb +17 -0
- data/doc/ex/text.rb +37 -0
- data/doc/ex/text01.rb +16 -0
- data/doc/ex/text_align.rb +36 -0
- data/doc/ex/text_antialias.rb +37 -0
- data/doc/ex/text_styles.rb +19 -0
- data/doc/ex/text_undercolor.rb +28 -0
- data/doc/ex/texture_fill_to_border.rb +34 -0
- data/doc/ex/texture_floodfill.rb +32 -0
- data/doc/ex/texturefill.rb +24 -0
- data/doc/ex/threshold.rb +13 -0
- data/doc/ex/to_blob.rb +13 -0
- data/doc/ex/translate.rb +39 -0
- data/doc/ex/transparent.rb +38 -0
- data/doc/ex/transpose.rb +9 -0
- data/doc/ex/transverse.rb +9 -0
- data/doc/ex/tref01.rb +24 -0
- data/doc/ex/triangle01.rb +15 -0
- data/doc/ex/trim.rb +23 -0
- data/doc/ex/tspan01.rb +17 -0
- data/doc/ex/tspan02.rb +17 -0
- data/doc/ex/tspan03.rb +19 -0
- data/doc/ex/unsharp_mask.rb +28 -0
- data/doc/ex/viewex.rb +33 -0
- data/doc/ex/vignette.rb +12 -0
- data/doc/ex/watermark.rb +27 -0
- data/doc/ex/wave.rb +9 -0
- data/doc/ex/wet_floor.rb +58 -0
- data/doc/ex/writing_mode01.rb +26 -0
- data/doc/ex/writing_mode02.rb +26 -0
- data/doc/ilist.html +2056 -0
- data/doc/image1.html +4680 -0
- data/doc/image2.html +3665 -0
- data/doc/image3.html +4522 -0
- data/doc/imageattrs.html +1638 -0
- data/doc/imusage.html +514 -0
- data/doc/index.html +416 -0
- data/doc/info.html +1499 -0
- data/doc/magick.html +565 -0
- data/doc/optequiv.html +2435 -0
- data/doc/rvg.html +975 -0
- data/doc/rvgclip.html +248 -0
- data/doc/rvggroup.html +305 -0
- data/doc/rvgimage.html +289 -0
- data/doc/rvgpattern.html +475 -0
- data/doc/rvgshape.html +406 -0
- data/doc/rvgstyle.html +270 -0
- data/doc/rvgtext.html +465 -0
- data/doc/rvgtspan.html +238 -0
- data/doc/rvgtut.html +530 -0
- data/doc/rvguse.html +145 -0
- data/doc/rvgxform.html +294 -0
- data/doc/scripts/doc.js +22 -0
- data/doc/scripts/stripeTables.js +23 -0
- data/doc/struct.html +1339 -0
- data/doc/usage.html +1621 -0
- data/examples/constitute.rb +7 -0
- data/examples/crop_with_gravity.rb +42 -0
- data/examples/demo.rb +324 -0
- data/examples/describe.rb +43 -0
- data/examples/find_similar_region.rb +34 -0
- data/examples/histogram.rb +321 -0
- data/examples/identify.rb +185 -0
- data/examples/image_opacity.rb +29 -0
- data/examples/import_export.rb +31 -0
- data/examples/pattern_fill.rb +38 -0
- data/examples/rotating_text.rb +44 -0
- data/examples/spinner.rb +49 -0
- data/examples/thumbnail.rb +64 -0
- data/examples/vignette.rb +78 -0
- data/ext/RMagick/extconf.rb +548 -0
- data/ext/RMagick/rmagick.c +401 -0
- data/ext/RMagick/rmagick.h +1287 -0
- data/ext/RMagick/rmdraw.c +2022 -0
- data/ext/RMagick/rmenum.c +1235 -0
- data/ext/RMagick/rmfill.c +720 -0
- data/ext/RMagick/rmilist.c +1270 -0
- data/ext/RMagick/rmimage.c +15427 -0
- data/ext/RMagick/rminfo.c +2590 -0
- data/ext/RMagick/rmmain.c +1741 -0
- data/ext/RMagick/rmmontage.c +519 -0
- data/ext/RMagick/rmpixel.c +1114 -0
- data/ext/RMagick/rmstruct.c +1124 -0
- data/ext/RMagick/rmutil.c +1754 -0
- data/lib/rmagick.rb +1 -0
- data/lib/rmagick/version.rb +6 -0
- data/lib/rmagick_internal.rb +1947 -0
- data/lib/rvg/clippath.rb +45 -0
- data/lib/rvg/container.rb +122 -0
- data/lib/rvg/deep_equal.rb +52 -0
- data/lib/rvg/describable.rb +47 -0
- data/lib/rvg/embellishable.rb +391 -0
- data/lib/rvg/misc.rb +723 -0
- data/lib/rvg/paint.rb +50 -0
- data/lib/rvg/pathdata.rb +126 -0
- data/lib/rvg/rvg.rb +283 -0
- data/lib/rvg/stretchable.rb +165 -0
- data/lib/rvg/stylable.rb +116 -0
- data/lib/rvg/text.rb +172 -0
- data/lib/rvg/transformable.rb +126 -0
- data/lib/rvg/units.rb +63 -0
- data/rmagick.gemspec +46 -0
- 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 +565 -0
- data/test/Image2.rb +1304 -0
- data/test/Image3.rb +1030 -0
- data/test/ImageList1.rb +806 -0
- data/test/ImageList2.rb +385 -0
- data/test/Image_attributes.rb +697 -0
- data/test/Import_Export.rb +121 -0
- data/test/Info.rb +345 -0
- data/test/Magick.rb +321 -0
- data/test/Pixel.rb +116 -0
- data/test/Preview.rb +57 -0
- data/test/cmyk.icm +0 -0
- data/test/srgb.icm +0 -0
- data/test/test_all_basic.rb +38 -0
- data/test/tmpnam_test.rb +50 -0
- data/wercker.yml +10 -0
- metadata +509 -0
@@ -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
data/test/Image1.rb
ADDED
@@ -0,0 +1,565 @@
|
|
1
|
+
#!/usr/bin/env ruby -w
|
2
|
+
|
3
|
+
require 'rmagick'
|
4
|
+
require 'test/unit'
|
5
|
+
require 'test/unit/ui/console/testrunner' unless RUBY_VERSION[/^1\.9|^2/]
|
6
|
+
|
7
|
+
class Image1_UT < Test::Unit::TestCase
|
8
|
+
FreezeError = RUBY_VERSION[/^1\.9|^2/] ? RuntimeError : TypeError
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@img = Magick::Image.new(20, 20)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_read_inline
|
15
|
+
img = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
|
16
|
+
blob = img.to_blob
|
17
|
+
encoded = [blob].pack('m*')
|
18
|
+
res = Magick::Image.read_inline(encoded)
|
19
|
+
assert_instance_of(Array, res)
|
20
|
+
assert_instance_of(Magick::Image, res[0])
|
21
|
+
assert_equal(img, res[0])
|
22
|
+
end
|
23
|
+
|
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
|
27
|
+
sig0 = img0.signature
|
28
|
+
sig1 = img1.signature
|
29
|
+
# since <=> is based on the signature, the images should
|
30
|
+
# have the same relationship to each other as their
|
31
|
+
# signatures have to each other.
|
32
|
+
assert_equal(sig0 <=> sig1, img0 <=> img1)
|
33
|
+
assert_equal(sig1 <=> sig0, img1 <=> img0)
|
34
|
+
assert_equal(img0, img0)
|
35
|
+
assert_not_equal(img0, img1)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_adaptive_blur
|
39
|
+
assert_nothing_raised do
|
40
|
+
res = @img.adaptive_blur
|
41
|
+
assert_instance_of(Magick::Image, res)
|
42
|
+
end
|
43
|
+
assert_nothing_raised { @img.adaptive_blur(2) }
|
44
|
+
assert_nothing_raised { @img.adaptive_blur(3, 2) }
|
45
|
+
assert_raise(ArgumentError) { @img.adaptive_blur(3, 2, 2) }
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_adaptive_blur_channel
|
49
|
+
assert_nothing_raised do
|
50
|
+
res = @img.adaptive_blur_channel
|
51
|
+
assert_instance_of(Magick::Image, res)
|
52
|
+
end
|
53
|
+
assert_nothing_raised { @img.adaptive_blur_channel(2) }
|
54
|
+
assert_nothing_raised { @img.adaptive_blur_channel(3, 2) }
|
55
|
+
assert_nothing_raised { @img.adaptive_blur_channel(3, 2, Magick::RedChannel) }
|
56
|
+
assert_nothing_raised { @img.adaptive_blur_channel(3, 2, Magick::RedChannel, Magick::BlueChannel) }
|
57
|
+
assert_raise(ArgumentError) { @img.adaptive_blur(3, 2, 2) }
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_adaptive_resize
|
61
|
+
assert_nothing_raised do
|
62
|
+
res = @img.adaptive_resize(10,10)
|
63
|
+
assert_instance_of(Magick::Image, res)
|
64
|
+
end
|
65
|
+
assert_nothing_raised { @img.adaptive_resize(2) }
|
66
|
+
assert_raise(ArgumentError) { @img.adaptive_resize(10,10,10) }
|
67
|
+
assert_raise(ArgumentError) { @img.adaptive_resize }
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_adaptive_sharpen
|
71
|
+
assert_nothing_raised do
|
72
|
+
res = @img.adaptive_sharpen
|
73
|
+
assert_instance_of(Magick::Image, res)
|
74
|
+
end
|
75
|
+
assert_nothing_raised { @img.adaptive_sharpen(2) }
|
76
|
+
assert_nothing_raised { @img.adaptive_sharpen(3, 2) }
|
77
|
+
assert_raise(ArgumentError) { @img.adaptive_sharpen(3, 2, 2) }
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_adaptive_sharpen_channel
|
81
|
+
assert_nothing_raised do
|
82
|
+
res = @img.adaptive_sharpen_channel
|
83
|
+
assert_instance_of(Magick::Image, res)
|
84
|
+
end
|
85
|
+
assert_nothing_raised { @img.adaptive_sharpen_channel(2) }
|
86
|
+
assert_nothing_raised { @img.adaptive_sharpen_channel(3, 2) }
|
87
|
+
assert_nothing_raised { @img.adaptive_sharpen_channel(3, 2, Magick::RedChannel) }
|
88
|
+
assert_nothing_raised { @img.adaptive_sharpen_channel(3, 2, Magick::RedChannel, Magick::BlueChannel) }
|
89
|
+
assert_raise(ArgumentError) { @img.adaptive_sharpen(3, 2, 2) }
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_adaptive_threshold
|
93
|
+
assert_nothing_raised do
|
94
|
+
res = @img.adaptive_threshold
|
95
|
+
assert_instance_of(Magick::Image, res)
|
96
|
+
end
|
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) }
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_add_compose_mask
|
104
|
+
mask = Magick::Image.new(20,20)
|
105
|
+
assert_nothing_raised { @img.add_compose_mask(mask) }
|
106
|
+
assert_nothing_raised { @img.delete_compose_mask }
|
107
|
+
assert_nothing_raised { @img.add_compose_mask(mask) }
|
108
|
+
assert_nothing_raised { @img.add_compose_mask(mask) }
|
109
|
+
assert_nothing_raised { @img.delete_compose_mask }
|
110
|
+
assert_nothing_raised { @img.delete_compose_mask }
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_add_noise
|
114
|
+
assert_nothing_raised { @img.add_noise(Magick::UniformNoise) }
|
115
|
+
assert_nothing_raised { @img.add_noise(Magick::GaussianNoise) }
|
116
|
+
assert_nothing_raised { @img.add_noise(Magick::MultiplicativeGaussianNoise) }
|
117
|
+
assert_nothing_raised { @img.add_noise(Magick::ImpulseNoise) }
|
118
|
+
assert_nothing_raised { @img.add_noise(Magick::LaplacianNoise) }
|
119
|
+
assert_nothing_raised { @img.add_noise(Magick::PoissonNoise) }
|
120
|
+
assert_raise(TypeError) { @img.add_noise(0) }
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_add_noise_channel
|
124
|
+
assert_nothing_raised { @img.add_noise_channel(Magick::UniformNoise) }
|
125
|
+
assert_nothing_raised { @img.add_noise_channel(Magick::UniformNoise, Magick::RedChannel) }
|
126
|
+
assert_nothing_raised { @img.add_noise_channel(Magick::GaussianNoise, Magick::BlueChannel) }
|
127
|
+
assert_nothing_raised { @img.add_noise_channel(Magick::ImpulseNoise, Magick::GreenChannel) }
|
128
|
+
assert_nothing_raised { @img.add_noise_channel(Magick::LaplacianNoise, Magick::RedChannel, Magick::GreenChannel) }
|
129
|
+
assert_nothing_raised { @img.add_noise_channel(Magick::PoissonNoise, Magick::RedChannel, Magick::GreenChannel, Magick::BlueChannel) }
|
130
|
+
|
131
|
+
# Not a NoiseType
|
132
|
+
assert_raise(TypeError) { @img.add_noise_channel(1) }
|
133
|
+
# Not a ChannelType
|
134
|
+
assert_raise(TypeError) { @img.add_noise_channel(Magick::UniformNoise, Magick::RedChannel, 1) }
|
135
|
+
# Too few arguments
|
136
|
+
assert_raise(ArgumentError) { @img.add_noise_channel }
|
137
|
+
end
|
138
|
+
|
139
|
+
def add_delete_profile
|
140
|
+
img = Magick::Image.read('cmyk.jpg'),first
|
141
|
+
assert_nothing_raised { img.add_profile('cmyk.icm') }
|
142
|
+
assert_nothing_raised { img.add_profile('srgb.icm') }
|
143
|
+
img.each_profile { |name, value| assert_equal('icc', name) }
|
144
|
+
assert_nothing_raised { img.delete_profile('icc') }
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_affine_matrix
|
148
|
+
affine = Magick::AffineMatrix.new(1, Math::PI/6, Math::PI/6, 1, 0, 0)
|
149
|
+
assert_nothing_raised { @img.affine_transform(affine) }
|
150
|
+
assert_raise(TypeError) { @img.affine_transform(0) }
|
151
|
+
res = @img.affine_transform(affine)
|
152
|
+
assert_instance_of(Magick::Image, res)
|
153
|
+
end
|
154
|
+
|
155
|
+
# test alpha backward compatibility. Image#alpha w/o arguments acts like alpha?
|
156
|
+
def test_alpha_compat
|
157
|
+
assert_nothing_raised { @img.alpha }
|
158
|
+
assert !@img.alpha
|
159
|
+
assert_nothing_raised { @img.alpha Magick::ActivateAlphaChannel }
|
160
|
+
assert @img.alpha
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_alpha
|
164
|
+
assert_nothing_raised { @img.alpha? }
|
165
|
+
assert !@img.alpha?
|
166
|
+
assert_nothing_raised { @img.alpha Magick::ActivateAlphaChannel }
|
167
|
+
assert @img.alpha?
|
168
|
+
assert_nothing_raised { @img.alpha Magick::DeactivateAlphaChannel }
|
169
|
+
assert !@img.alpha?
|
170
|
+
assert_nothing_raised { @img.alpha Magick::ResetAlphaChannel }
|
171
|
+
assert_nothing_raised { @img.alpha Magick::SetAlphaChannel }
|
172
|
+
@img.freeze
|
173
|
+
assert_raise(FreezeError) { @img.alpha Magick::SetAlphaChannel }
|
174
|
+
end
|
175
|
+
|
176
|
+
def test_auto_gamma
|
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
|
+
end
|
185
|
+
|
186
|
+
def test_auto_level
|
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
|
+
end
|
195
|
+
|
196
|
+
def test_auto_orient
|
197
|
+
assert_nothing_raised do
|
198
|
+
res = @img.auto_orient
|
199
|
+
assert_instance_of(Magick::Image, res)
|
200
|
+
assert_not_same(@img, res)
|
201
|
+
end
|
202
|
+
|
203
|
+
assert_nothing_raised do
|
204
|
+
res = @img.auto_orient!
|
205
|
+
# When not changed, returns nil
|
206
|
+
assert_nil(res)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_bilevel_channel
|
211
|
+
assert_raise(ArgumentError) { @img.bilevel_channel }
|
212
|
+
assert_nothing_raised { @img.bilevel_channel(100) }
|
213
|
+
assert_nothing_raised { @img.bilevel_channel(100, Magick::RedChannel) }
|
214
|
+
assert_nothing_raised { @img.bilevel_channel(100, Magick::RedChannel, Magick::BlueChannel, Magick::GreenChannel, Magick::OpacityChannel) }
|
215
|
+
assert_nothing_raised { @img.bilevel_channel(100, Magick::CyanChannel, Magick::MagentaChannel, Magick::YellowChannel, Magick::BlackChannel) }
|
216
|
+
assert_nothing_raised { @img.bilevel_channel(100, Magick::GrayChannel) }
|
217
|
+
assert_nothing_raised { @img.bilevel_channel(100, Magick::AllChannels) }
|
218
|
+
assert_raise(TypeError) { @img.bilevel_channel(100, 2) }
|
219
|
+
res = @img.bilevel_channel(100)
|
220
|
+
assert_instance_of(Magick::Image, res)
|
221
|
+
end
|
222
|
+
|
223
|
+
def test_blend
|
224
|
+
@img2 = Magick::Image.new(20,20) {self.background_color = 'black'}
|
225
|
+
assert_nothing_raised { @img.blend(@img2, 0.25) }
|
226
|
+
res = @img.blend(@img2, 0.25)
|
227
|
+
assert_instance_of(Magick::Image, res)
|
228
|
+
assert_nothing_raised { @img.blend(@img2, '25%') }
|
229
|
+
assert_nothing_raised { @img.blend(@img2, 0.25, 0.75) }
|
230
|
+
assert_nothing_raised { @img.blend(@img2, '25%', '75%') }
|
231
|
+
assert_nothing_raised { @img.blend(@img2, 0.25, 0.75, Magick::CenterGravity) }
|
232
|
+
assert_nothing_raised { @img.blend(@img2, 0.25, 0.75, Magick::CenterGravity, 10) }
|
233
|
+
assert_nothing_raised { @img.blend(@img2, 0.25, 0.75, Magick::CenterGravity, 10, 10) }
|
234
|
+
assert_raise(ArgumentError) { @img.blend }
|
235
|
+
assert_raise(ArgumentError) { @img.blend(@img2, 'x') }
|
236
|
+
assert_raise(TypeError) { @img.blend(@img2, 0.25, []) }
|
237
|
+
assert_raise(TypeError) { @img.blend(@img2, 0.25, 0.75, 'x') }
|
238
|
+
assert_raise(TypeError) { @img.blend(@img2, 0.25, 0.75, Magick::CenterGravity, 'x') }
|
239
|
+
assert_raise(TypeError) { @img.blend(@img2, 0.25, 0.75, Magick::CenterGravity, 10, []) }
|
240
|
+
|
241
|
+
@img2.destroy!
|
242
|
+
assert_raise(Magick::DestroyedImageError) { @img.blend(@img2, '25%') }
|
243
|
+
end
|
244
|
+
|
245
|
+
def test_blur_channel
|
246
|
+
assert_nothing_raised { @img.blur_channel }
|
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) }
|
255
|
+
res = @img.blur_channel
|
256
|
+
assert_instance_of(Magick::Image, res)
|
257
|
+
end
|
258
|
+
|
259
|
+
def test_blur_image
|
260
|
+
assert_nothing_raised { @img.blur_image }
|
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) }
|
264
|
+
res = @img.blur_image
|
265
|
+
assert_instance_of(Magick::Image, res)
|
266
|
+
end
|
267
|
+
|
268
|
+
def test_black_threshold
|
269
|
+
assert_raise(ArgumentError) { @img.black_threshold }
|
270
|
+
assert_nothing_raised { @img.black_threshold(50) }
|
271
|
+
assert_nothing_raised { @img.black_threshold(50, 50) }
|
272
|
+
assert_nothing_raised { @img.black_threshold(50, 50, 50) }
|
273
|
+
assert_nothing_raised { @img.black_threshold(50, 50, 50, 50) }
|
274
|
+
assert_raise(ArgumentError) { @img.black_threshold(50, 50, 50, 50, 50) }
|
275
|
+
res = @img.black_threshold(50)
|
276
|
+
assert_instance_of(Magick::Image, res)
|
277
|
+
end
|
278
|
+
|
279
|
+
def test_border
|
280
|
+
assert_nothing_raised { @img.border(2, 2, 'red') }
|
281
|
+
assert_nothing_raised { @img.border!(2, 2, 'red') }
|
282
|
+
res = @img.border(2,2, 'red')
|
283
|
+
assert_instance_of(Magick::Image, res)
|
284
|
+
@img.freeze
|
285
|
+
assert_raise(FreezeError) { @img.border!(2,2, 'red') }
|
286
|
+
end
|
287
|
+
|
288
|
+
def test_change_geometry
|
289
|
+
assert_raise(ArgumentError) { @img.change_geometry('sss') }
|
290
|
+
assert_raise(LocalJumpError) { @img.change_geometry('100x100') }
|
291
|
+
assert_nothing_raised do
|
292
|
+
res = @img.change_geometry('100x100') { 1 }
|
293
|
+
assert_equal(1, res)
|
294
|
+
end
|
295
|
+
assert_raise(ArgumentError) { @img.change_geometry([]) }
|
296
|
+
end
|
297
|
+
|
298
|
+
def test_changed?
|
299
|
+
# assert_block { !@img.changed? }
|
300
|
+
# @img.pixel_color(0,0,'red')
|
301
|
+
# assert_block { @img.changed? }
|
302
|
+
end
|
303
|
+
|
304
|
+
def test_channel
|
305
|
+
assert_nothing_raised { @img.channel(Magick::RedChannel) }
|
306
|
+
assert_nothing_raised { @img.channel(Magick::BlueChannel) }
|
307
|
+
assert_nothing_raised { @img.channel(Magick::GreenChannel) }
|
308
|
+
assert_nothing_raised { @img.channel(Magick::OpacityChannel) }
|
309
|
+
assert_nothing_raised { @img.channel(Magick::MagentaChannel) }
|
310
|
+
assert_nothing_raised { @img.channel(Magick::CyanChannel) }
|
311
|
+
assert_nothing_raised { @img.channel(Magick::YellowChannel) }
|
312
|
+
assert_nothing_raised { @img.channel(Magick::BlackChannel) }
|
313
|
+
assert_nothing_raised { @img.channel(Magick::GrayChannel) }
|
314
|
+
assert_nothing_raised { @img.channel(Magick::AlphaChannel) }
|
315
|
+
assert_nothing_raised { @img.channel(Magick::DefaultChannels) }
|
316
|
+
assert_nothing_raised { @img.channel(Magick::HueChannel) }
|
317
|
+
assert_nothing_raised { @img.channel(Magick::LuminosityChannel) }
|
318
|
+
assert_nothing_raised { @img.channel(Magick::SaturationChannel) }
|
319
|
+
assert_instance_of(Magick::Image, @img.channel(Magick::RedChannel))
|
320
|
+
assert_raise(TypeError) { @img.channel(2) }
|
321
|
+
end
|
322
|
+
|
323
|
+
def test_channel_depth
|
324
|
+
assert_nothing_raised { @img.channel_depth }
|
325
|
+
assert_nothing_raised { @img.channel_depth(Magick::RedChannel) }
|
326
|
+
assert_nothing_raised { @img.channel_depth(Magick::RedChannel, Magick::BlueChannel) }
|
327
|
+
assert_nothing_raised { @img.channel_depth(Magick::GreenChannel, Magick::OpacityChannel) }
|
328
|
+
assert_nothing_raised { @img.channel_depth(Magick::MagentaChannel, Magick::CyanChannel) }
|
329
|
+
assert_nothing_raised { @img.channel_depth(Magick::CyanChannel, Magick::BlackChannel) }
|
330
|
+
assert_nothing_raised { @img.channel_depth(Magick::GrayChannel) }
|
331
|
+
assert_raise(TypeError) { @img.channel_depth(2) }
|
332
|
+
assert_instance_of(Fixnum, @img.channel_depth(Magick::RedChannel))
|
333
|
+
end
|
334
|
+
|
335
|
+
def test_channel_extrema
|
336
|
+
assert_nothing_raised do
|
337
|
+
res = @img.channel_extrema
|
338
|
+
assert_instance_of(Array, res)
|
339
|
+
assert_equal(2, res.length)
|
340
|
+
assert_kind_of(Integer, res[0])
|
341
|
+
assert_kind_of(Integer, res[1])
|
342
|
+
end
|
343
|
+
assert_nothing_raised { @img.channel_extrema(Magick::RedChannel) }
|
344
|
+
assert_nothing_raised { @img.channel_extrema(Magick::RedChannel, Magick::BlueChannel) }
|
345
|
+
assert_nothing_raised { @img.channel_extrema(Magick::GreenChannel, Magick::OpacityChannel) }
|
346
|
+
assert_nothing_raised { @img.channel_extrema(Magick::MagentaChannel, Magick::CyanChannel) }
|
347
|
+
assert_nothing_raised { @img.channel_extrema(Magick::CyanChannel, Magick::BlackChannel) }
|
348
|
+
assert_nothing_raised { @img.channel_extrema(Magick::GrayChannel) }
|
349
|
+
assert_raise(TypeError) { @img.channel_extrema(2) }
|
350
|
+
end
|
351
|
+
|
352
|
+
def test_channel_mean
|
353
|
+
assert_nothing_raised do
|
354
|
+
res = @img.channel_mean
|
355
|
+
assert_instance_of(Array, res)
|
356
|
+
assert_equal(2, res.length)
|
357
|
+
assert_instance_of(Float, res[0])
|
358
|
+
assert_instance_of(Float, res[1])
|
359
|
+
end
|
360
|
+
assert_nothing_raised { @img.channel_mean(Magick::RedChannel) }
|
361
|
+
assert_nothing_raised { @img.channel_mean(Magick::RedChannel, Magick::BlueChannel) }
|
362
|
+
assert_nothing_raised { @img.channel_mean(Magick::GreenChannel, Magick::OpacityChannel) }
|
363
|
+
assert_nothing_raised { @img.channel_mean(Magick::MagentaChannel, Magick::CyanChannel) }
|
364
|
+
assert_nothing_raised { @img.channel_mean(Magick::CyanChannel, Magick::BlackChannel) }
|
365
|
+
assert_nothing_raised { @img.channel_mean(Magick::GrayChannel) }
|
366
|
+
assert_raise(TypeError) { @img.channel_mean(2) }
|
367
|
+
end
|
368
|
+
|
369
|
+
def test_charcoal
|
370
|
+
assert_nothing_raised do
|
371
|
+
res = @img.charcoal
|
372
|
+
assert_instance_of(Magick::Image, res)
|
373
|
+
end
|
374
|
+
assert_nothing_raised { @img.charcoal(1.0) }
|
375
|
+
assert_nothing_raised { @img.charcoal(1.0, 2.0) }
|
376
|
+
assert_raise(ArgumentError) { @img.charcoal(1.0, 2.0, 3.0) }
|
377
|
+
end
|
378
|
+
|
379
|
+
def test_chop
|
380
|
+
assert_nothing_raised do
|
381
|
+
res = @img.chop(10, 10, 10, 10)
|
382
|
+
assert_instance_of(Magick::Image, res)
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
def test_clone
|
387
|
+
assert_nothing_raised do
|
388
|
+
res = @img.clone
|
389
|
+
assert_instance_of(Magick::Image, res)
|
390
|
+
assert_equal(res, @img)
|
391
|
+
end
|
392
|
+
res = @img.clone
|
393
|
+
assert_equal(res.frozen?, @img.frozen?)
|
394
|
+
@img.freeze
|
395
|
+
res = @img.clone
|
396
|
+
assert_equal(res.frozen?, @img.frozen?)
|
397
|
+
end
|
398
|
+
|
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'}
|
402
|
+
res = nil
|
403
|
+
assert_nothing_raised {res = img.clut_channel(clut)}
|
404
|
+
assert_same(res, img)
|
405
|
+
assert_nothing_raised { img.clut_channel(clut, Magick::RedChannel) }
|
406
|
+
assert_nothing_raised { img.clut_channel(clut, Magick::RedChannel, Magick::BlueChannel) }
|
407
|
+
assert_raises(ArgumentError) { img.clut_channel(clut, 1, Magick::RedChannel) }
|
408
|
+
end
|
409
|
+
|
410
|
+
def test_color_fill_to_border
|
411
|
+
assert_raise(ArgumentError) { @img.color_fill_to_border(-1, 1, 'red') }
|
412
|
+
assert_raise(ArgumentError) { @img.color_fill_to_border(1, 100, 'red') }
|
413
|
+
assert_nothing_raised do
|
414
|
+
res = @img.color_fill_to_border(@img.columns/2, @img.rows/2, 'red')
|
415
|
+
assert_instance_of(Magick::Image, res)
|
416
|
+
end
|
417
|
+
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
418
|
+
assert_nothing_raised { @img.color_fill_to_border(@img.columns/2, @img.rows/2, pixel) }
|
419
|
+
end
|
420
|
+
|
421
|
+
def test_color_floodfill
|
422
|
+
assert_raise(ArgumentError) { @img.color_floodfill(-1, 1, 'red') }
|
423
|
+
assert_raise(ArgumentError) { @img.color_floodfill(1, 100, 'red') }
|
424
|
+
assert_nothing_raised do
|
425
|
+
res = @img.color_floodfill(@img.columns/2, @img.rows/2, 'red')
|
426
|
+
assert_instance_of(Magick::Image, res)
|
427
|
+
end
|
428
|
+
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
429
|
+
assert_nothing_raised { @img.color_floodfill(@img.columns/2, @img.rows/2, pixel) }
|
430
|
+
end
|
431
|
+
|
432
|
+
def test_color_histogram
|
433
|
+
assert_nothing_raised do
|
434
|
+
res = @img.color_histogram
|
435
|
+
assert_instance_of(Hash, res)
|
436
|
+
end
|
437
|
+
end
|
438
|
+
|
439
|
+
def test_colorize
|
440
|
+
assert_nothing_raised do
|
441
|
+
res = @img.colorize(0.25, 0.25, 0.25, 'red')
|
442
|
+
assert_instance_of(Magick::Image, res)
|
443
|
+
end
|
444
|
+
assert_nothing_raised { @img.colorize(0.25, 0.25, 0.25, 0.25, 'red') }
|
445
|
+
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
446
|
+
assert_nothing_raised { @img.colorize(0.25, 0.25, 0.25, pixel) }
|
447
|
+
assert_nothing_raised { @img.colorize(0.25, 0.25, 0.25, 0.25, pixel) }
|
448
|
+
assert_raise(ArgumentError) { @img.colorize }
|
449
|
+
assert_raise(ArgumentError) { @img.colorize(0.25) }
|
450
|
+
assert_raise(ArgumentError) { @img.colorize(0.25, 0.25) }
|
451
|
+
assert_raise(ArgumentError) { @img.colorize(0.25, 0.25, 0.25) }
|
452
|
+
assert_raise(ArgumentError) { @img.colorize(0.25, 0.25, 0.25, 'X') }
|
453
|
+
# last argument must be a color name or pixel
|
454
|
+
assert_raise(TypeError) { @img.colorize(0.25, 0.25, 0.25, 0.25) }
|
455
|
+
assert_raise(ArgumentError) { @img.colorize(0.25, 0.25, 0.25, 0.25, 'X') }
|
456
|
+
assert_raise(TypeError) { @img.colorize(0.25, 0.25, 0.25, 0.25, [2]) }
|
457
|
+
end
|
458
|
+
|
459
|
+
def test_colormap
|
460
|
+
# IndexError b/c @img is DirectClass
|
461
|
+
assert_raise(IndexError) { @img.colormap(0) }
|
462
|
+
# Read PseudoClass image
|
463
|
+
pc_img = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
|
464
|
+
assert_nothing_raised { pc_img.colormap(0) }
|
465
|
+
ncolors = pc_img.colors
|
466
|
+
assert_raise(IndexError) { pc_img.colormap(ncolors+1) }
|
467
|
+
assert_raise(IndexError) { pc_img.colormap(-1) }
|
468
|
+
assert_nothing_raised { pc_img.colormap(ncolors-1) }
|
469
|
+
res = pc_img.colormap(0)
|
470
|
+
assert_instance_of(String, res)
|
471
|
+
|
472
|
+
#test 'set' operation
|
473
|
+
assert_nothing_raised do
|
474
|
+
old_color = pc_img.colormap(0)
|
475
|
+
res = pc_img.colormap(0, 'red')
|
476
|
+
assert_equal(old_color, res)
|
477
|
+
res = pc_img.colormap(0)
|
478
|
+
assert_equal('red', res)
|
479
|
+
end
|
480
|
+
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
481
|
+
assert_nothing_raised { pc_img.colormap(0, pixel) }
|
482
|
+
assert_raise(TypeError) { pc_img.colormap(0, [2]) }
|
483
|
+
pc_img.freeze
|
484
|
+
assert_raise(FreezeError) { pc_img.colormap(0, 'red') }
|
485
|
+
end
|
486
|
+
|
487
|
+
def test_color_point
|
488
|
+
assert_nothing_raised do
|
489
|
+
res = @img.color_point(0, 0, 'red')
|
490
|
+
assert_instance_of(Magick::Image, res)
|
491
|
+
assert_not_same(@img, res)
|
492
|
+
end
|
493
|
+
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
494
|
+
assert_nothing_raised { @img.color_point(0, 0, pixel) }
|
495
|
+
end
|
496
|
+
|
497
|
+
def test_color_reset!
|
498
|
+
assert_nothing_raised do
|
499
|
+
res = @img.color_reset!('red')
|
500
|
+
assert_same(@img, res)
|
501
|
+
end
|
502
|
+
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
503
|
+
assert_nothing_raised { @img.color_reset!(pixel) }
|
504
|
+
assert_raise(TypeError) { @img.color_reset!([2]) }
|
505
|
+
assert_raise(ArgumentError) { @img.color_reset!('x') }
|
506
|
+
@img.freeze
|
507
|
+
assert_raise(FreezeError) { @img.color_reset!('red') }
|
508
|
+
end
|
509
|
+
|
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' }
|
515
|
+
assert_nothing_raised { Magick::Image.combine(r) }
|
516
|
+
assert_nothing_raised { Magick::Image.combine(r, g) }
|
517
|
+
assert_nothing_raised { Magick::Image.combine(r, g, b) }
|
518
|
+
assert_nothing_raised { Magick::Image.combine(r, g, b, a) }
|
519
|
+
assert_nothing_raised { Magick::Image.combine(nil, g) }
|
520
|
+
assert_nothing_raised { Magick::Image.combine(r, nil, b) }
|
521
|
+
assert_nothing_raised { Magick::Image.combine(r, g, nil, a) }
|
522
|
+
assert_nothing_raised { Magick::Image.combine(r, g, b, nil) }
|
523
|
+
res = Magick::Image.combine(r, g, b)
|
524
|
+
assert_instance_of(Magick::Image, res)
|
525
|
+
assert_raise(ArgumentError) { Magick::Image.combine }
|
526
|
+
assert_raise(ArgumentError) { Magick::Image.combine(nil) }
|
527
|
+
assert_raise(ArgumentError) { Magick::Image.combine(r, g, b, a, r) }
|
528
|
+
assert_raise(TypeError) { Magick::Image.combine(1, g, b, a) }
|
529
|
+
end
|
530
|
+
|
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
|
534
|
+
assert_nothing_raised { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric) }
|
535
|
+
assert_nothing_raised { img1.compare_channel(img2, Magick::MeanSquaredErrorMetric) }
|
536
|
+
assert_nothing_raised { img1.compare_channel(img2, Magick::PeakAbsoluteErrorMetric) }
|
537
|
+
assert_nothing_raised { img1.compare_channel(img2, Magick::PeakSignalToNoiseRatioMetric) }
|
538
|
+
assert_nothing_raised { img1.compare_channel(img2, Magick::RootMeanSquaredErrorMetric) }
|
539
|
+
assert_raise(TypeError) { img1.compare_channel(img2, 2) }
|
540
|
+
assert_raise(ArgumentError) { img1.compare_channel }
|
541
|
+
|
542
|
+
ilist = Magick::ImageList.new
|
543
|
+
ilist << img2
|
544
|
+
assert_nothing_raised { img1.compare_channel(ilist, Magick::MeanAbsoluteErrorMetric) }
|
545
|
+
|
546
|
+
assert_nothing_raised { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric, Magick::RedChannel) }
|
547
|
+
assert_nothing_raised { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric, Magick::RedChannel, Magick::BlueChannel) }
|
548
|
+
assert_raise(TypeError) { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric, 2) }
|
549
|
+
assert_raise(TypeError) { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric, Magick::RedChannel, 2) }
|
550
|
+
|
551
|
+
res = img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric)
|
552
|
+
assert_instance_of(Array, res)
|
553
|
+
assert_instance_of(Magick::Image, res[0])
|
554
|
+
assert_instance_of(Float, res[1])
|
555
|
+
|
556
|
+
img2.destroy!
|
557
|
+
assert_raise(Magick::DestroyedImageError) { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric) }
|
558
|
+
end
|
559
|
+
end
|
560
|
+
|
561
|
+
if __FILE__ == $PROGRAM_NAME
|
562
|
+
IMAGES_DIR = '../doc/ex/images'
|
563
|
+
FILES = Dir[IMAGES_DIR+'/Button_*.gif']
|
564
|
+
Test::Unit::UI::Console::TestRunner.run(Image1_UT) unless RUBY_VERSION[/^1\.9|^2/]
|
565
|
+
end
|