rmagick 3.2.0 → 4.3.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/.codeclimate.yml +63 -0
- data/.devcontainer/Dockerfile +14 -0
- data/.devcontainer/ImageMagick6/devcontainer.json +11 -0
- data/.devcontainer/devcontainer.json +11 -0
- data/.devcontainer/setup-repo.sh +10 -0
- data/.devcontainer/setup-user.sh +45 -0
- data/.editorconfig +3 -0
- data/.github/ISSUE_TEMPLATE.md +17 -0
- data/.github/workflows/ci.yml +79 -0
- data/.gitignore +3 -1
- data/.rspec +1 -0
- data/.rubocop.yml +24 -0
- data/.rubocop_todo.yml +151 -297
- data/.yardopts +5 -0
- data/CHANGELOG.md +233 -0
- data/CODE_OF_CONDUCT.md +122 -7
- data/CONTRIBUTING.md +14 -10
- data/README.md +326 -0
- data/Rakefile +16 -22
- data/before_install_linux.sh +22 -28
- data/before_install_osx.sh +57 -2
- data/ext/RMagick/extconf.rb +149 -105
- data/ext/RMagick/rmagick.c +77 -104
- data/ext/RMagick/rmagick.h +121 -103
- data/ext/RMagick/rmdraw.c +364 -436
- data/ext/RMagick/rmenum.c +106 -114
- data/ext/RMagick/rmfill.c +149 -70
- data/ext/RMagick/rmilist.c +225 -367
- data/ext/RMagick/rmimage.c +4751 -4405
- data/ext/RMagick/rminfo.c +574 -787
- data/ext/RMagick/rmkinfo.c +51 -121
- data/ext/RMagick/rmmain.c +454 -286
- data/ext/RMagick/rmmontage.c +64 -130
- data/ext/RMagick/rmpixel.c +488 -437
- data/ext/RMagick/rmstruct.c +83 -96
- data/ext/RMagick/rmutil.c +302 -214
- data/lib/rmagick/version.rb +1 -1
- data/lib/rmagick_internal.rb +138 -93
- data/lib/rvg/clippath.rb +2 -1
- data/lib/rvg/container.rb +10 -5
- data/lib/rvg/describable.rb +1 -1
- data/lib/rvg/embellishable.rb +5 -4
- data/lib/rvg/misc.rb +15 -12
- data/lib/rvg/paint.rb +2 -1
- data/lib/rvg/pathdata.rb +12 -11
- data/lib/rvg/rvg.rb +12 -8
- data/lib/rvg/stylable.rb +9 -7
- data/lib/rvg/text.rb +11 -6
- data/lib/rvg/transformable.rb +3 -2
- data/lib/rvg/units.rb +1 -1
- data/rmagick.gemspec +10 -11
- metadata +52 -423
- data/.appveyor.yml +0 -45
- data/.circleci/config.yml +0 -56
- data/.ruby-version +0 -1
- data/.simplecov +0 -27
- data/.travis.yml +0 -62
- data/Doxyfile +0 -1514
- data/README.textile +0 -259
- data/benchmarks/memory/README.md +0 -50
- data/benchmarks/memory/image_new.rb +0 -8
- data/benchmarks/memory/rmagick.gnuplot +0 -16
- data/doc/.cvsignore +0 -1
- data/doc/comtasks.html +0 -287
- data/doc/constants.html +0 -1581
- data/doc/css/doc.css +0 -299
- data/doc/css/popup.css +0 -34
- data/doc/css/ref.css +0 -67
- data/doc/draw.html +0 -3272
- data/doc/ex/InitialCoords.rb +0 -22
- data/doc/ex/NewCoordSys.rb +0 -30
- data/doc/ex/OrigCoordSys.rb +0 -16
- data/doc/ex/PreserveAspectRatio.rb +0 -204
- data/doc/ex/RotateScale.rb +0 -36
- data/doc/ex/Skew.rb +0 -38
- data/doc/ex/Use01.rb +0 -15
- data/doc/ex/Use02.rb +0 -20
- data/doc/ex/Use03.rb +0 -16
- data/doc/ex/ViewBox.rb +0 -31
- data/doc/ex/adaptive_threshold.rb +0 -9
- data/doc/ex/add_noise.rb +0 -16
- data/doc/ex/affine.rb +0 -48
- data/doc/ex/affine_transform.rb +0 -20
- data/doc/ex/arc.rb +0 -49
- data/doc/ex/arcpath.rb +0 -32
- data/doc/ex/arcs01.rb +0 -28
- data/doc/ex/arcs02.rb +0 -59
- data/doc/ex/average.rb +0 -15
- data/doc/ex/axes.rb +0 -64
- data/doc/ex/baseline_shift01.rb +0 -17
- data/doc/ex/bilevel_channel.rb +0 -8
- data/doc/ex/blur_image.rb +0 -12
- data/doc/ex/border.rb +0 -10
- data/doc/ex/bounding_box.rb +0 -42
- data/doc/ex/cbezier1.rb +0 -41
- data/doc/ex/cbezier2.rb +0 -41
- data/doc/ex/cbezier3.rb +0 -41
- data/doc/ex/cbezier4.rb +0 -42
- data/doc/ex/cbezier5.rb +0 -42
- data/doc/ex/cbezier6.rb +0 -53
- data/doc/ex/channel.rb +0 -25
- data/doc/ex/charcoal.rb +0 -12
- data/doc/ex/chop.rb +0 -29
- data/doc/ex/circle.rb +0 -33
- data/doc/ex/circle01.rb +0 -16
- data/doc/ex/clip_path.rb +0 -60
- data/doc/ex/coalesce.rb +0 -57
- data/doc/ex/color_fill_to_border.rb +0 -29
- data/doc/ex/color_floodfill.rb +0 -28
- data/doc/ex/color_histogram.rb +0 -47
- data/doc/ex/color_reset.rb +0 -11
- data/doc/ex/colorize.rb +0 -16
- data/doc/ex/colors.rb +0 -64
- data/doc/ex/compose_mask.rb +0 -22
- data/doc/ex/composite.rb +0 -133
- data/doc/ex/composite_layers.rb +0 -52
- data/doc/ex/composite_tiled.rb +0 -21
- data/doc/ex/contrast.rb +0 -36
- data/doc/ex/crop.rb +0 -31
- data/doc/ex/crop_with_gravity.rb +0 -42
- data/doc/ex/cubic01.rb +0 -43
- data/doc/ex/cubic02.rb +0 -91
- data/doc/ex/cycle_colormap.rb +0 -21
- data/doc/ex/dissolve.rb +0 -12
- data/doc/ex/drawcomp.rb +0 -41
- data/doc/ex/drop_shadow.rb +0 -60
- data/doc/ex/edge.rb +0 -11
- data/doc/ex/ellipse.rb +0 -45
- data/doc/ex/ellipse01.rb +0 -21
- data/doc/ex/emboss.rb +0 -11
- data/doc/ex/enhance.rb +0 -28
- data/doc/ex/equalize.rb +0 -11
- data/doc/ex/evenodd.rb +0 -42
- data/doc/ex/fill_pattern.rb +0 -23
- data/doc/ex/flatten_images.rb +0 -36
- data/doc/ex/flip.rb +0 -11
- data/doc/ex/flop.rb +0 -11
- data/doc/ex/font_styles.rb +0 -32
- data/doc/ex/fonts.rb +0 -16
- data/doc/ex/frame.rb +0 -12
- data/doc/ex/gaussian_blur.rb +0 -11
- data/doc/ex/get_multiline_type_metrics.rb +0 -41
- data/doc/ex/get_pixels.rb +0 -45
- data/doc/ex/get_type_metrics.rb +0 -142
- data/doc/ex/gradientfill.rb +0 -27
- data/doc/ex/grav.rb +0 -45
- data/doc/ex/gravity.rb +0 -78
- data/doc/ex/group.rb +0 -26
- data/doc/ex/hatchfill.rb +0 -27
- data/doc/ex/image.rb +0 -44
- 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.png +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.png +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.png +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 +0 -34
- data/doc/ex/level.rb +0 -11
- data/doc/ex/level_colors.rb +0 -11
- data/doc/ex/line.rb +0 -41
- data/doc/ex/line01.rb +0 -21
- data/doc/ex/mask.rb +0 -35
- data/doc/ex/matte_fill_to_border.rb +0 -39
- data/doc/ex/matte_floodfill.rb +0 -32
- data/doc/ex/matte_replace.rb +0 -39
- data/doc/ex/median_filter.rb +0 -28
- data/doc/ex/modulate.rb +0 -11
- data/doc/ex/mono.rb +0 -23
- data/doc/ex/morph.rb +0 -25
- data/doc/ex/mosaic.rb +0 -37
- data/doc/ex/motion_blur.rb +0 -11
- data/doc/ex/negate.rb +0 -11
- data/doc/ex/negate_channel.rb +0 -9
- data/doc/ex/nested_rvg.rb +0 -21
- data/doc/ex/nonzero.rb +0 -42
- data/doc/ex/normalize.rb +0 -11
- data/doc/ex/oil_paint.rb +0 -11
- data/doc/ex/opacity.rb +0 -37
- data/doc/ex/ordered_dither.rb +0 -11
- data/doc/ex/path.rb +0 -63
- data/doc/ex/pattern1.rb +0 -25
- data/doc/ex/pattern2.rb +0 -26
- data/doc/ex/polaroid.rb +0 -26
- data/doc/ex/polygon.rb +0 -23
- data/doc/ex/polygon01.rb +0 -21
- data/doc/ex/polyline.rb +0 -22
- data/doc/ex/polyline01.rb +0 -21
- data/doc/ex/posterize.rb +0 -8
- data/doc/ex/preview.rb +0 -8
- data/doc/ex/qbezierpath.rb +0 -52
- data/doc/ex/quad01.rb +0 -34
- data/doc/ex/quantize-m.rb +0 -25
- data/doc/ex/radial_blur.rb +0 -9
- data/doc/ex/raise.rb +0 -8
- data/doc/ex/random_threshold_channel.rb +0 -13
- data/doc/ex/rect01.rb +0 -14
- data/doc/ex/rect02.rb +0 -20
- data/doc/ex/rectangle.rb +0 -34
- data/doc/ex/reduce_noise.rb +0 -28
- data/doc/ex/remap.rb +0 -11
- data/doc/ex/remap_images.rb +0 -19
- data/doc/ex/resize_to_fill.rb +0 -8
- data/doc/ex/resize_to_fit.rb +0 -8
- data/doc/ex/roll.rb +0 -9
- data/doc/ex/rotate.rb +0 -44
- data/doc/ex/rotate_f.rb +0 -14
- data/doc/ex/roundrect.rb +0 -33
- data/doc/ex/rubyname.rb +0 -30
- data/doc/ex/rvg_clippath.rb +0 -12
- data/doc/ex/rvg_linecap.rb +0 -42
- data/doc/ex/rvg_linejoin.rb +0 -40
- data/doc/ex/rvg_opacity.rb +0 -18
- data/doc/ex/rvg_pattern.rb +0 -26
- data/doc/ex/rvg_stroke_dasharray.rb +0 -11
- data/doc/ex/segment.rb +0 -11
- data/doc/ex/sepiatone.rb +0 -7
- data/doc/ex/shade.rb +0 -11
- data/doc/ex/shadow.rb +0 -30
- data/doc/ex/shave.rb +0 -15
- data/doc/ex/shear.rb +0 -10
- data/doc/ex/sketch.rb +0 -17
- data/doc/ex/skewx.rb +0 -51
- data/doc/ex/skewy.rb +0 -47
- data/doc/ex/smile.rb +0 -126
- data/doc/ex/solarize.rb +0 -11
- data/doc/ex/sparse_color.rb +0 -55
- data/doc/ex/splice.rb +0 -8
- data/doc/ex/spread.rb +0 -11
- data/doc/ex/stegano.rb +0 -54
- data/doc/ex/stroke_dasharray.rb +0 -42
- data/doc/ex/stroke_fill.rb +0 -10
- data/doc/ex/stroke_linecap.rb +0 -44
- data/doc/ex/stroke_linejoin.rb +0 -48
- data/doc/ex/stroke_width.rb +0 -49
- data/doc/ex/swirl.rb +0 -17
- data/doc/ex/text.rb +0 -37
- data/doc/ex/text01.rb +0 -16
- data/doc/ex/text_align.rb +0 -36
- data/doc/ex/text_antialias.rb +0 -37
- data/doc/ex/text_styles.rb +0 -19
- data/doc/ex/text_undercolor.rb +0 -28
- data/doc/ex/texture_fill_to_border.rb +0 -34
- data/doc/ex/texture_floodfill.rb +0 -32
- data/doc/ex/texturefill.rb +0 -24
- data/doc/ex/threshold.rb +0 -13
- data/doc/ex/to_blob.rb +0 -13
- data/doc/ex/translate.rb +0 -39
- data/doc/ex/transparent.rb +0 -38
- data/doc/ex/transpose.rb +0 -9
- data/doc/ex/transverse.rb +0 -9
- data/doc/ex/tref01.rb +0 -24
- data/doc/ex/triangle01.rb +0 -15
- data/doc/ex/trim.rb +0 -23
- data/doc/ex/tspan01.rb +0 -17
- data/doc/ex/tspan02.rb +0 -17
- data/doc/ex/tspan03.rb +0 -19
- data/doc/ex/unsharp_mask.rb +0 -28
- data/doc/ex/viewex.rb +0 -33
- data/doc/ex/vignette.rb +0 -12
- data/doc/ex/watermark.rb +0 -27
- data/doc/ex/wave.rb +0 -9
- data/doc/ex/wet_floor.rb +0 -58
- data/doc/ex/writing_mode01.rb +0 -26
- data/doc/ex/writing_mode02.rb +0 -26
- data/doc/ilist.html +0 -2056
- data/doc/image1.html +0 -4680
- data/doc/image2.html +0 -3665
- data/doc/image3.html +0 -4522
- data/doc/imageattrs.html +0 -1638
- data/doc/imusage.html +0 -514
- data/doc/index.html +0 -416
- data/doc/info.html +0 -1499
- data/doc/magick.html +0 -570
- data/doc/optequiv.html +0 -2435
- data/doc/rvg.html +0 -975
- data/doc/rvgclip.html +0 -248
- data/doc/rvggroup.html +0 -305
- data/doc/rvgimage.html +0 -289
- data/doc/rvgpattern.html +0 -475
- data/doc/rvgshape.html +0 -406
- data/doc/rvgstyle.html +0 -270
- data/doc/rvgtext.html +0 -465
- data/doc/rvgtspan.html +0 -238
- data/doc/rvgtut.html +0 -530
- data/doc/rvguse.html +0 -145
- data/doc/rvgxform.html +0 -294
- data/doc/scripts/doc.js +0 -22
- data/doc/scripts/stripeTables.js +0 -23
- data/doc/struct.html +0 -1339
- data/doc/usage.html +0 -1621
- data/examples/constitute.rb +0 -7
- data/examples/crop_with_gravity.rb +0 -42
- data/examples/demo.rb +0 -323
- data/examples/describe.rb +0 -41
- data/examples/find_similar_region.rb +0 -34
- data/examples/histogram.rb +0 -312
- data/examples/identify.rb +0 -174
- data/examples/image_opacity.rb +0 -28
- data/examples/import_export.rb +0 -31
- data/examples/pattern_fill.rb +0 -37
- data/examples/rotating_text.rb +0 -45
- data/examples/spinner.rb +0 -49
- data/examples/thumbnail.rb +0 -64
- data/examples/vignette.rb +0 -78
- data/lib/obsolete.rb +0 -66
- data/spec/rmagick/ImageList1_spec.rb +0 -24
- data/spec/rmagick/draw_spec.rb +0 -155
- data/spec/rmagick/image/blue_shift_spec.rb +0 -14
- data/spec/rmagick/image/channel_entropy_spec.rb +0 -9
- data/spec/rmagick/image/composite_spec.rb +0 -72
- data/spec/rmagick/image/constitute_spec.rb +0 -13
- data/spec/rmagick/image/dispatch_spec.rb +0 -16
- data/spec/rmagick/image/from_blob_spec.rb +0 -12
- data/spec/rmagick/image/ping_spec.rb +0 -12
- data/spec/rmagick/image/properties_spec.rb +0 -27
- data/spec/rmagick/image/read_spec.rb +0 -28
- data/spec/spec_helper.rb +0 -10
- data/spec/support/issue_200/app.rb +0 -8
- data/test/Draw.rb +0 -351
- data/test/Enum.rb +0 -228
- data/test/Fill.rb +0 -93
- data/test/Image1.rb +0 -627
- data/test/Image2.rb +0 -1426
- data/test/Image3.rb +0 -1091
- data/test/ImageList1.rb +0 -858
- data/test/ImageList2.rb +0 -406
- data/test/Image_attributes.rb +0 -666
- data/test/Import_Export.rb +0 -115
- data/test/Info.rb +0 -444
- data/test/KernelInfo.rb +0 -67
- data/test/Magick.rb +0 -311
- data/test/Pixel.rb +0 -285
- data/test/PolaroidOptions.rb +0 -23
- data/test/Preview.rb +0 -26
- data/test/Struct.rb +0 -45
- data/test/appearance/Montage.rb +0 -26
- data/test/appearance/appearance_assertion.rb +0 -13
- data/test/appearance/expected/montage_border_color.jpg +0 -0
- data/test/cmyk.icm +0 -0
- data/test/lib/Obsolete.rb +0 -30
- data/test/lib/internal/Draw.rb +0 -823
- data/test/lib/internal/Geometry.rb +0 -98
- data/test/lib/internal/Magick.rb +0 -40
- data/test/srgb.icm +0 -0
- data/test/test_all_basic.rb +0 -49
- data/test/tmpnam_test.rb +0 -50
data/test/Image1.rb
DELETED
@@ -1,627 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby -w
|
2
|
-
|
3
|
-
require 'rmagick'
|
4
|
-
require 'test/unit'
|
5
|
-
require 'test/unit/ui/console/testrunner'
|
6
|
-
|
7
|
-
class Image1_UT < Test::Unit::TestCase
|
8
|
-
def setup
|
9
|
-
@img = Magick::Image.new(20, 20)
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_class_type
|
13
|
-
assert_raise(ArgumentError) { @img.class_type = Magick::UndefinedClass }
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_constitute
|
17
|
-
pixels = @img.dispatch(0, 0, @img.columns, @img.rows, 'RGBA')
|
18
|
-
res = Magick::Image.constitute(@img.columns, @img.rows, 'RGBA', pixels)
|
19
|
-
assert_equal(res.columns, @img.columns)
|
20
|
-
assert_equal(res.rows, @img.rows)
|
21
|
-
|
22
|
-
assert_nothing_raised { Magick::Image.constitute(@img.columns, @img.rows, 'RGBA', [1.0] * (4 * @img.columns * @img.rows)) }
|
23
|
-
assert_raise(TypeError) { Magick::Image.constitute(@img.columns, @img.rows, 'RGBA', ['x'] * (4 * @img.columns * @img.rows)) }
|
24
|
-
assert_raise(ArgumentError) { Magick::Image.constitute(0, @img.rows, 'RGBA', pixels) }
|
25
|
-
assert_raise(ArgumentError) { Magick::Image.constitute(@img.columns, 0, 'RGBA', pixels) }
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_read_inline
|
29
|
-
img = Magick::Image.read(IMAGES_DIR + '/Button_0.gif').first
|
30
|
-
blob = img.to_blob
|
31
|
-
encoded = [blob].pack('m*')
|
32
|
-
res = Magick::Image.read_inline(encoded)
|
33
|
-
assert_instance_of(Array, res)
|
34
|
-
assert_instance_of(Magick::Image, res[0])
|
35
|
-
assert_equal(img, res[0])
|
36
|
-
assert_raise(ArgumentError) { Magick::Image.read(nil) }
|
37
|
-
assert_raise(ArgumentError) { Magick::Image.read("") }
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_spaceship
|
41
|
-
img0 = Magick::Image.read(IMAGES_DIR + '/Button_0.gif').first
|
42
|
-
img1 = Magick::Image.read(IMAGES_DIR + '/Button_1.gif').first
|
43
|
-
sig0 = img0.signature
|
44
|
-
sig1 = img1.signature
|
45
|
-
# since <=> is based on the signature, the images should
|
46
|
-
# have the same relationship to each other as their
|
47
|
-
# signatures have to each other.
|
48
|
-
assert_equal(sig0 <=> sig1, img0 <=> img1)
|
49
|
-
assert_equal(sig1 <=> sig0, img1 <=> img0)
|
50
|
-
assert_equal(img0, img0)
|
51
|
-
assert_not_equal(img0, img1)
|
52
|
-
assert_nil(img0 <=> nil)
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_adaptive_blur
|
56
|
-
assert_nothing_raised do
|
57
|
-
res = @img.adaptive_blur
|
58
|
-
assert_instance_of(Magick::Image, res)
|
59
|
-
end
|
60
|
-
assert_nothing_raised { @img.adaptive_blur(2) }
|
61
|
-
assert_nothing_raised { @img.adaptive_blur(3, 2) }
|
62
|
-
assert_raise(ArgumentError) { @img.adaptive_blur(3, 2, 2) }
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_adaptive_blur_channel
|
66
|
-
assert_nothing_raised do
|
67
|
-
res = @img.adaptive_blur_channel
|
68
|
-
assert_instance_of(Magick::Image, res)
|
69
|
-
end
|
70
|
-
assert_nothing_raised { @img.adaptive_blur_channel(2) }
|
71
|
-
assert_nothing_raised { @img.adaptive_blur_channel(3, 2) }
|
72
|
-
assert_nothing_raised { @img.adaptive_blur_channel(3, 2, Magick::RedChannel) }
|
73
|
-
assert_nothing_raised { @img.adaptive_blur_channel(3, 2, Magick::RedChannel, Magick::BlueChannel) }
|
74
|
-
assert_raise(TypeError) { @img.adaptive_blur_channel(3, 2, 2) }
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_adaptive_resize
|
78
|
-
assert_nothing_raised do
|
79
|
-
res = @img.adaptive_resize(10, 10)
|
80
|
-
assert_instance_of(Magick::Image, res)
|
81
|
-
end
|
82
|
-
assert_nothing_raised { @img.adaptive_resize(2) }
|
83
|
-
assert_raise(ArgumentError) { @img.adaptive_resize(-1.0) }
|
84
|
-
assert_raise(ArgumentError) { @img.adaptive_resize(10, 10, 10) }
|
85
|
-
assert_raise(ArgumentError) { @img.adaptive_resize }
|
86
|
-
assert_raise(RangeError) { @img.adaptive_resize(Float::MAX) }
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_adaptive_sharpen
|
90
|
-
assert_nothing_raised do
|
91
|
-
res = @img.adaptive_sharpen
|
92
|
-
assert_instance_of(Magick::Image, res)
|
93
|
-
end
|
94
|
-
assert_nothing_raised { @img.adaptive_sharpen(2) }
|
95
|
-
assert_nothing_raised { @img.adaptive_sharpen(3, 2) }
|
96
|
-
assert_raise(ArgumentError) { @img.adaptive_sharpen(3, 2, 2) }
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_adaptive_sharpen_channel
|
100
|
-
assert_nothing_raised do
|
101
|
-
res = @img.adaptive_sharpen_channel
|
102
|
-
assert_instance_of(Magick::Image, res)
|
103
|
-
end
|
104
|
-
assert_nothing_raised { @img.adaptive_sharpen_channel(2) }
|
105
|
-
assert_nothing_raised { @img.adaptive_sharpen_channel(3, 2) }
|
106
|
-
assert_nothing_raised { @img.adaptive_sharpen_channel(3, 2, Magick::RedChannel) }
|
107
|
-
assert_nothing_raised { @img.adaptive_sharpen_channel(3, 2, Magick::RedChannel, Magick::BlueChannel) }
|
108
|
-
assert_raise(TypeError) { @img.adaptive_sharpen_channel(3, 2, 2) }
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_adaptive_threshold
|
112
|
-
assert_nothing_raised do
|
113
|
-
res = @img.adaptive_threshold
|
114
|
-
assert_instance_of(Magick::Image, res)
|
115
|
-
end
|
116
|
-
assert_nothing_raised { @img.adaptive_threshold(2) }
|
117
|
-
assert_nothing_raised { @img.adaptive_threshold(2, 4) }
|
118
|
-
assert_nothing_raised { @img.adaptive_threshold(2, 4, 1) }
|
119
|
-
assert_raise(ArgumentError) { @img.adaptive_threshold(2, 4, 1, 2) }
|
120
|
-
end
|
121
|
-
|
122
|
-
def test_add_compose_mask
|
123
|
-
mask = Magick::Image.new(20, 20)
|
124
|
-
assert_nothing_raised { @img.add_compose_mask(mask) }
|
125
|
-
assert_nothing_raised { @img.delete_compose_mask }
|
126
|
-
assert_nothing_raised { @img.add_compose_mask(mask) }
|
127
|
-
assert_nothing_raised { @img.add_compose_mask(mask) }
|
128
|
-
assert_nothing_raised { @img.delete_compose_mask }
|
129
|
-
assert_nothing_raised { @img.delete_compose_mask }
|
130
|
-
|
131
|
-
mask = Magick::Image.new(10, 10)
|
132
|
-
assert_raise(ArgumentError) { @img.add_compose_mask(mask) }
|
133
|
-
end
|
134
|
-
|
135
|
-
def test_add_noise
|
136
|
-
Magick::NoiseType.values do |noise|
|
137
|
-
assert_nothing_raised { @img.add_noise(noise) }
|
138
|
-
end
|
139
|
-
assert_raise(TypeError) { @img.add_noise(0) }
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_add_noise_channel
|
143
|
-
assert_nothing_raised { @img.add_noise_channel(Magick::UniformNoise) }
|
144
|
-
assert_nothing_raised { @img.add_noise_channel(Magick::UniformNoise, Magick::RedChannel) }
|
145
|
-
assert_nothing_raised { @img.add_noise_channel(Magick::GaussianNoise, Magick::BlueChannel) }
|
146
|
-
assert_nothing_raised { @img.add_noise_channel(Magick::ImpulseNoise, Magick::GreenChannel) }
|
147
|
-
assert_nothing_raised { @img.add_noise_channel(Magick::LaplacianNoise, Magick::RedChannel, Magick::GreenChannel) }
|
148
|
-
assert_nothing_raised { @img.add_noise_channel(Magick::PoissonNoise, Magick::RedChannel, Magick::GreenChannel, Magick::BlueChannel) }
|
149
|
-
|
150
|
-
# Not a NoiseType
|
151
|
-
assert_raise(TypeError) { @img.add_noise_channel(1) }
|
152
|
-
# Not a ChannelType
|
153
|
-
assert_raise(TypeError) { @img.add_noise_channel(Magick::UniformNoise, Magick::RedChannel, 1) }
|
154
|
-
# Too few arguments
|
155
|
-
assert_raise(ArgumentError) { @img.add_noise_channel }
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_add_delete_profile
|
159
|
-
img = Magick::Image.read(IMAGES_DIR + '/Button_0.gif').first
|
160
|
-
assert_nothing_raised { img.add_profile(File.join(__dir__, 'cmyk.icm')) }
|
161
|
-
# assert_raise(Magick::ImageMagickError) { img.add_profile(File.join(__dir__, 'srgb.icm')) }
|
162
|
-
|
163
|
-
img.each_profile { |name, _value| assert_equal('icc', name) }
|
164
|
-
assert_nothing_raised { img.delete_profile('icc') }
|
165
|
-
end
|
166
|
-
|
167
|
-
def test_affine_matrix
|
168
|
-
affine = Magick::AffineMatrix.new(1, Math::PI / 6, Math::PI / 6, 1, 0, 0)
|
169
|
-
assert_nothing_raised { @img.affine_transform(affine) }
|
170
|
-
assert_raise(TypeError) { @img.affine_transform(0) }
|
171
|
-
res = @img.affine_transform(affine)
|
172
|
-
assert_instance_of(Magick::Image, res)
|
173
|
-
end
|
174
|
-
|
175
|
-
# test alpha backward compatibility. Image#alpha w/o arguments acts like alpha?
|
176
|
-
def test_alpha_compat
|
177
|
-
assert_nothing_raised { @img.alpha }
|
178
|
-
assert !@img.alpha
|
179
|
-
assert_nothing_raised { @img.alpha Magick::ActivateAlphaChannel }
|
180
|
-
assert @img.alpha
|
181
|
-
end
|
182
|
-
|
183
|
-
def test_alpha
|
184
|
-
assert_nothing_raised { @img.alpha? }
|
185
|
-
assert !@img.alpha?
|
186
|
-
assert_nothing_raised { @img.alpha Magick::ActivateAlphaChannel }
|
187
|
-
assert @img.alpha?
|
188
|
-
assert_nothing_raised { @img.alpha Magick::DeactivateAlphaChannel }
|
189
|
-
assert !@img.alpha?
|
190
|
-
assert_nothing_raised { @img.alpha Magick::OpaqueAlphaChannel }
|
191
|
-
assert_nothing_raised { @img.alpha Magick::SetAlphaChannel }
|
192
|
-
assert_raise(ArgumentError) { @img.alpha Magick::SetAlphaChannel, Magick::OpaqueAlphaChannel }
|
193
|
-
@img.freeze
|
194
|
-
assert_raise(FreezeError) { @img.alpha Magick::SetAlphaChannel }
|
195
|
-
end
|
196
|
-
|
197
|
-
def test_aref
|
198
|
-
img = Magick::Image.read(IMAGES_DIR + '/Button_0.gif').first
|
199
|
-
assert_nil(img[nil])
|
200
|
-
assert_nil(img['label'])
|
201
|
-
assert_match(/^Creator: PolyView/, img[:comment])
|
202
|
-
end
|
203
|
-
|
204
|
-
def test_aset
|
205
|
-
@img['label'] = 'foobarbaz'
|
206
|
-
@img[:comment] = 'Hello world'
|
207
|
-
assert_equal('foobarbaz', @img['label'])
|
208
|
-
assert_equal('Hello world', @img['comment'])
|
209
|
-
assert_nothing_raised { @img[nil] = 'foobarbaz' }
|
210
|
-
end
|
211
|
-
|
212
|
-
def test_auto_gamma
|
213
|
-
res = nil
|
214
|
-
assert_nothing_raised { res = @img.auto_gamma_channel }
|
215
|
-
assert_instance_of(Magick::Image, res)
|
216
|
-
assert_not_same(@img, res)
|
217
|
-
assert_nothing_raised { res = @img.auto_gamma_channel Magick::RedChannel }
|
218
|
-
assert_nothing_raised { res = @img.auto_gamma_channel Magick::RedChannel, Magick::BlueChannel }
|
219
|
-
assert_raise(TypeError) { @img.auto_gamma_channel(1) }
|
220
|
-
end
|
221
|
-
|
222
|
-
def test_auto_level
|
223
|
-
res = nil
|
224
|
-
assert_nothing_raised { res = @img.auto_level_channel }
|
225
|
-
assert_instance_of(Magick::Image, res)
|
226
|
-
assert_not_same(@img, res)
|
227
|
-
assert_nothing_raised { res = @img.auto_level_channel Magick::RedChannel }
|
228
|
-
assert_nothing_raised { res = @img.auto_level_channel Magick::RedChannel, Magick::BlueChannel }
|
229
|
-
assert_raise(TypeError) { @img.auto_level_channel(1) }
|
230
|
-
end
|
231
|
-
|
232
|
-
def test_auto_orient
|
233
|
-
Magick::OrientationType.values.each do |v|
|
234
|
-
assert_nothing_raised do
|
235
|
-
img = Magick::Image.new(10, 10)
|
236
|
-
img.orientation = v
|
237
|
-
res = img.auto_orient
|
238
|
-
assert_instance_of(Magick::Image, res)
|
239
|
-
assert_not_same(img, res)
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
assert_nothing_raised do
|
244
|
-
res = @img.auto_orient!
|
245
|
-
# When not changed, returns nil
|
246
|
-
assert_nil(res)
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
def test_bilevel_channel
|
251
|
-
assert_raise(ArgumentError) { @img.bilevel_channel }
|
252
|
-
assert_nothing_raised { @img.bilevel_channel(100) }
|
253
|
-
assert_nothing_raised { @img.bilevel_channel(100, Magick::RedChannel) }
|
254
|
-
assert_nothing_raised { @img.bilevel_channel(100, Magick::RedChannel, Magick::BlueChannel, Magick::GreenChannel, Magick::OpacityChannel) }
|
255
|
-
assert_nothing_raised { @img.bilevel_channel(100, Magick::CyanChannel, Magick::MagentaChannel, Magick::YellowChannel, Magick::BlackChannel) }
|
256
|
-
assert_nothing_raised { @img.bilevel_channel(100, Magick::GrayChannel) }
|
257
|
-
assert_nothing_raised { @img.bilevel_channel(100, Magick::AllChannels) }
|
258
|
-
assert_raise(TypeError) { @img.bilevel_channel(100, 2) }
|
259
|
-
res = @img.bilevel_channel(100)
|
260
|
-
assert_instance_of(Magick::Image, res)
|
261
|
-
end
|
262
|
-
|
263
|
-
def test_blend
|
264
|
-
@img2 = Magick::Image.new(20, 20) { self.background_color = 'black' }
|
265
|
-
assert_nothing_raised { @img.blend(@img2, 0.25) }
|
266
|
-
res = @img.blend(@img2, 0.25)
|
267
|
-
|
268
|
-
Magick::GravityType.values do |gravity|
|
269
|
-
assert_nothing_raised { @img.blend(@img2, 0.25, 0.75, gravity) }
|
270
|
-
assert_nothing_raised { @img.blend(@img2, 0.25, 0.75, gravity, 10) }
|
271
|
-
assert_nothing_raised { @img.blend(@img2, 0.25, 0.75, gravity, 10, 10) }
|
272
|
-
end
|
273
|
-
|
274
|
-
assert_instance_of(Magick::Image, res)
|
275
|
-
assert_nothing_raised { @img.blend(@img2, '25%') }
|
276
|
-
assert_nothing_raised { @img.blend(@img2, 0.25, 0.75) }
|
277
|
-
assert_nothing_raised { @img.blend(@img2, '25%', '75%') }
|
278
|
-
assert_raise(ArgumentError) { @img.blend }
|
279
|
-
assert_raise(ArgumentError) { @img.blend(@img2, 'x') }
|
280
|
-
assert_raise(TypeError) { @img.blend(@img2, 0.25, []) }
|
281
|
-
assert_raise(TypeError) { @img.blend(@img2, 0.25, 0.75, 'x') }
|
282
|
-
assert_raise(TypeError) { @img.blend(@img2, 0.25, 0.75, Magick::CenterGravity, 'x') }
|
283
|
-
assert_raise(TypeError) { @img.blend(@img2, 0.25, 0.75, Magick::CenterGravity, 10, []) }
|
284
|
-
|
285
|
-
@img2.destroy!
|
286
|
-
assert_raise(Magick::DestroyedImageError) { @img.blend(@img2, '25%') }
|
287
|
-
end
|
288
|
-
|
289
|
-
def test_blue_shift
|
290
|
-
assert_not_same(@img, @img.blue_shift)
|
291
|
-
assert_not_same(@img, @img.blue_shift(2.0))
|
292
|
-
assert_raise(TypeError) { @img.blue_shift('x') }
|
293
|
-
assert_raise(ArgumentError) { @img.blue_shift(2, 2) }
|
294
|
-
end
|
295
|
-
|
296
|
-
def test_blur_channel
|
297
|
-
assert_nothing_raised { @img.blur_channel }
|
298
|
-
assert_nothing_raised { @img.blur_channel(1) }
|
299
|
-
assert_nothing_raised { @img.blur_channel(1, 2) }
|
300
|
-
assert_nothing_raised { @img.blur_channel(1, 2, Magick::RedChannel) }
|
301
|
-
assert_nothing_raised { @img.blur_channel(1, 2, Magick::RedChannel, Magick::BlueChannel, Magick::GreenChannel, Magick::OpacityChannel) }
|
302
|
-
assert_nothing_raised { @img.blur_channel(1, 2, Magick::CyanChannel, Magick::MagentaChannel, Magick::YellowChannel, Magick::BlackChannel) }
|
303
|
-
assert_nothing_raised { @img.blur_channel(1, 2, Magick::GrayChannel) }
|
304
|
-
assert_nothing_raised { @img.blur_channel(1, 2, Magick::AllChannels) }
|
305
|
-
assert_raise(TypeError) { @img.blur_channel(1, 2, 2) }
|
306
|
-
res = @img.blur_channel
|
307
|
-
assert_instance_of(Magick::Image, res)
|
308
|
-
end
|
309
|
-
|
310
|
-
def test_blur_image
|
311
|
-
assert_nothing_raised { @img.blur_image }
|
312
|
-
assert_nothing_raised { @img.blur_image(1) }
|
313
|
-
assert_nothing_raised { @img.blur_image(1, 2) }
|
314
|
-
assert_raise(ArgumentError) { @img.blur_image(1, 2, 3) }
|
315
|
-
res = @img.blur_image
|
316
|
-
assert_instance_of(Magick::Image, res)
|
317
|
-
end
|
318
|
-
|
319
|
-
def test_black_threshold
|
320
|
-
assert_raise(ArgumentError) { @img.black_threshold }
|
321
|
-
assert_nothing_raised { @img.black_threshold(50) }
|
322
|
-
assert_nothing_raised { @img.black_threshold(50, 50) }
|
323
|
-
assert_nothing_raised { @img.black_threshold(50, 50, 50) }
|
324
|
-
assert_nothing_raised { @img.black_threshold(50, 50, 50, 50) }
|
325
|
-
assert_nothing_raised { @img.black_threshold(50, 50, 50, alpha: 50) }
|
326
|
-
assert_raise(ArgumentError) { @img.black_threshold(50, 50, 50, wrong: 50) }
|
327
|
-
assert_raise(ArgumentError) { @img.black_threshold(50, 50, 50, alpha: 50, extra: 50) }
|
328
|
-
assert_raise(ArgumentError) { @img.black_threshold(50, 50, 50, 50, 50) }
|
329
|
-
res = @img.black_threshold(50)
|
330
|
-
assert_instance_of(Magick::Image, res)
|
331
|
-
end
|
332
|
-
|
333
|
-
def test_border
|
334
|
-
assert_nothing_raised { @img.border(2, 2, 'red') }
|
335
|
-
assert_nothing_raised { @img.border!(2, 2, 'red') }
|
336
|
-
res = @img.border(2, 2, 'red')
|
337
|
-
assert_instance_of(Magick::Image, res)
|
338
|
-
@img.freeze
|
339
|
-
assert_raise(FreezeError) { @img.border!(2, 2, 'red') }
|
340
|
-
end
|
341
|
-
|
342
|
-
def test_capture
|
343
|
-
# assert_nothing_raised { Magick::Image.capture }
|
344
|
-
# assert_nothing_raised { Magick::Image.capture(true) }
|
345
|
-
# assert_nothing_raised { Magick::Image.capture(true, true) }
|
346
|
-
# assert_nothing_raised { Magick::Image.capture(true, true, true) }
|
347
|
-
# assert_nothing_raised { Magick::Image.capture(true, true, true, true) }
|
348
|
-
# assert_nothing_raised { Magick::Image.capture(true, true, true, true, true) }
|
349
|
-
assert_raise(ArgumentError) { Magick::Image.capture(true, true, true, true, true, true) }
|
350
|
-
end
|
351
|
-
|
352
|
-
def test_change_geometry
|
353
|
-
assert_raise(ArgumentError) { @img.change_geometry('sss') }
|
354
|
-
assert_raise(LocalJumpError) { @img.change_geometry('100x100') }
|
355
|
-
assert_nothing_raised do
|
356
|
-
res = @img.change_geometry('100x100') { 1 }
|
357
|
-
assert_equal(1, res)
|
358
|
-
end
|
359
|
-
assert_raise(ArgumentError) { @img.change_geometry([]) }
|
360
|
-
end
|
361
|
-
|
362
|
-
def test_changed?
|
363
|
-
# assert_block { !@img.changed? }
|
364
|
-
# @img.pixel_color(0,0,'red')
|
365
|
-
# assert_block { @img.changed? }
|
366
|
-
end
|
367
|
-
|
368
|
-
def test_channel
|
369
|
-
Magick::ChannelType.values do |channel|
|
370
|
-
assert_nothing_raised { @img.channel(channel) }
|
371
|
-
end
|
372
|
-
|
373
|
-
assert_instance_of(Magick::Image, @img.channel(Magick::RedChannel))
|
374
|
-
assert_raise(TypeError) { @img.channel(2) }
|
375
|
-
end
|
376
|
-
|
377
|
-
def test_channel_depth
|
378
|
-
assert_nothing_raised { @img.channel_depth }
|
379
|
-
assert_nothing_raised { @img.channel_depth(Magick::RedChannel) }
|
380
|
-
assert_nothing_raised { @img.channel_depth(Magick::RedChannel, Magick::BlueChannel) }
|
381
|
-
assert_nothing_raised { @img.channel_depth(Magick::GreenChannel, Magick::OpacityChannel) }
|
382
|
-
assert_nothing_raised { @img.channel_depth(Magick::MagentaChannel, Magick::CyanChannel) }
|
383
|
-
assert_nothing_raised { @img.channel_depth(Magick::CyanChannel, Magick::BlackChannel) }
|
384
|
-
assert_nothing_raised { @img.channel_depth(Magick::GrayChannel) }
|
385
|
-
assert_raise(TypeError) { @img.channel_depth(2) }
|
386
|
-
assert_kind_of(Integer, @img.channel_depth(Magick::RedChannel))
|
387
|
-
end
|
388
|
-
|
389
|
-
def test_channel_extrema
|
390
|
-
assert_nothing_raised do
|
391
|
-
res = @img.channel_extrema
|
392
|
-
assert_instance_of(Array, res)
|
393
|
-
assert_equal(2, res.length)
|
394
|
-
assert_kind_of(Integer, res[0])
|
395
|
-
assert_kind_of(Integer, res[1])
|
396
|
-
end
|
397
|
-
assert_nothing_raised { @img.channel_extrema(Magick::RedChannel) }
|
398
|
-
assert_nothing_raised { @img.channel_extrema(Magick::RedChannel, Magick::BlueChannel) }
|
399
|
-
assert_nothing_raised { @img.channel_extrema(Magick::GreenChannel, Magick::OpacityChannel) }
|
400
|
-
assert_nothing_raised { @img.channel_extrema(Magick::MagentaChannel, Magick::CyanChannel) }
|
401
|
-
assert_nothing_raised { @img.channel_extrema(Magick::CyanChannel, Magick::BlackChannel) }
|
402
|
-
assert_nothing_raised { @img.channel_extrema(Magick::GrayChannel) }
|
403
|
-
assert_raise(TypeError) { @img.channel_extrema(2) }
|
404
|
-
end
|
405
|
-
|
406
|
-
def test_channel_mean
|
407
|
-
assert_nothing_raised do
|
408
|
-
res = @img.channel_mean
|
409
|
-
assert_instance_of(Array, res)
|
410
|
-
assert_equal(2, res.length)
|
411
|
-
assert_instance_of(Float, res[0])
|
412
|
-
assert_instance_of(Float, res[1])
|
413
|
-
end
|
414
|
-
assert_nothing_raised { @img.channel_mean(Magick::RedChannel) }
|
415
|
-
assert_nothing_raised { @img.channel_mean(Magick::RedChannel, Magick::BlueChannel) }
|
416
|
-
assert_nothing_raised { @img.channel_mean(Magick::GreenChannel, Magick::OpacityChannel) }
|
417
|
-
assert_nothing_raised { @img.channel_mean(Magick::MagentaChannel, Magick::CyanChannel) }
|
418
|
-
assert_nothing_raised { @img.channel_mean(Magick::CyanChannel, Magick::BlackChannel) }
|
419
|
-
assert_nothing_raised { @img.channel_mean(Magick::GrayChannel) }
|
420
|
-
assert_raise(TypeError) { @img.channel_mean(2) }
|
421
|
-
end
|
422
|
-
|
423
|
-
def test_charcoal
|
424
|
-
assert_nothing_raised do
|
425
|
-
res = @img.charcoal
|
426
|
-
assert_instance_of(Magick::Image, res)
|
427
|
-
end
|
428
|
-
assert_nothing_raised { @img.charcoal(1.0) }
|
429
|
-
assert_nothing_raised { @img.charcoal(1.0, 2.0) }
|
430
|
-
assert_raise(ArgumentError) { @img.charcoal(1.0, 2.0, 3.0) }
|
431
|
-
end
|
432
|
-
|
433
|
-
def test_chop
|
434
|
-
assert_nothing_raised do
|
435
|
-
res = @img.chop(10, 10, 10, 10)
|
436
|
-
assert_instance_of(Magick::Image, res)
|
437
|
-
end
|
438
|
-
end
|
439
|
-
|
440
|
-
def test_clone
|
441
|
-
assert_nothing_raised do
|
442
|
-
res = @img.clone
|
443
|
-
assert_instance_of(Magick::Image, res)
|
444
|
-
assert_equal(res, @img)
|
445
|
-
end
|
446
|
-
res = @img.clone
|
447
|
-
assert_equal(res.frozen?, @img.frozen?)
|
448
|
-
@img.freeze
|
449
|
-
res = @img.clone
|
450
|
-
assert_equal(res.frozen?, @img.frozen?)
|
451
|
-
end
|
452
|
-
|
453
|
-
def test_clut_channel
|
454
|
-
img = Magick::Image.new(20, 20) { self.colorspace = Magick::GRAYColorspace }
|
455
|
-
clut = Magick::Image.new(20, 1) { self.background_color = 'red' }
|
456
|
-
res = nil
|
457
|
-
assert_nothing_raised { res = img.clut_channel(clut) }
|
458
|
-
assert_same(res, img)
|
459
|
-
assert_nothing_raised { img.clut_channel(clut, Magick::RedChannel) }
|
460
|
-
assert_nothing_raised { img.clut_channel(clut, Magick::RedChannel, Magick::BlueChannel) }
|
461
|
-
assert_raises(ArgumentError) { img.clut_channel }
|
462
|
-
assert_raises(ArgumentError) { img.clut_channel(clut, 1, Magick::RedChannel) }
|
463
|
-
end
|
464
|
-
|
465
|
-
def test_color_fill_to_border
|
466
|
-
assert_raise(ArgumentError) { @img.color_fill_to_border(-1, 1, 'red') }
|
467
|
-
assert_raise(ArgumentError) { @img.color_fill_to_border(1, 100, 'red') }
|
468
|
-
assert_nothing_raised do
|
469
|
-
res = @img.color_fill_to_border(@img.columns / 2, @img.rows / 2, 'red')
|
470
|
-
assert_instance_of(Magick::Image, res)
|
471
|
-
end
|
472
|
-
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
473
|
-
assert_nothing_raised { @img.color_fill_to_border(@img.columns / 2, @img.rows / 2, pixel) }
|
474
|
-
end
|
475
|
-
|
476
|
-
def test_color_floodfill
|
477
|
-
assert_raise(ArgumentError) { @img.color_floodfill(-1, 1, 'red') }
|
478
|
-
assert_raise(ArgumentError) { @img.color_floodfill(1, 100, 'red') }
|
479
|
-
assert_nothing_raised do
|
480
|
-
res = @img.color_floodfill(@img.columns / 2, @img.rows / 2, 'red')
|
481
|
-
assert_instance_of(Magick::Image, res)
|
482
|
-
end
|
483
|
-
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
484
|
-
assert_nothing_raised { @img.color_floodfill(@img.columns / 2, @img.rows / 2, pixel) }
|
485
|
-
end
|
486
|
-
|
487
|
-
def test_color_histogram
|
488
|
-
assert_nothing_raised do
|
489
|
-
res = @img.color_histogram
|
490
|
-
assert_instance_of(Hash, res)
|
491
|
-
end
|
492
|
-
assert_nothing_raised do
|
493
|
-
@img.class_type = Magick::PseudoClass
|
494
|
-
res = @img.color_histogram
|
495
|
-
assert_equal(Magick::PseudoClass, @img.class_type)
|
496
|
-
assert_instance_of(Hash, res)
|
497
|
-
end
|
498
|
-
end
|
499
|
-
|
500
|
-
def test_colorize
|
501
|
-
assert_nothing_raised do
|
502
|
-
res = @img.colorize(0.25, 0.25, 0.25, 'red')
|
503
|
-
assert_instance_of(Magick::Image, res)
|
504
|
-
end
|
505
|
-
assert_nothing_raised { @img.colorize(0.25, 0.25, 0.25, 0.25, 'red') }
|
506
|
-
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
507
|
-
assert_nothing_raised { @img.colorize(0.25, 0.25, 0.25, pixel) }
|
508
|
-
assert_nothing_raised { @img.colorize(0.25, 0.25, 0.25, 0.25, pixel) }
|
509
|
-
assert_raise(ArgumentError) { @img.colorize }
|
510
|
-
assert_raise(ArgumentError) { @img.colorize(0.25) }
|
511
|
-
assert_raise(ArgumentError) { @img.colorize(0.25, 0.25) }
|
512
|
-
assert_raise(ArgumentError) { @img.colorize(0.25, 0.25, 0.25) }
|
513
|
-
assert_raise(ArgumentError) { @img.colorize(0.25, 0.25, 0.25, 'X') }
|
514
|
-
# last argument must be a color name or pixel
|
515
|
-
assert_raise(TypeError) { @img.colorize(0.25, 0.25, 0.25, 0.25) }
|
516
|
-
assert_raise(ArgumentError) { @img.colorize(0.25, 0.25, 0.25, 0.25, 'X') }
|
517
|
-
assert_raise(TypeError) { @img.colorize(0.25, 0.25, 0.25, 0.25, [2]) }
|
518
|
-
end
|
519
|
-
|
520
|
-
def test_colormap
|
521
|
-
# IndexError b/c @img is DirectClass
|
522
|
-
assert_raise(IndexError) { @img.colormap(0) }
|
523
|
-
# Read PseudoClass image
|
524
|
-
pc_img = Magick::Image.read(IMAGES_DIR + '/Button_0.gif').first
|
525
|
-
assert_nothing_raised { pc_img.colormap(0) }
|
526
|
-
ncolors = pc_img.colors
|
527
|
-
assert_raise(IndexError) { pc_img.colormap(ncolors + 1) }
|
528
|
-
assert_raise(IndexError) { pc_img.colormap(-1) }
|
529
|
-
assert_nothing_raised { pc_img.colormap(ncolors - 1) }
|
530
|
-
res = pc_img.colormap(0)
|
531
|
-
assert_instance_of(String, res)
|
532
|
-
|
533
|
-
# test 'set' operation
|
534
|
-
assert_nothing_raised do
|
535
|
-
old_color = pc_img.colormap(0)
|
536
|
-
res = pc_img.colormap(0, 'red')
|
537
|
-
assert_equal(old_color, res)
|
538
|
-
res = pc_img.colormap(0)
|
539
|
-
assert_equal('red', res)
|
540
|
-
end
|
541
|
-
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
542
|
-
assert_nothing_raised { pc_img.colormap(0, pixel) }
|
543
|
-
assert_raise(ArgumentError) { pc_img.colormap }
|
544
|
-
assert_raise(ArgumentError) { pc_img.colormap(0, pixel, Magick::BlackChannel) }
|
545
|
-
assert_raise(TypeError) { pc_img.colormap(0, [2]) }
|
546
|
-
pc_img.freeze
|
547
|
-
assert_raise(FreezeError) { pc_img.colormap(0, 'red') }
|
548
|
-
end
|
549
|
-
|
550
|
-
def test_color_point
|
551
|
-
assert_nothing_raised do
|
552
|
-
res = @img.color_point(0, 0, 'red')
|
553
|
-
assert_instance_of(Magick::Image, res)
|
554
|
-
assert_not_same(@img, res)
|
555
|
-
end
|
556
|
-
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
557
|
-
assert_nothing_raised { @img.color_point(0, 0, pixel) }
|
558
|
-
end
|
559
|
-
|
560
|
-
def test_color_reset!
|
561
|
-
assert_nothing_raised do
|
562
|
-
res = @img.color_reset!('red')
|
563
|
-
assert_same(@img, res)
|
564
|
-
end
|
565
|
-
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
566
|
-
assert_nothing_raised { @img.color_reset!(pixel) }
|
567
|
-
assert_raise(TypeError) { @img.color_reset!([2]) }
|
568
|
-
assert_raise(ArgumentError) { @img.color_reset!('x') }
|
569
|
-
@img.freeze
|
570
|
-
assert_raise(FreezeError) { @img.color_reset!('red') }
|
571
|
-
end
|
572
|
-
|
573
|
-
def test_combine
|
574
|
-
r = Magick::Image.new(20, 20) { self.background_color = 'red' }
|
575
|
-
g = Magick::Image.new(20, 20) { self.background_color = 'green' }
|
576
|
-
b = Magick::Image.new(20, 20) { self.background_color = 'blue' }
|
577
|
-
a = Magick::Image.new(20, 20) { self.background_color = 'transparent' }
|
578
|
-
assert_nothing_raised { Magick::Image.combine(r) }
|
579
|
-
assert_nothing_raised { Magick::Image.combine(r, g) }
|
580
|
-
assert_nothing_raised { Magick::Image.combine(r, g, b) }
|
581
|
-
assert_nothing_raised { Magick::Image.combine(r, g, b, a) }
|
582
|
-
assert_nothing_raised { Magick::Image.combine(nil, g) }
|
583
|
-
assert_nothing_raised { Magick::Image.combine(r, nil, b) }
|
584
|
-
assert_nothing_raised { Magick::Image.combine(r, g, nil, a) }
|
585
|
-
assert_nothing_raised { Magick::Image.combine(r, g, b, nil) }
|
586
|
-
res = Magick::Image.combine(r, g, b)
|
587
|
-
assert_instance_of(Magick::Image, res)
|
588
|
-
assert_raise(ArgumentError) { Magick::Image.combine }
|
589
|
-
assert_raise(ArgumentError) { Magick::Image.combine(nil) }
|
590
|
-
assert_raise(ArgumentError) { Magick::Image.combine(r, g, b, a, r) }
|
591
|
-
assert_raise(TypeError) { Magick::Image.combine(1, g, b, a) }
|
592
|
-
end
|
593
|
-
|
594
|
-
def test_compare_channel
|
595
|
-
img1 = Magick::Image.read(IMAGES_DIR + '/Button_0.gif').first
|
596
|
-
img2 = Magick::Image.read(IMAGES_DIR + '/Button_1.gif').first
|
597
|
-
|
598
|
-
Magick::MetricType.values do |metric|
|
599
|
-
assert_nothing_raised { img1.compare_channel(img2, metric) }
|
600
|
-
end
|
601
|
-
assert_raise(TypeError) { img1.compare_channel(img2, 2) }
|
602
|
-
assert_raise(ArgumentError) { img1.compare_channel }
|
603
|
-
|
604
|
-
ilist = Magick::ImageList.new
|
605
|
-
ilist << img2
|
606
|
-
assert_nothing_raised { img1.compare_channel(ilist, Magick::MeanAbsoluteErrorMetric) }
|
607
|
-
|
608
|
-
assert_nothing_raised { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric, Magick::RedChannel) }
|
609
|
-
assert_nothing_raised { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric, Magick::RedChannel, Magick::BlueChannel) }
|
610
|
-
assert_raise(TypeError) { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric, 2) }
|
611
|
-
assert_raise(TypeError) { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric, Magick::RedChannel, 2) }
|
612
|
-
|
613
|
-
res = img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric)
|
614
|
-
assert_instance_of(Array, res)
|
615
|
-
assert_instance_of(Magick::Image, res[0])
|
616
|
-
assert_instance_of(Float, res[1])
|
617
|
-
|
618
|
-
img2.destroy!
|
619
|
-
assert_raise(Magick::DestroyedImageError) { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric) }
|
620
|
-
end
|
621
|
-
end
|
622
|
-
|
623
|
-
if $PROGRAM_NAME == __FILE__
|
624
|
-
IMAGES_DIR = '../doc/ex/images'
|
625
|
-
FILES = Dir[IMAGES_DIR + '/Button_*.gif']
|
626
|
-
Test::Unit::UI::Console::TestRunner.run(Image1UT)
|
627
|
-
end
|