Name
crop--"Image Cropper"
Current Version
1.1 (16 January 1997)
Location
~ruzon/bin/crop
Syntax
crop <input file> {<identifier> {<number>}}
Parameters
input file | one PPM image
|
identifier | any string legal for filenames (default: swatch)
|
number | a positive integer (default: 1)
|
Starting the Program
The program starts by opening the input image in a new window. The file name
and image size are displayed in the bottom left corner, while the current
image
coordinates are displayed in the lower right. The upper left holds three menus.
Extracting a Sub-Image
The process is started by clicking the left mouse button in the upper left
corner of the portion of the image you wish to crop. A small circle will
appear at the coordinates you have chosen.
If you have chosen fixed-size rectangles from the
Size Menu, a rectangle will appear. If not, you can
specify the other corner by clicking the left mouse button again, which will
cause a rectangle to appear. The circle(s) can always be moved after
placement by dragging them with the middle mouse button.
The Coordinate System
Most image applications number the columns of an MxN image as 0 through M-1
and the rows as 0 through N-1. This utility differs from that scheme in two
major ways. First, the columns are numbered 1 through M and the rows 1 through
N. However, if this was the only place you could put your mouse, it would be
impossible to capture any pixels along the border of the image. For this
reason a 1-pixel wide padding has been placed around the image, meaning that
valid mouse coordinates are 0 through M+1 and 0 through N+1.
The File Menu
Once a rectangle has been drawn, it can be saved by choosing Save from the
menu. The program will save the file using the filename of the format
identifier + number + ".ppm". For example, if no options were
specified on the command line, the sub-image would be saved as
swatch1.ppm. After a save, the number is incremented so that
multiple saves can be performed easily. The identifier could be an entire
path, allowing the save to be performed to a different directory. The
identifier or number can be changed at any point by choosing Options from the
menu. New images can be loaded with the Open command, but currently only
images in the present working directory ending in ".ppm" can be opened.
The fourth option, Quit, allows an exit from the program.
It is important to note that only the pixels that are visible within the
rectangle are saved. The pixels underneath the rectangle itself are not. In
order to be able to save pixels at the borders of the image, it is possible to
place the circles at points whose coordinates are (0,0) or (x+1,y+1). The
upper-left corner of the image has coordinates (1,1). The padding mentioned
above will not show up in any saved images, because it can never be seen
inside the rectangle drawn.
The Edit Menu
The Edit Menu has only one command, Erase, which removes any circles and/or
rectangles that have been placed on the screen.
The Size Menu
Rectangles can be of fixed or of variable sizes. The default is
fixed
rectangles of size 128 by 128. The Fixed Size and Variable Size radio buttons
allow you to choose between them. In addition, the Change Fixed Size option
allows you to change the width and height of fixed-size rectangles to any
value you wish. Changing the type of rectangle automatically erases any
circles or rectangles on the screen.
Bugs
If you try hard enough, you can move a circle placed on the screen so that the
ensuing rectangle incorporates part of the border. This will result in a Tcl
error if you try to save the sub-image. The problem is that the rectangle is
drawn from the center of the circle, but moving a circle involves only the
mouse, which does not have to be in the center of the circle in order to begin
moving.