PageRenderTime 58ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/scripts/ImageMagick-6.6.2-6/wand/convert.c

https://bitbucket.org/JasonGross/alphabets
C | 2989 lines | 2833 code | 59 blank | 97 comment | 1509 complexity | afb6c8f3728e27fe77ddd5d581a6669a MD5 | raw file
Possible License(s): BSD-3-Clause-No-Nuclear-License-2014, Apache-2.0, MPL-2.0-no-copyleft-exception

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-2010 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. "-modulate value vary the brightness, saturation, and hue",
  214. "-monochrome transform image to black and white",
  215. "-morphology method kernel",
  216. " apply a morphology method to the image",
  217. "-motion-blur geometry",
  218. " simulate motion blur",
  219. "-negate replace every pixel with its complementary color ",
  220. "-noise radius add or reduce noise in an image",
  221. "-normalize transform image to span the full range of colors",
  222. "-opaque color change this color to the fill color",
  223. "-ordered-dither NxN",
  224. " add a noise pattern to the image with specific",
  225. " amplitudes",
  226. "-paint radius simulate an oil painting",
  227. "-polaroid angle simulate a Polaroid picture",
  228. "-posterize levels reduce the image to a limited number of color levels",
  229. "-profile filename add, delete, or apply an image profile",
  230. "-quantize colorspace reduce colors in this colorspace",
  231. "-radial-blur angle radial blur the image",
  232. "-raise value lighten/darken image edges to create a 3-D effect",
  233. "-random-threshold low,high",
  234. " random threshold the image",
  235. "-region geometry apply options to a portion of the image",
  236. "-render render vector graphics",
  237. "-repage geometry size and location of an image canvas",
  238. "-resample geometry change the resolution of an image",
  239. "-resize geometry resize the image",
  240. "-roll geometry roll an image vertically or horizontally",
  241. "-rotate degrees apply Paeth rotation to the image",
  242. "-sample geometry scale image with pixel sampling",
  243. "-scale geometry scale the image",
  244. "-segment values segment an image",
  245. "-selective-blur geometry",
  246. " selectively blur pixels within a contrast threshold",
  247. "-sepia-tone threshold",
  248. " simulate a sepia-toned photo",
  249. "-set property value set an image property",
  250. "-shade degrees shade the image using a distant light source",
  251. "-shadow geometry simulate an image shadow",
  252. "-sharpen geometry sharpen the image",
  253. "-shave geometry shave pixels from the image edges",
  254. "-shear geometry slide one edge of the image along the X or Y axis",
  255. "-sigmoidal-contrast geometry",
  256. " increase the contrast without saturating highlights or shadows",
  257. "-sketch geometry simulate a pencil sketch",
  258. "-solarize threshold negate all pixels above the threshold level",
  259. "-sparse-color method args",
  260. " fill in a image based on a few color points",
  261. "-splice geometry splice the background color into the image",
  262. "-spread radius displace image pixels by a random amount",
  263. "-strip strip image of all profiles and comments",
  264. "-swirl degrees swirl image pixels about the center",
  265. "-threshold value threshold the image",
  266. "-thumbnail geometry create a thumbnail of the image",
  267. "-tile filename tile image when filling a graphic primitive",
  268. "-tint value tint the image with the fill color",
  269. "-transform affine transform image",
  270. "-transparent color make this color transparent within the image",
  271. "-transpose flip image vertically and rotate 90 degrees",
  272. "-transverse flop image horizontally and rotate 270 degrees",
  273. "-trim trim image edges",
  274. "-type type image type",
  275. "-unique-colors discard all but one of any pixel color",
  276. "-unsharp geometry sharpen the image",
  277. "-vignette geometry soften the edges of the image in vignette style",
  278. "-wave geometry alter an image along a sine wave",
  279. "-white-threshold value",
  280. " force all pixels above the threshold into white",
  281. (char *) NULL
  282. },
  283. *sequence_operators[]=
  284. {
  285. "-append append an image sequence",
  286. "-clut apply a color lookup table to the image",
  287. "-coalesce merge a sequence of images",
  288. "-combine combine a sequence of images",
  289. "-composite composite image",
  290. "-crop geometry cut out a rectangular region of the image",
  291. "-deconstruct break down an image sequence into constituent parts",
  292. "-evaluate-sequence operator",
  293. " evaluate an arithmetic, relational, or logical expression",
  294. "-flatten flatten a sequence of images",
  295. "-fx expression apply mathematical expression to an image channel(s)",
  296. "-hald-clut apply a Hald color lookup table to the image",
  297. "-morph value morph an image sequence",
  298. "-mosaic create a mosaic from an image sequence",
  299. "-print string interpret string and print to console",
  300. "-process arguments process the image with a custom image filter",
  301. "-reverse reverse image sequence",
  302. "-separate separate an image channel into a grayscale image",
  303. "-write filename write images to this file",
  304. (char *) NULL
  305. },
  306. *settings[]=
  307. {
  308. "-adjoin join images into a single multi-image file",
  309. "-affine matrix affine transform matrix",
  310. "-alpha option activate, deactivate, reset, or set the alpha channel",
  311. "-antialias remove pixel-aliasing",
  312. "-authenticate password",
  313. " decipher image with this password",
  314. "-attenuate value lessen (or intensify) when adding noise to an image",
  315. "-background color background color",
  316. "-bias value add bias when convolving an image",
  317. "-black-point-compensation",
  318. " use black point compensation",
  319. "-blue-primary point chromaticity blue primary point",
  320. "-bordercolor color border color",
  321. "-caption string assign a caption to an image",
  322. "-channel type apply option to select image channels",
  323. "-colors value preferred number of colors in the image",
  324. "-colorspace type alternate image colorspace",
  325. "-comment string annotate image with comment",
  326. "-compose operator set image composite operator",
  327. "-compress type type of pixel compression when writing the image",
  328. "-define format:option",
  329. " define one or more image format options",
  330. "-delay value display the next image after pausing",
  331. "-density geometry horizontal and vertical density of the image",
  332. "-depth value image depth",
  333. "-direction type render text right-to-left or left-to-right",
  334. "-display server get image or font from this X server",
  335. "-dispose method layer disposal method",
  336. "-dither method apply error diffusion to image",
  337. "-encoding type text encoding type",
  338. "-endian type endianness (MSB or LSB) of the image",
  339. "-family name render text with this font family",
  340. "-fill color color to use when filling a graphic primitive",
  341. "-filter type use this filter when resizing an image",
  342. "-font name render text with this font",
  343. "-format \"string\" output formatted image characteristics",
  344. "-fuzz distance colors within this distance are considered equal",
  345. "-gravity type horizontal and vertical text placement",
  346. "-green-primary point chromaticity green primary point",
  347. "-intent type type of rendering intent when managing the image color",
  348. "-interlace type type of image interlacing scheme",
  349. "-interline-spacing value",
  350. " set the space between two text lines",
  351. "-interpolate method pixel color interpolation method",
  352. "-interword-spacing value",
  353. " set the space between two words",
  354. "-kerning value set the space between two letters",
  355. "-label string assign a label to an image",
  356. "-limit type value pixel cache resource limit",
  357. "-loop iterations add Netscape loop extension to your GIF animation",
  358. "-mask filename associate a mask with the image",
  359. "-mattecolor color frame color",
  360. "-monitor monitor progress",
  361. "-orient type image orientation",
  362. "-page geometry size and location of an image canvas (setting)",
  363. "-ping efficiently determine image attributes",
  364. "-pointsize value font point size",
  365. "-precision value maximum number of significant digits to print",
  366. "-preview type image preview type",
  367. "-quality value JPEG/MIFF/PNG compression level",
  368. "-quiet suppress all warning messages",
  369. "-red-primary point chromaticity red primary point",
  370. "-regard-warnings pay attention to warning messages",
  371. "-remap filename transform image colors to match this set of colors",
  372. "-respect-parentheses settings remain in effect until parenthesis boundary",
  373. "-sampling-factor geometry",
  374. " horizontal and vertical sampling factor",
  375. "-scene value image scene number",
  376. "-seed value seed a new sequence of pseudo-random numbers",
  377. "-size geometry width and height of image",
  378. "-stretch type render text with this font stretch",
  379. "-stroke color graphic primitive stroke color",
  380. "-strokewidth value graphic primitive stroke width",
  381. "-style type render text with this font style",
  382. "-taint image as ineligible for bi-modal delegate",
  383. "-texture filename name of texture to tile onto the image background",
  384. "-tile-offset geometry",
  385. " tile offset",
  386. "-treedepth value color tree depth",
  387. "-transparent-color color",
  388. " transparent color",
  389. "-undercolor color annotation bounding box color",
  390. "-units type the units of image resolution",
  391. "-verbose print detailed information about the image",
  392. "-view FlashPix viewing transforms",
  393. "-virtual-pixel method",
  394. " virtual pixel access method",
  395. "-weight type render text with this font weight",
  396. "-white-point point chromaticity white point",
  397. (char *) NULL
  398. },
  399. *stack_operators[]=
  400. {
  401. "-clone index clone an image",
  402. "-delete index delete the image from the image sequence",
  403. "-insert index insert last image into the image sequence",
  404. "-swap indexes swap two images in the image sequence",
  405. (char *) NULL
  406. };
  407. const char
  408. **p;
  409. (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
  410. (void) printf("Copyright: %s\n",GetMagickCopyright());
  411. (void) printf("Features: %s\n\n",GetMagickFeatures());
  412. (void) printf("Usage: %s [options ...] file [ [options ...] "
  413. "file ...] [options ...] file\n",GetClientName());
  414. (void) printf("\nImage Settings:\n");
  415. for (p=settings; *p != (char *) NULL; p++)
  416. (void) printf(" %s\n",*p);
  417. (void) printf("\nImage Operators:\n");
  418. for (p=operators; *p != (char *) NULL; p++)
  419. (void) printf(" %s\n",*p);
  420. (void) printf("\nImage Sequence Operators:\n");
  421. for (p=sequence_operators; *p != (char *) NULL; p++)
  422. (void) printf(" %s\n",*p);
  423. (void) printf("\nImage Stack Operators:\n");
  424. for (p=stack_operators; *p != (char *) NULL; p++)
  425. (void) printf(" %s\n",*p);
  426. (void) printf("\nMiscellaneous Options:\n");
  427. for (p=miscellaneous; *p != (char *) NULL; p++)
  428. (void) printf(" %s\n",*p);
  429. (void) printf(
  430. "\nBy default, the image format of `file' is determined by its magic\n");
  431. (void) printf(
  432. "number. To specify a particular image format, precede the filename\n");
  433. (void) printf(
  434. "with an image format name and a colon (i.e. ps:image) or specify the\n");
  435. (void) printf(
  436. "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
  437. (void) printf("'-' for standard input or output.\n");
  438. return(MagickFalse);
  439. }
  440. WandExport MagickBooleanType ConvertImageCommand(ImageInfo *image_info,
  441. int argc,char **argv,char **metadata,ExceptionInfo *exception)
  442. {
  443. #define NotInitialized (unsigned int) (~0)
  444. #define DestroyConvert() \
  445. { \
  446. DestroyImageStack(); \
  447. for (i=0; i < (ssize_t) argc; i++) \
  448. argv[i]=DestroyString(argv[i]); \
  449. argv=(char **) RelinquishMagickMemory(argv); \
  450. }
  451. #define ThrowConvertException(asperity,tag,option) \
  452. { \
  453. (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
  454. option); \
  455. DestroyConvert(); \
  456. return(MagickFalse); \
  457. }
  458. #define ThrowConvertInvalidArgumentException(option,argument) \
  459. { \
  460. (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
  461. "InvalidArgument","`%s': %s",option,argument); \
  462. DestroyConvert(); \
  463. return(MagickFalse); \
  464. }
  465. char
  466. *filename,
  467. *option;
  468. const char
  469. *format;
  470. Image
  471. *image;
  472. ImageStack
  473. image_stack[MaxImageStackDepth+1];
  474. ssize_t
  475. j,
  476. k;
  477. MagickBooleanType
  478. fire,
  479. pend;
  480. MagickStatusType
  481. status;
  482. register ssize_t
  483. i;
  484. /*
  485. Set defaults.
  486. */
  487. assert(image_info != (ImageInfo *) NULL);
  488. assert(image_info->signature == MagickSignature);
  489. if (image_info->debug != MagickFalse)
  490. (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
  491. assert(exception != (ExceptionInfo *) NULL);
  492. if (argc == 2)
  493. {
  494. option=argv[1];
  495. if ((LocaleCompare("version",option+1) == 0) ||
  496. (LocaleCompare("-version",option+1) == 0))
  497. {
  498. (void) fprintf(stdout,"Version: %s\n",
  499. GetMagickVersion((size_t *) NULL));
  500. (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
  501. (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
  502. return(MagickFalse);
  503. }
  504. }
  505. if (argc < 3)
  506. return(ConvertUsage());
  507. filename=(char *) NULL;
  508. format="%w,%h,%m";
  509. j=1;
  510. k=0;
  511. NewImageStack();
  512. option=(char *) NULL;
  513. pend=MagickFalse;
  514. status=MagickTrue;
  515. /*
  516. Parse command-line arguments.
  517. */
  518. ReadCommandlLine(argc,&argv);
  519. status=ExpandFilenames(&argc,&argv);
  520. if (status == MagickFalse)
  521. ThrowConvertException(ResourceLimitError,"MemoryAllocationFailed",
  522. GetExceptionMessage(errno));
  523. if ((argc > 2) && (LocaleCompare("-concatenate",argv[1]) == 0))
  524. return(ConcatenateImages(argc,argv,exception));
  525. for (i=1; i < (ssize_t) (argc-1); i++)
  526. {
  527. option=argv[i];
  528. if (LocaleCompare(option,"(") == 0)
  529. {
  530. FireImageStack(MagickTrue,MagickTrue,pend);
  531. if (k == MaxImageStackDepth)
  532. ThrowConvertException(OptionError,"ParenthesisNestedTooDeeply",
  533. option);
  534. PushImageStack();
  535. continue;
  536. }
  537. if (LocaleCompare(option,")") == 0)
  538. {
  539. FireImageStack(MagickTrue,MagickTrue,MagickTrue);
  540. if (k == 0)
  541. ThrowConvertException(OptionError,"UnableToParseExpression",option);
  542. PopImageStack();
  543. continue;
  544. }
  545. if (IsMagickOption(option) == MagickFalse)
  546. {
  547. Image
  548. *images;
  549. /*
  550. Read input image.
  551. */
  552. FireImageStack(MagickTrue,MagickTrue,pend);
  553. filename=argv[i];
  554. if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
  555. filename=argv[++i];
  556. (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
  557. if (image_info->ping != MagickFalse)
  558. images=PingImages(image_info,exception);
  559. else
  560. images=ReadImages(image_info,exception);
  561. status&=(images != (Image *) NULL) &&
  562. (exception->severity < ErrorException);
  563. if (images == (Image *) NULL)
  564. continue;
  565. AppendImageStack(images);
  566. continue;
  567. }
  568. pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
  569. switch (*(option+1))
  570. {
  571. case 'a':
  572. {
  573. if (LocaleCompare("adaptive-blur",option+1) == 0)
  574. {
  575. i++;
  576. if (i == (ssize_t) (argc-1))
  577. ThrowConvertException(OptionError,"MissingArgument",option);
  578. if (IsGeometry(argv[i]) == MagickFalse)
  579. ThrowConvertInvalidArgumentException(option,argv[i]);
  580. break;
  581. }
  582. if (LocaleCompare("adaptive-resize",option+1) == 0)
  583. {
  584. i++;
  585. if (i == (ssize_t) (argc-1))
  586. ThrowConvertException(OptionError,"MissingArgument",option);
  587. if (IsGeometry(argv[i]) == MagickFalse)
  588. ThrowConvertInvalidArgumentException(option,argv[i]);
  589. break;
  590. }
  591. if (LocaleCompare("adaptive-sharpen",option+1) == 0)
  592. {
  593. i++;
  594. if (i == (ssize_t) (argc-1))
  595. ThrowConvertException(OptionError,"MissingArgument",option);
  596. if (IsGeometry(argv[i]) == MagickFalse)
  597. ThrowConvertInvalidArgumentException(option,argv[i]);
  598. break;
  599. }
  600. if (LocaleCompare("adjoin",option+1) == 0)
  601. break;
  602. if (LocaleCompare("affine",option+1) == 0)
  603. {
  604. if (*option == '+')
  605. break;
  606. i++;
  607. if (i == (ssize_t) (argc-1))
  608. ThrowConvertException(OptionError,"MissingArgument",option);
  609. if (IsGeometry(argv[i]) == MagickFalse)
  610. ThrowConvertInvalidArgumentException(option,argv[i]);
  611. break;
  612. }
  613. if (LocaleCompare("alpha",option+1) == 0)
  614. {
  615. ssize_t
  616. type;
  617. if (*option == '+')
  618. break;
  619. i++;
  620. if (i == (ssize_t) argc)
  621. ThrowConvertException(OptionError,"MissingArgument",option);
  622. type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
  623. if (type < 0)
  624. ThrowConvertException(OptionError,"UnrecognizedAlphaChannelType",
  625. argv[i]);
  626. break;
  627. }
  628. if (LocaleCompare("annotate",option+1) == 0)
  629. {
  630. if (*option == '+')
  631. break;
  632. i++;
  633. if (i == (ssize_t) (argc-1))
  634. ThrowConvertException(OptionError,"MissingArgument",option);
  635. if (IsGeometry(argv[i]) == MagickFalse)
  636. ThrowConvertInvalidArgumentException(option,argv[i]);
  637. i++;
  638. if (i == (ssize_t) (argc-1))
  639. ThrowConvertException(OptionError,"MissingArgument",option);
  640. break;
  641. }
  642. if (LocaleCompare("antialias",option+1) == 0)
  643. break;
  644. if (LocaleCompare("append",option+1) == 0)
  645. break;
  646. if (LocaleCompare("attenuate",option+1) == 0)
  647. {
  648. if (*option == '+')
  649. break;
  650. i++;
  651. if (i == (ssize_t) (argc-1))
  652. ThrowConvertException(OptionError,"MissingArgument",option);
  653. if (IsGeometry(argv[i]) == MagickFalse)
  654. ThrowConvertInvalidArgumentException(option,argv[i]);
  655. break;
  656. }
  657. if (LocaleCompare("authenticate",option+1) == 0)
  658. {
  659. if (*option == '+')
  660. break;
  661. i++;
  662. if (i == (ssize_t) (argc-1))
  663. ThrowConvertException(OptionError,"MissingArgument",option);
  664. break;
  665. }
  666. if (LocaleCompare("auto-gamma",option+1) == 0)
  667. break;
  668. if (LocaleCompare("auto-level",option+1) == 0)
  669. break;
  670. if (LocaleCompare("auto-orient",option+1) == 0)
  671. break;
  672. if (LocaleCompare("average",option+1) == 0)
  673. break;
  674. ThrowConvertException(OptionError,"UnrecognizedOption",option)
  675. }
  676. case 'b':
  677. {
  678. if (LocaleCompare("background",option+1) == 0)
  679. {
  680. if (*option == '+')
  681. break;
  682. i++;
  683. if (i == (ssize_t) (argc-1))
  684. ThrowConvertException(OptionError,"MissingArgument",option);
  685. break;
  686. }
  687. if (LocaleCompare("bench",option+1) == 0)
  688. {
  689. if (*option == '+')
  690. break;
  691. i++;
  692. if (i == (ssize_t) (argc-1))
  693. ThrowConvertException(OptionError,"MissingArgument",option);
  694. if (IsGeometry(argv[i]) == MagickFalse)
  695. ThrowConvertInvalidArgumentException(option,argv[i]);
  696. break;
  697. }
  698. if (LocaleCompare("bias",option+1) == 0)
  699. {
  700. if (*option == '+')
  701. break;
  702. i++;
  703. if (i == (ssize_t) (argc-1))
  704. ThrowConvertException(OptionError,"MissingArgument",option);
  705. if (IsGeometry(argv[i]) == MagickFalse)
  706. ThrowConvertInvalidArgumentException(option,argv[i]);
  707. break;
  708. }
  709. if (LocaleCompare("black-point-compensation",option+1) == 0)
  710. break;
  711. if (LocaleCompare("black-threshold",option+1) == 0)
  712. {
  713. if (*option == '+')
  714. break;
  715. i++;
  716. if (i == (ssize_t) (argc-1))
  717. ThrowConvertException(OptionError,"MissingArgument",option);
  718. if (IsGeometry(argv[i]) == MagickFalse)
  719. ThrowConvertInvalidArgumentException(option,argv[i]);
  720. break;
  721. }
  722. if (LocaleCompare("blue-primary",option+1) == 0)
  723. {
  724. if (*option == '+')
  725. break;
  726. i++;
  727. if (i == (ssize_t) (argc-1))
  728. ThrowConvertException(OptionError,"MissingArgument",option);
  729. if (IsGeometry(argv[i]) == MagickFalse)
  730. ThrowConvertInvalidArgumentException(option,argv[i]);
  731. break;
  732. }
  733. if (LocaleCompare("blue-shift",option+1) == 0)
  734. {
  735. if (*option == '+')
  736. break;
  737. i++;
  738. if (i == (ssize_t) (argc-1))
  739. ThrowConvertException(OptionError,"MissingArgument",option);
  740. if (IsGeometry(argv[i]) == MagickFalse)
  741. ThrowConvertInvalidArgumentException(option,argv[i]);
  742. break;
  743. }
  744. if (LocaleCompare("blur",option+1) == 0)
  745. {
  746. if (*option == '+')
  747. break;
  748. i++;
  749. if (i == (ssize_t) (argc-1))
  750. ThrowConvertException(OptionError,"MissingArgument",option);
  751. if (IsGeometry(argv[i]) == MagickFalse)
  752. ThrowConvertInvalidArgumentException(option,argv[i]);
  753. break;
  754. }
  755. if (LocaleCompare("border",option+1) == 0)
  756. {
  757. if (*option == '+')
  758. break;
  759. i++;
  760. if (i == (ssize_t) (argc-1))
  761. ThrowConvertException(OptionError,"MissingArgument",option);
  762. if (IsGeometry(argv[i]) == MagickFalse)
  763. ThrowConvertInvalidArgumentException(option,argv[i]);
  764. break;
  765. }
  766. if (LocaleCompare("bordercolor",option+1) == 0)
  767. {
  768. if (*option == '+')
  769. break;
  770. i++;
  771. if (i == (ssize_t) (argc-1))
  772. ThrowConvertException(OptionError,"MissingArgument",option);
  773. break;
  774. }
  775. if (LocaleCompare("box",option+1) == 0)
  776. {
  777. if (*option == '+')
  778. break;
  779. i++;
  780. if (i == (ssize_t) (argc-1))
  781. ThrowConvertException(OptionError,"MissingArgument",option);
  782. break;
  783. }
  784. if (LocaleCompare("brightness-contrast",option+1) == 0)
  785. {
  786. i++;
  787. if (i == (ssize_t) (argc-1))
  788. ThrowConvertException(OptionError,"MissingArgument",option);
  789. if (IsGeometry(argv[i]) == MagickFalse)
  790. ThrowConvertInvalidArgumentException(option,argv[i]);
  791. break;
  792. }
  793. ThrowConvertException(OptionError,"UnrecognizedOption",option)
  794. }
  795. case 'c':
  796. {
  797. if (LocaleCompare("cache",option+1) == 0)
  798. {
  799. if (*option == '+')
  800. break;
  801. i++;
  802. if (i == (ssize_t) (argc-1))
  803. ThrowConvertException(OptionError,"MissingArgument",option);
  804. if (IsGeometry(argv[i]) == MagickFalse)
  805. ThrowConvertInvalidArgumentException(option,argv[i]);
  806. break;
  807. }
  808. if (LocaleCompare("caption",option+1) == 0)
  809. {
  810. if (*option == '+')
  811. break;
  812. i++;
  813. if (i == (ssize_t) argc)
  814. ThrowConvertException(OptionError,"MissingArgument",option);
  815. break;
  816. }
  817. if (LocaleCompare("cdl",option+1) == 0)
  818. {
  819. if (*option == '+')
  820. break;
  821. i++;
  822. if (i == (ssize_t) (argc-1))
  823. ThrowConvertException(OptionError,"MissingArgument",option);
  824. break;
  825. }
  826. if (LocaleCompare("channel",option+1) == 0)
  827. {
  828. ssize_t
  829. channel;
  830. if (*option == '+')
  831. break;
  832. i++;
  833. if (i == (ssize_t) (argc-1))
  834. ThrowConvertException(OptionError,"MissingArgument",option);
  835. channel=ParseChannelOption(argv[i]);
  836. if (channel < 0)
  837. ThrowConvertException(OptionError,"UnrecognizedChannelType",
  838. argv[i]);
  839. break;
  840. }
  841. if (LocaleCompare("charcoal",option+1) == 0)
  842. {
  843. if (*option == '+')
  844. break;
  845. i++;
  846. if (i == (ssize_t) (argc-1))
  847. ThrowConvertException(OptionError,"MissingArgument",option);
  848. if (IsGeometry(argv[i]) == MagickFalse)
  849. ThrowConvertInvalidArgumentException(option,argv[i]);
  850. break;
  851. }
  852. if (LocaleCompare("chop",option+1) == 0)
  853. {
  854. if (*option == '+')
  855. break;
  856. i++;
  857. if (i == (ssize_t) (argc-1))
  858. ThrowConvertException(OptionError,"MissingArgument",option);
  859. if (IsGeometry(argv[i]) == MagickFalse)
  860. ThrowConvertInvalidArgumentException(option,argv[i]);
  861. break;
  862. }
  863. if (LocaleCompare("clamp",option+1) == 0)
  864. break;
  865. if (LocaleCompare("clip",option+1) == 0)
  866. break;
  867. if (LocaleCompare("clip-mask",option+1) == 0)
  868. {
  869. if (*option == '+')
  870. break;
  871. i++;
  872. if (i == (ssize_t) (argc-1))
  873. ThrowConvertException(OptionError,"MissingArgument",option);
  874. break;
  875. }
  876. if (LocaleCompare("clip-path",option+1) == 0)
  877. {
  878. i++;
  879. if (i == (ssize_t) (argc-1))
  880. ThrowConvertException(OptionError,"MissingArgument",option);
  881. break;
  882. }
  883. if (LocaleCompare("clone",option+1) == 0)
  884. {
  885. Image
  886. *clone_images;
  887. clone_images=image;
  888. if (k != 0)
  889. clone_images=image_stack[k-1].image;
  890. if (clone_images == (Image *) NULL)
  891. ThrowConvertException(ImageError,"ImageSequenceRequired",option);
  892. FireImageStack(MagickTrue,MagickTrue,MagickTrue);
  893. if (*option == '+')
  894. clone_images=CloneImages(clone_images,"-1",exception);
  895. else
  896. {
  897. i++;
  898. if (i == (ssize_t) (argc-1))
  899. ThrowConvertException(OptionError,"MissingArgument",option);
  900. if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
  901. ThrowConvertInvalidArgumentException(option,argv[i]);
  902. clone_images=CloneImages(clone_images,argv[i],exception);
  903. }
  904. if (clone_images == (Image *) NULL)
  905. ThrowConvertException(OptionError,"NoSuchImage",option);
  906. AppendImageStack(clone_images);
  907. break;
  908. }
  909. if (LocaleCompare("clut",option+1) == 0)
  910. break;
  911. if (LocaleCompare("coalesce",option+1) == 0)
  912. break;
  913. if (LocaleCompare("colorize",option+1) == 0)
  914. {
  915. if (*option == '+')
  916. break;
  917. i++;
  918. if (i == (ssize_t) (argc-1))
  919. ThrowConvertException(OptionError,"MissingArgument",option);
  920. if (IsGeometry(argv[i]) == MagickFalse)
  921. ThrowConvertInvalidArgumentException(option,argv[i]);
  922. break;
  923. }
  924. if (LocaleCompare("color-matrix",option+1) == 0)
  925. {
  926. if (*option == '+')
  927. break;
  928. i++;
  929. if (i == (ssize_t) (argc-1))
  930. ThrowConvertException(OptionError,"MissingArgument",option);
  931. if (IsGeometry(argv[i]) == MagickFalse)
  932. ThrowConvertInvalidArgumentException(option,argv[i]);
  933. break;
  934. }
  935. if (LocaleCompare("colors",option+1) == 0)
  936. {
  937. if (*option == '+')
  938. break;
  939. i++;
  940. if ((i == (ssize_t) (argc-1)) ||
  941. (IsGeometry(argv[i]) == MagickFalse))
  942. ThrowConvertException(OptionError,"MissingArgument",option);
  943. break;
  944. }
  945. if (LocaleCompare("colorspace",option+1) == 0)
  946. {
  947. ssize_t
  948. colorspace;
  949. if (*option == '+')
  950. break;
  951. i++;
  952. if (i == (ssize_t) (argc-1))
  953. ThrowConvertException(OptionError,"MissingArgument",option);
  954. colorspace=ParseMagickOption(MagickColorspaceOptions,
  955. MagickFalse,argv[i]);
  956. if (colorspace < 0)
  957. ThrowConvertException(OptionError,"UnrecognizedColorspace",
  958. argv[i]);
  959. break;
  960. }
  961. if (LocaleCompare("combine",option+1) == 0)
  962. break;
  963. if (LocaleCompare("comment",option+1) == 0)
  964. {
  965. if (*option == '+')
  966. break;
  967. i++;
  968. if (i == (ssize_t) argc)
  969. ThrowConvertException(OptionError,"MissingArgument",option);
  970. break;
  971. }
  972. if (LocaleCompare("compose",option+1) == 0)
  973. {
  974. ssize_t
  975. compose;
  976. if (*option == '+')
  977. break;
  978. i++;
  979. if (i == (ssize_t) argc)
  980. ThrowConvertException(OptionError,"MissingArgument",option);
  981. compose=ParseMagickOption(MagickComposeOptions,MagickFalse,
  982. argv[i]);
  983. if (compose < 0)
  984. ThrowConvertException(OptionError,"UnrecognizedComposeOperator",
  985. argv[i]);
  986. break;
  987. }
  988. if (LocaleCompare("composite",option+1) == 0)
  989. break;
  990. if (LocaleCompare("compress",option+1) == 0)
  991. {
  992. ssize_t
  993. compress;
  994. if (*option == '+')
  995. break;
  996. i++;
  997. if (i == (ssize_t) (argc-1))
  998. ThrowConvertException(OptionError,"MissingArgument",option);
  999. compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
  1000. argv[i]);
  1001. if (compress < 0)
  1002. ThrowConvertException(OptionError,"UnrecognizedImageCompression",
  1003. argv[i]);
  1004. break;
  1005. }
  1006. if (LocaleCompare("concurrent",option+1) == 0)
  1007. break;
  1008. if (LocaleCompare("contrast",option+1) == 0)
  1009. break;
  1010. if (LocaleCompare("contrast-stretch",option+1) == 0)
  1011. {
  1012. i++;
  1013. if (i == (ssize_t) (argc-1))
  1014. ThrowConvertException(OptionError,"MissingArgument",option);
  1015. if (IsGeometry(argv[i]) == MagickFalse)
  1016. ThrowConvertInvalidArgumentException(option,argv[i]);
  1017. break;
  1018. }
  1019. if (LocaleCompare("convolve",option+1) == 0)
  1020. {
  1021. char
  1022. token[MaxTextExtent];
  1023. if (*option == '+')
  1024. break;
  1025. i++;
  1026. if (i == (ssize_t) (argc-1))
  1027. ThrowConvertException(OptionError,"MissingArgument",option);
  1028. #if 1
  1029. (void) token;
  1030. if (IsGeometry(argv[i]) == MagickFalse)
  1031. ThrowConvertInvalidArgumentException(option,argv[i]);
  1032. #else
  1033. /* Allow the use of built-in kernels like 'gaussian'
  1034. * These may not work for kernels with 'nan' values, like 'diamond'
  1035. */
  1036. GetMagickToken(argv[i],NULL,token);
  1037. if (isalpha((int) (unsigned char) *token) != 0)
  1038. {
  1039. ssize_t
  1040. op;
  1041. op=ParseMagickOption(MagickKernelOptions,MagickFalse,token);
  1042. if (op < 0)
  1043. ThrowConvertException(OptionError,"UnrecognizedKernelType",
  1044. token);
  1045. }
  1046. else
  1047. if (IsGeometry(argv[i]) == MagickFalse)
  1048. ThrowConvertInvalidArgumentException(option,argv[i]);
  1049. #endif
  1050. break;
  1051. }
  1052. if (LocaleCompare("crop",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. if (LocaleCompare("cycle",option+1) == 0)
  1064. {
  1065. if (*option == '+')
  1066. break;
  1067. i++;
  1068. if (i == (ssize_t) (argc-1))
  1069. ThrowConvertException(OptionError,"MissingArgument",option);
  1070. if (IsGeometry(argv[i]) == MagickFalse)
  1071. ThrowConvertInvalidArgumentException(option,argv[i]);
  1072. break;
  1073. }
  1074. ThrowConvertException(OptionError,"UnrecognizedOption",option)
  1075. }
  1076. case 'd':
  1077. {
  1078. if (LocaleCompare("decipher",option+1) == 0)
  1079. {
  1080. if (*option == '+')
  1081. break;
  1082. i++;
  1083. if (i == (ssize_t) (argc-1))
  1084. ThrowConvertException(OptionError,"MissingArgument",option);
  1085. break;
  1086. }
  1087. if (LocaleCompare("deconstruct",option+1) == 0)
  1088. break;
  1089. if (LocaleCompare("debug",option+1) == 0)
  1090. {
  1091. ssize_t
  1092. event;
  1093. if (*option == '+')
  1094. break;
  1095. i++;
  1096. if (i == (ssize_t) argc)
  1097. ThrowConvertException(OptionError,"MissingArgument",option);
  1098. event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
  1099. if (event < 0)
  1100. ThrowConvertException(OptionError,"UnrecognizedEventType",
  1101. argv[i]);
  1102. (void) SetLogEventMask(argv[i]);
  1103. break;
  1104. }
  1105. if (LocaleCompare("define",option+1) == 0)
  1106. {
  1107. i++;
  1108. if (i == (ssize_t) argc)
  1109. ThrowConvertException(OptionError,"MissingArgument",option);
  1110. if (*option == '+')
  1111. {
  1112. const char
  1113. *define;
  1114. define=GetImageOption(image_info,argv[i]);
  1115. if (define == (const char *) NULL)
  1116. ThrowConvertException(OptionError,"NoSuchOption",argv[i]);
  1117. break;
  1118. }
  1119. break;
  1120. }
  1121. if (LocaleCompare("delay",option+1) == 0)
  1122. {
  1123. if (*option == '+')
  1124. break;
  1125. i++;
  1126. if (i == (ssize_t) argc)
  1127. ThrowConvertException(OptionError,"MissingArgument",option);
  1128. if (IsGeometry(argv[i]) == MagickFalse)
  1129. ThrowConvertInvalidArgumentException(option,argv[i]);
  1130. break;
  1131. }
  1132. if (LocaleCompare("density",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("depth",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 (IsGeometry(argv[i]) == MagickFalse)
  1151. ThrowConvertInvalidArgumentException(option,argv[i]);
  1152. break;
  1153. }
  1154. if (LocaleCompare("delete",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 (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
  1162. ThrowConvertInvalidArgumentException(option,argv[i]);
  1163. break;
  1164. }
  1165. if (LocaleCompare("deskew",option+1) == 0)
  1166. {
  1167. if (*option == '+')
  1168. break;
  1169. i++;
  1170. if (i == (ssize_t) (argc-1))
  1171. ThrowConvertException(OptionError,"MissingArgument",option);
  1172. if (IsGeometry(argv[i]) == MagickFalse)
  1173. ThrowConvertInvalidArgumentException(option,argv[i]);
  1174. break;
  1175. }
  1176. if (LocaleCompare("despeckle",option+1) == 0)
  1177. break;
  1178. if (LocaleCompare("direction",option+1) == 0)
  1179. {
  1180. ssize_t
  1181. direction;
  1182. if (*option == '+')
  1183. break;
  1184. i++;
  1185. if (i == (ssize_t) argc)
  1186. ThrowConvertException(OptionError,"MissingArgument",option);
  1187. direction=ParseMagickOption(MagickDirectionOptions,MagickFalse,
  1188. argv[i]);
  1189. if (direction < 0)
  1190. ThrowConvertException(OptionError,"UnrecognizedDirectionType",
  1191. argv[i]);
  1192. break;
  1193. }
  1194. if (LocaleCompare("display",option+1) == 0)
  1195. {
  1196. if (*option == '+')
  1197. break;
  1198. i++;
  1199. if (i == (ssize_t) (argc-1))
  1200. ThrowConvertException(OptionError,"MissingArgument",option);
  1201. break;
  1202. }
  1203. if (LocaleCompare("dispose",option+1) == 0)
  1204. {
  1205. ssize_t
  1206. dispose;
  1207. if (*option == '+')
  1208. break;
  1209. i++;
  1210. if (i == (ssize_t) argc)
  1211. ThrowConvertException(OptionError,"MissingArgument",option);
  1212. dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
  1213. if (dispose < 0)
  1214. ThrowConvertException(OptionError,"UnrecognizedDisposeMethod",
  1215. argv[i]);
  1216. break;

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