PageRenderTime 65ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/lib/wand/convert.c

http://github.com/idaunis/binarytiers
C | 2993 lines | 2842 code | 60 blank | 91 comment | 1514 complexity | 7aa54b8fdebb8c7aae59af582d65b2ec MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. % %
  4. % %
  5. % %
  6. % CCCC OOO N N V V EEEEE RRRR TTTTT %
  7. % C O O NN N V V E R R T %
  8. % C O O N N N V V EEE RRRR T %
  9. % C O O N NN V V E R R T %
  10. % CCCC OOO N N V EEEEE R R T %
  11. % %
  12. % %
  13. % Convert an image from one format to another. %
  14. % %
  15. % Software Design %
  16. % John Cristy %
  17. % April 1992 %
  18. % %
  19. % %
  20. % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
  21. % dedicated to making software imaging solutions freely available. %
  22. % %
  23. % You may not use this file except in compliance with the License. You may %
  24. % obtain a copy of the License at %
  25. % %
  26. % http://www.imagemagick.org/script/license.php %
  27. % %
  28. % Unless required by applicable law or agreed to in writing, software %
  29. % distributed under the License is distributed on an "AS IS" BASIS, %
  30. % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
  31. % See the License for the specific language governing permissions and %
  32. % limitations under the License. %
  33. % %
  34. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  35. %
  36. % Use the convert program to convert between image formats as well as resize
  37. % an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample,
  38. % and much more.
  39. %
  40. */
  41. /*
  42. Include declarations.
  43. */
  44. #include "wand/studio.h"
  45. #include "wand/MagickWand.h"
  46. #include "wand/mogrify-private.h"
  47. /*
  48. Define declarations.
  49. */
  50. #define ThrowFileException(exception,severity,tag,context) \
  51. { \
  52. (void) ThrowMagickException(exception,GetMagickModule(),severity, \
  53. tag == (const char *) NULL ? "unknown" : tag,"`%s': %s",context, \
  54. GetExceptionMessage(errno)); \
  55. }
  56. /*
  57. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  58. % %
  59. % %
  60. % %
  61. + C o n v e r t I m a g e C o m m a n d %
  62. % %
  63. % %
  64. % %
  65. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  66. %
  67. % ConvertImageCommand() reads one or more images, applies one or more image
  68. % processing operations, and writes out the image in the same or differing
  69. % format.
  70. %
  71. % The format of the ConvertImageCommand method is:
  72. %
  73. % MagickBooleanType ConvertImageCommand(ImageInfo *image_info,int argc,
  74. % char **argv,char **metadata,ExceptionInfo *exception)
  75. %
  76. % A description of each parameter follows:
  77. %
  78. % o image_info: the image info.
  79. %
  80. % o argc: the number of elements in the argument vector.
  81. %
  82. % o argv: A text array containing the command line arguments.
  83. %
  84. % o metadata: any metadata is returned here.
  85. %
  86. % o exception: return any errors or warnings in this structure.
  87. %
  88. */
  89. static MagickBooleanType ConcatenateImages(int argc,char **argv,
  90. ExceptionInfo *exception)
  91. {
  92. FILE
  93. *input,
  94. *output;
  95. int
  96. c;
  97. register ssize_t
  98. i;
  99. /*
  100. Open output file.
  101. */
  102. output=OpenMagickStream(argv[argc-1],"wb");
  103. if (output == (FILE *) NULL)
  104. {
  105. ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
  106. argv[argc-1]);
  107. return(MagickFalse);
  108. }
  109. for (i=2; i < (ssize_t) (argc-1); i++)
  110. {
  111. input=OpenMagickStream(argv[i],"rb");
  112. if (input == (FILE *) NULL)
  113. ThrowFileException(exception,FileOpenError,"UnableToOpenFile",argv[i]);
  114. for (c=fgetc(input); c != EOF; c=fgetc(input))
  115. (void) fputc((char) c,output);
  116. (void) fclose(input);
  117. (void) remove(argv[i]);
  118. }
  119. (void) fclose(output);
  120. return(MagickTrue);
  121. }
  122. static MagickBooleanType ConvertUsage(void)
  123. {
  124. static const char
  125. *miscellaneous[]=
  126. {
  127. "-debug events display copious debugging information",
  128. "-help print program options",
  129. "-list type print a list of supported option arguments",
  130. "-log format format of debugging information",
  131. "-version print version information",
  132. (char *) NULL
  133. },
  134. *operators[]=
  135. {
  136. "-adaptive-blur geometry",
  137. " adaptively blur pixels; decrease effect near edges",
  138. "-adaptive-resize geometry",
  139. " adaptively resize image using 'mesh' interpolation",
  140. "-adaptive-sharpen geometry",
  141. " adaptively sharpen pixels; increase effect near edges",
  142. "-alpha option on, activate, off, deactivate, set, opaque, copy",
  143. " transparent, extract, background, or shape",
  144. "-annotate geometry text",
  145. " annotate the image with text",
  146. "-auto-gamma automagically adjust gamma level of image",
  147. "-auto-level automagically adjust color levels of image",
  148. "-auto-orient automagically orient (rotate) image",
  149. "-bench iterations measure performance",
  150. "-black-threshold value",
  151. " force all pixels below the threshold into black",
  152. "-blue-shift factor simulate a scene at nighttime in the moonlight",
  153. "-blur geometry reduce image noise and reduce detail levels",
  154. "-border geometry surround image with a border of color",
  155. "-bordercolor color border color",
  156. "-brightness-contrast geometry",
  157. " improve brightness / contrast of the image",
  158. "-cdl filename color correct with a color decision list",
  159. "-charcoal radius simulate a charcoal drawing",
  160. "-chop geometry remove pixels from the image interior",
  161. "-clamp restrict pixel range from 0 to the quantum depth",
  162. "-clip clip along the first path from the 8BIM profile",
  163. "-clip-mask filename associate a clip mask with the image",
  164. "-clip-path id clip along a named path from the 8BIM profile",
  165. "-colorize value colorize the image with the fill color",
  166. "-color-matrix matrix apply color correction to the image",
  167. "-contrast enhance or reduce the image contrast",
  168. "-contrast-stretch geometry",
  169. " improve contrast by `stretching' the intensity range",
  170. "-convolve coefficients",
  171. " apply a convolution kernel to the image",
  172. "-cycle amount cycle the image colormap",
  173. "-decipher filename convert cipher pixels to plain pixels",
  174. "-deskew threshold straighten an image",
  175. "-despeckle reduce the speckles within an image",
  176. "-distort method args",
  177. " distort images according to given method ad args",
  178. "-draw string annotate the image with a graphic primitive",
  179. "-edge radius apply a filter to detect edges in the image",
  180. "-encipher filename convert plain pixels to cipher pixels",
  181. "-emboss radius emboss an image",
  182. "-enhance apply a digital filter to enhance a noisy image",
  183. "-equalize perform histogram equalization to an image",
  184. "-evaluate operator value",
  185. " evaluate an arithmetic, relational, or logical expression",
  186. "-extent geometry set the image size",
  187. "-extract geometry extract area from image",
  188. "-fft implements the discrete Fourier transform (DFT)",
  189. "-flip flip image vertically",
  190. "-floodfill geometry color",
  191. " floodfill the image with color",
  192. "-flop flop image horizontally",
  193. "-frame geometry surround image with an ornamental border",
  194. "-function name parameters",
  195. " apply function over image values",
  196. "-gamma value level of gamma correction",
  197. "-gaussian-blur geometry",
  198. " reduce image noise and reduce detail levels",
  199. "-geometry geometry preferred size or location of the image",
  200. "-identify identify the format and characteristics of the image",
  201. "-ift implements the inverse discrete Fourier transform (DFT)",
  202. "-implode amount implode image pixels about the center",
  203. "-lat geometry local adaptive thresholding",
  204. "-layers method optimize, merge, or compare image layers",
  205. "-level value adjust the level of image contrast",
  206. "-level-colors color,color",
  207. " level image with the given colors",
  208. "-linear-stretch geometry",
  209. " improve contrast by `stretching with saturation'",
  210. "-liquid-rescale geometry",
  211. " rescale image with seam-carving",
  212. "-median radius apply a median filter to the image",
  213. "-mode radius make each pixel the 'predominate color' of the neighborhood",
  214. "-modulate value vary the brightness, saturation, and hue",
  215. "-monochrome transform image to black and white",
  216. "-morphology method kernel",
  217. " apply a morphology method to the image",
  218. "-motion-blur geometry",
  219. " simulate motion blur",
  220. "-negate replace every pixel with its complementary color ",
  221. "-noise radius add or reduce noise in an image",
  222. "-normalize transform image to span the full range of colors",
  223. "-opaque color change this color to the fill color",
  224. "-ordered-dither NxN",
  225. " add a noise pattern to the image with specific",
  226. " amplitudes",
  227. "-paint radius simulate an oil painting",
  228. "-polaroid angle simulate a Polaroid picture",
  229. "-posterize levels reduce the image to a limited number of color levels",
  230. "-profile filename add, delete, or apply an image profile",
  231. "-quantize colorspace reduce colors in this colorspace",
  232. "-radial-blur angle radial blur the image",
  233. "-raise value lighten/darken image edges to create a 3-D effect",
  234. "-random-threshold low,high",
  235. " random threshold the image",
  236. "-region geometry apply options to a portion of the image",
  237. "-render render vector graphics",
  238. "-repage geometry size and location of an image canvas",
  239. "-resample geometry change the resolution of an image",
  240. "-resize geometry resize the image",
  241. "-roll geometry roll an image vertically or horizontally",
  242. "-rotate degrees apply Paeth rotation to the image",
  243. "-sample geometry scale image with pixel sampling",
  244. "-scale geometry scale the image",
  245. "-segment values segment an image",
  246. "-selective-blur geometry",
  247. " selectively blur pixels within a contrast threshold",
  248. "-sepia-tone threshold",
  249. " simulate a sepia-toned photo",
  250. "-set property value set an image property",
  251. "-shade degrees shade the image using a distant light source",
  252. "-shadow geometry simulate an image shadow",
  253. "-sharpen geometry sharpen the image",
  254. "-shave geometry shave pixels from the image edges",
  255. "-shear geometry slide one edge of the image along the X or Y axis",
  256. "-sigmoidal-contrast geometry",
  257. " increase the contrast without saturating highlights or shadows",
  258. "-sketch geometry simulate a pencil sketch",
  259. "-solarize threshold negate all pixels above the threshold level",
  260. "-sparse-color method args",
  261. " fill in a image based on a few color points",
  262. "-splice geometry splice the background color into the image",
  263. "-spread radius displace image pixels by a random amount",
  264. "-strip strip image of all profiles and comments",
  265. "-swirl degrees swirl image pixels about the center",
  266. "-threshold value threshold the image",
  267. "-thumbnail geometry create a thumbnail of the image",
  268. "-tile filename tile image when filling a graphic primitive",
  269. "-tint value tint the image with the fill color",
  270. "-transform affine transform image",
  271. "-transparent color make this color transparent within the image",
  272. "-transpose flip image vertically and rotate 90 degrees",
  273. "-transverse flop image horizontally and rotate 270 degrees",
  274. "-trim trim image edges",
  275. "-type type image type",
  276. "-unique-colors discard all but one of any pixel color",
  277. "-unsharp geometry sharpen the image",
  278. "-vignette geometry soften the edges of the image in vignette style",
  279. "-wave geometry alter an image along a sine wave",
  280. "-white-threshold value",
  281. " force all pixels above the threshold into white",
  282. (char *) NULL
  283. },
  284. *sequence_operators[]=
  285. {
  286. "-append append an image sequence",
  287. "-clut apply a color lookup table to the image",
  288. "-coalesce merge a sequence of images",
  289. "-combine combine a sequence of images",
  290. "-composite composite image",
  291. "-crop geometry cut out a rectangular region of the image",
  292. "-deconstruct break down an image sequence into constituent parts",
  293. "-evaluate-sequence operator",
  294. " evaluate an arithmetic, relational, or logical expression",
  295. "-flatten flatten a sequence of images",
  296. "-fx expression apply mathematical expression to an image channel(s)",
  297. "-hald-clut apply a Hald color lookup table to the image",
  298. "-morph value morph an image sequence",
  299. "-mosaic create a mosaic from an image sequence",
  300. "-print string interpret string and print to console",
  301. "-process arguments process the image with a custom image filter",
  302. "-reverse reverse image sequence",
  303. "-separate separate an image channel into a grayscale image",
  304. "-smush geometry smush an image sequence together",
  305. "-write filename write images to this file",
  306. (char *) NULL
  307. },
  308. *settings[]=
  309. {
  310. "-adjoin join images into a single multi-image file",
  311. "-affine matrix affine transform matrix",
  312. "-alpha option activate, deactivate, reset, or set the alpha channel",
  313. "-antialias remove pixel-aliasing",
  314. "-authenticate password",
  315. " decipher image with this password",
  316. "-attenuate value lessen (or intensify) when adding noise to an image",
  317. "-background color background color",
  318. "-bias value add bias when convolving an image",
  319. "-black-point-compensation",
  320. " use black point compensation",
  321. "-blue-primary point chromaticity blue primary point",
  322. "-bordercolor color border color",
  323. "-caption string assign a caption to an image",
  324. "-channel type apply option to select image channels",
  325. "-colors value preferred number of colors in the image",
  326. "-colorspace type alternate image colorspace",
  327. "-comment string annotate image with comment",
  328. "-compose operator set image composite operator",
  329. "-compress type type of pixel compression when writing the image",
  330. "-define format:option",
  331. " define one or more image format options",
  332. "-delay value display the next image after pausing",
  333. "-density geometry horizontal and vertical density of the image",
  334. "-depth value image depth",
  335. "-direction type render text right-to-left or left-to-right",
  336. "-display server get image or font from this X server",
  337. "-dispose method layer disposal method",
  338. "-dither method apply error diffusion to image",
  339. "-encoding type text encoding type",
  340. "-endian type endianness (MSB or LSB) of the image",
  341. "-family name render text with this font family",
  342. "-fill color color to use when filling a graphic primitive",
  343. "-filter type use this filter when resizing an image",
  344. "-font name render text with this font",
  345. "-format \"string\" output formatted image characteristics",
  346. "-fuzz distance colors within this distance are considered equal",
  347. "-gravity type horizontal and vertical text placement",
  348. "-green-primary point chromaticity green primary point",
  349. "-intent type type of rendering intent when managing the image color",
  350. "-interlace type type of image interlacing scheme",
  351. "-interline-spacing value",
  352. " set the space between two text lines",
  353. "-interpolate method pixel color interpolation method",
  354. "-interword-spacing value",
  355. " set the space between two words",
  356. "-kerning value set the space between two letters",
  357. "-label string assign a label to an image",
  358. "-limit type value pixel cache resource limit",
  359. "-loop iterations add Netscape loop extension to your GIF animation",
  360. "-mask filename associate a mask with the image",
  361. "-mattecolor color frame color",
  362. "-monitor monitor progress",
  363. "-orient type image orientation",
  364. "-page geometry size and location of an image canvas (setting)",
  365. "-ping efficiently determine image attributes",
  366. "-pointsize value font point size",
  367. "-precision value maximum number of significant digits to print",
  368. "-preview type image preview type",
  369. "-quality value JPEG/MIFF/PNG compression level",
  370. "-quiet suppress all warning messages",
  371. "-red-primary point chromaticity red primary point",
  372. "-regard-warnings pay attention to warning messages",
  373. "-remap filename transform image colors to match this set of colors",
  374. "-respect-parentheses settings remain in effect until parenthesis boundary",
  375. "-sampling-factor geometry",
  376. " horizontal and vertical sampling factor",
  377. "-scene value image scene number",
  378. "-seed value seed a new sequence of pseudo-random numbers",
  379. "-size geometry width and height of image",
  380. "-stretch type render text with this font stretch",
  381. "-stroke color graphic primitive stroke color",
  382. "-strokewidth value graphic primitive stroke width",
  383. "-style type render text with this font style",
  384. "-synchronize synchronize image to storage device",
  385. "-taint declare the image as modified",
  386. "-texture filename name of texture to tile onto the image background",
  387. "-tile-offset geometry",
  388. " tile offset",
  389. "-treedepth value color tree depth",
  390. "-transparent-color color",
  391. " transparent color",
  392. "-undercolor color annotation bounding box color",
  393. "-units type the units of image resolution",
  394. "-verbose print detailed information about the image",
  395. "-view FlashPix viewing transforms",
  396. "-virtual-pixel method",
  397. " virtual pixel access method",
  398. "-weight type render text with this font weight",
  399. "-white-point point chromaticity white point",
  400. (char *) NULL
  401. },
  402. *stack_operators[]=
  403. {
  404. "-clone index clone an image",
  405. "-delete index delete the image from the image sequence",
  406. "-insert index insert last image into the image sequence",
  407. "-swap indexes swap two images in the image sequence",
  408. (char *) NULL
  409. };
  410. const char
  411. **p;
  412. (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
  413. (void) printf("Copyright: %s\n",GetMagickCopyright());
  414. (void) printf("Features: %s\n\n",GetMagickFeatures());
  415. (void) printf("Usage: %s [options ...] file [ [options ...] "
  416. "file ...] [options ...] file\n",GetClientName());
  417. (void) printf("\nImage Settings:\n");
  418. for (p=settings; *p != (char *) NULL; p++)
  419. (void) printf(" %s\n",*p);
  420. (void) printf("\nImage Operators:\n");
  421. for (p=operators; *p != (char *) NULL; p++)
  422. (void) printf(" %s\n",*p);
  423. (void) printf("\nImage Sequence Operators:\n");
  424. for (p=sequence_operators; *p != (char *) NULL; p++)
  425. (void) printf(" %s\n",*p);
  426. (void) printf("\nImage Stack Operators:\n");
  427. for (p=stack_operators; *p != (char *) NULL; p++)
  428. (void) printf(" %s\n",*p);
  429. (void) printf("\nMiscellaneous Options:\n");
  430. for (p=miscellaneous; *p != (char *) NULL; p++)
  431. (void) printf(" %s\n",*p);
  432. (void) printf(
  433. "\nBy default, the image format of `file' is determined by its magic\n");
  434. (void) printf(
  435. "number. To specify a particular image format, precede the filename\n");
  436. (void) printf(
  437. "with an image format name and a colon (i.e. ps:image) or specify the\n");
  438. (void) printf(
  439. "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
  440. (void) printf("'-' for standard input or output.\n");
  441. return(MagickFalse);
  442. }
  443. WandExport MagickBooleanType ConvertImageCommand(ImageInfo *image_info,
  444. int argc,char **argv,char **metadata,ExceptionInfo *exception)
  445. {
  446. #define NotInitialized (unsigned int) (~0)
  447. #define DestroyConvert() \
  448. { \
  449. DestroyImageStack(); \
  450. for (i=0; i < (ssize_t) argc; i++) \
  451. argv[i]=DestroyString(argv[i]); \
  452. argv=(char **) RelinquishMagickMemory(argv); \
  453. }
  454. #define ThrowConvertException(asperity,tag,option) \
  455. { \
  456. (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
  457. option); \
  458. DestroyConvert(); \
  459. return(MagickFalse); \
  460. }
  461. #define ThrowConvertInvalidArgumentException(option,argument) \
  462. { \
  463. (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
  464. "InvalidArgument","`%s': %s",option,argument); \
  465. DestroyConvert(); \
  466. return(MagickFalse); \
  467. }
  468. char
  469. *filename,
  470. *option;
  471. const char
  472. *format;
  473. Image
  474. *image;
  475. ImageStack
  476. image_stack[MaxImageStackDepth+1];
  477. ssize_t
  478. j,
  479. k;
  480. MagickBooleanType
  481. fire,
  482. pend,
  483. respect_parenthesis;
  484. MagickStatusType
  485. status;
  486. register ssize_t
  487. i;
  488. /*
  489. Set defaults.
  490. */
  491. assert(image_info != (ImageInfo *) NULL);
  492. assert(image_info->signature == MagickSignature);
  493. if (image_info->debug != MagickFalse)
  494. (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
  495. assert(exception != (ExceptionInfo *) NULL);
  496. if (argc == 2)
  497. {
  498. option=argv[1];
  499. if ((LocaleCompare("version",option+1) == 0) ||
  500. (LocaleCompare("-version",option+1) == 0))
  501. {
  502. (void) fprintf(stdout,"Version: %s\n",
  503. GetMagickVersion((size_t *) NULL));
  504. (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
  505. (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
  506. return(MagickFalse);
  507. }
  508. }
  509. if (argc < 3)
  510. return(ConvertUsage());
  511. filename=(char *) NULL;
  512. format="%w,%h,%m";
  513. j=1;
  514. k=0;
  515. NewImageStack();
  516. option=(char *) NULL;
  517. pend=MagickFalse;
  518. respect_parenthesis=MagickFalse;
  519. status=MagickTrue;
  520. /*
  521. Parse command-line arguments.
  522. */
  523. ReadCommandlLine(argc,&argv);
  524. status=ExpandFilenames(&argc,&argv);
  525. if (status == MagickFalse)
  526. ThrowConvertException(ResourceLimitError,"MemoryAllocationFailed",
  527. GetExceptionMessage(errno));
  528. if ((argc > 2) && (LocaleCompare("-concatenate",argv[1]) == 0))
  529. return(ConcatenateImages(argc,argv,exception));
  530. for (i=1; i < (ssize_t) (argc-1); i++)
  531. {
  532. option=argv[i];
  533. if (LocaleCompare(option,"(") == 0)
  534. {
  535. FireImageStack(MagickTrue,MagickTrue,pend);
  536. if (k == MaxImageStackDepth)
  537. ThrowConvertException(OptionError,"ParenthesisNestedTooDeeply",
  538. option);
  539. PushImageStack();
  540. continue;
  541. }
  542. if (LocaleCompare(option,")") == 0)
  543. {
  544. FireImageStack(MagickTrue,MagickTrue,MagickTrue);
  545. if (k == 0)
  546. ThrowConvertException(OptionError,"UnableToParseExpression",option);
  547. PopImageStack();
  548. continue;
  549. }
  550. if (IsMagickOption(option) == MagickFalse)
  551. {
  552. Image
  553. *images;
  554. /*
  555. Read input image.
  556. */
  557. FireImageStack(MagickTrue,MagickTrue,pend);
  558. filename=argv[i];
  559. if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
  560. filename=argv[++i];
  561. (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
  562. if (image_info->ping != MagickFalse)
  563. images=PingImages(image_info,exception);
  564. else
  565. images=ReadImages(image_info,exception);
  566. status&=(images != (Image *) NULL) &&
  567. (exception->severity < ErrorException);
  568. if (images == (Image *) NULL)
  569. continue;
  570. AppendImageStack(images);
  571. continue;
  572. }
  573. pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
  574. switch (*(option+1))
  575. {
  576. case 'a':
  577. {
  578. if (LocaleCompare("adaptive-blur",option+1) == 0)
  579. {
  580. i++;
  581. if (i == (ssize_t) (argc-1))
  582. ThrowConvertException(OptionError,"MissingArgument",option);
  583. if (IsGeometry(argv[i]) == MagickFalse)
  584. ThrowConvertInvalidArgumentException(option,argv[i]);
  585. break;
  586. }
  587. if (LocaleCompare("adaptive-resize",option+1) == 0)
  588. {
  589. i++;
  590. if (i == (ssize_t) (argc-1))
  591. ThrowConvertException(OptionError,"MissingArgument",option);
  592. if (IsGeometry(argv[i]) == MagickFalse)
  593. ThrowConvertInvalidArgumentException(option,argv[i]);
  594. break;
  595. }
  596. if (LocaleCompare("adaptive-sharpen",option+1) == 0)
  597. {
  598. i++;
  599. if (i == (ssize_t) (argc-1))
  600. ThrowConvertException(OptionError,"MissingArgument",option);
  601. if (IsGeometry(argv[i]) == MagickFalse)
  602. ThrowConvertInvalidArgumentException(option,argv[i]);
  603. break;
  604. }
  605. if (LocaleCompare("adjoin",option+1) == 0)
  606. break;
  607. if (LocaleCompare("affine",option+1) == 0)
  608. {
  609. if (*option == '+')
  610. break;
  611. i++;
  612. if (i == (ssize_t) (argc-1))
  613. ThrowConvertException(OptionError,"MissingArgument",option);
  614. break;
  615. }
  616. if (LocaleCompare("alpha",option+1) == 0)
  617. {
  618. ssize_t
  619. type;
  620. if (*option == '+')
  621. break;
  622. i++;
  623. if (i == (ssize_t) argc)
  624. ThrowConvertException(OptionError,"MissingArgument",option);
  625. type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
  626. if (type < 0)
  627. ThrowConvertException(OptionError,"UnrecognizedAlphaChannelType",
  628. argv[i]);
  629. break;
  630. }
  631. if (LocaleCompare("annotate",option+1) == 0)
  632. {
  633. if (*option == '+')
  634. break;
  635. i++;
  636. if (i == (ssize_t) (argc-1))
  637. ThrowConvertException(OptionError,"MissingArgument",option);
  638. if (IsGeometry(argv[i]) == MagickFalse)
  639. ThrowConvertInvalidArgumentException(option,argv[i]);
  640. i++;
  641. if (i == (ssize_t) (argc-1))
  642. ThrowConvertException(OptionError,"MissingArgument",option);
  643. break;
  644. }
  645. if (LocaleCompare("antialias",option+1) == 0)
  646. break;
  647. if (LocaleCompare("append",option+1) == 0)
  648. break;
  649. if (LocaleCompare("attenuate",option+1) == 0)
  650. {
  651. if (*option == '+')
  652. break;
  653. i++;
  654. if (i == (ssize_t) (argc-1))
  655. ThrowConvertException(OptionError,"MissingArgument",option);
  656. if (IsGeometry(argv[i]) == MagickFalse)
  657. ThrowConvertInvalidArgumentException(option,argv[i]);
  658. break;
  659. }
  660. if (LocaleCompare("authenticate",option+1) == 0)
  661. {
  662. if (*option == '+')
  663. break;
  664. i++;
  665. if (i == (ssize_t) (argc-1))
  666. ThrowConvertException(OptionError,"MissingArgument",option);
  667. break;
  668. }
  669. if (LocaleCompare("auto-gamma",option+1) == 0)
  670. break;
  671. if (LocaleCompare("auto-level",option+1) == 0)
  672. break;
  673. if (LocaleCompare("auto-orient",option+1) == 0)
  674. break;
  675. if (LocaleCompare("average",option+1) == 0)
  676. break;
  677. ThrowConvertException(OptionError,"UnrecognizedOption",option)
  678. }
  679. case 'b':
  680. {
  681. if (LocaleCompare("background",option+1) == 0)
  682. {
  683. if (*option == '+')
  684. break;
  685. i++;
  686. if (i == (ssize_t) (argc-1))
  687. ThrowConvertException(OptionError,"MissingArgument",option);
  688. break;
  689. }
  690. if (LocaleCompare("bench",option+1) == 0)
  691. {
  692. if (*option == '+')
  693. break;
  694. i++;
  695. if (i == (ssize_t) (argc-1))
  696. ThrowConvertException(OptionError,"MissingArgument",option);
  697. if (IsGeometry(argv[i]) == MagickFalse)
  698. ThrowConvertInvalidArgumentException(option,argv[i]);
  699. break;
  700. }
  701. if (LocaleCompare("bias",option+1) == 0)
  702. {
  703. if (*option == '+')
  704. break;
  705. i++;
  706. if (i == (ssize_t) (argc-1))
  707. ThrowConvertException(OptionError,"MissingArgument",option);
  708. if (IsGeometry(argv[i]) == MagickFalse)
  709. ThrowConvertInvalidArgumentException(option,argv[i]);
  710. break;
  711. }
  712. if (LocaleCompare("black-point-compensation",option+1) == 0)
  713. break;
  714. if (LocaleCompare("black-threshold",option+1) == 0)
  715. {
  716. if (*option == '+')
  717. break;
  718. i++;
  719. if (i == (ssize_t) (argc-1))
  720. ThrowConvertException(OptionError,"MissingArgument",option);
  721. if (IsGeometry(argv[i]) == MagickFalse)
  722. ThrowConvertInvalidArgumentException(option,argv[i]);
  723. break;
  724. }
  725. if (LocaleCompare("blue-primary",option+1) == 0)
  726. {
  727. if (*option == '+')
  728. break;
  729. i++;
  730. if (i == (ssize_t) (argc-1))
  731. ThrowConvertException(OptionError,"MissingArgument",option);
  732. if (IsGeometry(argv[i]) == MagickFalse)
  733. ThrowConvertInvalidArgumentException(option,argv[i]);
  734. break;
  735. }
  736. if (LocaleCompare("blue-shift",option+1) == 0)
  737. {
  738. if (*option == '+')
  739. break;
  740. i++;
  741. if (i == (ssize_t) (argc-1))
  742. ThrowConvertException(OptionError,"MissingArgument",option);
  743. if (IsGeometry(argv[i]) == MagickFalse)
  744. ThrowConvertInvalidArgumentException(option,argv[i]);
  745. break;
  746. }
  747. if (LocaleCompare("blur",option+1) == 0)
  748. {
  749. if (*option == '+')
  750. break;
  751. i++;
  752. if (i == (ssize_t) (argc-1))
  753. ThrowConvertException(OptionError,"MissingArgument",option);
  754. if (IsGeometry(argv[i]) == MagickFalse)
  755. ThrowConvertInvalidArgumentException(option,argv[i]);
  756. break;
  757. }
  758. if (LocaleCompare("border",option+1) == 0)
  759. {
  760. if (*option == '+')
  761. break;
  762. i++;
  763. if (i == (ssize_t) (argc-1))
  764. ThrowConvertException(OptionError,"MissingArgument",option);
  765. if (IsGeometry(argv[i]) == MagickFalse)
  766. ThrowConvertInvalidArgumentException(option,argv[i]);
  767. break;
  768. }
  769. if (LocaleCompare("bordercolor",option+1) == 0)
  770. {
  771. if (*option == '+')
  772. break;
  773. i++;
  774. if (i == (ssize_t) (argc-1))
  775. ThrowConvertException(OptionError,"MissingArgument",option);
  776. break;
  777. }
  778. if (LocaleCompare("box",option+1) == 0)
  779. {
  780. if (*option == '+')
  781. break;
  782. i++;
  783. if (i == (ssize_t) (argc-1))
  784. ThrowConvertException(OptionError,"MissingArgument",option);
  785. break;
  786. }
  787. if (LocaleCompare("brightness-contrast",option+1) == 0)
  788. {
  789. i++;
  790. if (i == (ssize_t) (argc-1))
  791. ThrowConvertException(OptionError,"MissingArgument",option);
  792. if (IsGeometry(argv[i]) == MagickFalse)
  793. ThrowConvertInvalidArgumentException(option,argv[i]);
  794. break;
  795. }
  796. ThrowConvertException(OptionError,"UnrecognizedOption",option)
  797. }
  798. case 'c':
  799. {
  800. if (LocaleCompare("cache",option+1) == 0)
  801. {
  802. if (*option == '+')
  803. break;
  804. i++;
  805. if (i == (ssize_t) (argc-1))
  806. ThrowConvertException(OptionError,"MissingArgument",option);
  807. if (IsGeometry(argv[i]) == MagickFalse)
  808. ThrowConvertInvalidArgumentException(option,argv[i]);
  809. break;
  810. }
  811. if (LocaleCompare("caption",option+1) == 0)
  812. {
  813. if (*option == '+')
  814. break;
  815. i++;
  816. if (i == (ssize_t) argc)
  817. ThrowConvertException(OptionError,"MissingArgument",option);
  818. break;
  819. }
  820. if (LocaleCompare("cdl",option+1) == 0)
  821. {
  822. if (*option == '+')
  823. break;
  824. i++;
  825. if (i == (ssize_t) (argc-1))
  826. ThrowConvertException(OptionError,"MissingArgument",option);
  827. break;
  828. }
  829. if (LocaleCompare("channel",option+1) == 0)
  830. {
  831. ssize_t
  832. channel;
  833. if (*option == '+')
  834. break;
  835. i++;
  836. if (i == (ssize_t) (argc-1))
  837. ThrowConvertException(OptionError,"MissingArgument",option);
  838. channel=ParseChannelOption(argv[i]);
  839. if (channel < 0)
  840. ThrowConvertException(OptionError,"UnrecognizedChannelType",
  841. argv[i]);
  842. break;
  843. }
  844. if (LocaleCompare("charcoal",option+1) == 0)
  845. {
  846. if (*option == '+')
  847. break;
  848. i++;
  849. if (i == (ssize_t) (argc-1))
  850. ThrowConvertException(OptionError,"MissingArgument",option);
  851. if (IsGeometry(argv[i]) == MagickFalse)
  852. ThrowConvertInvalidArgumentException(option,argv[i]);
  853. break;
  854. }
  855. if (LocaleCompare("chop",option+1) == 0)
  856. {
  857. if (*option == '+')
  858. break;
  859. i++;
  860. if (i == (ssize_t) (argc-1))
  861. ThrowConvertException(OptionError,"MissingArgument",option);
  862. if (IsGeometry(argv[i]) == MagickFalse)
  863. ThrowConvertInvalidArgumentException(option,argv[i]);
  864. break;
  865. }
  866. if (LocaleCompare("clamp",option+1) == 0)
  867. break;
  868. if (LocaleCompare("clip",option+1) == 0)
  869. break;
  870. if (LocaleCompare("clip-mask",option+1) == 0)
  871. {
  872. if (*option == '+')
  873. break;
  874. i++;
  875. if (i == (ssize_t) (argc-1))
  876. ThrowConvertException(OptionError,"MissingArgument",option);
  877. break;
  878. }
  879. if (LocaleCompare("clip-path",option+1) == 0)
  880. {
  881. i++;
  882. if (i == (ssize_t) (argc-1))
  883. ThrowConvertException(OptionError,"MissingArgument",option);
  884. break;
  885. }
  886. if (LocaleCompare("clone",option+1) == 0)
  887. {
  888. Image
  889. *clone_images;
  890. clone_images=image;
  891. if (k != 0)
  892. clone_images=image_stack[k-1].image;
  893. if (clone_images == (Image *) NULL)
  894. ThrowConvertException(ImageError,"ImageSequenceRequired",option);
  895. FireImageStack(MagickTrue,MagickTrue,MagickTrue);
  896. if (*option == '+')
  897. clone_images=CloneImages(clone_images,"-1",exception);
  898. else
  899. {
  900. i++;
  901. if (i == (ssize_t) (argc-1))
  902. ThrowConvertException(OptionError,"MissingArgument",option);
  903. if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
  904. ThrowConvertInvalidArgumentException(option,argv[i]);
  905. clone_images=CloneImages(clone_images,argv[i],exception);
  906. }
  907. if (clone_images == (Image *) NULL)
  908. ThrowConvertException(OptionError,"NoSuchImage",option);
  909. AppendImageStack(clone_images);
  910. break;
  911. }
  912. if (LocaleCompare("clut",option+1) == 0)
  913. break;
  914. if (LocaleCompare("coalesce",option+1) == 0)
  915. break;
  916. if (LocaleCompare("colorize",option+1) == 0)
  917. {
  918. if (*option == '+')
  919. break;
  920. i++;
  921. if (i == (ssize_t) (argc-1))
  922. ThrowConvertException(OptionError,"MissingArgument",option);
  923. if (IsGeometry(argv[i]) == MagickFalse)
  924. ThrowConvertInvalidArgumentException(option,argv[i]);
  925. break;
  926. }
  927. if (LocaleCompare("color-matrix",option+1) == 0)
  928. {
  929. KernelInfo
  930. *kernel_info;
  931. if (*option == '+')
  932. break;
  933. i++;
  934. if (i == (ssize_t) (argc-1))
  935. ThrowConvertException(OptionError,"MissingArgument",option);
  936. kernel_info=AcquireKernelInfo(argv[i]);
  937. if (kernel_info == (KernelInfo *) NULL)
  938. ThrowConvertInvalidArgumentException(option,argv[i]);
  939. kernel_info=DestroyKernelInfo(kernel_info);
  940. break;
  941. }
  942. if (LocaleCompare("colors",option+1) == 0)
  943. {
  944. if (*option == '+')
  945. break;
  946. i++;
  947. if ((i == (ssize_t) (argc-1)) ||
  948. (IsGeometry(argv[i]) == MagickFalse))
  949. ThrowConvertException(OptionError,"MissingArgument",option);
  950. break;
  951. }
  952. if (LocaleCompare("colorspace",option+1) == 0)
  953. {
  954. ssize_t
  955. colorspace;
  956. if (*option == '+')
  957. break;
  958. i++;
  959. if (i == (ssize_t) (argc-1))
  960. ThrowConvertException(OptionError,"MissingArgument",option);
  961. colorspace=ParseMagickOption(MagickColorspaceOptions,
  962. MagickFalse,argv[i]);
  963. if (colorspace < 0)
  964. ThrowConvertException(OptionError,"UnrecognizedColorspace",
  965. argv[i]);
  966. break;
  967. }
  968. if (LocaleCompare("combine",option+1) == 0)
  969. break;
  970. if (LocaleCompare("comment",option+1) == 0)
  971. {
  972. if (*option == '+')
  973. break;
  974. i++;
  975. if (i == (ssize_t) argc)
  976. ThrowConvertException(OptionError,"MissingArgument",option);
  977. break;
  978. }
  979. if (LocaleCompare("compose",option+1) == 0)
  980. {
  981. ssize_t
  982. compose;
  983. if (*option == '+')
  984. break;
  985. i++;
  986. if (i == (ssize_t) argc)
  987. ThrowConvertException(OptionError,"MissingArgument",option);
  988. compose=ParseMagickOption(MagickComposeOptions,MagickFalse,
  989. argv[i]);
  990. if (compose < 0)
  991. ThrowConvertException(OptionError,"UnrecognizedComposeOperator",
  992. argv[i]);
  993. break;
  994. }
  995. if (LocaleCompare("composite",option+1) == 0)
  996. break;
  997. if (LocaleCompare("compress",option+1) == 0)
  998. {
  999. ssize_t
  1000. compress;
  1001. if (*option == '+')
  1002. break;
  1003. i++;
  1004. if (i == (ssize_t) (argc-1))
  1005. ThrowConvertException(OptionError,"MissingArgument",option);
  1006. compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
  1007. argv[i]);
  1008. if (compress < 0)
  1009. ThrowConvertException(OptionError,"UnrecognizedImageCompression",
  1010. argv[i]);
  1011. break;
  1012. }
  1013. if (LocaleCompare("concurrent",option+1) == 0)
  1014. break;
  1015. if (LocaleCompare("contrast",option+1) == 0)
  1016. break;
  1017. if (LocaleCompare("contrast-stretch",option+1) == 0)
  1018. {
  1019. i++;
  1020. if (i == (ssize_t) (argc-1))
  1021. ThrowConvertException(OptionError,"MissingArgument",option);
  1022. if (IsGeometry(argv[i]) == MagickFalse)
  1023. ThrowConvertInvalidArgumentException(option,argv[i]);
  1024. break;
  1025. }
  1026. if (LocaleCompare("convolve",option+1) == 0)
  1027. {
  1028. KernelInfo
  1029. *kernel_info;
  1030. if (*option == '+')
  1031. break;
  1032. i++;
  1033. if (i == (ssize_t) (argc-1))
  1034. ThrowConvertException(OptionError,"MissingArgument",option);
  1035. kernel_info=AcquireKernelInfo(argv[i]);
  1036. if (kernel_info == (KernelInfo *) NULL)
  1037. ThrowConvertInvalidArgumentException(option,argv[i]);
  1038. kernel_info=DestroyKernelInfo(kernel_info);
  1039. break;
  1040. }
  1041. if (LocaleCompare("crop",option+1) == 0)
  1042. {
  1043. if (*option == '+')
  1044. break;
  1045. i++;
  1046. if (i == (ssize_t) (argc-1))
  1047. ThrowConvertException(OptionError,"MissingArgument",option);
  1048. if (IsGeometry(argv[i]) == MagickFalse)
  1049. ThrowConvertInvalidArgumentException(option,argv[i]);
  1050. break;
  1051. }
  1052. if (LocaleCompare("cycle",option+1) == 0)
  1053. {
  1054. if (*option == '+')
  1055. break;
  1056. i++;
  1057. if (i == (ssize_t) (argc-1))
  1058. ThrowConvertException(OptionError,"MissingArgument",option);
  1059. if (IsGeometry(argv[i]) == MagickFalse)
  1060. ThrowConvertInvalidArgumentException(option,argv[i]);
  1061. break;
  1062. }
  1063. ThrowConvertException(OptionError,"UnrecognizedOption",option)
  1064. }
  1065. case 'd':
  1066. {
  1067. if (LocaleCompare("decipher",option+1) == 0)
  1068. {
  1069. if (*option == '+')
  1070. break;
  1071. i++;
  1072. if (i == (ssize_t) (argc-1))
  1073. ThrowConvertException(OptionError,"MissingArgument",option);
  1074. break;
  1075. }
  1076. if (LocaleCompare("deconstruct",option+1) == 0)
  1077. break;
  1078. if (LocaleCompare("debug",option+1) == 0)
  1079. {
  1080. ssize_t
  1081. event;
  1082. if (*option == '+')
  1083. break;
  1084. i++;
  1085. if (i == (ssize_t) argc)
  1086. ThrowConvertException(OptionError,"MissingArgument",option);
  1087. event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
  1088. if (event < 0)
  1089. ThrowConvertException(OptionError,"UnrecognizedEventType",
  1090. argv[i]);
  1091. (void) SetLogEventMask(argv[i]);
  1092. break;
  1093. }
  1094. if (LocaleCompare("define",option+1) == 0)
  1095. {
  1096. i++;
  1097. if (i == (ssize_t) argc)
  1098. ThrowConvertException(OptionError,"MissingArgument",option);
  1099. if (*option == '+')
  1100. {
  1101. const char
  1102. *define;
  1103. define=GetImageOption(image_info,argv[i]);
  1104. if (define == (const char *) NULL)
  1105. ThrowConvertException(OptionError,"NoSuchOption",argv[i]);
  1106. break;
  1107. }
  1108. break;
  1109. }
  1110. if (LocaleCompare("delay",option+1) == 0)
  1111. {
  1112. if (*option == '+')
  1113. break;
  1114. i++;
  1115. if (i == (ssize_t) argc)
  1116. ThrowConvertException(OptionError,"MissingArgument",option);
  1117. if (IsGeometry(argv[i]) == MagickFalse)
  1118. ThrowConvertInvalidArgumentException(option,argv[i]);
  1119. break;
  1120. }
  1121. if (LocaleCompare("density",option+1) == 0)
  1122. {
  1123. if (*option == '+')
  1124. break;
  1125. i++;
  1126. if (i == (ssize_t) (argc-1))
  1127. ThrowConvertException(OptionError,"MissingArgument",option);
  1128. if (IsGeometry(argv[i]) == MagickFalse)
  1129. ThrowConvertInvalidArgumentException(option,argv[i]);
  1130. break;
  1131. }
  1132. if (LocaleCompare("depth",option+1) == 0)
  1133. {
  1134. if (*option == '+')
  1135. break;
  1136. i++;
  1137. if (i == (ssize_t) (argc-1))
  1138. ThrowConvertException(OptionError,"MissingArgument",option);
  1139. if (IsGeometry(argv[i]) == MagickFalse)
  1140. ThrowConvertInvalidArgumentException(option,argv[i]);
  1141. break;
  1142. }
  1143. if (LocaleCompare("delete",option+1) == 0)
  1144. {
  1145. if (*option == '+')
  1146. break;
  1147. i++;
  1148. if (i == (ssize_t) (argc-1))
  1149. ThrowConvertException(OptionError,"MissingArgument",option);
  1150. if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
  1151. ThrowConvertInvalidArgumentException(option,argv[i]);
  1152. break;
  1153. }
  1154. if (LocaleCompare("deskew",option+1) == 0)
  1155. {
  1156. if (*option == '+')
  1157. break;
  1158. i++;
  1159. if (i == (ssize_t) (argc-1))
  1160. ThrowConvertException(OptionError,"MissingArgument",option);
  1161. if (IsGeometry(argv[i]) == MagickFalse)
  1162. ThrowConvertInvalidArgumentException(option,argv[i]);
  1163. break;
  1164. }
  1165. if (LocaleCompare("despeckle",option+1) == 0)
  1166. break;
  1167. if (LocaleCompare("direction",option+1) == 0)
  1168. {
  1169. ssize_t
  1170. direction;
  1171. if (*option == '+')
  1172. break;
  1173. i++;
  1174. if (i == (ssize_t) argc)
  1175. ThrowConvertException(OptionError,"MissingArgument",option);
  1176. direction=ParseMagickOption(MagickDirectionOptions,MagickFalse,
  1177. argv[i]);
  1178. if (direction < 0)
  1179. ThrowConvertException(OptionError,"UnrecognizedDirectionType",
  1180. argv[i]);
  1181. break;
  1182. }
  1183. if (LocaleCompare("display",option+1) == 0)
  1184. {
  1185. if (*option == '+')
  1186. break;
  1187. i++;
  1188. if (i == (ssize_t) (argc-1))
  1189. ThrowConvertException(OptionError,"MissingArgument",option);
  1190. break;
  1191. }
  1192. if (LocaleCompare("dispose",option+1) == 0)
  1193. {
  1194. ssize_t
  1195. dispose;
  1196. if (*option == '+')
  1197. break;
  1198. i++;
  1199. if (i == (ssize_t) argc)
  1200. ThrowConvertException(OptionError,"MissingArgument",option);
  1201. dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
  1202. if (dispose < 0)
  1203. ThrowConvertException(OptionError,"UnrecognizedDisposeMethod",
  1204. argv[i]);
  1205. break;
  1206. }
  1207. if (LocaleCompare("distort",option+1) == 0)
  1208. {
  1209. ssize_t
  1210. op;
  1211. i++;
  1212. if (i == (ssize_t) argc)
  1213. ThrowConvertException(OptionError,"MissingArgument",option);
  1214. op=ParseMagickOption(MagickDistortOptions,MagickFalse,argv[i]);
  1215. if (op < 0)

Large files files are truncated, but you can click here to view the full file