home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sources / misc / 4192 < prev    next >
Encoding:
Text File  |  1992-12-14  |  57.5 KB  |  1,477 lines

  1. Newsgroups: comp.sources.misc
  2. Path: sparky!kent
  3. From: cristy@eplrx7.es.duPont.com (John Cristy)
  4. Subject:  v34i052:  imagemagick - X11 image processing and display v2.2, Part24/26
  5. Message-ID: <1992Dec15.035913.23089@sparky.imd.sterling.com>
  6. Followup-To: comp.sources.d
  7. X-Md4-Signature: ddc213416383218cd7dc1a0c01672bc8
  8. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  9. Organization: Sterling Software
  10. References: <csm-v34i028=imagemagick.141926@sparky.IMD.Sterling.COM>
  11. Date: Tue, 15 Dec 1992 03:59:13 GMT
  12. Approved: kent@sparky.imd.sterling.com
  13. Lines: 1462
  14.  
  15. Submitted-by: cristy@eplrx7.es.duPont.com (John Cristy)
  16. Posting-number: Volume 34, Issue 52
  17. Archive-name: imagemagick/part24
  18. Environment: UNIX, VMS, X11, SGI, DEC, Cray, Sun, Vax
  19.  
  20. #!/bin/sh
  21. # this is Part.24 (part 24 of a multipart archive)
  22. # do not concatenate these parts, unpack them in order with /bin/sh
  23. # file ImageMagick/montage.man continued
  24. #
  25. if test ! -r _shar_seq_.tmp; then
  26.     echo 'Please unpack part 1 first!'
  27.     exit 1
  28. fi
  29. (read Scheck
  30.  if test "$Scheck" != 24; then
  31.     echo Please unpack part "$Scheck" next!
  32.     exit 1
  33.  else
  34.     exit 0
  35.  fi
  36. ) < _shar_seq_.tmp || exit 1
  37. if test ! -f _shar_wnt_.tmp; then
  38.     echo 'x - still skipping ImageMagick/montage.man'
  39. else
  40. echo 'x - continuing file ImageMagick/montage.man'
  41. sed 's/^X//' << 'SHAR_EOF' >> 'ImageMagick/montage.man' &&
  42. \fP-background\fP command line argument or X resource.  The width and
  43. height of the composite image is determined by the title specified,
  44. the maximum tile size, the number of tiles per row, the tile border
  45. width and height, the image border width, and the label height.  The
  46. number of tiles per row specifies how many images are to appear in each
  47. row of the composite image.  The default is to have an equal number of
  48. images in each row and column of the composite.  A specific value is 
  49. specified with \fB-tiles_per_row\fP.  The tile border width and height,
  50. and the image border width defaults to the value of the X resource
  51. \fB-borderwidth\fP.  It can be changed with the \fB-borderwidth\fP or
  52. \fB-geometry\fP command line argument or X resource.  The label height
  53. is determined by the font you specify with the \fB-font\fP command line
  54. argument or X resource.  If you do not specify a font, a font is
  55. choosen that allows the name of the image to fit the maximum width of a
  56. tiled area.  The label colors is determined by the \fB-background\fP
  57. and \fB-foreground\fP command line argument or X resource.  Note, that
  58. if the background and foreground colors are the same, labels will not
  59. appear.
  60. X
  61. Initially, the composite image title is placed at the top if one is
  62. specified (refer to \fB-foreground\fP X resource).  Next, each image is
  63. set onto the composite image, surrounded by its border color, with its
  64. name centered just below it.  The individual images are left-justified
  65. within the width of the tiled area.  The order of the images is the
  66. same as they appear on the command line unless the images have a scene
  67. keyword.  If a scene number is specified in each image, then the images
  68. are tiled onto the composite in the order of their scene number.  Finally,
  69. the last argument on the command line is the name assigned to the
  70. composite image.  By default, the image is written in the \fIMIFF\fP format
  71. and can be viewed or printed with \fBdisplay(1)\fP.
  72. X
  73. You can specify a particular image format by prefixing \fIfile\fP with
  74. the image type and a colon (i.e. mtv:image) or specify the image type
  75. as the filename suffix (i.e. image.mtv).  See \fBconvert(1)\fP for a
  76. list of valid image formats.  If \fIfile\fP has the extension \fB.Z\fP,
  77. the file size is reduced using Lempel-Ziv coding with \fBcompress\fP.
  78. If \fIfile\fP already exists, you will be prompted as to whether it
  79. should be overwritten.
  80. .SH EXAMPLES
  81. To create a montage of a cockatoo, a parrot, and a hummingbird and write
  82. it to a file called birds, use:
  83. .PP
  84. X     montage cockatoo.miff parrot.miff hummingbird.miff birds.miff
  85. .PP
  86. To tile several bird images so that they are at most 256 pixels in width and
  87. 192 pixels in height, surrounded by a red border, and separated by
  88. 10 pixels of background color, use:
  89. .PP
  90. X     montage -geometry 256x192+10+10 -bordercolor red birds.* montage.miff
  91. X
  92. To create an unlabeled parrot image, 640 by 480 pixels, and surrounded
  93. by a border of black, use:
  94. .PP
  95. X     montage +display -geometry 640x480 -bordercolor black parrot.miff bird.miff
  96. .SH OPTIONS
  97. .TP 5
  98. .B "-aspect_ratio
  99. The original aspect ratio of each image is adhered to unless
  100. \fB\+aspect_ratio\fP is specfified.
  101. X
  102. That is, as each image is tiled onto the composite image it is scaled
  103. to fit the maximum width and height of the tiled area while respecting
  104. the aspect ratio of the original image. \fB\+aspect_ratio\fP means the
  105. image is scaled to exactly the dimensions of the tiled image as
  106. specified by \fB\-geometry\fP.
  107. .TP 5
  108. .B "-clip \fI<width>x<height>+<x offset>+<y offset>\fP"
  109. preferred size and location of the clipped image.  See \fBX(1)\fP for details
  110. about the geometry specification.
  111. X
  112. Use clipping to tile only a particular area of an image.
  113. X
  114. The equivalent X resource for this option is \fBclipGeometry\fP
  115. (class \fBClipGeometry\fP).  See \fBX RESOURCES\fP for details.
  116. .TP 5
  117. .B "-colors \fIvalue\fP"
  118. preferred number of colors in the image.
  119. X
  120. The actual number of colors in the image may be less than your request,
  121. but never more.  Note, this is a color reduction option.  Images with
  122. less unique colors than specified with this option will remain unchanged.
  123. Refer to \fBQuantize(9)\fP for more details.
  124. X
  125. Note, options \fB-dither\fP, \fB-colorspace\fP, and \fB-treedepth\fP affect
  126. the color reduction algorithm.
  127. .TP 5
  128. .B "-colorspace \fIvalue\fP"
  129. the type of colorspace: \fIGRAY\fP, \fIRGB\fP, \fIXYZ\fP, \fIYIQ\fP, or
  130. \fIYUV\fP.
  131. Color reduction, by default, takes place in the RGB color space.
  132. Empirical evidence suggests that distances in color spaces such as YUV
  133. or YIQ correspond to perceptual color differences more closely
  134. than do distances in RGB space.  These color spaces may give better
  135. results when color reducing an image.  Refer to \fBQuantize(9)\fP for
  136. more details.
  137. X
  138. The \fB-colors\fP or \fB-monochrome\fP option is required for this option
  139. to take effect.
  140. .TP 5
  141. .B "-compose \fIoperator\fP"
  142. the type of image composition.
  143. X
  144. By default, each of the composite image pixels are replaced by the
  145. cooresponding image tile pixel. You can choose an alternate composite
  146. operation:
  147. X
  148. X    over
  149. X    in
  150. X    out
  151. X    atop
  152. X    xor
  153. X    plus
  154. X    minus
  155. X    add
  156. X    subtract
  157. X    difference
  158. X    replace
  159. .PP
  160. The operations behaves as follows:
  161. .TP 9
  162. .B over
  163. The result will be the union of the two image shapes, with \fIimage\fP
  164. obscuring \fIcomposite image\fP in the region of overlap.
  165. .TP 9
  166. .B in
  167. The result is simply \fIimage\fP cut by the shape of \fIimage
  168. window\fP.  None of the image data of \fIcomposite image\fP will be in the
  169. result.
  170. .TP 9
  171. .B out
  172. The resulting image is \fIimage\fP with the shape of \fIcomposite image\fP
  173. cut out.
  174. .TP 9
  175. .B atop
  176. The result is the same shape as image \fIcomposite image\fP, with
  177. \fIimage\fP obscuring \fIcomposite image\fP where the image shapes
  178. overlap.  Note this differs from \fBover\fP because the portion of
  179. \fIimage\fP outside \fIcomposite image\fP's shape does not appear in the
  180. result.
  181. .TP 9
  182. .B xor
  183. The result is the image data from both \fIimage\fP and \fIcomposite image\fP
  184. that is outside the overlap region.  The overlap region will be blank.
  185. .TP 9
  186. .B plus
  187. The result is just the sum of the image data.  Output values are
  188. clipped to 255 (no overflow).  This operation is independent
  189. of the alpha channels.
  190. .TP 9
  191. .B minus
  192. The result of \fIimage\fP \- \fIcomposite image\fP, with underflow clipped
  193. to zero.  The alpha channel is ignored (set to 255, full coverage).
  194. .TP 9
  195. .B add
  196. The result of \fIimage\fP + \fIcomposite image\fP, with overflow wrapping
  197. around (\fImod\fP 256).
  198. .TP 9
  199. .B subtract
  200. The result of \fIimage\fP - \fIcomposite image\fP, with underflow wrapping
  201. around (\fImod\fP 256).  The \fBadd\fP and \fBsubtract\fP operators can
  202. be used to perform reversible transformations.
  203. .TP 9
  204. .B difference
  205. The result of abs(\fIimage\fP \- \fIcomposite image\fP).  This is useful
  206. for comparing two very similar images.
  207. .TP 9
  208. .B replace
  209. The resulting image is \fIcomposite image\fP replaced with \fIimage\fP.
  210. Here the alpha information is ignored.
  211. .PP
  212. The image compositor requires an alpha, or matte channel in the image
  213. for some operations.  This extra channel usually defines a mask which
  214. represents a sort of a cookie-cutter for the image.  This is the case
  215. when alpha is 255 (full coverage) for pixels inside the shape, zero
  216. outside, and between zero and 255 on the boundary.  If \fIimage\fP does
  217. not have an alpha channel, it is initialized with 0 for any pixel
  218. matching in color to pixel location (0,0), otherwise 255 (to work
  219. properly \fBborderwidth\fP must be 0).
  220. .TP 5
  221. .B "-compress \fItype\fP"
  222. the type of image compression: \fIQEncoded\fP or \fIRunlengthEncoded\fP.
  223. X
  224. This option specifies the type of image compression for the composite
  225. image.  See \fBMIFF(5)\fP for details.
  226. X
  227. Specify \fB\+compress\fP to store the binary image in an uncompressed format.
  228. The default is the compression type of the specified image file.
  229. .TP 5
  230. .B "-density \fI<width>x<height>
  231. vertical and horizonal density of the image.
  232. X
  233. This option specifies an image density whose interpretation changes
  234. with the type of image.  The default is 72 dots per inch in the
  235. horizonal and vertical direction for Postscript.  Text files default to
  236. 80 characters in width and 60 lines in height.  Use this option to
  237. alter the default density.
  238. .TP 5
  239. .B "-display \fIhost:display[.screen]\fP"
  240. specifies the X server to contact; see \fBX(1)\fP.
  241. X
  242. Specify \fB+display\fP if an X server is not available.  The label font
  243. is obtained from the X server.  If none is available, the composite image
  244. will not have labels.
  245. .TP 5
  246. .B "-dither"
  247. apply Floyd/Steinberg error diffusion to the image.
  248. X
  249. The basic strategy of dithering is to trade intensity resolution for
  250. spatial resolution by averaging the intensities of several neighboring
  251. pixels.  Images which suffer from severe contouring when reducing colors
  252. can be improved with this option.
  253. X
  254. The \fB-colors\fP or \fB-monochrome\fP option is required
  255. for this option to take effect.
  256. .TP 5
  257. .B "-gamma \fIvalue\fP"
  258. level of gamma correction.
  259. X
  260. The same color image displayed on two different workstations may look
  261. different due to differences in the display monitor.  Use gamma
  262. correction to adjust for this color difference.  Reasonable values
  263. extend from 0.8 to 2.3.
  264. .TP 5
  265. .B "-geometry \fI<width>x<height>+<border width>+<border height>\fP"
  266. preferred tile and border size of each tile of the composite image.
  267. See \fBX(1)\fP for details about the geometry specification.  By default,
  268. the tile size is 256x256 and there is no border.
  269. X
  270. The tile size you specify is a maximum size.  Each image is scaled to
  271. fit the maximum size while still retaining its original aspect ratio.
  272. Each image is surrounded by a border whose size in pixels is specified
  273. as \fI<border width>\fP and \fI<border height>\fP and whose color is
  274. the background color.
  275. X
  276. The equivalent X resource for this option is \fBimageGeometry\fP
  277. (class \fBImageGeometry\fP).  See \fBX RESOURCES\fP for details.
  278. .TP 5
  279. .B "-gravity \fIdirection\fP"
  280. direction image gravitates to within a tile.  See \fBX(1)\fP for details
  281. about the gravity specification.
  282. X
  283. A tile of the composite image is a fixed width and height.  However,
  284. the image within the tile may not fill it completely (see
  285. \fB-aspect_ratio\fP).  The direction you specify indicates where to
  286. position the image within the tile.  For example \fICenter\fP gravity
  287. forces the image to be centered within the tile.  By default, the image
  288. gravity is \fICenter\fP.
  289. .TP 5
  290. .B "-monochrome"
  291. transform the image to black and white.
  292. X
  293. Monochrome images can benefit from error diffusion.  Use \fB-dither\fP with
  294. this option to diffuse the error.
  295. .TP 5
  296. .B "-rotate \fIdegrees\fP"
  297. apply Paeth image rotation to the image.
  298. .TP 5
  299. .B "-tiles_per_row \fIvalue\fP"
  300. specifies how many images are to appear in each row of the composite image.
  301. The default is to have an equal number of images in each row and column of
  302. the composite.
  303. .TP 5
  304. .B "-treedepth \fIvalue\fP"
  305. Normally, this integer value is zero or one.  A zero or one tells
  306. \fIMontage\fP to choose a optimal tree depth for the color reduction
  307. algorithm.
  308. X
  309. An optimal depth generally allows the best representation of the source
  310. image with the fastest computational speed and the least amount of
  311. memory.  However, the default depth is inappropriate for some images.
  312. To assure the best representation, try values between 2 and 8 for this
  313. parameter.  Refer to \fBQuantize(9)\fP for more details.
  314. X
  315. The \fB-colors\fP or \fB-monochrome\fP option is required for this option
  316. to take effect.
  317. .TP 5
  318. .B -verbose
  319. print detailed information about the image.
  320. This information is printed: image scene number;  image name;  image size;
  321. the image class (\fIDirectClass\fP or \fIPseudoClass\fP);  the total
  322. number of unique colors;  and the number of seconds to read and write the
  323. image.
  324. .PP
  325. In addition to those listed above, you can specify these standard X
  326. resources as command line options:  -background, -bordercolor, -borderwidth,
  327. -font, -foreground, -title.
  328. See \fBX RESOURCES\fP for details.
  329. .PP
  330. Any option you specify on the command line remains in effect until it is
  331. explicitly changed by specifying the option again with a different effect.
  332. For example, to montage two images, the first with 32 colors and the
  333. second with only 16 colors, use:
  334. .PP
  335. X     montage -colors 32 cockatoo.1 -colors 16 cockatoo.2 cockatoo.miff
  336. .PP
  337. Change \fI-\fP to \fI\+\fP in any option above to reverse its effect.
  338. For example, specify \fB\+dither\fP to not apply error diffusion to an
  339. image.
  340. .PP
  341. \fIfile\fP specifies the image filename.  By default, the image format
  342. is determined by its magic number. To specify a particular image
  343. format, precede the filename with an image format name and a colon
  344. (i.e.  mtv:image) or as the filename suffix (i.e. image.mtv).  See
  345. \fBconvert(1)\fP for a list of valid image formats.  Specify \fIfile\fP
  346. as \fI-\fP for standard input or output.  If \fIfile\fP has the
  347. extension \fB.Z\fP, the file is decoded with \fIuncompress\fP.
  348. X
  349. Note, a composite MIFF image displayed to an X server with
  350. \fIdisplay\fB behaves differently than other images.  You can think of
  351. the composite as a visual image directory.  Choose a particular tile of
  352. the composite and press a button to display it.  See \fBdisplay(1)\fP
  353. and \fBMIFF(5)\fP for details.
  354. X
  355. .SH "X RESOURCES"
  356. \fIMontage\fP options can appear on the command line or in your X
  357. resource file.  Options on the command line supersede values specified
  358. in your X resource file.  See \fBX(1)\fP for more information on X
  359. resources.
  360. X
  361. All \fImontage\fP options have a corresponding X resource.  In addition,
  362. \fImontage\fP uses the following X resources:
  363. .TP 5
  364. .B background (\fPclass\fB Background)
  365. Specifies the preferred color to use for the composite image background.  The
  366. default is black.
  367. .TP 5
  368. .B borderColor (\fPclass\fB BorderColor)
  369. Specifies the preferred color to use for the composite image border.  The
  370. default is white.
  371. .TP 5
  372. .B borderWidth (\fPclass\fB BorderWidth)
  373. Specifies the width in pixels of the composite image border.  The default is 2.
  374. .TP 5
  375. .B font (\fPclass\fB Font)
  376. Specifies the name of the preferred font to use when displaying text
  377. within the composite image.  The default is 9x15, fixed, or 5x8 determined by
  378. the composite image size.
  379. .TP 5
  380. .B foreground (\fPclass\fB Foreground)
  381. Specifies the preferred color to use for text within the composite image.  The
  382. default is white.
  383. .TP 5
  384. .B title (\fPclass\fB Title)
  385. This resource specifies the title to be placed at the top of the composite 
  386. image.  The default is not to place a title at the top of the composite image.
  387. .SH ENVIRONMENT
  388. .TP 5
  389. .B DISPLAY
  390. To get the default host, display number, and screen.
  391. .SH SEE ALSO
  392. display(1), mogrify(1), convert(1), X(1), Quantize(9), MIFF(5), compress(1)
  393. .SH COPYRIGHT
  394. Copyright 1992 E. I. du Pont de Nemours & Company
  395. .PP
  396. Permission to use, copy, modify, distribute, and sell this software and
  397. its documentation for any purpose is hereby granted without fee,
  398. provided that the above copyright notice appear in all copies and that
  399. both that copyright notice and this permission notice appear in
  400. supporting documentation, and that the name of E. I. du Pont de Nemours
  401. & Company not be used in advertising or publicity pertaining to
  402. distribution of the software without specific, written prior
  403. permission.  E. I. du Pont de Nemours & Company makes no representations
  404. about the suitability of this software for any purpose.  It is provided
  405. "as is" without express or implied warranty.
  406. .PP
  407. E. I. du Pont de Nemours & Company disclaims all warranties with regard
  408. to this software, including all implied warranties of merchantability
  409. and fitness, in no event shall E. I. du Pont de Nemours & Company be
  410. liable for any special, indirect or consequential damages or any
  411. damages whatsoever resulting from loss of use, data or profits, whether
  412. in an action of contract, negligence or other tortious action, arising
  413. out of or in connection with the use or performance of this software.
  414. .SH ACKNOWLEDGEMENTS
  415. The MIT X Consortium for making network transparent graphics a reality.
  416. .PP
  417. Michael Halle, Spatial Imaging Group at MIT, for the initial
  418. implementation of Alan Paeth's image rotation algorithm.
  419. .PP
  420. David Pensak, E. I. du Pont de Nemours & Company, for providing a
  421. computing environment that made this program possible.
  422. .PP
  423. Paul Raveling, USC Information Sciences Institute, for the original
  424. idea of using space subdivision for the color reduction algorithm.
  425. .SH AUTHORS
  426. John Cristy, E.I. du Pont de Nemours & Company Incorporated
  427. SHAR_EOF
  428. echo 'File ImageMagick/montage.man is complete' &&
  429. chmod 0644 ImageMagick/montage.man ||
  430. echo 'restore of ImageMagick/montage.man failed'
  431. Wc_c="`wc -c < 'ImageMagick/montage.man'`"
  432. test 17572 -eq "$Wc_c" ||
  433.     echo 'ImageMagick/montage.man: original size 17572, current size' "$Wc_c"
  434. rm -f _shar_wnt_.tmp
  435. fi
  436. # ============= ImageMagick/PreRvIcccm.h ==============
  437. if test -f 'ImageMagick/PreRvIcccm.h' -a X"$1" != X"-c"; then
  438.     echo 'x - skipping ImageMagick/PreRvIcccm.h (File already exists)'
  439.     rm -f _shar_wnt_.tmp
  440. else
  441. > _shar_wnt_.tmp
  442. echo 'x - extracting ImageMagick/PreRvIcccm.h (Text)'
  443. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/PreRvIcccm.h' &&
  444. #ifdef PRE_R5_ICCCM
  445. /*
  446. X  Compatability defines for pre X11R5 ICCCM.
  447. */
  448. extern XrmDatabase
  449. X  XrmGetDatabase();
  450. #endif
  451. X
  452. #ifdef PRE_R4_ICCCM
  453. /*
  454. X  Compatability defines for pre X11R4 ICCCM.
  455. */
  456. #ifdef vms
  457. #define XMaxRequestSize(display)  16384
  458. #endif
  459. X
  460. #define XInductColormap(display,colormap)  XInstallColormap(display,colormap)
  461. #define XUninductColormap(display,colormap)  XUninstallColormap(display,colormap)
  462. X
  463. typedef struct _XTextProperty
  464. {
  465. X  unsigned char
  466. X    *value;
  467. X
  468. X  Atom
  469. X    encoding;
  470. X
  471. X  int
  472. X    format;
  473. X
  474. X  unsigned long
  475. X    nitems;
  476. } XTextProperty;
  477. X
  478. /*
  479. X  Pre R4 ICCCM compatibility routines.
  480. */
  481. char 
  482. X  *XResourceManagerString();
  483. X
  484. extern int
  485. X  XWMGeometry();
  486. X
  487. extern Status
  488. X  XGetRGBColormaps(),
  489. X  XGetWMName(),
  490. X  XReconfigureWMWindow(),
  491. X  XSetWMProtocols(),
  492. X  XWithdrawWindow();
  493. X
  494. extern XClassHint
  495. X  *XAllocClassHint();
  496. X
  497. extern XIconSize
  498. X  *XAllocIconSize();
  499. X
  500. extern XSizeHints
  501. X  *XAllocSizeHints();
  502. X
  503. extern XStandardColormap
  504. X  *XAllocStandardColormap();
  505. X
  506. extern XWMHints
  507. X  *XAllocWMHints();
  508. X
  509. extern VisualID
  510. X  XVisualIDFromVisual();
  511. X
  512. extern void
  513. X  XrmDestroyDatabase(),
  514. X  XSetWMProperties();
  515. #else
  516. #define XInductColormap(display,colormap)
  517. #define XUninductColormap(display,colormap)
  518. #endif
  519. SHAR_EOF
  520. chmod 0644 ImageMagick/PreRvIcccm.h ||
  521. echo 'restore of ImageMagick/PreRvIcccm.h failed'
  522. Wc_c="`wc -c < 'ImageMagick/PreRvIcccm.h'`"
  523. test 1201 -eq "$Wc_c" ||
  524.     echo 'ImageMagick/PreRvIcccm.h: original size 1201, current size' "$Wc_c"
  525. rm -f _shar_wnt_.tmp
  526. fi
  527. # ============= ImageMagick/quantize.man ==============
  528. if test -f 'ImageMagick/quantize.man' -a X"$1" != X"-c"; then
  529.     echo 'x - skipping ImageMagick/quantize.man (File already exists)'
  530.     rm -f _shar_wnt_.tmp
  531. else
  532. > _shar_wnt_.tmp
  533. echo 'x - extracting ImageMagick/quantize.man (Text)'
  534. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/quantize.man' &&
  535. .ad l
  536. .nh
  537. .TH QUANTIZE 9 "10 October 1992" "ImageMagick"
  538. .SH NAME
  539. Quantize - ImageMagick's color reduction algorithm.
  540. .SH SYNOPSIS
  541. .B #include <image.h>
  542. .SH DESCRIPTION
  543. This document describes how \fIImageMagick\fP performs color reduction on an
  544. image.  To fully understand this document, you should have a knowledge
  545. of basic imaging techniques and the tree data structure and terminology.
  546. .PP
  547. For purposes of color allocation, an image is a set of \fIn\fP pixels,
  548. where each pixel is a point in RGB space.  RGB space is a 3-dimensional
  549. vector space, and each pixel, \fIp\d\s-3i\s0\u\fP,  is defined by an
  550. ordered triple of red, green, and blue coordinates, (\fIr\d\s-3i\s0\u,
  551. g\d\s-3i\s0\u, b\d\s-3i\s0\u\fP).
  552. .PP
  553. Each primary color component (red, green, or blue) represents an
  554. intensity which varies linearly from 0 to a maximum value,
  555. \fIc\d\s-3max\s0\u\fP, which corresponds to full saturation of that
  556. color.  Color allocation is defined over a domain consisting of the
  557. cube in RGB space with opposite vertices at (0,0,0) and
  558. (\fIc\d\s-3max\s0\u,c\d\s-3max\s0\u,c\d\s-3max\s0\u\fP).  \fIImageMagick\fP
  559. requires \fIc\d\s-3max\s0\u = 255\fP.
  560. .PP
  561. The algorithm maps this domain onto a tree in which each node
  562. represents a cube within that domain.  In the following discussion,
  563. these cubes are defined by the coordinate of two opposite vertices: The
  564. vertex nearest the origin in RGB space and the vertex farthest from the
  565. origin.
  566. .PP
  567. The tree's root node represents the the entire domain, (0,0,0) through
  568. (\fIc\d\s-3max\s0\u,c\d\s-3max\s0\u,c\d\s-3max\s0\u\fP).  Each lower level in
  569. the tree is generated by subdividing one node's cube into eight smaller
  570. cubes of equal size.  This corresponds to bisecting the parent cube
  571. with planes passing through the midpoints of each edge.
  572. .PP
  573. The basic algorithm operates in three phases:  \fBClassification,
  574. Reduction\fP, and \fBAssignment\fP.  \fBClassification\fP builds a
  575. color description tree for the image.  \fBReduction\fP collapses the
  576. tree until the number it represents, at most, is the number of colors
  577. desired in the output image.  \fBAssignment\fP defines the output
  578. image's color map and sets each pixel's color by reclassification in
  579. the reduced tree.
  580. .PP
  581. \fBClassification\fP begins by initializing a color description tree of
  582. sufficient depth to represent each possible input color in a leaf.
  583. However, it is impractical to generate a fully-formed color description
  584. tree in the classification phase for realistic values of
  585. \fIc\d\s-3max\s0\u\fP.  If color components in the input image are
  586. quantized to \fIk\fP-bit precision, so that \fIc\d\s-3max\s0\u =
  587. 2\u\s-3k\s0\d-1\fP, the tree would need \fIk\fP levels below the root
  588. node to allow representing each possible input color in a leaf.  This
  589. becomes prohibitive because the tree's total number of nodes is
  590. .PP
  591. X        \fI\s+6\(*S\u\s-9 k\d\di=1\s0 8k\fP\s0\u
  592. .PP
  593. A complete tree would require 19,173,961 nodes for \fIk = 8,
  594. c\d\s-3max\s0\u = 255\fP.  Therefore, to avoid building a fully
  595. populated tree, \fIImageMagick\fP: (1) Initializes data structures for
  596. nodes only as they are needed; (2) Chooses a maximum depth for the tree
  597. as a function of the desired number of colors in the output image
  598. (currently \fIlog\d\s-34\s0\u(colormap size)\+2\fP).  A tree of this
  599. depth generally allows the best representation of the source image with
  600. the fastest computational speed and the least amount of memory.
  601. However, the default depth is inappropriate for some images.
  602. Therefore, the caller can request a specific tree depth.
  603. .PP
  604. For each pixel in the input image, classification scans downward from
  605. the root of the color description tree.  At each level of the tree, it
  606. identifies the single node which represents a cube in RGB space
  607. containing the pixel's color.  It updates the following data for each
  608. such node:
  609. .TP 5
  610. .B n\d\s-31\s0\u:
  611. Number of pixels whose color is contained in the RGB cube which this
  612. node represents;
  613. .TP 5
  614. .B n\d\s-32\s0\u:
  615. Number of pixels whose color is not represented in a node at lower
  616. depth in the tree;  initially,  \fIn\d\s-32\s0\u = 0\fP for all nodes
  617. except leaves of the tree.
  618. .TP 5
  619. .B S\d\s-3r\s0\u, S\d\s-3g\s0\u, S\d\s-3b\s0\u:
  620. Sums of the red, green, and blue component values for all pixels not
  621. classified at a lower depth.  The combination of these sums and
  622. \fIn\d\s-32\s0\u\fP will ultimately characterize the mean color of a
  623. set of pixels represented by this node.
  624. .PP
  625. \fBReduction\fP repeatedly prunes the tree until the number of nodes with
  626. \fIn\d\s-32\s0\u  > 0\fP is less than or equal to the maximum number of colors
  627. allowed in the output image.  On any given iteration over the tree, it
  628. selects those nodes whose \fIn\d\s-31\s0\u\fP count is minimal for pruning and
  629. merges their color statistics upward.  It uses a pruning threshold,
  630. \fIn\d\s-3p\s0\u\fP, to govern node selection as follows:
  631. .PP
  632. X  n\d\s-3p\s0\u = 0
  633. X  while number of nodes with (n\d\s-32\s0\u > 0) > required maximum number of colors
  634. X      prune all nodes such that n\d\s-31\s0\u <= n\d\s-3p\s0\u
  635. X      Set n\d\s-3p\s0\u  to minimum n\d\s-31\s0\u  in remaining nodes
  636. .PP
  637. When a node to be pruned has offspring, the pruning procedure invokes
  638. itself recursively in order to prune the tree from the leaves upward.
  639. The values of \fIn\d\s-32\s0\u  S\d\s-3r\s0\u, S\d\s-3g\s0\u,\fP  and
  640. \fIS\d\s-3b\s0\u\fP in a node being pruned are always added to the
  641. corresponding data in that node's parent.  This retains the pruned
  642. node's color characteristics for later averaging.
  643. .PP
  644. For each node,  \fIn\d\s-32\s0\u\fP pixels exist for which that node
  645. represents the smallest volume in RGB space containing those pixel's
  646. colors.  When \fIn\d\s-32\s0\u  > 0\fP the node will uniquely define a
  647. color in the output image.  At the beginning of reduction,
  648. \fIn\d\s-32\s0\u = 0\fP  for all nodes except the leaves of the tree
  649. which represent colors present in the input image.
  650. .PP
  651. The other pixel count, \fIn\d\s-31\s0\u\fP,  indicates the total
  652. number of colors within the cubic volume which the node represents.
  653. This includes \fIn\d\s-31\s0\u - n\d\s-32\s0\u\fP pixels whose colors
  654. should be defined by nodes at a lower level in the tree.
  655. .PP
  656. \fBAssignment\fP generates the output image from the pruned tree.  The
  657. output image consists of two parts:  (1)  A color map, which is an
  658. array of color descriptions (RGB triples) for each color present in the
  659. output image; (2)  A pixel array, which represents each pixel as an
  660. index into the color map array.
  661. .PP
  662. First, the assignment phase makes one pass over the pruned color
  663. description tree to establish the image's color map.  For each node
  664. with \fIn\d\s-32\s0\u > 0\fP, it divides \fIS\d\s-3r\s0\u,
  665. S\d\s-3g\s0\u\fP, and \fPS\d\s-3b\s0\u\fP by \fIn\d\s-32\s0\u\fP.  This
  666. produces the mean color of all pixels that classify no lower than this
  667. node.  Each of these colors becomes an entry in the color map.
  668. .PP
  669. Finally, the assignment phase reclassifies each pixel in the pruned
  670. tree to identify the deepest node containing the pixel's color.  The
  671. pixel's value in the pixel array becomes the index of this node's mean
  672. color in the color map.
  673. .PP
  674. Empirical evidence suggests that distances in color spaces such as
  675. YUV, or YIQ correspond to perceptual color differences more closely
  676. than do distances in RGB space.  These color spaces may give better
  677. results when color reducing an image.  Here the algorithm is as described
  678. except each pixel is a point in the alternate color space.  For convenience,
  679. the color components are normalized to the range 0 to a maximum value,
  680. \fIc\d\s-3max\s0\u\fP.  The color reduction can then proceed as described.
  681. .SH "MEASURING COLOR REDUCTION ERROR"
  682. .PP
  683. Depending on the image, the color reduction error may be obvious or
  684. invisible.  Images with high spatial frequencies (such as hair or
  685. grass) will show error much less than pictures with large smoothly
  686. shaded areas (such as faces).  This is because the high-frequency
  687. contour edges introduced by the color reduction process are masked by
  688. the high frequencies in the image.
  689. .PP
  690. To measure the difference between the original and color reduced images
  691. (the total color reduction error), \fIImageMagick\fP sums over all pixels
  692. in an image the distance squared in RGB space between each original
  693. pixel value and its color reduced value. \fIImageMagick\fP prints several error
  694. measurements including the mean error per pixel, the normalized mean error,
  695. and the normalized maximum error.
  696. .PP
  697. The normalized error measurement can be used to compare images.  In
  698. general, the closer the mean error is to zero the more the quantized
  699. image resembles the source image.  Ideally, the error should be
  700. perceptually-based, since the human eye is the final judge of
  701. quantization quality.
  702. .PP
  703. These errors are measured and printed when \fB-verbose\fP and \fB-colors\fI
  704. are specified on the command line:
  705. .TP 5
  706. .B mean error per pixel:
  707. is the mean error for any single pixel in the image.
  708. .TP 5
  709. .B normalized mean square error:
  710. is the normalized mean square quantization error for any single pixel in the
  711. image.
  712. X
  713. This distance measure is normalized to a range between 0 and 1.  It is
  714. independent of the range of red, green, and blue values in the image.
  715. .TP 5
  716. .B normalized maximum square error:
  717. is the largest normalized square quantization error for any single
  718. pixel in the image.
  719. X
  720. This distance measure is normalized to a range between 0 and 1.  It is
  721. independent of the range of red, green, and blue values in the image.
  722. .SH SEE ALSO
  723. display(1), animate(1), mogrify(1), import(1), MIFF(5)
  724. .SH COPYRIGHT
  725. Copyright 1992 E. I. du Pont de Nemours & Company
  726. .PP
  727. Permission to use, copy, modify, distribute, and sell this software and
  728. its documentation for any purpose is hereby granted without fee,
  729. provided that the above copyright notice appear in all copies and that
  730. both that copyright notice and this permission notice appear in
  731. supporting documentation, and that the name of E. I. du Pont de Nemours
  732. & Company not be used in advertising or publicity pertaining to
  733. distribution of the software without specific, written prior
  734. permission.  E. I. du Pont de Nemours & Company makes no representations
  735. about the suitability of this software for any purpose.  It is provided
  736. "as is" without express or implied warranty.
  737. .PP
  738. E. I. du Pont de Nemours & Company disclaims all warranties with regard
  739. to this software, including all implied warranties of merchantability
  740. and fitness, in no event shall E. I. du Pont de Nemours & Company be
  741. liable for any special, indirect or consequential damages or any
  742. damages whatsoever resulting from loss of use, data or profits, whether
  743. in an action of contract, negligence or other tortious action, arising
  744. out of or in connection with the use or performance of this software.
  745. .SH ACKNOWLEDGEMENTS
  746. Paul Raveling, USC Information Sciences Institute, for the original
  747. idea of using space subdivision for the color reduction algorithm.
  748. With Paul's permission, this document is an adaptation from a document he
  749. wrote.
  750. .SH AUTHORS
  751. John Cristy, E.I. du Pont de Nemours & Company Incorporated
  752. SHAR_EOF
  753. chmod 0644 ImageMagick/quantize.man ||
  754. echo 'restore of ImageMagick/quantize.man failed'
  755. Wc_c="`wc -c < 'ImageMagick/quantize.man'`"
  756. test 11043 -eq "$Wc_c" ||
  757.     echo 'ImageMagick/quantize.man: original size 11043, current size' "$Wc_c"
  758. rm -f _shar_wnt_.tmp
  759. fi
  760. # ============= ImageMagick/compress.h ==============
  761. if test -f 'ImageMagick/compress.h' -a X"$1" != X"-c"; then
  762.     echo 'x - skipping ImageMagick/compress.h (File already exists)'
  763.     rm -f _shar_wnt_.tmp
  764. else
  765. > _shar_wnt_.tmp
  766. echo 'x - extracting ImageMagick/compress.h (Text)'
  767. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/compress.h' &&
  768. /*
  769. X  Compress utility routines.
  770. */
  771. extern unsigned int
  772. X  HuffmanEncodeImage _Declare((Image *)),
  773. X  LZWDecodeImage _Declare((Image *)),
  774. X  LZWEncodeImage _Declare((Image *,unsigned int)),
  775. X  QDecodeImage _Declare((unsigned char *,unsigned char *,unsigned int,
  776. X    unsigned int)),
  777. X  QEncodeImage _Declare((unsigned char *,unsigned char *,unsigned int,
  778. X    unsigned int));
  779. SHAR_EOF
  780. chmod 0644 ImageMagick/compress.h ||
  781. echo 'restore of ImageMagick/compress.h failed'
  782. Wc_c="`wc -c < 'ImageMagick/compress.h'`"
  783. test 368 -eq "$Wc_c" ||
  784.     echo 'ImageMagick/compress.h: original size 368, current size' "$Wc_c"
  785. rm -f _shar_wnt_.tmp
  786. fi
  787. # ============= ImageMagick/XWDFile.h ==============
  788. if test -f 'ImageMagick/XWDFile.h' -a X"$1" != X"-c"; then
  789.     echo 'x - skipping ImageMagick/XWDFile.h (File already exists)'
  790.     rm -f _shar_wnt_.tmp
  791. else
  792. > _shar_wnt_.tmp
  793. echo 'x - extracting ImageMagick/XWDFile.h (Text)'
  794. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/XWDFile.h' &&
  795. /* Copyright 1985, 1986, Massachusetts Institute of Technology */
  796. X
  797. /* $XConsortium: XWDFile.h,v 1.12 89/10/08 16:33:57 rws Exp $ */
  798. /*
  799. X * XWDFile.h    MIT Project Athena, X Window system window raster
  800. X *        image dumper, dump file format header file.
  801. X *
  802. X *  Author:    Tony Della Fera, DEC
  803. X *        27-Jun-85
  804. X * 
  805. X * Modifier:    William F. Wyatt, SAO
  806. X *              18-Nov-86  - version 6 for saving/restoring color maps
  807. X */
  808. X
  809. X
  810. /*
  811. X * This is not portable between machines of differing word sizes.  To make
  812. X * it portable, do the following things:
  813. X *
  814. X *     o  #include <X11/Xmd.h>
  815. X *     o  remove the typedef for xwdval
  816. X *     o  replace all instances of xwdval with the appropriate CARD32 ... B32
  817. X *     o  make sure that XWDFileHeader is padded to quadword boundaries
  818. X *     o  make sure the window name is written out quadword aligned
  819. X *     o  create an XWDColor structure that contains the same fields as XColor
  820. X *        but which is defined in terms of CARD32 B32, CARD16 B16, and CARD8
  821. X *     o  convert XColor structures to XWDColor structures in xwd
  822. X *     o  remove all xwdval casts from xwd
  823. X *     o  pack image data before writing out if necessary
  824. X *     o  replace casts from xwdval objects in xwud with cvtINT macros
  825. X *     o  convert XWDColor structures to XColor structures
  826. X *     o  unpack data after reading in if necessary
  827. X */
  828. X
  829. X
  830. #include <X11/Xmd.h>
  831. X
  832. #define XWD_FILE_VERSION 7
  833. #ifdef WORD64
  834. #define sz_XWDheader 104
  835. #else
  836. #define sz_XWDheader 100
  837. #endif
  838. #define sz_XWDColor 12
  839. X
  840. typedef CARD32 xwdval;        /* for old broken programs */
  841. X
  842. typedef struct _xwd_file_header {
  843. X    CARD32 header_size B32;  /* Size of the entire file header (bytes). */
  844. X    CARD32 file_version B32;    /* XWD_FILE_VERSION */
  845. X    CARD32 pixmap_format B32;    /* Pixmap format */
  846. X    CARD32 pixmap_depth B32;    /* Pixmap depth */
  847. X    CARD32 pixmap_width B32;    /* Pixmap width */
  848. X    CARD32 pixmap_height B32;    /* Pixmap height */
  849. X    CARD32 xoffset B32;        /* Bitmap x offset */
  850. X    CARD32 byte_order B32;        /* MSBFirst, LSBFirst */
  851. X    CARD32 bitmap_unit B32;        /* Bitmap unit */
  852. X    CARD32 bitmap_bit_order B32;    /* MSBFirst, LSBFirst */
  853. X    CARD32 bitmap_pad B32;        /* Bitmap scanline pad */
  854. X    CARD32 bits_per_pixel B32;    /* Bits per pixel */
  855. X    CARD32 bytes_per_line B32;    /* Bytes per scanline */
  856. X    CARD32 visual_class B32;    /* Class of colormap */
  857. X    CARD32 red_mask B32;        /* Z red mask */
  858. X    CARD32 green_mask B32;        /* Z green mask */
  859. X    CARD32 blue_mask B32;        /* Z blue mask */
  860. X    CARD32 bits_per_rgb B32;    /* Log2 of distinct color values */
  861. X    CARD32 colormap_entries B32;    /* Number of entries in colormap */
  862. X    CARD32 ncolors B32;        /* Number of Color structures */
  863. X    CARD32 window_width B32;    /* Window width */
  864. X    CARD32 window_height B32;    /* Window height */
  865. X    CARD32 window_x B32;        /* Window upper left X coordinate */
  866. X    CARD32 window_y B32;        /* Window upper left Y coordinate */
  867. X    CARD32 window_bdrwidth B32;    /* Window border width */
  868. #ifdef WORD64
  869. X    CARD32 header_end B32;        /* Pad to fill out word */
  870. #endif
  871. } XWDFileHeader;
  872. X
  873. struct {
  874. X        CARD32    pixel B32;
  875. X        CARD16    red B16;
  876. X    CARD16    green B16;
  877. X    CARD16    blue B16;
  878. X        CARD8    flags;
  879. X        CARD8    pad;
  880. } XWDColor;
  881. SHAR_EOF
  882. chmod 0644 ImageMagick/XWDFile.h ||
  883. echo 'restore of ImageMagick/XWDFile.h failed'
  884. Wc_c="`wc -c < 'ImageMagick/XWDFile.h'`"
  885. test 3092 -eq "$Wc_c" ||
  886.     echo 'ImageMagick/XWDFile.h: original size 3092, current size' "$Wc_c"
  887. rm -f _shar_wnt_.tmp
  888. fi
  889. # ============= ImageMagick/alien.h ==============
  890. if test -f 'ImageMagick/alien.h' -a X"$1" != X"-c"; then
  891.     echo 'x - skipping ImageMagick/alien.h (File already exists)'
  892.     rm -f _shar_wnt_.tmp
  893. else
  894. > _shar_wnt_.tmp
  895. echo 'x - extracting ImageMagick/alien.h (Text)'
  896. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/alien.h' &&
  897. X
  898. /*
  899. X  Typedef declarations.
  900. */
  901. typedef struct _AlienInfo
  902. {
  903. X  char
  904. X    filename[2048];
  905. X
  906. X  char
  907. X    *server_name,
  908. X    *font,
  909. X    *geometry,
  910. X    *density;
  911. X
  912. X  unsigned int
  913. X    verbose;
  914. } AlienInfo;
  915. X
  916. /*
  917. X  Alien image format routines.
  918. */
  919. extern Image
  920. X  *ReadAlienImage _Declare((AlienInfo *));
  921. X
  922. extern unsigned int
  923. X  WriteAlienImage _Declare((Image *));
  924. X
  925. extern void
  926. X  GetAlienInfo _Declare((AlienInfo *));
  927. SHAR_EOF
  928. chmod 0644 ImageMagick/alien.h ||
  929. echo 'restore of ImageMagick/alien.h failed'
  930. Wc_c="`wc -c < 'ImageMagick/alien.h'`"
  931. test 403 -eq "$Wc_c" ||
  932.     echo 'ImageMagick/alien.h: original size 403, current size' "$Wc_c"
  933. rm -f _shar_wnt_.tmp
  934. fi
  935. # ============= ImageMagick/SYNOPSIS ==============
  936. if test -f 'ImageMagick/SYNOPSIS' -a X"$1" != X"-c"; then
  937.     echo 'x - skipping ImageMagick/SYNOPSIS (File already exists)'
  938.     rm -f _shar_wnt_.tmp
  939. else
  940. > _shar_wnt_.tmp
  941. echo 'x - extracting ImageMagick/SYNOPSIS (Text)'
  942. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/SYNOPSIS' &&
  943. ImageMagick is a collection of X11 image processing and display utilities.  It
  944. is available on export.lcs.mit.edu as contrib/ImageMagick.tar.Z.
  945. X
  946. cristy@dupont.com
  947. X
  948. ---
  949. X
  950. Display
  951. X
  952. X     Display is a machine architecture independent image
  953. X     processing and display program.  It can display an image on
  954. X     any workstation display running an X server.  Display first
  955. X     determines the hardware capabilities of the workstation.  If
  956. X     the number of unique colors in the image is less than or
  957. X     equal to the number the workstation can support, the image
  958. X     is displayed in an X window.  Otherwise the number of colors
  959. X     in the image is first reduced to match the color resolution
  960. X     of the workstation before it is displayed.
  961. X
  962. X     This means that a continuous-tone 24 bits/pixel image can
  963. X     display on a 8 bit pseudo-color device or monochrome device.
  964. X     In most instances the reduced color image closely resembles
  965. X     the original.  Alternatively, a monochrome or pseudo-color
  966. X     image can display on a continuous-tone 24 bits/pixels
  967. X     device.
  968. X
  969. X
  970. Import
  971. X
  972. X     Import reads an image from any visible window on an X server
  973. X     and outputs it as an image file.  You can capture a single
  974. X     window, the entire screen, or any rectangular portion of the
  975. X     screen.  You can use display (see display(1)) utility for
  976. X     redisplay, printing, editing, formatting, archiving, image
  977. X     processing, etc. of the captured image.
  978. X
  979. X     The target window can be specified by id, name, or may be
  980. X     selected by clicking the mouse in the desired window.  If
  981. X     you press a button and then drag, a rectangle will form
  982. X     which expands and contracts as the mouse moves.  To save the
  983. X     portion of the screen  defined by the rectangle, just
  984. X     release the button.  The keyboard bell is rung once at the
  985. X     beginning of the screen capture and twice when it completes.
  986. X
  987. X
  988. XXtoPS
  989. X
  990. X     XtoPS reads an image from any visible window on an X server
  991. X     and outputs it as Encapsulated Postscript.  You can capture
  992. X     a single window, the entire screen, or any rectangular
  993. X     portion of the screen.  You can view the captured screen
  994. X     with any Postscript compatible viewer or printer.  The
  995. X     Postscript is displayed in color on viewers or printers that
  996. X     support color, otherwise it is displayed as grayscale.
  997. X
  998. X     The target window can be specified by id, name, or may be
  999. X     selected by clicking the mouse in the desired window.  If
  1000. X     you press a button and then drag, a rectangle will form
  1001. X     which expands and contracts as the mouse moves.  To save the
  1002. X     portion of the screen defined by the rectangle, just release
  1003. X     the button.  The keyboard bell is rung once at the beginning
  1004. X     of the screen capture and twice it completes.
  1005. X
  1006. X
  1007. Animate
  1008. X
  1009. X     Animate displays a sequence of images on any workstation
  1010. X     display running an X server.  Animate first determines the
  1011. X     hardware capabilities of the workstation.  If the number of
  1012. X     unique colors in an image is less than or equal to the
  1013. X     number the workstation can support, the image is displayed
  1014. X     in an X window.  Otherwise the number of colors in the image
  1015. X     is first reduced to match the color resolution of the
  1016. X     workstation before it is displayed.
  1017. X
  1018. X     This means that a continuous-tone 24 bits/pixel image can
  1019. X     display on a 8 bit pseudo-color device or monochrome device.
  1020. X     In most instances the reduced color image closely resembles
  1021. X     the original.  Alternatively, a monochrome or pseudo-color
  1022. X     image sequence can display on a continuous-tone 24
  1023. X     bits/pixels device.
  1024. X
  1025. X
  1026. Montage
  1027. X
  1028. X     Montage creates a composite image by combining several
  1029. X     separate images.  The images are tiled on the composite
  1030. X     image with the name of the image optionally appearing just
  1031. X     below the individual tile.
  1032. X
  1033. X
  1034. Mogrify
  1035. X
  1036. X     Mogrify transforms an image or a sequence of images.  These
  1037. X     transforms include image scaling, image rotation, color
  1038. X     reduction, and others.  The transmogrified image overwrites
  1039. X     the original image.
  1040. X
  1041. X
  1042. Convert
  1043. X
  1044. X     Convert converts an input file using one image format to an
  1045. X     output file with a differing image format. By default, the
  1046. X     image format is determined by it's magic number. To specify
  1047. X     a particular image format, precede the filename with an
  1048. X     image format name and a colon (i.e.  mtv:image) or specify
  1049. X     the image type as the filename suffix (i.e. image.mtv).
  1050. X     Specify file as - for standard input or output.  If file has
  1051. X     the extension .Z, the file is decoded with uncompress.
  1052. X
  1053. X     Convert recognizes the following image formats:
  1054. X
  1055. X       Tag       Description
  1056. X       ----------------------------------------------------
  1057. X       AVS
  1058. X       CMYK      Raw cyan, magenta, yellow, and black bytes
  1059. X       FAX       Group 3
  1060. X       GIF
  1061. X       GRAY      Raw gray bytes
  1062. X       JPEG
  1063. X       MIFF      Machine Independant file format
  1064. X       MTV
  1065. X       PNM       Portable bitmap
  1066. X       PS        Postscript
  1067. X       RGB       Raw red, green, and blue bytes
  1068. X       RLE       Utah Raster Toolkit
  1069. X       SUN       SUN raster
  1070. X       TEXT      raw text file; read only
  1071. X       TIFF      Tagged Image File Format
  1072. X       VICAR
  1073. X       X         select image from X server screen; read only
  1074. X       XC        constant image of X server background color
  1075. X       XBM       X11 bitmap
  1076. X       XWD       X11 window dump
  1077. X
  1078. XXTP
  1079. X
  1080. X     Xtp is a utility for retrieving, listing, or printing files
  1081. X     from a remote network site, or sending files to a remote
  1082. X     network site.  Xtp performs most of the same functions as
  1083. X     the ftp program, but does not require any interactive
  1084. X     commands.  You simply specify the file transfer task on the
  1085. X     command line and xtp performs the task automatically.
  1086. SHAR_EOF
  1087. chmod 0644 ImageMagick/SYNOPSIS ||
  1088. echo 'restore of ImageMagick/SYNOPSIS failed'
  1089. Wc_c="`wc -c < 'ImageMagick/SYNOPSIS'`"
  1090. test 5765 -eq "$Wc_c" ||
  1091.     echo 'ImageMagick/SYNOPSIS: original size 5765, current size' "$Wc_c"
  1092. rm -f _shar_wnt_.tmp
  1093. fi
  1094. # ============= ImageMagick/utilities/mogrify.c ==============
  1095. if test ! -d 'ImageMagick/utilities'; then
  1096.     echo 'x - creating directory ImageMagick/utilities'
  1097.     mkdir 'ImageMagick/utilities'
  1098. fi
  1099. if test -f 'ImageMagick/utilities/mogrify.c' -a X"$1" != X"-c"; then
  1100.     echo 'x - skipping ImageMagick/utilities/mogrify.c (File already exists)'
  1101.     rm -f _shar_wnt_.tmp
  1102. else
  1103. > _shar_wnt_.tmp
  1104. echo 'x - extracting ImageMagick/utilities/mogrify.c (Text)'
  1105. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/utilities/mogrify.c' &&
  1106. /*
  1107. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1108. %                                                                             %
  1109. %                                                                             %
  1110. %                                                                             %
  1111. %              M   M   OOO    GGGG  RRRR   IIIII  FFFFF  Y   Y                %
  1112. %              MM MM  O   O  G      R   R    I    F       Y Y                 %
  1113. %              M M M  O   O  G GG   RRRRR    I    FFF      Y                  %
  1114. %              M   M  O   O  G   G  R R      I    F        Y                  %
  1115. %              M   M   OOO    GGG   R  R   IIIII  F        Y                  %
  1116. %                                                                             %
  1117. %                                                                             %
  1118. %               Transmogrify an Image or Sequence of Images.                  %
  1119. %                                                                             %
  1120. %                                                                             %
  1121. %                                                                             %
  1122. %                           Software Design                                   %
  1123. %                             John Cristy                                     %
  1124. %                            December 1992                                    %
  1125. %                                                                             %
  1126. %                                                                             %
  1127. %  Copyright 1992 E. I. du Pont de Nemours & Company                          %
  1128. %                                                                             %
  1129. %  Permission to use, copy, modify, distribute, and sell this software and    %
  1130. %  its documentation for any purpose is hereby granted without fee,           %
  1131. %  provided that the above Copyright notice appear in all copies and that     %
  1132. %  both that Copyright notice and this permission notice appear in            %
  1133. %  supporting documentation, and that the name of E. I. du Pont de Nemours    %
  1134. %  & Company not be used in advertising or publicity pertaining to            %
  1135. %  distribution of the software without specific, written prior               %
  1136. %  permission.  E. I. du Pont de Nemours & Company makes no representations   %
  1137. %  about the suitability of this software for any purpose.  It is provided    %
  1138. %  "as is" without express or implied warranty.                               %
  1139. %                                                                             %
  1140. %  E. I. du Pont de Nemours & Company disclaims all warranties with regard    %
  1141. %  to this software, including all implied warranties of merchantability      %
  1142. %  and fitness, in no event shall E. I. du Pont de Nemours & Company be       %
  1143. %  liable for any special, indirect or consequential damages or any           %
  1144. %  damages whatsoever resulting from loss of use, data or profits, whether    %
  1145. %  in an action of contract, negligence or other tortious action, arising     %
  1146. %  out of or in connection with the use or performance of this software.      %
  1147. %                                                                             %
  1148. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1149. %
  1150. %  `Mogrify' applies one or more image transforms to an image or sequence of
  1151. %   images and overwrites the original image.
  1152. %
  1153. %  The Mogrify program command syntax is:
  1154. %
  1155. %  Usage: mogrify [options ...] file [ [options ...] file ...]
  1156. %
  1157. %  Where options include:
  1158. %    -clip geometry      preferred size and location of the clipped image
  1159. %    -colormap filename  transform image colors to match this set of colors
  1160. %    -colors value       preferred number of colors in the image
  1161. %    -colorspace type    GRAY, RGB, XYZ, YIQ, or YUV
  1162. %    -compress type      RunlengthEncoded or QEncoded
  1163. %    -density geometry   vertical and horizonal density of the image
  1164. %    -display server     obtain image or font from this X server
  1165. %    -dither             apply Floyd/Steinberg error diffusion to image
  1166. %    -enhance            apply a digital filter to enhance a noisy image
  1167. %    -gamma value        level of gamma correction
  1168. %    -geometry geometry  preferred size of the image
  1169. %    -monochrome         transform image to black and white
  1170. %    -noise              reduce noise with a noise peak elimination filter
  1171. %    -normalize          tranform image to span the full range of colors
  1172. %    -reflect            reverse image scanlines
  1173. %    -rotate degrees     apply Paeth rotation to the image
  1174. %    -scale geometry     preferred size factors of the image
  1175. %    -scene value        image scene number
  1176. %    -treedepth value    depth of the color classification tree
  1177. %    -verbose            print detailed information about the image
  1178. %
  1179. %  Change '-' to '+' in any option above to reverse its effect.  For
  1180. %  example, specify +compress to store the image as uncompressed.
  1181. %
  1182. %  By default, the image format of `file' is determined by its magic
  1183. %  number.  To specify a particular image format, precede the filename
  1184. %  with an image format name and a colon (i.e. mtv:image) or specify the
  1185. %  image type as the filename suffix (i.e. image.mtv).  Specify 'file' as
  1186. %  '-' for standard input or output.
  1187. %
  1188. %
  1189. */
  1190. X
  1191. /*
  1192. X  Include declarations.
  1193. */
  1194. #include "display.h"
  1195. #include "image.h"
  1196. #include "alien.h"
  1197. #include "X.h"
  1198. X
  1199. /*
  1200. X  Global declarations.
  1201. */
  1202. char
  1203. X  *application_name;
  1204. X
  1205. /*
  1206. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1207. %                                                                             %
  1208. %                                                                             %
  1209. %                                                                             %
  1210. %   E r r o r                                                                 %
  1211. %                                                                             %
  1212. %                                                                             %
  1213. %                                                                             %
  1214. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1215. %
  1216. %  Function Error displays an error message and then terminates the program.
  1217. %
  1218. %  The format of the Error routine is:
  1219. %
  1220. %      Error(message,qualifier)
  1221. %
  1222. %  A description of each parameter follows:
  1223. %
  1224. %    o message: Specifies the message to display before terminating the
  1225. %      program.
  1226. %
  1227. %    o qualifier: Specifies any qualifier to the message.
  1228. %
  1229. %
  1230. */
  1231. void Error(message,qualifier)
  1232. char
  1233. X  *message,
  1234. X  *qualifier;
  1235. {
  1236. X  (void) fprintf(stderr,"%s: %s",application_name,message);
  1237. X  if (qualifier != (char *) NULL)
  1238. X    (void) fprintf(stderr," (%s)",qualifier);
  1239. X  (void) fprintf(stderr,".\n");
  1240. X  exit(1);
  1241. }
  1242. X
  1243. /*
  1244. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1245. %                                                                             %
  1246. %                                                                             %
  1247. %                                                                             %
  1248. %   U s a g e                                                                 %
  1249. %                                                                             %
  1250. %                                                                             %
  1251. %                                                                             %
  1252. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1253. %
  1254. %  Function Usage displays the program command syntax.
  1255. %
  1256. %  The format of the Usage routine is:
  1257. %
  1258. %      Usage()
  1259. %
  1260. %
  1261. */
  1262. static void Usage()
  1263. {
  1264. X  char
  1265. X    **p;
  1266. X
  1267. X  static char
  1268. X    *options[]=
  1269. X    {
  1270. X      "-clip geometry      preferred size and location of the clipped image",
  1271. X      "-colormap filename  transform image colors to match this set of colors",
  1272. X      "-colors value       preferred number of colors in the image",
  1273. X      "-colorspace type    GRAY, RGB, XYZ, YIQ, or YUV",
  1274. X      "-compress type      RunlengthEncoded or QEncoded",
  1275. X      "-density geometry   vertical and horizonal density of the image",
  1276. X      "-display server     obtain image or font from this X server",
  1277. X      "-dither             apply Floyd/Steinberg error diffusion to image",
  1278. X      "-enhance            apply a digital filter to enhance a noisy image",
  1279. X      "-gamma value        level of gamma correction",
  1280. X      "-geometry geometry  preferred size of the image",
  1281. X      "-monochrome         transform image to black and white",
  1282. X      "-noise              reduce noise with a noise peak elimination filter",
  1283. X      "-normalize          tranform image to span the full range of colors",
  1284. X      "-reflect            reflect the image scanlines",
  1285. X      "-rotate degrees     apply Paeth rotation to the image",
  1286. X      "-scale geometry     preferred size factors of the image",
  1287. X      "-scene number       image scene number",
  1288. X      "-treedepth value    depth of the color classification tree",
  1289. X      "-verbose            print detailed information about the image",
  1290. X      (char *) NULL
  1291. X    };
  1292. X  (void) fprintf(stderr,
  1293. X    "Usage: %s [-options ...] file [ [-options ...] file ...]\n",
  1294. X    application_name);
  1295. X  (void) fprintf(stderr,"\nWhere options include: \n");
  1296. X  for (p=options; *p != (char *) NULL; p++)
  1297. X    (void) fprintf(stderr,"  %s\n",*p);
  1298. X  (void) fprintf(stderr,
  1299. X    "\nChange '-' to '+' in any option above to reverse its effect.  For\n");
  1300. X  (void) fprintf(stderr,
  1301. X    "example, specify +compress to store the image as uncompressed.\n");
  1302. X  (void) fprintf(stderr,
  1303. X    "\nBy default, the image format of `file' is determined by its magic\n");
  1304. X  (void) fprintf(stderr,
  1305. X    "number.  To specify a particular image format, precede the filename\n");
  1306. X  (void) fprintf(stderr,
  1307. X    "with an image format name and a colon (i.e. mtv:image) or specify the\n");
  1308. X  (void) fprintf(stderr,
  1309. X    "image type as the filename suffix (i.e. image.mtv).  Specify 'file' as\n");
  1310. X  (void) fprintf(stderr,"'-' for standard input or output.\n");
  1311. X  exit(1);
  1312. }
  1313. X
  1314. /*
  1315. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1316. %                                                                             %
  1317. %                                                                             %
  1318. %                                                                             %
  1319. %    M a i n                                                                  %
  1320. %                                                                             %
  1321. %                                                                             %
  1322. %                                                                             %
  1323. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1324. %
  1325. %
  1326. */
  1327. int main(argc,argv)
  1328. int
  1329. X  argc;
  1330. X
  1331. char
  1332. X  **argv;
  1333. {
  1334. X  AlienInfo
  1335. X    alien_info;
  1336. X
  1337. X  char
  1338. X    *clip_geometry,
  1339. X    *colormap_filename,
  1340. X    *image_geometry,
  1341. X    *option,
  1342. X    *scale_geometry;
  1343. X
  1344. X  double
  1345. X    gamma;
  1346. X
  1347. X  Image
  1348. X    **images;
  1349. X
  1350. X  int
  1351. X    degrees,
  1352. X    i,
  1353. X    x;
  1354. X
  1355. X  unsigned int
  1356. X    colorspace,
  1357. X    compression,
  1358. X    dither,
  1359. X    enhance,
  1360. X    image_number,
  1361. X    inverse,
  1362. X    maximum_images,
  1363. X    monochrome,
  1364. X    noise,
  1365. X    normalize,
  1366. X    number_colors,
  1367. X    reflect,
  1368. X    scene,
  1369. X    tree_depth,
  1370. X    verbose;
  1371. X
  1372. X  /*
  1373. X    Display usage profile if there are no command line arguments.
  1374. X  */
  1375. X  application_name=(*argv);
  1376. X  if (argc < 2)
  1377. X    Usage();
  1378. X  /*
  1379. X    Set defaults.
  1380. X  */
  1381. X  GetAlienInfo(&alien_info);
  1382. X  clip_geometry=(char *) NULL;
  1383. X  colormap_filename=(char *) NULL;
  1384. X  colorspace=RGBColorspace;
  1385. X  compression=UndefinedCompression;
  1386. X  degrees=0;
  1387. X  dither=False;
  1388. X  enhance=False;
  1389. X  gamma=0.0;
  1390. X  image_geometry=(char *) NULL;
  1391. X  inverse=False;
  1392. X  monochrome=False;
  1393. X  noise=False;
  1394. X  normalize=False;
  1395. X  number_colors=0;
  1396. X  reflect=False;
  1397. X  scale_geometry=(char *) NULL;
  1398. X  scene=0;
  1399. X  tree_depth=0;
  1400. X  verbose=False;
  1401. X  maximum_images=2048;
  1402. X  images=(Image **) malloc(maximum_images*sizeof(Image *));
  1403. X  if (images == (Image **) NULL)
  1404. X    Error("unable to mogrify images","memory allocation failed");
  1405. X  /*
  1406. X    Parse command line.
  1407. X  */
  1408. X  image_number=0;
  1409. X  for (i=1; i < argc; i++)
  1410. X  {
  1411. X    option=argv[i];
  1412. X    if (((int) strlen(option) > 1) && ((*option == '-') || (*option == '+')))
  1413. X      switch (*(option+1))
  1414. X      {
  1415. X        case 'c':
  1416. X        {
  1417. X          if (strncmp("clip",option+1,2) == 0)
  1418. X            {
  1419. X              clip_geometry=(char *) NULL;
  1420. X              if (*option == '-')
  1421. X                {
  1422. X                  i++;
  1423. X                  if (i == argc)
  1424. X                    Error("missing geometry on -clip",(char *) NULL);
  1425. X                  clip_geometry=argv[i];
  1426. X                }
  1427. X              break;
  1428. X            }
  1429. X          if (strncmp("colormap",option+1,7) == 0)
  1430. X            {
  1431. X              colormap_filename=(char *) NULL;
  1432. X              if (*option == '-')
  1433. X                {
  1434. X                  i++;
  1435. X                  if (i == argc)
  1436. X                    Error("missing file name on -colormap",(char *) NULL);
  1437. X                  colormap_filename=argv[i];
  1438. X                }
  1439. X              break;
  1440. X            }
  1441. X          if (strncmp("colors",option+1,7) == 0)
  1442. X            {
  1443. X              number_colors=0;
  1444. X              if (*option == '-')
  1445. X                {
  1446. X                  i++;
  1447. X                  if ((i == argc) || !sscanf(argv[i],"%d",&x))
  1448. X                    Error("missing colors on -colors",(char *) NULL);
  1449. X                  number_colors=atoi(argv[i]);
  1450. X                }
  1451. X              break;
  1452. X            }
  1453. X          if (strncmp("colorspace",option+1,7) == 0)
  1454. X            {
  1455. X              colorspace=RGBColorspace;
  1456. X              if (*option == '-')
  1457. X                {
  1458. X                  i++;
  1459. X                  if (i == argc)
  1460. X                    Error("missing type on -colorspace",(char *) NULL);
  1461. X                  option=argv[i];
  1462. X                  colorspace=UndefinedColorspace;
  1463. X                  if (Latin1Compare("gray",option) == 0)
  1464. X                    colorspace=GRAYColorspace;
  1465. X                  if (Latin1Compare("rgb",option) == 0)
  1466. X                    colorspace=RGBColorspace;
  1467. SHAR_EOF
  1468. true || echo 'restore of ImageMagick/utilities/mogrify.c failed'
  1469. fi
  1470. echo 'End of  part 24'
  1471. echo 'File ImageMagick/utilities/mogrify.c is continued in part 25'
  1472. echo 25 > _shar_seq_.tmp
  1473. exit 0
  1474. exit 0 # Just in case...
  1475.