rmagick 2.13.4 → 2.16.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rmagick might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.editorconfig +14 -0
- data/.hound.yml +2 -0
- data/.rspec +1 -0
- data/.rubocop.yml +340 -0
- data/.simplecov +27 -0
- data/.travis.yml +29 -12
- data/CHANGELOG.md +915 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/CONTRIBUTING.md +31 -3
- data/Gemfile +3 -0
- data/README.textile +94 -4
- data/Rakefile +57 -45
- data/before_install_linux.sh +26 -6
- data/deprecated/RMagick.rb +6 -0
- data/doc/comtasks.html +1 -1
- data/doc/draw.html +7 -4
- data/doc/ex/InitialCoords.rb +16 -17
- data/doc/ex/NewCoordSys.rb +21 -23
- data/doc/ex/OrigCoordSys.rb +8 -10
- data/doc/ex/PreserveAspectRatio.rb +182 -183
- data/doc/ex/RotateScale.rb +27 -28
- data/doc/ex/Skew.rb +27 -27
- data/doc/ex/Use01.rb +7 -8
- data/doc/ex/Use02.rb +11 -12
- data/doc/ex/Use03.rb +7 -7
- data/doc/ex/ViewBox.rb +16 -18
- data/doc/ex/adaptive_threshold.rb +4 -5
- data/doc/ex/add_noise.rb +4 -5
- data/doc/ex/affine.rb +4 -4
- data/doc/ex/affine_transform.rb +4 -4
- data/doc/ex/arc.rb +10 -10
- data/doc/ex/arcpath.rb +7 -8
- data/doc/ex/arcs01.rb +10 -10
- data/doc/ex/arcs02.rb +36 -38
- data/doc/ex/average.rb +5 -5
- data/doc/ex/axes.rb +4 -4
- data/doc/ex/baseline_shift01.rb +11 -12
- data/doc/ex/bilevel_channel.rb +2 -3
- data/doc/ex/blur_image.rb +2 -2
- data/doc/ex/border.rb +2 -2
- data/doc/ex/bounding_box.rb +9 -11
- data/doc/ex/cbezier1.rb +3 -4
- data/doc/ex/cbezier2.rb +3 -4
- data/doc/ex/cbezier3.rb +3 -4
- data/doc/ex/cbezier4.rb +3 -4
- data/doc/ex/cbezier5.rb +2 -3
- data/doc/ex/cbezier6.rb +3 -3
- data/doc/ex/channel.rb +10 -11
- data/doc/ex/charcoal.rb +2 -2
- data/doc/ex/chop.rb +2 -2
- data/doc/ex/circle.rb +3 -3
- data/doc/ex/circle01.rb +6 -7
- data/doc/ex/clip_path.rb +12 -12
- data/doc/ex/coalesce.rb +32 -35
- data/doc/ex/color_fill_to_border.rb +6 -6
- data/doc/ex/color_floodfill.rb +2 -2
- data/doc/ex/color_histogram.rb +17 -18
- data/doc/ex/color_reset.rb +2 -2
- data/doc/ex/colorize.rb +2 -2
- data/doc/ex/colors.rb +30 -30
- data/doc/ex/compose_mask.rb +8 -9
- data/doc/ex/composite.rb +14 -16
- data/doc/ex/composite_layers.rb +15 -15
- data/doc/ex/composite_tiled.rb +5 -7
- data/doc/ex/contrast.rb +12 -12
- data/doc/ex/crop.rb +3 -3
- data/doc/ex/crop_with_gravity.rb +13 -17
- data/doc/ex/cubic01.rb +18 -20
- data/doc/ex/cubic02.rb +64 -67
- data/doc/ex/cycle_colormap.rb +2 -2
- data/doc/ex/dissolve.rb +2 -3
- data/doc/ex/drawcomp.rb +34 -34
- data/doc/ex/drop_shadow.rb +8 -8
- data/doc/ex/edge.rb +2 -2
- data/doc/ex/ellipse.rb +4 -4
- data/doc/ex/ellipse01.rb +10 -11
- data/doc/ex/emboss.rb +2 -2
- data/doc/ex/enhance.rb +2 -2
- data/doc/ex/equalize.rb +2 -2
- data/doc/ex/evenodd.rb +31 -32
- data/doc/ex/fill_pattern.rb +12 -15
- data/doc/ex/flatten_images.rb +13 -13
- data/doc/ex/flip.rb +2 -2
- data/doc/ex/flop.rb +2 -2
- data/doc/ex/font_styles.rb +21 -23
- data/doc/ex/fonts.rb +14 -14
- data/doc/ex/frame.rb +3 -3
- data/doc/ex/gaussian_blur.rb +2 -2
- data/doc/ex/get_multiline_type_metrics.rb +6 -7
- data/doc/ex/get_pixels.rb +13 -14
- data/doc/ex/get_type_metrics.rb +26 -31
- data/doc/ex/gradientfill.rb +12 -12
- data/doc/ex/grav.rb +4 -5
- data/doc/ex/gravity.rb +61 -60
- data/doc/ex/group.rb +16 -16
- data/doc/ex/hatchfill.rb +10 -10
- data/doc/ex/image.rb +29 -31
- data/doc/ex/implode.rb +17 -17
- data/doc/ex/level.rb +2 -2
- data/doc/ex/level_colors.rb +4 -4
- data/doc/ex/line.rb +4 -5
- data/doc/ex/line01.rb +11 -13
- data/doc/ex/mask.rb +7 -8
- data/doc/ex/matte_fill_to_border.rb +2 -3
- data/doc/ex/matte_floodfill.rb +2 -3
- data/doc/ex/matte_replace.rb +2 -3
- data/doc/ex/median_filter.rb +2 -2
- data/doc/ex/modulate.rb +2 -2
- data/doc/ex/mono.rb +4 -4
- data/doc/ex/morph.rb +7 -8
- data/doc/ex/mosaic.rb +15 -15
- data/doc/ex/motion_blur.rb +2 -2
- data/doc/ex/negate.rb +2 -2
- data/doc/ex/negate_channel.rb +2 -2
- data/doc/ex/nested_rvg.rb +11 -11
- data/doc/ex/nonzero.rb +31 -32
- data/doc/ex/normalize.rb +2 -2
- data/doc/ex/oil_paint.rb +2 -2
- data/doc/ex/opacity.rb +3 -3
- data/doc/ex/ordered_dither.rb +2 -2
- data/doc/ex/path.rb +4 -5
- data/doc/ex/pattern1.rb +10 -10
- data/doc/ex/pattern2.rb +7 -7
- data/doc/ex/polaroid.rb +13 -14
- data/doc/ex/polygon.rb +6 -7
- data/doc/ex/polygon01.rb +10 -12
- data/doc/ex/polyline.rb +4 -5
- data/doc/ex/polyline01.rb +11 -13
- data/doc/ex/posterize.rb +2 -2
- data/doc/ex/preview.rb +3 -4
- data/doc/ex/qbezierpath.rb +5 -5
- data/doc/ex/quad01.rb +23 -25
- data/doc/ex/quantize-m.rb +5 -5
- data/doc/ex/radial_blur.rb +2 -2
- data/doc/ex/raise.rb +2 -2
- data/doc/ex/random_threshold_channel.rb +2 -2
- data/doc/ex/rect01.rb +6 -7
- data/doc/ex/rect02.rb +9 -11
- data/doc/ex/rectangle.rb +3 -4
- data/doc/ex/reduce_noise.rb +2 -2
- data/doc/ex/remap.rb +7 -8
- data/doc/ex/remap_images.rb +9 -11
- data/doc/ex/resize_to_fill.rb +3 -5
- data/doc/ex/resize_to_fit.rb +3 -5
- data/doc/ex/roll.rb +2 -2
- data/doc/ex/rotate.rb +6 -7
- data/doc/ex/rotate_f.rb +2 -2
- data/doc/ex/roundrect.rb +4 -5
- data/doc/ex/rubyname.rb +11 -11
- data/doc/ex/rvg_clippath.rb +5 -7
- data/doc/ex/rvg_linecap.rb +25 -26
- data/doc/ex/rvg_linejoin.rb +25 -26
- data/doc/ex/rvg_opacity.rb +10 -11
- data/doc/ex/rvg_pattern.rb +15 -15
- data/doc/ex/rvg_stroke_dasharray.rb +6 -7
- data/doc/ex/segment.rb +2 -2
- data/doc/ex/sepiatone.rb +2 -3
- data/doc/ex/shade.rb +2 -2
- data/doc/ex/shadow.rb +2 -3
- data/doc/ex/shave.rb +2 -2
- data/doc/ex/shear.rb +3 -3
- data/doc/ex/sketch.rb +2 -3
- data/doc/ex/skewx.rb +4 -5
- data/doc/ex/skewy.rb +3 -3
- data/doc/ex/smile.rb +113 -113
- data/doc/ex/solarize.rb +2 -2
- data/doc/ex/sparse_color.rb +29 -30
- data/doc/ex/splice.rb +2 -3
- data/doc/ex/spread.rb +2 -2
- data/doc/ex/stegano.rb +34 -34
- data/doc/ex/stroke_dasharray.rb +4 -5
- data/doc/ex/stroke_fill.rb +4 -5
- data/doc/ex/stroke_linecap.rb +3 -3
- data/doc/ex/stroke_linejoin.rb +3 -3
- data/doc/ex/stroke_width.rb +3 -3
- data/doc/ex/swirl.rb +2 -2
- data/doc/ex/text.rb +4 -4
- data/doc/ex/text01.rb +7 -8
- data/doc/ex/text_align.rb +2 -2
- data/doc/ex/text_antialias.rb +9 -10
- data/doc/ex/text_styles.rb +11 -13
- data/doc/ex/text_undercolor.rb +2 -2
- data/doc/ex/texture_fill_to_border.rb +6 -6
- data/doc/ex/texture_floodfill.rb +2 -2
- data/doc/ex/texturefill.rb +10 -11
- data/doc/ex/threshold.rb +2 -2
- data/doc/ex/to_blob.rb +4 -5
- data/doc/ex/translate.rb +6 -6
- data/doc/ex/transparent.rb +5 -5
- data/doc/ex/transpose.rb +2 -2
- data/doc/ex/transverse.rb +2 -2
- data/doc/ex/tref01.rb +11 -12
- data/doc/ex/triangle01.rb +5 -6
- data/doc/ex/trim.rb +1 -2
- data/doc/ex/tspan01.rb +8 -9
- data/doc/ex/tspan02.rb +9 -11
- data/doc/ex/tspan03.rb +9 -11
- data/doc/ex/unsharp_mask.rb +2 -2
- data/doc/ex/viewex.rb +19 -21
- data/doc/ex/vignette.rb +2 -2
- data/doc/ex/watermark.rb +15 -16
- data/doc/ex/wave.rb +2 -2
- data/doc/ex/wet_floor.rb +17 -18
- data/doc/ex/writing_mode01.rb +8 -9
- data/doc/ex/writing_mode02.rb +8 -8
- data/doc/ilist.html +1 -1
- data/doc/usage.html +8 -8
- data/examples/constitute.rb +6 -6
- data/examples/crop_with_gravity.rb +13 -17
- data/examples/demo.rb +305 -305
- data/examples/describe.rb +27 -28
- data/examples/find_similar_region.rb +16 -16
- data/examples/histogram.rb +228 -232
- data/examples/identify.rb +165 -167
- data/examples/image_opacity.rb +4 -4
- data/examples/import_export.rb +10 -10
- data/examples/pattern_fill.rb +9 -9
- data/examples/rotating_text.rb +13 -14
- data/examples/spinner.rb +18 -19
- data/examples/thumbnail.rb +13 -14
- data/examples/vignette.rb +8 -9
- data/ext/RMagick/extconf.rb +489 -367
- data/ext/RMagick/rmagick.c +11 -4
- data/ext/RMagick/rmagick.h +4 -0
- data/ext/RMagick/rmdraw.c +49 -18
- data/ext/RMagick/rmenum.c +18 -7
- data/ext/RMagick/rmfill.c +4 -1
- data/ext/RMagick/rmilist.c +49 -13
- data/ext/RMagick/rmimage.c +196 -59
- data/ext/RMagick/rminfo.c +33 -10
- data/ext/RMagick/rmmain.c +18 -6
- data/ext/RMagick/rmmontage.c +12 -4
- data/ext/RMagick/rmpixel.c +18 -5
- data/ext/RMagick/rmstruct.c +108 -31
- data/ext/RMagick/rmutil.c +50 -26
- data/lib/rmagick/version.rb +4 -3
- data/lib/rmagick_internal.rb +1159 -1176
- data/lib/rvg/clippath.rb +36 -39
- data/lib/rvg/container.rb +115 -124
- data/lib/rvg/deep_equal.rb +46 -50
- data/lib/rvg/describable.rb +41 -47
- data/lib/rvg/embellishable.rb +384 -410
- data/lib/rvg/misc.rb +697 -714
- data/lib/rvg/paint.rb +42 -47
- data/lib/rvg/pathdata.rb +120 -125
- data/lib/rvg/rvg.rb +213 -213
- data/lib/rvg/stretchable.rb +159 -162
- data/lib/rvg/stylable.rb +109 -117
- data/lib/rvg/text.rb +9 -24
- data/lib/rvg/transformable.rb +120 -127
- data/lib/rvg/units.rb +58 -61
- data/rmagick.gemspec +46 -15
- data/spec/rmagick/ImageList1_spec.rb +24 -0
- data/spec/rmagick/draw_spec.rb +156 -0
- data/spec/rmagick/image/blue_shift_spec.rb +16 -0
- data/spec/rmagick/image/composite_spec.rb +140 -0
- data/spec/rmagick/image/constitute_spec.rb +15 -0
- data/spec/rmagick/image/dispatch_spec.rb +18 -0
- data/spec/rmagick/image/from_blob_spec.rb +14 -0
- data/spec/rmagick/image/ping_spec.rb +14 -0
- data/spec/rmagick/image/properties_spec.rb +29 -0
- data/spec/spec_helper.rb +4 -0
- data/test/Image1.rb +529 -727
- data/test/Image2.rb +1291 -1299
- data/test/Image3.rb +978 -981
- data/test/ImageList1.rb +7 -9
- data/test/ImageList2.rb +346 -350
- data/test/Image_attributes.rb +683 -686
- data/test/Import_Export.rb +25 -30
- data/test/Info.rb +339 -343
- data/test/Magick.rb +250 -253
- data/test/Pixel.rb +107 -110
- data/test/Preview.rb +48 -53
- data/test/test_all_basic.rb +15 -11
- data/test/tmpnam_test.rb +3 -3
- data/wercker.yml +10 -0
- metadata +77 -10
- data/ChangeLog +0 -816
- data/lib/RMagick.rb +0 -1
- data/test/Draw.rb +0 -121
data/examples/identify.rb
CHANGED
@@ -1,187 +1,185 @@
|
|
1
|
-
require '
|
1
|
+
require 'rmagick'
|
2
2
|
|
3
3
|
module Magick
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
puts "\tTainted: True\n" if changed?
|
163
|
-
puts "\tTainted: False\n" unless changed?
|
164
|
-
puts "\tVersion: #{Magick::Version}\n"
|
165
|
-
puts "\t #{Magick::Magick_version}\n"
|
4
|
+
class Image
|
5
|
+
# Print information similar to the identify -verbose command
|
6
|
+
def identify
|
7
|
+
printf 'Image: '
|
8
|
+
puts "#{base_filename}=>" if base_filename != filename
|
9
|
+
puts filename + "\n"
|
10
|
+
puts "\tFormat: #{format}\n"
|
11
|
+
puts "\tGeometry: #{columns}x#{rows}\n"
|
12
|
+
puts "\tClass: #{class_type}\n"
|
13
|
+
puts "\tType: #{image_type}\n"
|
14
|
+
puts "\tEndianess: #{endian}\n"
|
15
|
+
puts "\tColorspace: #{colorspace}\n"
|
16
|
+
puts "\tChannelDepth:\n"
|
17
|
+
color_space = gray? ? Magick::GrayColorspace : colorspace
|
18
|
+
case color_space
|
19
|
+
when Magick::RGBColorspace
|
20
|
+
puts "\t\tRed: #{channel_depth(Magick::RedChannel)}-bits\n"
|
21
|
+
puts "\t\tGreen: #{channel_depth(Magick::GreenChannel)}-bits\n"
|
22
|
+
puts "\t\tBlue: #{channel_depth(Magick::BlueChannel)}-bits\n"
|
23
|
+
puts "\t\tOpacity: #{channel_depth(Magick::OpacityChannel)}-bits\n" if matte
|
24
|
+
when Magick::CMYKColorspace
|
25
|
+
puts "\t\tCyan : #{channel_depth(Magick::CyanChannel)}-bits\n"
|
26
|
+
puts "\t\tMagenta: #{channel_depth(Magick::MagentaChannel)}-bits\n"
|
27
|
+
puts "\t\tYellow: #{channel_depth(Magick::YellowChannel)}-bits\n"
|
28
|
+
puts "\t\tBlack: #{channel_depth(Magick::BlackChannel)}-bits\n"
|
29
|
+
puts "\t\tOpacity: #{channel_depth(Magick::OpacityChannel)}-bits\n" if matte
|
30
|
+
when Magick::GrayColorspace
|
31
|
+
puts "\t\tGray: #{channel_depth(Magick::GrayChannel)}-bits\n"
|
32
|
+
puts "\t\tOpacity: #{channel_depth(Magick::OpacityChannel)}-bits\n" if matte
|
33
|
+
end
|
34
|
+
scale = Magick::QuantumRange / (Magick::QuantumRange >> (Magick::MAGICKCORE_QUANTUM_DEPTH-channel_depth))
|
35
|
+
puts "\tChannel statistics:\n"
|
36
|
+
case color_space
|
37
|
+
when Magick::RGBColorspace
|
38
|
+
puts "\t\tRed:\n"
|
39
|
+
puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::RedChannel)[0]/scale, channel_extrema(Magick::RedChannel)[0]/Magick::QuantumRange)
|
40
|
+
puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::RedChannel)[1]/scale, channel_extrema(Magick::RedChannel)[1]/Magick::QuantumRange)
|
41
|
+
puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::RedChannel)[0]/scale, channel_mean(Magick::RedChannel)[0]/Magick::QuantumRange)
|
42
|
+
puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::RedChannel)[1]/scale, channel_mean(Magick::RedChannel)[1]/Magick::QuantumRange)
|
43
|
+
puts "\t\tGreen:\n"
|
44
|
+
puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::GreenChannel)[0]/scale, channel_extrema(Magick::GreenChannel)[0]/Magick::QuantumRange)
|
45
|
+
puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::GreenChannel)[1]/scale, channel_extrema(Magick::GreenChannel)[1]/Magick::QuantumRange)
|
46
|
+
puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::GreenChannel)[0]/scale, channel_mean(Magick::GreenChannel)[0]/Magick::QuantumRange)
|
47
|
+
puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::GreenChannel)[1]/scale, channel_mean(Magick::GreenChannel)[1]/Magick::QuantumRange)
|
48
|
+
puts "\t\tBlue:\n"
|
49
|
+
puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::BlueChannel)[0]/scale, channel_extrema(Magick::BlueChannel)[0]/Magick::QuantumRange)
|
50
|
+
puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::BlueChannel)[1]/scale, channel_extrema(Magick::BlueChannel)[1]/Magick::QuantumRange)
|
51
|
+
puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::BlueChannel)[0]/scale, channel_mean(Magick::BlueChannel)[0]/Magick::QuantumRange)
|
52
|
+
puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::BlueChannel)[1]/scale, channel_mean(Magick::BlueChannel)[1]/Magick::QuantumRange)
|
53
|
+
when Magick::CMYKColorspace
|
54
|
+
puts "\t\tCyan:\n"
|
55
|
+
puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::CyanChannel)[0]/scale, channel_extrema(Magick::CyanChannel)[0]/Magick::QuantumRange)
|
56
|
+
puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::CyanChannel)[1]/scale, channel_extrema(Magick::CyanChannel)[1]/Magick::QuantumRange)
|
57
|
+
puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::CyanChannel)[0]/scale, channel_mean(Magick::CyanChannel)[0]/Magick::QuantumRange)
|
58
|
+
puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::CyanChannel)[1]/scale, channel_mean(Magick::CyanChannel)[1]/Magick::QuantumRange)
|
59
|
+
puts "\t\tMagenta:\n"
|
60
|
+
puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::MagentaChannel)[0]/scale, channel_extrema(Magick::MagentaChannel)[0]/Magick::QuantumRange)
|
61
|
+
puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::MagentaChannel)[1]/scale, channel_extrema(Magick::MagentaChannel)[1]/Magick::QuantumRange)
|
62
|
+
puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::MagentaChannel)[0]/scale, channel_mean(Magick::MagentaChannel)[0]/Magick::QuantumRange)
|
63
|
+
puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::MagentaChannel)[1]/scale, channel_mean(Magick::MagentaChannel)[1]/Magick::QuantumRange)
|
64
|
+
puts "\t\tYellow:\n"
|
65
|
+
puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::YellowChannel)[0]/scale, channel_extrema(Magick::YellowChannel)[0]/Magick::QuantumRange)
|
66
|
+
puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::YellowChannel)[1]/scale, channel_extrema(Magick::YellowChannel)[1]/Magick::QuantumRange)
|
67
|
+
puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::YellowChannel)[0]/scale, channel_mean(Magick::YellowChannel)[0]/Magick::QuantumRange)
|
68
|
+
puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::YellowChannel)[1]/scale, channel_mean(Magick::YellowChannel)[1]/Magick::QuantumRange)
|
69
|
+
puts "\t\tBlack:\n"
|
70
|
+
puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::BlackChannel)[0]/scale, channel_extrema(Magick::BlackChannel)[0]/Magick::QuantumRange)
|
71
|
+
puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::BlackChannel)[1]/scale, channel_extrema(Magick::BlackChannel)[1]/Magick::QuantumRange)
|
72
|
+
puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::BlackChannel)[0]/scale, channel_mean(Magick::BlackChannel)[0]/Magick::QuantumRange)
|
73
|
+
puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::BlackChannel)[1]/scale, channel_mean(Magick::BlackChannel)[1]/Magick::QuantumRange)
|
74
|
+
when Magick::GrayColorspace
|
75
|
+
puts "\t\tGray:\n"
|
76
|
+
puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::GrayChannel)[0]/scale, channel_extrema(Magick::GrayChannel)[0]/Magick::QuantumRange)
|
77
|
+
puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::GrayChannel)[1]/scale, channel_extrema(Magick::GrayChannel)[1]/Magick::QuantumRange)
|
78
|
+
puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::GrayChannel)[0]/scale, channel_mean(Magick::GrayChannel)[0]/Magick::QuantumRange)
|
79
|
+
puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::GrayChannel)[1]/scale, channel_mean(Magick::GrayChannel)[1]/Magick::QuantumRange)
|
80
|
+
end
|
81
|
+
if matte
|
82
|
+
puts "\t\tOpacity:\n"
|
83
|
+
puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::OpacityChannel)[0]/scale, channel_extrema(Magick::OpacityChannel)[0]/Magick::QuantumRange)
|
84
|
+
puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::OpacityChannel)[1]/scale, channel_extrema(Magick::OpacityChannel)[1]/Magick::QuantumRange)
|
85
|
+
puts "\t\t\tMean:" + sprintf("%u (%g)\n", channel_mean(Magick::OpacityChannel)[0]/scale, channel_mean(Magick::OpacityChannel)[0]/Magick::QuantumRange)
|
86
|
+
puts "\t\t\tStandard deviation:" + sprintf("%u (%g)\n", channel_mean(Magick::OpacityChannel)[1]/scale, channel_mean(Magick::OpacityChannel)[1]/Magick::QuantumRange)
|
87
|
+
end
|
88
|
+
if class_type == Magick::DirectClass
|
89
|
+
puts "\tColors: #{total_colors}\n"
|
90
|
+
else
|
91
|
+
if total_colors <= colors
|
92
|
+
puts "\tColors: #{colors}\n"
|
93
|
+
else
|
94
|
+
puts "\tColors: #{total_colors}=>#{colors}\n"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
# Histogram goes here
|
98
|
+
puts "\tMean error per pixel: #{mean_error_per_pixel}\n" if mean_error_per_pixel != 0.0
|
99
|
+
puts "\tNormalized mean error: #{normalized_mean_error}\n" if normalized_mean_error != 0.0
|
100
|
+
puts "\tNormalized maximum error: #{normalized_maximum_error}\n" if normalized_maximum_error != 0.0
|
101
|
+
puts "\tRendering-intent: #{rendering_intent}\n"
|
102
|
+
puts "\tGamma: #{gamma}\n" if gamma != 0.0
|
103
|
+
chrom = chromaticity
|
104
|
+
if chrom.red_primary.x != 0.0 || chrom.green_primary.x != 0.0 || chrom.blue_primary.x != 0.0 || chrom.white_point.x != 0.0
|
105
|
+
puts "\tChromaticity:\n"
|
106
|
+
puts "\t\tred primary: (#{sprintf('%g,%g', chrom.red_primary.x, chrom.red_primary.y)})\n"
|
107
|
+
puts "\t\tgreen primary: (#{sprintf('%g,%g', chrom.green_primary.x, chrom.green_primary.y)})\n"
|
108
|
+
puts "\t\tblue primary: (#{sprintf('%g,%g', chrom.blue_primary.x, chrom.blue_primary.y)})\n"
|
109
|
+
puts "\t\twhite point: (#{sprintf('%g,%g', chrom.white_point.x, chrom.white_point.y)})\n"
|
110
|
+
end
|
111
|
+
ex_info = extract_info
|
112
|
+
if ex_info.width * ex_info.height != 0.0
|
113
|
+
puts "\tTile geometry: #{ex_info.width}x#{ex_info.height}+#{ex_info.x}+#{ex_info.y}\n"
|
114
|
+
end
|
115
|
+
if x_resolution != 0.0 && y_resolution != 0.0
|
116
|
+
puts "\tResolution: #{sprintf('%gx%g', x_resolution, y_resolution)}\n"
|
117
|
+
end
|
118
|
+
puts "\tUnits: #{units}\n"
|
119
|
+
size = filesize
|
120
|
+
if size >= 1048576
|
121
|
+
puts "\tFilesize: #{'%.1f' % (size/1048576.0)}mb\n"
|
122
|
+
elsif size >= 1024
|
123
|
+
puts "\tFilesize: #{'%.0f' % (size/1024.0)}kb\n"
|
124
|
+
else
|
125
|
+
puts "\tFilesize: #{size}b\n"
|
126
|
+
end
|
127
|
+
puts "\tInterlace: #{interlace}\n"
|
128
|
+
puts "\tBackground Color: #{background_color}\n"
|
129
|
+
puts "\tBorder Color: #{border_color}\n"
|
130
|
+
puts "\tMatte Color: #{matte_color}\n"
|
131
|
+
pg = page
|
132
|
+
if pg.width != 0 || pg.height != 0 || pg.x != 0 || pg.y != 0
|
133
|
+
puts "\tPage geometry: #{pg.width}x#{pg.height}+#{pg.x}+#{pg.y}\n"
|
134
|
+
end
|
135
|
+
puts "\tDispose: #{dispose}\n"
|
136
|
+
puts "\tDelay: #{delay}\n" if delay != 0
|
137
|
+
puts "\tIterations: #{iterations}\n" unless iterations == 1
|
138
|
+
puts "\tScene: #{scene}\n" if scene != 0
|
139
|
+
puts "\tCompression: #{compression}\n"
|
140
|
+
puts "\tQuality: #{quality}\n" unless quality == 0
|
141
|
+
puts "\tOrientation: #{orientation}\n"
|
142
|
+
puts "\tMontage: #{montage}\n" if montage
|
143
|
+
signature # compute but ignore - will be displayed along with the other properties
|
144
|
+
properties.each do |prop, value|
|
145
|
+
next if prop[0,1] == '['
|
146
|
+
puts "\t#{prop}: #{value}\n"
|
147
|
+
end
|
148
|
+
clip_path = self['8BIM:1999,2998:#1']
|
149
|
+
if clip_path
|
150
|
+
puts "\tClipping path: #{clip_path}\n"
|
151
|
+
end
|
152
|
+
each_profile do |name, value|
|
153
|
+
puts "\tProfile-#{name}: #{value.length}\n"
|
154
|
+
if name == 'exif'
|
155
|
+
exif_attrs = get_exif_by_entry
|
156
|
+
exif_attrs.each do |attr|
|
157
|
+
puts "\t\t#{attr[0]}: #{attr[1]}\n"
|
158
|
+
end
|
166
159
|
end
|
160
|
+
end
|
161
|
+
puts "\tTainted: True\n" if changed?
|
162
|
+
puts "\tTainted: False\n" unless changed?
|
163
|
+
puts "\tVersion: #{Magick::Version}\n"
|
164
|
+
puts "\t #{Magick::Magick_version}\n"
|
167
165
|
end
|
166
|
+
end
|
168
167
|
end
|
169
168
|
|
170
169
|
if ARGV.length == 0
|
171
|
-
|
170
|
+
puts <<-'END_USAGE'
|
172
171
|
This example displays information about the specified image file(s)
|
173
172
|
that is similar to ImageMagick/GraphicsMagick's identify command.
|
174
173
|
|
175
174
|
Usage:
|
176
175
|
ruby identify.rb filename [filename...]
|
177
176
|
END_USAGE
|
178
|
-
|
177
|
+
exit
|
179
178
|
end
|
180
179
|
|
181
180
|
ilist = Magick::ImageList.new(*ARGV)
|
182
181
|
ilist.each do |img|
|
183
|
-
|
182
|
+
img.identify
|
184
183
|
end
|
185
184
|
|
186
185
|
exit
|
187
|
-
|
data/examples/image_opacity.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
# Ccreate a semi-transparent title for an image.
|
3
3
|
|
4
|
-
require '
|
4
|
+
require 'rmagick'
|
5
5
|
include Magick
|
6
6
|
|
7
7
|
puts <<END_INFO
|
@@ -15,15 +15,15 @@ balloons = Image.read('../doc/ex/images/Hot_Air_Balloons_H.jpg').first
|
|
15
15
|
legend = Image.new(160, 50) { self.background_color = '#ffffffc0' }
|
16
16
|
|
17
17
|
gc = Draw.new
|
18
|
-
gc.annotate(legend, 0, 0, 0, 0,
|
18
|
+
gc.annotate(legend, 0, 0, 0, 0, 'Balloon Day!\\nFri May 2 2003') do
|
19
19
|
self.gravity = CenterGravity
|
20
20
|
self.stroke = 'transparent'
|
21
21
|
self.fill = 'white'
|
22
22
|
self.pointsize = 18
|
23
|
-
|
23
|
+
end
|
24
24
|
|
25
25
|
result = balloons.composite(legend, SouthGravity, OverCompositeOp)
|
26
26
|
|
27
|
-
puts
|
27
|
+
puts '...Writing image_opacity.miff'
|
28
28
|
result.write 'image_opacity.miff'
|
29
29
|
exit
|
data/examples/import_export.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# Demonstrate the export_pixels and import_pixels methods.
|
3
3
|
#
|
4
4
|
|
5
|
-
require '
|
5
|
+
require 'rmagick'
|
6
6
|
include Magick
|
7
7
|
|
8
8
|
puts <<END_INFO
|
@@ -14,18 +14,18 @@ is identical to the original.
|
|
14
14
|
END_INFO
|
15
15
|
|
16
16
|
img = Image.read('../doc/ex/images/Gold_Statue.jpg').first
|
17
|
-
copy = Image.new(img.columns, img.rows)
|
17
|
+
copy = Image.new(img.columns, img.rows)
|
18
18
|
|
19
19
|
begin
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
img.rows.times do |r|
|
21
|
+
scanline = img.export_pixels(0, r, img.columns, 1, 'RGB')
|
22
|
+
copy.import_pixels(0, r, img.columns, 1, 'RGB', scanline)
|
23
|
+
end
|
24
24
|
rescue NotImplementedError
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
$stderr.puts 'The export_pixels and import_pixels methods are not supported' \
|
26
|
+
' by this version of ImageMagick/GraphicsMagick'
|
27
|
+
exit
|
28
28
|
end
|
29
29
|
|
30
|
-
copy.write(
|
30
|
+
copy.write('copy.gif')
|
31
31
|
exit
|
data/examples/pattern_fill.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Usage: pattern_fill.rb <name-of-pattern>
|
6
6
|
# Try 'checkerboard' or 'verticalsaw'
|
7
7
|
|
8
|
-
require '
|
8
|
+
require 'rmagick'
|
9
9
|
include Magick
|
10
10
|
|
11
11
|
puts <<END_INFO
|
@@ -17,22 +17,22 @@ supported patterns as an argument. For example, try "checkerboard".
|
|
17
17
|
END_INFO
|
18
18
|
|
19
19
|
class PatternFill < Magick::TextureFill
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
def initialize(name='bricks')
|
21
|
+
@pat_img = Magick::Image.read("pattern:#{name}").first
|
22
|
+
super(@pat_img)
|
23
|
+
end
|
24
24
|
end
|
25
25
|
|
26
26
|
if ARGV[0]
|
27
|
-
|
27
|
+
pattern = ARGV[0]
|
28
28
|
else
|
29
|
-
|
30
|
-
|
29
|
+
$stderr.puts 'Defaulting to checkerboard pattern.'
|
30
|
+
pattern = 'checkerboard'
|
31
31
|
end
|
32
32
|
|
33
33
|
# Create a sample image that is 100x bigger than the pattern.
|
34
34
|
attrs = Image.ping("pattern:#{pattern}").first
|
35
35
|
|
36
36
|
tryit = Image.new(10*attrs.columns, 10*attrs.rows, PatternFill.new(pattern))
|
37
|
-
tryit.write(
|
37
|
+
tryit.write('pattern_fill.gif')
|
38
38
|
exit
|
data/examples/rotating_text.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# Demonstrate the Draw#rotation= method by producing
|
2
2
|
# an animated MIFF file showing a rotating text string.
|
3
3
|
|
4
|
-
|
5
|
-
require 'RMagick'
|
4
|
+
require 'rmagick'
|
6
5
|
include Magick
|
7
6
|
|
8
7
|
puts <<END_INFO
|
@@ -19,27 +18,27 @@ text.gravity = CenterGravity
|
|
19
18
|
|
20
19
|
# Let's make it interesting. Composite the
|
21
20
|
# rotated text over a gradient fill background.
|
22
|
-
fill = GradientFill.new(100,100,100,100,
|
21
|
+
fill = GradientFill.new(100,100,100,100,'yellow','red')
|
23
22
|
bg = Image.new(200, 200, fill)
|
24
23
|
|
25
24
|
# The "none" color is transparent.
|
26
|
-
fg = Image.new(bg.columns, bg.rows) { self.background_color =
|
25
|
+
fg = Image.new(bg.columns, bg.rows) { self.background_color = 'none' }
|
27
26
|
|
28
27
|
# Here's where we'll collect the individual frames.
|
29
28
|
animation = ImageList.new
|
30
29
|
|
31
|
-
0.step(345,15)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
30
|
+
0.step(345,15) do |degrees|
|
31
|
+
frame = fg.copy
|
32
|
+
text.annotate(frame, 0,0,0,0, 'Rotating Text') do
|
33
|
+
self.rotation = degrees
|
34
|
+
end
|
35
|
+
# Composite the text over the gradient filled background frame.
|
36
|
+
animation << bg.composite(frame, CenterGravity, DisplaceCompositeOp)
|
37
|
+
end
|
39
38
|
|
40
39
|
animation.delay = 8
|
41
40
|
|
42
41
|
#animation.animate
|
43
|
-
puts
|
44
|
-
animation.write(
|
42
|
+
puts '...Writing rotating_text.gif'
|
43
|
+
animation.write('rotating_text.gif')
|
45
44
|
exit
|
data/examples/spinner.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Make a 32x32 animated GIF that resembles the OS X animation.
|
2
2
|
# This produces a very small (~2.6Kb) GIF file.
|
3
3
|
|
4
|
-
require '
|
4
|
+
require 'rmagick'
|
5
5
|
|
6
6
|
puts <<END_INFO
|
7
7
|
This example creates an animated GIF that resembles the OS X "waiting" icon.
|
@@ -10,7 +10,6 @@ You can view the GIF with the command
|
|
10
10
|
animate spinner.gif
|
11
11
|
END_INFO
|
12
12
|
|
13
|
-
|
14
13
|
NFRAMES = 12 # number of frames in the animation
|
15
14
|
DIM = 32 # width & height of image in pixels
|
16
15
|
DELAY = 100.0 / (NFRAMES/2) # 2 rotations per second
|
@@ -25,26 +24,26 @@ spinner = Magick::ImageList.new
|
|
25
24
|
level = Magick::QuantumRange / 2 / NFRAMES
|
26
25
|
|
27
26
|
NFRAMES.times do |x|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
gc = Magick::Draw.new
|
28
|
+
gc.translate(DIM/2, DIM/2)
|
29
|
+
gc.stroke('none')
|
30
|
+
intensity = 0.58 * Magick::QuantumRange
|
31
|
+
fill_color = Magick::Pixel.new(intensity, intensity, intensity).to_color
|
32
|
+
gc.fill(fill_color)
|
33
|
+
angle = x * (360/NFRAMES)
|
34
|
+
NFRAMES.times do
|
35
|
+
gc.rotate(angle)
|
36
|
+
intensity = [intensity, Magick::QuantumRange].min
|
32
37
|
fill_color = Magick::Pixel.new(intensity, intensity, intensity).to_color
|
33
38
|
gc.fill(fill_color)
|
34
|
-
|
35
|
-
NFRAMES
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
gc.roundrectangle(7, -1, 15, 0, 1, 1)
|
41
|
-
angle = -(360/NFRAMES)
|
42
|
-
intensity += level
|
43
|
-
end
|
44
|
-
spinner << frame.copy
|
45
|
-
gc.draw(spinner)
|
39
|
+
gc.roundrectangle(7, -1, 15, 0, 1, 1)
|
40
|
+
angle = -(360/NFRAMES)
|
41
|
+
intensity += level
|
42
|
+
end
|
43
|
+
spinner << frame.copy
|
44
|
+
gc.draw(spinner)
|
46
45
|
end
|
47
46
|
|
48
47
|
spinner.delay = DELAY
|
49
48
|
spinner.compression = Magick::LZWCompression
|
50
|
-
spinner.write('spinner.gif')
|
49
|
+
spinner.write('spinner.gif')
|