pip install filestools -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
from watermarker.marker import add_mark
import os
import cv2
import winreg
def read_directory(directory_name, b):
# this loop is for read each image in this foder,directory_name is the foder name with images.
for filename in os.listdir(directory_name):
print(filename)
add_mark(file=directory_name + '\\' + str(filename), out=get_desktop() + '\ Watermarked ',
mark=b, opacity=0.2, angle=30, space=30)
def get_desktop():
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders')
return winreg.QueryValueEx(key, "Desktop")[0]
if __name__ == '__main__':
a = input(' Enter full picture folder path :')
b = input(' Watermark text :')
read_directory(a, b)
About add_mark() function , They are as follows 8 Parameters :
file: Original photos ;
mark: What characters are used as watermarks ;
out: Location saved after adding watermark ;
color: The color of the watermark font , Default color #8B8B1B;
size: Watermark font size , Default 50;
opacity: Transparency of watermark font , Default 0.15;
space: Interval between watermark Fonts , Default 75 A space ;
angle: Rotation angle of watermark font , Default 30 degree ;