def apply_watermark(file_path, args): # Process an individual file image = Watermark(file_path) kwargs = {} if args.scale: kwargs['scale'] = float(args.scale) if args.align: kwargs['align'] = args.align if args.valign: kwargs['valign'] = args.valign if args.opacity: kwargs['opacity'] = (int(args.opacity),) if args.color: l_colors = args.color.split(",") if len(l_colors) == 3: if l_colors[0][0] == "(": l_colors[0] = l_colors[0][1:] if l_colors[2][-1] == ")": l_colors[2] = l_colors[2][1:-1] kwargs['color'] = (int(l_colors[0]), int(l_colors[1]), int(l_colors[2]) ) if args.margin: l_margins = args.margin.split("x") if len(l_margins) == 2: kwargs['margin'] = (int(l_margins[0]), int(l_margins[1])) image.apply_text(args.text, tile=args.tile, **kwargs) output_file = os.path.join(args.output_dir, os.path.basename(file_path)) print("Saving " + output_file) image.save(output_file)
def apply_watermark(file_path, args): # Process an individual file image = Watermark(file_path) image.apply_text(args.text, tile=args.tile) output_file = os.path.join(args.output_dir, os.path.basename(file_path)) print("Saving " + output_file) image.save(output_file)