| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 
 | from watermarker.marker import  add_markimport os
 import shutil
 
 
 def mark(file, outdir, mark = "火苗999℃"):
 add_mark(file = file, out = outdir, mark = mark
 
 , opacity=0.1, angle=30, space=300, size=20)
 return
 
 
 def mark_dir2(root, out):
 if not os.path.exists(out):
 
 os.mkdir(out)
 files = os.listdir(root)
 for fname in files:
 fpath = root + "\\" + fname
 if os.path.isfile(fpath):
 file_name, file_extension = os.path.splitext(fpath)
 if ".gif" != file_extension:
 mark(fpath, out)
 else:
 shutil.copy(fpath, out + "\\" + fname)
 elif os.path.isdir(fpath):
 subdir = root + "\\" + fname
 subout =  out + "\\" + fname
 mark_dir2(subdir, subout)
 else :
 print("no defined {}!".format(fpath))
 return
 
 if __name__ == '__main__' :
 src = 'H:\\myblog\\blog\\source\\picture\\src'
 out = 'H:\\myblog\\blog\\source\\picture\\mark'
 mark_dir2(src, out)
 
 |