GIMP Chat
http://gimpchat.com/

Inserting pdb.python_gegl command in my code
http://gimpchat.com/viewtopic.php?f=9&t=19801
Page 1 of 2

Author:  Pocholo [ Sat Jan 29, 2022 5:45 pm ]
Post subject:  Inserting pdb.python_gegl command in my code

Hi guys! I'm trying to implement a Gegl command in my code and it's not working :gaah .
Using the Bump map filter I have this:

pdb.python_gegl(img, layer,
   "bump-map type=linear compensate=True invert=False tiled=False azimuth=220 elevation=30 depth=20 offset-x=0 offset-y=0 waterlevel=1.00 ambient=1.00")


What am I missing here? Thank you in advance!

Author:  MareroQ [ Sat Jan 29, 2022 9:55 pm ]
Post subject:  Re: Inserting pdb.python_gegl command in my code

Hi Pocholo.
Gegl bump-map needs aux input (need to save layer or use existing image with full path).
https://www.gimp-forum.net/Thread-GEGL- ... 1#pid19961
I don't know Your target, but it's easier to use gegl emboss like bump-map.

Author:  Pocholo [ Sat Jan 29, 2022 10:17 pm ]
Post subject:  Re: Inserting pdb.python_gegl command in my code

Thanks a lot MareroQ. Nice to see you still around here to help! :tyspin

Author:  MareroQ [ Sat Jan 29, 2022 10:40 pm ]
Post subject:  Re: Inserting pdb.python_gegl command in my code (Solved)

Also for me it works when instead of: =False or =True You use =0 or =1 respectively.
Example:

def sample_bump(image, layer):
   xxx=pdb.gimp_image_get_active_layer(image)
   pdb.python_gegl(image, xxx, 'bump-map aux=[load path="d:/image.png"] compensate=1 invert=1 tiled=0 azimuth=220 elevation=30 depth=20 offset-x=30 offset-y=20')
   pdb.gimp_displays_flush()

Author:  Pocholo [ Sat Jan 29, 2022 11:55 pm ]
Post subject:  Re: Inserting pdb.python_gegl command in my code (Solved)

Thank you my friend! Believe it yourself, you're a good teacher! :hi5

Author:  dinasset [ Sun Jan 30, 2022 4:17 am ]
Post subject:  Re: Inserting pdb.python_gegl command in my code (Solved)

Pocholo, could you post here the complete plug-in source of a python filter which makes use of pdb.python_gegl?

Author:  Pocholo [ Sun Jan 30, 2022 10:36 am ]
Post subject:  Re: Inserting pdb.python_gegl command in my code (Solved)

Hi dinasset! I tryin to create a Night scene (Not finished yet). Can you check the Solid Noise gegl command? I thought I had this one right but is not applying to the image.


#!/usr/bin/env python
# -*- coding: utf-8 -*-

# author: Pocholo
# date: 8/18/21

# Comments directed to http://gimpchat.com

# Installation:
# This script should be placed in the user plugin folder

# Copyright (C)

#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by   
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.

#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <https://www.gnu.org/licenses/>.

from gimpfu import *
import os, sys,time
import gettext
gettext.install("gimp20", gimp.locale_directory, unicode=True)
               
def create_a_beautiful_moonlight_scene():

    #Initiates the temporary state
    pdb.gimp_context_push()
    pdb.gimp_context_set_defaults()
      
    #Create the sky
    img = pdb.gimp_image_new(1920, 1080, RGB)
    Starslayer = pdb.gimp_layer_new(img, img.width, img.height, RGBA_IMAGE, "Small Stars", 100, LAYER_MODE_NORMAL)
    pdb.gimp_image_insert_layer(img, Starslayer, None, 0)
    pdb.gimp_layer_add_alpha(Starslayer)
    pdb.gimp_context_set_foreground((0, 0, 0))
    pdb.gimp_drawable_fill(Starslayer, FILL_FOREGROUND)
   
    #Image process
    pdb.gimp_display_new(img)
   
    #Create the stars
    pdb.plug_in_hsv_noise(img, Starslayer, 8, 0, 0, 255)
    pdb.gimp_brightness_contrast(Starslayer, -80, 50)
    pdb.plug_in_gauss(img, Starslayer, 0.50, 0.50, 1)
    pdb.plug_in_sparkle(img, Starslayer, 0.001, 1.00, 20, 4, 15, 1.00, 0, 0, 0, FALSE, FALSE, FALSE, 0)
   
    #Create the Moon
    moonLayer = pdb.gimp_layer_new(img, img.width, img.height, RGBA_IMAGE, "Moon", 100, LAYER_MODE_NORMAL)
    pdb.gimp_image_add_layer(img, moonLayer, 0)
    pdb.gimp_drawable_fill(moonLayer, FILL_TRANSPARENT)
    pdb.gimp_context_set_foreground("White")
    pdb.gimp_image_select_ellipse(img, 2, 810, 75, 306, 306)
    pdb.gimp_edit_bucket_fill(moonLayer, BUCKET_FILL_FG, LAYER_MODE_NORMAL, 100, 255, FALSE, 0, 0)
    pdb.plug_in_solid_noise(img, moonLayer, FALSE, FALSE, 0, 15, 0.8, 0.8)
    pdb.gimp_selection_none(img)
   
    #Create a texture on the moon
    pdb.gimp_file_save(img, moonLayer, "C:\\temp\\Moon.png", "Moon.png")
    moonLayer=pdb.gimp_image_get_active_layer(img)
    pdb.python_gegl(img, moonLayer,
       'bump-map aux=[load path="C:\\temp\\Moon.png"] compensate=1 invert=0 tiled=0 azimuth=220 elevation=30 depth=7 offset-x=0 offset-y=0 waterlevel=1.00 ambient=1.00')
    pdb.gimp_image_select_item(img, 2, moonLayer)
    pdb.gimp_selection_shrink(img, 6)
    pdb.gimp_selection_invert(img)
    pdb.gimp_drawable_edit_clear(moonLayer)
   
    #Moon glow
    glowLayer = pdb.gimp_layer_new(img, img.width, img.height, RGBA_IMAGE, "Moon glow", 100, LAYER_MODE_NORMAL_LEGACY)
    pdb.gimp_image_add_layer(img, glowLayer, 1)
    pdb.gimp_drawable_fill(glowLayer, FILL_TRANSPARENT)
    pdb.gimp_context_set_foreground("White")
    pdb.gimp_image_select_item(img, 2, moonLayer)
    pdb.gimp_edit_bucket_fill(glowLayer, BUCKET_FILL_FG, LAYER_MODE_NORMAL, 100, 255, FALSE, 0, 0)
    pdb.gimp_selection_none(img)
    pdb.plug_in_gauss(img, glowLayer, 150, 150, 1)   #method=1
   
    #Create the sea
    seaLayer = pdb.gimp_layer_new(img, img.width, img.height, RGBA_IMAGE, "Sea", 100, LAYER_MODE_NORMAL)
    pdb.gimp_image_add_layer(img, seaLayer, 0)
    pdb.gimp_context_set_foreground((3, 3, 5))
    pdb.gimp_drawable_fill(seaLayer, FILL_FOREGROUND)
    wavesLayer = pdb.gimp_layer_new(img, img.width, img.height, RGBA_IMAGE, "Waves", 100, LAYER_MODE_NORMAL)
    pdb.gimp_image_add_layer(img, wavesLayer, 0)
    pdb.gimp_drawable_fill(wavesLayer, FILL_WHITE)
    pdb.python_gegl(img, wavesLayer, 'noise-solid x-size=16.00 y-size=16.00 detail=15 tileable=0 turbulent=0 seed=0 width=1920 height=1080')

    #Make active the bottom layer and done
    pdb.gimp_image_set_active_layer(img, Starslayer)
   
    #Set gimp to default
    pdb.gimp_context_pop()
      
register(
    "create_a_beautiful_moonlight_scene",
    "Creates Stars and a Moon",
    "Creates Stars and a Beautiful Moonlight over a Sea",
    "Pocholo",
    "Pocholo",
    "2021",
    "Create a Beautiful Moonlight Scene",
    "",
    [   
    ],
    [],
    create_a_beautiful_moonlight_scene, menu="<Image>/Pocholo-scripts/Beautiful Moonlight scene",
    domain=("gimp20", gimp.locale_directory))
main()         

Author:  dinasset [ Sun Jan 30, 2022 11:01 am ]
Post subject:  Re: Inserting pdb.python_gegl command in my code (Solved)

Downloaded and launched on my samj's Gimp, but I get this error message:
"Procedure 'python-gegl' not found".
What should I do?

Author:  dinasset [ Sun Jan 30, 2022 11:10 am ]
Post subject:  Re: Inserting pdb.python_gegl command in my code (Solved)

Stopping before "gegl" I get this image:
Attachment:
outcome_up_to_gegl.png
outcome_up_to_gegl.png [ 384.55 KiB | Viewed 839 times ]

Author:  Pocholo [ Sun Jan 30, 2022 4:46 pm ]
Post subject:  Re: Inserting pdb.python_gegl command in my code (Solved)

Sorry I had to stepped out. Wi the first Bump-map "gegl" and the "Moon glow" this what you supposed to get with no error.
Image

After the glow I want to use Solid Noise "gegl" in a whole layer and I don't know what I'm missing in the this gegl
line. It does not produce anything when it should give me a layer filled with Solid Noise.

Author:  Pocholo [ Sun Jan 30, 2022 5:44 pm ]
Post subject:  Re: Inserting pdb.python_gegl command in my code (Solved)

When I use Gegl graph, the procedure work fine and it give me the Solid Noise...

Image


But when I run the plugin it doesn't give me the same result, it just give me the created white layer.

Image

Author:  Pocholo [ Sun Jan 30, 2022 6:01 pm ]
Post subject:  Re: Inserting pdb.python_gegl command in my code (Solved)

dinasset wrote:
Downloaded and launched on my samj's Gimp, but I get this error message:
"Procedure 'python-gegl' not found".
What should I do?


I used the "gegl_command.py" that is made up of paynekj's simpler version.

Author:  dinasset [ Mon Jan 31, 2022 1:26 am ]
Post subject:  Re: Inserting pdb.python_gegl command in my code

Is it a separate .py plug-in? It's not embedded in your code.
Anyhow, I do not have "noise-solid" among the operations (C) I could test, hence I can't help.

edit: If you post here the separate .py plug-in, I can try to test your calls to the gegl functions

Author:  dinasset [ Mon Jan 31, 2022 8:29 am ]
Post subject:  Re: Inserting pdb.python_gegl command in my code

In some way I had the possibility to try solid noise: you are right, Pocholo, no action, it could be the interface is broken.

Author:  cli345 [ Mon Jan 31, 2022 1:36 pm ]
Post subject:  Re: Inserting pdb.python_gegl command in my code

Hello, :)
The plugin that enables pdb.python-gegl is here.

Author:  dinasset [ Mon Jan 31, 2022 2:05 pm ]
Post subject:  Re: Inserting pdb.python_gegl command in my code

Thanks cli345, installed.
I'll see whether I can understand why some Pocholo calls do not execute properly (but I doubt, I'm not an expert).

Author:  Pocholo [ Mon Jan 31, 2022 2:14 pm ]
Post subject:  Re: Inserting pdb.python_gegl command in my code

That is the one I have installed, cli345. But the procedure "Solid Noise" is not working all all.
pdb.python_gegl(img, wavesLayer,
        'noise-solid x-size=16.00 y-size=16.00 detail=15 tileable=0 turbulent=0 seed=0 width=1920 height=1080')

Author:  dinasset [ Mon Jan 31, 2022 3:16 pm ]
Post subject:  Re: Inserting pdb.python_gegl command in my code

Tested many types of noise, none works (not only noise-solid...).
Tested plasma, it works.

Author:  MareroQ [ Tue Feb 01, 2022 7:43 am ]
Post subject:  Re: Inserting pdb.python_gegl command in my code

Also for me without success.
I tried out the noise-solid version of Cli, Kevin, Samj and Jehan (plug-in-goat-exercise-python for Gimp-2.99).
Of all the Gegl filters, only 85 work for me (using Python code).

Author:  Pocholo [ Tue Feb 01, 2022 11:43 am ]
Post subject:  Re: Inserting pdb.python_gegl command in my code

Thank you dinasset and MareroQ for taking the time to test "Gegl".

@MareroQ: Do you have the list of the Gegl filter that work? If you don't mind, Can you post the list? I'll thank you in advance. :)

Page 1 of 2 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/