|
| 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