NAME

Image::WebP - binding to Google's libwebp.

SYNOPSIS

use Image::WebP;

my $foo = Image::WebP->new();

# get info about image
my $img_info = $foo->WebPGetInfo($webp_image_data);

# uncompress Webp-encoded data:
my $raw_data = $foo->WebPDecodeSimple($webp_image_data, "RGB");

SUBROUTINES/METHODS

new

Constructor. No params needed.

WebPGetFeatures(img_data)

Return hashref with information about passed <img_data> - the raw data of webp image file. Check field 'status', if it 0, then the webp data was invalid and image decoding failed. The other fileds is 'width' and 'height', and 'has_alpha'.

WebPDecodeSimple (data, format)

Decode WebP image data into the specified RGB format. The format can be: "RGBA", "ARGB", "BGRA", "RGB", "BGR". Returns raw string. If you pass invalid WebP data, the method throws an exception.

Returns hash like:

{
   'data'   => ...,
   'width'  => ...,
   'height' => ...
}

WebPEncodeSimple(data, width, height, format, opts)

Encode raw RGB or RGBA data with the specified width and height into WebP data. format must describe the raw data and can be one of "RGBA", "BGRA", "RGB", "BGR".

The <opts> parameter stands for encoding options. For understanding them see https://developers.google.com/speed/webp/docs/api. Supported options are:

{
   stride  => integer, # not specify it unless you really know what you want
   quality => float,   # 0.0 - 100.0, needed if you compress to lossy format
   lossless => 0 || 1, # 0 for lossy encoding and 1 for lossless
}

The historical misspelling loseless remains accepted for compatibility.

AUTHOR

Zargener, <zargener at gmail.com> Zen Dodd, <mail at steadytao.com>

LICENSE AND COPYRIGHT

Copyright 2013-2026 Yalexwander.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0