/lib/wand/convert.c
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
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % CCCC OOO N N V V EEEEE RRRR TTTTT %
- % C O O NN N V V E R R T %
- % C O O N N N V V EEE RRRR T %
- % C O O N NN V V E R R T %
- % CCCC OOO N N V EEEEE R R T %
- % %
- % %
- % Convert an image from one format to another. %
- % %
- % Software Design %
- % John Cristy %
- % April 1992 %
- % %
- % %
- % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
- % dedicated to making software imaging solutions freely available. %
- % %
- % You may not use this file except in compliance with the License. You may %
- % obtain a copy of the License at %
- % %
- % http://www.imagemagick.org/script/license.php %
- % %
- % Unless required by applicable law or agreed to in writing, software %
- % distributed under the License is distributed on an "AS IS" BASIS, %
- % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
- % See the License for the specific language governing permissions and %
- % limitations under the License. %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % Use the convert program to convert between image formats as well as resize
- % an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample,
- % and much more.
- %
- */
- /*
- Include declarations.
- */
- #include "wand/studio.h"
- #include "wand/MagickWand.h"
- #include "wand/mogrify-private.h"
- /*
- Define declarations.
- */
- #define ThrowFileException(exception,severity,tag,context) \
- { \
- (void) ThrowMagickException(exception,GetMagickModule(),severity, \
- tag == (const char *) NULL ? "unknown" : tag,"`%s': %s",context, \
- GetExceptionMessage(errno)); \
- }
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- + C o n v e r t I m a g e C o m m a n d %
- % %
- % %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % ConvertImageCommand() reads one or more images, applies one or more image
- % processing operations, and writes out the image in the same or differing
- % format.
- %
- % The format of the ConvertImageCommand method is:
- %
- % MagickBooleanType ConvertImageCommand(ImageInfo *image_info,int argc,
- % char **argv,char **metadata,ExceptionInfo *exception)
- %
- % A description of each parameter follows:
- %
- % o image_info: the image info.
- %
- % o argc: the number of elements in the argument vector.
- %
- % o argv: A text array containing the command line arguments.
- %
- % o metadata: any metadata is returned here.
- %
- % o exception: return any errors or warnings in this structure.
- %
- */
- static MagickBooleanType ConcatenateImages(int argc,char **argv,
- ExceptionInfo *exception)
- {
- FILE
- *input,
- *output;
- int
- c;
- register ssize_t
- i;
- /*
- Open output file.
- */
- output=OpenMagickStream(argv[argc-1],"wb");
- if (output == (FILE *) NULL)
- {
- ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
- argv[argc-1]);
- return(MagickFalse);
- }
- for (i=2; i < (ssize_t) (argc-1); i++)
- {
- input=OpenMagickStream(argv[i],"rb");
- if (input == (FILE *) NULL)
- ThrowFileException(exception,FileOpenError,"UnableToOpenFile",argv[i]);
- for (c=fgetc(input); c != EOF; c=fgetc(input))
- (void) fputc((char) c,output);
- (void) fclose(input);
- (void) remove(argv[i]);
- }
- (void) fclose(output);
- return(MagickTrue);
- }
- static MagickBooleanType ConvertUsage(void)
- {
- static const char
- *miscellaneous[]=
- {
- "-debug events display copious debugging information",
- "-help print program options",
- "-list type print a list of supported option arguments",
- "-log format format of debugging information",
- "-version print version information",
- (char *) NULL
- },
- *operators[]=
- {
- "-adaptive-blur geometry",
- " adaptively blur pixels; decrease effect near edges",
- "-adaptive-resize geometry",
- " adaptively resize image using 'mesh' interpolation",
- "-adaptive-sharpen geometry",
- " adaptively sharpen pixels; increase effect near edges",
- "-alpha option on, activate, off, deactivate, set, opaque, copy",
- " transparent, extract, background, or shape",
- "-annotate geometry text",
- " annotate the image with text",
- "-auto-gamma automagically adjust gamma level of image",
- "-auto-level automagically adjust color levels of image",
- "-auto-orient automagically orient (rotate) image",
- "-bench iterations measure performance",
- "-black-threshold value",
- " force all pixels below the threshold into black",
- "-blue-shift factor simulate a scene at nighttime in the moonlight",
- "-blur geometry reduce image noise and reduce detail levels",
- "-border geometry surround image with a border of color",
- "-bordercolor color border color",
- "-brightness-contrast geometry",
- " improve brightness / contrast of the image",
- "-cdl filename color correct with a color decision list",
- "-charcoal radius simulate a charcoal drawing",
- "-chop geometry remove pixels from the image interior",
- "-clamp restrict pixel range from 0 to the quantum depth",
- "-clip clip along the first path from the 8BIM profile",
- "-clip-mask filename associate a clip mask with the image",
- "-clip-path id clip along a named path from the 8BIM profile",
- "-colorize value colorize the image with the fill color",
- "-color-matrix matrix apply color correction to the image",
- "-contrast enhance or reduce the image contrast",
- "-contrast-stretch geometry",
- " improve contrast by `stretching' the intensity range",
- "-convolve coefficients",
- " apply a convolution kernel to the image",
- "-cycle amount cycle the image colormap",
- "-decipher filename convert cipher pixels to plain pixels",
- "-deskew threshold straighten an image",
- "-despeckle reduce the speckles within an image",
- "-distort method args",
- " distort images according to given method ad args",
- "-draw string annotate the image with a graphic primitive",
- "-edge radius apply a filter to detect edges in the image",
- "-encipher filename convert plain pixels to cipher pixels",
- "-emboss radius emboss an image",
- "-enhance apply a digital filter to enhance a noisy image",
- "-equalize perform histogram equalization to an image",
- "-evaluate operator value",
- " evaluate an arithmetic, relational, or logical expression",
- "-extent geometry set the image size",
- "-extract geometry extract area from image",
- "-fft implements the discrete Fourier transform (DFT)",
- "-flip flip image vertically",
- "-floodfill geometry color",
- " floodfill the image with color",
- "-flop flop image horizontally",
- "-frame geometry surround image with an ornamental border",
- "-function name parameters",
- " apply function over image values",
- "-gamma value level of gamma correction",
- "-gaussian-blur geometry",
- " reduce image noise and reduce detail levels",
- "-geometry geometry preferred size or location of the image",
- "-identify identify the format and characteristics of the image",
- "-ift implements the inverse discrete Fourier transform (DFT)",
- "-implode amount implode image pixels about the center",
- "-lat geometry local adaptive thresholding",
- "-layers method optimize, merge, or compare image layers",
- "-level value adjust the level of image contrast",
- "-level-colors color,color",
- " level image with the given colors",
- "-linear-stretch geometry",
- " improve contrast by `stretching with saturation'",
- "-liquid-rescale geometry",
- " rescale image with seam-carving",
- "-median radius apply a median filter to the image",
- "-mode radius make each pixel the 'predominate color' of the neighborhood",
- "-modulate value vary the brightness, saturation, and hue",
- "-monochrome transform image to black and white",
- "-morphology method kernel",
- " apply a morphology method to the image",
- "-motion-blur geometry",
- " simulate motion blur",
- "-negate replace every pixel with its complementary color ",
- "-noise radius add or reduce noise in an image",
- "-normalize transform image to span the full range of colors",
- "-opaque color change this color to the fill color",
- "-ordered-dither NxN",
- " add a noise pattern to the image with specific",
- " amplitudes",
- "-paint radius simulate an oil painting",
- "-polaroid angle simulate a Polaroid picture",
- "-posterize levels reduce the image to a limited number of color levels",
- "-profile filename add, delete, or apply an image profile",
- "-quantize colorspace reduce colors in this colorspace",
- "-radial-blur angle radial blur the image",
- "-raise value lighten/darken image edges to create a 3-D effect",
- "-random-threshold low,high",
- " random threshold the image",
- "-region geometry apply options to a portion of the image",
- "-render render vector graphics",
- "-repage geometry size and location of an image canvas",
- "-resample geometry change the resolution of an image",
- "-resize geometry resize the image",
- "-roll geometry roll an image vertically or horizontally",
- "-rotate degrees apply Paeth rotation to the image",
- "-sample geometry scale image with pixel sampling",
- "-scale geometry scale the image",
- "-segment values segment an image",
- "-selective-blur geometry",
- " selectively blur pixels within a contrast threshold",
- "-sepia-tone threshold",
- " simulate a sepia-toned photo",
- "-set property value set an image property",
- "-shade degrees shade the image using a distant light source",
- "-shadow geometry simulate an image shadow",
- "-sharpen geometry sharpen the image",
- "-shave geometry shave pixels from the image edges",
- "-shear geometry slide one edge of the image along the X or Y axis",
- "-sigmoidal-contrast geometry",
- " increase the contrast without saturating highlights or shadows",
- "-sketch geometry simulate a pencil sketch",
- "-solarize threshold negate all pixels above the threshold level",
- "-sparse-color method args",
- " fill in a image based on a few color points",
- "-splice geometry splice the background color into the image",
- "-spread radius displace image pixels by a random amount",
- "-strip strip image of all profiles and comments",
- "-swirl degrees swirl image pixels about the center",
- "-threshold value threshold the image",
- "-thumbnail geometry create a thumbnail of the image",
- "-tile filename tile image when filling a graphic primitive",
- "-tint value tint the image with the fill color",
- "-transform affine transform image",
- "-transparent color make this color transparent within the image",
- "-transpose flip image vertically and rotate 90 degrees",
- "-transverse flop image horizontally and rotate 270 degrees",
- "-trim trim image edges",
- "-type type image type",
- "-unique-colors discard all but one of any pixel color",
- "-unsharp geometry sharpen the image",
- "-vignette geometry soften the edges of the image in vignette style",
- "-wave geometry alter an image along a sine wave",
- "-white-threshold value",
- " force all pixels above the threshold into white",
- (char *) NULL
- },
- *sequence_operators[]=
- {
- "-append append an image sequence",
- "-clut apply a color lookup table to the image",
- "-coalesce merge a sequence of images",
- "-combine combine a sequence of images",
- "-composite composite image",
- "-crop geometry cut out a rectangular region of the image",
- "-deconstruct break down an image sequence into constituent parts",
- "-evaluate-sequence operator",
- " evaluate an arithmetic, relational, or logical expression",
- "-flatten flatten a sequence of images",
- "-fx expression apply mathematical expression to an image channel(s)",
- "-hald-clut apply a Hald color lookup table to the image",
- "-morph value morph an image sequence",
- "-mosaic create a mosaic from an image sequence",
- "-print string interpret string and print to console",
- "-process arguments process the image with a custom image filter",
- "-reverse reverse image sequence",
- "-separate separate an image channel into a grayscale image",
- "-smush geometry smush an image sequence together",
- "-write filename write images to this file",
- (char *) NULL
- },
- *settings[]=
- {
- "-adjoin join images into a single multi-image file",
- "-affine matrix affine transform matrix",
- "-alpha option activate, deactivate, reset, or set the alpha channel",
- "-antialias remove pixel-aliasing",
- "-authenticate password",
- " decipher image with this password",
- "-attenuate value lessen (or intensify) when adding noise to an image",
- "-background color background color",
- "-bias value add bias when convolving an image",
- "-black-point-compensation",
- " use black point compensation",
- "-blue-primary point chromaticity blue primary point",
- "-bordercolor color border color",
- "-caption string assign a caption to an image",
- "-channel type apply option to select image channels",
- "-colors value preferred number of colors in the image",
- "-colorspace type alternate image colorspace",
- "-comment string annotate image with comment",
- "-compose operator set image composite operator",
- "-compress type type of pixel compression when writing the image",
- "-define format:option",
- " define one or more image format options",
- "-delay value display the next image after pausing",
- "-density geometry horizontal and vertical density of the image",
- "-depth value image depth",
- "-direction type render text right-to-left or left-to-right",
- "-display server get image or font from this X server",
- "-dispose method layer disposal method",
- "-dither method apply error diffusion to image",
- "-encoding type text encoding type",
- "-endian type endianness (MSB or LSB) of the image",
- "-family name render text with this font family",
- "-fill color color to use when filling a graphic primitive",
- "-filter type use this filter when resizing an image",
- "-font name render text with this font",
- "-format \"string\" output formatted image characteristics",
- "-fuzz distance colors within this distance are considered equal",
- "-gravity type horizontal and vertical text placement",
- "-green-primary point chromaticity green primary point",
- "-intent type type of rendering intent when managing the image color",
- "-interlace type type of image interlacing scheme",
- "-interline-spacing value",
- " set the space between two text lines",
- "-interpolate method pixel color interpolation method",
- "-interword-spacing value",
- " set the space between two words",
- "-kerning value set the space between two letters",
- "-label string assign a label to an image",
- "-limit type value pixel cache resource limit",
- "-loop iterations add Netscape loop extension to your GIF animation",
- "-mask filename associate a mask with the image",
- "-mattecolor color frame color",
- "-monitor monitor progress",
- "-orient type image orientation",
- "-page geometry size and location of an image canvas (setting)",
- "-ping efficiently determine image attributes",
- "-pointsize value font point size",
- "-precision value maximum number of significant digits to print",
- "-preview type image preview type",
- "-quality value JPEG/MIFF/PNG compression level",
- "-quiet suppress all warning messages",
- "-red-primary point chromaticity red primary point",
- "-regard-warnings pay attention to warning messages",
- "-remap filename transform image colors to match this set of colors",
- "-respect-parentheses settings remain in effect until parenthesis boundary",
- "-sampling-factor geometry",
- " horizontal and vertical sampling factor",
- "-scene value image scene number",
- "-seed value seed a new sequence of pseudo-random numbers",
- "-size geometry width and height of image",
- "-stretch type render text with this font stretch",
- "-stroke color graphic primitive stroke color",
- "-strokewidth value graphic primitive stroke width",
- "-style type render text with this font style",
- "-synchronize synchronize image to storage device",
- "-taint declare the image as modified",
- "-texture filename name of texture to tile onto the image background",
- "-tile-offset geometry",
- " tile offset",
- "-treedepth value color tree depth",
- "-transparent-color color",
- " transparent color",
- "-undercolor color annotation bounding box color",
- "-units type the units of image resolution",
- "-verbose print detailed information about the image",
- "-view FlashPix viewing transforms",
- "-virtual-pixel method",
- " virtual pixel access method",
- "-weight type render text with this font weight",
- "-white-point point chromaticity white point",
- (char *) NULL
- },
- *stack_operators[]=
- {
- "-clone index clone an image",
- "-delete index delete the image from the image sequence",
- "-insert index insert last image into the image sequence",
- "-swap indexes swap two images in the image sequence",
- (char *) NULL
- };
- const char
- **p;
- (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
- (void) printf("Copyright: %s\n",GetMagickCopyright());
- (void) printf("Features: %s\n\n",GetMagickFeatures());
- (void) printf("Usage: %s [options ...] file [ [options ...] "
- "file ...] [options ...] file\n",GetClientName());
- (void) printf("\nImage Settings:\n");
- for (p=settings; *p != (char *) NULL; p++)
- (void) printf(" %s\n",*p);
- (void) printf("\nImage Operators:\n");
- for (p=operators; *p != (char *) NULL; p++)
- (void) printf(" %s\n",*p);
- (void) printf("\nImage Sequence Operators:\n");
- for (p=sequence_operators; *p != (char *) NULL; p++)
- (void) printf(" %s\n",*p);
- (void) printf("\nImage Stack Operators:\n");
- for (p=stack_operators; *p != (char *) NULL; p++)
- (void) printf(" %s\n",*p);
- (void) printf("\nMiscellaneous Options:\n");
- for (p=miscellaneous; *p != (char *) NULL; p++)
- (void) printf(" %s\n",*p);
- (void) printf(
- "\nBy default, the image format of `file' is determined by its magic\n");
- (void) printf(
- "number. To specify a particular image format, precede the filename\n");
- (void) printf(
- "with an image format name and a colon (i.e. ps:image) or specify the\n");
- (void) printf(
- "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
- (void) printf("'-' for standard input or output.\n");
- return(MagickFalse);
- }
- WandExport MagickBooleanType ConvertImageCommand(ImageInfo *image_info,
- int argc,char **argv,char **metadata,ExceptionInfo *exception)
- {
- #define NotInitialized (unsigned int) (~0)
- #define DestroyConvert() \
- { \
- DestroyImageStack(); \
- for (i=0; i < (ssize_t) argc; i++) \
- argv[i]=DestroyString(argv[i]); \
- argv=(char **) RelinquishMagickMemory(argv); \
- }
- #define ThrowConvertException(asperity,tag,option) \
- { \
- (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
- option); \
- DestroyConvert(); \
- return(MagickFalse); \
- }
- #define ThrowConvertInvalidArgumentException(option,argument) \
- { \
- (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
- "InvalidArgument","`%s': %s",option,argument); \
- DestroyConvert(); \
- return(MagickFalse); \
- }
- char
- *filename,
- *option;
- const char
- *format;
- Image
- *image;
- ImageStack
- image_stack[MaxImageStackDepth+1];
- ssize_t
- j,
- k;
- MagickBooleanType
- fire,
- pend,
- respect_parenthesis;
- MagickStatusType
- status;
- register ssize_t
- i;
- /*
- Set defaults.
- */
- assert(image_info != (ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
- if (image_info->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
- assert(exception != (ExceptionInfo *) NULL);
- if (argc == 2)
- {
- option=argv[1];
- if ((LocaleCompare("version",option+1) == 0) ||
- (LocaleCompare("-version",option+1) == 0))
- {
- (void) fprintf(stdout,"Version: %s\n",
- GetMagickVersion((size_t *) NULL));
- (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
- (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
- return(MagickFalse);
- }
- }
- if (argc < 3)
- return(ConvertUsage());
- filename=(char *) NULL;
- format="%w,%h,%m";
- j=1;
- k=0;
- NewImageStack();
- option=(char *) NULL;
- pend=MagickFalse;
- respect_parenthesis=MagickFalse;
- status=MagickTrue;
- /*
- Parse command-line arguments.
- */
- ReadCommandlLine(argc,&argv);
- status=ExpandFilenames(&argc,&argv);
- if (status == MagickFalse)
- ThrowConvertException(ResourceLimitError,"MemoryAllocationFailed",
- GetExceptionMessage(errno));
- if ((argc > 2) && (LocaleCompare("-concatenate",argv[1]) == 0))
- return(ConcatenateImages(argc,argv,exception));
- for (i=1; i < (ssize_t) (argc-1); i++)
- {
- option=argv[i];
- if (LocaleCompare(option,"(") == 0)
- {
- FireImageStack(MagickTrue,MagickTrue,pend);
- if (k == MaxImageStackDepth)
- ThrowConvertException(OptionError,"ParenthesisNestedTooDeeply",
- option);
- PushImageStack();
- continue;
- }
- if (LocaleCompare(option,")") == 0)
- {
- FireImageStack(MagickTrue,MagickTrue,MagickTrue);
- if (k == 0)
- ThrowConvertException(OptionError,"UnableToParseExpression",option);
- PopImageStack();
- continue;
- }
- if (IsMagickOption(option) == MagickFalse)
- {
- Image
- *images;
- /*
- Read input image.
- */
- FireImageStack(MagickTrue,MagickTrue,pend);
- filename=argv[i];
- if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
- filename=argv[++i];
- (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
- if (image_info->ping != MagickFalse)
- images=PingImages(image_info,exception);
- else
- images=ReadImages(image_info,exception);
- status&=(images != (Image *) NULL) &&
- (exception->severity < ErrorException);
- if (images == (Image *) NULL)
- continue;
- AppendImageStack(images);
- continue;
- }
- pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
- switch (*(option+1))
- {
- case 'a':
- {
- if (LocaleCompare("adaptive-blur",option+1) == 0)
- {
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("adaptive-resize",option+1) == 0)
- {
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("adaptive-sharpen",option+1) == 0)
- {
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("adjoin",option+1) == 0)
- break;
- if (LocaleCompare("affine",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- break;
- }
- if (LocaleCompare("alpha",option+1) == 0)
- {
- ssize_t
- type;
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) argc)
- ThrowConvertException(OptionError,"MissingArgument",option);
- type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
- if (type < 0)
- ThrowConvertException(OptionError,"UnrecognizedAlphaChannelType",
- argv[i]);
- break;
- }
- if (LocaleCompare("annotate",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- break;
- }
- if (LocaleCompare("antialias",option+1) == 0)
- break;
- if (LocaleCompare("append",option+1) == 0)
- break;
- if (LocaleCompare("attenuate",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("authenticate",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- break;
- }
- if (LocaleCompare("auto-gamma",option+1) == 0)
- break;
- if (LocaleCompare("auto-level",option+1) == 0)
- break;
- if (LocaleCompare("auto-orient",option+1) == 0)
- break;
- if (LocaleCompare("average",option+1) == 0)
- break;
- ThrowConvertException(OptionError,"UnrecognizedOption",option)
- }
- case 'b':
- {
- if (LocaleCompare("background",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- break;
- }
- if (LocaleCompare("bench",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("bias",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("black-point-compensation",option+1) == 0)
- break;
- if (LocaleCompare("black-threshold",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("blue-primary",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("blue-shift",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("blur",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("border",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("bordercolor",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- break;
- }
- if (LocaleCompare("box",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- break;
- }
- if (LocaleCompare("brightness-contrast",option+1) == 0)
- {
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- ThrowConvertException(OptionError,"UnrecognizedOption",option)
- }
- case 'c':
- {
- if (LocaleCompare("cache",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("caption",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) argc)
- ThrowConvertException(OptionError,"MissingArgument",option);
- break;
- }
- if (LocaleCompare("cdl",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- break;
- }
- if (LocaleCompare("channel",option+1) == 0)
- {
- ssize_t
- channel;
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- channel=ParseChannelOption(argv[i]);
- if (channel < 0)
- ThrowConvertException(OptionError,"UnrecognizedChannelType",
- argv[i]);
- break;
- }
- if (LocaleCompare("charcoal",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("chop",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("clamp",option+1) == 0)
- break;
- if (LocaleCompare("clip",option+1) == 0)
- break;
- if (LocaleCompare("clip-mask",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- break;
- }
- if (LocaleCompare("clip-path",option+1) == 0)
- {
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- break;
- }
- if (LocaleCompare("clone",option+1) == 0)
- {
- Image
- *clone_images;
- clone_images=image;
- if (k != 0)
- clone_images=image_stack[k-1].image;
- if (clone_images == (Image *) NULL)
- ThrowConvertException(ImageError,"ImageSequenceRequired",option);
- FireImageStack(MagickTrue,MagickTrue,MagickTrue);
- if (*option == '+')
- clone_images=CloneImages(clone_images,"-1",exception);
- else
- {
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- clone_images=CloneImages(clone_images,argv[i],exception);
- }
- if (clone_images == (Image *) NULL)
- ThrowConvertException(OptionError,"NoSuchImage",option);
- AppendImageStack(clone_images);
- break;
- }
- if (LocaleCompare("clut",option+1) == 0)
- break;
- if (LocaleCompare("coalesce",option+1) == 0)
- break;
- if (LocaleCompare("colorize",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("color-matrix",option+1) == 0)
- {
- KernelInfo
- *kernel_info;
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- kernel_info=AcquireKernelInfo(argv[i]);
- if (kernel_info == (KernelInfo *) NULL)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- kernel_info=DestroyKernelInfo(kernel_info);
- break;
- }
- if (LocaleCompare("colors",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if ((i == (ssize_t) (argc-1)) ||
- (IsGeometry(argv[i]) == MagickFalse))
- ThrowConvertException(OptionError,"MissingArgument",option);
- break;
- }
- if (LocaleCompare("colorspace",option+1) == 0)
- {
- ssize_t
- colorspace;
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- colorspace=ParseMagickOption(MagickColorspaceOptions,
- MagickFalse,argv[i]);
- if (colorspace < 0)
- ThrowConvertException(OptionError,"UnrecognizedColorspace",
- argv[i]);
- break;
- }
- if (LocaleCompare("combine",option+1) == 0)
- break;
- if (LocaleCompare("comment",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) argc)
- ThrowConvertException(OptionError,"MissingArgument",option);
- break;
- }
- if (LocaleCompare("compose",option+1) == 0)
- {
- ssize_t
- compose;
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) argc)
- ThrowConvertException(OptionError,"MissingArgument",option);
- compose=ParseMagickOption(MagickComposeOptions,MagickFalse,
- argv[i]);
- if (compose < 0)
- ThrowConvertException(OptionError,"UnrecognizedComposeOperator",
- argv[i]);
- break;
- }
- if (LocaleCompare("composite",option+1) == 0)
- break;
- if (LocaleCompare("compress",option+1) == 0)
- {
- ssize_t
- compress;
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
- argv[i]);
- if (compress < 0)
- ThrowConvertException(OptionError,"UnrecognizedImageCompression",
- argv[i]);
- break;
- }
- if (LocaleCompare("concurrent",option+1) == 0)
- break;
- if (LocaleCompare("contrast",option+1) == 0)
- break;
- if (LocaleCompare("contrast-stretch",option+1) == 0)
- {
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("convolve",option+1) == 0)
- {
- KernelInfo
- *kernel_info;
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- kernel_info=AcquireKernelInfo(argv[i]);
- if (kernel_info == (KernelInfo *) NULL)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- kernel_info=DestroyKernelInfo(kernel_info);
- break;
- }
- if (LocaleCompare("crop",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("cycle",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- ThrowConvertException(OptionError,"UnrecognizedOption",option)
- }
- case 'd':
- {
- if (LocaleCompare("decipher",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- break;
- }
- if (LocaleCompare("deconstruct",option+1) == 0)
- break;
- if (LocaleCompare("debug",option+1) == 0)
- {
- ssize_t
- event;
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) argc)
- ThrowConvertException(OptionError,"MissingArgument",option);
- event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
- if (event < 0)
- ThrowConvertException(OptionError,"UnrecognizedEventType",
- argv[i]);
- (void) SetLogEventMask(argv[i]);
- break;
- }
- if (LocaleCompare("define",option+1) == 0)
- {
- i++;
- if (i == (ssize_t) argc)
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (*option == '+')
- {
- const char
- *define;
- define=GetImageOption(image_info,argv[i]);
- if (define == (const char *) NULL)
- ThrowConvertException(OptionError,"NoSuchOption",argv[i]);
- break;
- }
- break;
- }
- if (LocaleCompare("delay",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) argc)
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("density",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("depth",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("delete",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("deskew",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- if (IsGeometry(argv[i]) == MagickFalse)
- ThrowConvertInvalidArgumentException(option,argv[i]);
- break;
- }
- if (LocaleCompare("despeckle",option+1) == 0)
- break;
- if (LocaleCompare("direction",option+1) == 0)
- {
- ssize_t
- direction;
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) argc)
- ThrowConvertException(OptionError,"MissingArgument",option);
- direction=ParseMagickOption(MagickDirectionOptions,MagickFalse,
- argv[i]);
- if (direction < 0)
- ThrowConvertException(OptionError,"UnrecognizedDirectionType",
- argv[i]);
- break;
- }
- if (LocaleCompare("display",option+1) == 0)
- {
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) (argc-1))
- ThrowConvertException(OptionError,"MissingArgument",option);
- break;
- }
- if (LocaleCompare("dispose",option+1) == 0)
- {
- ssize_t
- dispose;
- if (*option == '+')
- break;
- i++;
- if (i == (ssize_t) argc)
- ThrowConvertException(OptionError,"MissingArgument",option);
- dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
- if (dispose < 0)
- ThrowConvertException(OptionError,"UnrecognizedDisposeMethod",
- argv[i]);
- break;
- }
- if (LocaleCompare("distort",option+1) == 0)
- {
- ssize_t
- op;
- i++;
- if (i == (ssize_t) argc)
- ThrowConvertException(OptionError,"MissingArgument",option);
- op=ParseMagickOption(MagickDistortOptions,MagickFalse,argv[i]);
- if (op < 0)…
Large files files are truncated, but you can click here to view the full file