filestools目前包含四个工具包,分别是树形目录显示、文件差异比较、图片加水印和curl请求转python代码。
1 |
pip install filestools |
1 |
pip show filestools |
Name: filestools
Version: 0.1.3
Summary: 仿Linux的tree命令、文件差异比较工具、图片加水印和curl请求转python代码。
Home-page: UNKNOWN
Author: 小小明
License: GPLv3
Requires: cchardet, Pillow, pyperclip, rich
Required-by:
1 |
from watermarker.marker import add_mark |
1 2 3 4 5 6 7 8 |
add_mark(file="demo.jpg", out="out", mark="空空star", color="white", size=30, opacity=0.3, angle=45, space=75) |
3.效果
默认#8B8B1B
1 2 |
# 通过RGB值设置颜色-红色 color = (255, 0, 0) |
1 2 |
# 通过RGB值设置颜色-红色 color = (255, 0, 0) |
1 2 |
# 通过十六进制设置颜色-绿色 color = '#6FE000' |
默认30
1 |
# 左size=30 |
1 |
# 右size=50 |
默认0.15
1 |
# 左opacity=0.3 |
1 |
# 右opacity=0.6 |
默认75个空格
1 |
# 左space=75 |
1 |
# 右space=100 |
默认30度
1 |
# 左angle=45 |
1 |
# 右angle=-45 |
查看marker.py,可以发现,这个水印处理就是基于PIL库做的。也能看到水印字体的默认值。
从以下代码中,也可以看到相关参数的默认值。
1 2 3 4 5 6 7 8 |
def add_mark(file, mark, out="output", color="#8B8B1B", size=30, opacity=0.15, space=75, angle=30): if os.path.isdir(file): names = os.listdir(file) for name in names: image_file = os.path.join(file, name) add_mark2file(image_file, mark, out, color, size, opacity, space, angle) else: add_mark2file(file, mark, out, color, size, opacity, space, angle) |