-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_watermark_text.py
68 lines (57 loc) · 2.02 KB
/
add_watermark_text.py
1
2
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
# -*- coding: <utf-8> -*-
# Author: Ethan Blackwelder
# Copyright 2013 Ethan Blackwelder
# License: MIT (http://eib.mit-license.org/)
# Version 0.1
# GIMP compatibilty ???
# PyGIMP plugin to add watermark/copyright text
from gimpfu import *
import getpass
SIZE_IN_PIXELS = 0
SIZE_IN_POINTS = 1
def add_watermark_text(img, text, points, antialias, letter_spacing, fontname, color):
text = u'\xa9' + " " + text
x = 0
y = 0
border = -1
#undo-start
pdb.gimp_context_push();
pdb.gimp_image_undo_group_start(img);
#create text-layer (adds it to the image)
text_layer = pdb.gimp_text_fontname(img, None, x, y, text, border, antialias, points, SIZE_IN_POINTS, fontname)
layer_margins = 5
x = layer_margins #left
y = img.height - text_layer.height - layer_margins #bottom
pdb.gimp_text_layer_set_color(text_layer, color)
pdb.gimp_text_layer_set_text(text_layer, text)
pdb.gimp_item_set_name(text_layer, "Watermark")
pdb.gimp_layer_set_offsets(text_layer, x, y)
pdb.gimp_text_layer_set_letter_spacing(text_layer, letter_spacing)
#undo-end
pdb.gimp_image_undo_group_end(img);
pdb.gimp_context_pop();
register(
proc_name=("python-fu-add-watermark-text"),
blurb=("Adds watermark text"),
help=("Adds a text layer with watermark-friendly defaults."),
author=("Ethan Blackwelder"),
copyright=("Ethan Blackwelder"),
date=("2013"),
label=("Add Watermark Text"),
imagetypes=("*"),
params=[
(PF_IMAGE, "img", "Image", None),
(PF_TEXT, "copyright", "Copyright Owner", getpass.getuser()),
(PF_INT, "points", "Size (pts)", 100),
(PF_BOOL, "antialias", "Antialias", True),
(PF_INT, "letter_spacing", "Letter Spacing", -3),
(PF_FONT, "fontname", "Font Name", "Sans"),
(PF_COLOR, "color", "Color", (255, 255, 255)),
],
results=[],
function=(add_watermark_text),
menu=("<Image>/Image"),
domain=("gimp20-python", gimp.locale_directory)
)
main()