Class: Magick::ImageList
- Inherits:
-
Object
- Object
- Magick::ImageList
- Includes:
- Comparable, Enumerable
- Defined in:
- lib/RMagick.rb,
ext/RMagick/rmmain.c
Overview
class Magick::Image
Defined Under Namespace
Classes: Montage
Instance Attribute Summary collapse
-
#scene ⇒ Object
Returns the value of attribute scene.
Instance Method Summary collapse
- #*(n) ⇒ 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(*args) ⇒ Object
Method: ImageList#animate(<delay>) Purpose: repeatedly display the images in the images array to an XWindow screen.
-
#append(stack_arg) ⇒ Object
Method: ImageList#append(stack) Purpose: Append all the images by calling ImageAppend Returns: an Frame object for the result.
-
#average ⇒ Object
Method: ImageList#average Purpose: Average all images together by calling AverageImages Returns: an Frame object for the averaged image.
- #clear ⇒ Object
- #clone ⇒ Object
-
#coalesce ⇒ Object
Method: ImageList#coalesce Purpose: call CoalesceImages Returns: a new Image with the coalesced image sequence stored in the images array Notes: respects the delay, matte, and start_loop fields in each image.
-
#collect(&block) ⇒ Object
(also: #__map__)
override Enumerable#collect.
- #collect!(&block) ⇒ Object (also: #map!, #__map__!)
- #compact ⇒ Object
- #compact! ⇒ Object
-
#composite_layers(*args) ⇒ Object
Method: ImageList#composite_layers Purpose: Equivalent to convert’s -layers composite option Notes: see mogrify.c.
- #concat(other) ⇒ Object
-
#copy ⇒ Object
Make a deep copy.
-
#cur_image ⇒ Object
Return the current image.
-
#deconstruct ⇒ Object
Method: ImageList#deconstruct Purpose: compares each image with the next in a sequence and returns the maximum bounding region of any pixel differences it discovers.
-
#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__)
Method: ImageList#display Purpose: Display all the images to an X window screen.
- #dup ⇒ Object
- #eql?(other) ⇒ Boolean
- #fill(*args, &block) ⇒ Object
-
#find_all(&block) ⇒ Object
(also: #select)
Override Enumerable’s find_all.
-
#flatten_images ⇒ Object
Method: ImageList#flatten_images Purpose: merge all the images into a single image Returns: the new image Notes: Can’t use “flatten” because that’s an Array method.
- #from_blob(*blobs, &block) ⇒ Object
-
#fx(*args) ⇒ Object
Method: ImageList#fx(expression[, channel…]).
-
#initialize(*filenames, &block) ⇒ ImageList
constructor
Initialize new instances.
- #insert(index, *args) ⇒ Object
-
#inspect ⇒ Object
Call inspect for all the images.
-
#iterations=(n) ⇒ Object
Set the number of iterations of an animated GIF.
- #last(*args) ⇒ Object
-
#map(*args) ⇒ Object
Method: ImageList#map(reference, dither=false) Purpose: Call MapImages Returns: a new ImageList with mapped images.
-
#marshal_dump ⇒ Object
Custom marshal/unmarshal for Ruby 1.8.
- #marshal_load(ary) ⇒ 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
Method: ImageList#montage <block> Purpose: Call MontageImages Notes: Creates Montage object, yields to block if present in Montage object’s scope.
-
#morph(nimages) ⇒ Object
Method: ImageList#morph(number_images) Purpose: requires a minimum of two images.
-
#mosaic ⇒ Object
Method: ImageList#mosaic Purpose: merge all the images into a single image Returns: the new image.
-
#new_image(cols, rows, *fill, &info_blk) ⇒ Object
Create a new image and add it to the end.
- #nitems ⇒ Object
-
#optimize_layers(method) ⇒ Object
Method: ImageList#optimize_layers Purpose: Equivalent to -layers option in 6.2.6 Returns: a new imagelist.
- #partition(&block) ⇒ Object
-
#ping(*files, &block) ⇒ Object
Ping files and concatenate the new images.
- #pop ⇒ Object
- #push(*objs) ⇒ Object
-
#quantize(*args) ⇒ Object
Method: ImageList#quantize(<number_colors<, colorspace<, dither<, tree_depth<, measure_error>>>>>) defaults: 256, Magick::RGBColorspace, true, 0, false Purpose: call QuantizeImages Returns: a new ImageList with quantized images.
-
#read(*files, &block) ⇒ Object
Read files and concatenate the new images.
-
#reject(&block) ⇒ Object
override Enumerable’s reject.
- #reject!(&block) ⇒ Object
-
#remap(*args) ⇒ Object
(also: #affinity)
Method: ImageList#remap(remap_image=nil, dither_method=RiemersmaDitherMethod) Purpose: Call RemapImages Note: See Image_remap.
- #replace(other) ⇒ Object
- #respond_to?(methID, priv = false) ⇒ Boolean
- #reverse ⇒ Object
- #reverse! ⇒ Object
- #reverse_each ⇒ Object
- #shift ⇒ Object
- #slice(*args) ⇒ Object
- #slice!(*args) ⇒ Object
- #ticks_per_second=(t) ⇒ Object
- #to_a ⇒ Object
-
#to_blob ⇒ Object
Method: ImageList#to_blob Purpose: returns the imagelist as a blob (a String) Notes: runs an info parm block if present - the user can specify the image format and depth.
- #uniq ⇒ Object
- #uniq!(*args) ⇒ Object
- #unshift(obj) ⇒ Object
- #values_at(*args) ⇒ Object (also: #indexes, #indices)
-
#write(file) ⇒ Object
Method: ImageList#write(file) Purpose: Write all the images to the specified file.
Constructor Details
#initialize(*filenames, &block) ⇒ ImageList
Initialize new instances
1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 |
# File 'lib/RMagick.rb', line 1631 def initialize(*filenames, &block) @images = [] @scene = nil filenames.each { |f| Magick::Image.read(f, &block).each { |n| @images << n } } if length > 0 @scene = length - 1 # last image in array 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.
1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 |
# File 'lib/RMagick.rb', line 1698 def method_missing(methID, *args, &block) begin if @scene @images[@scene].send(methID, *args, &block) else super end rescue NoMethodError Kernel.raise NoMethodError, "undefined method `#{methID.id2name}' for #{self.class}" rescue Exception $@.delete_if { |s| /:in `send'$/.match(s) || /:in `method_missing'$/.match(s) } Kernel.raise end end |
Instance Attribute Details
#scene ⇒ Object
Returns the value of attribute scene.
1298 1299 1300 |
# File 'lib/RMagick.rb', line 1298 def scene @scene end |
Instance Method Details
#*(n) ⇒ Object
1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 |
# File 'lib/RMagick.rb', line 1390 def *(n) unless n.kind_of? Integer Kernel.raise ArgumentError, "Integer required (#{n.class} given)" end current = get_current() ilist = self.class.new (@images * n).each {|image| ilist << image} ilist.set_current current return ilist end |
#<<(obj) ⇒ Object
1401 1402 1403 1404 1405 1406 |
# File 'lib/RMagick.rb', line 1401 def <<(obj) is_an_image obj @images << obj @scene = @images.length - 1 self 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
1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 |
# File 'lib/RMagick.rb', line 1413 def <=>(other) unless other.kind_of? self.class Kernel.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 if @scene.nil? && other.scene.nil? return 0 elsif @scene.nil? && ! other.scene.nil? Kernel.raise TypeError, "cannot convert nil into #{other.scene.class}" elsif ! @scene.nil? && other.scene.nil? Kernel.raise TypeError, "cannot convert nil into #{self.scene.class}" end r = self.scene <=> other.scene return r unless r == 0 return self.length <=> other.length end |
#[](*args) ⇒ Object
1434 1435 1436 1437 1438 1439 1440 1441 1442 |
# File 'lib/RMagick.rb', line 1434 def [](*args) a = @images[*args] if a.respond_to?(:each) then ilist = self.class.new a.each {|image| ilist << image} a = ilist end return a end |
#[]=(*args) ⇒ Object
1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 |
# File 'lib/RMagick.rb', line 1444 def []=(*args) obj = @images.[]=(*args) if obj && obj.respond_to?(:each) then is_an_image_array(obj) set_current obj.last.__id__ elsif obj is_an_image(obj) set_current obj.__id__ else set_current nil end return obj end |
#__respond_to__? ⇒ Object
Ensure respond_to? answers correctly when we are delegating to Image
1798 |
# File 'lib/RMagick.rb', line 1798 alias_method :__respond_to__?, :respond_to? |
#animate(*args) ⇒ Object
Method: ImageList#animate(<delay>) Purpose: repeatedly display the images in the images array to an XWindow
screen. The "delay" argument is the number of 1/100ths of a
second (0 to 65535) to delay between images.
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 |
# File 'ext/RMagick/rmilist.c', line 30
VALUE
ImageList_animate(int argc, VALUE *argv, VALUE self)
{
Image *images;
Info *info;
volatile VALUE info_obj;
if (argc > 1)
{
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc);
}
// Create a new Info object to use with this call
info_obj = rm_info_new();
// Convert the images array to an images sequence.
images = images_from_imagelist(self);
if (argc == 1)
{
Image *img;
unsigned int delay;
delay = NUM2UINT(argv[0]);
for (img = images; img; img = GetNextImageInList(img))
{
img->delay = delay;
}
}
Data_Get_Struct(info_obj, Info, info);
(void) AnimateImages(info, images);
rm_check_image_exception(images, RetainOnError);
rm_split(images);
return self;
}
|
#append(stack_arg) ⇒ Object
Method: ImageList#append(stack) Purpose: Append all the images by calling ImageAppend Returns: an Frame object for the result
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'ext/RMagick/rmilist.c', line 74
VALUE
ImageList_append(VALUE self, VALUE stack_arg)
{
Image *images, *new_image;
unsigned int stack;
ExceptionInfo exception;
// Convert the image array to an image sequence.
images = images_from_imagelist(self);
// If stack == true, stack rectangular images top-to-bottom,
// otherwise left-to-right.
stack = RTEST(stack_arg);
GetExceptionInfo(&exception);
new_image = AppendImages(images, stack, &exception);
rm_split(images);
rm_check_exception(&exception, new_image, DestroyOnError);
(void) DestroyExceptionInfo(&exception);
rm_ensure_result(new_image);
return rm_image_new(new_image);
}
|
#average ⇒ Object
Method: ImageList#average Purpose: Average all images together by calling AverageImages Returns: an Frame object for the averaged image
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'ext/RMagick/rmilist.c', line 105
VALUE
ImageList_average(VALUE self)
{
Image *images, *new_image;
ExceptionInfo exception;
// Convert the images array to an images sequence.
images = images_from_imagelist(self);
GetExceptionInfo(&exception);
new_image = AverageImages(images, &exception);
rm_split(images);
rm_check_exception(&exception, new_image, DestroyOnError);
(void) DestroyExceptionInfo(&exception);
rm_ensure_result(new_image);
return rm_image_new(new_image);
}
|
#clear ⇒ Object
1475 1476 1477 1478 |
# File 'lib/RMagick.rb', line 1475 def clear @scene = nil @images.clear end |
#clone ⇒ Object
1480 1481 1482 1483 1484 |
# File 'lib/RMagick.rb', line 1480 def clone ditto = dup ditto.freeze if frozen? return ditto end |
#coalesce ⇒ Object
Method: ImageList#coalesce Purpose: call CoalesceImages Returns: a new Image with the coalesced image sequence
stored in the images array
Notes: respects the delay, matte, and start_loop fields
in each image.
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'ext/RMagick/rmilist.c', line 134
VALUE
ImageList_coalesce(VALUE self)
{
Image *images, *new_images;
ExceptionInfo exception;
// Convert the image array to an image sequence.
images = images_from_imagelist(self);
GetExceptionInfo(&exception);
new_images = CoalesceImages(images, &exception);
rm_split(images);
rm_check_exception(&exception, new_images, DestroyOnError);
(void) DestroyExceptionInfo(&exception);
rm_ensure_result(new_images);
return rm_imagelist_from_images(new_images);
}
|
#collect(&block) ⇒ Object Also known as: __map__
override Enumerable#collect
1487 1488 1489 1490 1491 1492 1493 1494 |
# File 'lib/RMagick.rb', line 1487 def collect(&block) current = get_current() a = @images.collect(&block) ilist = self.class.new a.each {|image| ilist << image} ilist.set_current current return ilist end |
#collect!(&block) ⇒ Object Also known as: map!, __map__!
1496 1497 1498 1499 1500 |
# File 'lib/RMagick.rb', line 1496 def collect!(&block) @images.collect!(&block) is_an_image_array @images self end |
#compact ⇒ Object
1527 1528 1529 1530 1531 1532 1533 1534 |
# File 'lib/RMagick.rb', line 1527 def compact current = get_current() ilist = self.class.new a = @images.compact a.each {|image| ilist << image} ilist.set_current current return ilist end |
#compact! ⇒ Object
1536 1537 1538 1539 1540 1541 |
# File 'lib/RMagick.rb', line 1536 def compact! current = get_current() a = @images.compact! # returns nil if no changes were made set_current current return a.nil? ? nil : self end |
#composite_layers(*args) ⇒ Object
Method: ImageList#composite_layers Purpose: Equivalent to convert’s -layers composite option Notes: see mogrify.c
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'ext/RMagick/rmilist.c', line 160
VALUE
ImageList_composite_layers(int argc, VALUE *argv, VALUE self)
{
volatile VALUE source_images;
Image *dest, *source, *new_images;
RectangleInfo geometry;
CompositeOperator operator = OverCompositeOp;
ExceptionInfo exception;
switch (argc)
{
case 2:
VALUE_TO_ENUM(argv[1], operator, CompositeOperator);
case 1:
source_images = argv[0];
break;
default:
rb_raise(rb_eArgError, "wrong number of arguments (expected 1 or 2, got %d)", argc);
break;
}
// Convert ImageLists to image sequences.
dest = images_from_imagelist(self);
new_images = clone_imagelist(dest);
rm_split(dest);
source = images_from_imagelist(source_images);
SetGeometry(new_images,&geometry);
(void) ParseAbsoluteGeometry(new_images->geometry, &geometry);
geometry.width = source->page.width != 0 ? source->page.width : source->columns;
geometry.height = source->page.height != 0 ? source->page.height : source->rows;
GravityAdjustGeometry(new_images->page.width != 0 ? new_images->page.width : new_images->columns
, new_images->page.height != 0 ? new_images->page.height : new_images->rows
, new_images->gravity, &geometry);
GetExceptionInfo(&exception);
CompositeLayers(new_images, operator, source, geometry.x, geometry.y, &exception);
rm_split(source);
rm_check_exception(&exception, new_images, DestroyOnError);
(void) DestroyExceptionInfo(&exception);
return rm_imagelist_from_images(new_images);
}
|
#concat(other) ⇒ Object
1543 1544 1545 1546 1547 1548 |
# File 'lib/RMagick.rb', line 1543 def concat(other) is_an_image_array other other.each {|image| @images << image} @scene = length-1 return self end |
#copy ⇒ Object
Make a deep copy
1503 1504 1505 1506 1507 1508 1509 |
# File 'lib/RMagick.rb', line 1503 def copy ditto = self.class.new @images.each { |f| ditto << f.copy } ditto.scene = @scene ditto.taint if tainted? return ditto end |
#cur_image ⇒ Object
Return the current image
1512 1513 1514 1515 1516 1517 |
# File 'lib/RMagick.rb', line 1512 def cur_image if ! @scene Kernel.raise IndexError, "no images in this list" end @images[@scene] end |
#deconstruct ⇒ Object
Method: ImageList#deconstruct Purpose: compares each image with the next in a sequence and returns
the maximum bounding region of any pixel differences it
discovers.
Returns: a new imagelist
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'ext/RMagick/rmilist.c', line 214
VALUE
ImageList_deconstruct(VALUE self)
{
Image *new_images, *images;
ExceptionInfo exception;
images = images_from_imagelist(self);
GetExceptionInfo(&exception);
new_images = DeconstructImages(images, &exception);
rm_split(images);
rm_check_exception(&exception, new_images, DestroyOnError);
(void) DestroyExceptionInfo(&exception);
rm_ensure_result(new_images);
return rm_imagelist_from_images(new_images);
}
|
#delay=(d) ⇒ Object
Set same delay for all images
1551 1552 1553 1554 1555 1556 |
# File 'lib/RMagick.rb', line 1551 def delay=(d) if Integer(d) < 0 raise ArgumentError, "delay must be greater than or equal to 0" end @images.each { |f| f.delay = Integer(d) } end |
#delete(obj, &block) ⇒ Object
1558 1559 1560 1561 1562 1563 1564 |
# File 'lib/RMagick.rb', line 1558 def delete(obj, &block) is_an_image obj current = get_current() a = @images.delete(obj, &block) set_current current return a end |
#delete_at(ndx) ⇒ Object
1566 1567 1568 1569 1570 1571 |
# File 'lib/RMagick.rb', line 1566 def delete_at(ndx) current = get_current() a = @images.delete_at(ndx) set_current current return a end |
#delete_if(&block) ⇒ Object
1573 1574 1575 1576 1577 1578 |
# File 'lib/RMagick.rb', line 1573 def delete_if(&block) current = get_current() @images.delete_if(&block) set_current current self end |
#display ⇒ Object Also known as: __display__
Method: ImageList#display Purpose: Display all the images to an X window screen.
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'ext/RMagick/rmilist.c', line 237
VALUE
ImageList_display(VALUE self)
{
Image *images;
Info *info;
volatile VALUE info_obj;
// Create a new Info object to use with this call
info_obj = rm_info_new();
Data_Get_Struct(info_obj, Info, info);
// Convert the images array to an images sequence.
images = images_from_imagelist(self);
(void) DisplayImages(info, images);
rm_split(images);
rm_check_image_exception(images, RetainOnError);
return self;
}
|
#dup ⇒ Object
1580 1581 1582 1583 1584 1585 1586 |
# File 'lib/RMagick.rb', line 1580 def dup ditto = self.class.new @images.each {|img| ditto << img} ditto.scene = @scene ditto.taint if tainted? return ditto end |
#eql?(other) ⇒ Boolean
1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 |
# File 'lib/RMagick.rb', line 1588 def eql?(other) is_an_image_array other eql = other.eql?(@images) begin # "other" is another ImageList eql &&= @scene == other.scene rescue NoMethodError # "other" is a plain Array end return eql end |
#fill(*args, &block) ⇒ Object
1599 1600 1601 1602 1603 1604 1605 1606 |
# File 'lib/RMagick.rb', line 1599 def fill(*args, &block) is_an_image args[0] unless block_given? current = get_current() @images.fill(*args, &block) is_an_image_array self set_current current self end |
#find_all(&block) ⇒ Object Also known as: select
Override Enumerable’s find_all
1609 1610 1611 1612 1613 1614 1615 1616 |
# File 'lib/RMagick.rb', line 1609 def find_all(&block) current = get_current() a = @images.find_all(&block) ilist = self.class.new a.each {|image| ilist << image} ilist.set_current current return ilist end |
#flatten_images ⇒ Object
Method: ImageList#flatten_images Purpose: merge all the images into a single image Returns: the new image Notes: Can’t use “flatten” because that’s an Array method
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'ext/RMagick/rmilist.c', line 265
VALUE
ImageList_flatten_images(VALUE self)
{
Image *images, *new_image;
ExceptionInfo exception;
images = images_from_imagelist(self);
GetExceptionInfo(&exception);
#if defined(HAVE_ENUM_FLATTENLAYER)
new_image = MergeImageLayers(images, FlattenLayer, &exception);
#else
new_image = FlattenImages(images, &exception);
#endif
rm_split(images);
rm_check_exception(&exception, new_image, DestroyOnError);
(void) DestroyExceptionInfo(&exception);
rm_ensure_result(new_image);
return rm_image_new(new_image);
}
|
#from_blob(*blobs, &block) ⇒ Object
1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 |
# File 'lib/RMagick.rb', line 1619 def from_blob(*blobs, &block) if (blobs.length == 0) Kernel.raise ArgumentError, "no blobs given" end blobs.each { |b| Magick::Image.from_blob(b, &block).each { |n| @images << n } } @scene = length - 1 self end |
#fx(*args) ⇒ Object
Method: ImageList#fx(expression[, channel…])
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'ext/RMagick/rmilist.c', line 293
VALUE
ImageList_fx(int argc, VALUE *argv, VALUE self)
{
Image *images, *new_image;
char *expression;
ChannelType channels;
ExceptionInfo exception;
channels = extract_channels(&argc, argv);
// There must be exactly 1 remaining argument.
if (argc == 0)
{
rb_raise(rb_eArgError, "wrong number of arguments (0 for 1 or more)");
}
else if (argc > 1)
{
raise_ChannelType_error(argv[argc-1]);
}
expression = StringValuePtr(argv[0]);
images = images_from_imagelist(self);
GetExceptionInfo(&exception);
new_image = FxImageChannel(images, channels, expression, &exception);
rm_split(images);
rm_check_exception(&exception, new_image, DestroyOnError);
(void) DestroyExceptionInfo(&exception);
rm_ensure_result(new_image);
return rm_image_new(new_image);
}
|
#insert(index, *args) ⇒ Object
1643 1644 1645 1646 1647 1648 1649 |
# File 'lib/RMagick.rb', line 1643 def insert(index, *args) args.each {|image| is_an_image image} current = get_current() @images.insert(index, *args) set_current current return self end |
#inspect ⇒ Object
Call inspect for all the images
1652 1653 1654 1655 1656 |
# File 'lib/RMagick.rb', line 1652 def inspect img = [] @images.each {|image| img << image.inspect } img = "[" + img.join(",\n") + "]\nscene=#{@scene}" end |
#iterations=(n) ⇒ Object
Set the number of iterations of an animated GIF
1659 1660 1661 1662 1663 1664 1665 1666 |
# File 'lib/RMagick.rb', line 1659 def iterations=(n) n = Integer(n) if n < 0 || n > 65535 Kernel.raise ArgumentError, "iterations must be between 0 and 65535" end @images.each {|f| f.iterations=n} self end |
#last(*args) ⇒ Object
1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 |
# File 'lib/RMagick.rb', line 1668 def last(*args) if args.length == 0 a = @images.last else a = @images.last(*args) ilist = self.class.new a.each {|img| ilist << img} @scene = a.length - 1 a = ilist end return a end |
#map(*args) ⇒ Object
Method: ImageList#map(reference, dither=false) Purpose: Call MapImages Returns: a new ImageList with mapped images. @scene is set to self.scene
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
# File 'ext/RMagick/rmilist.c', line 334
VALUE
ImageList_map(int argc, VALUE *argv, VALUE self)
{
Image *images, *new_images = NULL;
Image *map;
unsigned int dither = MagickFalse;
volatile VALUE scene, new_imagelist, t;
ExceptionInfo exception;
#if defined(HAVE_REMAPIMAGES)
rb_warning("ImageList#map is deprecated. Use ImageList#remap instead.");
#endif
switch (argc)
{
case 2:
dither = RTEST(argv[1]);
case 1:
t = rm_cur_image(argv[0]);
map = rm_check_destroyed(t);
break;
default:
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc);
break;
}
// Convert image array to image sequence, clone image sequence.
GetExceptionInfo(&exception);
images = images_from_imagelist(self);
new_images = CloneImageList(images, &exception);
rm_split(images);
rm_check_exception(&exception, new_images, DestroyOnError);
(void) DestroyExceptionInfo(&exception);
rm_ensure_result(new_images);
// Call ImageMagick
(void) MapImages(new_images, map, dither);
rm_check_image_exception(new_images, DestroyOnError);
// Set @scene in new ImageList object to same value as in self.
new_imagelist = rm_imagelist_from_images(new_images);
scene = rb_iv_get(self, "@scene");
(void) imagelist_scene_eq(new_imagelist, scene);
return new_imagelist;
}
|
#marshal_dump ⇒ Object
Custom marshal/unmarshal for Ruby 1.8.
1682 1683 1684 1685 1686 |
# File 'lib/RMagick.rb', line 1682 def marshal_dump() ary = [@scene] @images.each {|i| ary << Marshal.dump(i)} ary end |
#marshal_load(ary) ⇒ Object
1688 1689 1690 1691 1692 |
# File 'lib/RMagick.rb', line 1688 def marshal_load(ary) @scene = ary.shift @images = [] ary.each {|a| @images << Marshal.load(a)} end |
#montage ⇒ Object
Method: ImageList#montage <block> Purpose: Call MontageImages Notes: Creates Montage object, yields to block if present
in Montage object's scope.
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 |
# File 'ext/RMagick/rmilist.c', line 391
VALUE
ImageList_montage(VALUE self)
{
volatile VALUE montage_obj;
Montage *montage;
Image *new_images, *images;
ExceptionInfo exception;
// Create a new instance of the Magick::Montage class
montage_obj = rm_montage_new();
if (rb_block_given_p())
{
// Run the block in the instance's context, allowing the app to modify the
// object's attributes.
(void) rb_obj_instance_eval(0, NULL, montage_obj);
}
Data_Get_Struct(montage_obj, Montage, montage);
images = images_from_imagelist(self);
// If app specified a non-default composition operator, use it for all images.
if (montage->compose != UndefinedCompositeOp)
{
Image *i;
for (i = images; i; i = GetNextImageInList(i))
{
i->compose = montage->compose;
}
}
GetExceptionInfo(&exception);
// MontageImage can return more than one image.
new_images = MontageImages(images, montage->info, &exception);
rm_split(images);
rm_check_exception(&exception, new_images, DestroyOnError);
(void) DestroyExceptionInfo(&exception);
rm_ensure_result(new_images);
return rm_imagelist_from_images(new_images);
}
|
#morph(nimages) ⇒ Object
Method: ImageList#morph(number_images) Purpose: requires a minimum of two images. The first image is
transformed into the second by a number of intervening images
as specified by "number_images".
Returns: a new Image with the images array set to the morph sequence.
@scenes = 0
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
# File 'ext/RMagick/rmilist.c', line 444
VALUE
ImageList_morph(VALUE self, VALUE nimages)
{
Image *images, *new_images;
ExceptionInfo exception;
long number_images;
// Use a signed long so we can test for a negative argument.
number_images = NUM2LONG(nimages);
if (number_images <= 0)
{
rb_raise(rb_eArgError, "number of intervening images must be > 0");
}
GetExceptionInfo(&exception);
images = images_from_imagelist(self);
new_images = MorphImages(images, (unsigned long)number_images, &exception);
rm_split(images);
rm_check_exception(&exception, new_images, DestroyOnError);
(void) DestroyExceptionInfo(&exception);
rm_ensure_result(new_images);
return rm_imagelist_from_images(new_images);
}
|
#mosaic ⇒ Object
Method: ImageList#mosaic Purpose: merge all the images into a single image Returns: the new image
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 |
# File 'ext/RMagick/rmilist.c', line 477
VALUE
ImageList_mosaic(VALUE self)
{
Image *images, *new_image;
ExceptionInfo exception;
GetExceptionInfo(&exception);
images = images_from_imagelist(self);
#if defined(HAVE_ENUM_MOSAICLAYER)
new_image = MergeImageLayers(images, MosaicLayer, &exception);
#else
new_image = MosaicImages(images, &exception);
#endif
rm_split(images);
rm_check_exception(&exception, new_image, DestroyOnError);
(void) DestroyExceptionInfo(&exception);
rm_ensure_result(new_image);
return rm_image_new(new_image);
}
|
#new_image(cols, rows, *fill, &info_blk) ⇒ Object
Create a new image and add it to the end
1714 1715 1716 |
# File 'lib/RMagick.rb', line 1714 def new_image(cols, rows, *fill, &info_blk) self << Magick::Image.new(cols, rows, *fill, &info_blk) end |
#nitems ⇒ Object
1470 1471 1472 |
# File 'lib/RMagick.rb', line 1470 def nitems() @images.nitems() end |
#optimize_layers(method) ⇒ Object
Method: ImageList#optimize_layers Purpose: Equivalent to -layers option in 6.2.6 Returns: a new imagelist
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 |
# File 'ext/RMagick/rmilist.c', line 507
VALUE
ImageList_optimize_layers(VALUE self, VALUE method)
{
Image *images, *new_images, *new_images2;
LAYERMETHODTYPE mthd;
ExceptionInfo exception;
QuantizeInfo quantize_info;
new_images2 = NULL; // defeat "unused variable" message
GetExceptionInfo(&exception);
#if defined(HAVE_TYPE_IMAGELAYERMETHOD)
VALUE_TO_ENUM(method, mthd, ImageLayerMethod);
#else
VALUE_TO_ENUM(method, mthd, MagickLayerMethod);
#endif
images = images_from_imagelist(self);
switch (mthd)
{
case CoalesceLayer:
new_images = CoalesceImages(images, &exception);
break;
case DisposeLayer:
new_images = DisposeImages(images, &exception);
break;
case OptimizeTransLayer:
new_images = clone_imagelist(images);
OptimizeImageTransparency(new_images, &exception);
break;
case RemoveDupsLayer:
new_images = clone_imagelist(images);
RemoveDuplicateLayers(&new_images, &exception);
break;
case RemoveZeroLayer:
new_images = clone_imagelist(images);
RemoveZeroDelayLayers(&new_images, &exception);
break;
case CompositeLayer:
rm_split(images);
rb_raise(rb_eNotImpError, "Magick::CompositeLayer is not supported. Use the composite_layers method instead.");
break;
// In 6.3.4-ish, OptimizeImageLayer replaced OptimizeLayer
case OptimizeImageLayer:
new_images = OptimizeImageLayers(images, &exception);
break;
// and OptimizeLayer became a "General Purpose, GIF Animation Optimizer" (ref. mogrify.c)
case OptimizeLayer:
new_images = CoalesceImages(images, &exception);
rm_split(images);
rm_check_exception(&exception, new_images, DestroyOnError);
new_images2 = OptimizeImageLayers(new_images, &exception);
DestroyImageList(new_images);
rm_check_exception(&exception, new_images2, DestroyOnError);
new_images = new_images2;
OptimizeImageTransparency(new_images, &exception);
rm_check_exception(&exception, new_images, DestroyOnError);
// mogrify supports -dither here. We don't.
#if defined(HAVE_REMAPIMAGE)
GetQuantizeInfo(&quantize_info);
(void) RemapImages(&quantize_info, new_images, NULL);
#else
(void) MapImages(new_images, NULL, 0);
#endif
break;
case OptimizePlusLayer:
new_images = OptimizePlusImageLayers(images, &exception);
break;
case CompareAnyLayer:
case CompareClearLayer:
case CompareOverlayLayer:
new_images = CompareImageLayers(images, mthd, &exception);
break;
#if defined(HAVE_ENUM_MOSAICLAYER)
case MosaicLayer:
new_images = MergeImageLayers(images, mthd, &exception);
break;
#endif
#if defined(HAVE_ENUM_FLATTENLAYER)
case FlattenLayer:
new_images = MergeImageLayers(images, mthd, &exception);
break;
#endif
#if defined(HAVE_ENUM_MERGELAYER)
case MergeLayer:
new_images = MergeImageLayers(images, mthd, &exception);
break;
#endif
#if defined(HAVE_ENUM_TRIMBOUNDSLAYER)
case TrimBoundsLayer:
new_images = MergeImageLayers(images, mthd, &exception);
break;
#endif
default:
rm_split(images);
rb_raise(rb_eArgError, "undefined layer method");
break;
}
rm_split(images);
rm_check_exception(&exception, new_images, DestroyOnError);
(void) DestroyExceptionInfo(&exception);
rm_ensure_result(new_images);
return rm_imagelist_from_images(new_images);
}
|
#partition(&block) ⇒ Object
1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 |
# File 'lib/RMagick.rb', line 1718 def partition(&block) a = @images.partition(&block) t = self.class.new a[0].each { |img| t << img} t.set_current nil f = self.class.new a[1].each { |img| f << img} f.set_current nil [t, f] end |
#ping(*files, &block) ⇒ Object
Ping files and concatenate the new images
1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 |
# File 'lib/RMagick.rb', line 1730 def ping(*files, &block) if (files.length == 0) Kernel.raise ArgumentError, "no files given" end files.each { |f| Magick::Image.ping(f, &block).each { |n| @images << n } } @scene = length - 1 self end |
#pop ⇒ Object
1741 1742 1743 1744 1745 1746 |
# File 'lib/RMagick.rb', line 1741 def pop current = get_current() a = @images.pop # can return nil set_current current return a end |
#push(*objs) ⇒ Object
1748 1749 1750 1751 1752 1753 1754 1755 |
# File 'lib/RMagick.rb', line 1748 def push(*objs) objs.each do |image| is_an_image image @images << image end @scene = length - 1 self end |
#quantize(*args) ⇒ Object
Method: ImageList#quantize(<number_colors<, colorspace<, dither<, tree_depth<, measure_error>>>>>)
defaults: 256, Magick::RGBColorspace, true, 0, false
Purpose: call QuantizeImages Returns: a new ImageList with quantized images. ‘scene’ is set to the same
value as self.scene
774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 |
# File 'ext/RMagick/rmilist.c', line 774
VALUE
ImageList_quantize(int argc, VALUE *argv, VALUE self)
{
Image *images, *new_images;
Image *new_image;
QuantizeInfo quantize_info;
ExceptionInfo exception;
volatile VALUE new_imagelist, scene;
GetQuantizeInfo(&quantize_info);
switch (argc)
{
case 5:
quantize_info.measure_error = (MagickBooleanType) RTEST(argv[4]);
case 4:
quantize_info.tree_depth = (unsigned long)NUM2INT(argv[3]);
case 3:
#if defined(HAVE_TYPE_DITHERMETHOD) && defined(HAVE_ENUM_NODITHERMETHOD)
if (rb_obj_is_kind_of(argv[2], Class_DitherMethod))
{
VALUE_TO_ENUM(argv[2], quantize_info.dither_method, DitherMethod);
quantize_info.dither = quantize_info.dither_method != NoDitherMethod;
}
#else
quantize_info.dither = (MagickBooleanType) RTEST(argv[2]);
#endif
case 2:
VALUE_TO_ENUM(argv[1], quantize_info.colorspace, ColorspaceType);
case 1:
quantize_info.number_colors = NUM2ULONG(argv[0]);
case 0:
break;
default:
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 5)", argc);
break;
}
// Convert image array to image sequence, clone image sequence.
GetExceptionInfo(&exception);
images = images_from_imagelist(self);
new_images = CloneImageList(images, &exception);
rm_split(images);
rm_check_exception(&exception, new_images, DestroyOnError);
(void) DestroyExceptionInfo(&exception);
rm_ensure_result(new_images);
(void) QuantizeImages(&quantize_info, new_images);
rm_check_exception(&exception, new_images, DestroyOnError);
// Create new ImageList object, convert mapped image sequence to images,
// append to images array.
new_imagelist = ImageList_new();
while ((new_image = RemoveFirstImageFromList(&new_images)))
{
imagelist_push(new_imagelist, rm_image_new(new_image));
}
// Set @scene in new ImageList object to same value as in self.
scene = rb_iv_get(self, "@scene");
(void) rb_iv_set(new_imagelist, "@scene", scene);
return new_imagelist;
}
|
#read(*files, &block) ⇒ Object
Read files and concatenate the new images
1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 |
# File 'lib/RMagick.rb', line 1758 def read(*files, &block) if (files.length == 0) Kernel.raise ArgumentError, "no files given" end files.each { |f| Magick::Image.read(f, &block).each { |n| @images << n } } @scene = length - 1 self end |
#reject(&block) ⇒ Object
override Enumerable’s reject
1770 1771 1772 1773 1774 1775 1776 1777 |
# File 'lib/RMagick.rb', line 1770 def reject(&block) current = get_current() ilist = self.class.new a = @images.reject(&block) a.each {|image| ilist << image} ilist.set_current current return ilist end |
#reject!(&block) ⇒ Object
1779 1780 1781 1782 1783 1784 1785 |
# File 'lib/RMagick.rb', line 1779 def reject!(&block) current = get_current() a = @images.reject!(&block) @images = a if !a.nil? set_current current return a.nil? ? nil : self end |
#remap(*args) ⇒ Object Also known as: affinity
Method: ImageList#remap(remap_image=nil, dither_method=RiemersmaDitherMethod) Purpose: Call RemapImages Note: See Image_remap. Immediate - modifies images in-place
848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 |
# File 'ext/RMagick/rmilist.c', line 848
VALUE
ImageList_remap(int argc, VALUE *argv, VALUE self)
{
#if defined(HAVE_REMAPIMAGES) || defined(HAVE_AFFINITYIMAGES)
Image *images, *remap_image = NULL;
QuantizeInfo quantize_info;
if (argc > 0 && argv[0] != Qnil)
{
volatile VALUE t = rm_cur_image(argv[0]);
remap_image = rm_check_destroyed(t);
}
GetQuantizeInfo(&quantize_info);
if (argc > 1)
{
VALUE_TO_ENUM(argv[1], quantize_info.dither_method, DitherMethod);
quantize_info.dither = MagickTrue;
}
if (argc > 2)
{
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc);
}
images = images_from_imagelist(self);
#if defined(HAVE_REMAPIMAGE)
(void) RemapImages(&quantize_info, images, remap_image);
#else
(void) AffinityImages(&quantize_info, images, remap_image);
#endif
rm_check_image_exception(images, RetainOnError);
rm_split(images);
return self;
#else
self = self;
argc = argc;
argv = argv;
rm_not_implemented();
return(VALUE)0;
#endif
}
|
#replace(other) ⇒ Object
1787 1788 1789 1790 1791 1792 1793 1794 1795 |
# File 'lib/RMagick.rb', line 1787 def replace(other) is_an_image_array other current = get_current() @images.clear other.each {|image| @images << image} @scene = self.length == 0 ? nil : 0 set_current current self end |
#respond_to?(methID, priv = false) ⇒ Boolean
1799 1800 1801 1802 1803 1804 1805 1806 |
# File 'lib/RMagick.rb', line 1799 def respond_to?(methID, priv=false) return true if __respond_to__?(methID, priv) if @scene @images[@scene].respond_to?(methID, priv) else super end end |
#reverse ⇒ Object
1808 1809 1810 1811 1812 1813 1814 |
# File 'lib/RMagick.rb', line 1808 def reverse current = get_current() a = self.class.new @images.reverse_each {|image| a << image} a.set_current current return a end |
#reverse! ⇒ Object
1816 1817 1818 1819 1820 1821 |
# File 'lib/RMagick.rb', line 1816 def reverse! current = get_current() @images.reverse! set_current current self end |
#reverse_each ⇒ Object
1823 1824 1825 1826 |
# File 'lib/RMagick.rb', line 1823 def reverse_each @images.reverse_each {|image| yield(image)} self end |
#shift ⇒ Object
1828 1829 1830 1831 1832 1833 |
# File 'lib/RMagick.rb', line 1828 def shift current = get_current() a = @images.shift set_current current return a end |
#slice(*args) ⇒ Object
1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 |
# File 'lib/RMagick.rb', line 1835 def slice(*args) current = get_current() slice = @images.slice(*args) if slice ilist = self.class.new if slice.respond_to?(:each) then slice.each {|image| ilist << image} else ilist << slice end else ilist = nil end return ilist end |
#slice!(*args) ⇒ Object
1851 1852 1853 1854 1855 1856 |
# File 'lib/RMagick.rb', line 1851 def slice!(*args) current = get_current() a = @images.slice!(*args) set_current current return a end |
#ticks_per_second=(t) ⇒ Object
1858 1859 1860 1861 1862 1863 |
# File 'lib/RMagick.rb', line 1858 def ticks_per_second=(t) if Integer(t) < 0 Kernel.raise ArgumentError, "ticks_per_second must be greater than or equal to 0" end @images.each { |f| f.ticks_per_second = Integer(t) } end |
#to_a ⇒ Object
1865 1866 1867 1868 1869 |
# File 'lib/RMagick.rb', line 1865 def to_a a = Array.new @images.each {|image| a << image} return a end |
#to_blob ⇒ Object
Method: ImageList#to_blob Purpose: returns the imagelist as a blob (a String) Notes: runs an info parm block if present - the user can
specify the image format and depth
901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 |
# File 'ext/RMagick/rmilist.c', line 901
VALUE
ImageList_to_blob(VALUE self)
{
Image *images, *image;
Info *info;
volatile VALUE info_obj;
volatile VALUE blob_str;
void *blob = NULL;
size_t length = 0;
ExceptionInfo exception;
info_obj = rm_info_new();
Data_Get_Struct(info_obj, Info, info);
// Convert the images array to an images sequence.
images = images_from_imagelist(self);
GetExceptionInfo(&exception);
(void) SetImageInfo(info, MagickTrue, &exception);
rm_check_exception(&exception, images, RetainOnError);
if (*info->magick != '\0')
{
Image *img;
for (img = images; img; img = GetNextImageInList(img))
{
strncpy(img->magick, info->magick, sizeof(info->magick)-1);
}
}
for (image = images; image; image = GetNextImageInList(image))
{
rm_sync_image_options(image, info);
}
// Unconditionally request multi-images support. The worst that
// can happen is that there's only one image or the format
// doesn't support multi-image files.
info->adjoin = MagickTrue;
blob = ImagesToBlob(info, images, &length, &exception);
if (blob && exception.severity >= ErrorException)
{
magick_free((void*)blob);
blob = NULL;
length = 0;
}
rm_split(images);
CHECK_EXCEPTION()
(void) DestroyExceptionInfo(&exception);
if (length == 0 || !blob)
{
return Qnil;
}
blob_str = rb_str_new(blob, (long)length);
magick_free((void*)blob);
return blob_str;
}
|
#uniq ⇒ Object
1871 1872 1873 1874 1875 1876 1877 |
# File 'lib/RMagick.rb', line 1871 def uniq current = get_current() a = self.class.new @images.uniq.each {|image| a << image} a.set_current current return a end |
#uniq!(*args) ⇒ Object
1879 1880 1881 1882 1883 1884 |
# File 'lib/RMagick.rb', line 1879 def uniq!(*args) current = get_current() a = @images.uniq! set_current current return a.nil? ? nil : self end |
#unshift(obj) ⇒ Object
1887 1888 1889 1890 1891 1892 |
# File 'lib/RMagick.rb', line 1887 def unshift(obj) is_an_image obj @images.unshift(obj) @scene = 0 self end |
#values_at(*args) ⇒ Object Also known as: indexes, indices
1894 1895 1896 1897 1898 1899 1900 |
# File 'lib/RMagick.rb', line 1894 def values_at(*args) a = @images.values_at(*args) a = self.class.new @images.values_at(*args).each {|image| a << image} a.scene = a.length - 1 return a end |
#write(file) ⇒ Object
Method: ImageList#write(file) Purpose: Write all the images to the specified file. If the file format
supports multi-image files, and the @images array contains more
than one image, then the images will be written as a single
multi-image file. Otherwise each image will be written to a
separate file. Returns self.
972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 |
# File 'ext/RMagick/rmilist.c', line 972
VALUE
ImageList_write(VALUE self, VALUE file)
{
Image *images, *img;
Info *info;
const MagickInfo *m;
volatile VALUE info_obj;
unsigned long scene;
ExceptionInfo exception;
info_obj = rm_info_new();
Data_Get_Struct(info_obj, Info, info);
if (TYPE(file) == T_FILE)
{
OpenFile *fptr;
// Ensure file is open - raise error if not
GetOpenFile(file, fptr);
SetImageInfoFile(info, GetReadFile(fptr));
}
else
{
add_format_prefix(info, file);
SetImageInfoFile(info, NULL);
}
// Convert the images array to an images sequence.
images = images_from_imagelist(self);
// Copy the filename into each image. Set a scene number to be used if
// writing multiple files. (Ref: ImageMagick's utilities/convert.c
for (scene = 0, img = images; img; img = GetNextImageInList(img))
{
img->scene = scene++;
strcpy(img->filename, info->filename);
}
// Find out if the format supports multi-images files.
GetExceptionInfo(&exception);
(void) SetImageInfo(info, MagickTrue, &exception);
rm_check_exception(&exception, images, RetainOnError);
m = GetMagickInfo(info->magick, &exception);
rm_check_exception(&exception, images, RetainOnError);
(void) DestroyExceptionInfo(&exception);
// Tell WriteImage if we want a multi-images file.
if (imagelist_length(self) > 1L && m->adjoin)
{
info->adjoin = MagickTrue;
}
for (img = images; img; img = GetNextImageInList(img))
{
rm_sync_image_options(img, info);
(void) WriteImage(info, img);
// images will be split before raising an exception
rm_check_image_exception(images, RetainOnError);
if (info->adjoin)
{
break;
}
}
rm_split(images);
return self;
}
|