aboutsummaryrefslogtreecommitdiff
path: root/man/man1/crop.1
blob: c47afac65b922450371539fc7ebb4fa3649530e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
.TH CROP 1
.SH NAME
crop, iconv \- frame, crop, and convert image
.SH SYNOPSIS
.B crop
[
.BI -c
.I red
.I green
.I blue
]
[
.B -i
.I n
|
.B -x
.I dx
|
.B -y
.I dy
|
.B -r
.I minx
.I miny
.I maxx
.I maxy
]
[
.B -t
.I tx
.I ty
]
[
.B -b
.I red
.I green
.I blue
]
[
.I file
]
.PP
.B iconv
[
.B -u
] [
.B -c
.I chandesc
]
[
.I file
]
.SH DESCRIPTION
.I Crop
reads an
.MR image (7)
file (default standard input), crops it, and writes it as a compressed
.MR image (7)
file to standard output.
There are two ways to specify a crop, by color value or by geometry.
They may be combined in a single run of
.IR crop ,
in which case the color value crop will be done first.
.PP
The
.B -c
option takes a red-green-blue triplet as described in
.MR color (3) .
(For example, white
is
.B 255
.B 255
.BR 255 .)
The corresponding color is used as a value to be cut from the outer
edge of the picture; that is, the image is cropped to remove the maximal
outside rectangular strip in which every pixel has the specified color.
.PP
The
.B -i
option insets the image rectangle by a constant amount,
.IR n ,
which may be negative to generate extra space around the image.
The
.B -x
and
.B -y
options are similar, but apply only to the
.I x
or
.I y
coordinates of the image.
.PP
The
.B -r
option specifies an exact rectangle.
.PP
The 
.B -t
option specifies that the image's coordinate system should
be translated by
.IR tx ,
.IR ty
as the last step of processing.
.PP
The
.B -b
option specifies a background color to be used to fill around the image
if the cropped image is larger than the original, such as if the
.B -i
option is given a negative argument.
This can be used to draw a monochrome frame around the image.
The default color is black.
.PP
.I Iconv
changes the format of pixels in the image
.I file
(default standard input) and writes the resulting image to standard output.
Pixels in the image are converted according to the channel descriptor
.IR chandesc ,
(see
.MR image (7) ).
For example, to convert a 4-bit-per-pixel grey-scale image to an 8-bit-per-pixel
color-mapped image,
.I chandesc
should be
.BR m8 .
If
.I chandesc
is not given, the format is unchanged.
The output image is by default compressed; the
.B -u
option turns off the compression.
.SH EXAMPLE
To crop white edges off the picture and add a ten-pixel pink border,
.IP
.EX
crop -c 255 255 255 -i -10 -b 255 150 150 imagefile > cropped
.EE
.SH SOURCE
.B \*9/src/cmd/draw/crop.c
.SH SEE ALSO
.MR image (7) ,
.MR color (3)
.SH BUGS
.I Iconv
should be able to do Floyd-Steinberg error diffusion or dithering
when converting to small image depths.