Prima::Image::Loader - progressive loading and saving for multiframe images
The toolkit provides functionality for session-based loadign and saving of multiframe images to that is is not needed to store all images in memory at once. Instead, the Prima::Image::Loader and Prima::Image::Saver classes provide the API for operating on a single frame at a time.
Prima::Image::Loader
Prima::Image::Saver
use Prima::Image::Loader; my $l = Prima::Image::Loader->new($ARGV[0]); printf "$ARGV[0]: %d frames\n", $l->frames; while ( !$l->eof ) { my ($i,$err) = $l->next; die $err unless $i; printf "$n: %d x %d\n", $i->size; }
Opens a filename or a file handle, tries to deduce if the toolkit can recognize the image, and creates an image loading handler. The %OPTIONS are same as recognized by "load" in Prima::Image except map, loadAll, and profiles. The other options apply to each frame that will be coonsequently loaded, but these options could be overridden by supplying parameters to the next call.
%OPTIONS
map
loadAll
profiles
next
Returns either a new loader object, or undef and the error string.
undef
Note that it is possible to supply the onHeaderReady and onDataReady callbacks in the options, however, note that the first arguments in these callbacks will the newly created image.
onHeaderReady
onDataReady
Manages the index of the frame that will be loaded next. When set, requests repositioning of the frame pointer so that the next call to next would load the INDEXth image.
Return the boolean flag is the end of the file is reached.
Returns the hash of extra file data filled by the codec
Returns number of frames in the file
Loads the next image frame.
Returns either a newly loaded image, or undef and the error string.
In case an animation file is defect, and cannot be loaded in full, the toolkit will not allow to continue the loading session and will close it automatically. If it is desired to work around this limitation, a new session must be opened. The reload method does this by reopening the loading session with all the parameters supplied to new. The programmer thus has a chance to record how many successful frames were loaded, and only navigate these after the reload.
reload
new
If set, reopens the input stream or file on ever new frame. This may help recover broken frames.
Return the filename or the file handle passed to the new call.
my $fn = '1.webp'; open F, ">", $fn or die $!; my ($s,$err) = Prima::Image::Saver->new(\*F, frames => scalar(@images)); die $err unless $s; for my $image (@images) { my ($ok,$err) = $s->save($image); next if $ok; unlink $fn; die $err; }
Opens a filename or a file handle and an image saving handler. The %OPTIONS are same as recognized by "save" in Prima::Image except images. The other options apply to each frame that will be coonsequently saved, but these options could be overridden by supplying parameters to the save call.
images
save
Returns either a new saver object, or undef and the error string.
Saves the next image frame.
Returns a success boolean flag and an eventual error string
Dmitry Karasik, <dmitry@karasik.eu.org>.
Prima::Dialog::Animate.
To install Prima, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Prima
CPAN shell
perl -MCPAN -e shell install Prima
For more information on module installation, please visit the detailed CPAN module installation guide.