Using gimp as server on windows

2k views Asked by At

Here is my problem.

CONTEXT

I'm building a whole system to handle images processing in my company. We are processing .psd and .cr2 file making a whole lot of differents operations (like developping .cr2 file changing exposition building image architecture with layer and so on)
As we are very young (==> very small with limited budget) we do not have a computer dedicated to image processing. But we still need quite a lot of processing. So what i did is:
I set up a NAS and then installed a little .AS3 deamon on the 3 computers of the company that have a photoshop (i just managed to do it in .as3 wich is a shame i know.
This program use the brand new "remote connection" in cs5.1 to control photoshop. Basicly the program just check in a queue if it has some work to do and if so it transmit the order to photoshop using a .jsx file.
At the end when we want to use a photoshop on a computer we just stop that deamon use photoshop and then reactivate it if we need some processing.

PROBLEM

This is working fine for now but i have a big problem : It's hard to scale this system for financial reason ==> photoshop is not free! This is a problem because scalability was an objective...

So my idea is to use Gimp in the same way. Any new computer in the company would have gimp installed and a little Python/C++/ whatever program to control it.

QUESTION

Except the fact that gimp 2.6 (2.8!!!) still has a lack of support for the layers set, i got trouble to make simple socket connection with it!
How can a program A send to Gimp a python script to process images?

1

There are 1 answers

2
jsbueno On BEST ANSWER

It can be done and it is not hard to do. What can and cannot be done from within GIMP can be seen by checking GIMP's scripting API< known as Procedural Database - You can see the available functions and usage by going to Help-> Procedure Database from within GIMP. These are available to Python on the "pdb" module, with underscores replacing dashes on the function names (and whenever the first argument is "interactive/non-interactive, ti should be omitted at all from the call)

The biggest matter is that all these functions just work from withina running instance of GIMP - importing either the gimp, gimpfu or pdb modules froma Pytho running outside GIMP wil give you an error.

On the other hand, besides GIMP's API you have at your disposal the full Python Language -with all it has on its standard libray, plus whatever third party modules you'd choose to install.

So, you can write an application that listens to XML-RPC calls, receive some text message, and "exec" this message as a script - voilá (please on do this if you absolutely trust the request source for the scripts).

Writing Python scripts for GIMP can be somewhat tricky - you are encouraged to play along using Python Console from within Gimp->filters->Python->console menu, and to check documentation and examples elsewhere (http://stackoverflow.com/questions/tagged/gimp+python ) on how these scripts are done. On the other hand, creating a xml-rpc server using Python to be run from within a GIMP plug-in is an easy thing, and even the official Python docs can give you an example: http://docs.python.org/library/simplexmlrpcserver.html

You should create your "xml-rpc script server" as a GIMP-Python plug-in, and start GIMP with a command line like gimp -i -b (python-fu-myserverplugin ) to get it running.