Skip Navigation.

NWE Help: Graphics: XV: Pad

NWE Home :: Help :: Graphics :: XV

The Pad Command

The Pad command is the opposite of the Crop command. Sort of. It lets you add a border of a specified size to the edges of the image. It also lets you resize images to some desired size without manually expanding or cropping the image. But it goes further than that. There are a whole slew of interesting effects available, as described below:

XV pad button

Pad . Brings up the dialog box shown below.
Keyboard Equivalent: P

XV Pad dialog

Pad Methods

Pad Methods

There are three primary Pad methods, as shown to the left. These methods are accessible via the 'Pad Method' menu, which says 'Solid Fill' in the dialog box shown above. In all cases, the Pad command operates in the same basic way: A new image of the desired size is created, it is filled as specified, and the original image is pasted onto this new image, centered. If the new image is smaller than the original image, the original image will be cropped. Otherwise, the area outside the original image will have the new background.

Note: The new, padded image will have the same 8/24-bit mode as the original. As such, you probably want to switch to 24-bit Mode before issuing the Pad command, particularly if you intend to modify the image further. (See "The 24/8 Bit Menu" .)

The 'Pad Method' menu gives you three different ways of filling the background:

Solid fill The background is filled with a solid color. The color may be specified by name,
(as specified in the X11 ' rgb.txt ' file),
by RGB values in the range 0- 255,
separated by commas (e.g. '0,255,128'),
or by RGB values in hexadecimal (e.g. '0x00ff80'). In each case, the string you enter is parsed, and the background is filled solid with the specified color.
Run 'bggen' The external program bggen is executed to generate the background. This program is normally distributed with XV, and XV assumes that the executable is located somewhere in your search path (such as ' /usr/local/bin/bggen '). bggen can generate background gradients, at a specified angle. The gradient can be the entire size of the background, or it can repeat multiple times.
Load Image An image file in any of the XV-supported formats may be loaded and used as the background. In this case, the background size (and therefore the size of the padded image) is equal to the size of the loaded background image. If you want a different size, you can load the background image (as a regular image), resize it as you see fit, save it, and use the newly saved version as the background for the original image.

Image Size Dials

XV Image size Dials

These dials let you specify the size of the new, padded image in the "Solid" and "Run 'bggen'" modes. In the "Load Image" mode, the dials are disabled, as the new image size is dictated by the size of the loaded image.

If the image size dials are enabled, the small button above them resets them to the size of the currently-loaded image. Note that padding with the 'new' size equal to the current size won't actually do anything, unless you change the "Opaque" dial, described below.


Opacity

XV opacity dial

This dial sets the opacity of the foreground (the original image). Normally, this is set to '100%', which simply means that everywhere the original image and the background overlap, the original image is what you'll see. If you set the dial to '0%', then wherever the original image and the background overlap, the background is what you'll see. In any case, at points where the foreground image does not overlap the background, you'll see the background, unmodified. (Practical upshot: at '0%' you will only see the background.)

Of course, most of the interesting effects happen when the dial is set to intermediate values, where the foreground image will appear semi-transparent.

There are four modes the 'Opaque' dial can operate in. They are selected by clicking the button located above the 'Opaque' dial.

RGB

The two images are blended together in the most obvious way. Each RGB color component in the new image is computed by taking a weighted average of the RGB components from the appropriate pixels in the foreground and background images. Like so:

R new = ( opaque% * R fg ) + ( (100 - opaque% ) * R bg ) (same for G and B)

INT

On overlapping pixels, only the Intensity components (the 'V' in the HSV colorspace, see "RGB & HSV Colorspaces" ) of the pixels are blended, using the same weighted average calculation shown above. If you set the 'Opaque' value to '0%', brightness of overlapping pixels will be completely determined by the 'background' pixel. It's possible to get some interesting 'masking' effects and whatnot by playing around with black&white backgrounds.

SAT

Similar to INT , except that it is the Saturation component (the 'S' in the HSV colorspace, see "RGB & HSV Colorspaces" ) of the two pixels that will be blended together, again using the weighted average calculation. The effects possible with this one are considerably more subtle, and not necessarily interesting. It is mainly included for completeness.

HUE

In this case, the colors of the two overlapping pixels are blended. You can get some interesting effects by setting 'Opaque' to '0%', and loading a colorful rainbow background. In this case, at all overlapping pixels, it will be as if the foreground image were a greyscale transparency, as the brightness and saturation will be controlled by the foreground, and the color will be controlled by the background.

Technical Note: The HUE case does not simply do a weighted average of the two hue components. Instead, it plots the two points on the edge of a standard color wheel, draws a straight line between them, and picks a point along this line based on the 'Opaque' value (i.e., the larger the value, the closer it is to the 'foreground' endpoint of the line). As a result, the HUE setting can affect both the hue and saturation components of the computed pixel. While this makes this 'Opaque' mode somewhat unlike the others, once again it is a fine example of XV's trademark "Do The Right Thing" technology.