The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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 specified rgb <format>. Format can be: "RGBA", "ARGB", "BGRA", "RGB", "BGR". Returns raw string. If you pass wrong webp data, you can catch segfault!

Returns hash like:

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

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

Encode raw RGB <data> with specified <width> and <height> into webp image and return it as string. Parameter <format> stands for raw data format, you pass to function, it can be one of "RGBA", "BGRA", "RGB", "BGR". The <format> must be exactly same as your data, or you will encounter segfault!

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
    loseless=> 0 || 1,  #  0 for lossy encoding and 1 for loseless
 }

AUTHOR

Zargener, <zargener at gmail.com>

LICENSE AND COPYRIGHT

Copyright 2013 Zargener.

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