home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume20 / imagemgc / part01 < prev    next >
Encoding:
Text File  |  1993-07-13  |  56.2 KB  |  1,581 lines

  1. Newsgroups: comp.sources.x
  2. From: cristy@eplrx7.es.duPont.com (Cristy)
  3. Subject: v20i057:  imagemagic - X11 image processing and display, Part01/38
  4. Message-ID: <csx-v20i057=imagemagic.125050@sparky.Sterling.COM>
  5. X-Md4-Signature: 246ac3c004ad18b2be6a1860371e8f39
  6. Sender: chris@sparky.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Wed, 14 Jul 1993 17:52:04 GMT
  9. Approved: chris@sterling.com
  10.  
  11. Submitted-by: cristy@eplrx7.es.duPont.com (Cristy)
  12. Posting-number: Volume 20, Issue 57
  13. Archive-name: imagemagic/part01
  14. Environment: X11
  15. Supersedes: imagemagic: Volume 13, Issue 17-37
  16.  
  17.  
  18.  cristy@dupont.com
  19.  
  20.  ---
  21.  
  22.  Display
  23.  
  24.      Display is a machine architecture independent image
  25.      processing and display program.  It can display an image on
  26.      any workstation display running an X server.  Display first
  27.      determines the hardware capabilities of the workstation.  If
  28.      the number of unique colors in the image is less than or
  29.      equal to the number the workstation can support, the image
  30.      is displayed in an X window.  Otherwise the number of colors
  31.      in the image is first reduced to match the color resolution
  32.      of the workstation before it is displayed.
  33.  
  34.      This means that a continuous-tone 24 bits/pixel image can
  35.      display on a 8 bit pseudo-color device or monochrome device.
  36.      In most instances the reduced color image closely resembles
  37.      the original.  Alternatively, a monochrome or pseudo-color
  38.      image can display on a continuous-tone 24 bits/pixels
  39.      device.
  40.  
  41.  
  42.  Import
  43.  
  44.      Import reads an image from any visible window on an X server
  45.      and outputs it as an image file.  You can capture a single
  46.      window, the entire screen, or any rectangular portion of the
  47.      screen.  You can use display (see display(1)) utility for
  48.      redisplay, printing, editing, formatting, archiving, image
  49.      processing, etc. of the captured image.
  50.  
  51.      The target window can be specified by id, name, or may be
  52.      selected by clicking the mouse in the desired window.  If
  53.      you press a button and then drag, a rectangle will form
  54.      which expands and contracts as the mouse moves.  To save the
  55.      portion of the screen  defined by the rectangle, just
  56.      release the button.  The keyboard bell is rung once at the
  57.      beginning of the screen capture and twice when it completes.
  58.  
  59.  
  60.  Animate
  61.  
  62.      Animate displays a sequence of images on any workstation
  63.      display running an X server.  Animate first determines the
  64.      hardware capabilities of the workstation.  If the number of
  65.      unique colors in an image is less than or equal to the
  66.      number the workstation can support, the image is displayed
  67.      in an X window.  Otherwise the number of colors in the image
  68.      is first reduced to match the color resolution of the
  69.      workstation before it is displayed.
  70.  
  71.      This means that a continuous-tone 24 bits/pixel image can
  72.      display on a 8 bit pseudo-color device or monochrome device.
  73.      In most instances the reduced color image closely resembles
  74.      the original.  Alternatively, a monochrome or pseudo-color
  75.      image sequence can display on a continuous-tone 24
  76.      bits/pixels device.
  77.  
  78.  
  79.  Montage
  80.  
  81.      Montage creates a composite image by combining several
  82.      separate images.  The images are tiled on the composite
  83.      image with the name of the image optionally appearing just
  84.      below the individual tile.
  85.  
  86.  
  87.  Mogrify
  88.  
  89.      Mogrify transforms an image or a sequence of images.  These
  90.      transforms include image scaling, image rotation, color
  91.      reduction, and others.  The transmogrified image overwrites
  92.      the original image.
  93.  
  94.  
  95.  Convert
  96.  
  97.      Convert converts an input file using one image format to an
  98.      output file with a differing image format. By default, the
  99.      image format is determined by it's magic number. To specify
  100.      a particular image format, precede the filename with an
  101.      image format name and a colon (i.e.  ps:image) or specify
  102.      the image type as the filename suffix (i.e. image.ps).
  103.      Specify file as - for standard input or output.  If file has
  104.      the extension .Z, the file is decoded with uncompress.
  105.  
  106.      Convert recognizes the following image formats:
  107.  
  108.        Tag       Description
  109.        ----------------------------------------------------
  110.        ALPHA     Raw alpha bytes
  111.        AVS       AVS X image file
  112.        BMP       Microsoft Windows bitmap image file
  113.        CMYK      Raw cyan, magenta, yellow, and black bytes
  114.        EPS       Adobe Encapsulated Postscript
  115.        FAX       Group 3
  116.        GIF       Compuserve Graphics image file
  117.        GRAY      Raw gray bytes
  118.        JPEG
  119.        MIFF      Machine Independant file format
  120.        MTV
  121.        PCX       ZSoft IBM PC Paintbrush file
  122.        PICT      Apple Macintosh QuickDraw/PICT file
  123.        PNM       Portable bitmap
  124.        PS        Adobe PostScript file
  125.        PS2       Adobe PostScript Level II file
  126.        RGB       Raw red, green, and blue bytes
  127.        RLE       Utah Raster Toolkit
  128.        SUN       SUN raster
  129.        TGA       Truevision Targa image file
  130.        TEXT      raw text file;  read only
  131.        TIFF      Tagged Image File Format
  132.        VICAR
  133.        VIFF      Khoros Visualization image file.
  134.        X         select image from X server screen
  135.        XC        constant image of X server background color
  136.        XBM       X11 bitmap
  137.        XWD       X11 window dump
  138.        YUV       Raw Y, U, and V bytes
  139.  
  140.  
  141.  Combine
  142.  
  143.      Combine combines images to create new images.
  144.  
  145.  
  146.  Segment
  147.  
  148.      Segment segments an image by analyzing the histograms of the
  149.      color components and identifying units that are homogeneous
  150.      with the fuzzy c-means technique.  The scale-space filter
  151.      analyzes the histograms of the three color components of the
  152.      image and identifies a set of classes.  The extents of each
  153.      class is used to coarsely segment the image with
  154.      thresholding.  The color associated with each class is
  155.      determined by the mean color of all pixels within the
  156.      extents of a particular class.  Finally, any unclassified
  157.      pixels are assigned to the closest class with the fuzzy c-
  158.      means technique.
  159.  
  160.  
  161.  XTP
  162.  
  163.      Xtp is a utility for retrieving, listing, or printing files
  164.      from a remote network site, or sending files to a remote
  165.      network site.  Xtp performs most of the same functions as
  166.      the ftp program, but does not require any interactive
  167.      commands.  You simply specify the file transfer task on the
  168.      command line and xtp performs the task automatically.
  169.  
  170. #!/bin/sh
  171. # This is ImageMagick, a shell archive (produced by shar 3.49)
  172. # To extract the files from this archive, save it to a file, remove
  173. # everything above the "!/bin/sh" line above, and type "sh file_name".
  174. #
  175. # made 07/07/1993 14:14 UTC by cristy@dupont.com
  176. # Source directory /tmp_mnt/nfs/zeta/home/cristy/Archive/ImageMagick
  177. #
  178. # existing files will NOT be overwritten unless -c is specified
  179. #
  180. # This is part 1 of a multipart archive                                    
  181. # do not concatenate these parts, unpack them in order with /bin/sh        
  182. #
  183. # This shar contains:
  184. # length  mode       name
  185. # ------ ---------- ------------------------------------------
  186. #   2266 -rw-r--r-- ImageMagick/utilities/Imakefile
  187. #  36611 -rw-r--r-- ImageMagick/utilities/mogrify.c
  188. #   2959 -rw-r--r-- ImageMagick/utilities/Make.com
  189. #   3074 -rw-r--r-- ImageMagick/utilities/Makefile
  190. #  26574 -rw-r--r-- ImageMagick/utilities/convert.c
  191. #  11344 -rw-r--r-- ImageMagick/utilities/convert.man
  192. #  13912 -rw-r--r-- ImageMagick/utilities/mogrify.man
  193. #  23690 -rw-r--r-- ImageMagick/utilities/combine.c
  194. #  11289 -rw-r--r-- ImageMagick/utilities/combine.man
  195. #  59822 -rw-r--r-- ImageMagick/utilities/segment.c
  196. #   8572 -rw-r--r-- ImageMagick/utilities/segment.man
  197. #   1512 -rw-r--r-- ImageMagick/xtp/Imakefile
  198. #   1709 -rw-r--r-- ImageMagick/xtp/Makefile
  199. #   1876 -rw-r--r-- ImageMagick/xtp/README
  200. #    541 -rw-r--r-- ImageMagick/xtp/get
  201. #   5583 -rw-r--r-- ImageMagick/xtp/network.c
  202. #  36662 -rw-r--r-- ImageMagick/xtp/regular.c
  203. #   1299 -rw-r--r-- ImageMagick/xtp/regular.h
  204. #  41691 -rw-r--r-- ImageMagick/xtp/xtp.c
  205. #    819 -rw-r--r-- ImageMagick/xtp/xtp.h
  206. #   6440 -rw-r--r-- ImageMagick/xtp/xtp.man
  207. #    354 -rw-r--r-- ImageMagick/images/README
  208. #  10067 -rw-r--r-- ImageMagick/ChangeLog
  209. #   2673 -rw-r--r-- ImageMagick/Imakefile
  210. #   2134 -rw-r--r-- ImageMagick/Magick.tmpl
  211. #   3648 -rw-r--r-- ImageMagick/Make.com
  212. #   3027 -rw-r--r-- ImageMagick/Makefile
  213. #   2670 -rw-r--r-- ImageMagick/Manifest.ps
  214. #   5666 -rw-r--r-- ImageMagick/PreRvIcccm.c
  215. #   1201 -rw-r--r-- ImageMagick/PreRvIcccm.h
  216. #  12850 -rw-r--r-- ImageMagick/README
  217. #   6075 -rw-r--r-- ImageMagick/SYNOPSIS
  218. # 187033 -rw-r--r-- ImageMagick/X.c
  219. #   5805 -rw-r--r-- ImageMagick/X.h
  220. #   3092 -rw-r--r-- ImageMagick/XWDFile.h
  221. #  11194 -rw-r--r-- ImageMagick/colors.c
  222. #  35828 -rw-r--r-- ImageMagick/shear.c
  223. # 230407 -rw-r--r-- ImageMagick/decode.c
  224. #  73391 -rw-r--r-- ImageMagick/animate.c
  225. #    485 -rw-r--r-- ImageMagick/animate.h
  226. #  17246 -rw-r--r-- ImageMagick/animate.man
  227. #   1328 -rw-r--r-- ImageMagick/display.h
  228. #  68487 -rw-r--r-- ImageMagick/compress.c
  229. #    784 -rw-r--r-- ImageMagick/compress.h
  230. # 202798 -rw-r--r-- ImageMagick/display.c
  231. #  32428 -rw-r--r-- ImageMagick/display.man
  232. #  22346 -rw-r--r-- ImageMagick/import.c
  233. # 119137 -rw-r--r-- ImageMagick/image.c
  234. #   4822 -rw-r--r-- ImageMagick/image.h
  235. #   8036 -rw-r--r-- ImageMagick/import.man
  236. #  60193 -rw-r--r-- ImageMagick/quantize.c
  237. #   9952 -rw-r--r-- ImageMagick/miff.man
  238. #  56463 -rw-r--r-- ImageMagick/montage.c
  239. #  19241 -rw-r--r-- ImageMagick/montage.man
  240. #  21343 -rw-r--r-- ImageMagick/utility.c
  241. #  11046 -rw-r--r-- ImageMagick/quantize.man
  242. #    690 -rw-r--r-- ImageMagick/utility.h
  243. #  17852 -rw-r--r-- ImageMagick/signature.c
  244. # 175688 -rw-r--r-- ImageMagick/encode.c
  245. #     22 -rw-r--r-- ImageMagick/patchlevel.h
  246. #    281 -rw-r--r-- ImageMagick/scenes/Makefile
  247. #    464 -rw-r--r-- ImageMagick/scenes/README
  248. #  28655 -rw-r--r-- ImageMagick/scenes/dna.script
  249. #
  250. if test -r _shar_seq_.tmp; then
  251.     echo 'Must unpack archives in sequence!'
  252.     echo Please unpack part `cat _shar_seq_.tmp` next
  253.     exit 1
  254. fi
  255. # ============= ImageMagick/utilities/Imakefile ==============
  256. if test ! -d 'ImageMagick'; then
  257.     echo 'x - creating directory ImageMagick'
  258.     mkdir 'ImageMagick'
  259. fi
  260. if test ! -d 'ImageMagick/utilities'; then
  261.     echo 'x - creating directory ImageMagick/utilities'
  262.     mkdir 'ImageMagick/utilities'
  263. fi
  264. if test -f 'ImageMagick/utilities/Imakefile' -a X"$1" != X"-c"; then
  265.     echo 'x - skipping ImageMagick/utilities/Imakefile (File already exists)'
  266.     rm -f _shar_wnt_.tmp
  267. else
  268. > _shar_wnt_.tmp
  269. echo 'x - extracting ImageMagick/utilities/Imakefile (Text)'
  270. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/utilities/Imakefile' &&
  271. #
  272. #  Imakefile for ImageMagick image utilities.
  273. #
  274. #  Copyright 1992 E. I. du Pont de Nemours & Company
  275. #
  276. #  Permission to use, copy, modify, distribute, and sell this software and
  277. #  its documentation for any purpose is hereby granted without fee,
  278. #  provided that the above Copyright notice appear in all copies and that
  279. #  both that Copyright notice and this permission notice appear in
  280. #  supporting documentation, and that the name of E. I. du Pont de Nemours
  281. #  & Company not be used in advertising or publicity pertaining to
  282. #  distribution of the software without specific, written prior
  283. #  permission.  E. I. du Pont de Nemours & Company makes no representations
  284. #  about the suitability of this software for any purpose.  It is provided
  285. #  "as is" without express or implied warranty.
  286. #
  287. #  E. I. du Pont de Nemours & Company disclaims all warranties with regard
  288. #  to this software, including all implied warranties of merchantability
  289. #  and fitness, in no event shall E. I. du Pont de Nemours & Company be
  290. #  liable for any special, indirect or consequential damages or any
  291. #  damages whatsoever resulting from loss of use, data or profits, whether
  292. #  in an action of contract, negligence or other tortious action, arising
  293. #  out of or in connection with the use or performance of this software.
  294. #
  295. X
  296. #include "../Magick.tmpl"
  297. X
  298. EXTRA_INCLUDES= -I..
  299. X
  300. MagickObjects= ../X.o ../image.o ../shear.o ../quantize.o ../colors.o \
  301. X  ../signature.o ../decode.o ../encode.o ../compress.o ../utility.o \
  302. X  ../PreRvIcccm.o
  303. X
  304. COMBINEObjects= combine.o $(MagickObjects)
  305. CONVERTObjects= convert.o $(MagickObjects)
  306. MOGRIFYObjects= mogrify.o $(MagickObjects)
  307. SEGMENTObjects= segment.o $(MagickObjects)
  308. X
  309. PROGRAMS= mogrify convert combine segment
  310. X
  311. AllTarget($(PROGRAMS))
  312. X
  313. NormalProgramTarget(mogrify,$(MOGRIFYObjects), , , )
  314. InstallProgram(mogrify,$(LOCALDIR))
  315. InstallManPage(mogrify,$(MANDIR))
  316. NormalProgramTarget(convert,$(CONVERTObjects), , , )
  317. InstallProgram(convert,$(LOCALDIR))
  318. InstallManPage(convert,$(MANDIR))
  319. NormalProgramTarget(combine,$(COMBINEObjects), , , )
  320. InstallProgram(combine,$(LOCALDIR))
  321. InstallManPage(combine,$(MANDIR))
  322. NormalProgramTarget(segment,$(SEGMENTObjects), , , )
  323. InstallProgram(segment,$(LOCALDIR))
  324. InstallManPage(segment,$(MANDIR))
  325. DependTarget()
  326. SHAR_EOF
  327. chmod 0644 ImageMagick/utilities/Imakefile ||
  328. echo 'restore of ImageMagick/utilities/Imakefile failed'
  329. Wc_c="`wc -c < 'ImageMagick/utilities/Imakefile'`"
  330. test 2266 -eq "$Wc_c" ||
  331.     echo 'ImageMagick/utilities/Imakefile: original size 2266, current size' "$Wc_c"
  332. rm -f _shar_wnt_.tmp
  333. fi
  334. # ============= ImageMagick/utilities/mogrify.c ==============
  335. if test -f 'ImageMagick/utilities/mogrify.c' -a X"$1" != X"-c"; then
  336.     echo 'x - skipping ImageMagick/utilities/mogrify.c (File already exists)'
  337.     rm -f _shar_wnt_.tmp
  338. else
  339. > _shar_wnt_.tmp
  340. echo 'x - extracting ImageMagick/utilities/mogrify.c (Text)'
  341. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/utilities/mogrify.c' &&
  342. /*
  343. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  344. %                                                                             %
  345. %                                                                             %
  346. %                                                                             %
  347. %              M   M   OOO    GGGG  RRRR   IIIII  FFFFF  Y   Y                %
  348. %              MM MM  O   O  G      R   R    I    F       Y Y                 %
  349. %              M M M  O   O  G GG   RRRRR    I    FFF      Y                  %
  350. %              M   M  O   O  G   G  R R      I    F        Y                  %
  351. %              M   M   OOO    GGG   R  R   IIIII  F        Y                  %
  352. %                                                                             %
  353. %                                                                             %
  354. %               Transmogrify an Image or Sequence of Images.                  %
  355. %                                                                             %
  356. %                                                                             %
  357. %                                                                             %
  358. %                           Software Design                                   %
  359. %                             John Cristy                                     %
  360. %                            December 1992                                    %
  361. %                                                                             %
  362. %                                                                             %
  363. %  Copyright 1993 E. I. du Pont de Nemours & Company                          %
  364. %                                                                             %
  365. %  Permission to use, copy, modify, distribute, and sell this software and    %
  366. %  its documentation for any purpose is hereby granted without fee,           %
  367. %  provided that the above Copyright notice appear in all copies and that     %
  368. %  both that Copyright notice and this permission notice appear in            %
  369. %  supporting documentation, and that the name of E. I. du Pont de Nemours    %
  370. %  & Company not be used in advertising or publicity pertaining to            %
  371. %  distribution of the software without specific, written prior               %
  372. %  permission.  E. I. du Pont de Nemours & Company makes no representations   %
  373. %  about the suitability of this software for any purpose.  It is provided    %
  374. %  "as is" without express or implied warranty.                               %
  375. %                                                                             %
  376. %  E. I. du Pont de Nemours & Company disclaims all warranties with regard    %
  377. %  to this software, including all implied warranties of merchantability      %
  378. %  and fitness, in no event shall E. I. du Pont de Nemours & Company be       %
  379. %  liable for any special, indirect or consequential damages or any           %
  380. %  damages whatsoever resulting from loss of use, data or profits, whether    %
  381. %  in an action of contract, negligence or other tortious action, arising     %
  382. %  out of or in connection with the use or performance of this software.      %
  383. %                                                                             %
  384. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  385. %
  386. %  `Mogrify' applies one or more image transforms to an image or sequence of
  387. %   images and overwrites the original image.
  388. %
  389. %  The Mogrify program command syntax is:
  390. %
  391. %  Usage: mogrify [options ...] file [ [options ...] file ...]
  392. %
  393. %  Where options include:
  394. %    -border geometry     surround image with a border of color
  395. %    -clip geometry       preferred size and location of the clipped image
  396. %    -colormap filename   transform image colors to match this set of colors
  397. %    -colors value        preferred number of colors in the image
  398. %    -colorspace type     GRAY, RGB, XYZ, YCbCr, YIQ, or YUV
  399. %    -compress type       RunlengthEncoded or QEncoded
  400. %    -density geometry    vertical and horizonal density of the image
  401. %    -display server      obtain image or font from this X server
  402. %    -dither              apply Floyd/Steinberg error diffusion to image
  403. %    -enhance             apply a digital filter to enhance a noisy image
  404. %    -font name           X11 font for displaying text
  405. %    -gamma value         level of gamma correction
  406. %    -geometry geometry   preferred size of the image
  407. %    -interlace type      NONE, LINE, or PLANE
  408. %    -inverse             apply color inversion to image
  409. %    -monochrome          transform image to black and white
  410. %    -noise               reduce noise with a noise peak elimination filter
  411. %    -normalize           tranform image to span the full range of colors
  412. %    -page geometry       size and location of the Postscript page
  413. %    -quality value       JPEG quality setting
  414. %    -reflect             reverse image scanlines
  415. %    -roll geometry       roll an image vertically or horizontally
  416. %    -rotate degrees      apply Paeth rotation to the image
  417. %    -scale geometry      preferred size factors of the image
  418. %    -scene value         image scene number
  419. %    -shear geometry      slide one edge of the image along the X or Y axis
  420. %    -treedepth value     depth of the color classification tree
  421. %    -undercolor geometry control undercolor removal and black generation
  422. %    -verbose             print detailed information about the image
  423. %
  424. %  Change '-' to '+' in any option above to reverse its effect.  For
  425. %  example, specify +compress to store the image as uncompressed.
  426. %
  427. %  By default, the image format of `file' is determined by its magic
  428. %  number.  To specify a particular image format, precede the filename
  429. %  with an image format name and a colon (i.e. ps:image) or specify the
  430. %  image type as the filename suffix (i.e. image.ps).  Specify 'file' as
  431. %  '-' for standard input or output.
  432. %
  433. %
  434. */
  435. X
  436. /*
  437. X  Include declarations.
  438. */
  439. #include "display.h"
  440. #include "image.h"
  441. #include "X.h"
  442. X
  443. /*
  444. X  Global declarations.
  445. */
  446. char
  447. X  *client_name;
  448. X
  449. /*
  450. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  451. %                                                                             %
  452. %                                                                             %
  453. %                                                                             %
  454. %   E r r o r                                                                 %
  455. %                                                                             %
  456. %                                                                             %
  457. %                                                                             %
  458. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  459. %
  460. %  Function Error displays an error message and then terminates the program.
  461. %
  462. %  The format of the Error routine is:
  463. %
  464. %      Error(message,qualifier)
  465. %
  466. %  A description of each parameter follows:
  467. %
  468. %    o message: Specifies the message to display before terminating the
  469. %      program.
  470. %
  471. %    o qualifier: Specifies any qualifier to the message.
  472. %
  473. %
  474. */
  475. void Error(message,qualifier)
  476. char
  477. X  *message,
  478. X  *qualifier;
  479. {
  480. X  (void) fprintf(stderr,"%s: %s",client_name,message);
  481. X  if (qualifier != (char *) NULL)
  482. X    (void) fprintf(stderr," (%s)",qualifier);
  483. X  (void) fprintf(stderr,".\n");
  484. X  exit(1);
  485. }
  486. X
  487. /*
  488. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  489. %                                                                             %
  490. %                                                                             %
  491. %                                                                             %
  492. %   U s a g e                                                                 %
  493. %                                                                             %
  494. %                                                                             %
  495. %                                                                             %
  496. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  497. %
  498. %  Function Usage displays the program command syntax.
  499. %
  500. %  The format of the Usage routine is:
  501. %
  502. %      Usage()
  503. %
  504. %
  505. */
  506. static void Usage()
  507. {
  508. X  char
  509. X    **p;
  510. X
  511. X  static char
  512. X    *options[]=
  513. X    {
  514. X      "-border geometry     surround image with a border of color",
  515. X      "-clip geometry       preferred size and location of the clipped image",
  516. X      "-colormap filename   transform image colors to match this set of colors",
  517. X      "-colors value        preferred number of colors in the image",
  518. X      "-colorspace type     GRAY, RGB, XYZ, YCbCr, YIQ, or YUV",
  519. X      "-compress type       RunlengthEncoded or QEncoded",
  520. X      "-density geometry    vertical and horizonal density of the image",
  521. X      "-display server      obtain image or font from this X server",
  522. X      "-dither              apply Floyd/Steinberg error diffusion to image",
  523. X      "-enhance             apply a digital filter to enhance a noisy image",
  524. X      "-font name           X11 font for displaying text",
  525. X      "-gamma value         level of gamma correction",
  526. X      "-geometry geometry   preferred size of the image",
  527. X      "-interlace type      NONE, LINE, or PLANE",
  528. X      "-inverse             apply color inversion to image",
  529. X      "-monochrome          transform image to black and white",
  530. X      "-noise               reduce noise with a noise peak elimination filter",
  531. X      "-normalize           tranform image to span the full range of colors",
  532. X      "-page geometry       size and location of the Postscript page",
  533. X      "-quality value       JPEG quality setting",
  534. X      "-reflect             reflect the image scanlines",
  535. X      "-roll geometry       roll an image vertically or horizontally",
  536. X      "-rotate degrees      apply Paeth rotation to the image",
  537. X      "-scale geometry      preferred size factors of the image",
  538. X      "-scene number        image scene number",
  539. X      "-shear geometry      slide one edge of the image along the X or Y axis",
  540. X      "-treedepth value     depth of the color classification tree",
  541. X      "-undercolor geometry control undercolor removal and black generation",
  542. X      "-verbose             print detailed information about the image",
  543. X      (char *) NULL
  544. X    };
  545. X  (void) fprintf(stderr,
  546. X    "Usage: %s [-options ...] file [ [-options ...] file ...]\n",client_name);
  547. X  (void) fprintf(stderr,"\nWhere options include: \n");
  548. X  for (p=options; *p != (char *) NULL; p++)
  549. X    (void) fprintf(stderr,"  %s\n",*p);
  550. X  (void) fprintf(stderr,
  551. X    "\nChange '-' to '+' in any option above to reverse its effect.  For\n");
  552. X  (void) fprintf(stderr,
  553. X    "example, specify +compress to store the image as uncompressed.\n");
  554. X  (void) fprintf(stderr,
  555. X    "\nBy default, the image format of `file' is determined by its magic\n");
  556. X  (void) fprintf(stderr,
  557. X    "number.  To specify a particular image format, precede the filename\n");
  558. X  (void) fprintf(stderr,
  559. X    "with an image format name and a colon (i.e. ps:image) or specify the\n");
  560. X  (void) fprintf(stderr,
  561. X    "image type as the filename suffix (i.e. image.ps).  Specify 'file' as\n");
  562. X  (void) fprintf(stderr,"'-' for standard input or output.\n");
  563. X  exit(1);
  564. }
  565. X
  566. /*
  567. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  568. %                                                                             %
  569. %                                                                             %
  570. %                                                                             %
  571. %    M a i n                                                                  %
  572. %                                                                             %
  573. %                                                                             %
  574. %                                                                             %
  575. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  576. %
  577. %
  578. */
  579. int main(argc,argv)
  580. int
  581. X  argc;
  582. X
  583. char
  584. X  **argv;
  585. {
  586. X  char
  587. X    *border_color,
  588. X    *border_geometry,
  589. X    *clip_geometry,
  590. X    *colormap_filename,
  591. X    *density,
  592. X    *font,
  593. X    *image_geometry,
  594. X    *option,
  595. X    *page_geometry,
  596. X    *roll_geometry,
  597. X    *scale_geometry,
  598. X    *server_name,
  599. X    *shear_geometry,
  600. X    *undercolor_geometry;
  601. X
  602. X  double
  603. X    gamma;
  604. X
  605. X  Image
  606. X    **images;
  607. X
  608. X  ImageInfo
  609. X    image_info;
  610. X
  611. X  int
  612. X    degrees,
  613. X    flags,
  614. X    i,
  615. X    x,
  616. X    y;
  617. X         
  618. X  unsigned int
  619. X    colorspace,
  620. X    compression,
  621. X    dither,
  622. X    enhance,
  623. X    height,
  624. X    image_number,
  625. X    interlace,
  626. X    inverse,
  627. X    maximum_images,
  628. X    monochrome,
  629. X    noise,
  630. X    normalize,
  631. X    number_colors,
  632. X    quality,
  633. X    reflect,
  634. X    scene,
  635. X    tree_depth,
  636. X    verbose,
  637. X    width;
  638. X
  639. X  /*
  640. X    Display usage profile if there are no command line arguments.
  641. X  */
  642. X  client_name=(*argv);
  643. X  if (argc < 2)
  644. X    Usage();
  645. X  /*
  646. X    Set defaults.
  647. X  */
  648. X  border_color=(char *) NULL;
  649. X  border_geometry=(char *) NULL;
  650. X  clip_geometry=(char *) NULL;
  651. X  colormap_filename=(char *) NULL;
  652. X  colorspace=RGBColorspace;
  653. X  compression=UndefinedCompression;
  654. X  degrees=0;
  655. X  density=(char *) NULL;
  656. X  dither=False;
  657. X  enhance=False;
  658. X  font=(char *) NULL;
  659. X  gamma=0.0;
  660. X  image_geometry=(char *) NULL;
  661. X  interlace=NoneInterlace;
  662. X  inverse=False;
  663. X  monochrome=False;
  664. X  noise=False;
  665. X  normalize=False;
  666. X  number_colors=0;
  667. X  quality=75;
  668. X  page_geometry=(char *) NULL;
  669. X  reflect=False;
  670. X  roll_geometry=(char *) NULL;
  671. X  scale_geometry=(char *) NULL;
  672. X  server_name=(char *) NULL;
  673. X  shear_geometry=(char *) NULL;
  674. X  scene=0;
  675. X  tree_depth=0;
  676. X  undercolor_geometry=(char *) NULL;
  677. X  verbose=False;
  678. X  maximum_images=2048;
  679. X  images=(Image **) malloc(maximum_images*sizeof(Image *));
  680. X  if (images == (Image **) NULL)
  681. X    Error("unable to mogrify images","memory allocation failed");
  682. X  /*
  683. X    Parse command line.
  684. X  */
  685. X  image_number=0;
  686. X  for (i=1; i < argc; i++)
  687. X  {
  688. X    option=argv[i];
  689. X    if (((int) strlen(option) > 1) && ((*option == '-') || (*option == '+')))
  690. X      switch (*(option+1))
  691. X      {
  692. X        case 'b':
  693. X        {
  694. X          if (strncmp("border",option+1,7) == 0)
  695. X            {
  696. X              border_geometry=(char *) NULL;
  697. X              if (*option == '-')
  698. X                {
  699. X                  i++;
  700. X                  if (i == argc)
  701. X                    Error("missing geometry on -border",(char *) NULL);
  702. X                  border_geometry=argv[i];
  703. X                }
  704. X              break;
  705. X            }
  706. X          if (strncmp("bordercolor",option+1,7) == 0)
  707. X            {
  708. X              border_color=(char *) NULL;
  709. X              if (*option == '-')
  710. X                {
  711. X                  i++;
  712. X                  if (i == argc)
  713. X                    Error("missing color on -bordercolor",(char *) NULL);
  714. X                  border_color=argv[i];
  715. X                }
  716. X              break;
  717. X            }
  718. X          Error("unrecognized option",option);
  719. X          break;
  720. X        }
  721. X        case 'c':
  722. X        {
  723. X          if (strncmp("clip",option+1,2) == 0)
  724. X            {
  725. X              clip_geometry=(char *) NULL;
  726. X              if (*option == '-')
  727. X                {
  728. X                  i++;
  729. X                  if (i == argc)
  730. X                    Error("missing geometry on -clip",(char *) NULL);
  731. X                  clip_geometry=argv[i];
  732. X                }
  733. X              break;
  734. X            }
  735. X          if (strncmp("colormap",option+1,7) == 0)
  736. X            {
  737. X              colormap_filename=(char *) NULL;
  738. X              if (*option == '-')
  739. X                {
  740. X                  i++;
  741. X                  if (i == argc)
  742. X                    Error("missing file name on -colormap",(char *) NULL);
  743. X                  colormap_filename=argv[i];
  744. X                }
  745. X              break;
  746. X            }
  747. X          if (strncmp("colors",option+1,7) == 0)
  748. X            {
  749. X              number_colors=0;
  750. X              if (*option == '-')
  751. X                {
  752. X                  i++;
  753. X                  if ((i == argc) || !sscanf(argv[i],"%d",&x))
  754. X                    Error("missing colors on -colors",(char *) NULL);
  755. X                  number_colors=atoi(argv[i]);
  756. X                }
  757. X              break;
  758. X            }
  759. X          if (strncmp("colorspace",option+1,7) == 0)
  760. X            {
  761. X              colorspace=RGBColorspace;
  762. X              if (*option == '-')
  763. X                {
  764. X                  i++;
  765. X                  if (i == argc)
  766. X                    Error("missing type on -colorspace",(char *) NULL);
  767. X                  option=argv[i];
  768. X                  colorspace=UndefinedColorspace;
  769. X                  if (Latin1Compare("gray",option) == 0)
  770. X                    colorspace=GRAYColorspace;
  771. X                  if (Latin1Compare("rgb",option) == 0)
  772. X                    colorspace=RGBColorspace;
  773. X                  if (Latin1Compare("xyz",option) == 0)
  774. X                    colorspace=XYZColorspace;
  775. X                  if (Latin1Compare("ycbcr",option) == 0)
  776. X                    colorspace=YCbCrColorspace;
  777. X                  if (Latin1Compare("yiq",option) == 0)
  778. X                    colorspace=YIQColorspace;
  779. X                  if (Latin1Compare("yuv",option) == 0)
  780. X                    colorspace=YUVColorspace;
  781. X                  if (colorspace == UndefinedColorspace)
  782. X                    Error("invalid colorspace type on -colorspace",option);
  783. X                }
  784. X              break;
  785. X            }
  786. X          if (strncmp("compress",option+1,3) == 0)
  787. X            {
  788. X              compression=NoCompression;
  789. X              if (*option == '-')
  790. X                {
  791. X                  i++;
  792. X                  if (i == argc)
  793. X                    Error("missing type on -compress",(char *) NULL);
  794. X                  option=argv[i];
  795. X                  if (Latin1Compare("runlengthencoded",option) == 0)
  796. X                    compression=RunlengthEncodedCompression;
  797. X                  else
  798. X                    if (Latin1Compare("qencoded",option) == 0)
  799. X                      compression=QEncodedCompression;
  800. X                    else
  801. X                      Error("invalid compression type on -compress",option);
  802. X                }
  803. X              break;
  804. X            }
  805. X          Error("unrecognized option",option);
  806. X          break;
  807. X        }
  808. X        case 'd':
  809. X        {
  810. X          if (strncmp("density",option+1,3) == 0)
  811. X            {
  812. X              density=(char *) NULL;
  813. X              if (*option == '-')
  814. X                {
  815. X                  i++;
  816. X                  if (i == argc)
  817. X                    Error("missing geometry on -density",(char *) NULL);
  818. X                  density=argv[i];
  819. X                }
  820. X              break;
  821. X            }
  822. X          if (strncmp("display",option+1,3) == 0)
  823. X            {
  824. X              server_name=(char *) NULL;
  825. X              if (*option == '-')
  826. X                {
  827. X                  i++;
  828. X                  if (i == argc)
  829. X                    Error("missing server name on -display",(char *) NULL);
  830. X                  server_name=argv[i];
  831. X                }
  832. X              break;
  833. X            }
  834. X          if (strncmp("dither",option+1,3) == 0)
  835. X            {
  836. X              dither=(*option == '-');
  837. X              break;
  838. X            }
  839. X          Error("unrecognized option",option);
  840. X          break;
  841. X        }
  842. X        case 'e':
  843. X        {
  844. X          enhance=(*option == '-');
  845. X          break;
  846. X        }
  847. X        case 'f':
  848. X        {
  849. X          font=(char *) NULL;
  850. X          if (*option == '-')
  851. X            {
  852. X              i++;
  853. X              if (i == argc)
  854. X                Error("missing font name on -font",(char *) NULL);
  855. X              font=argv[i];
  856. X            }
  857. X          break;
  858. X        }
  859. X        case 'g':
  860. X        {
  861. X          if (strncmp("gamma",option+1,2) == 0)
  862. X            {
  863. X              gamma=0.0;
  864. X              if (*option == '-')
  865. X                {
  866. X                  i++;
  867. X                  if ((i == argc) || !sscanf(argv[i],"%f",(float *) &x))
  868. X                    Error("missing gamma on -gamma",(char *) NULL);
  869. X                  gamma=atof(argv[i]);
  870. X                }
  871. X              break;
  872. X            }
  873. X          if (strncmp("geometry",option+1,2) == 0)
  874. X            {
  875. X              image_geometry=(char *) NULL;
  876. X              if (*option == '-')
  877. X                {
  878. X                  i++;
  879. X                  if (i == argc)
  880. X                    Error("missing geometry on -geometry",(char *) NULL);
  881. X                  image_geometry=argv[i];
  882. X                }
  883. X              break;
  884. X            }
  885. X          Error("unrecognized option",option);
  886. X          break;
  887. X        }
  888. X        case 'h':
  889. X        {
  890. X          if (strncmp("help",option+1,2) == 0)
  891. X            {
  892. X              Usage();
  893. X              break;
  894. X            }
  895. X          Error("unrecognized option",option);
  896. X          break;
  897. X        }
  898. X        case 'i':
  899. X        {
  900. X          if (strncmp("interlace",option+1,3) == 0)
  901. X            {
  902. X              interlace=NoneInterlace;
  903. X              if (*option == '-')
  904. X                {
  905. X                  i++;
  906. X                  if (i == argc)
  907. X                    Error("missing type on -interlace",(char *) NULL);
  908. X                  option=argv[i];
  909. X                  interlace=UndefinedInterlace;
  910. X                  if (Latin1Compare("none",option) == 0)
  911. X                    interlace=NoneInterlace;
  912. X                  if (Latin1Compare("line",option) == 0)
  913. X                    interlace=LineInterlace;
  914. X                  if (Latin1Compare("plane",option) == 0)
  915. X                    interlace=PlaneInterlace;
  916. X                  if (interlace == UndefinedInterlace)
  917. X                    Error("invalid interlace type on -interlace",option);
  918. X                }
  919. X              break;
  920. X            }
  921. X          if (strncmp("inverse",option+1,3) == 0)
  922. X            {
  923. X              inverse=(*option == '-');
  924. X              break;
  925. X            }
  926. X          Error("unrecognized option",option);
  927. X          break;
  928. X        }
  929. X        case 'm':
  930. X        {
  931. X          monochrome=(*option == '-');
  932. X          break;
  933. X        }
  934. X        case 'n':
  935. X        {
  936. X          if (strncmp("noise",option+1,3) == 0)
  937. X            {
  938. X              noise=(*option == '-');
  939. X              break;
  940. X            }
  941. X          if (strncmp("normalize",option+1,3) == 0)
  942. X            {
  943. X              normalize=(*option == '-');
  944. X              break;
  945. X            }
  946. X          Error("unrecognized option",option);
  947. X          break;
  948. X        }
  949. X        case 'p':
  950. X        {
  951. X          if (strncmp("page",option+1,2) == 0)
  952. X            {
  953. X              page_geometry=(char *) NULL;
  954. X              if (*option == '-')
  955. X                {
  956. X                  i++;
  957. X                  if (i == argc)
  958. X                    Error("missing page geometry on -page",(char *) NULL);
  959. X                  page_geometry=argv[i];
  960. X                }
  961. X              break;
  962. X            }
  963. X          Error("unrecognized option",option);
  964. X          break;
  965. X        }
  966. X        case 'q':
  967. X        {
  968. X          i++;
  969. X          if ((i == argc) || !sscanf(argv[i],"%d",&x))
  970. X            Error("missing quality on -quality",(char *) NULL);
  971. X          quality=atoi(argv[i]);;
  972. X          break;
  973. X        }
  974. X        case 'r':
  975. X        {
  976. X          if (strncmp("reflect",option+1,2) == 0)
  977. X            {
  978. X              reflect=(*option == '-');
  979. X              break;
  980. X            }
  981. X          if (strncmp("roll",option+1,3) == 0)
  982. X            {
  983. X              roll_geometry=(char *) NULL;
  984. X              if (*option == '-')
  985. X                {
  986. X                  i++;
  987. X                  if (i == argc)
  988. X                    Error("missing geometry on -roll",(char *) NULL);
  989. X                  roll_geometry=argv[i];
  990. X                }
  991. X              break;
  992. X            }
  993. X          if (strncmp("rotate",option+1,3) == 0)
  994. X            {
  995. X              degrees=0;
  996. X              if (*option == '-')
  997. X                {
  998. X                  i++;
  999. X                  if ((i == argc) || !sscanf(argv[i],"%d",&x))
  1000. X                    Error("missing degrees on -rotate",(char *) NULL);
  1001. X                  degrees=atoi(argv[i]);
  1002. X                }
  1003. X              break;
  1004. X            }
  1005. X          Error("unrecognized option",option);
  1006. X          break;
  1007. X        }
  1008. X        case 's':
  1009. X        {
  1010. X          if (strncmp("scale",option+1,3) == 0)
  1011. X            {
  1012. X              scale_geometry=(char *) NULL;
  1013. X              if (*option == '-')
  1014. X                {
  1015. X                  i++;
  1016. X                  if ((i == argc) || !sscanf(argv[i],"%f",(float *) &x))
  1017. X                    Error("missing scale geometry on -scale",(char *) NULL);
  1018. X                  scale_geometry=argv[i];
  1019. X                }
  1020. X              break;
  1021. X            }
  1022. X          if (strncmp("scene",option+1,3) == 0)
  1023. X            {
  1024. X              scene=0;
  1025. X              if (*option == '-')
  1026. X                {
  1027. X                  i++;
  1028. X                  if ((i == argc) || !sscanf(argv[i],"%d",&x))
  1029. X                    Error("missing scene number on -scene",(char *) NULL);
  1030. X                  scene=atoi(argv[i]);
  1031. X                }
  1032. X              break;
  1033. X            }
  1034. X          if (strncmp("shear",option+1,2) == 0)
  1035. X            {
  1036. X              shear_geometry=(char *) NULL;
  1037. X              if (*option == '-')
  1038. X                {
  1039. X                  i++;
  1040. X                  if ((i == argc) || !sscanf(argv[i],"%f",(float *) &x))
  1041. X                    Error("missing shear geometry on -shear",(char *) NULL);
  1042. X                  shear_geometry=argv[i];
  1043. X                }
  1044. X              break;
  1045. X            }
  1046. X          Error("unrecognized option",option);
  1047. X          break;
  1048. X        }
  1049. X        case 't':
  1050. X        {
  1051. X          tree_depth=0;
  1052. X          if (*option == '-')
  1053. X            {
  1054. X              i++;
  1055. X              if ((i == argc) || !sscanf(argv[i],"%d",&x))
  1056. X                Error("missing depth on -treedepth",(char *) NULL);
  1057. X              tree_depth=atoi(argv[i]);
  1058. X            }
  1059. X          break;
  1060. X        }
  1061. X        case 'u':
  1062. X        {
  1063. X          if (strncmp("undercolor",option+1,2) == 0)
  1064. X            {
  1065. X              undercolor_geometry=(char *) NULL;
  1066. X              if (*option == '-')
  1067. X                {
  1068. X                  i++;
  1069. X                  if ((i == argc) || !sscanf(argv[i],"%f",(float *) &x))
  1070. X                    Error("missing undercolor geometry on -undercolor",
  1071. X                      (char *) NULL);
  1072. X                  undercolor_geometry=argv[i];
  1073. X                }
  1074. X              break;
  1075. X            }
  1076. X          Error("unrecognized option",option);
  1077. X          break;
  1078. X        }
  1079. X        case 'v':
  1080. X        {
  1081. X          verbose=(*option == '-');
  1082. X          break;
  1083. X        }
  1084. X        default:
  1085. X        {
  1086. X          Error("unrecognized option",option);
  1087. X          break;
  1088. X        }
  1089. X      }
  1090. X    else
  1091. X      {
  1092. X        double
  1093. X          normalized_maximum_error,
  1094. X          normalized_mean_error;
  1095. X
  1096. X        Image
  1097. X          *image,
  1098. X          info_image,
  1099. X          *next_image;
  1100. X
  1101. X        time_t
  1102. X          start_time;
  1103. X
  1104. X        unsigned int
  1105. X          mean_error_per_pixel;
  1106. X
  1107. X        unsigned long
  1108. X          total_colors;
  1109. X
  1110. X        /*
  1111. X          Option is a file name: begin by reading image from specified file.
  1112. X        */
  1113. X        start_time=time((time_t *) NULL);
  1114. X        GetImageInfo(&image_info);
  1115. X        (void) strcpy(image_info.filename,option);
  1116. X        image_info.server_name=server_name;
  1117. X        image_info.font=font;
  1118. X        image_info.geometry=image_geometry;
  1119. X        image_info.page=page_geometry;
  1120. X        image_info.density=density;
  1121. X        image_info.border_color=border_color;
  1122. X        image_info.interlace=interlace;
  1123. X        image_info.monochrome=monochrome;
  1124. X        image_info.quality=quality;
  1125. X        image_info.verbose=verbose;
  1126. X        image_info.undercolor=undercolor_geometry;
  1127. X        image=ReadImage(&image_info);
  1128. X        if (image == (Image *) NULL)
  1129. X          if (*option == '-')
  1130. X            break;
  1131. X          else
  1132. X            continue;
  1133. X        do
  1134. X        {
  1135. X          info_image=(*image);
  1136. X          if (scene != 0)
  1137. X            image->scene=scene;
  1138. X          total_colors=0;
  1139. X          /*
  1140. X            Transform image as defined by the clip, image and scale geometries.
  1141. X          */
  1142. X          TransformImage(&image,clip_geometry,image_geometry,scale_geometry);
  1143. X          if (reflect)
  1144. X            {
  1145. X              Image
  1146. X                *reflected_image;
  1147. X
  1148. X              /*
  1149. X                Reverse image scanlines.
  1150. X              */
  1151. X              reflected_image=ReflectImage(image);
  1152. X              if (reflected_image != (Image *) NULL)
  1153. X                {
  1154. X                  DestroyImage(image);
  1155. X                  image=reflected_image;
  1156. X                }
  1157. X            }
  1158. X          if (roll_geometry != (char *) NULL)
  1159. X            {
  1160. X              Image
  1161. X                *rolled_image;
  1162. X
  1163. X              /*
  1164. X                Roll image.
  1165. X              */
  1166. X              x=0;
  1167. X              y=0;
  1168. X              flags=XParseGeometry(roll_geometry,&x,&y,&width,&height);
  1169. X              rolled_image=RollImage(image,x,y);
  1170. X              if (rolled_image != (Image *) NULL)
  1171. X                {
  1172. X                  DestroyImage(image);
  1173. X                  image=rolled_image;
  1174. X                }
  1175. X            }
  1176. X          if (border_geometry != (char *) NULL)
  1177. X            {
  1178. X              Image
  1179. X                *bordered_image;
  1180. X
  1181. X              ImageInfo
  1182. X                border_info;
  1183. X
  1184. X              /*
  1185. X                Surround image with a border of solid color.
  1186. X              */
  1187. X              border_info=image_info;
  1188. X              (void) strcpy(border_info.filename,"XC:border");
  1189. X              border_info.geometry="1x1";
  1190. X              bordered_image=ReadImage(&border_info);
  1191. X              if (bordered_image != (Image *) NULL)
  1192. X                {
  1193. X                  ColorPacket
  1194. X                    border_color;
  1195. X
  1196. X                  RectangleInfo
  1197. X                    border_info;
  1198. X
  1199. X                  DestroyImage(bordered_image);
  1200. X                  border_info.width=0;
  1201. X                  border_info.height=0;
  1202. X                  border_info.x=0;
  1203. X                  border_info.y=0;
  1204. X                  flags=XParseGeometry(border_geometry,&border_info.x,
  1205. X                    &border_info.y,&border_info.width,&border_info.height);
  1206. X                  if ((flags & HeightValue) == 0)
  1207. X                    border_info.height=border_info.width;
  1208. X                  border_color.red=bordered_image->pixels->red;
  1209. X                  border_color.green=bordered_image->pixels->green;
  1210. X                  border_color.blue=bordered_image->pixels->blue;
  1211. X                  bordered_image=BorderImage(image,&border_info,&border_color,
  1212. X                    &border_color);
  1213. X                  if (bordered_image != (Image *) NULL)
  1214. X                    {
  1215. X                      DestroyImage(image);
  1216. X                      bordered_image->class=DirectClass;
  1217. X                      image=bordered_image;
  1218. X                    }
  1219. X                }
  1220. X            }
  1221. X          if (shear_geometry != (char *) NULL)
  1222. X            {
  1223. X              float
  1224. X                x_shear,
  1225. X                y_shear;
  1226. X
  1227. X              Image
  1228. X                *sheared_image;
  1229. X
  1230. X              /*
  1231. X                Shear image.
  1232. X              */
  1233. X              x_shear=0.0;
  1234. X              y_shear=0.0;
  1235. X              (void) sscanf(shear_geometry,"%fx%f",&x_shear,&y_shear);
  1236. X              sheared_image=ShearImage(image,x_shear,y_shear,False);
  1237. X              if (sheared_image != (Image *) NULL)
  1238. X                {
  1239. X                  DestroyImage(image);
  1240. X                  image=sheared_image;
  1241. X                }
  1242. X            }
  1243. X          if ((degrees % 360) != 0)
  1244. X            {
  1245. X              Image
  1246. X                *rotated_image;
  1247. X
  1248. X              /*
  1249. X                Rotate image.
  1250. X              */
  1251. X              rotated_image=RotateImage(image,(double) degrees,False);
  1252. X              if (rotated_image != (Image *) NULL)
  1253. X                {
  1254. X                  DestroyImage(image);
  1255. X                  image=rotated_image;
  1256. X                }
  1257. X            }
  1258. X          if (enhance)
  1259. X            {
  1260. X              Image
  1261. X                *enhanced_image;
  1262. X
  1263. X              /*
  1264. X                Enhance image.
  1265. X              */
  1266. X              enhanced_image=EnhanceImage(image);
  1267. X              if (enhanced_image != (Image *) NULL)
  1268. X                {
  1269. X                  DestroyImage(image);
  1270. X                  image=enhanced_image;
  1271. X                }
  1272. X            }
  1273. X          if (noise)
  1274. X            {
  1275. X              Image
  1276. X                *noisy_image;
  1277. X
  1278. X              /*
  1279. X                Reduce noise in image.
  1280. X              */
  1281. X              noisy_image=NoisyImage(image);
  1282. X              if (noisy_image != (Image *) NULL)
  1283. X                {
  1284. X                  DestroyImage(image);
  1285. X                  image=noisy_image;
  1286. X                }
  1287. X            }
  1288. X          if (gamma > 0.0)
  1289. X            GammaImage(image,gamma);
  1290. X          if (inverse)
  1291. X            InverseImage(image);
  1292. X          if (normalize)
  1293. X            NormalizeImage(image);
  1294. X          if (colorspace == GRAYColorspace)
  1295. X            QuantizeImage(image,256,8,dither,GRAYColorspace,True);
  1296. X          if (monochrome)
  1297. X            QuantizeImage(image,2,8,dither,GRAYColorspace,True);
  1298. X          if (number_colors != 0)
  1299. X            if ((image->class == DirectClass) ||
  1300. X                (image->colors > number_colors))
  1301. X              {
  1302. X                /*
  1303. X                  Reduce the number of colors in the image.
  1304. X                */
  1305. X                QuantizeImage(image,number_colors,tree_depth,dither,colorspace,
  1306. X                  True);
  1307. X                if (verbose)
  1308. X                  {
  1309. X                    /*
  1310. X                      Measure quantization error.
  1311. X                    */
  1312. X                    QuantizationError(image,&mean_error_per_pixel,
  1313. X                      &normalized_mean_error,&normalized_maximum_error);
  1314. X                    total_colors=NumberColors(image,(FILE *) NULL);
  1315. X                  }
  1316. X                SyncImage(image);
  1317. X              }
  1318. X          if (verbose)
  1319. X            {
  1320. X              /*
  1321. X                Display detailed info about the image.
  1322. X              */
  1323. X              (void) fprintf(stderr,"[%u] %s",
  1324. X                image->scene == 0 ? image_number : image->scene,
  1325. X                info_image.filename);
  1326. X              (void) fprintf(stderr," %ux%u",info_image.columns,
  1327. X                info_image.rows);
  1328. X              if ((info_image.columns != image->columns) ||
  1329. X                  (info_image.rows != image->rows))
  1330. X                (void) fprintf(stderr,"=>%ux%u",image->columns,image->rows);
  1331. X              if (image->class == DirectClass)
  1332. X                (void) fprintf(stderr," DirectClass");
  1333. X              else
  1334. X                if (total_colors == 0)
  1335. X                  (void) fprintf(stderr," PseudoClass %uc",image->colors);
  1336. X                else
  1337. X                  {
  1338. X                    (void) fprintf(stderr," PseudoClass %lu=>%uc",total_colors,
  1339. X                      image->colors);
  1340. X                    (void) fprintf(stderr," %u/%.6f/%.6fe",mean_error_per_pixel,
  1341. X                      normalized_mean_error,normalized_maximum_error);
  1342. X                  }
  1343. X              (void) fprintf(stderr," %s %lds\n",image->magick,
  1344. X                time((time_t *) NULL)-start_time+1);
  1345. X            }
  1346. X          if (compression != UndefinedCompression)
  1347. X            image->compression=compression;
  1348. X          else
  1349. X            image->compression=info_image.compression;
  1350. X          (void) strcpy(image->filename,option);
  1351. X          if (number_colors == 0)
  1352. X            (void) WriteImage(&image_info,image);
  1353. X          if (image_number == maximum_images)
  1354. X            {
  1355. X              /*
  1356. X                Increase size of images array.
  1357. X              */
  1358. X              maximum_images<<=1;
  1359. X              images=(Image **)
  1360. X                realloc((char *) images,maximum_images*sizeof(Image *));
  1361. X              if (images == (Image **) NULL)
  1362. X                Error("unable to mogrify images","memory allocation failed");
  1363. X            }
  1364. X          images[image_number++]=image;
  1365. X          next_image=image->next;
  1366. X          if (next_image != (Image *) NULL)
  1367. X            image=next_image;
  1368. X        } while (next_image != (Image *) NULL);
  1369. X        if (number_colors == 0)
  1370. X          DestroyImages(image);
  1371. X      }
  1372. X    }
  1373. X  if (image_number == 0)
  1374. X    Error("missing an image file name",(char *) NULL);
  1375. X  if (number_colors != 0)
  1376. X    {
  1377. X      Image
  1378. X        *colormap_image;
  1379. X
  1380. X      /*
  1381. X        Global colormap option;  reduce colors then write image.
  1382. X      */
  1383. X      colormap_image=(Image *) NULL;
  1384. X      if (colormap_filename != (char *) NULL)
  1385. X        {
  1386. X          (void) strcpy(image_info.filename,colormap_filename);
  1387. X          colormap_image=ReadImage(&image_info);
  1388. X          if (colormap_image == (Image *) NULL)
  1389. X            Error("unable to mogrify images","cannot read image colormap");
  1390. X        }
  1391. X      maximum_images=image_number;
  1392. X      QuantizeImages(images,maximum_images,colormap_image,number_colors,
  1393. X        tree_depth,dither,colorspace,True);
  1394. X      if (colormap_image != (Image *) NULL)
  1395. X        DestroyImage(colormap_image);
  1396. X      for (image_number=0; image_number < maximum_images; image_number++)
  1397. X      {
  1398. X        (void) WriteImage(&image_info,images[image_number]);
  1399. X        DestroyImage(images[image_number]);
  1400. X      }
  1401. X    }
  1402. X  (void) free((char *) images);
  1403. X  return(False);
  1404. }
  1405. SHAR_EOF
  1406. chmod 0644 ImageMagick/utilities/mogrify.c ||
  1407. echo 'restore of ImageMagick/utilities/mogrify.c failed'
  1408. Wc_c="`wc -c < 'ImageMagick/utilities/mogrify.c'`"
  1409. test 36611 -eq "$Wc_c" ||
  1410.     echo 'ImageMagick/utilities/mogrify.c: original size 36611, current size' "$Wc_c"
  1411. rm -f _shar_wnt_.tmp
  1412. fi
  1413. # ============= ImageMagick/utilities/Make.com ==============
  1414. if test -f 'ImageMagick/utilities/Make.com' -a X"$1" != X"-c"; then
  1415.     echo 'x - skipping ImageMagick/utilities/Make.com (File already exists)'
  1416.     rm -f _shar_wnt_.tmp
  1417. else
  1418. > _shar_wnt_.tmp
  1419. echo 'x - extracting ImageMagick/utilities/Make.com (Text)'
  1420. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/utilities/Make.com' &&
  1421. $!
  1422. $! Make ImageMagick X image utilities for VMS.
  1423. $!
  1424. $
  1425. $define/nolog X11 decw$include:
  1426. $define/nolog sys sys$library:
  1427. $link_options="/nodebug/notraceback"
  1428. $define/nolog lnk$library sys$library:vaxcrtl
  1429. $
  1430. $if ((p1.nes."").and.(p1.nes."mogrify")) then goto SkipMogrify
  1431. $write sys$output "Making Mogrify..."
  1432. $call Make mogrify
  1433. $
  1434. $link'link_options' mogrify,[-]X,[-]image,[-]shear,[-]quantize,[-]colors, -
  1435. X  [-]signature,[-]decode,[-]encode,[-]compress,[-]utility,[-]PreRvIcccm, -
  1436. X  sys$input:/opt
  1437. sys$share:decw$xlibshr.exe/share
  1438. $
  1439. $mogrify:==$'f$environment("default")'mogrify
  1440. $write sys$output "..symbol MOGRIFY defined."
  1441. $
  1442. $SkipMogrify:
  1443. $if ((p1.nes."").and.(p1.nes."convert")) then goto SkipConvert
  1444. $write sys$output "Making Convert..."
  1445. $call Make convert
  1446. $
  1447. $link'link_options' convert,[-]X,[-]image,[-]shear,[-]quantize,[-]colors, -
  1448. X  [-]signature,[-]decode,[-]encode,[-]compress,[-]utility,[-]PreRvIcccm, -
  1449. X  sys$input:/opt
  1450. sys$share:decw$xlibshr.exe/share
  1451. $
  1452. $convert:==$'f$environment("default")'convert
  1453. $write sys$output "..symbol CONVERT defined."
  1454. $SkipConvert:
  1455. $if ((p1.nes."").and.(p1.nes."combine")) then goto SkipCombine
  1456. $write sys$output "Making Combine..."
  1457. $call Make combine
  1458. $
  1459. $link'link_options' combine,[-]X,[-]image,[-]shear,[-]quantize,[-]colors, -
  1460. X  [-]signature,[-]decode,[-]encode,[-]compress,[-]utility,[-]PreRvIcccm, -
  1461. X  sys$input:/opt
  1462. sys$share:decw$xlibshr.exe/share
  1463. $
  1464. $combine:==$'f$environment("default")'combine
  1465. $write sys$output "..symbol COMBINE defined."
  1466. $SkipCombine:
  1467. $if ((p1.nes."").and.(p1.nes."segment")) then goto SkipSegment
  1468. $write sys$output "Making Segment..."
  1469. $call Make segment
  1470. $
  1471. $link'link_options' segment,[-]X,[-]image,[-]shear,[-]quantize,[-]colors, -
  1472. X  [-]signature,[-]decode,[-]encode,[-]compress,[-]utility,[-]PreRvIcccm, -
  1473. X  sys$input:/opt
  1474. sys$share:decw$xlibshr.exe/share
  1475. $
  1476. $segment:==$'f$environment("default")'segment
  1477. $write sys$output "..symbol SEGMENT defined."
  1478. $SkipSegment:
  1479. $type sys$input
  1480. X
  1481. Use this command to specify which X server to contact:
  1482. X
  1483. X  $set display/create/node=node_name::
  1484. X
  1485. This can be done automatically from your LOGIN.COM with the following 
  1486. command:
  1487. X
  1488. X  $if (f$trnlmn("sys$rem_node").nes."") then -
  1489. X  $  set display/create/node='f$trnlmn("sys$rem_node")'
  1490. $exit
  1491. $
  1492. $Make: subroutine
  1493. $!
  1494. $! A very primitive "make" (or MMS) hack for DCL.
  1495. $!
  1496. $if (p1.eqs."") then exit
  1497. $source_file=f$search(f$parse(p1,".c"))
  1498. $if (source_file.nes."")
  1499. $  then
  1500. $    object_file=f$parse(source_file,,,"name")+".obj"
  1501. $    object_file=f$search( object_file )
  1502. $    if (object_file.nes."") 
  1503. $      then
  1504. $        object_time=f$file_attribute(object_file,"cdt")
  1505. $        source_time=f$file_attribute(source_file,"cdt")
  1506. $        if (f$cvtime(object_time).lts.f$cvtime(source_time)) then -
  1507. $          object_file=""
  1508. $      endif
  1509. $    if (object_file.eqs."") 
  1510. $      then
  1511. $        write sys$output "Compiling ",p1
  1512. $        cc/nodebug/optimize/include_directory=[-] 'source_file'
  1513. $      endif
  1514. $  endif
  1515. $exit
  1516. $endsubroutine
  1517. X
  1518. SHAR_EOF
  1519. chmod 0644 ImageMagick/utilities/Make.com ||
  1520. echo 'restore of ImageMagick/utilities/Make.com failed'
  1521. Wc_c="`wc -c < 'ImageMagick/utilities/Make.com'`"
  1522. test 2959 -eq "$Wc_c" ||
  1523.     echo 'ImageMagick/utilities/Make.com: original size 2959, current size' "$Wc_c"
  1524. rm -f _shar_wnt_.tmp
  1525. fi
  1526. # ============= ImageMagick/utilities/Makefile ==============
  1527. if test -f 'ImageMagick/utilities/Makefile' -a X"$1" != X"-c"; then
  1528.     echo 'x - skipping ImageMagick/utilities/Makefile (File already exists)'
  1529.     rm -f _shar_wnt_.tmp
  1530. else
  1531. > _shar_wnt_.tmp
  1532. echo 'x - extracting ImageMagick/utilities/Makefile (Text)'
  1533. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/utilities/Makefile' &&
  1534. #
  1535. #  Generic makefile for convert, mogrify, and combine for computers that
  1536. #  do not have xmkmf.
  1537. #
  1538. #  Copyright 1993 E. I. du Pont de Nemours & Company
  1539. #
  1540. #  Permission to use, copy, modify, distribute, and sell this software and
  1541. #  its documentation for any purpose is hereby granted without fee,
  1542. #  provided that the above Copyright notice appear in all copies and that
  1543. #  both that Copyright notice and this permission notice appear in
  1544. #  supporting documentation, and that the name of E. I. du Pont de Nemours
  1545. #  & Company not be used in advertising or publicity pertaining to
  1546. #  distribution of the software without specific, written prior
  1547. #  permission.  E. I. du Pont de Nemours & Company makes no representations
  1548. #  about the suitability of this software for any purpose.  It is provided
  1549. #  "as is" without express or implied warranty.
  1550. #
  1551. #  E. I. du Pont de Nemours & Company disclaims all warranties with regard
  1552. #  to this software, including all implied warranties of merchantability
  1553. #  and fitness, in no event shall E. I. du Pont de Nemours & Company be
  1554. #  liable for any special, indirect or consequential damages or any
  1555. #  damages whatsoever resulting from loss of use, data or profits, whether
  1556. #  in an action of contract, negligence or other tortious action, arising
  1557. #  out of or in connection with the use or performance of this software.
  1558. #
  1559. X
  1560. #
  1561. # Uncomment the following lines if you have the JPEG or TIFF libraries.
  1562. # See README for more details.
  1563. #
  1564. #TOP= ..
  1565. #JPEG_DEFINES= -DHasJPEG
  1566. #JPEG_INCLUDES= -I$(TOP)/jpeg
  1567. SHAR_EOF
  1568. true || echo 'restore of ImageMagick/utilities/Makefile failed'
  1569. fi
  1570. echo 'End of ImageMagick part 1'
  1571. echo 'File ImageMagick/utilities/Makefile is continued in part 2'
  1572. echo 2 > _shar_seq_.tmp
  1573. exit 0
  1574.  
  1575. exit 0 # Just in case...
  1576. -- 
  1577.   // chris@Sterling.COM           | Send comp.sources.x submissions to:
  1578. \X/  Amiga - The only way to fly! |    sources-x@sterling.com
  1579.  "It's intuitively obvious to the |
  1580.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  1581.