Skip Menu |

This queue is for tickets about the Imager CPAN distribution.

Report information
The Basics
Id: 71494
Status: new
Priority: 80/
Queue: Imager

People
Owner: Nobody in particular
Requestors: TONYC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.85
Fixed in: (no value)



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; }
On Thu Oct 06 01:42:37 2011, TONYC wrote: Show quoted text
> 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; > } >
An extension to this would be to support modification of an existing file, eg: my $iter = Imager->open_multi(file => "foo.tiff"); my @file = $iter->fetch; $iter->replace(image => $im); $iter->append(image => $im); $iter->delete; $iter->addbefore(image => $im); $iter->addafter(image => $im); These should all be possible with TIFF (and DCX which is unsupported), only appending makes sense for GIF, PxM.