Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Where to find an installed plugin?
#1
Python 
Hey guys,

I installed a plugin to test it but I can't find it anywhere.
I looked inside the Python-Fu menu, I didn't find it.
Also in Filters - Python-Fu, without success.

In fact I'm not even sure what the name of this plugin would be.

Could anyone reveal the location of this plugin? Please!

Below is the plugin code: 

Code:
#!/usr/bin/env python
#grow-shrink-live.py
# Creator: TT
# This should allow user to adjust grow/shrink current selection with live preview
# Open Source
from gimpfu import *
import gtk

# Global variables to store the parameters used for our effect/work to show preview or actual layer when user OK it
global_param1 = 0 #in this example it's shrinkgrow radius
global_param2 = 0   #in this example it's feather_radius
global_param3 = 10  #in this example it's iterations
global_param4 = 0   #in this example it's enhance_shadows

image = 0 #we'll set these when dialog() is called so that we can access them later
drawable = 0
has_preview = False
preview_layer = 0
#for this operation
selection_channel = 0

def apply_effect(layer): #function to do work on either preview layer or actual drawable when user clicks OK
   global image
   radius = global_param1
   feather_radius = global_param2
   pdb.gimp_image_select_item(image,CHANNEL_OP_REPLACE,selection_channel) #first we selected the original saved channel
   if radius < 0:
       pdb.gimp_selection_shrink(image,-radius)
   else:
       pdb.gimp_selection_grow(image,radius)
   pdb.gimp_selection_feather(image,feather_radius)
   #do something to it to show it's effect so that user can distinguish between selected area or not
   pdb.gimp_drawable_edit_fill(layer,FILL_FOREGROUND)

   #pdb.gimp_ellipse_select(image,image.width/2-width/2,image.height/2-height/2,width,height,CHANNEL_OP_REPLACE,TRUE,FALSE,0)
   #pdb.gimp_drawable_invert(layer,TRUE)
   #pdb.gimp_selection_none(image)
   gimp.displays_flush()

def apply_final(layer): #wrapper to apply effect on final and remove preview_layer meant to be called by on_ok_button_clicked
   global preview_layer
   #pdb.gimp_image_undo_group_start(image) #so it's undone in Ctrl+Z
   pdb.gimp_image_undo_enable(image) #so that user can undo this next step
   apply_effect(preview_layer)
   #pdb.gimp_image_undo_group_end(image)
   if has_preview:
       pdb.gimp_image_remove_channel(image,selection_channel) #so that we don't leave a saved channel laying around
       pdb.gimp_image_remove_layer(image,preview_layer)
   pdb.gimp_image_set_active_layer(image,drawable)
   pdb.gimp_context_set_foreground(save_foreground)
   gimp.displays_flush()
 
# Function to update the live preview
def update_live_preview(): #this is called everytime some parameter changes
   global global_param1, global_param2, global_param3, global_param4
   global image,drawable
   global has_preview,preview_layer #deal with preview layer
   global selection_channel #this will save our current selection
   # Apply your plugin's effect using the current parameters
   # Use global_param1 and global_param2 to access the user's inputs
   if not has_preview: #create a preview layer
       #pdb.gimp_message("Creating preview")
       preview_layer = pdb.gimp_layer_new(image,image.width,image.height,RGBA_IMAGE,"preview",70,LAYER_MODE_NORMAL)
       pdb.gimp_image_insert_layer(image,preview_layer,None,0) #insert top most so we see it
       non_empty,x1,y1,x2,y2 = pdb.gimp_selection_bounds(image)
       if non_empty == TRUE:
           pass #there's already a selection
       else:
           pdb.gimp_selection_all(image) #if there's no selection we just select the whole image and work with that  
       selection_channel = pdb.gimp_selection_save(image)
       has_preview = True #now set it true so we can deal with existing layer in later calls
   else: # already have preview layer
       pass
       #pdb.gimp_message("Removing existing and creating new Preview")
       pdb.gimp_image_remove_layer(image,preview_layer) #remove it to create a new one to work on
       preview_layer = pdb.gimp_layer_new(image,image.width,image.height,RGBA_IMAGE,"preview",50,LAYER_MODE_NORMAL)
       pdb.gimp_image_insert_layer(image,preview_layer,None,0) #insert top most so we see it
   pdb.gimp_image_set_active_layer(image,preview_layer)
   #debug message
   #pdb.gimp_message(str(global_param1)+","+str(global_param2)+","+str(global_param3)+","+str(global_param4))

   apply_effect(preview_layer)
 
   # Update the live preview layer with the modified image
 
save_foreground = 0
hilightcolor = (255,0,0)
def dialog(image_, drawable_):
   global image, drawable, save_foreground
   #save these for updates
   image = image_
   pdb.gimp_image_undo_disable(image) #for speed and also when user undo it doesn't see our preview creations/deletions
   drawable = drawable_
   save_foreground = pdb.gimp_context_get_foreground()
   pdb.gimp_context_set_foreground(hilightcolor)

   dialog = gtk.Dialog("Shrink/Grow Feather Selection Live Preview", None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
   dialog.set_default_size(600, 100)

   # Create an HBox to hold the label and slider -------------------------------------------------------------
   hbox = gtk.HBox()
   dialog.vbox.pack_start(hbox, expand=True, fill=True)

   # Create a label on the left-hand side
   label1 = gtk.Label("Shrink/Grow Radius:")
   hbox.pack_start(label1, expand=False, fill=False, padding=5)

   # Create an adjustment for the HScale (slider) with a range from 10 to 90
   adjustment1 = gtk.Adjustment(value=0, lower=-400, upper=400, step_incr=1, page_incr=0)
   param1_scale = gtk.HScale(adjustment=adjustment1)
   param1_scale.set_digits(0)  # Display only integers
   hbox.pack_start(param1_scale, expand=True, fill=True, padding=5)
   # Connect callback functions for user interaction
   param1_scale.connect("value-changed", on_param1_changed)

   # # Create an HBox to hold the label and slider -------------------------------------------------------------
   hbox2 = gtk.HBox()
   dialog.vbox.pack_start(hbox2, expand=True, fill=True)

   # Create a label on the left-hand side
   label2 = gtk.Label("Feather Radius:")
   hbox2.pack_start(label2, expand=False, fill=False, padding=5)

   # Create an adjustment for the HScale (slider) with a range from 10 to 90
   adjustment2 = gtk.Adjustment(value=0, lower=0, upper=400, step_incr=1, page_incr=0)
   param2_scale = gtk.HScale(adjustment=adjustment2)
   param2_scale.set_digits(0)  # Display only integers
   hbox2.pack_start(param2_scale, expand=True, fill=True, padding=5)
   # Connect callback functions for user interaction
   param2_scale.connect("value-changed", on_param2_changed)

   # # Create an HBox to hold the label and slider -------------------------------------------------------------
   # hbox3 = gtk.HBox()
   # dialog.vbox.pack_start(hbox3, expand=True, fill=True)

   # # Create a label on the left-hand side
   # label3 = gtk.Label("iterations:")
   # hbox3.pack_start(label3, expand=False, fill=False, padding=5)

   # # Create an adjustment for the HScale (slider) with a range from 10 to 90
   # adjustment3 = gtk.Adjustment(value=10, lower=1, upper=30, step_incr=1, page_incr=0)
   # param3_scale = gtk.HScale(adjustment=adjustment3)
   # param3_scale.set_digits(0)  # Display only integers
   # hbox3.pack_start(param3_scale, expand=True, fill=True, padding=5)
   # # Connect callback functions for user interaction
   # param3_scale.connect("value-changed", on_param3_changed)

   # Add an OK button
   ok_button = dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
   ok_button.connect("clicked", on_ok_button_clicked)
   # Show the dialog
   dialog.show_all()
   update_live_preview() #call this once so we see effect
   dialog.run()
 

# Callback function for updating the live preview when param1 changes
def on_param1_changed(scale):
   global global_param1
   global_param1 = scale.get_value()
   update_live_preview()

# Callback function for updating the live preview when param2 changes
def on_param2_changed(scale):
   global global_param2
   global_param2 = scale.get_value()
   update_live_preview()

def on_param3_changed(scale):
   global global_param3
   global_param3 = scale.get_value()
   update_live_preview()

# Callback function for the OK button
def on_ok_button_clicked(button, data=None):
   global drawable
   apply_final(preview_layer) #preview layer because we don't want to apply the invert to final layer it's just for viewing
   button.get_toplevel().destroy() #destroys the gtk dialog window
# Register the Python-Fu plugin
register(
   "python_fu_grow_shrink_live",
   "Grow/Shrink Current Selection with Live Preview",
   "Grow/Shrink Current Selection with Live Preview",
   "TT",
   "TT",
   "NAME",
   "<Image>/Python-Fu/Live Preview/Grow-Shrink Live",  # Menu location
   "*",  # Image type
   [],
   [],
   dialog
)

main()


Thx.
                               .....
Samj PortableGimp 2.10.28 - Win-10 /64.
Reply
#2
(12-09-2023, 04:05 PM)Krikor Wrote:    "TT",
   "TT",
   "NAME",
   "<Image>/Python-Fu/Live Preview/Grow-Shrink Live",   # Menu location
   "*",  # Image type
Thx.

Python-Fu > Live Preview > Grow-Shrink Live (look near/at the bottom at Python-Fu, perso I did change the path to put it in "Select" instead of Python-Fu)

It's a nice script, but get quickly slow when moving the slider especially with big images and on my old computer, a recent computer is needed IMO
Patrice
Reply
#3
As above and in a Win 10 / samj 2.10.34 I have handy.  I did copy the plugin from your post.

   

If it is not working, did you put the plugin straight into ...\Preferences\plug-ins ?
Did you perhaps put it in its own folder ? If so is the folder name the same as the plugin file name ? 
Maybe in another folder ? Is that in your plugins path

...that is about all I can think of at the moment.
Reply
#4
PixLab,
I had looked at the code and precisely for this line of code <Image>/Pyton-Fu.... One of the first menus I looked for the plugin was in the Python-Fu menu, but as I said I didn't find anything in that menu.

You said to look near the bottom... I looked again but couldn't find it.

In fact, I don't even know what name to look for this plugin.

rich2005,
I put it in the correct folder, the same one where all the other plugins are.
I didn't put it in a folder. I put it directly in the plugins/PluginsUso folder (the same for all plugins that install it).

   

Would I have to name it with a specific name? I named this plugin grow-shrink-live.py

Thank you for your help!
                               .....
Samj PortableGimp 2.10.28 - Win-10 /64.
Reply
#5
It does not really matter what you have named the plugin file (excepting silly names) 123abc.py will do, it is the registration name in the code that matters.

Going back to where to find the plugin in the menu structure. Providing the plugin registers (that is not corrupt or not in your plugins folder) you can find from Help -> Plugin Browser.

   

All those other plugins in your screenshot work ? Just not grow-shrink-live.py Is that correct.
It might be when you copied / pasted the code. Did you use a text editor ? I got 194 lines start to finish

   

There is another version back on GimpChat - by david http://gimpchat.com/viewtopic.php?f=9&t=20616#p285735
Might be worth trying that.
Reply
#6
I had already used help - Plugin Browser but nothing appeared.

   

Yes, this folder is the one I've always used, and the plugins in it work without problems, and I can find them all in their appropriate menus.

Yes, 194 lines, using notepad++

I think maybe this plugin is for newer versions of Gimp, or even for development versions 2.99.xx

Hmmmm. Good to know, I will test this other version by David.

rich2005, thx!

(12-09-2023, 08:18 PM)rich2005 Wrote: [...]
There is another version back on GimpChat - by david http://gimpchat.com/viewtopic.php?f=9&t=20616#p285735
Might be worth trying that.

Yes!
With this other version, all the problems are gone.
Now everything goes as it should. Plugin easily visible in the menu as it should have been in the other version.

       

rich2005 thanks for solving another mystery. :-)
                               .....
Samj PortableGimp 2.10.28 - Win-10 /64.
Reply
#7
(12-09-2023, 09:35 PM)Krikor Wrote: I had already used help - Plugin Browser but nothing appeared.



Yes, this folder is the one I've always used, and the plugins in it work without problems, and I can find them all in their appropriate menus.

Yes, 194 lines, using notepad++

I think maybe this plugin is for newer versions of Gimp, or even for development versions 2.99.xx

Hmmmm. Good to know, I will test this other version by David.

rich2005, thx!

(12-09-2023, 08:18 PM)rich2005 Wrote: [...]
There is another version back on GimpChat - by david http://gimpchat.com/viewtopic.php?f=9&t=20616#p285735
Might be worth trying that.

Yes!
With this other version, all the problems are gone.
Now everything goes as it should. Plugin easily visible in the menu as it should have been in the other version.



rich2005 thanks for solving another mystery. :-)

Krikor,

I have made a new (experimental) version of this program.
The maximum value of the slider is set to the size of the image.
When the program is run without a pre-existing selection is selects the compete image so "0" (zero) on the slider becomes maximum so that the selection can only be reduced.
The minimum of the slider I have tried to make so that it reduces the selection to only a few pixels.

If you wish to try it, your comments and criticisms would be very welcome.

david.


Attached Files
.zip   grow-shrink-live.zip (Size: 3.11 KB / Downloads: 352)
Reply
#8
Thumbs Up 
(12-10-2023, 03:54 PM)david Wrote: Krikor,

I have made a new (experimental) version of this program.
The maximum value of the slider is set to the size of the image.
When the program is run without a pre-existing selection is selects the compete image so "0" (zero) on the slider becomes maximum so that the selection can only be reduced.
The minimum of the slider I have tried to make so that it reduces the selection to only a few pixels.

If you wish to try it, your comments and criticisms would be very welcome.

david.

Hi David,

Below are some observations. Sorry if they are not well organized or clear.

1- There is no way to cancel the plugin execution:

If I close the plugin window without clicking OK (by clicking the X in the window):
-- A layer called "preview" with opacity of 70% is created.
-- A channel called Selection Mask copy is created.
-- The selection remains active with the values that were in the plugin before it was closed, and not with the values initially defined before the plugin was called.

Due to the above, I need to close the preview layer, close the Selection Mask channel, close the active selection, and I will still have to redo the selection again.

This makes it easier to just give OK anyway, since only the selection will have to be closed. (the preview layer nor the Selection Mask copy channel is created)

2- When the selection is being made on a background (a part of the image) with a color close to that used in the preview layer (for example, lips), the 70% opacity value ends up being a little high.

-- Fortunately, it is possible to adjust the opacity value while the plugin is still open.

-- However, if I notice, after making adjustments to the plugin (for example Grow = 4, Feather = 1) and reducing the opacity of the "preview" window to something around 30%; When I need to change these adjustment values, the opacity returns to the initial 70%, making it difficult to see the desired changes again.

Ideally, we would be able to adjust the opacity of the "preview" layer while adjusting the plugin values.

3-- I found it easier to move the sliders via the keyboard (<, >), which increments and decrements by one unit with each press.

4-- When there is no selection, the slider only allows the Skrink option (reduction), this is ok, but on the other hand it does not allow any change in the Feather Radius value.

-- Ideally, perhaps, in addition to being able to reduce the selection, it would allow the application of a Feather Radius if desired.

I only did a few tests with this plugin, and regardless of my considerations made above, I believe I will use it constantly as now I can have a better idea of which values to choose for the Grow/Shrink/Feather operations, which before it was guesswork and repetition.

David, thank you for taking the time to improve the usability of this plugin!
                               .....
Samj PortableGimp 2.10.28 - Win-10 /64.
Reply
#9
(12-11-2023, 04:54 PM)Krikor Wrote:
(12-10-2023, 03:54 PM)david Wrote: Krikor,

I have made a new (experimental) version of this program.
The maximum value of the slider is set to the size of the image.
When the program is run without a pre-existing selection is selects the compete image so "0" (zero) on the slider becomes maximum so that the selection can only be reduced.
The minimum of the slider I have tried to make so that it reduces the selection to only a few pixels.

If you wish to try it, your comments and criticisms would be very welcome.

david.

Hi David,

Below are some observations. Sorry if they are not well organized or clear.

1- There is no way to cancel the plugin execution:

If I close the plugin window without clicking OK (by clicking the X in the window):
-- A layer called "preview" with opacity of 70% is created.
-- A channel called Selection Mask copy is created.
-- The selection remains active with the values that were in the plugin before it was closed, and not with the values initially defined before the plugin was called.

Due to the above, I need to close the preview layer, close the Selection Mask channel, close the active selection, and I will still have to redo the selection again.

This makes it easier to just give OK anyway, since only the selection will have to be closed. (the preview layer nor the Selection Mask copy channel is created)

2- When the selection is being made on a background (a part of the image) with a color close to that used in the preview layer (for example, lips), the 70% opacity value ends up being a little high.

-- Fortunately, it is possible to adjust the opacity value while the plugin is still open.

-- However, if I notice, after making adjustments to the plugin (for example Grow = 4, Feather = 1) and reducing the opacity of the "preview" window to something around 30%; When I need to change these adjustment values, the opacity returns to the initial 70%, making it difficult to see the desired changes again.

Ideally, we would be able to adjust the opacity of the "preview" layer while adjusting the plugin values.

3-- I found it easier to move the sliders via the keyboard (<, >), which increments and decrements by one unit with each press.

4-- When there is no selection, the slider only allows the Skrink option (reduction), this is ok, but on the other hand it does not allow any change in the Feather Radius value.

-- Ideally, perhaps, in addition to being able to reduce the selection, it would allow the application of a Feather Radius if desired.

I only did a few tests with this plugin, and regardless of my considerations made above, I believe I will use it constantly as now I can have a better idea of which values to choose for the Grow/Shrink/Feather operations, which before it was guesswork and repetition.

David, thank you for taking the time to improve the usability of this plugin!
@ Krikor,

Thanks for your comments - I always find them helpful.

This is a plug-in by TinT. I have only made small alterations to try and set the limits for the sliders. Unfortunately the program has become unstable and I am unable to make other changes at present. (This may be the reason why you had problems installing the original program.)

When I have a stable program to work on, I shall examine your comments again.

david.
Reply
#10
(12-12-2023, 04:39 PM)david Wrote:
(12-11-2023, 04:54 PM)Krikor Wrote:
(12-10-2023, 03:54 PM)david Wrote: Krikor,

I have made a new (experimental) version of this program.
The maximum value of the slider is set to the size of the image.
When the program is run without a pre-existing selection is selects the compete image so "0" (zero) on the slider becomes maximum so that the selection can only be reduced.
The minimum of the slider I have tried to make so that it reduces the selection to only a few pixels.

If you wish to try it, your comments and criticisms would be very welcome.

david.

Hi David,

Below are some observations. Sorry if they are not well organized or clear.

1- There is no way to cancel the plugin execution:

If I close the plugin window without clicking OK (by clicking the X in the window):
-- A layer called "preview" with opacity of 70% is created.
-- A channel called Selection Mask copy is created.
-- The selection remains active with the values that were in the plugin before it was closed, and not with the values initially defined before the plugin was called.

Due to the above, I need to close the preview layer, close the Selection Mask channel, close the active selection, and I will still have to redo the selection again.

This makes it easier to just give OK anyway, since only the selection will have to be closed. (the preview layer nor the Selection Mask copy channel is created)

2- When the selection is being made on a background (a part of the image) with a color close to that used in the preview layer (for example, lips), the 70% opacity value ends up being a little high.

-- Fortunately, it is possible to adjust the opacity value while the plugin is still open.

-- However, if I notice, after making adjustments to the plugin (for example Grow = 4, Feather = 1) and reducing the opacity of the "preview" window to something around 30%; When I need to change these adjustment values, the opacity returns to the initial 70%, making it difficult to see the desired changes again.

Ideally, we would be able to adjust the opacity of the "preview" layer while adjusting the plugin values.

3-- I found it easier to move the sliders via the keyboard (<, >), which increments and decrements by one unit with each press.

4-- When there is no selection, the slider only allows the Skrink option (reduction), this is ok, but on the other hand it does not allow any change in the Feather Radius value.

-- Ideally, perhaps, in addition to being able to reduce the selection, it would allow the application of a Feather Radius if desired.

I only did a few tests with this plugin, and regardless of my considerations made above, I believe I will use it constantly as now I can have a better idea of which values to choose for the Grow/Shrink/Feather operations, which before it was guesswork and repetition.

David, thank you for taking the time to improve the usability of this plugin!
@ Krikor,

Thanks for your comments - I always find them helpful.

This is a plug-in by TinT. I have only made small alterations to try and set the limits for the sliders. Unfortunately the program has become unstable and I am unable to make other changes at present. (This may be the reason why you had problems installing the original program.)

When I have a stable program to work on, I shall examine your comments again.

david.

@Krikor,

I have made a few changes to my previous version.

Ignore my comments about instability. The problem was a mistake in my code which TinT spotted!

The opacity of the mask is reduced to 50%.
It is now possible to change the feather setting when all the image is selected.

I have asked TinT to comment on my latest version, so I am certain he will make improvements to it!

Your comments are always welcome.

david.


Attached Files
.zip   grow-shrink-live_dm.zip (Size: 2.9 KB / Downloads: 91)
Reply


Forum Jump: