[gimp] script-fu: fix #6741 Round Corners script fails to work on layer masks



commit ed35579861e57ffd013411f7535b25c9f79d32a3
Author: Jacob Boerema <jgboerema gmail com>
Date:   Sat Apr 24 12:41:41 2021 -0400

    script-fu: fix #6741 Round Corners script fails to work on layer masks
    
    The round corners script was assuming that the drawable always
    was a layer, which is incorrect when a layer mask is selected.
    
    We fix this by always requesting the active layer instead of
    active drawable.
    
    We also enable this script for RGB and GRAY with alpha
    channel. Although it might not always make sense to
    use this script when an alpha channel is present, there
    can be use cases where it is perfectly fine.
    
    So let the designer decide if this script is suited or not
    instead of GIMP making that judgement.

 plug-ins/script-fu/scripts/round-corners.scm | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/plug-ins/script-fu/scripts/round-corners.scm b/plug-ins/script-fu/scripts/round-corners.scm
index 3116ec2ba9..a5224e5c32 100644
--- a/plug-ins/script-fu/scripts/round-corners.scm
+++ b/plug-ins/script-fu/scripts/round-corners.scm
@@ -51,12 +51,14 @@
          (diam (* 2 radius))
          (width (car (gimp-image-get-width img)))
          (height (car (gimp-image-get-height img)))
-         (type (car (gimp-drawable-type-with-alpha drawable)))
          (image (cond ((= work-on-copy TRUE)
                        (car (gimp-image-duplicate img)))
                       ((= work-on-copy FALSE)
                        img)))
-         (pic-layer (car (gimp-image-get-active-drawable image))))
+         ; active drawable is not necessarily the active layer
+         (pic-layer (car (gimp-image-get-active-layer image)))
+         (type (car (gimp-drawable-type-with-alpha pic-layer)))
+        )
 
   (gimp-context-push)
   (gimp-context-set-defaults)
@@ -131,7 +133,7 @@
   "Sven Neumann <sven gimp org>"
   "Sven Neumann"
   "1999/12/21"
-  "RGB GRAY"
+  "RGB* GRAY*"
   SF-IMAGE      "Image"            0
   SF-DRAWABLE   "Drawable"         0
   SF-ADJUSTMENT _"Edge radius"     '(15 0 4096 1 10 0 1)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]