Most Linux users are familiar with the GIMP raster graphics editor, a versatile tool for photo and graphics work. What is often overlooked is that a significant chunk of GIMP’s power comes not from its built-in functions, but from its extensibility. GIMP supports enhanced features through compiled plug-ins and scripts, for everything from automating difficult tasks to introducing whole new functionality. A basic set of plug-ins is supplied with your distro’s version of GIMP, but if you’re just sticking with that, you’re missing out on many of the high-end features. This weekend, let’s take a look at GIMP’s plug-in power, through the lens of one of its most advanced add-ons, Resynthesizer.
To find out what your plug-in situation currently is, fire up GIMP and then go to the Help -> Plug-in Browser menu item. You will probably want to expand the window size for readability; for some reason only the first column is visible in the left-side pane, but there is much more. This browser lists all of the installed plug-ins, and for each one allows you to see where in the program’s menu structure the added function appears, when it was last updated, what image types it operates on, and any additional information provided by the plug-in author — such as a URL.
The example plug-in we’ll be looking at in this project is called Resynthesizer, and it is one you will definitely want to install. Resynthesizer performs “texture synthesis,” which means healing and selection-fill-in functions in a picture based on the surrounding image itself. It is essentially the same features provided by Photoshop’s “healing brush” and “content aware fill,” but Resynthesizer was doing it half a decade ahead of Photoshop. The original author Paul Harrison developed the plug-in for his PhD research, but new maintainer Lloyd Konneker took over in 2010 and is producing binaries and packages for up-to-date GIMP releases.
Where Plug-Ins Come From
The officially-sanctioned home for GIMP plug-ins and scripts is the GIMP Plugin Registry. It offers a variety of ways to access extensions, from browsing by popularity or update date, to sifting by category, to subscribing to the registry update RSS feed.
If you are completely new, try taking a look at the popularity-sorted page to get a feel for what other users find helpful. There you’ll see support for extra image formats, layer effects, color separation, and entirely new functionality like wavelet-based denoising, adaptive edge-detection, liquid rescaling, and the ability to run native Photoshop plugins.
Despite its official status, not every plugin author makes regular use of the registry, so if you see a plugin that looks interesting but has a long-past “last update” date, be sure to read the comments and to click through to the plug-in’s home page. Most are actively maintained, and the comments from other readers will often be a current source of information on the status.
You don’t actually have to find plug-ins through the registry at all, of course. Many design blogs feature “five great GIMP plug-in”-style posts on a regular basis, often with an eye towards a particular use-case (design, photo editing, etc.). Start with the lists from MakeTechEasier and LightStalking to get a feel for the option.
Installation
Go ahead and close GIMP if you still have it open from the previous step. From a terminal window, type cd ~/.gimp-2.6/
and hit Enter to move to your GIMP configuration directory. An ls
shows you the contents, which include directories for saving brushes, curves, gradients and other resources. The directories of interest to the plug-in shopper are plug-ins
and scripts
.
What’s the difference between the two? For historical reasons, scripts (which you might think of as similar to “user macros” in other applications) go in their own directory, are written in a Scheme-like language and use the .scm file extension. Plug-ins can be compiled executables or Python code, and generally implement features that cannot be accomplished via scripting GIMP’s existing internals.
On the Resynthesizer registry page, you can download a .tar.gz archive containing everything you will need to install on a 32-bit Linux system. You can also browse the source at Github, where you’ll find a basic README. The archive contains two executables, resynthesizer and resynthesizer-gui, and eight Python scripts (one each for each new menu function provided). Extract them all to ~/.gimp-2.6/plug-ins/ and then type ls -l
at the command line. That will show you the file permissions.
The newly extracted package will not have the executable “x
bit” listed in the fourth column, so type chmod +x *
to set it. In the future, other plugins you install may or may not require this step, depending on whether you install them through your distro package manager, download them manually, or perhaps compile them locally.
Resynthesizer uses binary and Python plug-ins only, but another package could include both plug-ins and scripts. If you are installing a script, though, the process is exactly the same except for the target directory: extract the script to ~/.gimp-2.6/scripts/ and use chmod to set the executable bit.
Plug-Ins in Practice
Now, when you re-open GIMP, the program will scan the plug-ins directory, pick up the new additions, and integrate their new menu entries directly into the interface. There is no separate “plug-in area” of the menus; that is part of why the Plug-in Browser we opened earlier is important. If you can’t figure out whether or not a plug-in is being picked up by GIMP, you can search for it or try and locate it by name, but the listed names correspond to the new functions implemented, not the name of the package as a whole.
In Resynthesizer’s case, you gain eight functions: “Enlarge & sharpen,” “Sharpen by synthesis,” “Heal selection,” “Heal transparency,” and “Uncrop” in the Filter -> Enhance menu, “Texture” in the Filter -> Render menu, “Fill with pattern seamless” in the Edit menu, and “Style” in the Filter -> Map menu.
If you’ve been using GIMP for a long time, you may have to worry about plug-ins and scripts from previous major releases. Note that the directory we’ve been using thus far is ~/.gimp-2.6/. Resources and extensions from the GIMP 2.4 series (if you still have any) are located in ~/.gimp-2.4/. However, it is a very bad idea to simply copy-and-paste objects between these two directories. Changes in the API might make them malfunction in ways that you can’t predict, although this is primarily of concern to compiled binary plug-ins. Most plug-in authors keep up to date on GIMP’s long release cycle — visit the registry or plug-in URL and see if there is a new version available.
Resynthesizing
So what about Resynthesizer itself? No, it’s not a resurgence of 80’s New Wave pop. Thankfully. Instead, the eight new functions it provides implement texture synthesis in very specific uses. The canonical example is cropping a distracting item out of a photograph: you can manually remove the object and paint over it using the clone tool, sampling from the surrounding area. Resynthesizer does this automatically, without risk of smudging up the result through choosing awkward sampling points.
This function is implemented in the “Heal selection” option. Make a selection, then choose is from the Filter -> Enhance menu. The new version of the plug-in lets you choose the size of the sampling area, whether to sample on all sides or just vertically/horizontally, and whether to fill in randomly, work from the inside-out, or the outside-in. What gives you the best result depends on the image.
Heal transparency does essentially the same thing, but for transparent regions of an image. The mysteriously-named Uncrop takes the process to a new level, adding a transparent border to the image, then automatically filling it in with texture generated from the neighboring region, including correctly preserving horizon lines and other features. Sharpen by synthesis and Enlarge & sharpen both work to reconstruct detail in a blurry image by synthesizing pixels. It’s not as good as tech teams produce on TV, but it can save an otherwise scruffy-looking photo.
The Render Texture and “Fill with pattern seamless” options are different entirely. They deal with the Resynthesizer engine’s ability to detect edges and seamlessly connect to them as it generates pixels. Render Texture uses the current image as a source and generates a reusable, randomized texture preserving visible features (optionally making it tile-able at the same time), while the Fill option takes an external image as a “source” and generates a random-but-natural-looking texture from it to fill in part of the image. The first might be of interest to those who generate textures for 3-D modeling or video game graphics, while the second is a genuine photo-editing tool (provided you don’t pick an easily-recognizable source texture).
The last new function is original. Filter -> Map -> Style transfers the “color and texture” of one image into another, through sampling and texture synthesis. The result is that you can take a source image (such as a photograph) and map the “style” of a target image (such as a watercolor painting) onto it. The result ought to be a watercolor-like rendering of the photo.
To be honest, I haven’t played around too much with the new functions. I’m happy enough to have the healing functionality of Resynthesizer return to GIMP after such a long absence.
When you’ve worked with Mozilla Firefox and Thunderbird for a while, the process for managing GIMP plugins seems quaint by default. Here’s hoping a future version of the editor will automate more of the installation process, or perhaps even tie the registry directly into GIMP’s Plug-in Browser so you don’t have to switch to a web browser. But don’t get too down on the GIMP’s process — it’d be nicer if it was fully automatic, but it’s fairly simple already. Most people just haven’t tried it. In fact, you’ve probably got enough of your weekend left that you can check out some additional plug-ins, too. Here’s a hint: if you like Resynthesizer, try G’MIC for extra credit.