rmagick 1.7.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.
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
@@ -0,0 +1,29 @@
|
|
1
|
+
#! /usr/local/bin/ruby -w
|
2
|
+
require 'RMagick'
|
3
|
+
|
4
|
+
# Demonstrate the Image#color_fill_to_border method
|
5
|
+
|
6
|
+
before = Magick::Image.new(200,200) {
|
7
|
+
self.background_color = 'white'
|
8
|
+
self.border_color = 'black'
|
9
|
+
}
|
10
|
+
before.border!(1,1,'black')
|
11
|
+
|
12
|
+
circle = Magick::Draw.new
|
13
|
+
circle.fill('transparent')
|
14
|
+
circle.stroke('black')
|
15
|
+
circle.stroke_width(2)
|
16
|
+
circle.circle(100,100,180,100)
|
17
|
+
circle.fill('plum1')
|
18
|
+
circle.stroke('transparent')
|
19
|
+
circle.circle( 60,100, 40,100)
|
20
|
+
circle.circle(140,100,120,100)
|
21
|
+
circle.circle(100, 60,100, 40)
|
22
|
+
circle.circle(100,140,100,120)
|
23
|
+
circle.draw(before)
|
24
|
+
|
25
|
+
before.write('color_fill_to_border_before.gif')
|
26
|
+
|
27
|
+
after = before.color_fill_to_border(100,100, 'aquamarine')
|
28
|
+
after.write('color_fill_to_border_after.gif')
|
29
|
+
exit
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#! /usr/local/bin/ruby -w
|
2
|
+
require 'RMagick'
|
3
|
+
|
4
|
+
# Demonstrate the Image#color_floodfill method
|
5
|
+
|
6
|
+
before = Magick::Image.new(200,200) { self.background_color = 'white' }
|
7
|
+
before.border!(1,1,'black')
|
8
|
+
|
9
|
+
circle = Magick::Draw.new
|
10
|
+
circle.fill('transparent')
|
11
|
+
circle.stroke_width(2)
|
12
|
+
circle.stroke('black')
|
13
|
+
circle.circle(100,100,180,100)
|
14
|
+
circle.fill('plum1')
|
15
|
+
circle.stroke('transparent')
|
16
|
+
circle.circle( 60,100, 40,100)
|
17
|
+
circle.circle(140,100,120,100)
|
18
|
+
circle.circle(100, 60,100, 40)
|
19
|
+
circle.circle(100,140,100,120)
|
20
|
+
circle.draw(before)
|
21
|
+
|
22
|
+
before.write('color_floodfill_before.gif')
|
23
|
+
|
24
|
+
aquamarine = Magick::Pixel.from_color('aquamarine')
|
25
|
+
after = before.color_floodfill(100,100, aquamarine)
|
26
|
+
|
27
|
+
after.write('color_floodfill_after.gif')
|
28
|
+
exit
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#! /usr/local/bin/ruby -w
|
2
|
+
|
3
|
+
require 'RMagick'
|
4
|
+
include Magick
|
5
|
+
|
6
|
+
NUM_COLORS = 256
|
7
|
+
HIST_HEIGHT = 200
|
8
|
+
|
9
|
+
img = Image.read('images/Hot_Air_Balloons_H.jpg').first
|
10
|
+
img = img.quantize(NUM_COLORS)
|
11
|
+
|
12
|
+
begin
|
13
|
+
hist = img.color_histogram
|
14
|
+
rescue NotImplementedError
|
15
|
+
img = Image.read('images/notimplemented.gif').first
|
16
|
+
img.write('color_histogram.gif')
|
17
|
+
exit
|
18
|
+
end
|
19
|
+
|
20
|
+
# sort pixels by increasing count
|
21
|
+
begin
|
22
|
+
pixels = hist.keys.sort_by {|pixel| hist[pixel] }
|
23
|
+
rescue NameError # No sort_by?
|
24
|
+
pixels = hist.keys.sort { |p, q| hist[p] <=> hist[q] }
|
25
|
+
end
|
26
|
+
|
27
|
+
scale = HIST_HEIGHT / (hist.values.max*1.025) # put 2.5% air at the top
|
28
|
+
|
29
|
+
gc = Draw.new
|
30
|
+
gc.stroke_width(1)
|
31
|
+
gc.affine(1, 0, 0, -scale, 0, HIST_HEIGHT)
|
32
|
+
|
33
|
+
# handle images with fewer than NUM_COLORS colors
|
34
|
+
start = NUM_COLORS - img.number_colors
|
35
|
+
|
36
|
+
pixels.each { |pixel|
|
37
|
+
gc.stroke(pixel.to_color)
|
38
|
+
gc.line(start, 0, start, hist[pixel])
|
39
|
+
start = start.succ
|
40
|
+
}
|
41
|
+
|
42
|
+
hatch = HatchFill.new("white", "gray95")
|
43
|
+
canvas = Image.new(NUM_COLORS, HIST_HEIGHT, hatch)
|
44
|
+
gc.draw(canvas)
|
45
|
+
|
46
|
+
text = Draw.new
|
47
|
+
text.annotate(canvas, 0, 0, 0, 20, "Color Frequency\nHistogram") {
|
48
|
+
self.pointsize = 10
|
49
|
+
self.gravity = NorthGravity
|
50
|
+
self.stroke = 'transparent'
|
51
|
+
}
|
52
|
+
|
53
|
+
canvas.border!(1, 1, "white")
|
54
|
+
canvas.border!(1, 1, "black")
|
55
|
+
canvas.border!(3, 3, "white")
|
56
|
+
#canvas.display
|
57
|
+
canvas.write("color_histogram.gif")
|
58
|
+
|
59
|
+
exit
|
60
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#! /usr/local/bin/ruby -w
|
2
|
+
require 'RMagick'
|
3
|
+
|
4
|
+
# Demonstrate the Image#color_reset! method
|
5
|
+
|
6
|
+
f = Magick::Image.new(100,100) { self.background_color = 'white' }
|
7
|
+
red = Magick::Pixel.from_color('red')
|
8
|
+
f.color_reset!(red)
|
9
|
+
#f.display
|
10
|
+
f.write('color_reset.gif')
|
11
|
+
exit
|
data/doc/ex/colorize.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/local/bin/ruby -w
|
2
|
+
require 'RMagick'
|
3
|
+
|
4
|
+
# Demonstrate the Image#colorize method by converting
|
5
|
+
# a full-color image to "sepia-tone"
|
6
|
+
|
7
|
+
img = Magick::Image.read('images/Flower_Hat.jpg').first
|
8
|
+
|
9
|
+
# Convert the color image to monochrome
|
10
|
+
mono = img.quantize(256, Magick::GRAYColorspace)
|
11
|
+
|
12
|
+
# Colorize with a 30% blend of a brownish-orange color
|
13
|
+
colorized = mono.colorize(0.30, 0.30, 0.30, '#cc9933')
|
14
|
+
|
15
|
+
colorized.write('colorize.jpg')
|
16
|
+
exit
|
data/doc/ex/colors.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
#! /usr/local/bin/ruby -w
|
2
|
+
require 'RMagick'
|
3
|
+
include Magick
|
4
|
+
|
5
|
+
puts("Creating colors.miff. This may take a few seconds...")
|
6
|
+
|
7
|
+
colors = ImageList.new
|
8
|
+
|
9
|
+
# Add a row of "null" colors so we'll have
|
10
|
+
# room to add the title at the top.
|
11
|
+
4.times { colors.read('null:') }
|
12
|
+
|
13
|
+
puts("\tCreating color swatches...")
|
14
|
+
|
15
|
+
# Create a 200x25 image for each named color.
|
16
|
+
# Label with the name, RGB values, and compliance type.
|
17
|
+
colors { |c|
|
18
|
+
if c.name !~ /grey/ then # omit SVG 'grays'
|
19
|
+
colors.new_image(200, 25) {
|
20
|
+
self.background_color = c.color
|
21
|
+
self.border_color = 'gray50'
|
22
|
+
}
|
23
|
+
rgb = sprintf('#%02x%02x%02x', c.color.red&0xff, c.color.green&0xff, c.color.blue&0xff)
|
24
|
+
rgb += sprintf('%02x', c.color.opacity&0xff) if c.color.opacity != 0
|
25
|
+
m = /(.*?)Compliance/.match c.compliance.to_s
|
26
|
+
colors.cur_image['Label'] = "#{c.name} (#{rgb}) #{m[1]}"
|
27
|
+
end
|
28
|
+
}
|
29
|
+
|
30
|
+
puts("\tCreating montage...")
|
31
|
+
|
32
|
+
# Montage. Each image will have 40 tiles.
|
33
|
+
# There will be 16 images.
|
34
|
+
montage = colors.montage {
|
35
|
+
self.geometry = '200x25+10+5'
|
36
|
+
self.gravity = CenterGravity
|
37
|
+
self.tile = '4x10'
|
38
|
+
self.background_color = 'black'
|
39
|
+
self.border_width = 1
|
40
|
+
self.fill = 'white'
|
41
|
+
self.stroke = 'transparent'
|
42
|
+
}
|
43
|
+
|
44
|
+
# Add the title at the top, over the 'null:'
|
45
|
+
# tiles we added at the very beginning.
|
46
|
+
title = Draw.new
|
47
|
+
title.annotate(montage, 0,0,0,20, 'Named Colors') {
|
48
|
+
self.font_family = 'Helvetica'
|
49
|
+
self.fill = 'white'
|
50
|
+
self.stroke = 'transparent'
|
51
|
+
self.pointsize = 32
|
52
|
+
self.font_weight = BoldWeight
|
53
|
+
self.gravity = NorthGravity
|
54
|
+
}
|
55
|
+
|
56
|
+
puts("\tWriting ./colors.miff")
|
57
|
+
montage.each { |f| f.compression = ZipCompression }
|
58
|
+
montage.write('colors.miff')
|
59
|
+
|
60
|
+
# Make a small sample of the full montage to display in the HTML file.
|
61
|
+
sample = montage[8].crop(55, 325, 495, 110)
|
62
|
+
sample.page = Rectangle.new(495,110)
|
63
|
+
sample.write('colors.gif')
|
64
|
+
|
65
|
+
exit
|
data/doc/ex/composite.rb
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
#! /usr/local/bin/ruby -w
|
2
|
+
|
3
|
+
# Demonstrate the effects of various composite operators.
|
4
|
+
# Based on ImageMagick's composite test.
|
5
|
+
|
6
|
+
require 'RMagick'
|
7
|
+
include Magick
|
8
|
+
|
9
|
+
ROWS = 70
|
10
|
+
COLS = 70
|
11
|
+
COLOR_A = "#999966"
|
12
|
+
COLOR_B = "#990066"
|
13
|
+
|
14
|
+
img = Image.new(COLS, ROWS)
|
15
|
+
triangle = Draw.new
|
16
|
+
triangle.fill(COLOR_A)
|
17
|
+
triangle.stroke('transparent')
|
18
|
+
triangle.polygon(0,0, COLS,0, 0,ROWS, 0,0)
|
19
|
+
triangle.draw(img)
|
20
|
+
image_A = img.transparent('white', TransparentOpacity)
|
21
|
+
image_A['Label'] = 'A'
|
22
|
+
|
23
|
+
img = Image.new(COLS, ROWS)
|
24
|
+
triangle = Draw.new
|
25
|
+
triangle.fill(COLOR_B)
|
26
|
+
triangle.stroke('transparent')
|
27
|
+
triangle.polygon(0,0, COLS,ROWS, COLS,0, 0,0)
|
28
|
+
triangle.draw(img)
|
29
|
+
image_B = img.transparent('white', TransparentOpacity)
|
30
|
+
image_B['Label'] = 'B'
|
31
|
+
|
32
|
+
list = ImageList.new
|
33
|
+
null = Image.read("xc:white") { self.size = Geometry.new(COLS,ROWS) }
|
34
|
+
null = null.first.transparent('white', TransparentOpacity)
|
35
|
+
null.border_color = 'transparent'
|
36
|
+
granite = Image.read("granite:")
|
37
|
+
|
38
|
+
list << null.copy
|
39
|
+
list << image_A
|
40
|
+
list << image_B
|
41
|
+
list << null.copy
|
42
|
+
|
43
|
+
|
44
|
+
list << image_B.composite(image_A, CenterGravity, OverCompositeOp)
|
45
|
+
list.cur_image['Label'] = 'A over B'
|
46
|
+
list << image_A.composite(image_B, CenterGravity, OverCompositeOp)
|
47
|
+
list.cur_image['Label'] = 'B over A'
|
48
|
+
|
49
|
+
list << image_B.composite(image_A, CenterGravity, InCompositeOp)
|
50
|
+
list.cur_image['Label'] = 'A in B'
|
51
|
+
list << image_A.composite(image_B, CenterGravity, InCompositeOp)
|
52
|
+
list.cur_image['Label'] = 'B in A'
|
53
|
+
|
54
|
+
list << image_B.composite(image_A, CenterGravity, OutCompositeOp)
|
55
|
+
list.cur_image['Label'] = 'A out B'
|
56
|
+
list << image_A.composite(image_B, CenterGravity, OutCompositeOp)
|
57
|
+
list.cur_image['Label'] = 'B out A'
|
58
|
+
|
59
|
+
list << image_B.composite(image_A, CenterGravity, AtopCompositeOp)
|
60
|
+
list.cur_image['Label'] = 'A atop B'
|
61
|
+
list << image_A.composite(image_B, CenterGravity, AtopCompositeOp)
|
62
|
+
list.cur_image['Label'] = 'B atop A'
|
63
|
+
|
64
|
+
list << image_B.composite(image_A, CenterGravity, XorCompositeOp)
|
65
|
+
list.cur_image['Label'] = 'A xor B'
|
66
|
+
|
67
|
+
list << image_B.composite(image_A, CenterGravity, MultiplyCompositeOp)
|
68
|
+
list.cur_image['Label'] = 'A multiply B'
|
69
|
+
|
70
|
+
list << image_B.composite(image_A, CenterGravity, ScreenCompositeOp)
|
71
|
+
list.cur_image['Label'] = 'A screen B'
|
72
|
+
|
73
|
+
list << image_B.composite(image_A, CenterGravity, DarkenCompositeOp)
|
74
|
+
list.cur_image['Label'] = 'A darken B'
|
75
|
+
|
76
|
+
list << image_B.composite(image_A, CenterGravity, LightenCompositeOp)
|
77
|
+
list.cur_image['Label'] = 'A lighten B'
|
78
|
+
|
79
|
+
list << image_B.composite(image_A, CenterGravity, PlusCompositeOp)
|
80
|
+
list.cur_image['Label'] = 'A plus B'
|
81
|
+
|
82
|
+
list << image_B.composite(image_A, CenterGravity, MinusCompositeOp)
|
83
|
+
list.cur_image['Label'] = 'A minus B'
|
84
|
+
|
85
|
+
list << image_B.composite(image_A, CenterGravity, AddCompositeOp)
|
86
|
+
list.cur_image['Label'] = 'A add B'
|
87
|
+
|
88
|
+
list << image_B.composite(image_A, CenterGravity, SubtractCompositeOp)
|
89
|
+
list.cur_image['Label'] = 'A subtract B'
|
90
|
+
|
91
|
+
list << image_B.composite(image_A, CenterGravity, DifferenceCompositeOp)
|
92
|
+
list.cur_image['Label'] = 'A difference B'
|
93
|
+
|
94
|
+
list << image_B.composite(image_A, CenterGravity, HueCompositeOp)
|
95
|
+
list.cur_image['Label'] = 'A hue B'
|
96
|
+
|
97
|
+
list << image_B.composite(image_A, CenterGravity, SaturateCompositeOp)
|
98
|
+
list.cur_image['Label'] = 'A saturate B'
|
99
|
+
|
100
|
+
list << image_B.composite(image_A, CenterGravity, LuminizeCompositeOp)
|
101
|
+
list.cur_image['Label'] = 'A luminize B'
|
102
|
+
|
103
|
+
list << image_B.composite(image_A, CenterGravity, ColorizeCompositeOp)
|
104
|
+
list.cur_image['Label'] = 'A colorize B'
|
105
|
+
|
106
|
+
list << image_B.composite(image_A, CenterGravity, BumpmapCompositeOp)
|
107
|
+
list.cur_image['Label'] = 'A bumpmap B'
|
108
|
+
|
109
|
+
list << image_B.composite(image_A, CenterGravity, DissolveCompositeOp)
|
110
|
+
list.cur_image['Label'] = 'A dissolve B'
|
111
|
+
|
112
|
+
list << image_B.composite(image_A, CenterGravity, ThresholdCompositeOp)
|
113
|
+
list.cur_image['Label'] = 'A threshold B'
|
114
|
+
|
115
|
+
list << image_B.composite(image_A, CenterGravity, ModulateCompositeOp)
|
116
|
+
list.cur_image['Label'] = 'A modulate B'
|
117
|
+
|
118
|
+
list << image_A.composite(image_B, CenterGravity, ModulateCompositeOp)
|
119
|
+
list.cur_image['Label'] = 'B modulate A'
|
120
|
+
|
121
|
+
list << image_B.composite(image_A, CenterGravity, OverlayCompositeOp)
|
122
|
+
list.cur_image['Label'] = 'A overlay B'
|
123
|
+
|
124
|
+
montage = list.montage {
|
125
|
+
self.geometry = Geometry.new(COLS, ROWS, 3, 3)
|
126
|
+
rows = (list.size+3) / 4
|
127
|
+
self.tile = Geometry.new(4, rows)
|
128
|
+
self.texture = granite[0]
|
129
|
+
self.fill = 'white'
|
130
|
+
self.stroke = 'transparent'
|
131
|
+
}
|
132
|
+
|
133
|
+
montage.write('composite.gif')
|
134
|
+
exit
|
135
|
+
|
data/doc/ex/contrast.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#! /usr/local/bin/ruby -w
|
2
|
+
require 'RMagick'
|
3
|
+
|
4
|
+
# Demonstrate the Image#contrast method
|
5
|
+
|
6
|
+
img = Magick::ImageList.new('images/Flower_Hat.jpg')
|
7
|
+
img.resize!(0.5)
|
8
|
+
|
9
|
+
# Prepare to label each image with a number from 1 to 4
|
10
|
+
legend = Magick::Draw.new
|
11
|
+
legend.font_family = 'Helvetica'
|
12
|
+
legend.stroke = 'transparent'
|
13
|
+
legend.pointsize = 12
|
14
|
+
legend.gravity = Magick::SouthEastGravity
|
15
|
+
|
16
|
+
# Add 3 images, each one having slightly less contrast
|
17
|
+
f = 1
|
18
|
+
3.times {
|
19
|
+
img << img.contrast
|
20
|
+
|
21
|
+
# Annotate the previous image
|
22
|
+
legend.annotate(img[f-1], 0,0,7,10, f.to_s)
|
23
|
+
f += 1
|
24
|
+
}
|
25
|
+
|
26
|
+
# Annotate the last image
|
27
|
+
legend.annotate(img, 0,0,7,10, f.to_s)
|
28
|
+
|
29
|
+
# Montage into a single image
|
30
|
+
imgs = img.montage {
|
31
|
+
self.geometry = Magick::Geometry.new(img.columns, img.rows)
|
32
|
+
self.tile = "2x2"
|
33
|
+
}
|
34
|
+
|
35
|
+
imgs.write('contrast.jpg')
|
36
|
+
#imgs.display
|
37
|
+
exit
|
data/doc/ex/crop.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/local/bin/ruby -w
|
2
|
+
require 'RMagick'
|
3
|
+
|
4
|
+
# Demonstrate the Image#crop method
|
5
|
+
|
6
|
+
img = Magick::Image.read('images/Flower_Hat.jpg')[0]
|
7
|
+
|
8
|
+
# Crop the specified rectangle out of the img.
|
9
|
+
chopped = img.crop(23, 81, 107, 139)
|
10
|
+
|
11
|
+
# Go back to the original and highlight the area
|
12
|
+
# corresponding to the retained rectangle.
|
13
|
+
rect = Magick::Draw.new
|
14
|
+
rect.stroke('transparent')
|
15
|
+
rect.fill('white')
|
16
|
+
rect.fill_opacity(0.25)
|
17
|
+
rect.rectangle(23, 81, 107+23, 139+81)
|
18
|
+
rect.draw(img)
|
19
|
+
|
20
|
+
img.write('crop_before.jpg')
|
21
|
+
|
22
|
+
# Create a image to use as a background for
|
23
|
+
# the "after" image.
|
24
|
+
bg = Magick::Image.new(img.columns, img.rows)
|
25
|
+
|
26
|
+
# Composite the the "after" (chopped) image on the background
|
27
|
+
bg = bg.composite(chopped, 23, 81, Magick::OverCompositeOp)
|
28
|
+
|
29
|
+
bg.write('crop_after.jpg')
|
30
|
+
|
31
|
+
exit
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#! /usr/local/bin/ruby -w
|
2
|
+
|
3
|
+
#=======================================================#
|
4
|
+
# Thanks to Robert Wagner for the idea of allowing a #
|
5
|
+
# GravityType instead of the x- and y-offset arguments! #
|
6
|
+
#=======================================================#
|
7
|
+
|
8
|
+
# Demo the use of the GravityType argument to Image#crop.
|
9
|
+
|
10
|
+
require 'RMagick'
|
11
|
+
include Magick
|
12
|
+
|
13
|
+
shorts = Image.read('images/Shorts.jpg').first
|
14
|
+
|
15
|
+
regwidth = shorts.columns/2
|
16
|
+
regheight = shorts.rows/2
|
17
|
+
|
18
|
+
mask = Image.new(regwidth, regheight) { self.background_color = 'white'}
|
19
|
+
mask.opacity = 0.50 * TransparentOpacity
|
20
|
+
|
21
|
+
black = Image.new(shorts.columns, shorts.rows) {self.background_color = 'black'}
|
22
|
+
pairs = ImageList.new
|
23
|
+
|
24
|
+
[NorthWestGravity, NorthGravity, NorthEastGravity,
|
25
|
+
WestGravity, CenterGravity, EastGravity,
|
26
|
+
SouthWestGravity, SouthGravity, SouthEastGravity].each do |gravity|
|
27
|
+
pattern = shorts.composite(mask, gravity, OverCompositeOp)
|
28
|
+
cropped = shorts.crop(gravity, regwidth, regheight)
|
29
|
+
result = black.composite(cropped, gravity, OverCompositeOp)
|
30
|
+
result.border_color = "white"
|
31
|
+
pairs << pattern
|
32
|
+
pairs << result
|
33
|
+
end
|
34
|
+
|
35
|
+
# Montage into a single image
|
36
|
+
montage = pairs.montage {
|
37
|
+
self.geometry = "#{pairs.columns}x#{pairs.rows}+0+0"
|
38
|
+
self.tile = "6x3"
|
39
|
+
self.border_width = 1
|
40
|
+
}
|
41
|
+
montage.write('crop_with_gravity.miff')
|
42
|
+
#montage.display
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|