-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresize-ris.py
executable file
·84 lines (68 loc) · 2.71 KB
/
resize-ris.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
###
### Gimp-Python - allows the writing of Gimp plugins in Python.
### Public Domain Mark 1.0
### No Copyright
###
from gimpfu import *
PROC_NAME = 'python-fu-resize-ris'
PROC_LABEL = 'Resize RIS'
PROC_AUTHOR = 'zvezdochiot <[email protected]>'
PROC_DATE = '2021-03-13'
def ris(image, drawable, width, height, interpol):
image.undo_group_start()
orig_width = pdb.gimp_image_width(image)
orig_height = pdb.gimp_image_height(image)
image_copy = pdb.gimp_image_duplicate(image)
drawable_copy = pdb.gimp_image_get_active_drawable(image_copy)
image_blur = pdb.gimp_image_duplicate(image)
drawable_blur = pdb.gimp_image_get_active_drawable(image_blur)
pdb.gimp_context_set_interpolation(interpol)
pdb.gimp_image_scale(image_blur, width, height)
pdb.gimp_image_scale(image_blur, orig_width, orig_height)
layer_blur = pdb.gimp_layer_new_from_visible(image_blur, image, "ResizeBlur")
pdb.gimp_image_insert_layer(image, layer_blur, None, -1)
pdb.gimp_image_set_active_layer(image, layer_blur)
layer_copy = pdb.gimp_layer_new_from_visible(image_copy, image, "CopyOrig")
pdb.gimp_image_insert_layer(image, layer_copy, None, -1)
pdb.gimp_image_set_active_layer(image, layer_copy)
layer_copy.mode = SUBTRACT_MODE
layer_sub = pdb.gimp_image_merge_down(image, layer_copy, 0)
layer_sub.name = "RIS_SUBTRACT"
layer_sub.mode = SUBTRACT_MODE
layer_copy = pdb.gimp_layer_new_from_visible(image_copy, image, "CopyOrig")
pdb.gimp_image_insert_layer(image, layer_copy, None, -1)
pdb.gimp_image_set_active_layer(image, layer_copy)
layer_blur = pdb.gimp_layer_new_from_visible(image_blur, image, "ResizeBlur")
pdb.gimp_image_insert_layer(image, layer_blur, None, -1)
pdb.gimp_image_set_active_layer(image, layer_blur)
layer_blur.mode = SUBTRACT_MODE
layer_plus = pdb.gimp_image_merge_down(image, layer_blur, 0)
layer_plus.name = "RIS_ADDITION"
layer_plus.mode = ADDITION_MODE
pdb.gimp_image_delete(image_copy)
pdb.gimp_image_delete(image_blur)
pdb.gimp_image_scale(image, width, height)
pdb.gimp_displays_flush()
image.undo_group_end()
register(
PROC_NAME,
PROC_LABEL,
"",
PROC_AUTHOR,
PROC_AUTHOR,
PROC_DATE,
PROC_LABEL,
"*",
[
(PF_IMAGE, "image", "_Image", None),
(PF_LAYER, "drawable", "_Drawable", None),
(PF_INT, "width", "Width", 512),
(PF_INT, "height", "Height", 512),
(PF_OPTION, "interp", "Method", 2, ["None","Linear","Cubic","Lanczos"]),
#(PF_FLOAT, "mult", "Multiply", 1),
],
[],
ris,
menu="<Image>/Image/Transform",
domain=("gimp20-python", gimp.locale_directory))
main()