home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume34 / imagemagick / part25 < prev    next >
Encoding:
Text File  |  1992-12-14  |  57.1 KB  |  1,667 lines

  1. Newsgroups: comp.sources.misc
  2. From: cristy@eplrx7.es.duPont.com (John Cristy)
  3. Subject:  v34i053:  imagemagick - X11 image processing and display v2.2, Part25/26
  4. Message-ID: <1992Dec15.035938.23162@sparky.imd.sterling.com>
  5. X-Md4-Signature: 64aae8f7bdf9f3af4a6a9f14abf84424
  6. Date: Tue, 15 Dec 1992 03:59:38 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: cristy@eplrx7.es.duPont.com (John Cristy)
  10. Posting-number: Volume 34, Issue 53
  11. Archive-name: imagemagick/part25
  12. Environment: UNIX, VMS, X11, SGI, DEC, Cray, Sun, Vax
  13.  
  14. #!/bin/sh
  15. # this is Part.25 (part 25 of a multipart archive)
  16. # do not concatenate these parts, unpack them in order with /bin/sh
  17. # file ImageMagick/utilities/mogrify.c continued
  18. #
  19. if test ! -r _shar_seq_.tmp; then
  20.     echo 'Please unpack part 1 first!'
  21.     exit 1
  22. fi
  23. (read Scheck
  24.  if test "$Scheck" != 25; then
  25.     echo Please unpack part "$Scheck" next!
  26.     exit 1
  27.  else
  28.     exit 0
  29.  fi
  30. ) < _shar_seq_.tmp || exit 1
  31. if test ! -f _shar_wnt_.tmp; then
  32.     echo 'x - still skipping ImageMagick/utilities/mogrify.c'
  33. else
  34. echo 'x - continuing file ImageMagick/utilities/mogrify.c'
  35. sed 's/^X//' << 'SHAR_EOF' >> 'ImageMagick/utilities/mogrify.c' &&
  36. X                  if (Latin1Compare("yiq",option) == 0)
  37. X                    colorspace=YIQColorspace;
  38. X                  if (Latin1Compare("yuv",option) == 0)
  39. X                    colorspace=YUVColorspace;
  40. X                  if (Latin1Compare("xyz",option) == 0)
  41. X                    colorspace=XYZColorspace;
  42. X                  if (colorspace == UndefinedColorspace)
  43. X                    Error("invalid colorspace type on -colorspace",option);
  44. X                }
  45. X              break;
  46. X            }
  47. X          if (strncmp("compress",option+1,3) == 0)
  48. X            {
  49. X              compression=NoCompression;
  50. X              if (*option == '-')
  51. X                {
  52. X                  i++;
  53. X                  if (i == argc)
  54. X                    Error("missing type on -compress",(char *) NULL);
  55. X                  option=argv[i];
  56. X                  if (Latin1Compare("runlengthencoded",option) == 0)
  57. X                    compression=RunlengthEncodedCompression;
  58. X                  else
  59. X                    if (Latin1Compare("qencoded",option) == 0)
  60. X                      compression=QEncodedCompression;
  61. X                    else
  62. X                      Error("invalid compression type on -compress",option);
  63. X                }
  64. X              break;
  65. X            }
  66. X          Error("unrecognized option",option);
  67. X          break;
  68. X        }
  69. X        case 'd':
  70. X        {
  71. X          if (strncmp("density",option+1,3) == 0)
  72. X            {
  73. X              alien_info.density=(char *) NULL;
  74. X              if (*option == '-')
  75. X                {
  76. X                  i++;
  77. X                  if (i == argc)
  78. X                    Error("missing density on -density",(char *) NULL);
  79. X                  alien_info.density=argv[i];
  80. X                }
  81. X              break;
  82. X            }
  83. X          if (strncmp("display",option+1,3) == 0)
  84. X            {
  85. X              alien_info.server_name=(char *) NULL;
  86. X              if (*option == '-')
  87. X                {
  88. X                  i++;
  89. X                  if (i == argc)
  90. X                    Error("missing server name on -display",(char *) NULL);
  91. X                  alien_info.server_name=argv[i];
  92. X                }
  93. X              break;
  94. X            }
  95. X          if (strncmp("dither",option+1,3) == 0)
  96. X            {
  97. X              dither=(*option == '-');
  98. X              break;
  99. X            }
  100. X          Error("unrecognized option",option);
  101. X          break;
  102. X        }
  103. X        case 'e':
  104. X        {
  105. X          enhance=(*option == '-');
  106. X          break;
  107. X        }
  108. X        case 'g':
  109. X        {
  110. X          if (strncmp("gamma",option+1,2) == 0)
  111. X            {
  112. X              gamma=0.0;
  113. X              if (*option == '-')
  114. X                {
  115. X                  i++;
  116. X                  if ((i == argc) || !sscanf(argv[i],"%f",(float *) &x))
  117. X                    Error("missing gamma on -gamma",(char *) NULL);
  118. X                  gamma=atof(argv[i]);
  119. X                }
  120. X              break;
  121. X            }
  122. X          if (strncmp("geometry",option+1,2) == 0)
  123. X            {
  124. X              image_geometry=(char *) NULL;
  125. X              if (*option == '-')
  126. X                {
  127. X                  i++;
  128. X                  if (i == argc)
  129. X                    Error("missing geometry on -geometry",(char *) NULL);
  130. X                  image_geometry=argv[i];
  131. X                }
  132. X              alien_info.geometry=image_geometry;
  133. X              break;
  134. X            }
  135. X          Error("unrecognized option",option);
  136. X          break;
  137. X        }
  138. X        case 'h':
  139. X        {
  140. X          Usage();
  141. X          break;
  142. X        }
  143. X        case 'i':
  144. X        {
  145. X          inverse=(*option == '-');
  146. X          break;
  147. X        }
  148. X        case 'm':
  149. X        {
  150. X          monochrome=(*option == '-');
  151. X          break;
  152. X        }
  153. X        case 'n':
  154. X        {
  155. X          if (strncmp("noise",option+1,3) == 0)
  156. X            {
  157. X              noise=(*option == '-');
  158. X              break;
  159. X            }
  160. X          if (strncmp("normalize",option+1,3) == 0)
  161. X            {
  162. X              normalize=(*option == '-');
  163. X              break;
  164. X            }
  165. X          Error("unrecognized option",option);
  166. X          break;
  167. X        }
  168. X        case 'r':
  169. X        {
  170. X          if (strncmp("reflect",option+1,2) == 0)
  171. X            {
  172. X              reflect=(*option == '-');
  173. X              break;
  174. X            }
  175. X          if (strncmp("rotate",option+1,3) == 0)
  176. X            {
  177. X              degrees=0;
  178. X              if (*option == '-')
  179. X                {
  180. X                  i++;
  181. X                  if ((i == argc) || !sscanf(argv[i],"%d",&x))
  182. X                    Error("missing degrees on -rotate",(char *) NULL);
  183. X                  degrees=atoi(argv[i]);
  184. X                }
  185. X              break;
  186. X            }
  187. X          Error("unrecognized option",option);
  188. X          break;
  189. X        }
  190. X        case 's':
  191. X        {
  192. X          if (strncmp("scale",option+1,3) == 0)
  193. X            {
  194. X              scale_geometry=(char *) NULL;
  195. X              if (*option == '-')
  196. X                {
  197. X                  i++;
  198. X                  if ((i == argc) || !sscanf(argv[i],"%f",(float *) &x))
  199. X                    Error("missing scale geometry on -scale",(char *) NULL);
  200. X                  scale_geometry=argv[i];
  201. X                }
  202. X              break;
  203. X            }
  204. X          if (strncmp("scene",option+1,3) == 0)
  205. X            {
  206. X              scene=0;
  207. X              if (*option == '-')
  208. X                {
  209. X                  i++;
  210. X                  if ((i == argc) || !sscanf(argv[i],"%d",&x))
  211. X                    Error("missing scene number on -scene",(char *) NULL);
  212. X                  scene=atoi(argv[i]);
  213. X                }
  214. X              break;
  215. X            }
  216. X          Error("unrecognized option",option);
  217. X          break;
  218. X        }
  219. X        case 't':
  220. X        {
  221. X          tree_depth=0;
  222. X          if (*option == '-')
  223. X            {
  224. X              i++;
  225. X              if ((i == argc) || !sscanf(argv[i],"%d",&x))
  226. X                Error("missing depth on -treedepth",(char *) NULL);
  227. X              tree_depth=atoi(argv[i]);
  228. X            }
  229. X          break;
  230. X        }
  231. X        case 'v':
  232. X        {
  233. X          verbose=(*option == '-');
  234. X          alien_info.verbose=verbose;
  235. X          break;
  236. X        }
  237. X        default:
  238. X        {
  239. X          Error("unrecognized option",option);
  240. X          break;
  241. X        }
  242. X      }
  243. X    else
  244. X      {
  245. X        Image
  246. X          *image,
  247. X          info_image,
  248. X          *next_image;
  249. X
  250. X        time_t
  251. X          start_time;
  252. X
  253. X        unsigned long
  254. X          total_colors;
  255. X
  256. X        /*
  257. X          Option is a file name: begin by reading image from specified file.
  258. X        */
  259. X        start_time=time((time_t *) 0);
  260. X        (void) strcpy(alien_info.filename,option);
  261. X        image=ReadAlienImage(&alien_info);
  262. X        if (image == (Image *) NULL)
  263. X          if (*option == '-')
  264. X            break;
  265. X          else
  266. X            continue;
  267. X        do
  268. X        {
  269. X          info_image=(*image);
  270. X          if (scene > 0)
  271. X            image->scene=scene;
  272. X          /*
  273. X            Transform image as defined by the clip, image and scale geometries.
  274. X          */
  275. X          TransformImage(&image,clip_geometry,image_geometry,scale_geometry);
  276. X          if (reflect)
  277. X            {
  278. X              Image
  279. X                *reflected_image;
  280. X
  281. X              /*
  282. X                Reverse image scanlines.
  283. X              */
  284. X              reflected_image=ReflectImage(image);
  285. X              if (reflected_image != (Image *) NULL)
  286. X                {
  287. X                  DestroyImage(image);
  288. X                  image=reflected_image;
  289. X                }
  290. X            }
  291. X          if ((degrees % 360) != 0)
  292. X            {
  293. X              Image
  294. X                *rotated_image;
  295. X
  296. X              /*
  297. X                Rotate image.
  298. X              */
  299. X              rotated_image=RotateImage(image,(double) degrees,False);
  300. X              if (rotated_image != (Image *) NULL)
  301. X                {
  302. X                  DestroyImage(image);
  303. X                  image=rotated_image;
  304. X                }
  305. X            }
  306. X          if (enhance)
  307. X            {
  308. X              Image
  309. X                *enhanced_image;
  310. X
  311. X              /*
  312. X                Enhance image.
  313. X              */
  314. X              enhanced_image=EnhanceImage(image);
  315. X              if (enhanced_image != (Image *) NULL)
  316. X                {
  317. X                  DestroyImage(image);
  318. X                  image=enhanced_image;
  319. X                }
  320. X            }
  321. X          if (noise)
  322. X            {
  323. X              Image
  324. X                *noisy_image;
  325. X
  326. X              /*
  327. X                Reduce noise in image.
  328. X              */
  329. X              noisy_image=NoisyImage(image);
  330. X              if (noisy_image != (Image *) NULL)
  331. X                {
  332. X                  DestroyImage(image);
  333. X                  image=noisy_image;
  334. X                }
  335. X            }
  336. X          if (gamma > 0.0)
  337. X            GammaImage(image,gamma);
  338. X          if (inverse)
  339. X            InverseImage(image);
  340. X          if (normalize)
  341. X            NormalizeImage(image);
  342. X          if (verbose)
  343. X            {
  344. X              /*
  345. X                Initialize image error attributes.
  346. X              */
  347. X              if (image->class == DirectClass)
  348. X                image->colors=NumberColors(image);
  349. X              total_colors=image->colors;
  350. X            }
  351. X          if (colorspace == GRAYColorspace)
  352. X            QuantizeImage(image,256,8,dither,GRAYColorspace,True);
  353. X          if (monochrome)
  354. X            QuantizeImage(image,2,8,dither,GRAYColorspace,True);
  355. X          if (number_colors > 0)
  356. X            if ((image->class == DirectClass) ||
  357. X                (image->colors > number_colors))
  358. X              QuantizeImage(image,number_colors,tree_depth,dither,colorspace,
  359. X                True);
  360. X          if (verbose)
  361. X            {
  362. X              /*
  363. X                Display detailed info about the image.
  364. X              */
  365. X              (void) fprintf(stderr,"[%u] %s",
  366. X                image->scene == 0 ? image_number : image->scene,
  367. X                info_image.filename);
  368. X              (void) fprintf(stderr," %ux%u",info_image.columns,
  369. X                info_image.rows);
  370. X              if ((info_image.columns != image->columns) ||
  371. X                  (info_image.rows != image->rows))
  372. X                (void) fprintf(stderr,"=>%ux%u",image->columns,image->rows);
  373. X              if (image->class == DirectClass)
  374. X                (void) fprintf(stderr," DirectClass ");
  375. X              else
  376. X                (void) fprintf(stderr," PseudoClass ");
  377. X              if (total_colors != image->colors)
  378. X                (void) fprintf(stderr,"%lu=>",total_colors);
  379. X              (void) fprintf(stderr,"%uc",image->colors);
  380. X              if ((number_colors > 0) || monochrome)
  381. X                {
  382. X                  double
  383. X                    normalized_maximum_error,
  384. X                    normalized_mean_error;
  385. X
  386. X                  unsigned int
  387. X                    mean_error_per_pixel;
  388. X
  389. X                  /*
  390. X                    Measure quantization error.
  391. X                  */
  392. X                  QuantizationError(image,&mean_error_per_pixel,
  393. X                    &normalized_mean_error,&normalized_maximum_error);
  394. X                  (void) fprintf(stderr," %u/%.6f/%.6fe",mean_error_per_pixel,
  395. X                    normalized_mean_error,normalized_maximum_error);
  396. X                }
  397. X              (void) fprintf(stderr," %s %lds\n",image->magick,
  398. X                time((time_t *) 0)-start_time+1);
  399. X            }
  400. X          if (compression != UndefinedCompression)
  401. X            image->compression=compression;
  402. X          else
  403. X            image->compression=info_image.compression;
  404. X          if (number_colors == 0)
  405. X            (void) WriteAlienImage(image);
  406. X          if (image_number == maximum_images)
  407. X            {
  408. X              /*
  409. X                Increase size of images array.
  410. X              */
  411. X              maximum_images<<=1;
  412. X              images=(Image **)
  413. X                realloc((char *) images,maximum_images*sizeof(Image *));
  414. X              if (images == (Image **) NULL)
  415. X                Error("unable to mogrify images","memory allocation failed");
  416. X            }
  417. X          images[image_number++]=image;
  418. X          next_image=image->next;
  419. X          if (next_image != (Image *) NULL)
  420. X            image=next_image;
  421. X        } while (next_image != (Image *) NULL);
  422. X        if (number_colors == 0)
  423. X          DestroyImages(image);
  424. X      }
  425. X    }
  426. X  if (image_number == 0)
  427. X    Error("missing an image file name",(char *) NULL);
  428. X  if (number_colors > 0)
  429. X    {
  430. X      Image
  431. X        *colormap_image;
  432. X
  433. X      /*
  434. X        Global colormap option;  reduce colors then write image.
  435. X      */
  436. X      if (colormap_filename != (char *) NULL)
  437. X        {
  438. X          (void) strcpy(alien_info.filename,colormap_filename);
  439. X          colormap_image=ReadAlienImage(&alien_info);
  440. X          if (colormap_image == (Image *) NULL)
  441. X            Error("unable to mogrify images","cannot read image colormap");
  442. X        }
  443. X      maximum_images=image_number;
  444. X      QuantizeImages(images,maximum_images,colormap_image,number_colors,
  445. X        tree_depth,dither,colorspace,True);
  446. X      if (colormap_image != (Image *) NULL)
  447. X    DestroyImage(colormap_image);
  448. X      for (image_number=0; image_number < maximum_images; image_number++)
  449. X      {
  450. X        (void) WriteAlienImage(images[image_number]);
  451. X        DestroyImage(images[image_number]);
  452. X      }
  453. X    }
  454. X  (void) free((char *) images);
  455. X  return(False);
  456. }
  457. SHAR_EOF
  458. echo 'File ImageMagick/utilities/mogrify.c is complete' &&
  459. chmod 0644 ImageMagick/utilities/mogrify.c ||
  460. echo 'restore of ImageMagick/utilities/mogrify.c failed'
  461. Wc_c="`wc -c < 'ImageMagick/utilities/mogrify.c'`"
  462. test 27143 -eq "$Wc_c" ||
  463.     echo 'ImageMagick/utilities/mogrify.c: original size 27143, current size' "$Wc_c"
  464. rm -f _shar_wnt_.tmp
  465. fi
  466. # ============= ImageMagick/utilities/Imakefile ==============
  467. if test -f 'ImageMagick/utilities/Imakefile' -a X"$1" != X"-c"; then
  468.     echo 'x - skipping ImageMagick/utilities/Imakefile (File already exists)'
  469.     rm -f _shar_wnt_.tmp
  470. else
  471. > _shar_wnt_.tmp
  472. echo 'x - extracting ImageMagick/utilities/Imakefile (Text)'
  473. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/utilities/Imakefile' &&
  474. #
  475. #  Imakefile for ImageMagick image utilities.
  476. #
  477. #  Copyright 1992 E. I. du Pont de Nemours & Company
  478. #
  479. #  Permission to use, copy, modify, distribute, and sell this software and
  480. #  its documentation for any purpose is hereby granted without fee,
  481. #  provided that the above Copyright notice appear in all copies and that
  482. #  both that Copyright notice and this permission notice appear in
  483. #  supporting documentation, and that the name of E. I. du Pont de Nemours
  484. #  & Company not be used in advertising or publicity pertaining to
  485. #  distribution of the software without specific, written prior
  486. #  permission.  E. I. du Pont de Nemours & Company makes no representations
  487. #  about the suitability of this software for any purpose.  It is provided
  488. #  "as is" without express or implied warranty.
  489. #
  490. #  E. I. du Pont de Nemours & Company disclaims all warranties with regard
  491. #  to this software, including all implied warranties of merchantability
  492. #  and fitness, in no event shall E. I. du Pont de Nemours & Company be
  493. #  liable for any special, indirect or consequential damages or any
  494. #  damages whatsoever resulting from loss of use, data or profits, whether
  495. #  in an action of contract, negligence or other tortious action, arising
  496. #  out of or in connection with the use or performance of this software.
  497. #
  498. X
  499. #include "../Magick.tmpl"
  500. X
  501. EXTRA_INCLUDES= -I..
  502. X
  503. MagickObjects= ../X.o ../image.o ../rotate.o ../quantize.o ../colors.o \
  504. X  ../signature.o ../compress.o ../alien.o ../PreRvIcccm.o
  505. X
  506. CONVERTObjects= convert.o $(MagickObjects)
  507. MOGRIFYObjects= mogrify.o $(MagickObjects)
  508. MIFFtoSTEREOSources= MIFFtoSTEREO.c
  509. MIFFtoSTEREOObjects= MIFFtoSTEREO.o $(MagickObjects)
  510. X
  511. PROGRAMS= mogrify convert MIFFtoSTEREO
  512. X
  513. AllTarget($(PROGRAMS))
  514. X
  515. NormalProgramTarget(mogrify,$(MOGRIFYObjects), , , )
  516. InstallProgram(mogrify,$(LOCALDIR))
  517. InstallManPage(mogrify,$(MANDIR))
  518. NormalProgramTarget(convert,$(CONVERTObjects), , , )
  519. InstallProgram(convert,$(LOCALDIR))
  520. InstallManPage(convert,$(MANDIR))
  521. NormalProgramTarget(MIFFtoSTEREO,$(MIFFtoSTEREOObjects), , , )
  522. InstallProgram(MIFFtoSTEREO,$(LOCALDIR))
  523. DependTarget()
  524. SHAR_EOF
  525. chmod 0644 ImageMagick/utilities/Imakefile ||
  526. echo 'restore of ImageMagick/utilities/Imakefile failed'
  527. Wc_c="`wc -c < 'ImageMagick/utilities/Imakefile'`"
  528. test 2095 -eq "$Wc_c" ||
  529.     echo 'ImageMagick/utilities/Imakefile: original size 2095, current size' "$Wc_c"
  530. rm -f _shar_wnt_.tmp
  531. fi
  532. # ============= ImageMagick/utilities/Makefile ==============
  533. if test -f 'ImageMagick/utilities/Makefile' -a X"$1" != X"-c"; then
  534.     echo 'x - skipping ImageMagick/utilities/Makefile (File already exists)'
  535.     rm -f _shar_wnt_.tmp
  536. else
  537. > _shar_wnt_.tmp
  538. echo 'x - extracting ImageMagick/utilities/Makefile (Text)'
  539. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/utilities/Makefile' &&
  540. #
  541. #  Generic makefile for convert, mogrify, MIFFtoSTEREO, and import for
  542. #  computers that do not have xmkmf.
  543. #
  544. #  Copyright 1992 E. I. du Pont de Nemours & Company
  545. #
  546. #  Permission to use, copy, modify, distribute, and sell this software and
  547. #  its documentation for any purpose is hereby granted without fee,
  548. #  provided that the above Copyright notice appear in all copies and that
  549. #  both that Copyright notice and this permission notice appear in
  550. #  supporting documentation, and that the name of E. I. du Pont de Nemours
  551. #  & Company not be used in advertising or publicity pertaining to
  552. #  distribution of the software without specific, written prior
  553. #  permission.  E. I. du Pont de Nemours & Company makes no representations
  554. #  about the suitability of this software for any purpose.  It is provided
  555. #  "as is" without express or implied warranty.
  556. #
  557. #  E. I. du Pont de Nemours & Company disclaims all warranties with regard
  558. #  to this software, including all implied warranties of merchantability
  559. #  and fitness, in no event shall E. I. du Pont de Nemours & Company be
  560. #  liable for any special, indirect or consequential damages or any
  561. #  damages whatsoever resulting from loss of use, data or profits, whether
  562. #  in an action of contract, negligence or other tortious action, arising
  563. #  out of or in connection with the use or performance of this software.
  564. #
  565. X
  566. #
  567. # Uncomment the following lines if you have the JPEG or TIFF libraries.
  568. # See README for more details.
  569. #
  570. #JPEG= -DAlienJPEG
  571. #JPEG_LIBRARIES= -L../jpeg -ljpeg
  572. #JPEG_INCLUDES= -I../jpeg
  573. #TIFF= -DAlienTIFF
  574. #TIFF_LIBRARIES= -L../tiff/libtiff -ltiff
  575. #TIFF_INCLUDES= -I../tiff/libtiff
  576. X
  577. XXLIB= -L/usr/lib/X11R4 -lX11
  578. X
  579. CC= cc -O -I/usr/include/X11R4
  580. DESTDIR= /usr/local/bin
  581. INSTALL = install -c
  582. RM= /bin/rm -f
  583. X
  584. DEFINES= -I.. $(JPEG) $(JPEG_INCLUDES) $(TIFF) $(TIFF_INCLUDES)
  585. SYS_LIBRARIES= $(XLIB) $(JPEG_LIBRARIES) $(TIFF_LIBRARIES) -lm
  586. X
  587. MagickObjects= ../X.o ../image.o ../rotate.o ../quantize.o ../colors.o \
  588. X  ../signature.o ../compress.o ../alien.o ../PreRvIcccm.o
  589. X
  590. ConvertObjects= convert.o $(MagickObjects)
  591. MogrifyObjects= mogrify.o $(MagickObjects)
  592. ImportObjects= import.o $(MagickObjects)
  593. MIFFtoSTEREOObjects= MIFFtoSTEREO.o $(MagickObjects)
  594. X
  595. PROGRAMS= convert mogrify MIFFtoSTEREO
  596. X
  597. CFLAGS= $(DEFINES)
  598. X
  599. all: $(PROGRAMS)
  600. X
  601. convert: $(ConvertObjects)
  602. X    $(RM) $@
  603. X    $(CC) -o $@ $(ConvertObjects) $(SYS_LIBRARIES)
  604. X
  605. clean::
  606. X    $(RM) convert
  607. X
  608. install:: convert
  609. X    $(INSTALL) convert $(DESTDIR)
  610. X
  611. mogrify: $(MogrifyObjects)
  612. X    $(RM) $@
  613. X    $(CC) -o $@ $(MogrifyObjects) $(SYS_LIBRARIES)
  614. X
  615. clean::
  616. X    $(RM) mogrify
  617. X
  618. install:: mogrify
  619. X    $(INSTALL) mogrify $(DESTDIR)
  620. X
  621. MIFFtoSTEREO: $(MIFFtoSTEREOObjects)
  622. X    $(RM) $@
  623. X    $(CC) -o $@ $(MIFFtoSTEREOObjects) $(SYS_LIBRARIES)
  624. X
  625. clean::
  626. X    $(RM) MIFFtoSTEREO
  627. X
  628. install:: MIFFtoSTEREO
  629. X    $(INSTALL) MIFFtoSTEREO $(DESTDIR)
  630. X
  631. clean::
  632. X    $(RM) *.ln *.bak *.o core errs ,* *~ *.a .emacs_* make.log MakeOut
  633. SHAR_EOF
  634. chmod 0644 ImageMagick/utilities/Makefile ||
  635. echo 'restore of ImageMagick/utilities/Makefile failed'
  636. Wc_c="`wc -c < 'ImageMagick/utilities/Makefile'`"
  637. test 2880 -eq "$Wc_c" ||
  638.     echo 'ImageMagick/utilities/Makefile: original size 2880, current size' "$Wc_c"
  639. rm -f _shar_wnt_.tmp
  640. fi
  641. # ============= ImageMagick/utilities/convert.c ==============
  642. if test -f 'ImageMagick/utilities/convert.c' -a X"$1" != X"-c"; then
  643.     echo 'x - skipping ImageMagick/utilities/convert.c (File already exists)'
  644.     rm -f _shar_wnt_.tmp
  645. else
  646. > _shar_wnt_.tmp
  647. echo 'x - extracting ImageMagick/utilities/convert.c (Text)'
  648. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/utilities/convert.c' &&
  649. /*
  650. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  651. %                                                                             %
  652. %                                                                             %
  653. %                                                                             %
  654. %                CCCC   OOO   N   N  V   V  EEEEE  RRRR   TTTTT               %
  655. %               C      O   O  NN  N  V   V  E      R   R    T                 %
  656. %               C      O   O  N N N  V   V  EEE    RRRR     T                 %
  657. %               C      O   O  N  NN   V V   E      R R      T                 %
  658. %                CCCC   OOO   N   N    V    EEEEE  R  R     T                 %
  659. %                                                                             %
  660. %                                                                             %
  661. %                 Convert a image from one format to another.                 %
  662. %                                                                             %
  663. %                                                                             %
  664. %                                                                             %
  665. %                              Software Design                                %
  666. %                                John Cristy                                  %
  667. %                                April 1992                                   %
  668. %                                                                             %
  669. %                                                                             %
  670. %  Copyright 1992 E. I. Dupont de Nemours & Company                           %
  671. %                                                                             %
  672. %  Permission to use, copy, modify, distribute, and sell this software and    %
  673. %  its documentation for any purpose is hereby granted without fee,           %
  674. %  provided that the above Copyright notice appear in all copies and that     %
  675. %  both that Copyright notice and this permission notice appear in            %
  676. %  supporting documentation, and that the name of E. I. Dupont de Nemours     %
  677. %  & Company not be used in advertising or publicity pertaining to            %
  678. %  distribution of the software without specific, written prior               %
  679. %  permission.  E. I. Dupont de Nemours & Company makes no representations    %
  680. %  about the suitability of this software for any purpose.  It is provided    %
  681. %  "as is" without express or implied warranty.                               %
  682. %                                                                             %
  683. %  E. I. Dupont de Nemours & Company disclaims all warranties with regard     %
  684. %  to this software, including all implied warranties of merchantability      %
  685. %  and fitness, in no event shall E. I. Dupont de Nemours & Company be        %
  686. %  liable for any special, indirect or consequential damages or any           %
  687. %  damages whatsoever resulting from loss of use, data or profits, whether    %
  688. %  in an action of contract, negligence or other tortious action, arising     %
  689. %  out of or in connection with the use or performance of this software.      %
  690. %                                                                             %
  691. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  692. %
  693. %  The convert program syntax is:
  694. %
  695. %  Usage: convert [options ...] file
  696. %
  697. %  Where options include:
  698. %    -alpha              store alpha channel if the image has one
  699. %    -colors value       preferred number of colors in the image
  700. %    -colorspace type    GRAY, RGB, XYZ, YIQ, or YUV
  701. %    -compress type      RunlengthEncoded or QEncoded
  702. %    -density geometry   vertical and horizonal density of the image
  703. %    -display server     obtain image or font from this X server
  704. %    -dither             apply Floyd/Steinberg error diffusion to image
  705. %    -geometry geometry  width and height of the image
  706. %    -quality value      JPEG quality setting
  707. %    -scene value        image scene number
  708. %    -treedepth value    depth of the color classification tree
  709. %    -verbose            print detailed information about the image
  710. %
  711. %  Change '-' to '+' in any option above to reverse its effect.  For
  712. %  example,  specify +alpha to store the image without its alpha channel.
  713. %
  714. %  By default, the image format of `file' is determined by its magic
  715. %  number.  To specify a particular image format, precede the filename
  716. %  with an image format name and a colon (i.e. mtv:image) or specify the
  717. %  image type as the filename suffix (i.e. image.mtv).  Specify 'file' as
  718. %  '-' for standard input or output.
  719. %
  720. %
  721. */
  722. X
  723. #include "display.h"
  724. #include "image.h"
  725. #include "alien.h"
  726. #include "X.h"
  727. X
  728. /*
  729. X  Global declarations.
  730. */
  731. char
  732. X  *application_name;
  733. X
  734. /*
  735. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  736. %                                                                             %
  737. %                                                                             %
  738. %                                                                             %
  739. %   E r r o r                                                                 %
  740. %                                                                             %
  741. %                                                                             %
  742. %                                                                             %
  743. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  744. %
  745. %  Function Error displays an error message and then terminates the program.
  746. %
  747. %  The format of the Error routine is:
  748. %
  749. %      Error(message,qualifier)
  750. %
  751. %  A description of each parameter follows:
  752. %
  753. %    o message: Specifies the message to display before terminating the
  754. %      program.
  755. %
  756. %    o qualifier: Specifies any qualifier to the message.
  757. %
  758. %
  759. */
  760. void Error(message,qualifier)
  761. char
  762. X  *message,
  763. X  *qualifier;
  764. {
  765. X  (void) fprintf(stderr,"%s: %s",application_name,message);
  766. X  if (qualifier != (char *) NULL)
  767. X    (void) fprintf(stderr," (%s)",qualifier);
  768. X  (void) fprintf(stderr,".\n");
  769. X  exit(1);
  770. }
  771. X
  772. /*
  773. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  774. %                                                                             %
  775. %                                                                             %
  776. %                                                                             %
  777. %   U s a g e                                                                 %
  778. %                                                                             %
  779. %                                                                             %
  780. %                                                                             %
  781. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  782. %
  783. %  Procedure Usage displays the program usage;
  784. %
  785. %  The format of the Usage routine is:
  786. %
  787. %      Usage()
  788. %
  789. %
  790. */
  791. static void Usage()
  792. {
  793. X  char
  794. X    **p;
  795. X
  796. X  static char
  797. X    *options[]=
  798. X    {
  799. X      "-alpha              store alpha channel if the image has one",
  800. X      "-colors value       preferred number of colors in the image",
  801. X      "-colorspace type    GRAY, RGB, XYZ, YIQ, or YUV",
  802. X      "-compress type      RunlengthEncoded or QEncoded",
  803. X      "-density geometry   vertical and horizonal density of the image",
  804. X      "-display server     obtain image or font from this X server",
  805. X      "-dither             apply Floyd/Steinberg error diffusion to image",
  806. X      "-geometry geometry  width and height of the image",
  807. X      "-quality value      JPEG quality setting",
  808. X      "-scene value        image scene number",
  809. X      "-treedepth value    depth of the color classification tree",
  810. X      "-verbose            print detailed information about the image",
  811. X      (char *) NULL
  812. X    };
  813. X  (void) fprintf(stderr,"Usage: %s [options ...] input_file output_file\n",
  814. X    application_name);
  815. X  (void) fprintf(stderr,"\nWhere options include:\n");
  816. X  for (p=options; *p != (char *) NULL; p++)
  817. X    (void) fprintf(stderr,"  %s\n",*p);
  818. X  (void) fprintf(stderr,
  819. X    "\nChange '-' to '+' in any option above to reverse its effect.  For\n");
  820. X  (void) fprintf(stderr,
  821. X    "example,  specify +alpha to store the image without an alpha channel.\n");
  822. X  (void) fprintf(stderr,
  823. X    "\nBy default, the image format of `file' is determined by its magic\n");
  824. X  (void) fprintf(stderr,
  825. X    "number.  To specify a particular image format, precede the filename\n");
  826. X  (void) fprintf(stderr,
  827. X    "with an image format name and a colon (i.e. mtv:image) or specify the\n");
  828. X  (void) fprintf(stderr,
  829. X    "image type as the filename suffix (i.e. image.mtv).  Specify 'file' as\n");
  830. X  (void) fprintf(stderr,"'-' for standard input or output.\n");
  831. X  exit(1);
  832. }
  833. X
  834. /*
  835. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  836. %                                                                             %
  837. %                                                                             %
  838. %                                                                             %
  839. %  M a i n                                                                    %
  840. %                                                                             %
  841. %                                                                             %
  842. %                                                                             %
  843. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  844. %
  845. %
  846. */
  847. int main(argc,argv)
  848. int
  849. X  argc;
  850. X
  851. char
  852. X  *argv[];
  853. {
  854. #define NotInitialized  (~0)
  855. X
  856. X  AlienInfo
  857. X    alien_info;
  858. X
  859. X  char
  860. X    *filename,
  861. X    *option;
  862. X
  863. X  Image
  864. X    *image,
  865. X    *next_image;
  866. X
  867. X  int
  868. X    i,
  869. X    status,
  870. X    x;
  871. X
  872. X  time_t
  873. X    start_time;
  874. X
  875. X  unsigned int
  876. X    alpha,
  877. X    colorspace,
  878. X    compression,
  879. X    dither,
  880. X    number_colors,
  881. X    quality,
  882. X    scene,
  883. X    total_colors,
  884. X    tree_depth,
  885. X    verbose;
  886. X
  887. X  /*
  888. X    Initialize program variables.
  889. X  */
  890. X  application_name=argv[0];
  891. X  if (argc < 3)
  892. X    Usage();
  893. X  /*
  894. X    Read image and convert to MIFF format.
  895. X  */
  896. X  GetAlienInfo(&alien_info);
  897. X  alpha=NotInitialized;
  898. X  colorspace=RGBColorspace;
  899. X  compression=UndefinedCompression;
  900. X  dither=False;
  901. X  number_colors=0;
  902. X  quality=0;
  903. X  scene=0;
  904. X  tree_depth=0;
  905. X  verbose=False;
  906. X  /*
  907. X    Check command syntax.
  908. X  */
  909. X  filename=(char *) NULL;
  910. X  for (i=1; i < (argc-1); i++)
  911. X  {
  912. X    option=argv[i];
  913. X    if (((int) strlen(option) < 2) || ((*option != '-') && (*option != '+')))
  914. X      filename=argv[i];
  915. X    else
  916. X      switch(*(option+1))
  917. X      {
  918. X        case 'a':
  919. X        {
  920. X          alpha=(*option == '-');
  921. X          break;
  922. X        }
  923. X        case 'c':
  924. X        {
  925. X          if (strncmp("colors",option+1,7) == 0)
  926. X            {
  927. X              number_colors=0;
  928. X              if (*option == '-')
  929. X                {
  930. X                  i++;
  931. X                  if ((i == argc) || !sscanf(argv[i],"%d",&x))
  932. X                    Error("missing colors on -colors",(char *) NULL);
  933. X                  number_colors=atoi(argv[i]);
  934. X                }
  935. X              break;
  936. X            }
  937. X          if (strncmp("colorspace",option+1,7) == 0)
  938. X            {
  939. X              colorspace=RGBColorspace;
  940. X              if (*option == '-')
  941. X                {
  942. X                  i++;
  943. X                  if (i == argc)
  944. X                    Error("missing type on -colorspace",(char *) NULL);
  945. X                  option=argv[i];
  946. X                  colorspace=UndefinedColorspace;
  947. X                  if (Latin1Compare("gray",option) == 0)
  948. X                    colorspace=GRAYColorspace;
  949. X                  if (Latin1Compare("rgb",option) == 0)
  950. X                    colorspace=RGBColorspace;
  951. X                  if (Latin1Compare("yiq",option) == 0)
  952. X                    colorspace=YIQColorspace;
  953. X                  if (Latin1Compare("yuv",option) == 0)
  954. X                    colorspace=YUVColorspace;
  955. X                  if (Latin1Compare("xyz",option) == 0)
  956. X                    colorspace=XYZColorspace;
  957. X                  if (colorspace == UndefinedColorspace)
  958. X                    Error("invalid colorspace type on -colorspace",option);
  959. X                }
  960. X              break;
  961. X            }
  962. X          if (strncmp("compress",option+1,3) == 0)
  963. X            {
  964. X              compression=NoCompression;
  965. X              if (*option == '-')
  966. X                {
  967. X                  i++;
  968. X                  if (i == argc)
  969. X                    Error("missing type on -compress",(char *) NULL);
  970. X                  option=argv[i];
  971. X                  if (Latin1Compare("runlengthencoded",option) == 0)
  972. X                    compression=RunlengthEncodedCompression;
  973. X                  else
  974. X                    if (Latin1Compare("qencoded",option) == 0)
  975. X                      compression=QEncodedCompression;
  976. X                    else
  977. X                      Error("invalid compression type on -compress",option);
  978. X                }
  979. X              break;
  980. X            }
  981. X          Error("unrecognized option",option);
  982. X          break;
  983. X        }
  984. X        case 'd':
  985. X        {
  986. X          if (strncmp("density",option+1,3) == 0)
  987. X            {
  988. X              alien_info.density=(char *) NULL;
  989. X              if (*option == '-')
  990. X                {
  991. X                  i++;
  992. X                  if (i == argc)
  993. X                    Error("missing density on -density",(char *) NULL);
  994. X                  alien_info.density=argv[i];
  995. X                }
  996. X              break;
  997. X            }
  998. X          if (strncmp("display",option+1,3) == 0)
  999. X            {
  1000. X              alien_info.server_name=(char *) NULL;
  1001. X              if (*option == '-')
  1002. X                {
  1003. X                  i++;
  1004. X                  if (i == argc)
  1005. X                    Error("missing server name on -display",(char *) NULL);
  1006. X                  alien_info.server_name=argv[i];
  1007. X                }
  1008. X              break;
  1009. X            }
  1010. X          if (strncmp("dither",option+1,3) == 0)
  1011. X            {
  1012. X              dither=(*option == '-');
  1013. X              break;
  1014. X            }
  1015. X          Error("unrecognized option",option);
  1016. X          break;
  1017. X        }
  1018. X        case 'f':
  1019. X        {
  1020. X          alien_info.font=(char *) NULL;
  1021. X          if (*option == '-')
  1022. X            {
  1023. X              i++;
  1024. X              if (i == argc)
  1025. X                Error("missing font name on -font",(char *) NULL);
  1026. X              alien_info.font=argv[i];
  1027. X            }
  1028. X          break;
  1029. X        }
  1030. X        case 'g':
  1031. X        {
  1032. X          alien_info.geometry=(char *) NULL;
  1033. X          if (*option == '-')
  1034. X            {
  1035. X              i++;
  1036. X              if (i == argc)
  1037. X                Error("missing geometry on -geometry",(char *) NULL);
  1038. X              alien_info.geometry=argv[i];
  1039. X            }
  1040. X          break;
  1041. X        }
  1042. X        case 'h':
  1043. X        {
  1044. X          Usage();
  1045. X          break;
  1046. X        }
  1047. X        case 'q':
  1048. X        {
  1049. X          i++;
  1050. X          if ((i == argc) || !sscanf(argv[i],"%d",&x))
  1051. X            Error("missing quality on -quality",(char *) NULL);
  1052. X          quality=atoi(argv[i]);
  1053. X          break;
  1054. X        }
  1055. X        case 's':
  1056. X        {
  1057. X          scene=0;
  1058. X          if (*option == '-')
  1059. X            {
  1060. X              i++;
  1061. X              if ((i == argc) || !sscanf(argv[i],"%d",&x))
  1062. X                Error("missing scene number on -scene",(char *) NULL);
  1063. X              scene=atoi(argv[i]);
  1064. X            }
  1065. X          break;
  1066. X        }
  1067. X        case 't':
  1068. X        {
  1069. X          tree_depth=0;
  1070. X          if (*option == '-')
  1071. X            {
  1072. X              i++;
  1073. X              if ((i == argc) || !sscanf(argv[i],"%d",&x))
  1074. X                Error("missing depth on -treedepth",(char *) NULL);
  1075. X              tree_depth=atoi(argv[i]);
  1076. X            }
  1077. X          break;
  1078. X        }
  1079. X        case 'v':
  1080. X        {
  1081. X          verbose=(*option == '-');
  1082. X          alien_info.verbose=verbose;
  1083. X          break;
  1084. X        }
  1085. X        default:
  1086. X        {
  1087. X          Error("unrecognized option",option);
  1088. X          break;
  1089. X        }
  1090. X      }
  1091. X  }
  1092. X  if (filename == (char *) NULL)
  1093. X    Error("missing an image file name",(char *) NULL);
  1094. X  start_time=time((time_t *) 0);
  1095. X  (void) strcpy(alien_info.filename,filename);
  1096. X  image=ReadAlienImage(&alien_info);
  1097. X  if (image == (Image *) NULL)
  1098. X    exit(1);
  1099. X  /*
  1100. X    Write images.
  1101. X  */
  1102. X  do
  1103. X  {
  1104. X    if (alpha != NotInitialized)
  1105. X      image->alpha=alpha;
  1106. X    if (compression != UndefinedCompression)
  1107. X      image->compression=compression;
  1108. X    if (quality > 0)
  1109. X      image->quality=quality;
  1110. X    if (scene > 0)
  1111. X      image->scene=scene;
  1112. X    (void) strcpy(image->filename,argv[i]);
  1113. X    if (image->last != (Image *) NULL)
  1114. X      (void) sprintf(image->filename,"%s.%u\0",argv[i],image->scene);
  1115. X    if (verbose)
  1116. X      {
  1117. X        /*
  1118. X          Initialize image error attributes.
  1119. X        */
  1120. X        if (image->class == DirectClass)
  1121. X          image->colors=NumberColors(image);
  1122. X        total_colors=image->colors;
  1123. X      }
  1124. X    if (colorspace == GRAYColorspace)
  1125. X      QuantizeImage(image,256,8,dither,GRAYColorspace,True);
  1126. X    if (number_colors > 0)
  1127. X      if ((image->class == DirectClass) || (image->colors > number_colors))
  1128. X        QuantizeImage(image,number_colors,tree_depth,dither,colorspace,True);
  1129. X    status=WriteAlienImage(image);
  1130. X    if (verbose)
  1131. X      {
  1132. X        /*
  1133. X          Display detailed info about the image.
  1134. X        */
  1135. X        (void) fprintf(stderr,"[%u] %s=>%s %ux%u",image->scene,filename,
  1136. X          image->filename,image->columns,image->rows);
  1137. X        if (image->class == DirectClass)
  1138. X          (void) fprintf(stderr," DirectClass ");
  1139. X        else
  1140. X          (void) fprintf(stderr," PseudoClass ");
  1141. X        if (total_colors != image->colors)
  1142. X          (void) fprintf(stderr,"%u=>",total_colors);
  1143. X        (void) fprintf(stderr,"%uc",image->colors);
  1144. X        if (number_colors > 0)
  1145. X          {
  1146. X            double
  1147. X              normalized_maximum_error,
  1148. X              normalized_mean_error;
  1149. X
  1150. X            unsigned int
  1151. X              mean_error_per_pixel;
  1152. X
  1153. X            /*
  1154. X              Measure quantization error.
  1155. X            */
  1156. X            QuantizationError(image,&mean_error_per_pixel,
  1157. X              &normalized_mean_error,&normalized_maximum_error);
  1158. X            (void) fprintf(stderr," %u/%.6f/%.6fe",mean_error_per_pixel,
  1159. X              normalized_mean_error,normalized_maximum_error);
  1160. X          }
  1161. X        (void) fprintf(stderr," %s %lds\n",image->magick,
  1162. X          time((time_t *) 0)-start_time+1);
  1163. X      }
  1164. X    next_image=image->next;
  1165. X    DestroyImage(image);
  1166. X    image=next_image;
  1167. X  } while (image != (Image *) NULL);
  1168. X  return(!status);
  1169. }
  1170. SHAR_EOF
  1171. chmod 0644 ImageMagick/utilities/convert.c ||
  1172. echo 'restore of ImageMagick/utilities/convert.c failed'
  1173. Wc_c="`wc -c < 'ImageMagick/utilities/convert.c'`"
  1174. test 18313 -eq "$Wc_c" ||
  1175.     echo 'ImageMagick/utilities/convert.c: original size 18313, current size' "$Wc_c"
  1176. rm -f _shar_wnt_.tmp
  1177. fi
  1178. # ============= ImageMagick/utilities/mogrify.man ==============
  1179. if test -f 'ImageMagick/utilities/mogrify.man' -a X"$1" != X"-c"; then
  1180.     echo 'x - skipping ImageMagick/utilities/mogrify.man (File already exists)'
  1181.     rm -f _shar_wnt_.tmp
  1182. else
  1183. > _shar_wnt_.tmp
  1184. echo 'x - extracting ImageMagick/utilities/mogrify.man (Text)'
  1185. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/utilities/mogrify.man' &&
  1186. .ad l
  1187. .nh
  1188. .TH MOGRIFY 1 "10 October 1992" "ImageMagick"
  1189. .SH NAME
  1190. mogrify - transform an image or sequence of images
  1191. .SH SYNOPSIS
  1192. .B "mogrify" [ \fIoptions\fP ...] \fIfile\fP
  1193. [ [ \fIoptions\fP ...] \fIfile\fP ...]
  1194. .SH DESCRIPTION
  1195. \fIMogrify\fP transforms an image or a sequence of images.  These
  1196. transforms include image scaling, image rotation, color reduction, and
  1197. others.  The transmogrified image overwrites the original image.
  1198. .SH EXAMPLES
  1199. To scale an image of a cockatoo to exactly 640 pixels in width and 480
  1200. pixels in height, use:
  1201. .PP
  1202. X    mogrify -geometry 640x480 cockatoo.miff
  1203. .PP
  1204. To create a single colormap for a sequence of bird images, use:
  1205. .PP
  1206. X    mogrify -colors 256 scenes/birds.*
  1207. .SH OPTIONS
  1208. .TP 5
  1209. .B "-clip \fI<width>x<height>{\+-}<x offset>{\+-}<y offset>\fP"
  1210. preferred size and location of the clipped image.  See \fBX(1)\fP for details
  1211. about the geometry specification.
  1212. X
  1213. Use clipping to apply image processing options, or transmogrify, only a
  1214. particular area of an image.
  1215. .TP 5
  1216. .B "-colors \fIvalue\fP"
  1217. preferred number of colors in the image.
  1218. X
  1219. The actual number of colors in the image may be less than your request,
  1220. but never more.  Note, this is a color reduction option.  Images with
  1221. less unique colors than specified with this option will remain unchanged.
  1222. Refer to \fBQuantize(9)\fP for more details.
  1223. X
  1224. If more than one image is specified on the command line, a single
  1225. colormap is created and saved with each image.
  1226. X
  1227. Note, options \fB-dither\fP, \fB-colorspace\fP, and \fB-treedepth\fP affect
  1228. the color reduction algorithm.
  1229. .TP 5
  1230. .B "-colorspace \fIvalue\fP"
  1231. the type of colorspace: \fIGRAY\fP, \fIRGB\fP, \fIXYZ\fP, \fIYIQ\fP, or
  1232. \fIYUV\fP.
  1233. X
  1234. Color reduction, by default, takes place in the RGB color space.
  1235. Empirical evidence suggests that distances in color spaces such as YUV
  1236. or YIQ correspond to perceptual color differences more closely
  1237. than do distances in RGB space.  These color spaces may give better
  1238. results when color reducing an image.  Refer to \fBQuantize(9)\fP for
  1239. more details.
  1240. X
  1241. The \fB-colors\fP or \fB-monochrome\fP option is required
  1242. for this option to take effect.
  1243. .TP 5
  1244. .B "-compress \fItype\fP"
  1245. the type of image compression: \fIQEncoded\fP or \fIRunlengthEncoded\fP.
  1246. X
  1247. Specify \fB\+compress\fP to store the binary image in an uncompressed format.
  1248. The default is the compression type of the specified image file.
  1249. .TP 5
  1250. .B "-density \fI<width>x<height>
  1251. vertical and horizonal density of the image.
  1252. X
  1253. This option specifies an image density whose interpretation changes
  1254. with the type of image.  The default is 72 dots per inch in the
  1255. horizonal and vertical direction for Postscript.  Text files default to
  1256. 80 characters in width and 60 lines in height.  Use this option to
  1257. alter the default density.
  1258. .TP 5
  1259. .B "-display \fIhost:display[.screen]\fP"
  1260. specifies the X server to contact; see \fBX(1)\fP.
  1261. .TP 5
  1262. .B "-dither"
  1263. apply Floyd/Steinberg error diffusion to the image.
  1264. X
  1265. The basic strategy of dithering is to trade intensity resolution for
  1266. spatial resolution by averaging the intensities of several neighboring
  1267. pixels.  Images which suffer from severe contouring when reducing colors
  1268. can be improved with this option.
  1269. X
  1270. The \fB-colors\fP or \fB-monochrome\fP option is required for this option
  1271. to take effect.
  1272. .TP 5
  1273. .B "-enhance"
  1274. apply a digital filter to enhance a noisy image.
  1275. .TP 5
  1276. .B "-gamma \fIvalue\fP"
  1277. level of gamma correction.
  1278. X
  1279. The same color image displayed on two different workstations may look
  1280. different due to differences in the display monitor.  Use gamma
  1281. correction to adjust for this color difference.  Reasonable values
  1282. extend from 0.8 to 2.3.
  1283. .TP 5
  1284. .B "-geometry \fI<width>x<height>\fP"
  1285. preferred size of the image window.  See \fBX(1)\fP for details
  1286. about the geometry specification.
  1287. X
  1288. If the specified image size is smaller than the actual image size, the
  1289. image is first reduced to an integral of the specified image size with
  1290. an antialias digital filter.  The image is then scaled to the exact
  1291. specified image size with pixel replication.  If the specified image
  1292. size is greater than the actual image size, the image is first enlarged
  1293. to an integral of the specified image size with bilinear
  1294. interpolation.  The image is then scaled to the exact specified image
  1295. size with pixel replication.
  1296. .TP 5
  1297. .B "-inverse"
  1298. apply color inversion to image.
  1299. X
  1300. The red, green, and blue intensities of an image are negated.
  1301. .TP 5
  1302. .B "-monochrome"
  1303. transform the image to black and white.
  1304. X
  1305. Monochrome images can benefit from error diffusion.  Use \fB-dither\fP with
  1306. this option to diffuse the error.
  1307. .TP 5
  1308. .B "-noise"
  1309. reduce the noise in an image with a noise peak elimination filter.
  1310. X
  1311. The principal function of noise peak elimination filter is to smooth
  1312. the objects within an image without losing edge information and without
  1313. creating undesired structures.  The central idea of the algorithm is to
  1314. replace a pixel with its next neighbor in value within a 3 x 3 window,
  1315. if this pixel has been found to be noise.  A pixel is defined as noise
  1316. if and only if this pixel is a maximum or minimum within the 3 x 3 window.
  1317. .TP 5
  1318. .B "-normalize"
  1319. tranform image to span the full range of color values.  This is a contrast
  1320. enhancement technique.
  1321. .TP 5
  1322. .B "-reflect"
  1323. create a "mirror image" by reflecting the image scanlines.
  1324. .TP 5
  1325. .B "-rotate \fIdegrees\fP"
  1326. apply Paeth image rotation to the image.
  1327. .TP 5
  1328. .B "-scale \fI<width factor>x<height factor>\fP"
  1329. preferred size factors of the image.
  1330. X
  1331. This option behaves like \fB-geometry\fP except the width and height values
  1332. are relative instead of absolute.  The image size is multiplied by the
  1333. width and height factors to obtain the final image dimensions.  If only
  1334. one factor is specified, both the width and height factors assume the
  1335. value.
  1336. X
  1337. Factors may be fractional.  For example, a factor of 1.5 will increase the
  1338. image size by one and one-half.
  1339. .TP 5
  1340. .B "-scene \fIvalue\fP"
  1341. image scene number.
  1342. .TP 5
  1343. .B "-treedepth \fIvalue\fP"
  1344. Normally, this integer value is zero or one.  A zero or one tells
  1345. \fIMogrify\fP to choose a optimal tree depth for the color reduction
  1346. algorithm.
  1347. X
  1348. An optimal depth generally allows the best representation of the source
  1349. image with the fastest computational speed and the least amount of
  1350. memory.  However, the default depth is inappropriate for some images.
  1351. To assure the best representation, try values between 2 and 8 for this
  1352. parameter.  Refer to \fBQuantize(9)\fP for more details.
  1353. X
  1354. The \fB-colors\fP or \fB-monochrome\fP option is required for this option
  1355. to take effect.
  1356. .TP 5
  1357. .B -verbose
  1358. print detailed information about the image.
  1359. X
  1360. This information is printed: image scene number;  image name;  image
  1361. size; the image class (\fIDirectClass\fP or \fIPseudoClass\fP); the total
  1362. number of unique colors (if known);  and the number of seconds to read and
  1363. transform the image.  Refer to \fBMIFF(5)\fP for a description of
  1364. the image class.
  1365. X
  1366. If \fB-colors\fP is also specified, the total unique colors in the image
  1367. and color reduction error values are printed.  Refer to \fBQuantize(9)\fP
  1368. for a description of these values.
  1369. .PP
  1370. Any option you specify on the command line remains in effect until it is
  1371. explicitly changed by specifying the option again with a different effect.
  1372. For example, to mogrify two images, the first with 32 colors and the
  1373. second with only 16 colors, use:
  1374. .PP
  1375. X     mogrify -colors 32 cockatoo.miff -colors 16 macaw.miff
  1376. .PP
  1377. Change \fI-\fP to \fI\+\fP in any option above to reverse its effect.
  1378. For example, specify \fB\+compress\fP to store the binary image in an
  1379. uncompressed format.
  1380. .PP
  1381. To specify a particular image format prefix \fIfile\fP with the image
  1382. type and a colon (i.e. mtv:image) or specify the image type as the
  1383. filename suffix (i.e. image.mtv).  See \fBCONVERT(1)\fP for a list of
  1384. valid image formats.  If \fIfile\fP has the extension \fB.Z\fP, the
  1385. file size is reduced using Lempel-Ziv coding with \fBcompress\fP.  If
  1386. \fIfile\fP already exists, you will be prompted as to whether it should
  1387. be overwritten.
  1388. .SH SEE ALSO
  1389. display(1), animate(1), import(1), convert(1), Quantize(9), MIFF(5), X(1),
  1390. compress(1)
  1391. .SH COPYRIGHT
  1392. Copyright 1992 E. I. du Pont de Nemours & Company
  1393. .PP
  1394. Permission to use, copy, modify, distribute, and sell this software and
  1395. its documentation for any purpose is hereby granted without fee,
  1396. provided that the above copyright notice appear in all copies and that
  1397. both that copyright notice and this permission notice appear in
  1398. supporting documentation, and that the name of E. I. du Pont de Nemours
  1399. & Company not be used in advertising or publicity pertaining to
  1400. distribution of the software without specific, written prior
  1401. permission.  E. I. du Pont de Nemours & Company makes no representations
  1402. about the suitability of this software for any purpose.  It is provided
  1403. "as is" without express or implied warranty.
  1404. .PP
  1405. E. I. du Pont de Nemours & Company disclaims all warranties with regard
  1406. to this software, including all implied warranties of merchantability
  1407. and fitness, in no event shall E. I. du Pont de Nemours & Company be
  1408. liable for any special, indirect or consequential damages or any
  1409. damages whatsoever resulting from loss of use, data or profits, whether
  1410. in an action of contract, negligence or other tortious action, arising
  1411. out of or in connection with the use or performance of this software.
  1412. .SH ACKNOWLEDGEMENTS
  1413. Michael Halle, Spatial Imaging Group at MIT, for the initial
  1414. implementation of Alan Paeth's image rotation algorithm.
  1415. .PP
  1416. David Pensak, E. I. du Pont de Nemours & Company, for providing a
  1417. computing environment that made this program possible.
  1418. .PP
  1419. Paul Raveling, USC Information Sciences Institute, for the original
  1420. idea of using space subdivision for the color reduction algorithm.
  1421. .SH AUTHORS
  1422. John Cristy, E.I. du Pont de Nemours & Company Incorporated
  1423. SHAR_EOF
  1424. chmod 0644 ImageMagick/utilities/mogrify.man ||
  1425. echo 'restore of ImageMagick/utilities/mogrify.man failed'
  1426. Wc_c="`wc -c < 'ImageMagick/utilities/mogrify.man'`"
  1427. test 9749 -eq "$Wc_c" ||
  1428.     echo 'ImageMagick/utilities/mogrify.man: original size 9749, current size' "$Wc_c"
  1429. rm -f _shar_wnt_.tmp
  1430. fi
  1431. # ============= ImageMagick/utilities/convert.man ==============
  1432. if test -f 'ImageMagick/utilities/convert.man' -a X"$1" != X"-c"; then
  1433.     echo 'x - skipping ImageMagick/utilities/convert.man (File already exists)'
  1434.     rm -f _shar_wnt_.tmp
  1435. else
  1436. > _shar_wnt_.tmp
  1437. echo 'x - extracting ImageMagick/utilities/convert.man (Text)'
  1438. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/utilities/convert.man' &&
  1439. .ad l
  1440. .nh
  1441. .TH CONVERT 1 "10 October 1992" "ImageMagick"
  1442. .SH NAME
  1443. convert - converts an input file using one image format to an output
  1444. file with a differing image format.
  1445. .SH SYNOPSIS
  1446. .B "convert"
  1447. [ \fIoptions\fP ... ] \fIfile\fP \fIfile\fP
  1448. .SH DESCRIPTION
  1449. .PP
  1450. .I Convert
  1451. converts an input file using one image format to an output file with a
  1452. differing image format. By default, the image format is determined by
  1453. its magic number. To specify a particular image format, precede the 
  1454. filename with an image format name and a colon (i.e.  mtv:image) or specify 
  1455. the image type as the filename suffix (i.e. image.mtv).  Specify \fIfile\fP as 
  1456. \fI-\fP for standard input or output.  If \fIfile\fP has the extension 
  1457. \fB.Z\fP, the file is decoded with \fIuncompress\fP.
  1458. X
  1459. \fIConvert\fP recognizes the following image formats:
  1460. X
  1461. .TP 6
  1462. .B Tag
  1463. \fBDescription\fP
  1464. .PP
  1465. -------------------------------------------------------------
  1466. .TP 6
  1467. .B AVS
  1468. Advanced Visualization System image file format.
  1469. .TP 6
  1470. .B CMYK    
  1471. Raw cyan, magenta, yellow, and black bytes.
  1472. .TP 6
  1473. .B FAX
  1474. Group 3.
  1475. .TP 6
  1476. .B GIF
  1477. Graphic Image Format.
  1478. .TP 6
  1479. .B GRAY
  1480. Raw gray bytes.
  1481. .TP 6
  1482. .B JPEG
  1483. .TP 6
  1484. .B MIFF
  1485. Machine Independant file format.
  1486. .TP 6
  1487. .B MTV
  1488. .TP 6
  1489. .B PNM
  1490. Portable bitmap.
  1491. .TP 6
  1492. .B PS
  1493. Postscript.
  1494. .TP 6
  1495. .B RGB
  1496. Raw red, green, and blue bytes.
  1497. .TP 6
  1498. .B RLE
  1499. Utah Raster Toolkit; read only.
  1500. .TP 6
  1501. .B SUN
  1502. SUN raster.
  1503. .TP 6
  1504. .B TEXT
  1505. raw text file; read only.
  1506. .TP 6
  1507. .B TIFF
  1508. Tagged Image File Format.
  1509. .TP 6
  1510. .B VICAR
  1511. read only.
  1512. .TP 6
  1513. .B YUV
  1514. Raw Y, U, and V bytes.  U and V, normally -0.5 through 0.5, are normalized
  1515. to the range 0 through 255 to fit within a byte.
  1516. .TP 6
  1517. .B X
  1518. select image from X server screen; read only.
  1519. .TP 6
  1520. .B XC
  1521. constant image of X server background color.
  1522. .TP 6
  1523. .B XBM
  1524. XX11 bitmap.
  1525. .TP 6
  1526. .B XWD
  1527. XX11 window dump.
  1528. .PP
  1529. .SH EXAMPLES
  1530. .PP
  1531. To convert a \fIMIFF\fP image of a cockatoo to a SUN raster image, use:
  1532. .PP
  1533. X     convert cockatoo.miff sun:cockatoo.ras
  1534. .PP
  1535. To convert a \fIMTV\fP image of a molecule to a JPEG image, use:
  1536. .PP
  1537. X     convert molecule.mtv molecule.jpeg
  1538. .PP
  1539. To convert a raw \fIGRAY\fP image to a portable graymap, use:
  1540. .PP
  1541. X     convert -geometry 768x512 gray:raw image.pnm
  1542. .SH OPTIONS
  1543. .TP 5
  1544. .B "-alpha"
  1545. store alpha channel if the image has one.
  1546. .TP 5
  1547. .B "-colors \fIvalue\fP"
  1548. preferred number of colors in the image.
  1549. X
  1550. The actual number of colors in the image may be less than your request,
  1551. but never more.  Note, this is a color reduction option.  Images with
  1552. less unique colors than specified with this option will remain unchanged.
  1553. Refer to \fBQuantize(9)\fP for more details.
  1554. X
  1555. Note, options \fB-dither\fP, \fB-colorspace\fP, and \fB-treedepth\fP affect
  1556. the color reduction algorithm.
  1557. .TP 5
  1558. .B "-colorspace \fIvalue\fP"
  1559. the type of colorspace: \fIGRAY\fP, \fIRGB\fP, \fIXYZ\fP, \fIYIQ\fP, or
  1560. \fIYUV\fP.
  1561. X
  1562. Color reduction, by default, takes place in the RGB color space.
  1563. Empirical evidence suggests that distances in color spaces such as YUV
  1564. or YIQ correspond to perceptual color differences more closely
  1565. than do distances in RGB space.  These color spaces may give better
  1566. results when color reducing an image.  Refer to \fBQuantize(9)\fP for
  1567. more details.
  1568. X
  1569. The \fB-colors\fP or \fB-monochrome\fP option is required for this option
  1570. to take effect.
  1571. .TP 5
  1572. .B "-compress \fItype\fP"
  1573. the type of image compression: \fIQEncoded\fP or \fIRunlengthEncoded\fP.
  1574. X
  1575. Specify \fB\+compress\fP to store the binary image in an uncompressed format.
  1576. The default is the compression type of the specified image file.
  1577. .TP 5
  1578. .B "-density \fI<width>x<height>
  1579. vertical and horizonal density of the image.
  1580. X
  1581. This option specifies an image density whose interpretation changes
  1582. with the type of image.  The default is 72 dots per inch in the
  1583. horizonal and vertical direction for Postscript.  Text files default to
  1584. 80 characters in width and 60 lines in height.  Use this option to
  1585. alter the default density.
  1586. .TP 5
  1587. .B "-display \fIhost:display[.screen]\fP"
  1588. specifies the X server to contact; see \fBX(1)\fP.
  1589. .TP 5
  1590. .B "-dither"
  1591. apply Floyd/Steinberg error diffusion to the image.
  1592. X
  1593. The basic strategy of dithering is to trade intensity resolution for
  1594. spatial resolution by averaging the intensities of several neighboring
  1595. pixels.  Images which suffer from severe contouring when reducing colors
  1596. can be improved with this option.
  1597. X
  1598. The \fB-colors\fP option is required for dithering to take effect.
  1599. .TP 5
  1600. .B "-geometry \fI<width>x<height>\fP"
  1601. the width and height of the image.  
  1602. X
  1603. Use this option to specified the width and height of raw images whose
  1604. dimensions are unknown such as GRAY, RGB, and CMYK.  This option can
  1605. also change the default 8.5 by 11 width and height of the Postscript
  1606. canvas.
  1607. .TP 5
  1608. .B "-quality \fIvalue\fP"
  1609. JPEG quality setting.  Quality is 0 (worst) to 100 (best). The default is
  1610. 75.
  1611. .TP 5
  1612. .B "-scene \fIvalue\fP"
  1613. image scene number.
  1614. .TP 5
  1615. .B "-treedepth \fIvalue\fP"
  1616. Normally, this integer value is zero or one.  A zero or one tells
  1617. \fIDisplay\fP to choose a optimal tree depth for the color reduction
  1618. algorithm.
  1619. X
  1620. An optimal depth generally allows the best representation of the source
  1621. image with the fastest computational speed and the least amount of
  1622. memory.  However, the default depth is inappropriate for some images.
  1623. To assure the best representation, try values between 2 and 8 for this
  1624. parameter.  Refer to \fBQuantize(9)\fP for more details.
  1625. X
  1626. The \fB-colors\fP option is required for this option to take effect.
  1627. .TP 5
  1628. .B -verbose
  1629. print detailed information about the image.
  1630. X
  1631. This information is printed: image scene number;  image name;  converted
  1632. image name;  image size;  the image class (\fIDirectClass\fP or 
  1633. \fIPseudoClass\fP);  the total number of unique colors;  and the number
  1634. of seconds to read and convert the image.
  1635. .PP
  1636. Change '-' to '+' in any option above to reverse its effect.  For
  1637. example, specify +alpha to store the image without its alpha channel.
  1638. .PP
  1639. To specify a particular image format prefix \fIfile\fP with the image
  1640. type and a colon (i.e. mtv:image) or specify the image type as the
  1641. filename suffix (i.e. image.mtv).  See the beginning of this document
  1642. for a list of valid image formats.  If \fIfile\fP has the extension
  1643. \fB.Z\fP, the file size is reduced using Lempel-Ziv coding with
  1644. \fBcompress\fP.  If \fIfile\fP already exists, you will be prompted as
  1645. to whether it should be overwritten.
  1646. X
  1647. When you specify \fBX\fP as your image type, the filename has special
  1648. meaning.  It specifies an X window by id, name, or \fBroot\fP.  If no
  1649. filename is specified, the window is selected by clicking the mouse in
  1650. the desired window.
  1651. .SH ENVIRONMENT
  1652. .PP
  1653. .TP 5
  1654. .B DISPLAY
  1655. To get the default host, display number, and screen.
  1656. .SH SEE ALSO
  1657. display(1), animate(1), mogrify(1), Quantize(9), X(1), MIFF(5)
  1658. .SH COPYRIGHT
  1659. SHAR_EOF
  1660. true || echo 'restore of ImageMagick/utilities/convert.man failed'
  1661. fi
  1662. echo 'End of  part 25'
  1663. echo 'File ImageMagick/utilities/convert.man is continued in part 26'
  1664. echo 26 > _shar_seq_.tmp
  1665. exit 0
  1666. exit 0 # Just in case...
  1667.