1

I know you can write python scripts for GIMP and then through GIMP you can use these scripts as plug-ins but what I'm trying to achieve is to use GIMP's functions through Python as if you would use PIL or scikit-image functions through Python.I don't want to disturb my program user to actually download Gimp only to execute the one function I need from it.

Can I do such a thing ??? or I'm going too far?
If no, what is the best alternative thing I can do to force Gimp does the work undercover without disturbing the program user.in this case I think I would be forced to install GIMP within the installation process which is something I hate.

Update:-
(1) considering libgimp after googling I found this discussion.in brief words > " libgimp is just used to allow the GIMP core and it's plug-ins to communicate" so it doesn't work as I hope.
(2) I thought of accessing the GIMP code and deleting all unnecessary functions I don't need and keep the only function I'm gonna use,that would be a one function GIMP.Do you think I should do something like that?

Update:-
Yes the problem was solved but I'm still interested in using GIMP as a library by any means even if it was undercover as Marawan has suggested.Hope you can help.

Thanks.

Someone Someoneelse
  • 487
  • 2
  • 8
  • 27

2 Answers2

2

If GIMP is installed, you could try batch mode. Another alternative is to use gimp-fu.

Obviously, you cannot use GIMP if you don't have it installed. :-)

EDIT:

I thought of accessing the GIMP code and deleting all unnecessary functions I don't need and keep the only function I'm gonna use,that would be a one function GIMP.

That seems overly ambitious. The GIMP codebase is large and complicated.

As an alternative for image manipulation, you might have a look at ImageMagick with the Wand python bindings. Or the Python Imaging Library.

Roland Smith
  • 42,427
  • 3
  • 64
  • 94
1

You could use something like portable gimp: this would allow you to have gimp be shipped with your program with no additional installation required by the user. You could then have functions in your python library run gimp operations using gimp's python scripting feature. Look at this answer for an example doing this.

In the above example every call to the flip function will spawn a new gimp process and wait for it to finish executing. This can of course be slow. There are two strategies to improve the speed:

  1. Reduce gimp startup time using command line options that reduce startup time
  2. Start one gimp process at program startup. Leave it running and communicate with it using some inter-process communication technique, and send it instructions whenever you want it to execute an operation.
Community
  • 1
  • 1
Marwan Alsabbagh
  • 25,364
  • 9
  • 55
  • 65
  • +1 It worked but it takes so much time to execute the flip function you provided.Do u know why?Thanks – Someone Someoneelse Oct 26 '12 at 00:02
  • Good to hear it works. Could you time whole long it takes to call the function, i'm curious how slow it is. I'll update the answer with ways to speedup performance – Marwan Alsabbagh Oct 26 '12 at 03:28
  • almost 40 seconds elapsed since the first call till the GIMP output."I used `time.clock()` function.Mr Marwan do you think I'm going too far if I thought of deleting most of the GIMP functionality as I'm only interested in the *sharpen* filter.Thanks – Someone Someoneelse Oct 26 '12 at 07:01
  • well it shouldnt take that long. shouldnt be more then 5 seconds or so. im on vacation now, ill be back at my pc in a few days. ill give u more updates then – Marwan Alsabbagh Oct 26 '12 at 09:54
  • waiting for your help.have a nice vacation – Someone Someoneelse Oct 26 '12 at 11:14