|
| 1 | +Metadata-Version: 1.0 |
| 2 | +Name: webptools |
| 3 | +Version: 0.0.1 |
| 4 | +Summary: Webp image conversion package for python. |
| 5 | +Home-page: https://github.com/scionoftech/webptools |
| 6 | +Author: Sai Kumar Yava |
| 7 | + |
| 8 | +License: MIT |
| 9 | +Description: webptools is a Webp image conversion package for python. |
| 10 | + ==================== |
| 11 | + |
| 12 | + |
| 13 | + Installation |
| 14 | + ------------ |
| 15 | + |
| 16 | + .. code:: sh |
| 17 | + |
| 18 | + from webptools import webplib as webp |
| 19 | + |
| 20 | + |
| 21 | + - This library uses precompiled executables of WebP for more info visit `WebP <https://developers.google.com/speed/webp>` |
| 22 | + - For converting other image formats to webp, please read this documentation `cwebp Encoder <https://developers.google.com/speed/webp/docs/cwebp>` |
| 23 | + - For converting webp image to other image format, please read this documentation `dwebp Encoder <https://developers.google.com/speed/webp/docs/dwebp>` |
| 24 | + - For converting gif image to webp, please read this documentation `gif2webp Converter <https://developers.google.com/speed/webp/docs/gif2webp>` |
| 25 | + - For creating animated webp image using webp images, please read this documentation `webpmux Muxer <https://developers.google.com/speed/webp/docs/webpmux>` |
| 26 | + |
| 27 | + Usage |
| 28 | + ----- |
| 29 | + |
| 30 | + .. code:: python |
| 31 | + |
| 32 | + import webptools |
| 33 | + |
| 34 | + How to use |
| 35 | + ~~~~~~~~~~ |
| 36 | + cwebp |
| 37 | + ~~~~~~~~~~ |
| 38 | + Convert other image format to webp |
| 39 | + ~~~~~~~~~~ |
| 40 | + |
| 41 | + .. code:: python |
| 42 | + |
| 43 | + from webptools import webplib as webp |
| 44 | + |
| 45 | + # pass input_image(.jpeg,.pnp .....) path , |
| 46 | + # output_image(give path where to save and image file name with .webp file type extension) |
| 47 | + print(webp.cwebp("python_logo.jpg", "python_logo.webp", "-q 80")) |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + dwebp |
| 52 | + ~~~~~~~~~~ |
| 53 | + Convert webp image to other image format |
| 54 | + ~~~~~~~~~~ |
| 55 | + |
| 56 | + .. code:: python |
| 57 | + |
| 58 | + from webptools import webplib as webp |
| 59 | + |
| 60 | + # pass input_image(.webp image) path ,output_image(.jpeg,.pnp .....) |
| 61 | + print(webp.dwebp("python_logo.webp","python_logo.jpg","-o")) |
| 62 | + |
| 63 | + |
| 64 | + gif2webp |
| 65 | + ~~~~~~~~~~ |
| 66 | + Convert gif image to webp |
| 67 | + ~~~~~~~~~~ |
| 68 | + |
| 69 | + .. code:: python |
| 70 | + |
| 71 | + from webptools import webplib as webp |
| 72 | + |
| 73 | + # pass input_image(.gif) path ,output_image(give path where to save and image file name with .webp file type extension) |
| 74 | + print(webp.gifwebp("linux_logo.gif","linux_logo.webp","-q 80")) |
| 75 | + |
| 76 | + |
| 77 | + webpmux |
| 78 | + ~~~~~~~~~~ |
| 79 | + Add ICC profile,XMP metadata and EXIF metadata |
| 80 | + ~~~~~~~~~~ |
| 81 | + |
| 82 | + .. code:: python |
| 83 | + |
| 84 | + from webptools import webplib as webp |
| 85 | + |
| 86 | + # pass input_image(.webp image) path,output_image,set options(icc image profile,XMP metadata or EXIF metadata) and file. |
| 87 | + # for options use keywords as below |
| 88 | + # for ICC: icc |
| 89 | + # for XMP metadata: xmp |
| 90 | + # for EXIF metadata: exif |
| 91 | + print(webp.webpmux_add("in.webp","icc_container.webp","image_profile.icc","icc")) |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + Extract ICC profile,XMP metadata and EXIF metadata |
| 96 | + ~~~~~~~~~~ |
| 97 | + |
| 98 | + .. code:: python |
| 99 | + |
| 100 | + from webptools import webplib as webp |
| 101 | + |
| 102 | + # pass input_image(.webp image) path,output_image,set options(icc image profile,XMP metadata or EXIF metadata) and file. |
| 103 | + # for options use keywords as below |
| 104 | + # for ICC: icc |
| 105 | + # for XMP metadata: xmp |
| 106 | + # for EXIF metadata: exif |
| 107 | + print(webp.webpmux_extract("anim_container.webp","image_profile.icc","icc")) |
| 108 | + |
| 109 | + |
| 110 | + Strip ICC profile,XMP metadata and EXIF metadata |
| 111 | + ~~~~~~~~~~ |
| 112 | + |
| 113 | + .. code:: python |
| 114 | + |
| 115 | + from webptools import webplib as webp |
| 116 | + |
| 117 | + # pass input_image(.webp image) path,output_image,set options(icc image profile,XMP metadata or EXIF metadata) and file. |
| 118 | + # for options use keywords as below |
| 119 | + # for ICC: icc |
| 120 | + # for XMP metadata: xmp |
| 121 | + # for EXIF metadata: exif |
| 122 | + print(webp.webpmux_strip("icc_container.webp","without_icc.webp","icc")) |
| 123 | + |
| 124 | + |
| 125 | + |
| 126 | + Create an animated WebP file from Webp images |
| 127 | + ~~~~~~~~~~ |
| 128 | + |
| 129 | + .. code:: python |
| 130 | + |
| 131 | + from webptools import webplib as webp |
| 132 | + |
| 133 | + # pass input_images(.webp image) path with FRAME_OPTIONS, as array,ouput image will be animated .webp image |
| 134 | + |
| 135 | + # https://developers.google.com/speed/webp/docs/webpmux |
| 136 | + # FRAME_OPTIONS |
| 137 | + |
| 138 | + # -file_i +di[+xi+yi[+mi[bi]]] |
| 139 | + |
| 140 | + # e.g -frame one.webp +100 -frame two.webp +100+50+50 -frame three.webp +100+50+50+1+b |
| 141 | + |
| 142 | + # Where: file_i is the i'th frame (WebP format), xi,yi specify the image offset for this frame, |
| 143 | + # di is the pause duration before next frame, mi is the dispose method for this frame (0 for NONE or 1 for BACKGROUND) |
| 144 | + # and bi is the blending method for this frame (+b for BLEND or -b for NO_BLEND). |
| 145 | + # Argument bi can be omitted and will default to +b (BLEND). Also, mi can be omitted if bi is omitted and |
| 146 | + # will default to 0 (NONE). Finally, |
| 147 | + # if mi and bi are omitted then xi and yi can be omitted and will default to +0+0. |
| 148 | + |
| 149 | + # -loop n |
| 150 | + |
| 151 | + # e.g 10 |
| 152 | + |
| 153 | + # Loop the frames n number of times. 0 indicates the frames should loop forever. |
| 154 | + # Valid range is 0 to 65535 [Default: 0 (infinite)]. |
| 155 | + |
| 156 | + # -bgcolor A,R,G,B |
| 157 | + |
| 158 | + # e.g 255,255,255,255 |
| 159 | + |
| 160 | + # Background color of the canvas. Where: A, R, G and B are integers in the range 0 to 255 specifying |
| 161 | + # the Alpha, Red, Green and Blue component values respectively [Default: 255,255,255,255]. |
| 162 | + |
| 163 | + input=["./frames/tmp-0.webp +100","./frames/tmp-1.webp +100","./frames/tmp-2.webp +100"] |
| 164 | + print(webp.webpmux_animate(input,"anim_container.webp","10","255,255,255,255")) |
| 165 | + |
| 166 | + |
| 167 | + |
| 168 | + Get a frame from an animated WebP file |
| 169 | + ~~~~~~~~~~ |
| 170 | + |
| 171 | + .. code:: python |
| 172 | + |
| 173 | + from webptools import webplib as webp |
| 174 | + |
| 175 | + # pass input_image(.webp image) path ,output_image and frame number |
| 176 | + print(webp.webpmux_getframe("anim_container.webp","frame_2.webp","2")) |
| 177 | + |
0 commit comments