Re: Batch command syntax for callingPythonplugins/scripts on Windows XP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> > Further I open the command line, go to the directory that contains my
> > pictures to be processed and type:
> > 
> > gimp-2.6 -i --batch-interpreter=python-fu-eval -b python-fu-my-function
> > 
> > which starts to print the usual loading commands but stops with:
> > 
> > Starting extension: 'extension-script-fu'
> > batch command experienced an execution error
> > 
> > Is there essentially anything wrong with my syntax?
> 
> Please post a simple example script to illustrate what you are trying to
> achieve.

Of course I forgot the important part, so there you go.

My script/plugin is to be used predominantly from the command line in batch mode.
What it does:
1) Make a list of jpg-files
2) load each jpg and apply a predefined path (provided by an SVG-file) onto it
3) off this path a selection is made and gets inverted
4) the inverted area is filled black
5) file gets saved

There is room for improvement but basically this is my script, some parts are commented out:


#!/usr/bin/env python

from gimpfu import *
import os
import datetime

def my_function():
    path = 'G:\\to\\my\\directory'
    
    #folder_list = os.listdir(path)

    #day = datetime.datetime.today().strftime("%Y%m%d")
    # for testing set specific date for variable 'day'
    day = '20100826'		# temporarily set a specific day for testing
    datestring = path + '\\' + day

    # List of files of the current day's directory
    filelist = os.listdir(datestring)

    # filelist should contain just jpg-files.
    filelist = [ a for a in filelist if '.jpg' in a]

    pic = range(len(filelist))


    for pic in filelist:
            
            im = pdb.gimp_file_load(datestring + '\\' + pic, pic)
            pdb.gimp_vectors_import_from_file(im,
'G:\\to\\my\\directory\\thepath.svg', 1, 0)
            pdb.gimp_path_to_selection(im, 'Auswahl', 2, 0, 0, 0, 0)
            pdb.gimp_selection_invert(im)
            drawable = pdb.gimp_image_get_active_drawable(im)
            pdb.gimp_edit_fill(drawable, 0)
            pdb.gimp_image_crop(im, 1067, 1055, 296, 105)          
# to be set relative to the current image

            pdb.file_jpeg_save(im, drawable, datestring + '\\' +
pic[:-4] + '_cut.jpg', pic[:-4] + '_cut.jpg', 1, 0, 0, 0, 'none', 0,
0, 0, 0)
            
            #pdb.gimp_image_delete(gimp.image_list()[0])	    
            pdb.gimp_image_delete(im)
        
    

# registration function
register(
    "my_function",    
    "Short description",   
    "Long description",
    "Sebastian Koblinger", 
    "Sebastian Koblinger", 
    "October 2010",
    "<Image>/New Scripts/My special script", 
    "*", 
    [], 
    [],
    my_function
    )

main()



> > I guess the issues are the input paramters of the function. A function
> > requires an image and a drawable as input, am I right?
> 
> No, procedures don't require any input parameters at all. For procedures
> to be run from the image menu, it makes sense to have an image and a
> drawable parameters, but even there this is not a requirement.

Another question that keeps me busy: Are the GIMP modules available only within the GIMP-Python console? So no other console (IDLE in my case) has access to them? That would make things by far easier I guess.

Sebastian

_______________________________________________
Gimp-developer mailing list
Gimp-developer@xxxxxxxxxxxxxxxxxxxxxx
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux