[Gimp-developer] newb questions re python-fu

Chris Mohler cr33dog at gmail.com
Mon Sep 22 09:50:19 PDT 2008


On Mon, Sep 22, 2008 at 10:29 AM, paul taney <paultaney at yahoo.com> wrote:
>
> Hi,
>
> A coupla questions from the newb...
>
> I am trying to write my first python-fu plug-in and I cannot get it to install.  Here"s how I am pushing it to the plugins dir:
>
>  cp VanDerWalt.py ~/.gimp-2.4/plug-ins/python-fu-vanderwalt.py
>  chmod +x ~/.gimp-2.4/plug-ins/python-fu-vanderwalt.py
>
> Then I look for it under <Image>/Filters/Render/  and it is not there.
>
>
> It"s a color filter that attempts to extract the bluest pixels,
> like this:
>
> <code>
>
>  RED, GRN, BLU = 0, 1, 2
>  bluemask = (image[...,BLU] > 1.4*image[...,GRN]) & \
>             (image[...,BLU] > 1.4*image[...,RED])
>
>  blue_layer = gimp.layer(bluemask, width, height, RGBA_IMAGE, 100, NORMAL_MODE)
>  image.addlayer(blue_layer, 0)
>
> </code>
>
> Q1) Is this even close?
> Q2) can I continue to use numpy (as I was with wx.Python) or do these images have to be treated with scipy?

Hi Paul,

I found a few mistakes here and there.  The main one is that Python is
very strict about indentation.  After that, the "import Interpolate"
line I changed to "from scipy import interpolate as ma" - I'm not sure
if that is correct or not.  Lastly, there were some items like
"PF_ITEM("foo", _("foo"), "foo")" that I changed to "PF_ITEM("foo",
"foo", "foo")" and also I added "Vanderwalt" to the end on the plug-in
resgistration.  Oh yeah - I also added an 'except' in somewhere befor
a "finally"...

So... now it still does not run correctly, but at least it registers
with GIMP :|

BTW - starting GIMP from the command line will show syntax errors in
py-fu scripts....  Also editors like scite and eric (among others)
show indentation problems in Python by default - these are probably in
your repositories.

HTH,
Chris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: python-fu-vanderwalt_02.py
Type: text/x-python
Size: 7104 bytes
Desc: not available
Url : /lists/gimp-developer/attachments/20080922/da51d7f5/attachment.py 


More information about the Gimp-developer mailing list