Imager::File::APNG - read and write APNG image files
use Imager; use Imager::File::APNG; my @frames = Imager->read_multi(file => "foo.png", type => "apng) or die Imager->errstr; Imager->write_multi({ file => "foo.png", type => "apng" apng_delay => 1/60, }, @frames) or die Imager->errstr;
Implements APNG support for Imager.
To write an APNG image the type parameter needs to be explicitly supplied.
Due to the limitations of APNG all images are written as the same type, eg. all RGBA, or all Grayscale, or all paletted with the same palette. Imager::File::APNG will upgrade all supplied images to the greatest common layout.
APNG
Imager::File::APNG
The i_format tag is deliberately set to png on reading an APNG image.
i_format
png
Tags common to reading and writing:
apng_hidden - set on all images when reading, only has an effect on the first image when writing. If non-zero for the first image it will be hidden from the animation.
apng_hidden
apng_num_plays - set on all images when reading, only used from the fisrt image when writing. Specifies the number of time to repeat the animation. If zero repeat forever. Default: 0.
apng_num_plays
apng_xoffset, apng_yoffset - the position of the frame within the canvas, which is defined by the first image. The frame as positioned by these offsets must be contained within the canvas dimensions. Both default to 0.
apng_xoffset
apng_yoffset
apng_dispose - for each animation frame, one of 0, 1, or 2, or alternatively none, background or previous when writing. Default: 0.
apng_dispose
none
background
previous
apng_blend - for each animation frame, one of 0 or 1, or alternatively source or over when writing. Default: 0.
apng_blend
source
over
apng_delay - for each animation frame, the delay in seconds, including fractional seconds, that the frame is displayed for. This overrides apng_delay_num and apng_delay_den. This is currently converted to a fraction out of 1000 when written to the file.
apng_delay
apng_delay_num
apng_delay_den
apng_delay_num, apng_delay_den - for each animation frame, the delay in seconds, including fractional seconds, that the frame is displayed for, as a rational number apng_delay_num / apng_delay_den . Default: 1/60. Ignored if apng_delay is set. All three tags are set on read.
apng_delay_num / apng_delay_den
Support paletted images. This will require that all the images have the same palette.
Optionally optimize frame generation from the source images, eg, trimming common pixels between the canvas at that point.
Optionally generate a common palette across all the frames. This should work with the above.
Provide a tool to convert optimized frames read from a file into full frames.
Tony Cook <tonyc@cpan.org>
Imager, <Imager::Files>.
To install Imager::File::APNG, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Imager::File::APNG
CPAN shell
perl -MCPAN -e shell install Imager::File::APNG
For more information on module installation, please visit the detailed CPAN module installation guide.