• No se han encontrado resultados

Calculo de demanda de cereal en el cantón Quito

INEC, CENSO DE POBLACION Y VIVIENDA, 2001 INDICADORES SOCIALES

4. Capitulo IV : Estudio Técnico

4.2. Administración de la Capacidad

As comprehensive as the interactive possibilities of GIMP are, so is its plug-in interface. The flexible architecture of GIMP allows a simple integration of extensions and the available functions can either be automations that are triggered from the user interface and via a console or plug- ins and scripts written in a high-level programming language that can perform complex image processing tasks. In fact, many of the functionalities that are available through the GIMP user interface are actually plug-ins. They are implemented in C as GIMP is itself or as scripts which do not require compliling. Scripts can be written in Python, Perl or Scheme, a Lisp dialect and experimental packages are also existing for Ruby and C#. Many plug-ins developed by other users can be found online at the official GIMP plug-in repository or at other websites.

For this project, the Python script interface of GIMP was chosen which is called Python-Fu. It offers a almost the same scope of functionalities as the C plug-ins without the need of diving into the entire software’s architecture. The Scheme interface which is called Script-Fu and the most popular way that GIMP scripts are created was not used because Python is more versatile and does also provide packages for database access and geometry processing which are used in the script. It is also much faster than Scheme. The only drawback of the GIMP Python module is its setup on a Windows operating system as it is not bundled with the standard GIMP installation package. However, as the implementation was carried out in a Linux environment, required packages are easy to install additionally (Peck, 2008).

The Python-Fu interface consists of a set of Python modules acting as a wrapper to the GIMP Python package called libgimp for Ubuntu Linux. It is imported via the gimpfu module at the beginning of a script file and enables access to the GIMP module and the procedural database reg- istry (PDB). The GIMP module provides procedures and functions like constructors, configuration information and other operations as well as GIMP object types. These include image objects and methods which operate on so called drawables like channels and layers as well as other functions. The procedural database is a registry of GIMP and plug-in procedures that can be accessed. All procedures are listed in the Procedure Browser that can be explored from the GIMP Graphical User Interface (GUI). A Python-Fu script always has the same structure which consists of the import of the gimp module, the definition of the main method and the register function which connects the script function with GIMP. Along with the registration parameters which include information like the plug-in name, the author or the menu path, input parameters can be defined in this part as

3.2. RASTER IMAGE EDITING WITH GIMP 29 well. Arguments like an existing image, a specific drawable or other variables can be passed to the script for operating with it. All common variable types like Integer, String or Boolean are availabe aside from the GIMP objects.

The following code shows an example “Hello World” Python-Fu GIMP script which takes an input String that has “Hello World” as its default value and prints it to the console:

1 # ! / usr / bin / env python 2 from gimpfu import * 3

4 def echo (input) : 5 print " echo : ", input 6

7 r e g i s t e r (

8 " console \ _echo ", 9 " A console echo test ",

10 " A console echo test taking an input String p a r a m e t e r ", 11 " Test Author ",

12 " Test Author ", 13 " 2015 ",

14 " < Toolbox >/ Xtns / L a n g u a g e s / Python - Fu / Test / Console Echo ", 15 " ",

16 [( PF_STRING , " input ", " Input String ", " Hello world ") ] , 17 [] ,

18 echo

19 )

20

21 main ()

First the register function is called that connects the script with GIMP. It takes the following parameters:

• Name of the plug-in for external use (command-line) • Short description*

• More detailed description* • Author*

• Date* • Menu path • Image types*

• Parameter list (parameters are defined by type, name, display name and default value) • Return values

• Function to call inside the script as the main function * optional (can be left blank)

After that, the main function is called which runs the plug-in. The function defined in the register function is serving as the entry point which is the echo function in this case. Plug-ins and scripts have to be stored in a directory that GIMP is aware of. This can either be the default directory in the system’s user directory or any other location that is known by GIMP. Additional locations can be added to GIMP in the Preferences menu and are scanned for files after a restart of the pro- gram. Scripts can then be executed either from inside the GIMP GUI or from the system console command-line interface. The example script could be started inside GIMP from the menu path that is defined in the second row of the register function. A dialog would then appear that allows the user to enter a value for the input string parameters. A command line call that would invoke the script and print the String ”This is a Python-Fu script” on the console is for example:

1 python - fu - console -echo RUN - N O N I N T E R A C T I V E " This is a Python - Fu script "

Comparison of functionalities

The functions and procedures that are available are very comprehensive and most of the interactive drawing techniques from chapter 2.2 have an equivalent scripting function. However, there are some limitations in scripting that need to be mentioned. As GIMP is an open-source software, it is under continuous development and not yet complete. Some of the scripting procedures are behaving unpredictable, for example the path stroking function did not work properly with the applied styling in GIMP version 2.8.12 which was the stable release at the time this project started. Therefore version 2.8.14 was used but this version still does not implement interface functions for the emulation of brush dynamics which is available from the user interface since version 2.6 and is explained in a previous section. With this function, a more irregular and hand-drawn appearance

3.3. MAP RENDERING 31

Documento similar