13ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
23ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
43ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
53ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
63ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                 SSSSS  TTTTT  RRRR   EEEEE   AAA   M   M                    %
73ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                 SS       T    R   R  E      A   A  MM MM                    %
83ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                  SSS     T    RRRR   EEE    AAAAA  M M M                    %
93ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                    SS    T    R R    E      A   A  M   M                    %
103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                 SSSSS    T    R  R   EEEEE  A   A  M   M                    %
113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                     Stream Image to a Raw Image Format                      %
143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                           Software Design                                   %
16de984cdc3631106b1cbbb8d3972b76a0fc27e8e8cristy%                                Cristy                                       %
173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                              July 1992                                      %
183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
207ce65e7125a4e1df1a274ce373c537a9df9c16cdCristy%  Copyright 1999-2016 ImageMagick Studio LLC, a non-profit organization      %
213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  dedicated to making software imaging solutions freely available.           %
223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  You may not use this file except in compliance with the License.  You may  %
243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  obtain a copy of the License at                                            %
253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    http://www.imagemagick.org/script/license.php                            %
273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  Unless required by applicable law or agreed to in writing, software        %
293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  distributed under the License is distributed on an "AS IS" BASIS,          %
303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  See the License for the specific language governing permissions and        %
323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  limitations under the License.                                             %
333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  Stream is a lightweight tool to stream one or more pixel components of the
373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  image or portion of the image to your choice of storage formats. It writes
383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  the pixel components as they are read from the input image a row at a time
393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  making stream desirable when working with large images or when you require
403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  raw pixel components.
413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  Include declarations.
463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
474c08aed51c5899665ade97263692328eea4af106cristy#include "MagickWand/studio.h"
484c08aed51c5899665ade97263692328eea4af106cristy#include "MagickWand/MagickWand.h"
494c08aed51c5899665ade97263692328eea4af106cristy#include "MagickWand/mogrify-private.h"
504c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/stream-private.h"
51196372de602f3999bb9059f9f3c5756d3d8654c0cristy#include "MagickCore/string-private.h"
523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   S t r e a m I m a g e C o m m a n d                                       %
593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  StreamImageCommand() is a lightweight method designed to extract pixels
653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  from large image files to a raw format using a minimum of system resources.
663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The entire image or any regular portion of the image can be extracted.
673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the StreamImageCommand method is:
693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      MagickBooleanType StreamImageCommand(ImageInfo *image_info,int argc,
713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        char **argv,char **metadata,ExceptionInfo *exception)
723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o image_info: the image info.
763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o argc: the number of elements in the argument vector.
783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o argv: A text array containing the command line arguments.
803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o metadata: any metadata is returned here.
823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: return any errors or warnings in this structure.
843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
873ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic MagickBooleanType StreamUsage(void)
883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  const char
903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    **p;
913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  static const char
933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *miscellaneous[]=
943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    {
9517ada024a8d39285affcac96ff344f3142c41aadcristy      "-channel mask        set the image channel mask",
963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-debug events        display copious debugging information",
973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-help                print program options",
983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-list type           print a list of supported option arguments",
993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-log format          format of debugging information",
1003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-version             print version information",
1013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (char *) NULL
1023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    },
1033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *settings[]=
1043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    {
1053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-authenticate password",
1063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "                     decipher image with this password",
1073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-colorspace type     alternate image colorspace",
1083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-compress type       type of pixel compression when writing the image",
1093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-define format:option",
1103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "                     define one or more image format options",
1113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-density geometry    horizontal and vertical density of the image",
1123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-depth value         image depth",
1133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-extract geometry    extract area from image",
1143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-identify            identify the format and characteristics of the image",
1153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-interlace type      type of image interlacing scheme",
1163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-interpolate method  pixel color interpolation method",
1173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-limit type value    pixel cache resource limit",
1183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-map components      one or more pixel components",
1193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-monitor             monitor progress",
1203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-quantize colorspace reduce colors in this colorspace",
1213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-quiet               suppress all warning messages",
1223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-regard-warnings     pay attention to warning messages",
1233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-respect-parentheses settings remain in effect until parenthesis boundary",
1243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-sampling-factor geometry",
1253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "                     horizontal and vertical sampling factor",
1263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-seed value          seed a new sequence of pseudo-random numbers",
1273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-set attribute value set an image attribute",
1283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-size geometry       width and height of image",
1293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-storage-type type   pixel storage type",
130d9a291985cb653d62a4e7c3b6aa3f9c4436d30ebcristy      "-synchronize         synchronize image to storage device",
131d9a291985cb653d62a4e7c3b6aa3f9c4436d30ebcristy      "-taint               declare the image as modified",
1323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-transparent-color color",
1333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "                     transparent color",
1343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-verbose             print detailed information about the image",
1353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-virtual-pixel method",
1363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "                     virtual pixel access method",
1373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (char *) NULL
1383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    };
1393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1404f7a61361f38ef4d3eaae0c74b9964a57aee813acristy  ListMagickVersion(stdout);
1413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) printf("Usage: %s [options ...] input-image raw-image\n",
1423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    GetClientName());
1433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) printf("\nImage Settings:\n");
1443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  for (p=settings; *p != (char *) NULL; p++)
1453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    (void) printf("  %s\n",*p);
1463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) printf("\nMiscellaneous Options:\n");
1473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  for (p=miscellaneous; *p != (char *) NULL; p++)
1483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    (void) printf("  %s\n",*p);
1493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) printf(
150e5b39652d8d21bc3940d83b8d6088d4070a8a34aanthony    "\nBy default, the image format of 'file' is determined by its magic\n");
1513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) printf(
1523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    "number.  To specify a particular image format, precede the filename\n");
1533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) printf(
1543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    "with an image format name and a colon (i.e. ps:image) or specify the\n");
1553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) printf(
1563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    "image type as the filename suffix (i.e. image.ps).  Specify 'file' as\n");
1573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) printf("'-' for standard input or output.\n");
1583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(MagickFalse);
1593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
1603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1613ed852eea50f9d4cd633efb8c2b054b8e33c253cristyWandExport MagickBooleanType StreamImageCommand(ImageInfo *image_info,
1623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  int argc,char **argv,char **metadata,ExceptionInfo *exception)
1633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
1643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define DestroyStream() \
1653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ \
1663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  DestroyImageStack(); \
1673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  stream_info=DestroyStreamInfo(stream_info); \
168bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  for (i=0; i < (ssize_t) argc; i++) \
1693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    argv[i]=DestroyString(argv[i]); \
1703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  argv=(char **) RelinquishMagickMemory(argv); \
1713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
1723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define ThrowStreamException(asperity,tag,option) \
1733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ \
174efe601ce9ea5ad34ad0e8ad6e61d9be9b148b2a3cristy  (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
1753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    option); \
1763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  DestroyStream(); \
1773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(MagickFalse); \
1783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
1793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define ThrowStreamInvalidArgumentException(option,argument) \
1803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ \
1813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
182e5b39652d8d21bc3940d83b8d6088d4070a8a34aanthony    "InvalidArgument","'%s': %s",option,argument); \
1833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  DestroyStream(); \
1843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(MagickFalse); \
1853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
1863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  char
1883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *filename,
1893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *option;
1903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  const char
1923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *format;
1933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  Image
1953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *image;
1963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  ImageStack
1983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    image_stack[MaxImageStackDepth+1];
1993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
2003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  MagickBooleanType
2013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    fire,
202ebbcfea9ab0a5066ff5f0b5257c9598ca77579d3cristy    pend,
203ebbcfea9ab0a5066ff5f0b5257c9598ca77579d3cristy    respect_parenthesis;
2043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
2053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  MagickStatusType
2063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    status;
2073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
208bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  register ssize_t
2093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    i;
2103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
2119d314ff2c17a77996c05413c2013880387e50f0ecristy  ssize_t
2129d314ff2c17a77996c05413c2013880387e50f0ecristy    j,
2139d314ff2c17a77996c05413c2013880387e50f0ecristy    k;
2149d314ff2c17a77996c05413c2013880387e50f0ecristy
2153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  StreamInfo
2163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *stream_info;
2173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
2183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  /*
2193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    Set defaults.
2203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  */
2213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  assert(image_info != (ImageInfo *) NULL);
222e1c94d9d25db6b0dd7a5028ffee31d1057855d73cristy  assert(image_info->signature == MagickCoreSignature);
2233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (image_info->debug != MagickFalse)
2243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  assert(exception != (ExceptionInfo *) NULL);
2263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) metadata;
2273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (argc == 2)
2283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    {
2293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      option=argv[1];
2303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if ((LocaleCompare("version",option+1) == 0) ||
2313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (LocaleCompare("-version",option+1) == 0))
2323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
2334f7a61361f38ef4d3eaae0c74b9964a57aee813acristy          ListMagickVersion(stdout);
2343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          return(MagickFalse);
2353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
2363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    }
2373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (argc < 3)
23813e61a1ac6772c75eac4825ebca144e22f636b6bcristy    return(StreamUsage());
2393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  format="%w,%h,%m";
240da16f16767eb31921af855f17bda465fffc4e000cristy  (void) format;
2413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  j=1;
2423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  k=0;
2433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  NewImageStack();
2443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  option=(char *) NULL;
2453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  pend=MagickFalse;
246ebbcfea9ab0a5066ff5f0b5257c9598ca77579d3cristy  respect_parenthesis=MagickFalse;
2479950d57e1124b73f684fb5946e206994cefda628cristy  stream_info=AcquireStreamInfo(image_info,exception);
2483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  status=MagickTrue;
2493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  /*
2503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    Stream an image.
2513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  */
2523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  ReadCommandlLine(argc,&argv);
2533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  status=ExpandFilenames(&argc,&argv);
2543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (status == MagickFalse)
2553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    ThrowStreamException(ResourceLimitError,"MemoryAllocationFailed",
2563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      GetExceptionMessage(errno));
2573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  status=OpenStream(image_info,stream_info,argv[argc-1],exception);
2583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (status == MagickFalse)
2593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    {
2603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      DestroyStream();
2613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      return(MagickFalse);
2623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    }
263bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  for (i=1; i < (ssize_t) (argc-1); i++)
2643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
2653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    option=argv[i];
2663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    if (LocaleCompare(option,"(") == 0)
2673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
2683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        FireImageStack(MagickFalse,MagickTrue,pend);
2693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (k == MaxImageStackDepth)
2703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          ThrowStreamException(OptionError,"ParenthesisNestedTooDeeply",option);
2713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        PushImageStack();
2723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        continue;
2733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
2743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    if (LocaleCompare(option,")") == 0)
2753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
2763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        FireImageStack(MagickFalse,MagickTrue,MagickTrue);
2773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (k == 0)
2783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          ThrowStreamException(OptionError,"UnableToParseExpression",option);
2793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        PopImageStack();
2803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        continue;
2813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
282042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy    if (IsCommandOption(option) == MagickFalse)
2833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
2843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        Image
2853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          *images;
2863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
2873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        /*
2883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          Stream input image.
2893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        */
2903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        FireImageStack(MagickFalse,MagickFalse,pend);
2913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        filename=argv[i];
292cee9711bbc334b5677d5ec4ea1cc70340d35ee35cristy        if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
2933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          filename=argv[++i];
294151b66dffc9e3c2e8c4f8cdaca37ff987ca0f497cristy        (void) CopyMagickString(image_info->filename,filename,MagickPathExtent);
2953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        images=StreamImage(image_info,stream_info,exception);
2963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        status&=(images != (Image *) NULL) &&
2973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (exception->severity < ErrorException);
2983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (images == (Image *) NULL)
2993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
3003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        AppendImageStack(images);
3013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        continue;
3023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
3033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
3043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    switch (*(option+1))
3053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    {
3063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case 'a':
3073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
3083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("authenticate",option+1) == 0)
3093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
3103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
3113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
3123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
313e81f552f8ca2fc16632bd9830db3f93af07d514ccristy            if (i == (ssize_t) argc)
3143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
3153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
3163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
3173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowStreamException(OptionError,"UnrecognizedOption",option)
3183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
3193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case 'c':
3203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
3213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("cache",option+1) == 0)
3223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
3233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
3243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
3253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
326bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            if (i == (ssize_t) argc)
3273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
3283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (IsGeometry(argv[i]) == MagickFalse)
3293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamInvalidArgumentException(option,argv[i]);
3303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
3313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
3323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("channel",option+1) == 0)
3333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
334bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            ssize_t
3353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              channel;
3363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
3373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
3383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
3393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
340e81f552f8ca2fc16632bd9830db3f93af07d514ccristy            if (i == (ssize_t) argc)
3413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
3423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            channel=ParseChannelOption(argv[i]);
3433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (channel < 0)
3443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"UnrecognizedChannelType",
3453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy                argv[i]);
3463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
3473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
3483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("colorspace",option+1) == 0)
3493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
350bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            ssize_t
3513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              colorspace;
3523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
3533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
3543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
3553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
356e81f552f8ca2fc16632bd9830db3f93af07d514ccristy            if (i == (ssize_t) argc)
3573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
358042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy            colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
3593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              argv[i]);
3603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (colorspace < 0)
3613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"UnrecognizedColorspace",
3623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy                argv[i]);
3633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
3643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
3653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("compress",option+1) == 0)
3663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
367bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            ssize_t
3683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              compress;
3693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
3703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
3713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
3723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
373e81f552f8ca2fc16632bd9830db3f93af07d514ccristy            if (i == (ssize_t) argc)
3743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
375042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy            compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
3763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              argv[i]);
3773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (compress < 0)
3783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"UnrecognizedImageCompression",
3793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy                argv[i]);
3803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
3813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
3822287975e02162155f1500d91ccce6e0fde5de7c8cristy        if (LocaleCompare("concurrent",option+1) == 0)
3832287975e02162155f1500d91ccce6e0fde5de7c8cristy          break;
3843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowStreamException(OptionError,"UnrecognizedOption",option)
3853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
3863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case 'd':
3873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
3883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("debug",option+1) == 0)
3893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
390bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            ssize_t
3913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              event;
3923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
3933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
3943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
3953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
396bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            if (i == (ssize_t) argc)
3973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
398042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy            event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
3993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (event < 0)
4003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"UnrecognizedEventType",argv[i]);
4013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            (void) SetLogEventMask(argv[i]);
4023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
4033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
4043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("define",option+1) == 0)
4053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
4063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
407bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            if (i == (ssize_t) argc)
4083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
4093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
4103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              {
4113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy                const char
4123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy                  *define;
4133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
4143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy                define=GetImageOption(image_info,argv[i]);
4153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy                if (define == (const char *) NULL)
4163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy                  ThrowStreamException(OptionError,"NoSuchOption",argv[i]);
4173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy                break;
4183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              }
4193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
4203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
4213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("density",option+1) == 0)
4223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
4233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
4243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
4253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
426bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            if (i == (ssize_t) argc)
4273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
4283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (IsGeometry(argv[i]) == MagickFalse)
4293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamInvalidArgumentException(option,argv[i]);
4303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
4313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
4323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("depth",option+1) == 0)
4333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
4343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
4353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
4363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
437bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            if (i == (ssize_t) argc)
4383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
4393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (IsGeometry(argv[i]) == MagickFalse)
4403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamInvalidArgumentException(option,argv[i]);
4413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
4423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
4432287975e02162155f1500d91ccce6e0fde5de7c8cristy        if (LocaleCompare("duration",option+1) == 0)
4442287975e02162155f1500d91ccce6e0fde5de7c8cristy          {
4452287975e02162155f1500d91ccce6e0fde5de7c8cristy            if (*option == '+')
4462287975e02162155f1500d91ccce6e0fde5de7c8cristy              break;
4472287975e02162155f1500d91ccce6e0fde5de7c8cristy            i++;
448e81f552f8ca2fc16632bd9830db3f93af07d514ccristy            if (i == (ssize_t) argc)
4492287975e02162155f1500d91ccce6e0fde5de7c8cristy              ThrowStreamException(OptionError,"MissingArgument",option);
4502287975e02162155f1500d91ccce6e0fde5de7c8cristy            if (IsGeometry(argv[i]) == MagickFalse)
4512287975e02162155f1500d91ccce6e0fde5de7c8cristy              ThrowStreamInvalidArgumentException(option,argv[i]);
4522287975e02162155f1500d91ccce6e0fde5de7c8cristy            break;
4532287975e02162155f1500d91ccce6e0fde5de7c8cristy          }
4543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowStreamException(OptionError,"UnrecognizedOption",option)
4553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
4563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case 'e':
4573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
4583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("extract",option+1) == 0)
4593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
4603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
4613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
4623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
463e81f552f8ca2fc16632bd9830db3f93af07d514ccristy            if (i == (ssize_t) argc)
4643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
4653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (IsGeometry(argv[i]) == MagickFalse)
4663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamInvalidArgumentException(option,argv[i]);
4673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
4683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
4693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowStreamException(OptionError,"UnrecognizedOption",option)
4703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
4713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case 'h':
4723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
4733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if ((LocaleCompare("help",option+1) == 0) ||
4743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            (LocaleCompare("-help",option+1) == 0))
4753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          return(StreamUsage());
4763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowStreamException(OptionError,"UnrecognizedOption",option)
4773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
4783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case 'i':
4793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
4803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("identify",option+1) == 0)
4813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          break;
4823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("interlace",option+1) == 0)
4833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
484bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            ssize_t
4853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              interlace;
4863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
4873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
4883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
4893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
490bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            if (i == (ssize_t) argc)
4913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
492042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy            interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
4933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              argv[i]);
4943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (interlace < 0)
4953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"UnrecognizedInterlaceType",
4963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy                argv[i]);
4973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
4983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
4993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("interpolate",option+1) == 0)
5003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
501bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            ssize_t
5023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              interpolate;
5033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
5043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
5053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
5063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
507bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            if (i == (ssize_t) argc)
5083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
509042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy            interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
5103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              argv[i]);
5113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (interpolate < 0)
5123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"UnrecognizedInterpolateMethod",
5133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy                argv[i]);
5143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
5153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
5163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowStreamException(OptionError,"UnrecognizedOption",option)
5173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
5183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case 'l':
5193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
5203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("limit",option+1) == 0)
5213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
5223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            char
5233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              *p;
5243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
5253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            double
5263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              value;
5273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
528bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            ssize_t
5293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              resource;
5303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
5313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
5323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
5333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
534bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            if (i == (ssize_t) argc)
5353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
536042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy            resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
5373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              argv[i]);
5383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (resource < 0)
5393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"UnrecognizedResourceType",
5403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy                argv[i]);
5413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
542bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            if (i == (ssize_t) argc)
5433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
544dbdd0e35efc03c9bccda644f5407db38b7c17eeccristy            value=StringToDouble(argv[i],&p);
545da16f16767eb31921af855f17bda465fffc4e000cristy            (void) value;
5463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
5473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamInvalidArgumentException(option,argv[i]);
5483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
5493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
5503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("list",option+1) == 0)
5513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
552bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            ssize_t
5533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              list;
5543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
5553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
5563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
5573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
558bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            if (i == (ssize_t) argc)
5593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
560042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy            list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
5613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (list < 0)
5623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"UnrecognizedListType",argv[i]);
563aeb2cbc4eb61cc6a04744db1dc52f5319c466e29cristy            status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
5643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              argv+j,exception);
5653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            DestroyStream();
56632ce2391bb7051ac53c7c3c25d3ad8f41836824dcristy            return(status == 0 ? MagickTrue : MagickFalse);
5673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
5683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("log",option+1) == 0)
5693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
5703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
5713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
5723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
573bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL))
5743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
5753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
5763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
5773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowStreamException(OptionError,"UnrecognizedOption",option)
5783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
5793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case 'm':
5803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
5813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("map",option+1) == 0)
5823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
583151b66dffc9e3c2e8c4f8cdaca37ff987ca0f497cristy            (void) CopyMagickString(argv[i]+1,"san",MagickPathExtent);
5843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
5853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
5863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
5873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            SetStreamInfoMap(stream_info,argv[i]);
5883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
5893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
5903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("monitor",option+1) == 0)
5913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          break;
5923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowStreamException(OptionError,"UnrecognizedOption",option)
5933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
5943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case 'q':
5953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
5963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("quantize",option+1) == 0)
5973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
598bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            ssize_t
5993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              colorspace;
6003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
6013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
6023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
6033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
604e81f552f8ca2fc16632bd9830db3f93af07d514ccristy            if (i == (ssize_t) argc)
6053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
606042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy            colorspace=ParseCommandOption(MagickColorspaceOptions,
6073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              MagickFalse,argv[i]);
6083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (colorspace < 0)
6093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"UnrecognizedColorspace",
6103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy                argv[i]);
6113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
6123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
6133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("quiet",option+1) == 0)
6143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          break;
6153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowStreamException(OptionError,"UnrecognizedOption",option)
6163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
6173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case 'r':
6183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
6193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("regard-warnings",option+1) == 0)
6203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          break;
6213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
6223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
6233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
6243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
6253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
6263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowStreamException(OptionError,"UnrecognizedOption",option)
6273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
6283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case 's':
6293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
6303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("sampling-factor",option+1) == 0)
6313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
6323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
6333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
6343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
635bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            if (i == (ssize_t) argc)
6363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
6373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (IsGeometry(argv[i]) == MagickFalse)
6383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamInvalidArgumentException(option,argv[i]);
6393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
6403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
6413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("seed",option+1) == 0)
6423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
6433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
6443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
6453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
646e81f552f8ca2fc16632bd9830db3f93af07d514ccristy            if (i == (ssize_t) argc)
6473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
6483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (IsGeometry(argv[i]) == MagickFalse)
6493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamInvalidArgumentException(option,argv[i]);
6503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
6513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
6523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("set",option+1) == 0)
6533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
6543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
655bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            if (i == (ssize_t) argc)
6563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
6573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
6583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
6593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
660bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            if (i == (ssize_t) argc)
6613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
6623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
6633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
6643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("size",option+1) == 0)
6653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
6663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
6673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
6683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
669bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            if (i == (ssize_t) argc)
6703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
6713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (IsGeometry(argv[i]) == MagickFalse)
6723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamInvalidArgumentException(option,argv[i]);
6733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
6743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
6753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("storage-type",option+1) == 0)
6763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
677bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            ssize_t
6783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              type;
6793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
6803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
6813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
6823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
683e81f552f8ca2fc16632bd9830db3f93af07d514ccristy            if (i == (ssize_t) argc)
6843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
685042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy            type=ParseCommandOption(MagickStorageOptions,MagickFalse,argv[i]);
6863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (type < 0)
6873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"UnrecognizedStorageType",
6883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy                argv[i]);
6893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            SetStreamInfoStorageType(stream_info,(StorageType) type);
6903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
6913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
692d9a291985cb653d62a4e7c3b6aa3f9c4436d30ebcristy        if (LocaleCompare("synchronize",option+1) == 0)
693d9a291985cb653d62a4e7c3b6aa3f9c4436d30ebcristy          break;
6943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowStreamException(OptionError,"UnrecognizedOption",option)
6953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
6963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case 't':
6973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
698d9a291985cb653d62a4e7c3b6aa3f9c4436d30ebcristy        if (LocaleCompare("taint",option+1) == 0)
699d9a291985cb653d62a4e7c3b6aa3f9c4436d30ebcristy          break;
7003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("transparent-color",option+1) == 0)
7013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
7023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
7033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
7043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
705e81f552f8ca2fc16632bd9830db3f93af07d514ccristy            if (i == (ssize_t) argc)
7063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
7073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
7083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
7093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowStreamException(OptionError,"UnrecognizedOption",option)
7103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
7113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case 'v':
7123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
7133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("verbose",option+1) == 0)
7143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          break;
7153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if ((LocaleCompare("version",option+1) == 0) ||
7163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            (LocaleCompare("-version",option+1) == 0))
7173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
7184f7a61361f38ef4d3eaae0c74b9964a57aee813acristy            ListMagickVersion(stdout);
7193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
7203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
7213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("virtual-pixel",option+1) == 0)
7223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
723bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            ssize_t
7243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              method;
7253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
7263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
7273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
7283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
729e81f552f8ca2fc16632bd9830db3f93af07d514ccristy            if (i == (ssize_t) argc)
7303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowStreamException(OptionError,"MissingArgument",option);
731042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy            method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
7323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              argv[i]);
7333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (method < 0)
7340696de1c50b4fece983d6c88b139ff3d0d534f44cristy              ThrowStreamException(OptionError,"UnrecognizedVirtualPixelMethod",
7350696de1c50b4fece983d6c88b139ff3d0d534f44cristy                argv[i]);
7363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
7373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
7383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowStreamException(OptionError,"UnrecognizedOption",option)
7393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
7403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case '?':
7413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        break;
7423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      default:
7433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowStreamException(OptionError,"UnrecognizedOption",option)
7443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    }
745042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy    fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
746042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy      FireOptionFlag) == 0 ?  MagickFalse : MagickTrue;
7473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    if (fire != MagickFalse)
7483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      FireImageStack(MagickFalse,MagickTrue,MagickTrue);
7493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  }
7503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (k != 0)
7513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    ThrowStreamException(OptionError,"UnbalancedParenthesis",argv[i]);
752bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  if (i-- != (ssize_t) (argc-1))
7533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    ThrowStreamException(OptionError,"MissingAnImageFilename",argv[i]);
7543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (image == (Image *) NULL)
7553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    ThrowStreamException(OptionError,"MissingAnImageFilename",argv[i]);
7563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  FinalizeImageSettings(image_info,image,MagickTrue);
75794f2007ae3b0c364b710bc5396ede341db4a4b97cristy  if (image == (Image *) NULL)
75894f2007ae3b0c364b710bc5396ede341db4a4b97cristy    ThrowStreamException(OptionError,"MissingAnImageFilename",argv[i]);
7593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  DestroyStream();
7603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(status != 0 ? MagickTrue : MagickFalse);
7613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
762