Cropping Commands

Crops the image to the current selection rectangle. This command is only available when a cropping rectangle has been drawn on the image. See "Cropping" for further information.
Keyboard Equivalent: c
Returns the image to its normal, uncropped state. This command is only available after the image has been cropped. See "Cropping" for further information.
Keyboard Equivalent: u
Crops off any constant-color borders that exist in the image. It will crop to the smallest rectangle that encloses the 'interesting' section of the image. It may not always appear to work because of minor invisible color changes in the image. As such, it works best on computer-generated images, and not as well on scanned images. In an attempt to get around this problem, if you AutoCrop while in 24-bit Mode , it will crop off portions that change by a little bit, not just portions that are exactly the same. Not that it works all that well.
Keyboard Equivalent: C

Also, you can 'fine-crop' an image, by holding the <Ctrl> key and pressing the arrow keys on your keyboard. Each press of the keys will remove one row (or column) of pixels from the appropriate edge. For example, pressing <Ctrl><Up> will crop off the bottom row of the image. Likewise, <Ctrl><Down> will crop off the top row, <Ctrl><Left> will crop off the right edge, and <Ctrl><Right> will crop off the left edge. It may sound backwards, but it does the Right Thing.

This 'fine-cropping' will work regardless of whether or not there is a selection rectangle currently drawn. If you accidentally crop too much off the image, you can use the UnCrop command described above to get the original image back.

Note that cropping never actually changes the image, only what portions are displayed. The original image can always be restored using the UnCrop command. Also, note that the 'cropping' commands and the 'zoom' commands (See "Zooming" ) are related, in that both affect the 'visible portion' of the image. The cropping commands maintain the same expansion factors by making the window larger or smaller, while the zooming commands maintain the same window size, and stretch the relevant portion of the image to fit. As such, the UnCrop command will also undo an zooming that you may have done.

Image Cut and Paste Commands

A new feature added to Version 3.10 is the ability to cut and paste arbitrary rectangular portions of images. You can cut (and copy) and paste within a single image, between two different images, or even between two running copies of xv. You can even cut or copy a portion of an image, exit xv, go out for dinner, come back, restart xv , and paste the previously-copied portion into the current image.

Copied image data is normally stored within the X Server's memory (in the 'XV_CLIPBOARD' property), and remains there until some other data is copied, or until the X Server is reset (i.e., when you log off). This allows you to transfer image data between different copies of xv, and the xv's can even be running on different machines.

If there is not enough server memory available to hold the copied image data (this can happen if you copy a large amount of data, and you're using an X Terminal, as opposed to a workstation), xv will detect this, and fall back to using a file ('.xvclip') in your home directory. Needless to say, this precludes transferring data between xv's running on different machines, but it's better than nothing.

Copy . First, you must select a region to copy, via the selection rectangle mechanism (See "Selection Rectangle" ). Then, use this command to copy the selected data to the 'clipboard'.
Keyboard Equivalent: <Meta> c
Cut . Operates just like the Copy command, except that it also clears the selection to the 'current color', which is set using the pixel measurement tool. See "Displaying Pixel Values" for further information.
Keyboard Equivalent: <Meta> x
Paste . If there is no selection rectangle currently drawn, the first time you issue the Paste command, it will create a selection rectangle the size and shape of the image data that will be pasted. You may move and resize this rectangle as you see fit (See "Selection Rectangle" ). Then, when you have the selection appropriately adjusted, hit Paste a second time to actually paste the clipboard contents onto the image.

On the other hand, if you have a selection rectangle drawn when you hit Paste the first time, the image will be pasted into the selected area immediately.
Keyboard Equivalent: <Meta> v

Clear . Clears the selected region to the 'current color', which is set using the pixel measurement tool. See "Displaying Pixel Values" .
Keyboard Equivalent: <Meta> d

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:

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

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:

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.
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. See "External Programs" for a complete description of the bggen command.
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

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.


This dial sets the 'opaque-itude' 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.


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)


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.


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.


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.