posted on 2023-05-21 16:33 read(1214) comment(0) like(19) collect(3)
Hello everyone, I am Kongkong star. In this article, I will share with you how to add full-image watermarks to pictures through Python's filestools library .
filestools currently includes four toolkits, which are tree directory display, file difference comparison, image watermarking and curl request to python code.
pip install filestools
pip show filestools
Name: filestools
Version: 0.1.3
Summary: Linux-like tree command, file difference comparison tool, image watermarking and curl request to python code.
Home-page: UNKNOWN
Author: Xiaoxiaoming
License: GPLv3
Requires: cchardet, Pillow , pyperclip, rich
Required-by:
from watermarker.marker import add_mark
add_mark(file="demo.jpg",
out="out",
mark="空空star",
color="white",
size=30,
opacity=0.3,
angle=45,
space=75)
Default #8B8B1B
# 通过名称设置颜色-黄色
color = 'yellow'
# 通过RGB值设置颜色-红色
color = (255, 0, 0)
# 通过十六进制设置颜色-绿色
color = '#6FE000'
Default 30
# 左
size=30
# 右
size=50
default 0.15
# 左
opacity=0.3
# 右
opacity=0.6
Default 75 spaces
# 左
space=75
# 右
space=100
Default 30 degrees
# 左
angle=45
# 右
angle=-45
Looking at marker.py, you can find that this watermark processing is based on the PIL library. You can also see the default value of the watermark font.
From the following code, you can also see the default values of the relevant parameters.
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)
Author:cindy
link:http://www.pythonblackhole.com/blog/article/25285/7acf75ff745ee2dec589/
source:python black hole net
Please indicate the source for any form of reprinting. If any infringement is discovered, it will be held legally responsible.
name:
Comment content: (supports up to 255 characters)
Copyright © 2018-2021 python black hole network All Rights Reserved All rights reserved, and all rights reserved.京ICP备18063182号-7
For complaints and reports, and advertising cooperation, please contact vgs_info@163.com or QQ3083709327
Disclaimer: All articles on the website are uploaded by users and are only for readers' learning and communication use, and commercial use is prohibited. If the article involves pornography, reactionary, infringement and other illegal information, please report it to us and we will delete it immediately after verification!