rmagick 1.13.0 → 1.14.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.
- data/ChangeLog +34 -0
- data/README.html +12 -29
- data/README.txt +10 -26
- data/configure +768 -73
- data/configure.ac +29 -26
- data/doc/comtasks.html +3 -4
- data/doc/constants.html +85 -67
- data/doc/draw.html +22 -0
- data/doc/ex/dissolve.rb +13 -0
- data/doc/ex/edge.rb +1 -1
- data/doc/ex/mask.rb +37 -0
- data/doc/ex/sketch.rb +25 -0
- data/doc/ex/watermark.rb +23 -0
- data/doc/ilist.html +11 -13
- data/doc/image1.html +601 -52
- data/doc/image2.html +637 -28
- data/doc/image3.html +339 -54
- data/doc/imageattrs.html +211 -41
- data/doc/imusage.html +41 -2
- data/doc/index.html +8 -6
- data/doc/info.html +57 -42
- data/doc/optequiv.html +1919 -0
- data/doc/rvg.html +45 -42
- data/doc/scripts/doc.js +14 -1
- data/doc/scripts/stripeTables.js +23 -0
- data/doc/usage.html +66 -15
- data/{doc/ex → examples}/demo.rb +0 -0
- data/examples/find_similar_region.rb +34 -0
- data/examples/import_export.rb +1 -1
- data/examples/pattern_fill.rb +2 -2
- data/examples/rotating_text.rb +2 -4
- data/examples/thumbnail.rb +1 -1
- data/ext/RMagick/MANIFEST +9 -4
- data/ext/RMagick/extconf.rb.in +1 -1
- data/ext/RMagick/rmagick.h +47 -10
- data/ext/RMagick/rmagick_config.h.in +24 -0
- data/ext/RMagick/rmdraw.c +32 -7
- data/ext/RMagick/rmilist.c +55 -37
- data/ext/RMagick/rmimage.c +1588 -447
- data/ext/RMagick/rminfo.c +94 -3
- data/ext/RMagick/rmmain.c +68 -7
- data/ext/RMagick/rmutil.c +67 -9
- data/lib/RMagick.rb +190 -53
- data/lib/rvg/stretchable.rb +17 -13
- data/rmagick.gemspec +1 -1
- metadata +11 -6
- data/doc/ex/level_channel.rb +0 -33
- data/doc/ex/opaque.rb +0 -14
data/lib/RMagick.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id: RMagick.rb,v 1.
|
1
|
+
# $Id: RMagick.rb,v 1.48 2006/08/27 23:06:00 rmagick Exp $
|
2
2
|
#==============================================================================
|
3
3
|
# Copyright (C) 2006 by Timothy P. Hunter
|
4
4
|
# Name: RMagick.rb
|
@@ -54,14 +54,14 @@ class Geometry
|
|
54
54
|
elsif width.to_f >= 0.0
|
55
55
|
@width = width.to_f
|
56
56
|
else
|
57
|
-
raise ArgumentError, "width must be >= 0: #{width}"
|
57
|
+
Kernel.raise ArgumentError, "width must be >= 0: #{width}"
|
58
58
|
end
|
59
59
|
if height == nil
|
60
60
|
@height = 0
|
61
61
|
elsif height.to_f >= 0.0
|
62
62
|
@height = height.to_f
|
63
63
|
else
|
64
|
-
raise ArgumentError, "height must be >= 0: #{height}"
|
64
|
+
Kernel.raise ArgumentError, "height must be >= 0: #{height}"
|
65
65
|
end
|
66
66
|
|
67
67
|
@x = x.to_i
|
@@ -73,7 +73,7 @@ class Geometry
|
|
73
73
|
RE = /\A(\d*)(?:x(\d+))?([-+]\d+)?([-+]\d+)?([%!<>@]?)\Z/
|
74
74
|
|
75
75
|
def Geometry.from_s(str)
|
76
|
-
raise(ArgumentError, "no geometry string specified") unless str
|
76
|
+
Kernel.raise(ArgumentError, "no geometry string specified") unless str
|
77
77
|
|
78
78
|
m = RE.match(str)
|
79
79
|
if m
|
@@ -83,7 +83,7 @@ class Geometry
|
|
83
83
|
y = m[4].to_i
|
84
84
|
flag = RFLAGS[m[5]]
|
85
85
|
else
|
86
|
-
raise ArgumentError, "invalid geometry format"
|
86
|
+
Kernel.raise ArgumentError, "invalid geometry format"
|
87
87
|
end
|
88
88
|
Geometry.new(width, height, x, y, flag)
|
89
89
|
end
|
@@ -190,9 +190,9 @@ class Draw
|
|
190
190
|
# Draw a bezier curve.
|
191
191
|
def bezier(*points)
|
192
192
|
if points.length == 0
|
193
|
-
raise ArgumentError, "no points specified"
|
193
|
+
Kernel.raise ArgumentError, "no points specified"
|
194
194
|
elsif points.length % 2 != 0
|
195
|
-
raise ArgumentError, "odd number of arguments specified"
|
195
|
+
Kernel.raise ArgumentError, "odd number of arguments specified"
|
196
196
|
end
|
197
197
|
primitive "bezier " + points.join(',')
|
198
198
|
end
|
@@ -210,7 +210,7 @@ class Draw
|
|
210
210
|
# Define the clipping rule.
|
211
211
|
def clip_rule(rule)
|
212
212
|
if ( not ["evenodd", "nonzero"].include?(rule.downcase) )
|
213
|
-
raise ArgumentError, "Unknown clipping rule #{rule}"
|
213
|
+
Kernel.raise ArgumentError, "Unknown clipping rule #{rule}"
|
214
214
|
end
|
215
215
|
primitive "clip-rule #{rule}"
|
216
216
|
end
|
@@ -218,7 +218,7 @@ class Draw
|
|
218
218
|
# Define the clip units
|
219
219
|
def clip_units(unit)
|
220
220
|
if ( not ["userspace", "userspaceonuse", "objectboundingbox"].include?(unit.downcase) )
|
221
|
-
raise ArgumentError, "Unknown clip unit #{unit}"
|
221
|
+
Kernel.raise ArgumentError, "Unknown clip unit #{unit}"
|
222
222
|
end
|
223
223
|
primitive "clip-units #{unit}"
|
224
224
|
end
|
@@ -227,7 +227,7 @@ class Draw
|
|
227
227
|
# point, replace, floodfill, filltoborder,reset
|
228
228
|
def color(x, y, method)
|
229
229
|
if ( not PAINT_METHOD_NAMES.has_key?(method.to_i) )
|
230
|
-
raise ArgumentError, "Unknown PaintMethod: #{method}"
|
230
|
+
Kernel.raise ArgumentError, "Unknown PaintMethod: #{method}"
|
231
231
|
end
|
232
232
|
primitive "color #{x},#{y},#{PAINT_METHOD_NAMES[method.to_i]}"
|
233
233
|
end
|
@@ -286,7 +286,7 @@ class Draw
|
|
286
286
|
|
287
287
|
def fill_rule(rule)
|
288
288
|
if ( not ["evenodd", "nonzero"].include?(rule.downcase) )
|
289
|
-
raise ArgumentError, "Unknown fill rule #{rule}"
|
289
|
+
Kernel.raise ArgumentError, "Unknown fill rule #{rule}"
|
290
290
|
end
|
291
291
|
primitive "fill-rule #{rule}"
|
292
292
|
end
|
@@ -302,14 +302,14 @@ class Draw
|
|
302
302
|
|
303
303
|
def font_stretch(stretch)
|
304
304
|
if ( not STRETCH_TYPE_NAMES.has_key?(stretch.to_i) )
|
305
|
-
raise ArgumentError, "Unknown stretch type"
|
305
|
+
Kernel.raise ArgumentError, "Unknown stretch type"
|
306
306
|
end
|
307
307
|
primitive "font-stretch #{STRETCH_TYPE_NAMES[stretch.to_i]}"
|
308
308
|
end
|
309
309
|
|
310
310
|
def font_style(style)
|
311
311
|
if ( not STYLE_TYPE_NAMES.has_key?(style.to_i) )
|
312
|
-
raise ArgumentError, "Unknown style type"
|
312
|
+
Kernel.raise ArgumentError, "Unknown style type"
|
313
313
|
end
|
314
314
|
primitive "font-style #{STYLE_TYPE_NAMES[style.to_i]}"
|
315
315
|
end
|
@@ -328,7 +328,7 @@ class Draw
|
|
328
328
|
# NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast
|
329
329
|
def gravity(grav)
|
330
330
|
if ( not GRAVITY_NAMES.has_key?(grav.to_i) )
|
331
|
-
raise ArgumentError, "Unknown text positioning gravity"
|
331
|
+
Kernel.raise ArgumentError, "Unknown text positioning gravity"
|
332
332
|
end
|
333
333
|
primitive "gravity #{GRAVITY_NAMES[grav.to_i]}"
|
334
334
|
end
|
@@ -342,7 +342,7 @@ class Draw
|
|
342
342
|
# colorization rule
|
343
343
|
def matte(x, y, rule)
|
344
344
|
if ( not PAINT_METHOD_NAMES.has_key?(method.to_i) )
|
345
|
-
raise ArgumentError, "Unknown paint method"
|
345
|
+
Kernel.raise ArgumentError, "Unknown paint method"
|
346
346
|
end
|
347
347
|
primitive "matte #{x},#{y} #{PAINT_METHOD_NAMES[method.to_i]}"
|
348
348
|
end
|
@@ -352,7 +352,7 @@ class Draw
|
|
352
352
|
def opacity(opacity)
|
353
353
|
if (Numeric === opacity)
|
354
354
|
if (opacity < 0 || opacity > 1.0)
|
355
|
-
raise ArgumentError, "opacity must be >= 0 and <= 1.0"
|
355
|
+
Kernel.raise ArgumentError, "opacity must be >= 0 and <= 1.0"
|
356
356
|
end
|
357
357
|
end
|
358
358
|
primitive "opacity #{opacity}"
|
@@ -396,9 +396,9 @@ class Draw
|
|
396
396
|
# Draw a polygon
|
397
397
|
def polygon(*points)
|
398
398
|
if points.length == 0
|
399
|
-
raise ArgumentError, "no points specified"
|
399
|
+
Kernel.raise ArgumentError, "no points specified"
|
400
400
|
elsif points.length % 2 != 0
|
401
|
-
raise ArgumentError, "odd number of points specified"
|
401
|
+
Kernel.raise ArgumentError, "odd number of points specified"
|
402
402
|
end
|
403
403
|
primitive "polygon " + points.join(',')
|
404
404
|
end
|
@@ -406,9 +406,9 @@ class Draw
|
|
406
406
|
# Draw a polyline
|
407
407
|
def polyline(*points)
|
408
408
|
if points.length == 0
|
409
|
-
raise ArgumentError, "no points specified"
|
409
|
+
Kernel.raise ArgumentError, "no points specified"
|
410
410
|
elsif points.length % 2 != 0
|
411
|
-
raise ArgumentError, "odd number of points specified"
|
411
|
+
Kernel.raise ArgumentError, "odd number of points specified"
|
412
412
|
end
|
413
413
|
primitive "polyline " + points.join(',')
|
414
414
|
end
|
@@ -492,7 +492,7 @@ class Draw
|
|
492
492
|
else
|
493
493
|
list.each { |x|
|
494
494
|
if x <= 0 then
|
495
|
-
raise ArgumentError, "dash array elements must be > 0 (#{x} given)"
|
495
|
+
Kernel.raise ArgumentError, "dash array elements must be > 0 (#{x} given)"
|
496
496
|
end
|
497
497
|
}
|
498
498
|
primitive "stroke-dasharray #{list.join(',')}"
|
@@ -506,21 +506,21 @@ class Draw
|
|
506
506
|
|
507
507
|
def stroke_linecap(value)
|
508
508
|
if ( not ["butt", "round", "square"].include?(value.downcase) )
|
509
|
-
raise ArgumentError, "Unknown linecap type: #{value}"
|
509
|
+
Kernel.raise ArgumentError, "Unknown linecap type: #{value}"
|
510
510
|
end
|
511
511
|
primitive "stroke-linecap #{value}"
|
512
512
|
end
|
513
513
|
|
514
514
|
def stroke_linejoin(value)
|
515
515
|
if ( not ["round", "miter", "bevel"].include?(value.downcase) )
|
516
|
-
raise ArgumentError, "Unknown linejoin type: #{value}"
|
516
|
+
Kernel.raise ArgumentError, "Unknown linejoin type: #{value}"
|
517
517
|
end
|
518
518
|
primitive "stroke-linejoin #{value}"
|
519
519
|
end
|
520
520
|
|
521
521
|
def stroke_miterlimit(value)
|
522
522
|
if (value < 1)
|
523
|
-
raise ArgumentError, "miterlimit must be >= 1"
|
523
|
+
Kernel.raise ArgumentError, "miterlimit must be >= 1"
|
524
524
|
end
|
525
525
|
primitive "stroke-miterlimit #{value}"
|
526
526
|
end
|
@@ -539,7 +539,7 @@ class Draw
|
|
539
539
|
# Draw text at position x,y. Add quotes to text that is not already quoted.
|
540
540
|
def text(x, y, text)
|
541
541
|
if text.to_s.empty?
|
542
|
-
raise ArgumentError, "missing text argument"
|
542
|
+
Kernel.raise ArgumentError, "missing text argument"
|
543
543
|
end
|
544
544
|
if text.length > 2 && /\A(?:\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})\z/.match(text)
|
545
545
|
; # text already quoted
|
@@ -559,7 +559,7 @@ class Draw
|
|
559
559
|
# Specify text alignment relative to a given point
|
560
560
|
def text_align(alignment)
|
561
561
|
if ( not ALIGN_TYPE_NAMES.has_key?(alignment.to_i) )
|
562
|
-
raise ArgumentError, "Unknown alignment constant: #{alignment}"
|
562
|
+
Kernel.raise ArgumentError, "Unknown alignment constant: #{alignment}"
|
563
563
|
end
|
564
564
|
primitive "text-align #{ALIGN_TYPE_NAMES[alignment.to_i]}"
|
565
565
|
end
|
@@ -567,7 +567,7 @@ class Draw
|
|
567
567
|
# SVG-compatible version of text_align
|
568
568
|
def text_anchor(anchor)
|
569
569
|
if ( not ANCHOR_TYPE_NAMES.has_key?(anchor.to_i) )
|
570
|
-
raise ArgumentError, "Unknown anchor constant: #{anchor}"
|
570
|
+
Kernel.raise ArgumentError, "Unknown anchor constant: #{anchor}"
|
571
571
|
end
|
572
572
|
primitive "text-anchor #{ANCHOR_TYPE_NAMES[anchor.to_i]}"
|
573
573
|
end
|
@@ -590,6 +590,115 @@ class Draw
|
|
590
590
|
end
|
591
591
|
end # class Magick::Draw
|
592
592
|
|
593
|
+
|
594
|
+
# Define IPTC record number:dataset tags for use with Image#get_iptc_dataset
|
595
|
+
module IPTC
|
596
|
+
module Envelope
|
597
|
+
Model_Version = "1:00"
|
598
|
+
Destination = "1:05"
|
599
|
+
File_Format = "1:20"
|
600
|
+
File_Format_Version = "1:22"
|
601
|
+
Service_Identifier = "1:30"
|
602
|
+
Envelope_Number = "1:40"
|
603
|
+
Product_ID = "1:50"
|
604
|
+
Envelope_Priority = "1:60"
|
605
|
+
Date_Sent = "1:70"
|
606
|
+
Time_Sent = "1:80"
|
607
|
+
Coded_Character_Set = "1:90"
|
608
|
+
UNO = "1:100"
|
609
|
+
Unique_Name_of_Object = "1:100"
|
610
|
+
ARM_Identifier = "1:120"
|
611
|
+
ARM_Version = "1:122"
|
612
|
+
end
|
613
|
+
|
614
|
+
module Application
|
615
|
+
#Record_Version = "2:00" abends with IM 6.2.9
|
616
|
+
Object_Type_Reference = "2:03"
|
617
|
+
Object_Name = "2:05"
|
618
|
+
Title = "2:05"
|
619
|
+
Edit_Status = "2:07"
|
620
|
+
Editorial_Update = "2:08"
|
621
|
+
Urgency = "2:10"
|
622
|
+
Subject_Reference = "2:12"
|
623
|
+
Category = "2:15"
|
624
|
+
Supplemental_Category = "2:20"
|
625
|
+
Fixture_Identifier = "2:22"
|
626
|
+
Keywords = "2:25"
|
627
|
+
Content_Location_Code = "2:26"
|
628
|
+
Content_Location_Name = "2:27"
|
629
|
+
Release_Date = "2:30"
|
630
|
+
Release_Time = "2:35"
|
631
|
+
Expiration_Date = "2:37"
|
632
|
+
Expiration_Time = "2:35"
|
633
|
+
Special_Instructions = "2:40"
|
634
|
+
Action_Advised = "2:42"
|
635
|
+
Reference_Service = "2:45"
|
636
|
+
Reference_Date = "2:47"
|
637
|
+
Reference_Number = "2:50"
|
638
|
+
Date_Created = "2:55"
|
639
|
+
Time_Created = "2:60"
|
640
|
+
Digital_Creation_Date = "2:62"
|
641
|
+
Digital_Creation_Time = "2:63"
|
642
|
+
Originating_Program = "2:65"
|
643
|
+
Program_Version = "2:70"
|
644
|
+
Object_Cycle = "2:75"
|
645
|
+
By_Line = "2:80"
|
646
|
+
Author = "2:80"
|
647
|
+
By_Line_Title = "2:85"
|
648
|
+
Author_Position = "2:85"
|
649
|
+
City = "2:90"
|
650
|
+
Sub_Location = "2:92"
|
651
|
+
Province = "2:95"
|
652
|
+
State = "2:95"
|
653
|
+
Country_Primary_Location_Code = "2:100"
|
654
|
+
Country_Primary_Location_Name = "2:101"
|
655
|
+
Original_Transmission_Reference = "2:103"
|
656
|
+
Headline = "2:105"
|
657
|
+
Credit = "2:110"
|
658
|
+
Source = "2:115"
|
659
|
+
Copyright_Notice = "2:116"
|
660
|
+
Contact = "2:118"
|
661
|
+
Abstract = "2:120"
|
662
|
+
Caption = "2:120"
|
663
|
+
Editor = "2:122"
|
664
|
+
Caption_Writer = "2:122"
|
665
|
+
Rasterized_Caption = "2:125"
|
666
|
+
Image_Type = "2:130"
|
667
|
+
Image_Orientation = "2:131"
|
668
|
+
Language_Identifier = "2:135"
|
669
|
+
Audio_Type = "2:150"
|
670
|
+
Audio_Sampling_Rate = "2:151"
|
671
|
+
Audio_Sampling_Resolution = "2:152"
|
672
|
+
Audio_Duration = "2:153"
|
673
|
+
Audio_Outcue = "2:154"
|
674
|
+
ObjectData_Preview_File_Format = "2:200"
|
675
|
+
ObjectData_Preview_File_Format_Version = "2:201"
|
676
|
+
ObjectData_Preview_Data = "2:202"
|
677
|
+
end
|
678
|
+
|
679
|
+
module Pre_ObjectData_Descriptor
|
680
|
+
Size_Mode = "7:10"
|
681
|
+
Max_Subfile_Size = "7:20"
|
682
|
+
ObjectData_Size_Announced = "7:90"
|
683
|
+
Maximum_ObjectData_Size = "7:95"
|
684
|
+
end
|
685
|
+
|
686
|
+
module ObjectData
|
687
|
+
Subfile = "8:10"
|
688
|
+
end
|
689
|
+
|
690
|
+
module Post_ObjectData_Descriptor
|
691
|
+
Confirmed_ObjectData_Size = "9:10"
|
692
|
+
end
|
693
|
+
|
694
|
+
# Make all constants above immutable
|
695
|
+
constants.each do |record|
|
696
|
+
rec = const_get(record)
|
697
|
+
rec.constants.each { |ds| rec.const_get(ds).freeze }
|
698
|
+
end
|
699
|
+
|
700
|
+
end # module Magick::IPTC
|
701
|
+
|
593
702
|
# Ruby-level Magick::Image methods
|
594
703
|
class Image
|
595
704
|
include Comparable
|
@@ -698,6 +807,24 @@ class Image
|
|
698
807
|
return hash
|
699
808
|
end
|
700
809
|
|
810
|
+
# Retrieve IPTC information by record number:dataset tag constant defined in
|
811
|
+
# Magick::IPTC, above.
|
812
|
+
def get_iptc_dataset(ds)
|
813
|
+
self['IPTC:'+ds]
|
814
|
+
end
|
815
|
+
|
816
|
+
# Iterate over IPTC record number:dataset tags, yield for each non-nil dataset
|
817
|
+
def each_iptc_dataset
|
818
|
+
Magick::IPTC.constants.each do |record|
|
819
|
+
rec = Magick::IPTC.const_get(record)
|
820
|
+
rec.constants.each do |dataset|
|
821
|
+
data_field = get_iptc_dataset(rec.const_get(dataset))
|
822
|
+
yield(dataset, data_field) unless data_field.nil?
|
823
|
+
end
|
824
|
+
end
|
825
|
+
nil
|
826
|
+
end
|
827
|
+
|
701
828
|
# Patches problematic change to the order of arguments in 1.11.0.
|
702
829
|
# Before this release, the order was
|
703
830
|
# black_point, gamma, white_point
|
@@ -778,6 +905,16 @@ class Image
|
|
778
905
|
self
|
779
906
|
end
|
780
907
|
|
908
|
+
# Corresponds to ImageMagick's -resample option
|
909
|
+
def resample(x_res=72.0, y_res=nil)
|
910
|
+
y_res ||= x_res
|
911
|
+
width = x_res * columns / x_resolution + 0.5
|
912
|
+
height = y_res * rows / y_resolution + 0.5
|
913
|
+
self.x_resolution = x_res
|
914
|
+
self.y_resolution = y_res
|
915
|
+
resize(width, height)
|
916
|
+
end
|
917
|
+
|
781
918
|
# Convenience method to resize retaining the aspect ratio.
|
782
919
|
# (Thanks to Robert Manni!)
|
783
920
|
def resize_to_fit(cols, rows)
|
@@ -827,10 +964,10 @@ class Image
|
|
827
964
|
|
828
965
|
def initialize(img, x, y, width, height)
|
829
966
|
if width <= 0 || height <= 0
|
830
|
-
raise ArgumentError, "invalid geometry (#{width}x#{height}+#{x}+#{y})"
|
967
|
+
Kernel.raise ArgumentError, "invalid geometry (#{width}x#{height}+#{x}+#{y})"
|
831
968
|
end
|
832
969
|
if x < 0 || y < 0 || (x+width) > img.columns || (y+height) > img.rows
|
833
|
-
raise RangeError, "geometry (#{width}x#{height}+#{x}+#{y}) exceeds image boundary"
|
970
|
+
Kernel.raise RangeError, "geometry (#{width}x#{height}+#{x}+#{y}) exceeds image boundary"
|
834
971
|
end
|
835
972
|
@view = img.get_pixels(x, y, width, height)
|
836
973
|
@img = img
|
@@ -918,7 +1055,7 @@ class Image
|
|
918
1055
|
begin
|
919
1056
|
rv = Pixel.from_color(rv)
|
920
1057
|
rescue TypeError
|
921
|
-
raise TypeError, "cannot convert #{rv.class} into Pixel"
|
1058
|
+
Kernel.raise TypeError, "cannot convert #{rv.class} into Pixel"
|
922
1059
|
end
|
923
1060
|
end
|
924
1061
|
cols(args)
|
@@ -957,7 +1094,7 @@ class Image
|
|
957
1094
|
@rows += @height
|
958
1095
|
end
|
959
1096
|
if @rows < 0 || @rows > @height-1
|
960
|
-
raise IndexError, "index [#{@rows}] out of range"
|
1097
|
+
Kernel.raise IndexError, "index [#{@rows}] out of range"
|
961
1098
|
end
|
962
1099
|
# Convert back to an array
|
963
1100
|
@rows = Array.new(1, @rows)
|
@@ -974,7 +1111,7 @@ class Image
|
|
974
1111
|
end
|
975
1112
|
|
976
1113
|
if start > @height || start < 0 || length < 0
|
977
|
-
raise IndexError, "index [#{@rows.first}] out of range"
|
1114
|
+
Kernel.raise IndexError, "index [#{@rows.first}] out of range"
|
978
1115
|
else
|
979
1116
|
if start + length > @height
|
980
1117
|
length = @height - length
|
@@ -1001,7 +1138,7 @@ class Image
|
|
1001
1138
|
@cols += @width
|
1002
1139
|
end
|
1003
1140
|
if @cols < 0 || @cols > @width-1
|
1004
|
-
raise IndexError, "index [#{@cols}] out of range"
|
1141
|
+
Kernel.raise IndexError, "index [#{@cols}] out of range"
|
1005
1142
|
end
|
1006
1143
|
# Convert back to array
|
1007
1144
|
@cols = Array.new(1, @cols)
|
@@ -1039,11 +1176,11 @@ class Image
|
|
1039
1176
|
|
1040
1177
|
@rows.each do |j|
|
1041
1178
|
if j > maxrows
|
1042
|
-
raise IndexError, "index [#{j}] out of range"
|
1179
|
+
Kernel.raise IndexError, "index [#{j}] out of range"
|
1043
1180
|
end
|
1044
1181
|
@cols.each do |i|
|
1045
1182
|
if i > maxcols
|
1046
|
-
raise IndexError, "index [#{i}] out of range"
|
1183
|
+
Kernel.raise IndexError, "index [#{i}] out of range"
|
1047
1184
|
end
|
1048
1185
|
yield j*@width + i
|
1049
1186
|
end
|
@@ -1076,7 +1213,7 @@ protected
|
|
1076
1213
|
|
1077
1214
|
def is_a_image(obj)
|
1078
1215
|
unless obj.kind_of? Magick::Image
|
1079
|
-
raise ArgumentError, "Magick::Image required (#{obj.class} given)"
|
1216
|
+
Kernel.raise ArgumentError, "Magick::Image required (#{obj.class} given)"
|
1080
1217
|
end
|
1081
1218
|
true
|
1082
1219
|
end
|
@@ -1084,7 +1221,7 @@ protected
|
|
1084
1221
|
# Ensure array is always an array of Magick::Image objects
|
1085
1222
|
def is_a_image_array(ary)
|
1086
1223
|
unless ary.respond_to? :each
|
1087
|
-
raise ArgumentError, "Magick::ImageList or array of Magick::Images required (#{ary.class} given)"
|
1224
|
+
Kernel.raise ArgumentError, "Magick::ImageList or array of Magick::Images required (#{ary.class} given)"
|
1088
1225
|
end
|
1089
1226
|
ary.each { |obj| is_a_image obj }
|
1090
1227
|
true
|
@@ -1116,16 +1253,16 @@ public
|
|
1116
1253
|
# Allow scene to be set to nil
|
1117
1254
|
def scene=(n)
|
1118
1255
|
if n.nil?
|
1119
|
-
raise IndexError, "scene number out of bounds" unless length == 0
|
1256
|
+
Kernel.raise IndexError, "scene number out of bounds" unless length == 0
|
1120
1257
|
@scene = nil
|
1121
1258
|
return @scene
|
1122
1259
|
elsif length == 0
|
1123
|
-
raise IndexError, "scene number out of bounds"
|
1260
|
+
Kernel.raise IndexError, "scene number out of bounds"
|
1124
1261
|
end
|
1125
1262
|
|
1126
1263
|
n = Integer(n)
|
1127
1264
|
if n < 0 || n > length - 1
|
1128
|
-
raise IndexError, "scene number out of bounds"
|
1265
|
+
Kernel.raise IndexError, "scene number out of bounds"
|
1129
1266
|
end
|
1130
1267
|
@scene = n
|
1131
1268
|
return @scene
|
@@ -1172,7 +1309,7 @@ public
|
|
1172
1309
|
|
1173
1310
|
def *(n)
|
1174
1311
|
unless n.kind_of? Integer
|
1175
|
-
raise ArgumentError, "Integer required (#{n.class} given)"
|
1312
|
+
Kernel.raise ArgumentError, "Integer required (#{n.class} given)"
|
1176
1313
|
end
|
1177
1314
|
cfid = self[@scene].__id__ rescue nil
|
1178
1315
|
a = self.class.new.replace super
|
@@ -1289,7 +1426,7 @@ public
|
|
1289
1426
|
|
1290
1427
|
if self.superclass.instance_methods(true).include? 'insert' then
|
1291
1428
|
def insert(*args)
|
1292
|
-
raise(ArgumentError, "can't insert nil") unless args.length > 1
|
1429
|
+
Kernel.raise(ArgumentError, "can't insert nil") unless args.length > 1
|
1293
1430
|
is_a_image_array args[1,args.length-1]
|
1294
1431
|
cfid = self[@scene].__id__ rescue nil
|
1295
1432
|
super
|
@@ -1439,7 +1576,7 @@ public
|
|
1439
1576
|
# return A.length <=> B.length
|
1440
1577
|
def <=>(other)
|
1441
1578
|
unless other.kind_of? self.class
|
1442
|
-
raise TypeError, "#{self.class} required (#{other.class} given)"
|
1579
|
+
Kernel.raise TypeError, "#{self.class} required (#{other.class} given)"
|
1443
1580
|
end
|
1444
1581
|
size = [self.length, other.length].min
|
1445
1582
|
size.times do |x|
|
@@ -1449,9 +1586,9 @@ public
|
|
1449
1586
|
if @scene.nil? && other.scene.nil?
|
1450
1587
|
return 0
|
1451
1588
|
elsif @scene.nil? && ! other.scene.nil?
|
1452
|
-
raise TypeError, "cannot convert nil into #{other.scene.class}"
|
1589
|
+
Kernel.raise TypeError, "cannot convert nil into #{other.scene.class}"
|
1453
1590
|
elsif ! @scene.nil? && other.scene.nil?
|
1454
|
-
raise TypeError, "cannot convert nil into #{self.scene.class}"
|
1591
|
+
Kernel.raise TypeError, "cannot convert nil into #{self.scene.class}"
|
1455
1592
|
end
|
1456
1593
|
r = self.scene <=> other.scene
|
1457
1594
|
return r unless r == 0
|
@@ -1476,7 +1613,7 @@ public
|
|
1476
1613
|
# Return the current image
|
1477
1614
|
def cur_image
|
1478
1615
|
if ! @scene
|
1479
|
-
raise IndexError, "no images in this list"
|
1616
|
+
Kernel.raise IndexError, "no images in this list"
|
1480
1617
|
end
|
1481
1618
|
self[@scene]
|
1482
1619
|
end
|
@@ -1491,7 +1628,7 @@ public
|
|
1491
1628
|
|
1492
1629
|
def ticks_per_second=(t)
|
1493
1630
|
if Integer(t) < 0
|
1494
|
-
raise ArgumentError, "ticks_per_second must be greater than or equal to 0"
|
1631
|
+
Kernel.raise ArgumentError, "ticks_per_second must be greater than or equal to 0"
|
1495
1632
|
end
|
1496
1633
|
each { |f| f.ticks_per_second = Integer(t) }
|
1497
1634
|
end
|
@@ -1506,7 +1643,7 @@ public
|
|
1506
1643
|
|
1507
1644
|
def from_blob(*blobs, &block)
|
1508
1645
|
if (blobs.length == 0)
|
1509
|
-
raise ArgumentError, "no blobs given"
|
1646
|
+
Kernel.raise ArgumentError, "no blobs given"
|
1510
1647
|
end
|
1511
1648
|
blobs.each { |b|
|
1512
1649
|
Magick::Image.from_blob(b, &block).each { |n| self << n }
|
@@ -1538,7 +1675,7 @@ public
|
|
1538
1675
|
def iterations=(n)
|
1539
1676
|
n = Integer(n)
|
1540
1677
|
if n < 0 || n > 65535
|
1541
|
-
raise ArgumentError, "iterations must be between 0 and 65535"
|
1678
|
+
Kernel.raise ArgumentError, "iterations must be between 0 and 65535"
|
1542
1679
|
end
|
1543
1680
|
each {|f| f.iterations=n}
|
1544
1681
|
self
|
@@ -1556,10 +1693,10 @@ public
|
|
1556
1693
|
super
|
1557
1694
|
end
|
1558
1695
|
rescue NoMethodError
|
1559
|
-
raise NoMethodError, "undefined method `#{methID.id2name}' for #{self.class}"
|
1696
|
+
Kernel.raise NoMethodError, "undefined method `#{methID.id2name}' for #{self.class}"
|
1560
1697
|
rescue Exception
|
1561
1698
|
$@.delete_if { |s| /:in `send'$/.match(s) || /:in `method_missing'$/.match(s) }
|
1562
|
-
raise
|
1699
|
+
Kernel.raise
|
1563
1700
|
end
|
1564
1701
|
end
|
1565
1702
|
|
@@ -1582,7 +1719,7 @@ public
|
|
1582
1719
|
# Ping files and concatenate the new images
|
1583
1720
|
def ping(*files, &block)
|
1584
1721
|
if (files.length == 0)
|
1585
|
-
raise ArgumentError, "no files given"
|
1722
|
+
Kernel.raise ArgumentError, "no files given"
|
1586
1723
|
end
|
1587
1724
|
files.each { |f|
|
1588
1725
|
Magick::Image.ping(f, &block).each { |n| self << n }
|
@@ -1594,7 +1731,7 @@ public
|
|
1594
1731
|
# Read files and concatenate the new images
|
1595
1732
|
def read(*files, &block)
|
1596
1733
|
if (files.length == 0)
|
1597
|
-
raise ArgumentError, "no files given"
|
1734
|
+
Kernel.raise ArgumentError, "no files given"
|
1598
1735
|
end
|
1599
1736
|
files.each { |f|
|
1600
1737
|
Magick::Image.read(f, &block).each { |n| self << n }
|