batch mode in gimp?
This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.
This is a read-only list on gimpusers.com so this discussion thread is read-only, too.
batch mode in gimp? | Josef Wolf | 01 Aug 14:10 |
batch mode in gimp? | Jehan Pagès | 01 Aug 15:32 |
batch mode in gimp? | Josef Wolf | 02 Aug 08:37 |
batch mode in gimp? | Maurizio Loreti | 02 Aug 08:56 |
batch mode in gimp? | Paul Cartwright | 02 Aug 12:22 |
batch mode in gimp? | Maurizio Loreti | 02 Aug 13:00 |
batch mode in gimp? | Ofnuts | 02 Aug 18:24 |
batch mode in gimp? | Josef Wolf | 02 Aug 12:48 |
batch mode in gimp? | Ofnuts | 01 Aug 19:44 |
batch mode in gimp? | Josef Wolf | 02 Aug 08:47 |
batch mode in gimp? | Ofnuts | 02 Aug 18:18 |
batch mode in gimp? | Brendan Scott | 02 Aug 22:28 |
batch mode in gimp? | Josef Wolf | 03 Aug 09:57 |
batch mode in gimp? | Ofnuts | 03 Aug 11:17 |
batch mode in gimp? | Grue | 03 Aug 12:37 |
batch mode in gimp? | Kevin Cozens | 03 Aug 16:21 |
batch mode in gimp? | Josef Wolf | 05 Aug 13:46 |
batch mode in gimp? | Kevin Cozens | 03 Aug 16:12 |
batch mode in gimp?
Hello,
I am trying to use gimp in batch mode. Unfortunately, I can't find any examples of how to do _real_ batch processing. All the examples on the net show how to integrate into the gui.
I see that I can use the -b flag to invoke script-fu functions. But AFAICS, the script with the function definitions needs to reside somewhere in ~/gimp-x.y/scripts or something.
In addition, I can't find a way to pass command line arguments to the called functions.
Is there any way to define/execute functions? For example, I'd like to call simple-unsharp-mask from http://www.gimp.org/tutorials/Basic_Batch/ like this:
$ call-gimp-function script.scm simple-unsharp-mask file.png 5.0 0.5 0
Is there any way to achieve this? Any hints?
Josef Wolf jw@raven.inka.de
batch mode in gimp?
Hello,
You can do it this way. Tested by myself right now and working well:
$ gimp-2.9 -i -d -f -s -b "`cat script.scm` (simple-unsharp-mask \"file.png\" 5.0 0.5 0)" -b '(gimp-quit 0)'
So basically you could have your small shell script call-gimp-function with the following code inside:
------------------------------------------------------ #!/bin/sh
gimp-2.9 -i -d -f -s -b "`cat \"$1\"` $2" -b '(gimp-quit 0)' ------------------------------------------------------
Then you can call it this way: $ ./call-gimp-function script.scm "(simple-unsharp-mask \"file.png\" 5.0 0.5 0)"
I think it should work well even if there are double quotes in the definition script because I think cat escapes them before feeding the contents to the main command.
Enjoy!
Jehan
P.S.: don't forget to replace gimp-2.9 in the script with your version and to make your script executable.
On Fri, Aug 2, 2013 at 2:10 AM, Josef Wolf wrote:
Hello,
I am trying to use gimp in batch mode. Unfortunately, I can't find any examples of how to do _real_ batch processing. All the examples on the net show how to integrate into the gui.
I see that I can use the -b flag to invoke script-fu functions. But AFAICS, the script with the function definitions needs to reside somewhere in ~/gimp-x.y/scripts or something.
In addition, I can't find a way to pass command line arguments to the called functions.
Is there any way to define/execute functions? For example, I'd like to call simple-unsharp-mask from http://www.gimp.org/tutorials/Basic_Batch/ like this:
$ call-gimp-function script.scm simple-unsharp-mask file.png 5.0 0.5 0
Is there any way to achieve this? Any hints?
-- Josef Wolf
jw@raven.inka.de
_______________________________________________ gimp-user-list mailing list
List address: gimp-user-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list
batch mode in gimp?
On 08/01/2013 04:10 PM, Josef Wolf wrote:
Hello,
I am trying to use gimp in batch mode. Unfortunately, I can't find any examples of how to do _real_ batch processing. All the examples on the net show how to integrate into the gui.
I see that I can use the -b flag to invoke script-fu functions. But AFAICS, the script with the function definitions needs to reside somewhere in ~/gimp-x.y/scripts or something.
In addition, I can't find a way to pass command line arguments to the called functions.
Is there any way to define/execute functions? For example, I'd like to call simple-unsharp-mask from http://www.gimp.org/tutorials/Basic_Batch/ like this:
$ call-gimp-function script.scm simple-unsharp-mask file.png 5.0 0.5 0
Is there any way to achieve this? Any hints?
For such simple processing, you should consider using ImageMagick. Here
my script that, for all the files in the directory:
- boosts the saturation a bit
- reduces the files to 3000px wide
- sharpens a bit
- saves with quality 85
--------------------------------
#! /bin/bash
dir=${1:-.}
for f in "$dir/"*.JPG;
do
echo "Exporting $f"
convert "$f" -modulate 100,120 -geometry 3000 -sharpen 0x1.0
-quality 85 "$dir/$(basename "$f" .JPG).jpg"
done
--------------------------------
Runs in about 5 seconds/file (on 12Mpx source files) on my PC (Core i5-3320M CPU @ 2.60GHz, Ubuntu AMD64)
If you insist in using Gimp for this, PM me and I'll send you a sample batch script (uses Python) with sample command lines for Linux and Windows
batch mode in gimp?
On Fr, Aug 02, 2013 at 03:32:55 +1200, Jehan Pags wrote:
You can do it this way. Tested by myself right now and working well:
$ gimp-2.9 -i -d -f -s -b "`cat script.scm` (simple-unsharp-mask \"file.png\" 5.0 0.5 0)" -b '(gimp-quit 0)'
So basically you could have your small shell script call-gimp-function with the following code inside:
------------------------------------------------------ #!/bin/sh
gimp-2.9 -i -d -f -s -b "`cat \"$1\"` $2" -b '(gimp-quit 0)' ------------------------------------------------------
Then you can call it this way: $ ./call-gimp-function script.scm "(simple-unsharp-mask \"file.png\" 5.0 0.5 0)"
Thanks for your suggestion, Jehan!
In fact, that's what I'm currently doing. But I thought there must be a better way, since this is very prone to quoting errors. I got hidden badly when I tried to pass a color definition as a quoted scheme list =:8O
I think it should work well even if there are double quotes in the definition script because I think cat escapes them before feeding the contents to the main command.
I'd rather redirect stdin instead of using cat.
PS: where can I find information about how to access operating system (files, directories, environment, etc) from script-fu? I've been searching for TinyScheme ducumentation but could not find anyting. There seems to be something like txn extensions and re extensions. But they don't seem to be available from script-fu? Any hints?
Josef Wolf jw@raven.inka.de
batch mode in gimp?
On Do, Aug 01, 2013 at 09:44:59 +0200, Ofnuts wrote:
For such simple processing, you should consider using ImageMagick.
Thanks for the pointer, Ofnuts!
I am currently using IM. But my processing got so complicated, including various levels of quoting through muiltiple levels of schell scripts.
I have a strong feeling that it is time for me to switch to a real, reliable programming language, which script-fu would be (so I hope).
Josef Wolf jw@raven.inka.de
batch mode in gimp?
IMHO, the best candidate for these repetitive jobs is ImageMagick - as suggested before by ofnuts. Or with a shell script invoking "convert" (as shown in the example) or (if you have some programming experience) with a simple C program using the Magick shared library. In this way i wrote a simple program to resize images, adjusting the quality in order to generate a file not bigger than a specified limit.
On Fri, Aug 2, 2013 at 10:37 AM, Josef Wolf wrote:
On Fr, Aug 02, 2013 at 03:32:55 +1200, Jehan Pags wrote:
You can do it this way. Tested by myself right now and working well:
$ gimp-2.9 -i -d -f -s -b "`cat script.scm` (simple-unsharp-mask \"file.png\" 5.0 0.5 0)" -b '(gimp-quit 0)'
So basically you could have your small shell script call-gimp-function with the following code inside:
------------------------------------------------------ #!/bin/sh
gimp-2.9 -i -d -f -s -b "`cat \"$1\"` $2" -b '(gimp-quit 0)' ------------------------------------------------------
Then you can call it this way: $ ./call-gimp-function script.scm "(simple-unsharp-mask \"file.png\" 5.0
0.5 0)"
Thanks for your suggestion, Jehan!
In fact, that's what I'm currently doing. But I thought there must be a better
way, since this is very prone to quoting errors. I got hidden badly when I tried to pass a color definition as a quoted scheme list =:8OI think it should work well even if there are double quotes in the definition script because I think cat escapes them before feeding the contents to the main command.
I'd rather redirect stdin instead of using cat.
PS: where can I find information about how to access operating system (files,
directories, environment, etc) from script-fu? I've been searching for TinyScheme ducumentation but could not find anyting. There seems to be something like txn extensions and re extensions. But they don't seem to be available from script-fu? Any hints?-- Josef Wolf
jw@raven.inka.de
_______________________________________________ gimp-user-list mailing list
List address: gimp-user-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list
(@_ | //\ | Maurizio Loreti - Fisico in pensione, nonno felice di V_/_ | due nipotini, vagabondo e fotografo a tempo perso...
batch mode in gimp?
On 08/02/2013 04:56 AM, Maurizio Loreti wrote:
IMHO, the best candidate for these repetitive jobs is ImageMagick - as suggested before by ofnuts. Or with a shell script invoking "convert" (as shown in the example) or (if you have some programming experience) with a simple C program using the Magick shared library. In this way i wrote a simple program to resize images, adjusting the quality in order to generate a file not bigger than a specified limit.
I would be interested in a script that does resizing.. I do that on most of my images to send in email & add to web pages.. Sometimes I use my Samsung Galaxy camera, other times my Nikon & raw images.. I'm pretty good with shell scripts, if I have a template:)
Paul Cartwright
batch mode in gimp?
On Fr, Aug 02, 2013 at 10:56:14 +0200, Maurizio Loreti wrote:
IMHO, the best candidate for these repetitive jobs is ImageMagick - as suggested before by ofnuts.
I agree with this -- as long as your operations are simple.
But when your operations get more complex and involve things like like stacking, multiple layers, etc/pp, things get very complicated because the expressiveness and syntax/semantics are very limited by convert's very limited command line interface.
Josef Wolf jw@raven.inka.de
batch mode in gimp?
On Fri, Aug 2, 2013 at 2:22 PM, Paul Cartwright wrote:
On 08/02/2013 04:56 AM, Maurizio Loreti wrote: I would be interested in a script that does resizing.. I do that on most of my images to send in email & add to web pages.. Sometimes I use my Samsung Galaxy camera, other times my Nikon & raw images.. I'm pretty good with shell scripts, if I have a template:)
It is not a shell script, but c C++ program using the Magick++ library. You may fine the program opening the following directory on Google Documents:
and entering the subdirectory "photo batch resizing". GPL license; enjoy!
P.S.: you will need the Magick++ shared library and the GNU getopt library; read the enclosed man page, or the README.pdf file.
(@_ | //\ | Maurizio Loreti - Fisico in pensione, nonno felice di V_/_ | due nipotini, vagabondo e fotografo a tempo perso...
batch mode in gimp?
On 08/02/2013 10:47 AM, Josef Wolf wrote:
On Do, Aug 01, 2013 at 09:44:59 +0200, Ofnuts wrote:
For such simple processing, you should consider using ImageMagick.
Thanks for the pointer, Ofnuts!
I am currently using IM. But my processing got so complicated, including various levels of quoting through muiltiple levels of schell scripts.
I have a strong feeling that it is time for me to switch to a real, reliable programming language, which script-fu would be (so I hope).
At the risk of raising some eyebrows, better switch to python. You'll find more uses for it outside of Gimp, and inside Gimp you can do more things with it than with script-fu (like create your own dialogs...). It is also a thousand times more readable.
batch mode in gimp?
On 08/02/2013 02:22 PM, Paul Cartwright wrote:
I would be interested in a script that does resizing.. I do that on most of my images to send in email & add to web pages.. Sometimes I use my Samsung Galaxy camera, other times my Nikon & raw images.. I'm pretty good with shell scripts, if I have a template:)
batch mode in gimp?
On 08/03/2013 04:18 AM, Ofnuts wrote:
On 08/02/2013 10:47 AM, Josef Wolf wrote:
On Do, Aug 01, 2013 at 09:44:59 +0200, Ofnuts wrote:
[]
I have a strong feeling that it is time for me to switch to a real, reliable programming language, which script-fu would be (so I hope).
At the risk of raising some eyebrows, better switch to python. You'll find more uses for it outside of Gimp, and inside Gimp you can do more things with it than with script-fu (like create your own dialogs...). It is also a thousand times more readable.
+1
batch mode in gimp?
On Fr, Aug 02, 2013 at 08:18:58 +0200, Ofnuts wrote:
On 08/02/2013 10:47 AM, Josef Wolf wrote:
On Do, Aug 01, 2013 at 09:44:59 +0200, Ofnuts wrote:
For such simple processing, you should consider using ImageMagick.
Thanks for the pointer, Ofnuts!
I am currently using IM. But my processing got so complicated, including various levels of quoting through muiltiple levels of schell scripts.
I have a strong feeling that it is time for me to switch to a real, reliable programming language, which script-fu would be (so I hope).
At the risk of raising some eyebrows, better switch to python. You'll find more uses for it outside of Gimp,
I know python and I know scheme (and a lot of other languages, if that matters). Granted, I don't know the scheme dialect used by gimp. I'd rather use any lisp dialect in favour of python. I started to learn python, but I broke, since I just can't get used to python's lambda's. Due to the indentation syntax, defining lambda's seems to be very ambiguous to me.
OTOH, I'd probably never need lambdas for picture manipulation 8-)
What about perl? how stable are perl's bindings to gimp?
and inside Gimp you
can do more things with it than with script-fu (like create your own dialogs...). It is also a thousand times more readable.
Ough? Isn't script-fu the _primary_ scripting language for gimp? How comes that python, which is working on top of the primary language can be more reliable than the primary language?
Maybe my best bet would be cl-magick? Unfortunately, all the links on http://common-lisp.net/project/cl-magick/ seem to be dead :-(
Josef Wolf jw@raven.inka.de
batch mode in gimp?
On 08/03/2013 11:57 AM, Josef Wolf wrote:
On Fr, Aug 02, 2013 at 08:18:58 +0200, Ofnuts wrote:
On 08/02/2013 10:47 AM, Josef Wolf wrote:
On Do, Aug 01, 2013 at 09:44:59 +0200, Ofnuts wrote:
For such simple processing, you should consider using ImageMagick.
Thanks for the pointer, Ofnuts!
I am currently using IM. But my processing got so complicated, including various levels of quoting through muiltiple levels of schell scripts.
I have a strong feeling that it is time for me to switch to a real, reliable programming language, which script-fu would be (so I hope).
At the risk of raising some eyebrows, better switch to python. You'll find more uses for it outside of Gimp,
I know python and I know scheme (and a lot of other languages, if that matters). Granted, I don't know the scheme dialect used by gimp. I'd rather use any lisp dialect in favour of python. I started to learn python, but I broke, since I just can't get used to python's lambda's. Due to the indentation syntax, defining lambda's seems to be very ambiguous to me.
OTOH, I'd probably never need lambdas for picture manipulation 8-)
What about perl? how stable are perl's bindings to gimp?
I don't think anyone is still using them these days.
and inside Gimp you
can do more things with it than with script-fu (like create your own dialogs...). It is also a thousand times more readable.Ough? Isn't script-fu the _primary_ scripting language for gimp? How comes that python, which is working on top of the primary language can be more reliable than the primary language?
Define "primary". Historically first, yes... but all script-fu bindings are also availabe as python-fu ones, and the python interpreter you use has likely several millions more lines of code executed under its belt than Scheme, so its stability cannot really be a concern. Python-fu isn't written on top of Scheme but on the side... And just in case, I said 'readable', not 'reliable'... for instance in Python you can access some member of an aggregate using mnemonic names and not random bursts of C,A,D,R,(,)
Maybe my best bet would be cl-magick? Unfortunately, all the links on http://common-lisp.net/project/cl-magick/ seem to be dead :-(
Not sure that would be a significant progress...
- postings
- 9
batch mode in gimp?
I know python and I know scheme (and a lot of other languages, if that matters). Granted, I don't know the scheme dialect used by gimp. I'd rather use any lisp dialect in favour of python. I started to learn
python, but I broke, since I just can't get used to python's lambda's. Due to
the indentation syntax, defining lambda's seems to be very ambiguous to me.OTOH, I'd probably never need lambdas for picture manipulation 8-)
I'm a Python programmer by trade, and I develop my scripts in Script-Fu. It has numerous advantages over Python, such as being truly dynamic (you can refresh your scripts without restarting GIMP), better console (Python's indentation is hell), and like you noticed it has real lambdas. The scheme interpreter used by GIMP also has macros, which can be used to eliminate repetitive code. Script-Fu API is also more consistent than Python's (almost everything is an integer, and all gimp library functions return a list of return values), so Procedure Browser is also a complete documentation of the library.
Granted, it would be nice if GIMP included a more powerful Lisp (such as ECL, Embeddable Common Lisp), but Script-Fu's Tinyscheme is surprisingly fun to program in.
batch mode in gimp?
On 13-08-03 05:57 AM, Josef Wolf wrote:
I know python and I know scheme (and a lot of other languages, if that matters). Granted, I don't know the scheme dialect used by gimp. I'd rather use any lisp dialect in favour of python. I started to learn python, but I broke, since I just can't get used to python's lambda's. Due to the indentation syntax, defining lambda's seems to be very ambiguous to me.
If you know Scheme then you know the Scheme of Script-Fu. The TinyScheme interpreter used in Script-Fu follows the official Scheme standard as documented in the R5RS but it is not a full implementation of R5RS.
I finally started learning to work with Python by writing a new GUI for avrdude using wxGlade and wxPython. I don't find using indentation in Python to be much of a problem (so far) but doing the GUI doesn't use much of Python. I might have more issues with it when I do something more complicated. The general rule seems to be that you indent anywhere you would have used { } if one was writing in C.
What about perl? how stable are perl's bindings to gimp?
They are so stable you could measure the dust that has settled on the bindings in inches. ;)
The gimp-perl binding is in need of a lot of TLC. It really needs a complete overhaul. It has not been kept up-to-date with changes in GIMP. I have too many other projects on my plate so I haven't touched the Perl binding in a long time.
Isn't script-fu the _primary_ scripting language for gimp? How comes that python, which is working on top of the primary language can be more reliable than the primary language?
Script-Fu has been part of GIMP for many years. Whatever operating system you are running when you use GIMP, Script-Fu is there. Other bindings, such as Python, rely on external programs or packages (e.g. a Python interpreter). Some operating systems ship with Python already installed and some do not (or have not in the past). That has been addressed in some cases by the GIMP installer including the option to install Python if a user needs it.
The Python, Perl, and Ruby language bindings (to name three bindings) do not operate on top of Script-Fu. They are completely independent of Script-Fu. Any language binding can still invoke a procedure supplied as part of Script-Fu if desired.
Maybe my best bet would be cl-magick? Unfortunately, all the links on http://common-lisp.net/project/cl-magick/ seem to be dead :-(
The top two links from a simple search using Google returned: http://common-lisp.net/project/cl-magick/ http://www.cliki.net/cl-magick
Cheers! Kevin. http://www.ve3syb.ca/ |"Nerds make the shiny things that distract Owner of Elecraft K2 #2172 | the mouth-breathers, and that's why we're | powerful!" #include | --Chris Hardwick
batch mode in gimp?
On 13-08-03 08:37 AM, Grue wrote:
Script-Fu API is also more consistent than Python's (almost everything is an integer, and all gimp library functions return a list of return values), so Procedure Browser is also a complete documentation of the library.
There are a couple of minor points one has to keep in mind when reading the information provided by the PDB while working on SF scripts. Apart from that, the procedure browser does provide a (mostly?) complete documentation of the library.
Granted, it would be nice if GIMP included a more powerful Lisp (such as ECL, Embeddable Common Lisp), but Script-Fu's Tinyscheme is surprisingly fun to program in.
There have been discussions where people have said GIMP should use a more complete Scheme implementation. Guile was mentioned in particular in those discussions. SF has tried to stay small by using a small Scheme interpreter. It let's you automate tasks in GIMP and you can do some reasonably complex tasks. However, it does have its limitations and there are times when a more full featured programming language is useful. To that end, there other language bindings available one can use.
Cheers! Kevin. http://www.ve3syb.ca/ |"Nerds make the shiny things that distract Owner of Elecraft K2 #2172 | the mouth-breathers, and that's why we're | powerful!" #include | --Chris Hardwick
batch mode in gimp?
On Sa, Aug 03, 2013 at 12:21:54 -0400, Kevin Cozens wrote:
Granted, it would be nice if GIMP included a more powerful Lisp (such as ECL, Embeddable Common Lisp), but Script-Fu's Tinyscheme is surprisingly fun to program in.
There have been discussions where people have said GIMP should use a more complete Scheme implementation. Guile was mentioned in particular in those discussions. SF has tried to stay small by using a small Scheme interpreter. It let's you automate tasks in GIMP and you can do some reasonably complex tasks. However, it does have its limitations and there are times when a more full featured programming language is useful. To that end, there other language bindings available one can use.
Probably I mis-understand some important aspects. But for me it seems that embedding a language into gimp is doomed to deliver suboptimal functionality. IMHO, the better way would be to provide libraries that can be used by any language. That way one could combine the functionality offered by the library with any other functionality that is offered by the language of choice.
Josef Wolf jw@raven.inka.de