Gimp: python script not showing in menu

I followed this tutorial, and this is what I still came up with:

#!/usr/bin/python # -*- coding: utf-8 -*- #http://www.ibm.com/developerworks/library/os-autogimp/ from gimpfu import* def plugin_main(timg, tdrawable, maxh=540, maxw=800): currentWidth = tdrawable.width currentHeight = tdrawable.height newWidth = currentWidth newHeight = currentHeight if (maxw < newWidth): newWidth = maxw newHeight = (float(currentHeight) / (float(currentWidth) / newWidth)) if (maxh < newHeight): newHeight = maxh newWidth = (float(currentWidth) / (float(currentHeight) / newHeight)) pdb.gimp_image_scale(timg, newWidth, newHeight) register( "python_fu_resize", "Saves the image at a maximum width and height", "Saves the image at a maximum width and height", "NN", "NN", "2013", "<Image>/Image/Resize to max...", "*", [], [], plugin_main) main() 

But the plugin will not appear in the gimp menu (I am using gimp 2.8). The chmod a + x file is provided. Perhaps the problem is with the file: /. Gimp-2.8 / plug-ins / src / resize.py? Src is due to an eclipse.

+8
python gimp gimpfu python-fu
source share
1 answer

If your script has any syntax errors, it will not be displayed in the menu at all - the above code has a syntax error in the very first line of code from gimpfu import* (space before * )

One easy way to check for syntax errors is to try to run the script as a standalone (it will fail if it cannot find the "gimpfu" module outside of GIMP, but by then the parsed syntax is another way - use a lint utility like pyflakes to check syntax.

Other runtime errors that your script may contain should appear in a popup when it starts from GIMP - at this point you can only update the script and try again from the menu. If you change the input or output parameters from your script, you must restart GIMP.

And yes, "file location" is the problem - you have to put your code in the directory specified for the plugins in the GIMP settings - the default is ~/.gimp-2.8/plug-ins/ or /usr/lib[64]/gimp/2.0/plug-ins - without "src" - if your IDE does not allow you to specify where to put your files, you must copy them yourself or add src dirs in the GIMP settings.

+10
source share

All Articles