User Tools

Site Tools


cs:scripting_gimp

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
cs:scripting_gimp [2020/09/01 02:42]
paolo_bolzoni Created
cs:scripting_gimp [2020/09/01 10:14] (current)
paolo_bolzoni
Line 7: Line 7:
 Gimp also allows to use scripting in Scheme or Python2 to add functionalities,​ and most of the tutorial one can find on the web are directed to this idea: to have a new element in the menus that give you the functions you implemented yourself. Gimp also allows to use scripting in Scheme or Python2 to add functionalities,​ and most of the tutorial one can find on the web are directed to this idea: to have a new element in the menus that give you the functions you implemented yourself.
  
-In this page instead we focus on how to call your functions from the command line to apply in bulk to many pictures.+In this page instead we focus on how to call your functions from the command line to apply them in bulk to many pictures.
  
  
Line 13: Line 13:
 ===== Intro ===== ===== Intro =====
  
-The main obstacle is the Gimp scripts are meant to be called //from inside// Gimp. In the normal python2 interpreter the call ''​from gimpfu import *''​ will normally ​fail.+The main obstacle is that Gimp scripts are meant to be called //from inside// Gimp. In the normal python2 interpreter the call ''​from gimpfu import *''​ will fail.
  
 To make Gimp load our script we need to embed a bit of python code in the command line. To make Gimp load our script we need to embed a bit of python code in the command line.
Line 22: Line 22:
  
   * ''​-idf''​ starts Gimp with no GUI (''​-i''​) and skips loading "​data"​ (brushes, patterns, ...) and fonts (''​-df''​),​   * ''​-idf''​ starts Gimp with no GUI (''​-i''​) and skips loading "​data"​ (brushes, patterns, ...) and fonts (''​-df''​),​
-  * ''​--batch-interpreter python-fu-eval''​ tells Gimp that we want to script in Python2 ​(Gimp3 will use python3, but for now...),+  * ''​--batch-interpreter python-fu-eval''​ tells Gimp that we want to script in python2 ​(Gimp3 will use python3, but for now...),
   * ''​-b''​ execute the script in quotes.   * ''​-b''​ execute the script in quotes.
  
Line 29: Line 29:
 ==== What functions should I call? ==== ==== What functions should I call? ====
  
-In Gimp is the documentation of all the functions ​you can use. The documentation is in the **Help**->​**Procedure browser**. Usually the functions are called ​in quite straightforward manner; seek for the name you find in the menus or the name of the menus themselves. For example, if you want the artistic filter "​cubism", ​searching for cubism gives ''​plug-in-cubism''​.+In Gimp is the documentation of all the functions ​one can use. The documentation is in the **Help**->​**Procedure browser**. Usually the functions are named in quite straightforward manner; seek for the name you find in the menus or the name of the menus themselves. For example, if you want the artistic filter "​cubism", ​typing ''​cubism'' ​gives ''​plug-in-cubism''​.
  
-To call the procedures one need to know that, in python2, the functions are under the object ''​pdb''​ (procedures database), the hyphens in the name are replaced with underscores,​ and the parameter ''​run-mode''​ has to be skipped ​for it is implicit.+To call the procedures one need to know that, in python2, the functions are under the object ''​pdb''​ (procedures database), the hyphens in the name are replaced with underscores,​ and the parameter ''​run-mode''​ has to be skipped ​because ​it is implicit.
  
 ==== What is a drawable? ==== ==== What is a drawable? ====
Line 84: Line 84:
  
 [[https://​www.gimp.org/​docs/​python/​index.html|Gimp documentation]] [[https://​www.gimp.org/​docs/​python/​index.html|Gimp documentation]]
 +[[https://​stackoverflow.com/​questions/​44430081/​how-to-run-python-scripts-using-gimpfu-from-command-line#​44435560|Stack overflow answer with the original script]]
cs/scripting_gimp.1598928124.txt.gz ยท Last modified: 2020/09/01 02:42 by paolo_bolzoni