rmagick 1.7.1
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.
- data/ChangeLog +232 -0
- data/Makefile.in +28 -0
- data/README.html +404 -0
- data/README.txt +397 -0
- data/configure +8554 -0
- data/configure.ac +497 -0
- data/doc/comtasks.html +241 -0
- data/doc/constants.html +1195 -0
- data/doc/css/doc.css +299 -0
- data/doc/css/popup.css +34 -0
- data/doc/draw.html +3108 -0
- data/doc/ex/Adispatch.rb +43 -0
- data/doc/ex/Zconstitute.rb +9 -0
- data/doc/ex/adaptive_threshold.rb +19 -0
- data/doc/ex/add_noise.rb +18 -0
- data/doc/ex/affine.rb +48 -0
- data/doc/ex/affine_transform.rb +20 -0
- data/doc/ex/arc.rb +47 -0
- data/doc/ex/arcpath.rb +33 -0
- data/doc/ex/average.rb +15 -0
- data/doc/ex/axes.rb +64 -0
- data/doc/ex/bilevel_channel.rb +20 -0
- data/doc/ex/blur_image.rb +12 -0
- data/doc/ex/border.rb +10 -0
- data/doc/ex/bounding_box.rb +48 -0
- data/doc/ex/cbezier1.rb +40 -0
- data/doc/ex/cbezier2.rb +40 -0
- data/doc/ex/cbezier3.rb +40 -0
- data/doc/ex/cbezier4.rb +41 -0
- data/doc/ex/cbezier5.rb +41 -0
- data/doc/ex/cbezier6.rb +51 -0
- data/doc/ex/channel.rb +26 -0
- data/doc/ex/channel_threshold.rb +48 -0
- data/doc/ex/charcoal.rb +12 -0
- data/doc/ex/chop.rb +29 -0
- data/doc/ex/circle.rb +31 -0
- data/doc/ex/clip_path.rb +56 -0
- data/doc/ex/coalesce.rb +60 -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 +60 -0
- data/doc/ex/color_reset.rb +11 -0
- data/doc/ex/colorize.rb +16 -0
- data/doc/ex/colors.rb +65 -0
- data/doc/ex/composite.rb +135 -0
- data/doc/ex/contrast.rb +37 -0
- data/doc/ex/crop.rb +31 -0
- data/doc/ex/crop_with_gravity.rb +46 -0
- data/doc/ex/cycle_colormap.rb +21 -0
- data/doc/ex/demo.rb +324 -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 +43 -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/flatten_images.rb +38 -0
- data/doc/ex/flip.rb +11 -0
- data/doc/ex/flop.rb +11 -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 +53 -0
- data/doc/ex/get_pixels.rb +48 -0
- data/doc/ex/get_type_metrics.rb +140 -0
- data/doc/ex/gradientfill.rb +27 -0
- data/doc/ex/grav.rb +44 -0
- data/doc/ex/gravity.rb +80 -0
- data/doc/ex/hatchfill.rb +27 -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/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/Shorts.jpg +0 -0
- data/doc/ex/images/Snake.wmf +0 -0
- data/doc/ex/images/Violin.jpg +0 -0
- data/doc/ex/images/graydient230x6.gif +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 +32 -0
- data/doc/ex/level.rb +12 -0
- data/doc/ex/level_channel.rb +33 -0
- data/doc/ex/line.rb +40 -0
- data/doc/ex/map.rb +28 -0
- data/doc/ex/map_f.rb +15 -0
- data/doc/ex/matte_fill_to_border.rb +42 -0
- data/doc/ex/matte_floodfill.rb +35 -0
- data/doc/ex/matte_replace.rb +42 -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 +26 -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 +19 -0
- data/doc/ex/normalize.rb +11 -0
- data/doc/ex/oil_paint.rb +11 -0
- data/doc/ex/opacity.rb +38 -0
- data/doc/ex/opaque.rb +14 -0
- data/doc/ex/ordered_dither.rb +11 -0
- data/doc/ex/path.rb +62 -0
- data/doc/ex/pattern1.rb +25 -0
- data/doc/ex/pattern2.rb +26 -0
- data/doc/ex/polygon.rb +24 -0
- data/doc/ex/polyline.rb +23 -0
- data/doc/ex/posterize.rb +19 -0
- data/doc/ex/preview.rb +16 -0
- data/doc/ex/qbezierpath.rb +49 -0
- data/doc/ex/quantize-m.rb +25 -0
- data/doc/ex/radial_blur.rb +19 -0
- data/doc/ex/raise.rb +11 -0
- data/doc/ex/random_channel_threshold.rb +17 -0
- data/doc/ex/random_threshold_channel.rb +18 -0
- data/doc/ex/rectangle.rb +33 -0
- data/doc/ex/reduce_noise.rb +28 -0
- data/doc/ex/roll.rb +9 -0
- data/doc/ex/rotate.rb +43 -0
- data/doc/ex/rotate_f.rb +14 -0
- data/doc/ex/roundrect.rb +32 -0
- data/doc/ex/rubyname.rb +31 -0
- data/doc/ex/segment.rb +11 -0
- data/doc/ex/shade.rb +11 -0
- data/doc/ex/shave.rb +15 -0
- data/doc/ex/shear.rb +10 -0
- data/doc/ex/skewx.rb +50 -0
- data/doc/ex/skewy.rb +45 -0
- data/doc/ex/smile.rb +124 -0
- data/doc/ex/solarize.rb +11 -0
- data/doc/ex/splice.rb +16 -0
- data/doc/ex/spread.rb +11 -0
- data/doc/ex/stegano.rb +50 -0
- data/doc/ex/stroke_dasharray.rb +41 -0
- data/doc/ex/stroke_linecap.rb +44 -0
- data/doc/ex/stroke_linejoin.rb +48 -0
- data/doc/ex/stroke_width.rb +47 -0
- data/doc/ex/swirl.rb +17 -0
- data/doc/ex/text.rb +32 -0
- data/doc/ex/text_align.rb +36 -0
- data/doc/ex/text_antialias.rb +33 -0
- data/doc/ex/text_undercolor.rb +26 -0
- data/doc/ex/texture_fill_to_border.rb +34 -0
- data/doc/ex/texture_floodfill.rb +31 -0
- data/doc/ex/texturefill.rb +25 -0
- data/doc/ex/threshold.rb +13 -0
- data/doc/ex/to_blob.rb +14 -0
- data/doc/ex/translate.rb +37 -0
- data/doc/ex/transparent.rb +38 -0
- data/doc/ex/trim.rb +25 -0
- data/doc/ex/unsharp_mask.rb +28 -0
- data/doc/ex/viewex.rb +36 -0
- data/doc/ex/wave.rb +9 -0
- data/doc/ilist.html +1592 -0
- data/doc/image1.html +3009 -0
- data/doc/image2.html +2169 -0
- data/doc/image3.html +2815 -0
- data/doc/imageattrs.html +1319 -0
- data/doc/imusage.html +403 -0
- data/doc/index.html +418 -0
- data/doc/info.html +949 -0
- data/doc/magick.html +439 -0
- data/doc/scripts/doc.js +9 -0
- data/doc/struct.html +1334 -0
- data/doc/usage.html +1318 -0
- data/examples/describe.rb +44 -0
- data/examples/histogram.rb +289 -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 +47 -0
- data/examples/thumbnail.rb +65 -0
- data/examples/vignette.rb +79 -0
- data/ext/RMagick/MANIFEST +239 -0
- data/ext/RMagick/extconf.rb.in +21 -0
- data/ext/RMagick/rmagick.h +938 -0
- data/ext/RMagick/rmagick_config.h.in +170 -0
- data/ext/RMagick/rmdraw.c +1308 -0
- data/ext/RMagick/rmfill.c +609 -0
- data/ext/RMagick/rmilist.c +685 -0
- data/ext/RMagick/rmimage.c +7980 -0
- data/ext/RMagick/rminfo.c +982 -0
- data/ext/RMagick/rmmain.c +1497 -0
- data/ext/RMagick/rmutil.c +2685 -0
- data/install.rb +1015 -0
- data/lib/RMagick.rb +1486 -0
- data/metaconfig.in +6 -0
- data/post-clean.rb +12 -0
- data/post-install.rb +36 -0
- data/post-setup.rb +245 -0
- data/rmagick.gemspec +22 -0
- data/uninstall.rb +71 -0
- metadata +286 -0
data/doc/ex/map_f.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#! /usr/local/bin/ruby -w
|
2
|
+
require 'RMagick'
|
3
|
+
|
4
|
+
# Demonstrate the Image#map method
|
5
|
+
|
6
|
+
img = Magick::Image.read('images/Flower_Hat.jpg')[0]
|
7
|
+
|
8
|
+
# "Read" the builtin Netscape format, which
|
9
|
+
# contains the 216 colors in the Netscape palette.
|
10
|
+
nsmap = Magick::Image.read('netscape:')[0]
|
11
|
+
|
12
|
+
# Map the original image colors into the Netscape colors.
|
13
|
+
after = img.map(nsmap)
|
14
|
+
|
15
|
+
after.write('map_f.jpg')
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#! /usr/local/bin/ruby -w
|
2
|
+
|
3
|
+
require 'RMagick'
|
4
|
+
include Magick
|
5
|
+
|
6
|
+
img = Image.new(200,200)
|
7
|
+
img.compression = LZWCompression
|
8
|
+
|
9
|
+
bg = Image.read('plasma:fractal') {
|
10
|
+
self.size = '200x200'
|
11
|
+
}
|
12
|
+
|
13
|
+
gc = Draw.new
|
14
|
+
gc.stroke_width(2)
|
15
|
+
gc.stroke('black')
|
16
|
+
gc.fill('white')
|
17
|
+
gc.roundrectangle(0, 0, 199, 199, 8, 8)
|
18
|
+
|
19
|
+
gc.fill('black')
|
20
|
+
gc.circle(100, 45, 100, 25)
|
21
|
+
gc.circle( 45, 100, 25, 100)
|
22
|
+
gc.circle(100, 155, 100, 175)
|
23
|
+
gc.circle(155, 100, 175, 100)
|
24
|
+
|
25
|
+
gc.draw(img)
|
26
|
+
|
27
|
+
img.write('matte_fill_to_border_before.gif')
|
28
|
+
|
29
|
+
# Set the border color. Set the fuzz attribute so that
|
30
|
+
# the matte fill will fill the aliased pixels around
|
31
|
+
# the edges of the black circles.
|
32
|
+
img.border_color = 'black'
|
33
|
+
img.fuzz = 10
|
34
|
+
img = img.matte_fill_to_border(100, 100)
|
35
|
+
|
36
|
+
# Composite the image over a nice bright background
|
37
|
+
# so that the transparent pixels will be obvious.
|
38
|
+
img = bg[0].composite(img, CenterGravity, OverCompositeOp)
|
39
|
+
|
40
|
+
img.write('matte_fill_to_border_after.gif')
|
41
|
+
exit
|
42
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#! /usr/local/bin/ruby -w
|
2
|
+
|
3
|
+
require 'RMagick'
|
4
|
+
include Magick
|
5
|
+
|
6
|
+
img = Image.new(200,200)
|
7
|
+
img.compression = LZWCompression
|
8
|
+
|
9
|
+
bg = Image.read('plasma:fractal') {
|
10
|
+
self.size = '200x200'
|
11
|
+
}
|
12
|
+
|
13
|
+
gc = Draw.new
|
14
|
+
gc.stroke_width(2)
|
15
|
+
gc.stroke('black')
|
16
|
+
gc.fill('white')
|
17
|
+
gc.roundrectangle(0, 0, 199, 199, 8, 8)
|
18
|
+
|
19
|
+
gc.fill('yellow')
|
20
|
+
gc.stroke('red')
|
21
|
+
gc.circle(100, 100, 100, 25)
|
22
|
+
gc.draw(img)
|
23
|
+
|
24
|
+
img.write('matte_floodfill_before.gif')
|
25
|
+
|
26
|
+
img.fuzz = 100
|
27
|
+
img = img.matte_floodfill(100, 100)
|
28
|
+
|
29
|
+
# Composite the image over a nice bright background
|
30
|
+
# so that the transparent pixels will be obvious.
|
31
|
+
img = bg[0].composite(img, CenterGravity, OverCompositeOp)
|
32
|
+
|
33
|
+
img.write('matte_floodfill_after.gif')
|
34
|
+
exit
|
35
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#! /usr/local/bin/ruby -w
|
2
|
+
|
3
|
+
require 'RMagick'
|
4
|
+
include Magick
|
5
|
+
|
6
|
+
img = Image.new(200,200)
|
7
|
+
img.compression = LZWCompression
|
8
|
+
|
9
|
+
bg = Image.read('plasma:fractal') {
|
10
|
+
self.size = '200x200'
|
11
|
+
}
|
12
|
+
|
13
|
+
gc = Draw.new
|
14
|
+
gc.stroke_width(2)
|
15
|
+
gc.stroke('black')
|
16
|
+
gc.fill('white')
|
17
|
+
gc.roundrectangle(0, 0, 199, 199, 8, 8)
|
18
|
+
|
19
|
+
gc.fill('black')
|
20
|
+
gc.circle(100, 45, 100, 25)
|
21
|
+
gc.circle( 45, 100, 25, 100)
|
22
|
+
gc.circle(100, 155, 100, 175)
|
23
|
+
gc.circle(155, 100, 175, 100)
|
24
|
+
|
25
|
+
gc.draw(img)
|
26
|
+
|
27
|
+
img.write('matte_replace_before.gif')
|
28
|
+
|
29
|
+
# Set the border color. Set the fuzz attribute so that
|
30
|
+
# the matte fill will fill the aliased pixels around
|
31
|
+
# the edges of the black circles.
|
32
|
+
img.border_color = 'black'
|
33
|
+
img.fuzz = 10
|
34
|
+
img = img.matte_replace(100, 45)
|
35
|
+
|
36
|
+
# Composite the image over a nice bright background
|
37
|
+
# so that the transparent pixels will be obvious.
|
38
|
+
img = bg[0].composite(img, CenterGravity, OverCompositeOp)
|
39
|
+
|
40
|
+
img.write('matte_replace_after.gif')
|
41
|
+
exit
|
42
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#! /usr/local/bin/ruby -w
|
2
|
+
require 'RMagick'
|
3
|
+
|
4
|
+
# Demonstrate the Image#median_filter method
|
5
|
+
|
6
|
+
img = Magick::Image.read('images/Flower_Hat.jpg').first
|
7
|
+
img = img.add_noise(Magick::UniformNoise)
|
8
|
+
|
9
|
+
eimg = img.median_filter(0.05)
|
10
|
+
|
11
|
+
# Zoom in so we can see the change
|
12
|
+
img.resize!(3)
|
13
|
+
eimg.resize!(3)
|
14
|
+
|
15
|
+
# Make a before-and-after composite
|
16
|
+
eimg.crop!(eimg.columns/2, 0, eimg.columns/2, eimg.rows)
|
17
|
+
img = img.composite(eimg, Magick::EastGravity, Magick::OverCompositeOp)
|
18
|
+
|
19
|
+
# Draw a black line between the before and after parts.
|
20
|
+
line = Magick::Draw.new
|
21
|
+
line.line(img.columns/2, 0, img.columns/2, img.rows)
|
22
|
+
line.draw(img)
|
23
|
+
|
24
|
+
# Crop everything but the face.
|
25
|
+
img.crop!(Magick::CenterGravity, 250, 200)
|
26
|
+
|
27
|
+
img.write('median_filter.jpg')
|
28
|
+
exit
|
data/doc/ex/modulate.rb
ADDED
data/doc/ex/mono.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/local/bin/ruby -w
|
2
|
+
require 'RMagick'
|
3
|
+
|
4
|
+
# Demonstrate the ImageListImage#quantize method by converting
|
5
|
+
# a color image into a monochrome image.
|
6
|
+
|
7
|
+
# Read the large color cheetah image and scale it to a third
|
8
|
+
# of its size.
|
9
|
+
cheetah = Magick::Image.read("images/Cheetah.jpg").first
|
10
|
+
cheetah.scale!(0.33)
|
11
|
+
|
12
|
+
# Quantize the cheetah image into 256 colors in the GRAY colorspace.
|
13
|
+
mono_cheetah = cheetah.quantize 256, Magick::GRAYColorspace
|
14
|
+
|
15
|
+
# Cut the top off the monochrome cheetah image.
|
16
|
+
mono_bottom = mono_cheetah.crop 0, mono_cheetah.rows/2, mono_cheetah.columns, mono_cheetah.rows/2
|
17
|
+
|
18
|
+
# Composite the half-height mono cheetah onto the bottom of
|
19
|
+
# the original color cheetah.
|
20
|
+
before_after = cheetah.composite mono_bottom, 0, cheetah.rows/2, Magick::OverCompositeOp
|
21
|
+
|
22
|
+
before_after.write "mono.jpg"
|
23
|
+
exit
|
data/doc/ex/morph.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#! /usr/local/bin/ruby -w
|
2
|
+
|
3
|
+
require 'RMagick'
|
4
|
+
|
5
|
+
# Demonstrate the morph method
|
6
|
+
|
7
|
+
# Read 4 digit image files. Create an
|
8
|
+
# animated morph sequence by inserting 8
|
9
|
+
# in-between images between each pair of digits.
|
10
|
+
|
11
|
+
i = Magick::ImageList.new
|
12
|
+
number = '0'
|
13
|
+
4.times do
|
14
|
+
i.read "images/Button_" + number + ".gif"
|
15
|
+
number.succ!
|
16
|
+
end
|
17
|
+
|
18
|
+
puts "This may take a few seconds..."
|
19
|
+
morph = i.morph 8
|
20
|
+
morph.delay = 12
|
21
|
+
morph.iterations = 10000
|
22
|
+
# Display the resulting sequence as an animation.
|
23
|
+
# morph.animate(12)
|
24
|
+
morph.write "morph.gif"
|
25
|
+
exit
|
26
|
+
|
data/doc/ex/mosaic.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/local/bin/ruby -w
|
2
|
+
require 'RMagick'
|
3
|
+
|
4
|
+
# Demonstrate the mosaic method
|
5
|
+
|
6
|
+
a = Magick::ImageList.new
|
7
|
+
|
8
|
+
letter = 'A'
|
9
|
+
26.times do
|
10
|
+
# 'M' is not the same size as the other letters.
|
11
|
+
if letter != 'M'
|
12
|
+
a.read("images/Button_"+letter+".gif")
|
13
|
+
end
|
14
|
+
letter.succ!
|
15
|
+
end
|
16
|
+
|
17
|
+
# Make a copy of "a" with all the images quarter-sized
|
18
|
+
b = Magick::ImageList.new
|
19
|
+
page = Magick::Rectangle.new(0,0,0,0)
|
20
|
+
a.scene = 0
|
21
|
+
5.times do |i|
|
22
|
+
5.times do |j|
|
23
|
+
b << a.scale(0.25)
|
24
|
+
page.x = j * b.columns
|
25
|
+
page.y = i * b.rows
|
26
|
+
b.page = page
|
27
|
+
(a.scene += 1) rescue a.scene = 0
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Make a 5x5 mosaic
|
32
|
+
mosaic = b.mosaic
|
33
|
+
mosaic.write("mosaic.gif")
|
34
|
+
# mosaic.display
|
35
|
+
exit
|
data/doc/ex/negate.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#! /usr/local/bin/ruby -w
|
2
|
+
require 'RMagick'
|
3
|
+
|
4
|
+
# Demonstrate the Image#negate_channel method
|
5
|
+
|
6
|
+
img = Magick::Image.read('images/Flower_Hat.jpg').first
|
7
|
+
|
8
|
+
begin
|
9
|
+
|
10
|
+
result = img.negate_channel(false, Magick::GreenChannel)
|
11
|
+
|
12
|
+
# Substitute the standard "Not Implemented" image
|
13
|
+
rescue NotImplementedError
|
14
|
+
result = Magick::Image.read("images/notimplemented.gif").first
|
15
|
+
result.resize!(img.columns, img.rows)
|
16
|
+
end
|
17
|
+
|
18
|
+
result.write('negate_channel.jpg')
|
19
|
+
exit
|
data/doc/ex/normalize.rb
ADDED
data/doc/ex/oil_paint.rb
ADDED
data/doc/ex/opacity.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#! /usr/local/bin/ruby -w
|
2
|
+
|
3
|
+
require 'RMagick'
|
4
|
+
include Magick
|
5
|
+
|
6
|
+
canvas = Image.new(260, 125)
|
7
|
+
gc = Draw.new
|
8
|
+
gc.fill('black')
|
9
|
+
gc.rectangle(10,20, 250,90)
|
10
|
+
|
11
|
+
gc.stroke('blue')
|
12
|
+
gc.fill('yellow')
|
13
|
+
gc.stroke_width(10)
|
14
|
+
|
15
|
+
gc.opacity('25%')
|
16
|
+
gc.roundrectangle(20,20, 60,90, 5,5)
|
17
|
+
|
18
|
+
gc.opacity('50%')
|
19
|
+
gc.roundrectangle(80,20, 120,90, 5,5)
|
20
|
+
|
21
|
+
gc.opacity(0.75)
|
22
|
+
gc.roundrectangle(140,20, 180,90, 5,5)
|
23
|
+
|
24
|
+
gc.opacity(1)
|
25
|
+
gc.roundrectangle(200,20, 240,90, 5,5)
|
26
|
+
|
27
|
+
gc.stroke('transparent')
|
28
|
+
gc.fill('black')
|
29
|
+
gc.gravity(SouthGravity)
|
30
|
+
gc.text(-90,20, '"25%%"')
|
31
|
+
gc.text(-30,20, '"50%%"')
|
32
|
+
gc.text( 30,20, '"75%%"')
|
33
|
+
gc.text( 90,20, '"100%%"')
|
34
|
+
|
35
|
+
gc.draw(canvas)
|
36
|
+
|
37
|
+
canvas.write("opacity.gif")
|
38
|
+
exit
|
data/doc/ex/opaque.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#! /usr/local/bin/ruby -w
|
2
|
+
require 'RMagick'
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
# Demonstrate the Image#opaque method.
|
6
|
+
|
7
|
+
img = Image.read('images/Flower_Hat.jpg').first
|
8
|
+
|
9
|
+
# Allow non-exact matches
|
10
|
+
img.fuzz = 25
|
11
|
+
img = img.opaque('white', 'red')
|
12
|
+
|
13
|
+
img.write('opaque.jpg')
|
14
|
+
|
data/doc/ex/path.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
#! /usr/local/bin/ruby -w
|
2
|
+
require 'RMagick'
|
3
|
+
|
4
|
+
imgl = Magick::ImageList.new
|
5
|
+
imgl.new_image(390, 240, Magick::HatchFill.new('white','lightcyan2'))
|
6
|
+
|
7
|
+
gc = Magick::Draw.new
|
8
|
+
|
9
|
+
# Draw path
|
10
|
+
gc.fill_opacity 0
|
11
|
+
gc.stroke 'red'
|
12
|
+
gc.stroke_width 3
|
13
|
+
gc.path "M20,120 C20,20 170,20 170,120 S320,220 320,120"
|
14
|
+
|
15
|
+
# Annotate
|
16
|
+
# Show end points
|
17
|
+
gc.fill_opacity 0
|
18
|
+
gc.stroke 'gray50'
|
19
|
+
gc.stroke_width 1
|
20
|
+
gc.circle 20,120, 23, 123
|
21
|
+
gc.circle 170,120, 173, 123
|
22
|
+
gc.circle 320,120, 323, 123
|
23
|
+
|
24
|
+
# Show control points
|
25
|
+
gc.fill_opacity 1
|
26
|
+
gc.circle 20, 20, 23, 23
|
27
|
+
gc.circle 170, 20, 173, 23
|
28
|
+
gc.circle 320,220, 323, 223
|
29
|
+
|
30
|
+
# Show connector lines
|
31
|
+
gc.line 20,120, 20, 20
|
32
|
+
gc.line 170, 20, 170,220
|
33
|
+
gc.line 320,220, 320,120
|
34
|
+
|
35
|
+
# Show auto control point
|
36
|
+
gc.fill_opacity 0
|
37
|
+
gc.stroke 'blue'
|
38
|
+
gc.stroke_width 3
|
39
|
+
gc.circle 170,220, 173,223
|
40
|
+
|
41
|
+
# Add labels
|
42
|
+
gc.stroke "#000000ff" # unset stroke color
|
43
|
+
gc.fill 'black'
|
44
|
+
|
45
|
+
# Add end point labels
|
46
|
+
gc.text 30,125, "'20,120'"
|
47
|
+
gc.text 180,125, "'170,120'"
|
48
|
+
gc.text 330,125, "'320,120'"
|
49
|
+
|
50
|
+
# Add control point labels
|
51
|
+
gc.text 30, 25, "'20,20'"
|
52
|
+
gc.text 180, 25, "'170,20'"
|
53
|
+
gc.text 330,225, "'320,320'"
|
54
|
+
|
55
|
+
# Add auto control point label
|
56
|
+
gc.text 180,225, "'auto ctl point'"
|
57
|
+
|
58
|
+
gc.draw imgl
|
59
|
+
|
60
|
+
imgl.border!(1,1, 'lightcyan2')
|
61
|
+
imgl.write 'path.gif'
|
62
|
+
|