Skip to content

Commit ed0faf8

Browse files
committed
0.0.4
1 parent b540f62 commit ed0faf8

15 files changed

+649
-98
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2019 Sai Kumar Yava
3+
Copyright (c) 2021 Sai Kumar Yava
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 69 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,43 @@
1-
[Webptools v0.0.3](https://pypi.org/project/webptools/)
1+
[Webptools v0.0.4](https://pypi.org/project/webptools/)
22

3-
webptools is a Webp image conversion package for python.
3+
webptools is a Webp image conversion package for the python.
44

55
Convert JPG,PNG.. images to webp image format
66

7-
This library uses precompiled executables of WebP for more info visit [WebP](https://developers.google.com/speed/webp)
7+
This library uses precompiled executables of WebP(v1.1.0) for more info
8+
visit [WebP](https://developers.google.com/speed/webp)
89

9-
For converting other image formats to webp, please read this documentation [cwebp Encoder](https://developers.google.com/speed/webp/docs/cwebp)
10+
For converting other image formats to webp, please read this
11+
documentation [cwebp Encoder](https://developers.google.com/speed/webp/docs/cwebp)
1012

11-
For converting webp image to other image format, please read this documentation [dwebp Encoder](https://developers.google.com/speed/webp/docs/dwebp)
13+
For converting webp image to other image format, please read this
14+
documentation [dwebp Encoder](https://developers.google.com/speed/webp/docs/dwebp)
1215

13-
For converting gif image to webp, please read this documentation [gif2webp Converter](https://developers.google.com/speed/webp/docs/gif2webp)
16+
For converting gif image to webp, please read this
17+
documentation [gif2webp Converter](https://developers.google.com/speed/webp/docs/gif2webp)
1418

15-
For creating animated webp image using webp images, please read this documentation [webpmux Muxer](https://developers.google.com/speed/webp/docs/webpmux)
19+
For creating animated webp image using webp images, please read this
20+
documentation [webpmux Muxer](https://developers.google.com/speed/webp/docs/webpmux)
1621

22+
## What's New
1723

18-
## What's New
19-
* Precompiled executables of WebP(v1.1.0) added
20-
24+
* webp executables permission issue fixed
25+
* base64 to webp base64 added
26+
* logging options added
2127

2228
# How to use
2329

30+
## Fix Permission Issue
31+
32+
```python
33+
34+
from webptools import grant_permission
35+
36+
# this will grant 755 permission to webp executables
37+
grant_permission()
38+
39+
```
40+
2441
# cwebp
2542

2643
## Convert other image format to webp
@@ -31,8 +48,29 @@ from webptools import cwebp
3148

3249
# pass input_image(.jpeg,.pnp .....) path ,
3350
# output_image(give path where to save and image file name with .webp file type extension)
34-
print(cwebp("python_logo.jpg", "python_logo.webp", "-q 80"))
51+
print(cwebp(input_image="python_logo.jpg", output_image="python_logo.webp",
52+
option="-q 80", logging="-v"))
53+
54+
55+
```
56+
57+
## Convert base64 image to webp base64
58+
59+
```python
60+
61+
from webptools import base64str2webp_base64str
62+
63+
# pass base64 image, image type, webp options,
64+
# for the conversion temp location need
3565

66+
# use the default temp path for conversion
67+
print(
68+
base64str2webp_base64str(base64str="", image_type="jpg", option="-q 80",
69+
logging="-v"))
70+
# use the custom temp path for conversion
71+
print(base64str2webp_base64str(base64str="", image_type="jpg", option="-q 80",
72+
temp_path="./temp",
73+
logging="-v"))
3674

3775
```
3876

@@ -45,7 +83,8 @@ print(cwebp("python_logo.jpg", "python_logo.webp", "-q 80"))
4583
from webptools import dwebp
4684

4785
# pass input_image(.webp image) path ,output_image(.jpeg,.pnp .....)
48-
print(dwebp("python_logo.webp","python_logo.jpg","-o"))
86+
print(dwebp(input_image="python_logo.webp", output_image="python_logo.jpg",
87+
option="-o", logging="-v"))
4988

5089
```
5190

@@ -57,7 +96,8 @@ print(dwebp("python_logo.webp","python_logo.jpg","-o"))
5796
from webptools import gifwebp
5897

5998
# pass input_image(.gif) path ,output_image(give path where to save and image file name with .webp file type extension)
60-
print(gifwebp("linux_logo.gif","linux_logo.webp","-q 80"))
99+
print(gifwebp(input_image="linux_logo.gif", output_image="linux_logo.webp",
100+
option="-q 80", logging="-v"))
61101
```
62102

63103
# webpmux
@@ -72,7 +112,8 @@ from webptools import webpmux_add
72112
# for ICC: icc
73113
# for XMP metadata: xmp
74114
# for EXIF metadata: exif
75-
print(webpmux_add("in.webp","icc_container.webp","image_profile.icc","icc"))
115+
print(webpmux_add(input_image="in.webp", output_image="icc_container.webp",
116+
icc_profile="image_profile.icc", option="icc", logging="-v"))
76117
```
77118

78119
## Extract ICC profile,XMP metadata and EXIF metadata
@@ -86,7 +127,9 @@ from webptools import webpmux_extract
86127
# for ICC: icc
87128
# for XMP metadata: xmp
88129
# for EXIF metadata: exif
89-
print(webpmux_extract("anim_container.webp","image_profile.icc","icc"))
130+
print(webpmux_extract(input_image="anim_container.webp",
131+
icc_profile="image_profile.icc", option="icc",
132+
logging="-v"))
90133
```
91134

92135
## Strip ICC profile,XMP metadata and EXIF metadata
@@ -100,7 +143,9 @@ from webptools import webpmux_strip
100143
# for ICC: icc
101144
# for XMP metadata: xmp
102145
# for EXIF metadata: exif
103-
print(webpmux_strip("icc_container.webp","without_icc.webp","icc"))
146+
print(webpmux_strip(input_image="icc_container.webp",
147+
output_image="without_icc.webp", option="icc",
148+
logging="-v"))
104149

105150

106151
```
@@ -141,8 +186,10 @@ from webptools import webpmux_animate
141186
# Background color of the canvas. Where: A, R, G and B are integers in the range 0 to 255 specifying
142187
# the Alpha, Red, Green and Blue component values respectively [Default: 255,255,255,255].
143188

144-
input=["./frames/tmp-0.webp +100","./frames/tmp-1.webp +100","./frames/tmp-2.webp +100"]
145-
print(webpmux_animate(input,"anim_container.webp","10","255,255,255,255"))
189+
input = ["./frames/tmp-0.webp +100", "./frames/tmp-1.webp +100",
190+
"./frames/tmp-2.webp +100"]
191+
print(webpmux_animate(input_images=input, output_image="anim_container.webp",
192+
loop="10", bgcolor="255,255,255,255", logging="-v"))
146193

147194
```
148195

@@ -153,7 +200,9 @@ print(webpmux_animate(input,"anim_container.webp","10","255,255,255,255"))
153200
from webptools import webpmux_getframe
154201

155202
# pass input_image(.webp image) path ,output_image and frame number
156-
print(webpmux_getframe("anim_container.webp","frame_2.webp","2"))
203+
print(webpmux_getframe(input_image="anim_container.webp",
204+
output_image="frame_2.webp", frame_number="2",
205+
logging="-v"))
157206

158207

159208
```
@@ -166,4 +215,4 @@ $ pip install webptools
166215

167216
## License
168217

169-
[MIT](LICENSE)
218+
[MIT](LICENSE)

dist/webptools-0.0.4.tar.gz

14.3 MB
Binary file not shown.

setup.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,28 @@
55

66
setuptools.setup(
77
name="webptools",
8-
version="0.0.3",
8+
version="0.0.4",
99
scripts=['webptools/webplib.py'],
1010
author="Sai Kumar Yava",
1111
author_email="[email protected]",
1212
description="webptools is a Webp image conversion package for python",
1313
long_description=long_description,
1414
long_description_content_type='text/markdown',
1515
url="https://github.com/scionoftech/webptools",
16-
packages=['webptools', 'lib', 'lib/libwebp_linux', 'lib/libwebp_osx', 'lib/libwebp_win64'],
16+
packages=['webptools', 'lib', 'lib/libwebp_linux', 'lib/libwebp_osx',
17+
'lib/libwebp_win64'],
1718
package_data={'': ['lib/*']},
1819
include_package_data=True,
1920
keywords=['webp', 'converter', 'image'],
21+
install_requires=["uuid", "base64"],
2022
license='MIT',
2123
classifiers=[
2224
'Development Status :: 5 - Production/Stable',
2325
'Programming Language :: Python',
2426
'Programming Language :: Python :: 3.6',
2527
'Programming Language :: Python :: 3.7',
2628
'Programming Language :: Python :: 3.8',
27-
'Programming Language :: Python :: Implementation :: CPython',
28-
'Programming Language :: Python :: Implementation :: PyPy',
2929
'License :: OSI Approved :: MIT License',
30-
3130
],
3231

3332
)

test.py

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
from os import sep
22
from pathlib import Path
3-
from webptools import (cwebp, dwebp, gifwebp, webpmux_add, webpmux_extract,
4-
webpmux_strip, webpmux_animate, webpmux_getframe)
3+
import base64
4+
from webptools import cwebp, dwebp, gifwebp, webpmux_add, webpmux_extract
5+
from webptools import webpmux_strip, webpmux_animate, webpmux_getframe
6+
from webptools import base64str2webp_base64str, grant_permission
57

8+
grant_permission()
69
# *************** cwebp ************** #
710

811
# pass input_image(.jpeg,.pnp .....) path ,
@@ -11,24 +14,24 @@
1114
print(cwebp(
1215
f"{str(Path(__file__).parent.parent)}{sep}extras{sep}python_logo.jpg",
1316
f"{str(Path(__file__).parent.parent)}{sep}extras{sep}python_logo.webp",
14-
"-q 80"))
17+
"-q 80",logging="-v"))
1518

1619
# ******* dwebp ************ #
1720

1821
# pass input_image(.webp image) path ,output_image(.jpeg,.pnp .....)
19-
print(dwebp(
20-
f"{str(Path(__file__).parent.parent)}{sep}extras{sep}python_logo.webp",
21-
f"{str(Path(__file__).parent.parent)}{sep}extras{sep}python_logo.jpg",
22-
"-o"))
22+
# print(dwebp(
23+
# f"{str(Path(__file__).parent.parent)}{sep}extras{sep}python_logo.webp",
24+
# f"{str(Path(__file__).parent.parent)}{sep}extras{sep}python_logo.jpg",
25+
# "-o"))
2326

2427
# ***************** gif2webp *********************** #
2528

2629
# pass input_image(.gif) path ,output_image(give path where to save and
2730
# image file name with .webp file type extension)
28-
print(gifwebp(
29-
f"{str(Path(__file__).parent.parent)}{sep}extras{sep}linux_logo.gif",
30-
f"{str(Path(__file__).parent.parent)}{sep}extras{sep}linux_logo.webp",
31-
"-q 80"))
31+
# print(gifwebp(
32+
# f"{str(Path(__file__).parent.parent)}{sep}extras{sep}linux_logo.gif",
33+
# f"{str(Path(__file__).parent.parent)}{sep}extras{sep}linux_logo.webp",
34+
# "-q 80"))
3235

3336
# *************** webpmux ********************* #
3437

@@ -40,7 +43,7 @@
4043
# for ICC: icc
4144
# for XMP metadata: xmp
4245
# for EXIF metadata: exif
43-
print(webpmux_add("in.webp", "icc_container.webp", "image_profile.icc", "icc"))
46+
# print(webpmux_add("in.webp", "icc_container.webp", "image_profile.icc", "icc"))
4447

4548
# %%%%%%%%%%%%%%%% Extract ICC profile,XMP metadata and EXIF metadata
4649

@@ -50,7 +53,7 @@
5053
# for ICC: icc
5154
# for XMP metadata: xmp
5255
# for EXIF metadata: exif
53-
print(webpmux_extract("anim_container.webp", "image_profile.icc", "icc"))
56+
# print(webpmux_extract("anim_container.webp", "image_profile.icc", "icc"))
5457

5558
# %%%%%%%%%%%%%%%%%%%%% Strip ICC profile,XMP metadata and EXIF metadata
5659

@@ -60,7 +63,7 @@
6063
# for ICC: icc
6164
# for XMP metadata: xmp
6265
# for EXIF metadata: exif
63-
print(webpmux_strip("icc_container.webp", "without_icc.webp", "icc"))
66+
# print(webpmux_strip("icc_container.webp", "without_icc.webp", "icc"))
6467

6568
# %%%%%%%%%%%%%%%%%%% Create an animated WebP file from Webp images
6669

@@ -104,11 +107,22 @@
104107
# the Alpha, Red, Green and Blue component values respectively
105108
# [Default: 255,255,255,255].
106109

107-
input = ["./frames/tmp-0.webp +100", "./frames/tmp-1.webp +100",
108-
"./frames/tmp-2.webp +100"]
109-
print(webpmux_animate(input, "anim_container.webp", "10", "255,255,255,255"))
110+
# input = ["./frames/tmp-0.webp +100", "./frames/tmp-1.webp +100",
111+
# "./frames/tmp-2.webp +100"]
112+
# print(webpmux_animate(input, "anim_container.webp", "10", "255,255,255,255"))
110113

111114
# %%%%%%%%%%%%%%%%%%%%% Get the a frame from an animated WebP file
112115

113116
# pass input_image(.webp image) path ,output_image and frame number
114-
print(webpmux_getframe("anim_container.webp", "frame_2.webp", "2"))
117+
# print(webpmux_getframe("anim_container.webp", "frame_2.webp", "2"))
118+
119+
# *************** base64 to webp base64 ************** #
120+
121+
# with open(
122+
# r"C:\Users\user\python_logo.jpg",
123+
# "rb") as image_file:
124+
# encoded_string = base64.b64encode(image_file.read())
125+
# base64_image = encoded_string.decode('utf-8')
126+
#
127+
# print(str2webpstr(base64str=base64_image, image_type="jpg",
128+
# option="-q 80", logging="-v"))

0 commit comments

Comments
 (0)