Writing GIMP scripts and plugins

Video thumbnail (Frame 0) Video thumbnail (Frame 562) Video thumbnail (Frame 1235) Video thumbnail (Frame 3857) Video thumbnail (Frame 5133) Video thumbnail (Frame 6037) Video thumbnail (Frame 6788) Video thumbnail (Frame 7453) Video thumbnail (Frame 8155) Video thumbnail (Frame 8920) Video thumbnail (Frame 9680) Video thumbnail (Frame 10420) Video thumbnail (Frame 11407) Video thumbnail (Frame 12730) Video thumbnail (Frame 13788) Video thumbnail (Frame 14345) Video thumbnail (Frame 15795) Video thumbnail (Frame 16523) Video thumbnail (Frame 17115) Video thumbnail (Frame 17850) Video thumbnail (Frame 18748) Video thumbnail (Frame 20110) Video thumbnail (Frame 21815) Video thumbnail (Frame 23553) Video thumbnail (Frame 24168) Video thumbnail (Frame 25025) Video thumbnail (Frame 26245) Video thumbnail (Frame 27565) Video thumbnail (Frame 28105) Video thumbnail (Frame 29595) Video thumbnail (Frame 31112) Video thumbnail (Frame 32420) Video thumbnail (Frame 33187) Video thumbnail (Frame 34480)
Video in TIB AV-Portal: Writing GIMP scripts and plugins

Formal Metadata

Writing GIMP scripts and plugins
Title of Series
Part Number
Number of Parts
CC Attribution - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this license.
Release Date

Content Metadata

Subject Area
Much of the power of GIMP comes from its plug-in architecture. Most of the functions you use in GIMP, including everything in the Filters menu, are implemented as plug-ins. Happily, writing GIMP plug-ins is easy. This talk will show you how to write new plug-ins or extend existing ones in two languages: Script-fu and Python
Keywords Libre Graphics Meeting (LGM)
Scripting language Programming language Computer animation Bit rate Meeting/Interview Different (Kate Ryan album) Electronic mailing list Bit Complete metric space Hydraulic jump
Scripting language Medical imaging Functional (mathematics) Inverter (logic gate)
Scripting language Information Online help Instance (computer science) Parameter (computer programming) Function (mathematics) Functional (mathematics) Web 2.0 Medical imaging Type theory Voting String (computer science) output Window Inverter (logic gate) Plug-in (computing)
Scripting language Category of being Programming language Database normalization Computer animation Different (Kate Ryan album) Planning Data conversion Directory service Plug-in (computing) Window Physical system
Web 2.0 Email Computer animation Multiplication sign Plug-in (computing)
Medical imaging Mathematics Multiplication sign Number
Computer animation Different (Kate Ryan album) Electronic mailing list Complete metric space Plug-in (computing)
Texture mapping Sampling (statistics) Line (geometry) Graph coloring Field (computer science) Number Type theory String (computer science) Single-precision floating-point format Cuboid Integer Arrow of time Plug-in (computing)
Medical imaging Mapping Graph coloring
Boolean algebra Medical imaging Multiplication Computer file Divisor Computer configuration Cuboid Drop (liquid) Directory service Menu (computing)
User interface Module (mathematics) Pixel Dialect Computer animation Pattern language Quicksort Object (grammar) Drop (liquid) Computer font Pressure Food energy
Module (mathematics) Scripting language Functional (mathematics) Electronic mailing list Database Online help Menu (computing) Web browser Graph coloring Functional (mathematics) Medical imaging Computer animation Personal digital assistant Self-organization Procedural programming Object (grammar) Marginal distribution
Medical imaging Computer animation Different (Kate Ryan album) Computer configuration Electronic mailing list Parameter (computer programming) Acoustic shadow Drop (liquid) Web browser Procedural programming Graph coloring
Scripting language Default (computer science) Bit Parameter (computer programming) Instance (computer science) Mathematics Differenz <Mathematik> Arithmetic mean Computer configuration Personal digital assistant Error message Plug-in (computing) Asynchronous Transfer Mode
Revision control Computer animation Meeting/Interview Network topology Website Quicksort
Scripting language Pairwise comparison Medical imaging Pixel Direction (geometry) Multiplication sign Selectivity (electronic) Instance (computer science) Quicksort Plug-in (computing)
Medical imaging Pixel Goodness of fit Computer animation Multiplication sign Direction (geometry) Search tree Source code Selectivity (electronic)
Revision control Complex (psychology) Medical imaging Pixel Touchscreen Computer file Code Bit Directory service Window
Scripting language Computer animation State of matter Hypermedia Computer configuration Source code Online help Compiler
Human migration Scripting language Revision control Point (geometry) Programming language Dialect Computer animation Sampling (statistics) Numbering scheme System call
Scripting language Programming language Computer animation Profil (magazine) Menu (computing) Image registration
Graph (mathematics) Electronic mailing list Damping Parameter (computer programming) Graph coloring
Scripting language Wave Variable (mathematics) Spectrum (functional analysis)
Scripting language Programming language Functional (mathematics) Software developer Gradient Electronic mailing list Content (media) Functional (mathematics) Computer programming Element (mathematics) Medical imaging Type theory Computer animation Positional notation Interpreter (computing) Error message Address space Social class
Scripting language Loop (music) Computer animation Software testing Selectivity (electronic) Variable (mathematics) Error message Product (business)
Scripting language Computer animation Multiplication sign Set (mathematics) Text editor Line (geometry) Number
Scripting language Wiki Windows Registry Googol Computer animation Source code Electronic program guide Electronic mailing list Sampling (statistics) Damping Plug-in (computing) Number
Point (geometry) Scripting language Slide rule Computer animation Link (knot theory) Bit rate Length Source code Sampling (statistics) Web browser Plug-in (computing)
Scripting language Multiplication sign 1 (number) Connected space Revision control Digital photography Component-based software engineering Meeting/Interview Ontology Network topology Software testing Game theory Quicksort Tuple Position operator
we you will be talking about how rate again description for
a given and Gintis scriptable and lots of different languages this is not a complete list but I'll be
talking mostly about Python and a little bit about script and the jump right into my thought because that's really the easiest way of stripping down a minimal
Python script is very simple doesn't do very much inverts the current layer but it shows you have to register has set up in the menus I'll go through it begins module basically imports everything you need so that's the only thing you need you need a function that does something usually will be a bit longer than this 1 you
need to call register this is the thing that tells calcium where you're what image function is world going the
menus the new for the function short help
long-held and some copyright information who wrote the plug-in and when finally you need to work the name will be and many others so when you search for it it call itself gives you know there's an old way of registering in the menus and you'll see this a lot in old against script so if you don't want a script from the web you'll see the full many us because in the image window and then in voters enhanced and I'm on about Italian not to do this is deprecated but you'll see a lot and it is a pretty simple way registering if the image runs on if if the plug-in runs on an image for instance you're going to take an image inverted like this 1 would do that you need to explain what kind of images you're working on you work on RGB images indexed images grayscale you can use a star to indicate all types of images or you can create a new image not work on a and just with the string blank you can have input and output parameters all talk a lot more about input parameters output parameters are for plug-ins that actually return a value that is that may be of use to other plug-ins but you almost never see that so we will be talking about that at all the name of the function which refers back to the function in the defined earlier and once you've written of the plug-in
gifted put it somewhere and you have to figure out where to put on Linux that's just your home directory get 2 . 6 or whatever the conversion is select it's a place but when you write a plug-in you often want distributed to other people and some of them are running Linux you need to tell them where to find their get profile so began preferences directory has a plug-ins category under folders it tells you where to find what the system plug-ins and your own plug-ins directory where you can install new plants so this this is what I was told Windows and Mac people when they need to find out where the problems are so was
the difference between a script and plug technically a script is just something written script script was built and again in run anywhere a plane is run as a separate process it might be written in Python might be redundancy Ruby or something else so even if it's in a scripting language it's technically applied but you also see people say scripts to offer a python scripts were or Ruby or other scripting languages whatever that means something that's not compiled and I'm not consistent about this myself
and nobody else seems to be no plug-ins you have
to be executable I see people running into the struggle all the time so when you distribute your plugin even if you know this yourself even if this is totally obvious you don't forget to tell your users to make it executable when they downloaded from the web it won't be and then you get lots of e-mails asking about for plug-ins have to restart again every time you
change every time you add a new plug-in or every time you change the way registers and what so this is a simple
plugin dialog know how much stuff my example plug and of course didn't do anything with this number so it asked for a number and then adjust adversely image but money on a normal and you would have a lot more
stuff and there are lots of different things you can asked for
plug-ins this is a pretty much a complete list of everything you can ask for in Python there are about 3 others that aid England in this dialog because they're not well-supported not documented you don't really see anything useful in the following dialog so
go through that I appear and meaning obviously an integer in my sample plugin that was just a text field that let me type in a number of most users don't want that they want spend box with up and down arrows or they want slider and you can do this to you can also type in a single line of text string wore a multi-line text field multi-line texture you can have been
boxes and letters of course you can of color clickers
click on the button and the normal give color picker comes up and you can drive around and just use saturation value you can also select items
within again images layers channels troubles and that's really useful during a plug-in like but map were any kind of map like that where you might have a layer even another image that applies to the image working on using have you can
add Booleans you can have a multi valued options so you know you can have a mel-scale of course and specify which 1 is going to be chosen by default either with a radio box or with the drop menu and you can have a file and directory
factors which is useful if you want to have something that region of Ireland as something to our reason image
and of course fonts pressures patterns all that sort of thing oral chaseable so that planning dialogs make this really easy to do you don't have to write your own user interface for any of this stuff no when your
permanent Python is pretty object-oriented you have an object for the energy of an object 4 layers which inherits from the drawable object a drop goal is just a layer or a channel something you can draw and the objects for channel styles and pixel regions of talk more about this later and into modules that are very important in the PDB module in again module so in practice
a Python script that actually does something useful might look more like this will be hard to read so the giver modules which you used to create a new image created new layer set the foreground and background color and it has some of the useful items you can you can do with that linked to the documentation where you can get a complete list of what these objects will do you can also add a layer image once you have and once you've created a layer but the most important module really is the PDB marginal PDP stands for procedural database and that's where almost all of the functions with indium reside so embedded fill in this case if gonna fill layer it is created so how do you find all these
functions fortunately jump in its help menu has something called procedure browser that lets you search for any PDB function that's available to any of your organs so the search for
fellow you'll find 5 different FIL options give that felt is the 1 that you use if you're using can be interactively and you did it again in a new and safer with foreground color filled with background color or whatever you can see all the parameters there you have to scroll sideways unfortunately you is a little a little tricky there
and you can you can search for drop shadow it gives you a long list of parameters and sometimes it gives you use a chance like if you look at that layer it will tell you but if you look at where create layer New it'll tell you you have to add it to the image after you created which might not otherwise so the procedure browser is really great when you're developing scripts and
how do you turn those parameters into Python that's a little bit tricky because the parameters are actually set up for script food which means they have dashes in them and they have they have various options that don't quite translated by 5 like most of them start with a
parameter called run mode which he just ignore when year when you're translating into Python the dachshunds of course would mean subtraction in Python so changes to underscore and in a lot of cases where there is for instance a default parameter that where it says pass minus 1 for instance for the default past 9 instead in Python and there are a few other cultures like that so developing Python plug-ins sometimes takes a little practice and a little trial and error and a little bit of copying from existing Python scripts there is documentation
random dot org if you google for documentation
and Python you'll probably find an earlier version of this on another site it sort of scattered around there are lots of copies the best documentation is actually and again get tree because this pipeline is being actively developed and it's being improved with every version no 1 great
thing about my son compare descriptor food is that you can use the full python gtk toolkit so you can write your own dialog so you can write your own fancy UI if you want have a good preview you can do it and you can also get direct pixel access to images you can look over pixels pretty fast which you would never wanted you a script for so for instance this is a simple plugin
that do our there wrote a few years ago you know what was going is that which it monitors the size of the selection it pulls every 200 milliseconds or something like that and if the selection size is changed it updates the dialog and most of the the time you will want to do that but it's a great illustration of the sorts of things you can do with Python and this is pretty much how you would do
something like that you add a time out you check for the selection and then uses the text in your dialog so very straightforward direct pixel manipulation
it's almost as fast as C for doing these things there are a couple of good examples world attention is an against source it's not actually installed in but it's and against source so if you get a search tree you look at the source online you can see it as an example of how to read and write pixels in your image it does
that basically and the code is a little bit complexity does not fit on the screen and I am not going to read it to you but this is also another example
a different way of reading from pixel images is a a plug-in hierarchical layer which spends text in hour because there's actually surprisingly no good way of doing that inherently down and I were 1st in C and I got tired of Windows people saying I installed it see file in my plug directory and it doesn't run so tried writing in Python knowing it would be slow and I was little and I tried if you different ways and begin our with with a really fast way and this is about 95 per cent of the speed of the C version in it's amazingly fast if you do it the right way very fast and so
States may not be able to run but they can slow the really fast but I does disadvantages
even all although I found this kind of help the and stole this . se violent it doesn't run problem you don't need a compiler it's still not installed on Windows or on now now so media still get questions from users about how to run it and there are very many simple scripts available in source there are about 5 i think which may be 3 year installed so there's not a lot of stuff to copy from you can use and that's getting better and it get source there's a lot more and there or scripts available online to copy but if you want to be able to get lots of things to copy from lots of documentation script who is still at that option it's going to make a scripting
language is available on every version of down anywhere so if you write something in script food you know you can distributed to all your users there will be able to use and there's lots of samples is based on scheme which is a dialect of lisp which not everybody loves you know about they're running on a versions it's mostly true but in 2 . 4 which now was several years ago a new version of script was introduced call tiny it's better it's more more standard scheme which means there's more documentation available for the language itself but it's not 100 per cent compatible with the old script for which means there's still a lot of old scripts floating around that don't quite run all that well with current down and there is a migration by which is quite that it tells you everything you need to do to update a script but it's a little frustrating that there these all scripts floating around fortunately there are many people using you point to any more do run into them now and then and you can see
the the middle 1 I mentioned that technically scripts a
script through and Python and other scripting languages are applied so this is really where this comes in you install script food to you're doing profiles slash scripts rather than politicians and they don't have to be executable the and script through hello world looks pretty
much like this and if you're not familiar with less it stands for lots of irritating stupid parentheses as you see the menu registration works
about the same way as it does in Python except more parentheses the arguments are slightly different but very similar and just like in Python colors is specified as a list of RGB values
you don't have to restart again when you install scratch there's a reason refresh graphs signed on to the greatest can could have that someday 1st plants to 1 of the things that the biggest
problem with migrating those older scripts from 3 2 . 4 is that people don't declare the variables variables do you have to be declared in script for use let's stop for that if you use let's then subsequent definitions can depend on earlier definitions so the wave height depends on with here would be possible if you don't stop so this is a little confusing just always use let's start and I don't any real disadvantage she that
and you may have noticed a lot of cars in spectral
congress means the 1st element of the list and this is because the early list developers decided that a great name for a function with content of address register which had something to do with the way the 1st list interpreters were implemented it's not true for probably 20 years but were stuck within cars and nearly every given functions In script food that returns anything at all returns a list of it so if you ask for like the image height you'll get a list of the entire if you ask image with you much of the image with and so forth so you always have to use car to take the item that's actually in the last so that's that's the most common error and script from programming and have
to prefix notation trips up a lot of people and script food if image type equals equals grade is how you would say than in any other language but you have to do with the the function that conditional or whatever 1st and likewise with classes
like for while and and so forth and this
all gets nested you know you you test whether the against selection is empty that returns a list of true or false so you have to take the hard again and then you have to compare it against false you can't just say it product but that's another thing that came in with tiny food so some old scripts don't do that and you have to change it to update them a loop looks like this is not that different from a conditional release well you have printed and then various things you're doing inside the loop and you can use that to change of variable once it's been declared older scripts will use that on variables that have been declared but it is but it doesn't work anymore error messages we were all hoping we get
much better In tiny food but they didn't really and they still don't have my numbers so this is pretty much the set of what you'll see what you're developing a tiny food or when you're developing script food scraps not very helpful this 1 means you forgot to say less but all the rest could mean practically anything and since there no line numbers if you have a long script you're kind of stuck so the best method I found of debugging these things is binary search you take your script and cut out half of it and see if you're still happens and then you know which half it was a narrow it down now horrible do you yeah that's that's true so use just really use an editor that can match operands and that can show you unbalanced burns if you can that helps a lot and I have already talked about some of these
but a big 1 they came in with tiny food is that you can't say . 5 you have to say 0 . 5 you know I that would basically all the time there is a good
documentation on script food but it's really hard to find it because if you go for this this is the good documentation and it doesn't show up in Google it's it's like number 5 on the list of you google for script for documentation this stuff and develop got there are a couple of tutorials but they don't really give you the details in a certain that start in the Getting Started guides but you really do need the wiki and you know maybe we can think that from get . Sunday
when you develop you don't write from scratch just find a script that's pretty close to what you wanna do and copy it and that's the great thing about the GPL if you do that even legal and again source is the best place to do that the gimp registry has a lot of sample scripts also gorgeous google because their chance against scripts and get plug-ins available on Google on the chopper while you you can always find something to do pretty close to what you want you
at probably everybody here knows how to find source but you can there's an online browser these slides will be online and these are links so if you don't know how to find the they get source you can go to the slides and get the length so basically use when
you're writing scripts for yourself or for other Linux users use script for of you need to distribute to everybody but watch out for some of the chinese food problems hence the and that really even sure there's an point . 2 rating see plug ins for most people anymore In developed outcomes less scripting is where the slides are in the links and some sample scraps any questions
thank thank you for you mn thank any questions to account but scripting problems in game I heard lots of room on that in their work and so this this this this supposing writer uh a Python script that um which versions of the game will I be able to use that the would that be problems with that working in 1 version of but not in another the basic Python API as the ones that are documented on online document the online Python documentation haven't changed over of time so you'll be able to use that in any position again since know in Python came but it's it's been there for a long time if you use some of the newer stuff that's in the again get tree that won't work earlier versions of and some of that is frequently very simple stuff coming in but you probably wouldn't be writing and that yet are there other questions the request reserve a workshop being be do you workshops on this the instigators right at the kinda another 1 0 we could talk at lunchtime you know finding and I'm happy to go over some scripts talked about yesterday we have LG school was sort of pre a gym day and a kind of gave the works of on how to the scripts of the components of what this but you you need to come into the frogs and so can the and I just want to ask about your pulp and related to photo book about q is it and 38 to come common I single because protected test the tuple being too long my name is in the so people people came studying is when unfortunately it's not my book was published by a press and they're not really up on sort of thing there apparently getting better there they're starting to understand that things like this are important but but it's not I would love to have it translated in the ontology expressed there it's something we can more called to make the connection because I think it's going to know for that it opens the user base of think tremendously OK thank you very much and but but but if