Imager::File::WEBP - read and write WEBP files
use Imager; my $img = Imager->new; $img->read(file=>"foo.webp") or die $img->errstr; # type won't be necessary if the extension is webp from Imager 1.008 $img->write(file => "foo.webp", type => "webp") or die $img->errstr;
Implements .webp file support for Imager.
Due to the limitations of webp grayscale images are written as RGB images.
webp
webp_mode - set when reading an image and used when writing. Possible values:
webp_mode
lossy - write in lossy mode. This is the default.
lossy
lossless - write in lossless mode.
lossless
webp_quality - the lossy compression quality, a floating point number from 0 (bad) to 100 (better). Default: 80.
webp_quality
These only have meaning for files with more than one image.
Tags that can be set for the whole file, only the tag value from the first image is used when writing:
webp_loop_count - the number of times to loop the animation. When writing an animation this is fetched only from the first image. When reading, the same file global value is set for every image read. Default: 0.
webp_loop_count
webp_background - the background color for the animation. When writing an animation this is fetched only from the first image. When reading, the same file global value is set for every image read. Default: white.
webp_background
The following can be set separately for each image in the file:
webp_left, webp_top - position of the frame within the animation frame. Only has meaning for multiple image files. Odd numbers are stored as the even number just below. Default: 0.
webp_left
webp_top
webp_duraton - duration of the frame in milliseconds. Default: 100.
webp_duraton
webp_dispose - the disposal method for the frame:
webp_dispose
background - restore to the background before displaying the next frame.
background
none - leave the canvas as is when drawing the next frame.
none
Default: background.
webp_blend - the blend method for the frame:
webp_blend
alpha - alpha combine the frame with canvas.
alpha
none - replace the area under the image with the frame.
If the frame has no alpha channel this option makes no difference.
Default: alpha.
To install Imager::File::WEBP you need Imager installed and you need libwebp 0.5.0 or later and the libwebpmux distributed with libwebp.
These aren't intended immediately, but are possible future enhancements.
This is complicated by the simple lossless API doesn't support it (while lossy does.)
To fix this I'd probably pull imexif.* out of Imager::File::JPEG and make it part of the Imager API.
Maybe also add extended EXIF/Geotagging via libexif or Exiftool.
I think this is largely done.
Tony Cook <tonyc@cpan.org>
Imager, Imager::Files.
To install Imager::File::WEBP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Imager::File::WEBP
CPAN shell
perl -MCPAN -e shell install Imager::File::WEBP
For more information on module installation, please visit the detailed CPAN module installation guide.