March 27th, 2008
424 CHAPTER 11 PLUG-INS AND SCRIPTING Figure 11-4. The sphere generated by the built-in Sphere script You might want to take one of these spheres and paste them into a drawing wouldn t it make a nice Christmas tree ornament or poodle nose? But you can t! The sphere generated by the script always has a solid background. If you want to paste the sphere into another image, you either have to use your selection skills to get rid of the background, or make your own sphere by hand (as you learned to do in Chapter 9). That s a lot of work. But the GIMP is an open source program, and that means you aren t limited to the choices the developers made: you can make it do anything you want. Why not just make it do the right thing? Find the Original Script The first step is to locate the existing script. You can find where GIMP scripts are stored by looking in the Preferences window (File . Preferences from the Toolbox): expand the Folders category and click on Scripts. The GIMP should show you at least two folders. One is the place where you can put personal copies of scripts; the other is in a system directory where GIMP has its own files installed. Make a note of these two locations. You ll use them both. Now find the script itself (in the system script directory). Usually it will have a .scm (short for scheme ) extension. You generally have to guess what the file name might be, but in this case it s not too hard: there s a file there called sphere.scm. Edit a Copy of the Script It s not a good idea to edit GIMP s existing scripts in place what if something goes wrong? so be safe and copy sphere.scm to your personal scripts folder.
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.
March 27th, 2008
CHAPTER 11 PLUG-INS AND SCRIPTING 423 You can easily tell whether you have gimp-python enabled: check for a Python menu in the Toolbox under Xtns. If you re just learning scripting and you have gimp-python installed, it s well worth trying it out. Perl Perl is a well established and popular scripting language, commonly used on web servers and for system administration. Perl used to come standard with GIMP, at least on UNIX systems. But somewhere along the line, it became less popular for GIMP scripting, and today it s not included as part of the standard GIMP package. You can see whether you have gimp-perl installed by looking for a Perl or Perl-Fu menu under Xtns. It s still possible to install gimp-perl as a separate package (look for it at gimp.org), and there are still plenty of gimp-perl scripts in the Plug-In Registry. If you re familiar with the Perl language and prefer it to Python or Scheme, then there s no reason not to use Perl as your introduction to GIMP scripting. If you re not already a Perl fan, though, you re probably better off sticking to Python or Script-Fu. Reading and Modifying a Script You don t have to be a programmer to write simple GIMP scripts, or to modify existing scripts, though of course programming experience will give you a head start. It s easiest to begin with an existing script and modify it. A quick run through the process will show you how it s done. Let s dig deeper into something that always frustrates me. The GIMP has a useful little Sphere script, in the Toolbox Xtns menu under Misc (in earlier versions, look for Misc inside Script-Fu). It shows you the dialog in Figure 11-3, and produces a nice sphere like the one in Figure 11-4. Figure 11-3. The Sphere script s dialog
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.
March 26th, 2008
422 CHAPTER 11 PLUG-INS AND SCRIPTING Once the compile completes without errors, it s time to install it. Type: gimptool –install filename where filename is the file you built in the previous step. (Some very complex plug-ins may need to install more than one file, and use their own installers, usually run from a Makefile, so the user need only type make install. Creation of Makefiles and installers is outside the scope of this book.) Writing GIMP Scripts Now it s time to take a closer look at GIMP scripts. The GIMP can be scripted in three different languages: Script-Fu, Python, and Perl. They each have their advantages and disadvantages. Script-Fu (= Scheme = Lisp) Script-Fu (a pun on kung-fu ) is the GIMP s built-in scripting language. Script-Fu has one big advantage: it is always available in every version of the GIMP. If you want to write a script to distribute widely, Script-Fu is the best choice. You can be fairly sure everyone will be able to use it. In addition, most scripts distributed with the GIMP are written in Script-Fu. That means that you can find examples already installed on your system for all sorts of useful techniques. Since the easiest way to learn scripting is to copy an existing script (as you ll see in a moment), that s a big advantage. The downside of Script-Fu is that its syntax is somewhat difficult for most people. Script-Fu is actually just the GIMP s term for a language called Scheme, a dialect of Lisp. (To be even more specific, it s a dialect of Scheme called SIOD, and you can find tutorials and documentation on its syntax with a web search for SIOD. ) Lisp is a language invented in 1960 for mathematics and artificial intelligence research. The name stands for list processing, because it s very good at processing lists of items. But Lisp programmers joke that it actually stands for Lots of Irritating Stupid Parentheses, a phrase which you will readily understand after looking at some Script-Fu examples. Don t be too scared off by the parentheses. Often, you can copy bits and pieces from existing programs to make simple scripts without needing to understand much about Lisp. But if you really dislike the syntax, you may be better off with one of the GIMP s other scripting languages. Python Python is a much more modern language, created in 1990. It has a clear, straightforward syntax and is a very friendly introduction to general-purpose programming. It s also well integrated into the GIMP, so it s fairly easy to write gimp-python scripts. The only downside is that Python didn t become part of the standard GIMP install until quite recently, and was a bit tricky to install on Windows. That s been fixed now gimp-python comes as part of GIMP 2.4 though you do need the Python language installed on your system: you can get it from http://python.org if you don t already have it. You may also need the pygtk package, from http://pygtk.org.
We recommend high quality webhost to host and run your jsp application: christian web host services.
March 25th, 2008
CHAPTER 11 PLUG-INS AND SCRIPTING 421 Compiling makes a C plug-in run much faster than a script, since the compiler speaks the machine s native language. However, it also means there s an extra step in creating something that can run, and it has to be done separately for each platform. If there s a binary available for your operating system, just take that file and move it to the plug-ins folder inside your GIMP profile. Alternately, if you have gimptool installed, you can use gimptool –install-bin. The next time you restart GIMP, the new plug-in should show up in the menus. Tip Where did the new plug-in show up? A lot of plug-in developers forget to tell you where to look in the menus to find their plug-in once it s installed. Since GIMP has so many features already, searching for something new could take quite a while! Fortunately, you can use the Plug-In Browser to figure out where it appears. However, since many plug-in developers don t have C compilers for all three platforms, often they simply make the C source code available, and you have to build (compile) it yourself. You ll need some supporting programs in order to do that. Installing a Gimp C Development Environment On Mac and Linux systems, installing a C compiler is easy. The GNU C compiler (gcc) comes on the Mac OS X Development CD, and is included with most Linux distributions. If it s not installed, it can usually be installed easily using the software update tools provided with your system. You ll probably need a few additional packages, in particular gimptool. It s sometimes included with GIMP, but if not, look for a package called something like gimp-dev or gimp-devel. You ll also need development packages for X11 and gtk. Most packaging systems should automatically install these when you install the GIMP development package, but if you get errors, these packages may be what you re lacking. On Windows it s a bit harder, since Windows doesn t come with a C compiler. If you don t already have a compiler installed, you re probably best off with MinGW, the Minimalist GNU for Windows packages. Find them at http://www.mingw.org/. You will need both MinGW and MSYS. In addition, even if you already had a compiler, you ll need the development libraries for GTK+, Glib, and other related features. You can get them by clicking on GIMP for Windows on the main gimp.org site. Look for packages with -dev in the name. Building a C Plug-In Once you have the compiler and libraries installed, it s time to build your plug-in. You ll need a terminal window open so you can type commands: the Command Prompt program should work on Windows systems, Terminal on Macs, or any terminal client on Linux. Then type: gimptool –build filename.c where filename.c is the name of the plug-in file. Remember: two dashes, not just one. If this gives errors, it may be that you re missing libraries. Double-check that you have all the requirements installed.
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.
March 25th, 2008
420 CHAPTER 11 PLUG-INS AND SCRIPTING Finding Plug-Ins Using a Web Search A web search often works much better for finding GIMP plug-ins. Lots of people develop plug- ins and never get around to listing them on the registry. Maybe they don t know about the registry, or they don t think their plug-in is quite polished enough to list there, even though it might be good enough for your purposes. Use gimp as one of your search terms, along with the functionality you re looking for, such as gimp redeye. If you get too many hits (sometimes you ll get a lot of mailing list traffic discussing how to do things by hand), you could try adding plug-in or plugin or script to your search query, for example, gimp redeye plugin OR script. Installing a Plug-In With any luck, the plug-in you find will come with installation instructions. But some don t. Here s what you need to know about installing plug-ins. You first need to know what type it is: whether it s a C plug-in or a script. Usually the page where you found the plug-in will tell you. In addition, a script will usually have an extension such as .scm (Script-Fu), .py (Python), or .pl (Perl), while a C file will end in .c. If the file you downloaded has the extension .zip, .tar.gz, or .tar.bz2, that means it s part of a compressed archive. You must unpack the archive first (using a program such as unzip or tar) before you can install the plug-in. Installing a Script Installing a script is easy. For a Script-Fu, just take the file.scm and copy it to the folder named scripts inside your GIMP profile. For Python or Perl, copy the file to the plug-ins folder instead of scripts. If you don t remember where your GIMP profile folder is, check the Folders category in the File . Preferences window. That s all! The next time you start GIMP, the new script should register. If GIMP is already running, you can tell it to look for new Script-Fu scripts from the Toolbox menu: Xtns . Script-Fu . Refresh Scripts…. If the script is Python or Perl, you ll have to restart GIMP. Tip If you have the gimptool program installed, you can use it to install Script-Fu scripts. In a terminal window, type gimptool –install-script file.scm (that s two dashes together). For Python or Perl plug-ins, use gimptool –install-bin file. This shortcuts the need to find your GIMP profile, if you don t mind typing commands. You ll need gimptool for installing C plug-ins anyway (see below). Installing a C Plug-In Installing a C plug-in is no more complicated if the plug-in has already been compiled for your platform. C is a compiled language, which means that in order to run anything written in C, it has to be translated (compiled) into machine language first. The compiled version is referred to as an executable or a binary.
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.
March 24th, 2008
CHAPTER 11 PLUG-INS AND SCRIPTING 419 Figure 11-2. The Tree View shows GIMP s menu structure; entering a term in the Search field limits the number of plug-ins shown. The Image Type field tells you which kinds of images the plug-in accepts. Some plug-ins will only work on RGB images, and will be grayed out if the current image is indexed or grayscale. Other plug-ins may work only on indexed, only on grayscale, or only on RGBA (RGB images with an alpha channel). A * is a wildcard: RGB* means that both RGB and RGBA images will work, and * by itself means the plug-in will accept any type of image. The right half of the dialog gives you more information about the plug-in, including its location in the menus, a description of the plug-in, the parameters it takes (these are usually the same as the values you ll be able to change in the plug-in s dialog) in case you ever wanted to use it in another plug-in, and information about who wrote the plug-in. Finding Plug-Ins What if you ve searched the Plug-In Browser and there s nothing there? Might someone else have developed a plug-in to do what you need? You have two options to find such a plug-in: the GIMP s Plug-In Registry, and a web search. The Plug-In Registry GIMP s official Plug-In Registry is located at http://registry.gimp.org. Anyone who develops a plug-in or script for GIMP can register it there. As a user, you can search by language, by GIMP version, or by categories such as Distorts, File, Artistic, and so on. If you aren t sure which category would cover the function you re looking for, just search by name and hope you find something. The Plug-In Registry is theoretically a good resource. But it tends not to be very well maintained: the GIMP versions it lists tend to run behind, and searching doesn t always work well. Try the Plug-In Registry when you re looking for a way to do something in GIMP. But if you don t find anything there, don t despair: try a web search.
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.
March 23rd, 2008
418 CHAPTER 11 PLUG-INS AND SCRIPTING Finding out how to do things: The GIMP PDB A Perl script Batch processing of multiple files Writing a C plug-in Plug-Ins Strictly speaking, anything that isn t built into the GIMP s core libraries is a plug-in. You ve probably already used lots of GIMP plug-ins: nearly everything in the Filters menu is a plug-in. About half of the Colors menu and most of the Xtns menu in the Toolbox are also plug-ins. The Plug-In Browser How do you know which plug-ins you already have installed? With the Plug-In Browser (Figure 11-1), accessed through the Toolbox menu: Xtns . Plug-In Browser…. Figure 11-1. The Plug-In Browser Yikes there are a lot of plug-ins! Bet you didn t know you had that many installed. Fortunately, there s a Search field. Type in a search term, such as crop (or even part of a term, like rop), and GIMP will show you only plug-ins that contain that term. The Plug-In Browser is a good way of finding functionality without searching through all the menus. If you re pretty sure that there s some sort of automatic crop function, click on the Tree View tab and enter crop in the Search field. All plug-ins that include the name crop will come up in the menu, and you can see where they are in the menu structure, as in Figure 11-2.
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.
March 22nd, 2008
Plug-Ins and Scripting CHAPTER 11 The GIMP is a supremely flexible image-editing program. But sometimes you may need to do something unusual, something that isn t built-in. Or maybe you just need to do the same repetitive operation over and over on many different images. Either way, don t give up just because the function you need isn t in the menus anywhere. GIMP s flexible architecture means it s very easy to add plug-ins and scripts to do nearly anything you need to do. There are dozens, maybe hundreds, of plug-ins readily available. But if you can t find one to do what you need, you can even write your own, using a choice of several different languages. Many plug-ins are written in the C programming language, the same language used to write GIMP itself. But other plug-ins are actually scripts. Scripts are a special type of plug-in, a type that doesn t need any special compiler software. The GIMP supports three scripting languages, Script-Fu, Python, and Perl, in varying degrees. You ll learn more about the differences later in this chapter. Scripts are especially easy to write, which has three benefits: It s easy for other people to write them, so there s a good chance you can find a script to do what you need. It s easy to read them, so if you can find a script that s similar to what you need, you might be able to modify it for your purposes. It s not very hard to write a script from scratch. So let s take a look at what all this means. You ll learn how to find and install plug-ins, and how to find out which plug-ins you already have installed. You ll also learn how to find scripts, install them, read them, and modify them. And finally, you ll learn how to write a new script from scratch to automate some simple but useful operations. The chapter will cover the following topics: Installing plug-ins Writing GIMP scripts User interface options for scripts A Python script
You want to have a cheap webhost for your apache application, then check apache web hosting services.
March 22nd, 2008
416 CHAPTER 10 ADVANCED COMPOSITING Summary Now you know all sorts of ways to composite several images. No book could possibly list all the amazing things you can do compositing images in the GIMP, but now you know the important tools and a collection of different techniques. You should have a good solid base from which to begin experimenting with your own images. You ll also be able to apply techniques you find in web tutorials. If you experiment with these ideas, and try them on the sorts of images you use yourself, you ll be an expert in no time. But for now, take a break from fiddling with images by hand. During the course of this chapter, you ve done quite a lot of repetitive operations which would have been so much easier if they were automated. In the next chapter, you ll learn how to automate GIMP processes yourself, using plug-ins and scripting.
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.
March 21st, 2008
CHAPTER 10 ADVANCED COMPOSITING 415 Adjust with Other Tools if Necessary Most of the time, you can get what you need (except the sky) by drawing on the layer mask. But in a few cases, you ll have something perhaps a branch, or a road that just doesn t meet in the two images. Sometimes, you can use other tools to fix this. Of course, you can draw directly on the image, using your cloning and smudging skills from Chapter 6. But first, try IWarp (described in Chapter 7, Distorts ). Sometimes careful use of IWarp can do exactly what you need. Add the Rest of the Images You re done adding the second image! Now, repeat the steps for each of the pieces of your panorama: load the image, add a layer mask, move it into place, adjust the layer mask, and make any additional adjustments you need. Final Adjustments Ironically, skies are particularly hard to get right in panoramas. Differences in exposure seem much more obvious against a clear blue sky. So go ahead and cheat: select the sky using your favorite selection technique, and then make a sky from a gradient between two shades of blue, just like in the Decomposing to HSV exercise in Chapter 8. Finally, crop the panorama. The top and bottom edges of the component images probably won t quite line up. It s your choice: you can leave the edges ragged (Figure 10-40), to show off its panoramic nature, or you can crop to an even rectangle so it looks like the whole thing was taken in one shot. Figure 10-40. Crop the panorama. Leave the ragged edges if you like: sometimes it s fun to show how many images went into your creation.
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.