Gimp-Forum.net
python plug-in drop shadow - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions)
+---- Thread: python plug-in drop shadow (/Thread-python-plug-in-drop-shadow)



python plug-in drop shadow - marekGP - 02-05-2025

Hello, I am trying to create plugin with drop shadow functionality.
The shadow layer is created, but it behaves as invisible - I can copy the content and put it in other layer, but everything in the shadow layer stays invisible - here is the code:
Code:
#!/usr/bin/env python

from gimpfu import *

def gp_shadow(image, drawable):

   offsetx = 5  
   offsety = 5  
   blurradius = 8
   opacity = 1.0  
   color = gimpcolor.RGB(255,0,0)
   allowresizing = FALSE
   
   pdb.script_fu_drop_shadow(image, drawable, offsetx, offsety, blurradius, color, opacity, allowresizing)
   

register(
   "python-fu-gp_shadow",
   "Drop multipe shadows for GP artwork titles",
   "Drop multipe shadows for GP artwork titles",
   "MK", "MK", "2025",
   "GP shadow",
   "", # type of image it works on (*, RGB, RGB*, RGBA, GRAY etc...)
   [
       # basic parameters are: (UI_ELEMENT, "variable", "label", Default)
       (PF_IMAGE, "image", "takes current image", None),
       (PF_DRAWABLE, "drawable", "Input layer", None)
       # PF_SLIDER, SPINNER have an extra tuple (min, max, step)
       # PF_RADIO has an extra tuples within a tuple:
       # eg. (("radio_label", "radio_value), ...) for as many radio buttons
       # PF_OPTION has an extra tuple containing options in drop-down list
       # eg. ("opt1", "opt2", ...) for as many options
       # see ui_examples_1.py and ui_examples_2.py for live examples
   ],
   [],
   gp_shadow, menu="<Image>/Filters/Light and Shadow")  # second item is menu location

main()

Can you find a problem?
(GIMP 2.10.36, Win10)


RE: python plug-in drop shadow - teapot - 02-05-2025

(6 hours ago)marekGP Wrote: Hello, I am trying to create plugin with drop shadow functionality.
The shadow layer is created, but it behaves as invisible - I can copy the content and put it in other layer, but everything in the shadow layer stays invisible - here is the code:
Code:
#!/usr/bin/env python

from gimpfu import *

def gp_shadow(image, drawable):

   offsetx = 5  
   offsety = 5  
   blurradius = 8
   opacity = 1.0  
   color = gimpcolor.RGB(255,0,0)
   allowresizing = FALSE
   
   pdb.script_fu_drop_shadow(image, drawable, offsetx, offsety, blurradius, color, opacity, allowresizing)
   

register(
   "python-fu-gp_shadow",
   "Drop multipe shadows for GP artwork titles",
   "Drop multipe shadows for GP artwork titles",
   "MK", "MK", "2025",
   "GP shadow",
   "", # type of image it works on (*, RGB, RGB*, RGBA, GRAY etc...)
   [
       # basic parameters are: (UI_ELEMENT, "variable", "label", Default)
       (PF_IMAGE, "image", "takes current image", None),
       (PF_DRAWABLE, "drawable", "Input layer", None)
       # PF_SLIDER, SPINNER have an extra tuple (min, max, step)
       # PF_RADIO has an extra tuples within a tuple:
       # eg. (("radio_label", "radio_value), ...) for as many radio buttons
       # PF_OPTION has an extra tuple containing options in drop-down list
       # eg. ("opt1", "opt2", ...) for as many options
       # see ui_examples_1.py and ui_examples_2.py for live examples
   ],
   [],
   gp_shadow, menu="<Image>/Filters/Light and Shadow")  # second item is menu location

main()

Can you find a problem?
(GIMP 2.10.36, Win10)

Set the opacity higher.

pdb.script_fu_drop_shadow creates a 'Drop Shadow' layer and sets the layer opacity to the value you pass, in your example opacity = 1.0.  If you make the shadow layer active in the layers dialogue you should see the opacity of your shadow layer is 1.0.  This is very low as layer opacity goes from 0 (transparent) to 100 (opaque).


RE: python plug-in drop shadow - marekGP - 02-05-2025

That's it, thank you very much!