Subject: | provide image file iteration for files with multiple images |
Date: | Thu, 6 Oct 2011 16:42:27 +1100 |
To: | bug-Imager [...] rt.cpan.org |
From: | tonyc [...] cpan.org |
Currently all of the images in a multi-image GIF, TIFF or PNM file are
loaded into memory when reading or writing:
my @images = Imager->read_multi(...);
Imager->write_multi({ ... }, @images);
Allow the caller to iterate over the images in a file.
This must not use a callback mechanism:
Imager->read_multi(onread => sub { my $img = shift; } ...)
since that makes doing different things with different images from the
file more complex. Ideally an iterator pattern:
my $iter = Imager->read_iterator(file => ...);
while (my $img = $iter->next) {
}
and similarly for writing:
my $iter = Imager->write_iterator(file => ...);
while (my $row = $sth->fetchrow) {
my $img = ...;
$iter->write($img)
or die;
}