Skip to content

Commit df98808

Browse files
committed
0.20210310: layers model
0 parents  commit df98808

File tree

7 files changed

+145
-0
lines changed

7 files changed

+145
-0
lines changed

LICENSE

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Public Domain Mark 1.0
2+
No Copyright
3+
4+
This work has been identified as being free of known restrictions
5+
under copyright law, including all related and neighboring rights.
6+
7+
You can copy, modify, distribute and perform the work, even for
8+
commercial purposes, all without asking permission. See Other
9+
Information below.
10+
11+
Other Information
12+
13+
The work may not be free of known copyright restrictions in all
14+
jurisdictions.
15+
16+
Persons may have other rights in or related to the work, such as
17+
patent or trademark rights, and others may have rights in how the
18+
work is used, such as publicity or privacy rights.
19+
20+
In some jurisdictions moral rights of the author may persist beyond
21+
the term of copyright. These rights may include the right to be
22+
identified as the author and the right to object to derogatory
23+
treatments.
24+
25+
Unless expressly stated otherwise, the person who identified the work
26+
makes no warranties about the work, and disclaims liability for all
27+
uses of the work, to the fullest extent permitted by applicable law.
28+
29+
When using or citing the work, you should not imply endorsement by
30+
the author or the person who identified the work.

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Gimp Resize RIS Plugin
2+
3+
GIMP plugin for resize images using Reverse Interpolate Scale (RIS)
4+
5+
This plugin is designed to resize images according to the RIS rules,
6+
according to which an enlarged image can be returned
7+
to the original image by simple averaging.
8+
9+
![RIS resize](images/ris-resize-dialog.png)
10+
11+
Hints:
12+
* The plugin is located in : Menu -> Image -> Transform -> Resize RIS
13+
* Currently it all colormode images
14+
15+
Compare:
16+
17+
Origin:
18+
![origin](images/means-orig.png)
19+
GIMP (cubic):
20+
![](images/means-gimp-cubic-x4.png)
21+
RIS resize (cubic):
22+
![RIS resize](images/means-ris-resize-x4.png)
23+
24+
25+
## Install:
26+
27+
Copy `resize-ris.py` in:
28+
* Linux: `~/.gimp-2.8/plug-ins`
29+
* Windows: `C:\Program Files\GIMP 2\lib\gimp\2.0\plug-ins`
30+
31+
----
32+
33+
Homepage: https://github.com/ImageProcessing-ElectronicPublications/gimp-plugin-resize-ris
34+
35+
2021

images/means-gimp-cubic-x4.png

437 KB
Loading

images/means-orig.png

60 KB
Loading

images/means-ris-resize-x4.png

636 KB
Loading

images/ris-resize-dialog.png

17.4 KB
Loading

resize-ris.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
###
2+
### Gimp-Python - allows the writing of Gimp plugins in Python.
3+
### Public Domain Mark 1.0
4+
### No Copyright
5+
###
6+
7+
from gimpfu import *
8+
9+
PROC_NAME = 'python-fu-resize-ris'
10+
PROC_LABEL = 'Resize RIS'
11+
PROC_AUTHOR = 'zvezdochiot <[email protected]>'
12+
PROC_DATE = '2021-03-10'
13+
14+
def ris(image, drawable, width, height, interpol):
15+
image.undo_group_start()
16+
orig_width = pdb.gimp_image_width(image)
17+
orig_height = pdb.gimp_image_height(image)
18+
19+
copy_image = pdb.gimp_image_duplicate(image)
20+
copy_drawable = pdb.gimp_image_get_active_drawable(copy_image)
21+
blur_image = pdb.gimp_image_duplicate(image)
22+
blur_drawable = pdb.gimp_image_get_active_drawable(blur_image)
23+
24+
pdb.gimp_context_set_interpolation(interpol)
25+
pdb.gimp_image_scale(blur_image, width, height)
26+
pdb.gimp_image_scale(blur_image, orig_width, orig_height)
27+
28+
blur_layer = pdb.gimp_layer_new_from_visible(blur_image, image, "ResizeBlur")
29+
pdb.gimp_image_insert_layer(image, blur_layer, None, -1)
30+
pdb.gimp_image_set_active_layer(image, blur_layer)
31+
blur_layer.mode = SUBTRACT_MODE
32+
33+
copy_layer = pdb.gimp_layer_new_from_visible(copy_image, image, "CopyOrig")
34+
pdb.gimp_image_insert_layer(image, copy_layer, None, -1)
35+
pdb.gimp_image_set_active_layer(image, copy_layer)
36+
copy_layer.mode = ADDITION_MODE
37+
38+
blur_layer2 = pdb.gimp_layer_new_from_visible(blur_image, image, "ResizeBlur2")
39+
pdb.gimp_image_insert_layer(image, blur_layer2, None, -1)
40+
pdb.gimp_image_set_active_layer(image, blur_layer2)
41+
blur_layer2.mode = SUBTRACT_MODE
42+
43+
copy_layer2 = pdb.gimp_layer_new_from_visible(copy_image, image, "CopyOrig2")
44+
pdb.gimp_image_insert_layer(image, copy_layer2, None, -1)
45+
pdb.gimp_image_set_active_layer(image, copy_layer2)
46+
copy_layer2.mode = ADDITION_MODE
47+
48+
#pdb.gimp_image_merge_down(image, blur_layer, 0)
49+
50+
pdb.gimp_image_delete(copy_image)
51+
pdb.gimp_image_delete(blur_image)
52+
53+
pdb.gimp_image_scale(image, width, height)
54+
55+
pdb.gimp_displays_flush()
56+
image.undo_group_end()
57+
58+
register(
59+
PROC_NAME,
60+
PROC_LABEL,
61+
"",
62+
PROC_AUTHOR,
63+
PROC_AUTHOR,
64+
PROC_DATE,
65+
PROC_LABEL,
66+
"*",
67+
[
68+
(PF_IMAGE, "image", "_Image", None),
69+
(PF_LAYER, "drawable", "_Drawable", None),
70+
(PF_INT, "width", "Width", 512),
71+
(PF_INT, "height", "Height", 512),
72+
(PF_OPTION, "interp", "Method", 2, ["None","Linear","Cubic","Lanczos"]),
73+
#(PF_FLOAT, "mult", "Multiply", 1),
74+
],
75+
[],
76+
ris,
77+
menu="<Image>/Image/Transform",
78+
domain=("gimp20-python", gimp.locale_directory))
79+
80+
main()

0 commit comments

Comments
 (0)