Class: Magick::ImageList
- Inherits:
-
Array
- Object
- Array
- Magick::ImageList
show all
- Includes:
- Comparable
- Defined in:
- lib/RMagick.rb,
ext/RMagick/rmmain.c
Overview
Defined Under Namespace
Classes: Montage
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#&(other) ⇒ Object
-
#*(n) ⇒ Object
-
#+(other) ⇒ Object
-
#-(other) ⇒ Object
-
#<<(obj) ⇒ Object
-
#<=>(other) ⇒ Object
Compare ImageLists Compare each image in turn until the result of a comparison is not 0.
-
#[](*args) ⇒ Object
-
#[]=(*args) ⇒ Object
-
#__respond_to__? ⇒ Object
Ensure respond_to? answers correctly when we are delegating to Image.
-
#animate ⇒ Object
-
#append ⇒ Object
-
#average ⇒ Object
-
#clear ⇒ Object
-
#coalesce ⇒ Object
-
#collect(&block) ⇒ Object
-
#collect!(&block) ⇒ Object
-
#compact ⇒ Object
-
#compact! ⇒ Object
-
#concat(other) ⇒ Object
-
#copy ⇒ Object
-
#cur_image ⇒ Object
Return the current image.
-
#deconstruct ⇒ Object
-
#delay=(d) ⇒ Object
Set same delay for all images.
-
#delete(obj, &block) ⇒ Object
-
#delete_at(ndx) ⇒ Object
-
#delete_if(&block) ⇒ Object
-
#display ⇒ Object
(also: #__display__)
-
#fetch(*args, &block) ⇒ Object
-
#fill(obj, *args) ⇒ Object
-
#flatten_images ⇒ Object
-
#from_blob(*blobs, &block) ⇒ Object
-
#initialize(*filenames) ⇒ ImageList
constructor
Initialize new instances.
-
#insert(*args) ⇒ Object
-
#inspect ⇒ Object
Call inspect for all the images.
-
#iterations=(n) ⇒ Object
Set the number of iterations of an animated GIF.
-
#map ⇒ Object
(also: #__map__)
-
#map!(&block) ⇒ Object
-
#method_missing(methID, *args, &block) ⇒ Object
The ImageList class supports the Magick::Image class methods by simply sending the method to the current image.
-
#montage ⇒ Object
-
#morph ⇒ Object
-
#mosaic ⇒ Object
-
#new_image(cols, rows, *fill, &info_blk) ⇒ Object
Create a new image and add it to the end.
-
#ping(*files, &block) ⇒ Object
Ping files and concatenate the new images.
-
#pop ⇒ Object
-
#push(*objs) ⇒ Object
-
#quantize ⇒ Object
-
#read(*files, &block) ⇒ Object
Read files and concatenate the new images.
-
#reject(&block) ⇒ Object
-
#reject!(&block) ⇒ Object
-
#replace(other) ⇒ Object
-
#respond_to?(methID, priv = false) ⇒ Boolean
-
#reverse ⇒ Object
-
#reverse! ⇒ Object
-
#select(*args, &block) ⇒ Object
-
#shift ⇒ Object
-
#slice(*args) ⇒ Object
-
#slice!(*args) ⇒ Object
-
#to_blob ⇒ Object
-
#uniq ⇒ Object
-
#uniq!(*args) ⇒ Object
-
#unshift(obj) ⇒ Object
-
#write ⇒ Object
-
#|(other) ⇒ Object
Constructor Details
#initialize(*filenames) ⇒ ImageList
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
|
# File 'lib/RMagick.rb', line 1375
def initialize(*filenames)
@scene = nil
filenames.each { |f|
Magick::Image.read(f).each { |n| self << n }
}
if length > 0
@scene = length - 1 end
self
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(methID, *args, &block) ⇒ Object
The ImageList class supports the Magick::Image class methods by simply sending the method to the current image. If the method isn’t explicitly supported, send it to the current image in the array. If there are no images, send it up the line. Catch a NameError and emit a useful message.
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
|
# File 'lib/RMagick.rb', line 1406
def method_missing(methID, *args, &block)
begin
if @scene
self[@scene].send(methID, *args, &block)
else
super
end
rescue NameError
raise NameError, "undefined method `#{methID.id2name}' for #{self.class}"
rescue Exception
$@.delete_if { |s| /:in `send'$/.match(s) || /:in `method_missing'$/.match(s) }
raise
end
end
|
Instance Attribute Details
#scene ⇒ Object
Returns the value of attribute scene.
983
984
985
|
# File 'lib/RMagick.rb', line 983
def scene
@scene
end
|
Instance Method Details
#&(other) ⇒ Object
1060
1061
1062
1063
1064
1065
1066
|
# File 'lib/RMagick.rb', line 1060
def &(other)
is_a_image_array other
cfid = self[@scene].__id__ rescue nil
a = self.class.new.replace super
a.set_cf cfid
return a
end
|
#*(n) ⇒ Object
1068
1069
1070
1071
1072
1073
1074
1075
1076
|
# File 'lib/RMagick.rb', line 1068
def *(n)
unless n.kind_of? Integer
raise ArgumentError, "Integer required (#{n.class} given)"
end
cfid = self[@scene].__id__ rescue nil
a = self.class.new.replace super
a.set_cf cfid
return a
end
|
#+(other) ⇒ Object
1078
1079
1080
1081
1082
1083
|
# File 'lib/RMagick.rb', line 1078
def +(other)
cfid = self[@scene].__id__ rescue nil
a = self.class.new.replace super
a.set_cf cfid
return a
end
|
#-(other) ⇒ Object
1085
1086
1087
1088
1089
1090
1091
|
# File 'lib/RMagick.rb', line 1085
def -(other)
is_a_image_array other
cfid = self[@scene].__id__ rescue nil
a = self.class.new.replace super
a.set_cf cfid
return a
end
|
#<<(obj) ⇒ Object
1093
1094
1095
1096
1097
1098
|
# File 'lib/RMagick.rb', line 1093
def <<(obj)
is_a_image obj
a = super
@scene = length-1
return a
end
|
#<=>(other) ⇒ Object
Compare ImageLists Compare each image in turn until the result of a comparison is not 0. If all comparisons return 0, then
return if A.scene != B.scene
return A.length <=> B.length
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
|
# File 'lib/RMagick.rb', line 1324
def <=>(other)
unless other.kind_of? self.class
raise TypeError, "#{self.class} required (#{other.class} given)"
end
size = [self.length, other.length].min
size.times do |x|
r = self[x] <=> other[x]
return r unless r == 0
end
r = self.scene <=> other.scene
return r unless r == 0
return self.length <=> other.length
end
|
#[](*args) ⇒ Object
1031
1032
1033
1034
1035
1036
1037
|
# File 'lib/RMagick.rb', line 1031
def [](*args)
if (args.length > 1) || args[0].kind_of?(Range)
self.class.new.replace super
else
super
end
end
|
#[]=(*args) ⇒ Object
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
|
# File 'lib/RMagick.rb', line 1039
def []=(*args)
if args.length == 3 is_a_image_array args[2]
super
if args[1] > 0
@scene = args[0] + args[1] - 1
else @scene = args[0] + args[2].length - 1
end
elsif args[0].kind_of? Range is_a_image_array args[1]
super
@scene = args[0].end
else is_a_image args[1]
super @scene = args[0] < 0 ? length + args[0] : args[0]
end
args.last end
|
#__respond_to__? ⇒ Object
Ensure respond_to? answers correctly when we are delegating to Image
1422
|
# File 'lib/RMagick.rb', line 1422
alias_method :__respond_to__?, :respond_to?
|
#animate ⇒ Object
#append ⇒ Object
#average ⇒ Object
#clear ⇒ Object
1108
1109
1110
1111
|
# File 'lib/RMagick.rb', line 1108
def clear
@scene = nil
super
end
|
#coalesce ⇒ Object
#collect(&block) ⇒ Object
1113
1114
1115
1116
1117
1118
|
# File 'lib/RMagick.rb', line 1113
def collect(&block)
cfid = self[@scene].__id__ rescue nil
a = self.class.new.replace super
a.set_cf cfid
return a
end
|
#collect!(&block) ⇒ Object
1120
1121
1122
1123
1124
|
# File 'lib/RMagick.rb', line 1120
def collect!(&block)
super
is_a_image_array self
self
end
|
#compact ⇒ Object
1126
1127
1128
1129
1130
1131
|
# File 'lib/RMagick.rb', line 1126
def compact
cfid = self[@scene].__id__ rescue nil
a = self.class.new.replace super
a.set_cf cfid
return a
end
|
#compact! ⇒ Object
1133
1134
1135
1136
1137
1138
|
# File 'lib/RMagick.rb', line 1133
def compact!
cfid = self[@scene].__id__ rescue nil
a = super set_cf cfid
return a
end
|
#concat(other) ⇒ Object
1140
1141
1142
1143
1144
1145
|
# File 'lib/RMagick.rb', line 1140
def concat(other)
is_a_image_array other
a = super
@scene = length-1
return a
end
|
#copy ⇒ Object
1339
1340
1341
1342
1343
1344
1345
|
# File 'lib/RMagick.rb', line 1339
def copy
ditto = self.class.new
each { |f| ditto << f.copy }
ditto.scene = @scene
ditto.taint if tainted?
return ditto
end
|
#cur_image ⇒ Object
1348
1349
1350
1351
1352
1353
|
# File 'lib/RMagick.rb', line 1348
def cur_image
if ! @scene
raise IndexError, "no images in this list"
end
self[@scene]
end
|
#deconstruct ⇒ Object
#delay=(d) ⇒ Object
Set same delay for all images
1356
1357
1358
1359
1360
1361
|
# File 'lib/RMagick.rb', line 1356
def delay=(d)
if Integer(d) < 0
raise ArgumentError, "delay must be greater than 0"
end
each { |f| f.delay = Integer(d) }
end
|
#delete(obj, &block) ⇒ Object
1147
1148
1149
1150
1151
1152
1153
|
# File 'lib/RMagick.rb', line 1147
def delete(obj, &block)
is_a_image obj
cfid = self[@scene].__id__ rescue nil
a = super
set_cf cfid
return a
end
|
#delete_at(ndx) ⇒ Object
1155
1156
1157
1158
1159
1160
|
# File 'lib/RMagick.rb', line 1155
def delete_at(ndx)
cfid = self[@scene].__id__ rescue nil
a = super
set_cf cfid
return a
end
|
#delete_if(&block) ⇒ Object
1162
1163
1164
1165
1166
1167
|
# File 'lib/RMagick.rb', line 1162
def delete_if(&block)
cfid = self[@scene].__id__ rescue nil
a = super
set_cf cfid
return a
end
|
#display ⇒ Object
Also known as:
__display__
#fetch(*args, &block) ⇒ Object
1178
1179
1180
|
# File 'lib/RMagick.rb', line 1178
def fetch(*args,&block)
super
end
|
#fill(obj, *args) ⇒ Object
1169
1170
1171
1172
1173
1174
1175
|
# File 'lib/RMagick.rb', line 1169
def fill(obj, *args)
is_a_image obj
cfid = self[@scene].__id__ rescue nil
a = super
set_cf cfid
return a
end
|
#flatten_images ⇒ Object
#from_blob(*blobs, &block) ⇒ Object
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
|
# File 'lib/RMagick.rb', line 1363
def from_blob(*blobs, &block)
if (blobs.length == 0)
raise ArgumentError, "no blobs given"
end
blobs.each { |b|
Magick::Image.from_blob(b, &block).each { |n| self << n }
}
@scene = length - 1
self
end
|
#insert(*args) ⇒ Object
1184
1185
1186
1187
1188
1189
|
# File 'lib/RMagick.rb', line 1184
def insert(*args)
cfid = self[@scene].__id__ rescue nil
a = self.class.new.replace super
a.set_cf cfid
return a
end
|
#inspect ⇒ Object
Call inspect for all the images
1387
1388
1389
1390
1391
|
# File 'lib/RMagick.rb', line 1387
def inspect
ins = '['
each {|image| ins << image.inspect << "\n"}
ins.chomp("\n") + "]\nscene=#{@scene}"
end
|
#iterations=(n) ⇒ Object
Set the number of iterations of an animated GIF
1394
1395
1396
1397
1398
1399
1400
|
# File 'lib/RMagick.rb', line 1394
def iterations=(n)
if n < 0 || n > 65535
raise ArgumentError, "iterations must be between 0 and 65535"
end
each {|f| f.iterations=n}
self
end
|
#map ⇒ Object
Also known as:
__map__
#map!(&block) ⇒ Object
1203
1204
1205
1206
1207
|
# File 'lib/RMagick.rb', line 1203
def map!(&block)
super
is_a_image_array self
self
end
|
#montage ⇒ Object
#morph ⇒ Object
#mosaic ⇒ Object
#new_image(cols, rows, *fill, &info_blk) ⇒ Object
Create a new image and add it to the end
1433
1434
1435
|
# File 'lib/RMagick.rb', line 1433
def new_image(cols, rows, *fill, &info_blk)
self << Magick::Image.new(cols, rows, *fill, &info_blk)
end
|
#ping(*files, &block) ⇒ Object
Ping files and concatenate the new images
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
|
# File 'lib/RMagick.rb', line 1438
def ping(*files, &block)
if (files.length == 0)
raise ArgumentError, "no files given"
end
files.each { |f|
Magick::Image.ping(f, &block).each { |n| self << n }
}
@scene = length - 1
self
end
|
#pop ⇒ Object
1209
1210
1211
1212
1213
1214
|
# File 'lib/RMagick.rb', line 1209
def pop
cfid = self[@scene].__id__ rescue nil
a = super
set_cf cfid
return a
end
|
#push(*objs) ⇒ Object
1216
1217
1218
1219
1220
1221
|
# File 'lib/RMagick.rb', line 1216
def push(*objs)
objs.each { |o| is_a_image o }
super
@scene = length - 1
self
end
|
#quantize ⇒ Object
#read(*files, &block) ⇒ Object
Read files and concatenate the new images
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
|
# File 'lib/RMagick.rb', line 1450
def read(*files, &block)
if (files.length == 0)
raise ArgumentError, "no files given"
end
files.each { |f|
Magick::Image.read(f, &block).each { |n| self << n }
}
@scene = length - 1
self
end
|
#reject(&block) ⇒ Object
1224
1225
1226
1227
1228
1229
|
# File 'lib/RMagick.rb', line 1224
def reject(&block)
cfid = self[@scene].__id__ rescue nil
a = super
set_cf cfid
return a
end
|
#reject!(&block) ⇒ Object
1232
1233
1234
1235
1236
1237
|
# File 'lib/RMagick.rb', line 1232
def reject!(&block)
cfid = self[@scene].__id__ rescue nil
a = super
set_cf cfid
return a
end
|
#replace(other) ⇒ Object
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
|
# File 'lib/RMagick.rb', line 1239
def replace(other)
is_a_image_array other
cfid = nil
if @scene then
cfid = self[@scene].__id__ rescue nil
end
super
set_cf cfid
self
end
|
#respond_to?(methID, priv = false) ⇒ Boolean
1423
1424
1425
1426
1427
1428
1429
1430
|
# File 'lib/RMagick.rb', line 1423
def respond_to?(methID, priv=false)
return true if __respond_to__?(methID, priv)
if @scene
self[@scene].respond_to?(methID, priv)
else
super
end
end
|
#reverse ⇒ Object
1252
1253
1254
1255
1256
1257
|
# File 'lib/RMagick.rb', line 1252
def reverse
cfid = self[@scene].__id__ rescue nil
a = self.class.new.replace super
a.set_cf cfid
return a
end
|
#reverse! ⇒ Object
1259
1260
1261
1262
1263
1264
|
# File 'lib/RMagick.rb', line 1259
def reverse!
cfid = self[@scene].__id__ rescue nil
a = super
set_cf cfid
return a
end
|
#select(*args, &block) ⇒ Object
1267
1268
1269
1270
1271
1272
|
# File 'lib/RMagick.rb', line 1267
def select(*args,&block)
cfid = self[@scene].__id__ rescue nil
a = super
a.set_cf cfid
return a
end
|
#shift ⇒ Object
1275
1276
1277
1278
1279
1280
|
# File 'lib/RMagick.rb', line 1275
def shift
cfid = self[@scene].__id__ rescue nil
a = super
set_cf cfid
return a
end
|
#slice(*args) ⇒ Object
1282
1283
1284
|
# File 'lib/RMagick.rb', line 1282
def slice(*args)
self[*args]
end
|
#slice!(*args) ⇒ Object
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
|
# File 'lib/RMagick.rb', line 1286
def slice!(*args)
cfid = self[@scene].__id__ rescue nil
if args.length > 1 || args[0].kind_of?(Range)
a = self.class.new.replace super
else
a = super
end
set_cf cfid
return a
end
|
#to_blob ⇒ Object
#uniq ⇒ Object
1297
1298
1299
1300
1301
1302
|
# File 'lib/RMagick.rb', line 1297
def uniq
cfid = self[@scene].__id__ rescue nil
a = self.class.new.replace super
a.set_cf cfid
return a
end
|
#uniq!(*args) ⇒ Object
1304
1305
1306
1307
1308
1309
|
# File 'lib/RMagick.rb', line 1304
def uniq!(*args)
cfid = self[@scene].__id__ rescue nil
a = super
set_cf cfid
return a
end
|
#unshift(obj) ⇒ Object
1312
1313
1314
1315
1316
1317
|
# File 'lib/RMagick.rb', line 1312
def unshift(obj)
is_a_image obj
a = super
@scene = 0
return a
end
|
#write ⇒ Object
#|(other) ⇒ Object
1100
1101
1102
1103
1104
1105
1106
|
# File 'lib/RMagick.rb', line 1100
def |(other)
is_a_image_array other
cfid = self[@scene].__id__ rescue nil
a = self.class.new.replace super
a.set_cf cfid
return a
end
|