Applying a Squeeze

Stock images for this tutorial

Full Size Screenshots

Have an urge to put the squeeze on the government? GIMP makes this a pretty painless process—at least for you. Several GIMP filters can distort an image, but not all can give you the results you seek.

4.1-00.ApplyingASqueezeFinal

Experimenting with Distortion Filters

In this tutorial we’ll experiment with the three distortion filters that can pinch an image: the Curve Bend, Whirl and Pinch, and IWarp filters. None of these are difficult to use, but the results can be distinctly different. Each example will show how a filter affects a simple image—like the sphere you created in Section 3.2. (Make sure you complete that exercise before trying this one.) Knowing how each of these filters works can help you decide which is appropriate for your project.

Squeezing with the Curve Bend Filter

In general, the Curve Bend filter gives you more control over the pinched shape, but it doesn’t provide the wrinkles you’d see with a real pinch.

  • Start by opening the MetalButtons XCF file you saved in Section 3.2. Make sure the button is in a layer by itself, with the white background layer below it. If there are multiple layers in your Layers dialog, merge them down until you just have a Button layer and a Background layer (Layer->Merge Down).
  • Use the Rectangle select tool from the Toolbox to make a rectangular selection around the button. The selection doesn’t have to be exact and should leave a little space between the selection and the button. The selection will allow a larger preview when using the Curve Bend filter.
4.1-01.Button

Open the Curve Bend filter (Filters->Distorts->Curve Bend). Click the Upper radio button under the Curve for Border heading. Then drag control points out on the curve, as shown. Check the Automatic Preview checkboxto view the changes as you make them.

4.1-02.CurveBend
  • Click the Mirror button to make the Upper curve mirror the Lower curve and create a symmetrical pinch. Click OK in the Curve Bend dialog to apply the changes.
4.1-03.CurveBendApplied

If you want to apply the Curve Bend filter’s pinch horizontally instead of vertically, you must set the Rotate value to 90 degrees in the Curve Bend filters dialog. Then apply your changes. Because you applied the filter to a selection, you’ll have a Floating Selection in the Layers dialog. Convert this to a new layer (Layer->To New Layer). Name the layer Curve Bend, then turn off the visibility of the original layer.

  • In this example, the edges of the pinched image look jagged. To clean this up, start by making sure the Lock Alpha Channel box for this layer is not enabled in the Layers dialog. Then create a selection of the object (Layer->Transparency->Alpha to Selection).
  • Shrink the selection by 2 pixels (Select->Shrink), feather the selection by 3 pixels (Select->Feather), then invert the selection (Select->Invert).
  • Open the Gaussian Blur filter (Filters->Blur->Gaussian Blur) and apply a blur of 3 or more pixels. Deselect all when you’re done (ctrl-shift-A).
4.1-04.FixingJaggedEdges

The Lock Alpha Channel box is just below the Opacity slider in the Layers dialog. When there’s no outline around this box, the Lock Alpha Channel option is turned off for the active layer.

Squeezing with the Whirl and Pinch Filter

  • To try out the Whirl and Pinch filter, first turn off the visibility of the Curve Bend layer. Duplicate the Button layer and name the duplicate layer Whirl/Pinch. Turn on the visibility of the new layer.
  • Open the Whirl and Pinch filter (Filter->Distorts->Whirl and Pinch). Set the Whirl angle slider to 0 degrees, the Pinch amount slider to 0.7, and the Radius slider to 1.8.
  • Click OK to apply the filter to the image. The result is that the effect is applied along the horizontal axis and pinches all the way in toward the center of the sphere, converting a highlight into a pinpoint.

NOTE: Note that this result relies on the fact that the button was centered in the image window. If it isn’t, the effect may be significantly different.

  4.1-05.WhirlAndPinch

The Whirl and Pinch filter is easier to use than the Curve Bend filter. The effect is just as uniform, though possibly a bit off center.

As with the Curve Bend filter, the Whirl and Pinch filter only works in one direction. This time the direction is horizontal. To apply this pinch vertically, you must rotate the layer, apply the filter, then rotate the layer back to its original orientation.

Squeezing with the IWarp Filter

The IWarp filter is the only distortion filter that produces a wrinkled pinch effect, much like you’d get if you squeezed a soft ball.

  • To see how it works, first turn off the visibility of the Whirl/Pinch layer. Duplicate the Button layer (Layer->Duplicate Layer) and name the duplicate layer IWarp. Turn on the visibility of the new layer.
  • Open the IWarp filter (Filters->Distorts->IWarp). To apply this filter, configure the various settings and then click and drag inside the preview.
4.1-06.IWarp

The IWarp filter is the Swiss Army knife of GIMP distortion filters, but its use requires more manual manipulation than other filters and there’s no simple mechanism for mirroring a distortion on opposite sides of an object.

  • Click above the top edge of the button and drag down a small amount. Multiple drags are usually required to form the desired pinch effect. Do the same on the bottom of the image to squeeze it up.
  • Adjust the Deform radius and Deform amount sliders if you like. This example used a Deform Mode of Move with the Deform radius set to 50 pixels and the Deform amount to 0.50. With this filter, experimentation is painless—just click Reset to remove all changes made in the preview window. When you’re satisfied with the warp, click OK to apply the changes.
4.1-07.IWarpApplied

It’s easier to set the width of the squeeze using the IWarp filter than it is with the Curve Bend filter. Just increase the Deform radius setting before dragging through the preview in the IWarp dialog.

If you look closely, you’ll see that the Whirl and Pinch and the IWarp filters don’t leave the jagged edges seen with the Curve Bend filter. Each filter has its own set of pros and cons, so choose carefully for your project.

Using the IWarp Filter to Squeeze the Capitol Building

Now let’s use the IWarp filter to squeeze a photograph of the U.S. Capitol Building.

  • Use the Crop tool to crop out construction work on the right, leaving the dome and a solid blue background.
4.1-08.CropCapital
  • You can leave the lower floors in the picture, but they’ll just be distracting because you aren’t going to squeeze that part of the image.
  • Next let’s cut a C-Clamp from a stock photo and add it to this image. Open the clamp image, select the clamp using the Foreground Select and/or Quick Mask tools, turn off the Quick Mask, then copy and paste the selection into the image of the Capitol dome.
  • Use the Move tool to position the clamp over the Capitol dome, then use the Scale tool to fit the clamp to the image. When the clamp is in the right place, make it a new layer (Layer->New) and name it Clamp.
4.1-09.Clamp

The newspaper in the background of the clamp image makes it difficult to select the clamp with anything other than the Quick Mask tool, but even that takes time and a steady hand. If you’re impatient, the next best bet is the Scissors tool.

  • Click the Background layer to make it active, and then open the IWarp filter (Filters->Distorts->IWarp). Set the Deform radius and Deform amount sliders to low values and begin dragging in the preview window. Experiment with different Deform radius and Deform amount values as necessary. Once your preview is satisfactory, click OK to apply the warp.
  • Use the Scale and Move tools to tweak the size of your clamp.
  • Add a layer mask to the Clamp layer to blend the two layers better (Layer->Mask->Add Layer Mask). This method is imprecise, and it may take a few trial-and-error attempts to get it right, but the result will be better than you’d get if you used the Curve Bend filter or the Whirl and Pinch filter.
4.1-10.ClampApplied

Because of the angle of the clamp in the original image, it’s easiest to use the IWarp filter to make the squeeze on the Capitol Building fit the clamp.

Further Exploration

The final image, displayed at the front of this tutorial, shows that white text with a simple drop shadow has been added. The drop shadow uses small values for the X and Y Offsets (2 or 3 pixels for a web design) and the Blur Radius. If the background were not so uniform in color, you might consider adding a text screen as we did in Section 2.9.

Distortions like this squeeze effect are fun to work with, but you have to be careful about the size of the original image. If you distort small images too much, you may notice a stairstep effect along the edges (also known as “the jaggies”). For this reason it’s best to apply the distortion to larger images and then scale down the result.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Get the book!

You can purchase the book directly from No Starch Press You can also get it through Amazon.com and O'Reilly

On The Web