Prima::...:Loader(3)
β¨ NAME β¨
Hey bestie π you're reading Prima::...:Loader(3), a page from the User Contributed Perl Documentation collection. It's the manual for Prima::Image::Loader β progressive loading and saving for multiframe images. Slay.
πΈ DESCRIPTION πΈ
Okay so the toolkit gives you session-based loading and saving for multiframe images, so you do not have to store all image frames in memory at once. Instead, the Prima::Image::Loader and Prima::Image::Saver classes hand you the API for operating on a single frame at a time. Iconic. π
π§ Prima::Image::Loader
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;
}
new FILENAME|FILEHANDLE, %OPTIONSβ Opens a filename or a file handle, tries to deduce if the toolkit can recognize the image, and creates an image loading handler. The%OPTIONSare the same as recognized byloadinPrima::Imageexceptmap,loadAll, andprofiles. The other options apply to each frame that will be consequently loaded, but these options could be overridden by supplying parameters to thenextcall.
Returns either a new loader object or undef and an error string.
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 point to the newly created image, not the loader object.
closeβ Releases the image file handle. The image can be reopened again by callingreload.current INDEXβ Manages the index of the frame that will be loaded next. When set, requests repositioning of the frame pointer so that the next call tonextwould load theINDEXth image.eofβ Returns the boolean flag if the end of the file is reached.extrasβ Returns the hash of the extra file data as filled by the codec.framesβ Returns the number of frames in the file.next %OPTIONSβ Loads the next image frame.
Returns either a newly loaded image or undef and an error string.
reloadβ In case an animation file is defective 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. Thereloadmethod does this by reopening the loading session with all the parameters supplied to the initialnewcall. The programmer thus has a chance to record how many successful frames were loaded, and only navigate these after the reload.rescue BOOLEANβ If set, reopens the input stream or file on every new frame. This may help recover broken frames.sourceβ Returns the filename or the file handle passed to thenewcall.
π¦ Prima::Image::Saver
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;
}
new FILENAME|FILEHANDLE, %OPTIONSβ Opens a filename or a file handle. The%OPTIONSare the same as recognized bysaveinPrima::Imageexcept theimagesoption. The other options apply to each frame that will be consequently saved, but these options could also be overridden by supplying parameters to thesavecall.
Returns either a new saver object or undef and an error string.
save %OPTIONSβ Saves the next image frame.
Returns a success boolean flag and an eventual error string.
π AUTHOR
Dmitry Karasik, <dmitry@karasik.eu.org>.
π SEE ALSO
Prima::Image::Animateβ go look, bestie π¦
xoxo π this page comes from perl v5.42.0, dated 2024-08-20, under the Prima::...:Loader(3) manual slot. Bye bestie! π«Ά
π¦ where this page comes from
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms