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)
예제 #2
0
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)
예제 #3
0
파일: bot.py 프로젝트: aahnik/telewater
async def watermarker(event):

    if not (event.gif or event.photo or event.video):
        await event.respond("File not supported.")
        return

    org_file = stamp(await event.download_media(""), user=str(event.sender_id))

    file = File(org_file)
    wtm = Watermark(File("image.png"), pos=conf.config.position)

    out_file = apply_watermark(
        file, wtm, frame_rate=conf.config.frame_rate, preset=conf.config.preset
    )
    await event.client.send_file(event.sender_id, out_file)
    cleanup(org_file, out_file)
예제 #4
0
    def __init__(self, parent, root, dir_watermark):
        self.parent = parent
        self.root = root
        self.dir_w = dir_watermark
        self.print_window = Toplevel(self.root)
        self.print_window.withdraw()

        self.check_window = Toplevel(self.root)
        self.check_window.withdraw()

        self.build_check_window()

        self.ephew = Image.open(dir_watermark + "/watermark.png")

        i = 0
        for f in os.listdir(self.dir_w):
            nom = f.split(".")[0]
            self.watermarks.append(
                Watermark(self.print_window, self, self.dir_w + "/" + f, nom,
                          0, i, i))
            i = i + 1
예제 #5
0
parser = argparse.ArgumentParser(
    description='Script used to add watermark and reverse the process.')
parser.add_argument('--image',
                    '-i',
                    help='Path to the input image.',
                    default='sample/sample_image.png')
parser.add_argument('--text',
                    '-t',
                    help='Text for watermark.',
                    default='Monkey D Luffy')
process_type = parser.add_mutually_exclusive_group(required=False)
process_type.add_argument('--add', dest='add_watermark', action='store_true')
process_type.add_argument('--remove',
                          dest='add_watermark',
                          action='store_false')
parser.set_defaults(add_watermark=True)

args = parser.parse_args()

# Default parameters for Watermark class are:
#     text='Sample watermark'
#     alpha=0.3
#     color=(0, 0, 255)
#     path_to_save='./result'

watermark = Watermark(text=args.text)
if args.add_watermark:
    watermarked_image = watermark.add_watermark(args.image)
else:
    un_watermarked_image = watermark.remove_watermark(args.image)
예제 #6
0
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 22 14:25:10 2020

@author: mhayt
"""

from watermark import Watermark

Watermark('super_merge.pdf', 'wtr.pdf', 'import_test.pdf')


예제 #7
0
from watermark import Watermark

# params = {
#     'logoPath': 'logoCircle.png',
#     'imagePath': 'test.jpg',
#     'output': 'output.jpg',
#     'title': 'Titulo de Prueba',
#     'style': 3
# }

watermark = Watermark()
# INICIAR PARAMETROS METODO 1
# watermark.setParams(params)
# INICIAR PARAMETROS METODO 2
watermark.setParamsLineal(logoPath='sources/logoCircle.png', imagePath='sources/test.jpg', output='output.jpg', title='OVI Ingemmet', style=3)
watermark.makeWatermark()
watermark.showImage()