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

Learning to do first Python script

Tue Apr 07, 2020 1:36 pm

Hi I"m trying to learn python scripting, (I took advise from ofnuts, thank you) and I'm trying to create my first simple plugin "Extreme Canvas texturing". The problem is that is not registering with GIMP, it doesn't appear on the menu Scrip-fu. Any help will be appreciated. I want to let you know that I'm a 59 old but I'm in first grade in Python scripting, so be gentle! Thank you in advanced.


This is the script so far:

Code:
#!/usr/bin/env python

from gimpfu import *

def python_extreme_canvas_texturing(image, drawable):
   #Run the unsharp mask, radius 3, amount 3, threshold 0,
   #Run desaturate, lightness mode,
   radius= 3.0
   amount= 3.0
   threshold= 0
   pdb.plug_in_unsharp_mask(image, drawable, radius, amount, threshold)
   
   #Run apply canvas, light direction top right,
   direction= TOP_RIGHT
   depth= 10
   pdb.plug_in_apply_canvas(image, drawable, direction, depth)
   
   





register(
    "python_extreme_canvas_texturing",
    "Extreme canvas",
    "Create and extreme canvas on image",
    "Pocholo",
    "Pocholo",
    "April 7, 2020",
    "<Image>/Python-Fu/Extreme canvas texture...",
   "RGB",
   [
      (PF_IMAGE,    "ïmage",  "take current image", "None"),
      (PF_DRAWABLE, "drawable",  "input layer", "None"),
    ],
   [],
   python_extreme_canvas_texturing)

   
main()

Re: Learning to do first Python script

Tue Apr 07, 2020 2:34 pm

Your i in "image" is not an i ;) That gets it registered but not a lot happens.

not-an-i.jpg
not-an-i.jpg (55.72 KiB) Viewed 2375 times

Re: Learning to do first Python script

Tue Apr 07, 2020 2:45 pm

I got it working after making 3 changes

TOP_RIGHT is not defined

the two lines below were deleted/not required
(PF_IMAGE, "ïmage", "take current image", "None"),
(PF_DRAWABLE, "drawable", "input layer", "None"),

comma missing at end of line python_extreme_canvas_texturing)

steve

Re: Learning to do first Python script

Tue Apr 07, 2020 2:51 pm

Running in terminal, it reports error in line 34:

Code:
line 34
SyntaxError: Non-ASCII character '\xc3' in file /home/racer/.config/GIMP-AppImage/2.10/plug-ins/01-test.py on line 34, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

Re: Learning to do first Python script

Tue Apr 07, 2020 2:59 pm

Thank you guys, you are Awesome!

Re: Learning to do first Python script

Tue Apr 21, 2020 4:53 pm

I was also having a problem writing my first script. What I found out that helped me was to start gimp in verbose mode.

The easiest way to do this is use the verbose flag (--verbose) when starting gimp.

Thanks

Re: Learning to do first Python script

Wed Apr 22, 2020 2:47 am

See also: https://www.gimp-forum.net/Thread-Debug ... in-Windows
Post a reply