1
0

crop 2.6 KB

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