From 3a5cf20b03ce37da3e718c162460d19081e1173c Mon Sep 17 00:00:00 2001 From: Gabriel Almir Date: Mon, 11 Jan 2021 14:10:04 -0300 Subject: [PATCH] Remove old comment about the lazy clamp function --- .../config/GIMP/2.10/plug-ins/plugin-heal-selection.py | 9 +++++++-- .../GIMP/2.10/plug-ins/plugin-heal-transparency.py | 1 - .../config/GIMP/2.10/plug-ins/plugin-map-style.py | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.var/app/org.gimp.GIMP/config/GIMP/2.10/plug-ins/plugin-heal-selection.py b/.var/app/org.gimp.GIMP/config/GIMP/2.10/plug-ins/plugin-heal-selection.py index 3a09e7b..0396c9a 100755 --- a/.var/app/org.gimp.GIMP/config/GIMP/2.10/plug-ins/plugin-heal-selection.py +++ b/.var/app/org.gimp.GIMP/config/GIMP/2.10/plug-ins/plugin-heal-selection.py @@ -55,6 +55,7 @@ def heal_selection(timg, tdrawable, samplingRadiusParam=50, directionParam=0, or # !!! The drawable can be a mask (grayscale channel), don't restrict to layer. work_drawable = pdb.gimp_image_get_active_drawable(tempImage) + if not work_drawable: raise RuntimeError, "Failed get active drawable" @@ -84,10 +85,12 @@ def heal_selection(timg, tdrawable, samplingRadiusParam=50, directionParam=0, or # crop the temp image to size of selection to save memory and for directional healing!! frisketBounds = grownSelection.mask_bounds + frisketLowerLeftX = frisketBounds[0] frisketLowerLeftY = frisketBounds[1] frisketUpperRightX = frisketBounds[2] frisketUpperRightY = frisketBounds[3] + targetLowerLeftX = targetBounds[0] targetLowerLeftY = targetBounds[1] targetUpperRightX = targetBounds[2] @@ -111,6 +114,7 @@ def heal_selection(timg, tdrawable, samplingRadiusParam=50, directionParam=0, or # X newWidth, newHeight, newLLX, newLLY = ( targetUpperRightX-targetLowerLeftX, frisketHeight, targetLowerLeftX, frisketLowerLeftY ) + # Restrict crop to image size (condition of gimp_image_crop) eg when off edge of image newWidth = min(pdb.gimp_image_width(tempImage) - newLLX, newWidth) newHeight = min(pdb.gimp_image_height(tempImage) - newLLY, newHeight) @@ -122,13 +126,13 @@ def heal_selection(timg, tdrawable, samplingRadiusParam=50, directionParam=0, or if not orderParam : useBorder = 1 # User wants NO order, ie random filling elif orderParam == 1 : # Inward to corpus. 2,3,4 - useBorder = directionParam+2 # !!! Offset by 2 to get past the original two boolean values + useBorder = directionParam + 2 # !!! Offset by 2 to get past the original two boolean values else: # Outward from image center. # 5+0=5 outward concentric # 5+1=6 outward from sides # 5+2=7 outward above and below - useBorder = directionParam+5 + useBorder = directionParam + 5 # Note that the old resynthesizer required an inverted selection !! @@ -138,6 +142,7 @@ def heal_selection(timg, tdrawable, samplingRadiusParam=50, directionParam=0, or gimp.displays_flush() except RuntimeError: # thrown if non-interactive pass + from time import sleep sleep(2) diff --git a/.var/app/org.gimp.GIMP/config/GIMP/2.10/plug-ins/plugin-heal-transparency.py b/.var/app/org.gimp.GIMP/config/GIMP/2.10/plug-ins/plugin-heal-transparency.py index 91c5021..f489bb1 100755 --- a/.var/app/org.gimp.GIMP/config/GIMP/2.10/plug-ins/plugin-heal-transparency.py +++ b/.var/app/org.gimp.GIMP/config/GIMP/2.10/plug-ins/plugin-heal-transparency.py @@ -31,7 +31,6 @@ gettext.install("resynthesizer", gimp.locale_directory, unicode=True) def heal_transparency(timg, tdrawable, samplingRadiusParam=50, orderParam=2): - # precondition should be enforced by Gimp according to image modes allowed. if not pdb.gimp_drawable_has_alpha(tdrawable): pdb.gimp_message("The active layer has no alpha channel to heal.") diff --git a/.var/app/org.gimp.GIMP/config/GIMP/2.10/plug-ins/plugin-map-style.py b/.var/app/org.gimp.GIMP/config/GIMP/2.10/plug-ins/plugin-map-style.py index e72071d..850b906 100755 --- a/.var/app/org.gimp.GIMP/config/GIMP/2.10/plug-ins/plugin-map-style.py +++ b/.var/app/org.gimp.GIMP/config/GIMP/2.10/plug-ins/plugin-map-style.py @@ -146,6 +146,7 @@ def make_grayscale_map(image, drawable): original_selection = pdb.gimp_selection_save(image) pdb.gimp_selection_all(image) # copy requires selection pdb.gimp_edit_copy(drawable) + if original_selection: pdb.gimp_selection_load(original_selection) # restore selection in image pdb.gimp_image_remove_channel( @@ -199,6 +200,7 @@ def copy_selection_to_image(drawable): layer_copy = pdb.gimp_image_get_active_layer(image_copy) # In earlier version, futzed with selection to deal with transparencey display_debug_image(image_copy) + return image_copy, layer_copy @@ -227,7 +229,7 @@ def synchronize_contrast(drawable, source_drawable, percent_transfer): # 2.5 is from experimentation with gimp_brightness_contrast which seems linear in its effect. contrast_control = (mean - source_mean) * 2.5 * (1 - (percent_transfer / 100)) - # clamp to valid range (above formula is lazy, ad hoc) + # clamp to valid range contrast_control = max(min(contrast_control, 127), -127) pdb.gimp_brightness_contrast(source_drawable, 0, contrast_control)