Webptools v0.0.9
webptools is a Webp image conversion package for the python.
Convert JPG,PNG.. images to webp image format
This library uses precompiled executables of WebP(v1.1.0) for more info
visit WebP
For converting other image formats to webp, please read this
documentation cwebp Encoder
For converting webp image to other image format, please read this
documentation dwebp Encoder
For converting gif image to webp, please read this
documentation gif2webp Converter
For creating animated webp image using webp images, please read this
documentation webpmux Muxer
How to use
Installation
$ pip install webptools
Fix Permission Issue (if not using external executables)
from webptools import grant_permission
grant_permission()
Using External executables
bin_path="libwebp_linux/bin/cwebp"
cwebp
Convert other image format to webp
from webptools import cwebp
print(cwebp(input_image="python_logo.jpg", output_image="python_logo.webp",
option="-q 80", logging="-v"))
Convert base64 image to webp base64
from webptools import base64str2webp_base64str
print(
base64str2webp_base64str(base64str="", image_type="jpg", option="-q 80",
logging="-v"))
print(base64str2webp_base64str(base64str="", image_type="jpg", option="-q 80",
temp_path="./temp",
logging="-v"))
dwebp
Convert webp image to other image format
from webptools import dwebp
print(dwebp(input_image="python_logo.webp", output_image="python_logo.jpg",
option="-o", logging="-v"))
gif2webp
Convert gif image to webp
from webptools import gifwebp
print(gifwebp(input_image="linux_logo.gif", output_image="linux_logo.webp",
option="-q 80", logging="-v"))
webpmux
Add ICC profile,XMP metadata and EXIF metadata
from webptools import webpmux_add
print(webpmux_add(input_image="in.webp", output_image="icc_container.webp",
icc_profile="image_profile.icc", option="icc"))
Extract ICC profile,XMP metadata and EXIF metadata
from webptools import webpmux_extract
print(webpmux_extract(input_image="anim_container.webp",
icc_profile="image_profile.icc", option="icc"))
Strip ICC profile,XMP metadata and EXIF metadata
from webptools import webpmux_strip
print(webpmux_strip(input_image="icc_container.webp",
output_image="without_icc.webp", option="icc"))
Create an animated WebP file from Webp images
from webptools import webpmux_animate
input = ["./frames/tmp-0.webp +100", "./frames/tmp-1.webp +100",
"./frames/tmp-2.webp +100"]
print(webpmux_animate(input_images=input, output_image="anim_container.webp",
loop="10", bgcolor="255,255,255,255"))
Get a frame from an animated WebP file
from webptools import webpmux_getframe
print(webpmux_getframe(input_image="anim_container.webp",
output_image="frame_2.webp", frame_number="2"))