Switch to full style
Post all Gimp scripts and script writing questions here
Post a reply

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Tue Nov 21, 2023 1:05 am

MareroQ wrote:Changes in Ver.2:

- combined into one file gegl-python-fu.py and gegl-graph.py to gegl-python-fu & gegl-graph.py (standalone files: gegl-python-fu.py and gegl-graph.py must be deleted),
- change menu location (You can change it very quickly as you want using Notepad++),
- removed gegl-tile (because it doesn't work), gegl-nop (No operation),
- added: bump-map, component_extract, dropshadow, embos, mosaic, supernova.
- added: "Additional Information"
[ Image ]

A little about bump-map:

- bump-map: https://gegl.org/operations/gegl-bump-map.html
- about GEGL graph by Kevin and Tmanni: https://www.gimp-forum.net/Thread-GEGL- ... 0#pid19960. This was crucial to solving the aux problem - save aux.
- chanche offset: '+' up/right, '-' down/left
- gegl_graph_string + aux does not accept commas (that was problem number 2 but I don't know why at all),

I think that the save method (assuming that the 'd:' drive exists) will allow the conversion of filters from 2 pads: aux2 aux.
Tim wrote about 3 pads - which filter is it?

Edit:
Version 2.0 has been removed due to detected bugs
Reported bugs have been fixed in version 2.1 #55

I see you removed gegl:nop, Its okay to remove it from the GUI (where the user sees stuff) but that operation (gegl:nop) is critical to make connnections in GEGL known as id and ref. Many plugins of mine depend on gegl:nop to do this.

To put things simple gegl:nop exist to put filters inside blend modes while calling a copy of the original image.

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Tue Nov 21, 2023 4:56 am

MareroQ wrote:I'm looking for a Bump-map tester on Linux (included in version 2.1) - my Ubuntu doesn't work (temporarily?) after updating.


Bumpmap doesn't work on my Linux Mint 20.1
The message I get is this:
Code:
Traceback (most recent call last):
  File "/usr/lib/gimp/2.0/python/gimpfu.py", line 741, in response
    dialog.res = run_script(params)
  File "/usr/lib/gimp/2.0/python/gimpfu.py", line 362, in run_script
    return apply(function, params)
  File "/home/xxx/.config/GIMP/2.10/plug-ins/gegl-python-fu & gegl_graph.py", line 1865, in gegl_bump_map
    pdb.file_png_save(image, save, xchange, xchange, 1, 1, 1, 0, 0, 1, 0, run_mode=RUN_NONINTERACTIVE)
RuntimeError: Datei »/usr/image_1.png« konnte nicht zum Schreiben geöffnet werden: Keine Berechtigung


Looks like it wants to write to /usr where it has no permisssions.
A user's home dir would be /home/username in Linux

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Tue Nov 21, 2023 5:48 am

Hello Contrast
Plugin gegl-python-fu & gegl_graph.py is a helper for people writing plugins or scripts, and I don't see any way to use gegl:nop outside of Gegl proper.
Single Gegl plugins are registered in the PDB and this is very good, but if you only want to use one operation, it is better to use GEGL directly (advantage in preview).
Practically, gegl-python-fu & gegl_graph.py does not need to be registered in the Gimp menu at all (only in the PDB).
I assume plugin developers have knowledge of how to use gegl-python.

What do you think about not registering gegl-python-fu in menus (except gegl-graph)???

Hello Nelo.
Thank you for trying the plugin.
The idea behind this game is to temporarily save the Aux image in a location that will be publicly available to users of different versions of Linux.
Could you try with the tmp folder (replace "/usr/image_1.png" twice with "/tmp/image_1.png")

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Tue Nov 21, 2023 6:49 am

I am probably missing something in the discussion but it works ok here: kubuntu 20.04 / Gimp 2.10.36 (from PPA)

bump.jpg
bump.jpg (85.71 KiB) Viewed 15515 times


Lots of output in a terminal but no error messages

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Tue Nov 21, 2023 8:57 am

Could you try with the tmp folder (replace "/usr/image_1.png" twice with "/tmp/image_1.png")


Yes, that works

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Wed Nov 22, 2023 12:49 am

Thank you very much Nelo and Rich2005 for testing.
We can always rely on you. :hi5

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Wed Nov 22, 2023 11:03 am

I tried adding a special version of my glossy balloon plugin designated for python all by myself and the .py file failed to load.

This is what I put

Code:
#-------------------------------------Beaver-----------------------------------------------------   

def gegl_glossy_balloon(image, layer, gaus,hue,lightness,opacityall):


    gegl_graph_string="lb:script-glossy-balloon gaus=%f hue=%f lightness=%f opacityall=%f" % (gaus, hue, lightness, opacityall)
    pdb.python_fu_gegl_graph(image, layer, gegl_graph_string)

register(
    "python_fu_gegl_glossy_balloon",
    "GEGL to Python. Works on the active layer",
    "Glossy Balloon GEGL Text Styling Plugin In Python",
    "Auto Author",
    "Auto Author",
    "Auto Generated Dated",
    "<Image>/GEGL as Python/gegl-glossy-balloon...",             #Menu path
    "*",
    [
    (PF_FLOAT, "gaus","gaus (default:6.0, 0.5..20.0):", 6.0),
    (PF_FLOAT, "hue","hue (default:0, -180..180.0):", 0),
    (PF_FLOAT, "lightness","lightness (default:-7, -15.0..15.0):", -7)
    (PF_FLOAT, "opacityall","opacityall (default:0.0, 1.0..5.0):", 3.0)

    ],
    [],
    gegl_glossy_balloon)

#---------------------------------------------------------------------------------------------


What did I do wrong? Here are the parameters of the filter I cited.
https://github.com/LinuxBeaver/Special_ ... ipt-only.c



THIS DOES NOT WORK


The plan should be to make the 24 compatible plugins of mine a separate python file that ships on said Github page of mine. I'll do it myself (all 24 of them) if someone teaches me how to get my plugins in python correctly.

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Wed Nov 22, 2023 1:38 pm

@Beaver.

If you add a comma (missing) after the line:
Code:
     (PF_FLOAT, "lightness","lightness (default:-7, -15.0..15.0):", -7)

everything works (but why without PF_COLOR?)

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Wed Nov 22, 2023 5:24 pm

Thank you Mr.Q I got it working and I plan to port my 24 plugins to python all by myself.

But should I have them as my own .c file called geglplugins.py, but if so they'd still need to be in your menu. I could have parenthesis with (plugin) after them.

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Wed Nov 22, 2023 5:29 pm

MareroQ wrote:@Beaver.

If you add a comma (missing) after the line:
Code:
     (PF_FLOAT, "lightness","lightness (default:-7, -15.0..15.0):", -7)

everything works (but why without PF_COLOR?)


The script version of glossy balloon only has a hue rotation. (-180 - 180) from gegl:hue-chroma. The color node in the modern version of Glossy Balloon uses gimp:layer-mode layer-mode=hsl-color and that node does not work in gegl_command.py

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Wed Nov 22, 2023 8:47 pm

This code causes the python script to not show up at all in Gimp.

What did I do wrong?
Corresponds too
https://github.com/LinuxBeaver/Special_ ... t_cbevel.c

I used PF_OPTION for the drop down list of blend modes and intentionally excluded some options.


Code:
def gegl_custom_bevel(image, layer, opacity,blendmode,azimuth,elevation,depth,size,alphapercentile,gaus,box,mcb):


    if type==0:
        blendmode= "Hardlight"
    if type==1:
        blendmode= "Multiply"
    if type==2:
        blendmode= "ColorDodge"
    if type==3:
        blendmode= "Plus"
    if type==4 :
        blendmode= "Darken"
    if type==5 :
        blendmode= "Lighten"
    if type==6:


    gegl_graph_string="lb:script-custom-bevel opacity=%f blendmode=%f azimuth=%f elevation=%f depth=%f size=%f alphapercentile=%f gaus=%f box=%f mcb=%f" % (opacity, blendmode, azimuth, elevation, depth, size, alphapercentile, gaus, box, mcb)
    pdb.python_fu_gegl_graph(image, layer, gegl_graph_string)

register(
    "python_fu_gegl_custom_bevel",
    "GEGL to Python. Works on the active layer",
    "Custom Bevel GEGL Text Styling Plugin In Python",
    "Auto Author",
    "Auto Author",
    "Auto Generated Dated",
    "<Image>/GEGL as Python/gegl-glossy-balloon...",             #Menu path
    "*",
    [
    (PF_FLOAT, "opacity","opacity (default:1.0, 3.5 10.0):", 3.5),
    (PF_OPTION,  "blendmode",      "blendmode:", 0, ["Hardlight","Multiply","ColorDodge","Plus","Darken","Lighten"]),
    (PF_FLOAT, "azimuth","azimuth (default:67, 30 90.0):", 67),
    (PF_FLOAT, "elevation","elevation (default:25, 7 90):", 25),
    (PF_FLOAT, "depth","depth (default:24, 1 100):", 24),
    (PF_FLOAT, "size","size (default:1, 0 15):", 1),
    (PF_FLOAT, "alphapercentile","alphapercentile (default:68, 0 100):", 68),
    (PF_FLOAT, "gaus","gaus (default:2, 0 9):", 2),
    (PF_FLOAT, "box","box (default:0, 0 6):", 0),
    (PF_FLOAT, "mcb","mcb (default:0, 0 6):", 1),

    ],
    [],
    gegl_custom_bevel)

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Wed Nov 22, 2023 9:47 pm

I got custom bevel working but every blend mode I choose is exactly the same.

how do I get it to switch blend modes

Image

CODE HERE
Code:
def gegl_custom_bevel(image, layer, opacity,blendmode,azimuth,elevation,depth,size,alphapercentile,gaus,box,mcb):


    if blendmode==1:
        type= "Hardlight"
    if blendmode==2:
        type= "Multiply"
    if blendmode==3:
        type= "ColorDodge"
    if blendmode==4:
        type= "Plus"
    if blendmode==5:
        type= "Darken"
    if blendmode==6:
        type= "Lighten"



    gegl_graph_string="lb:script-custom-bevel opacity=%f blendmode=%f azimuth=%f elevation=%f depth=%f size=%f alphapercentile=%f gaus=%f box=%f mcb=%f" % (opacity, blendmode, azimuth, elevation, depth, size, alphapercentile, gaus, box, mcb)
    pdb.python_fu_gegl_graph(image, layer, gegl_graph_string)

register(
    "python_fu_gegl_custom_bevel",
    "GEGL to Python. Works on the active layer",
    "Custom Bevel GEGL Text Styling Plugin In Python",
    "Auto Author",
    "Auto Author",
    "Auto Generated Dated",
    "<Image>/GEGL as Python/gegl-custom-bevel...",             #Menu path
    "*",
    [
    (PF_FLOAT, "opacity","opacity (default:1.0, 3.5 10.0):", 3.5),
    (PF_OPTION,  "blendmode",      "blendmode:", 0, ["Hardlight","Multiply","ColorDodge","Plus","Darken","Lighten"]),
    (PF_FLOAT, "azimuth","azimuth (default:67, 30 90.0):", 67),
    (PF_FLOAT, "elevation","elevation (default:25, 7 90):", 25),
    (PF_FLOAT, "depth","depth (default:24, 1 100):", 24),
    (PF_FLOAT, "size","size (default:1, 0 15):", 1),
    (PF_FLOAT, "alphapercentile","alphapercentile (default:68, 0 100):", 68),
    (PF_FLOAT, "gaus","gaus (default:2, 0 9):", 2),
    (PF_FLOAT, "box","box (default:0, 0 6):", 0),
    (PF_FLOAT, "mcb","mcb (default:0, 0 6):", 1),

    ],
    [],
    gegl_custom_bevel)

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Wed Nov 22, 2023 9:49 pm

Also things like mcb and gaus are technical property names. I want to rename them to "internal gaussian blur" and "smooth". I think I know how to do that so I'll attempt to rename some things.

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Wed Nov 22, 2023 9:52 pm

you're setting type.
don't know for sure but shouldn't you pass in like this as string for blendmode and pass in type
Code:
gegl_graph_string="lb:script-custom-bevel opacity=%f blendmode=%s azimuth=%f elevation=%f depth=%f size=%f alphapercentile=%f gaus=%f box=%f mcb=%f" % (opacity, type, azimuth, elevation, depth, size, alphapercentile, gaus, box, mcb)
    pdb.python_fu_gegl_graph(image, layer, gegl_graph_string)

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Wed Nov 22, 2023 10:59 pm

ok, I will change blend mode to %s instead of =%f. I also changed "type" to "blendmode" because custom bevel has no "type" property but it does have a "blendmode" property. Now lets see if it works

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Wed Nov 22, 2023 11:06 pm

I don't know how to solve this but here is the code. It works but the blend mode switcher is broke

Code:
def gegl_custom_bevel(image, layer, opacity, blend_mode,azimuth,elevation,depth,size,alphapercentile,gaus,box,mcb):


    if blend_mode==0:
        blendmode= "Hardlight"
    if blend_mode==1:
        blendmode= "Multiply"
    if blend_mode==2:
        blendmode= "ColorDodge"
    if blend_mode==3:
        blendmode= "Plus"
    if blend_mode==4:
        blendmode= "Darken"
    if blend_mode==5:
        blendmode= "Lighten"



    gegl_graph_string="lb:script-custom-bevel opacity=%f blendmode=%s azimuth=%f elevation=%f depth=%f size=%f alphapercentile=%f gaus=%f box=%f mcb=%f" % (opacity, blend_mode, azimuth, elevation, depth, size, alphapercentile, gaus, box, mcb)
    pdb.python_fu_gegl_graph(image, layer, gegl_graph_string)

register(
    "python_fu_gegl_custom_bevel",
    "GEGL to Python. Works on the active layer",
    "Custom Bevel GEGL Text Styling Plugin In Python",
    "Auto Author",
    "Auto Author",
    "Auto Generated Dated",
    "<Image>/GEGL as Python/gegl-custom-bevel...",             #Menu path
    "*",
    [
    (PF_FLOAT, "opacity","opacity (default:1.0, 3.5 10.0):", 3.5),
    (PF_OPTION,  "blend_mode", "blendmode:", 0, ["Hardlight","Multiply","ColorDodge","Plus","Darken","Lighten"]),
    (PF_FLOAT, "azimuth","azimuth (default:67, 30 90.0):", 67),
    (PF_FLOAT, "elevation","elevation (default:25, 7 90):", 25),
    (PF_FLOAT, "depth","depth (default:24, 1 100):", 24),
    (PF_FLOAT, "size","size (default:1, 0 15):", 1),
    (PF_FLOAT, "alphapercentile","alphapercentile (default:68, 0 100):", 68),
    (PF_FLOAT, "gaus","Internal Gaussian Blur (default:2, 0 9):", 2),
    (PF_FLOAT, "box","Internal Box Blur (default:0, 0 6):", 0),
    (PF_FLOAT, "mcb","Smooth (default:0, 0 6):", 1),

    ],
    [],
    gegl_custom_bevel)

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Wed Nov 22, 2023 11:20 pm

I don't think it's broken but if you're setting now blendmode without underscore,
you should pass that in as
Code:
gegl_graph_string="lb:script-custom-bevel opacity=%f blendmode=%s azimuth=%f elevation=%f depth=%f size=%f alphapercentile=%f gaus=%f box=%f mcb=%f" % (opacity, blendmode, azimuth, elevation, depth, size, alphapercentile, gaus, box, mcb)

unless you're trying to pass the number in for blendmode, otherwise you want the string blendmode in the (opacity, blendmode ....) and not (opacity,blend_mode...)
that's why i put it as type before because you're trying to pass the variable you set with switch so I assume you're trying to pass that into the string so that after it formats it
you get opacity=%f with %f replace with opacity float variable.
and blendmode=%s with %s replaced with type string variable.
you can always pdb.gimp_message(gegl_graph_string) to debug it.
it's just setting a string
for example
Code:
mystring = "My age is %f and my name is %s" % (10,"Tin")

pdb.gimp_message(mystring) will show
My age is 10 and my name is Tin

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Wed Nov 22, 2023 11:30 pm

also is the string supposed to be "blendmode=%s" or "blend_mode=%s"

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Thu Nov 23, 2023 12:31 am

ok, I got it. This works. Thanks


Code:
def gegl_custom_bevel(image, layer, opacity, blendmode, azimuth, elevation, depth, size, alphapercentile, gaus, box, mcb):


    if blendmode==0:
        blend_mode= "Hardlight"
    if blendmode==1:
        blend_mode= "Multiply"
    if blendmode==2:
        blend_mode= "ColorDodge"
    if blendmode==3:
        blend_mode= "Plus"
    if blendmode==4:
        blend_mode= "Darken"
    if blendmode==5:
        blend_mode= "Lighten"



    gegl_graph_string="lb:script-custom-bevel opacity=%f blendmode=%s azimuth=%f elevation=%f depth=%f size=%f alphapercentile=%f gaus=%f box=%f mcb=%f" % (opacity, blend_mode, azimuth, elevation, depth, size, alphapercentile, gaus, box, mcb)
    pdb.python_fu_gegl_graph(image, layer, gegl_graph_string)

register(
    "python_fu_gegl_custom_bevel",
    "GEGL to Python. Works on the active layer",
    "Custom Bevel GEGL Text Styling Plugin In Python",
    "Auto Author",
    "Auto Author",
    "Auto Generated Dated",
    "<Image>/GEGL as Python/gegl-custom-bevel...",             #Menu path
    "*",
    [
    (PF_FLOAT, "opacity","opacity (default:1.0, 3.5 10.0):", 3.5),
    (PF_OPTION,  "blend_mode", "blendmode:", 0, ["Hardlight","Multiply","ColorDodge","Plus","Darken","Lighten"]),
    (PF_FLOAT, "azimuth","azimuth (default:67, 30 90.0):", 67),
    (PF_FLOAT, "elevation","elevation (default:25, 7 90):", 25),
    (PF_FLOAT, "depth","depth (default:24, 1 100):", 24),
    (PF_FLOAT, "size","size (default:1, 0 15):", 1),
    (PF_FLOAT, "alphapercentile","alphapercentile (default:68, 0 100):", 68),
    (PF_FLOAT, "gaus","Internal Gaussian Blur (default:2, 0 9):", 2),
    (PF_FLOAT, "box","Internal Box Blur (default:0, 0 6):", 0),
    (PF_FLOAT, "mcb","Smooth (default:0, 0 6):", 1),

    ],
    [],
    gegl_custom_bevel)

Re: GEGL operations exposed to Python-Fu - WIP 72 ops wrapped

Thu Nov 23, 2023 12:37 am

btw, I could make a special version of the emboss filter that uses blend modes other then the default "multiply" that way you guys can have easier access to good bevel algorithms without having to learn how GEGL composers work.

id=1 blendmodehere aux=[ ref=1 emboss elevation= depth= azimuth= ]
Post a reply