Home | History | Annotate | Download | only in MagickWand
      1 /*
      2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      3 %                                                                             %
      4 %                                                                             %
      5 %                                                                             %
      6 %                 SSSSS  TTTTT  RRRR   EEEEE   AAA   M   M                    %
      7 %                 SS       T    R   R  E      A   A  MM MM                    %
      8 %                  SSS     T    RRRR   EEE    AAAAA  M M M                    %
      9 %                    SS    T    R R    E      A   A  M   M                    %
     10 %                 SSSSS    T    R  R   EEEEE  A   A  M   M                    %
     11 %                                                                             %
     12 %                                                                             %
     13 %                     Stream Image to a Raw Image Format                      %
     14 %                                                                             %
     15 %                           Software Design                                   %
     16 %                                Cristy                                       %
     17 %                              July 1992                                      %
     18 %                                                                             %
     19 %                                                                             %
     20 %  Copyright 1999-2016 ImageMagick Studio LLC, a non-profit organization      %
     21 %  dedicated to making software imaging solutions freely available.           %
     22 %                                                                             %
     23 %  You may not use this file except in compliance with the License.  You may  %
     24 %  obtain a copy of the License at                                            %
     25 %                                                                             %
     26 %    http://www.imagemagick.org/script/license.php                            %
     27 %                                                                             %
     28 %  Unless required by applicable law or agreed to in writing, software        %
     29 %  distributed under the License is distributed on an "AS IS" BASIS,          %
     30 %  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
     31 %  See the License for the specific language governing permissions and        %
     32 %  limitations under the License.                                             %
     33 %                                                                             %
     34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     35 %
     36 %  Stream is a lightweight tool to stream one or more pixel components of the
     37 %  image or portion of the image to your choice of storage formats. It writes
     38 %  the pixel components as they are read from the input image a row at a time
     39 %  making stream desirable when working with large images or when you require
     40 %  raw pixel components.
     41 %
     42 */
     43 
     44 /*
     46   Include declarations.
     47 */
     48 #include "MagickWand/studio.h"
     49 #include "MagickWand/MagickWand.h"
     50 #include "MagickWand/mogrify-private.h"
     51 #include "MagickCore/stream-private.h"
     52 #include "MagickCore/string-private.h"
     53 
     54 /*
     56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     57 %                                                                             %
     58 %                                                                             %
     59 %                                                                             %
     60 %   S t r e a m I m a g e C o m m a n d                                       %
     61 %                                                                             %
     62 %                                                                             %
     63 %                                                                             %
     64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     65 %
     66 %  StreamImageCommand() is a lightweight method designed to extract pixels
     67 %  from large image files to a raw format using a minimum of system resources.
     68 %  The entire image or any regular portion of the image can be extracted.
     69 %
     70 %  The format of the StreamImageCommand method is:
     71 %
     72 %      MagickBooleanType StreamImageCommand(ImageInfo *image_info,int argc,
     73 %        char **argv,char **metadata,ExceptionInfo *exception)
     74 %
     75 %  A description of each parameter follows:
     76 %
     77 %    o image_info: the image info.
     78 %
     79 %    o argc: the number of elements in the argument vector.
     80 %
     81 %    o argv: A text array containing the command line arguments.
     82 %
     83 %    o metadata: any metadata is returned here.
     84 %
     85 %    o exception: return any errors or warnings in this structure.
     86 %
     87 */
     88 
     89 static MagickBooleanType StreamUsage(void)
     90 {
     91   const char
     92     **p;
     93 
     94   static const char
     95     *miscellaneous[]=
     96     {
     97       "-channel mask        set the image channel mask",
     98       "-debug events        display copious debugging information",
     99       "-help                print program options",
    100       "-list type           print a list of supported option arguments",
    101       "-log format          format of debugging information",
    102       "-version             print version information",
    103       (char *) NULL
    104     },
    105     *settings[]=
    106     {
    107       "-authenticate password",
    108       "                     decipher image with this password",
    109       "-colorspace type     alternate image colorspace",
    110       "-compress type       type of pixel compression when writing the image",
    111       "-define format:option",
    112       "                     define one or more image format options",
    113       "-density geometry    horizontal and vertical density of the image",
    114       "-depth value         image depth",
    115       "-extract geometry    extract area from image",
    116       "-identify            identify the format and characteristics of the image",
    117       "-interlace type      type of image interlacing scheme",
    118       "-interpolate method  pixel color interpolation method",
    119       "-limit type value    pixel cache resource limit",
    120       "-map components      one or more pixel components",
    121       "-monitor             monitor progress",
    122       "-quantize colorspace reduce colors in this colorspace",
    123       "-quiet               suppress all warning messages",
    124       "-regard-warnings     pay attention to warning messages",
    125       "-respect-parentheses settings remain in effect until parenthesis boundary",
    126       "-sampling-factor geometry",
    127       "                     horizontal and vertical sampling factor",
    128       "-seed value          seed a new sequence of pseudo-random numbers",
    129       "-set attribute value set an image attribute",
    130       "-size geometry       width and height of image",
    131       "-storage-type type   pixel storage type",
    132       "-synchronize         synchronize image to storage device",
    133       "-taint               declare the image as modified",
    134       "-transparent-color color",
    135       "                     transparent color",
    136       "-verbose             print detailed information about the image",
    137       "-virtual-pixel method",
    138       "                     virtual pixel access method",
    139       (char *) NULL
    140     };
    141 
    142   ListMagickVersion(stdout);
    143   (void) printf("Usage: %s [options ...] input-image raw-image\n",
    144     GetClientName());
    145   (void) printf("\nImage Settings:\n");
    146   for (p=settings; *p != (char *) NULL; p++)
    147     (void) printf("  %s\n",*p);
    148   (void) printf("\nMiscellaneous Options:\n");
    149   for (p=miscellaneous; *p != (char *) NULL; p++)
    150     (void) printf("  %s\n",*p);
    151   (void) printf(
    152     "\nBy default, the image format of 'file' is determined by its magic\n");
    153   (void) printf(
    154     "number.  To specify a particular image format, precede the filename\n");
    155   (void) printf(
    156     "with an image format name and a colon (i.e. ps:image) or specify the\n");
    157   (void) printf(
    158     "image type as the filename suffix (i.e. image.ps).  Specify 'file' as\n");
    159   (void) printf("'-' for standard input or output.\n");
    160   return(MagickFalse);
    161 }
    162 
    163 WandExport MagickBooleanType StreamImageCommand(ImageInfo *image_info,
    164   int argc,char **argv,char **metadata,ExceptionInfo *exception)
    165 {
    166 #define DestroyStream() \
    167 { \
    168   DestroyImageStack(); \
    169   stream_info=DestroyStreamInfo(stream_info); \
    170   for (i=0; i < (ssize_t) argc; i++) \
    171     argv[i]=DestroyString(argv[i]); \
    172   argv=(char **) RelinquishMagickMemory(argv); \
    173 }
    174 #define ThrowStreamException(asperity,tag,option) \
    175 { \
    176   (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
    177     option); \
    178   DestroyStream(); \
    179   return(MagickFalse); \
    180 }
    181 #define ThrowStreamInvalidArgumentException(option,argument) \
    182 { \
    183   (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
    184     "InvalidArgument","'%s': %s",option,argument); \
    185   DestroyStream(); \
    186   return(MagickFalse); \
    187 }
    188 
    189   char
    190     *filename,
    191     *option;
    192 
    193   const char
    194     *format;
    195 
    196   Image
    197     *image;
    198 
    199   ImageStack
    200     image_stack[MaxImageStackDepth+1];
    201 
    202   MagickBooleanType
    203     fire,
    204     pend,
    205     respect_parenthesis;
    206 
    207   MagickStatusType
    208     status;
    209 
    210   register ssize_t
    211     i;
    212 
    213   ssize_t
    214     j,
    215     k;
    216 
    217   StreamInfo
    218     *stream_info;
    219 
    220   /*
    221     Set defaults.
    222   */
    223   assert(image_info != (ImageInfo *) NULL);
    224   assert(image_info->signature == MagickCoreSignature);
    225   if (image_info->debug != MagickFalse)
    226     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
    227   assert(exception != (ExceptionInfo *) NULL);
    228   (void) metadata;
    229   if (argc == 2)
    230     {
    231       option=argv[1];
    232       if ((LocaleCompare("version",option+1) == 0) ||
    233           (LocaleCompare("-version",option+1) == 0))
    234         {
    235           ListMagickVersion(stdout);
    236           return(MagickFalse);
    237         }
    238     }
    239   if (argc < 3)
    240     return(StreamUsage());
    241   format="%w,%h,%m";
    242   (void) format;
    243   j=1;
    244   k=0;
    245   NewImageStack();
    246   option=(char *) NULL;
    247   pend=MagickFalse;
    248   respect_parenthesis=MagickFalse;
    249   stream_info=AcquireStreamInfo(image_info,exception);
    250   status=MagickTrue;
    251   /*
    252     Stream an image.
    253   */
    254   ReadCommandlLine(argc,&argv);
    255   status=ExpandFilenames(&argc,&argv);
    256   if (status == MagickFalse)
    257     ThrowStreamException(ResourceLimitError,"MemoryAllocationFailed",
    258       GetExceptionMessage(errno));
    259   status=OpenStream(image_info,stream_info,argv[argc-1],exception);
    260   if (status == MagickFalse)
    261     {
    262       DestroyStream();
    263       return(MagickFalse);
    264     }
    265   for (i=1; i < (ssize_t) (argc-1); i++)
    266   {
    267     option=argv[i];
    268     if (LocaleCompare(option,"(") == 0)
    269       {
    270         FireImageStack(MagickFalse,MagickTrue,pend);
    271         if (k == MaxImageStackDepth)
    272           ThrowStreamException(OptionError,"ParenthesisNestedTooDeeply",option);
    273         PushImageStack();
    274         continue;
    275       }
    276     if (LocaleCompare(option,")") == 0)
    277       {
    278         FireImageStack(MagickFalse,MagickTrue,MagickTrue);
    279         if (k == 0)
    280           ThrowStreamException(OptionError,"UnableToParseExpression",option);
    281         PopImageStack();
    282         continue;
    283       }
    284     if (IsCommandOption(option) == MagickFalse)
    285       {
    286         Image
    287           *images;
    288 
    289         /*
    290           Stream input image.
    291         */
    292         FireImageStack(MagickFalse,MagickFalse,pend);
    293         filename=argv[i];
    294         if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
    295           filename=argv[++i];
    296         (void) CopyMagickString(image_info->filename,filename,MagickPathExtent);
    297         images=StreamImage(image_info,stream_info,exception);
    298         status&=(images != (Image *) NULL) &&
    299           (exception->severity < ErrorException);
    300         if (images == (Image *) NULL)
    301           continue;
    302         AppendImageStack(images);
    303         continue;
    304       }
    305     pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
    306     switch (*(option+1))
    307     {
    308       case 'a':
    309       {
    310         if (LocaleCompare("authenticate",option+1) == 0)
    311           {
    312             if (*option == '+')
    313               break;
    314             i++;
    315             if (i == (ssize_t) argc)
    316               ThrowStreamException(OptionError,"MissingArgument",option);
    317             break;
    318           }
    319         ThrowStreamException(OptionError,"UnrecognizedOption",option)
    320       }
    321       case 'c':
    322       {
    323         if (LocaleCompare("cache",option+1) == 0)
    324           {
    325             if (*option == '+')
    326               break;
    327             i++;
    328             if (i == (ssize_t) argc)
    329               ThrowStreamException(OptionError,"MissingArgument",option);
    330             if (IsGeometry(argv[i]) == MagickFalse)
    331               ThrowStreamInvalidArgumentException(option,argv[i]);
    332             break;
    333           }
    334         if (LocaleCompare("channel",option+1) == 0)
    335           {
    336             ssize_t
    337               channel;
    338 
    339             if (*option == '+')
    340               break;
    341             i++;
    342             if (i == (ssize_t) argc)
    343               ThrowStreamException(OptionError,"MissingArgument",option);
    344             channel=ParseChannelOption(argv[i]);
    345             if (channel < 0)
    346               ThrowStreamException(OptionError,"UnrecognizedChannelType",
    347                 argv[i]);
    348             break;
    349           }
    350         if (LocaleCompare("colorspace",option+1) == 0)
    351           {
    352             ssize_t
    353               colorspace;
    354 
    355             if (*option == '+')
    356               break;
    357             i++;
    358             if (i == (ssize_t) argc)
    359               ThrowStreamException(OptionError,"MissingArgument",option);
    360             colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
    361               argv[i]);
    362             if (colorspace < 0)
    363               ThrowStreamException(OptionError,"UnrecognizedColorspace",
    364                 argv[i]);
    365             break;
    366           }
    367         if (LocaleCompare("compress",option+1) == 0)
    368           {
    369             ssize_t
    370               compress;
    371 
    372             if (*option == '+')
    373               break;
    374             i++;
    375             if (i == (ssize_t) argc)
    376               ThrowStreamException(OptionError,"MissingArgument",option);
    377             compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
    378               argv[i]);
    379             if (compress < 0)
    380               ThrowStreamException(OptionError,"UnrecognizedImageCompression",
    381                 argv[i]);
    382             break;
    383           }
    384         if (LocaleCompare("concurrent",option+1) == 0)
    385           break;
    386         ThrowStreamException(OptionError,"UnrecognizedOption",option)
    387       }
    388       case 'd':
    389       {
    390         if (LocaleCompare("debug",option+1) == 0)
    391           {
    392             ssize_t
    393               event;
    394 
    395             if (*option == '+')
    396               break;
    397             i++;
    398             if (i == (ssize_t) argc)
    399               ThrowStreamException(OptionError,"MissingArgument",option);
    400             event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
    401             if (event < 0)
    402               ThrowStreamException(OptionError,"UnrecognizedEventType",argv[i]);
    403             (void) SetLogEventMask(argv[i]);
    404             break;
    405           }
    406         if (LocaleCompare("define",option+1) == 0)
    407           {
    408             i++;
    409             if (i == (ssize_t) argc)
    410               ThrowStreamException(OptionError,"MissingArgument",option);
    411             if (*option == '+')
    412               {
    413                 const char
    414                   *define;
    415 
    416                 define=GetImageOption(image_info,argv[i]);
    417                 if (define == (const char *) NULL)
    418                   ThrowStreamException(OptionError,"NoSuchOption",argv[i]);
    419                 break;
    420               }
    421             break;
    422           }
    423         if (LocaleCompare("density",option+1) == 0)
    424           {
    425             if (*option == '+')
    426               break;
    427             i++;
    428             if (i == (ssize_t) argc)
    429               ThrowStreamException(OptionError,"MissingArgument",option);
    430             if (IsGeometry(argv[i]) == MagickFalse)
    431               ThrowStreamInvalidArgumentException(option,argv[i]);
    432             break;
    433           }
    434         if (LocaleCompare("depth",option+1) == 0)
    435           {
    436             if (*option == '+')
    437               break;
    438             i++;
    439             if (i == (ssize_t) argc)
    440               ThrowStreamException(OptionError,"MissingArgument",option);
    441             if (IsGeometry(argv[i]) == MagickFalse)
    442               ThrowStreamInvalidArgumentException(option,argv[i]);
    443             break;
    444           }
    445         if (LocaleCompare("duration",option+1) == 0)
    446           {
    447             if (*option == '+')
    448               break;
    449             i++;
    450             if (i == (ssize_t) argc)
    451               ThrowStreamException(OptionError,"MissingArgument",option);
    452             if (IsGeometry(argv[i]) == MagickFalse)
    453               ThrowStreamInvalidArgumentException(option,argv[i]);
    454             break;
    455           }
    456         ThrowStreamException(OptionError,"UnrecognizedOption",option)
    457       }
    458       case 'e':
    459       {
    460         if (LocaleCompare("extract",option+1) == 0)
    461           {
    462             if (*option == '+')
    463               break;
    464             i++;
    465             if (i == (ssize_t) argc)
    466               ThrowStreamException(OptionError,"MissingArgument",option);
    467             if (IsGeometry(argv[i]) == MagickFalse)
    468               ThrowStreamInvalidArgumentException(option,argv[i]);
    469             break;
    470           }
    471         ThrowStreamException(OptionError,"UnrecognizedOption",option)
    472       }
    473       case 'h':
    474       {
    475         if ((LocaleCompare("help",option+1) == 0) ||
    476             (LocaleCompare("-help",option+1) == 0))
    477           return(StreamUsage());
    478         ThrowStreamException(OptionError,"UnrecognizedOption",option)
    479       }
    480       case 'i':
    481       {
    482         if (LocaleCompare("identify",option+1) == 0)
    483           break;
    484         if (LocaleCompare("interlace",option+1) == 0)
    485           {
    486             ssize_t
    487               interlace;
    488 
    489             if (*option == '+')
    490               break;
    491             i++;
    492             if (i == (ssize_t) argc)
    493               ThrowStreamException(OptionError,"MissingArgument",option);
    494             interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
    495               argv[i]);
    496             if (interlace < 0)
    497               ThrowStreamException(OptionError,"UnrecognizedInterlaceType",
    498                 argv[i]);
    499             break;
    500           }
    501         if (LocaleCompare("interpolate",option+1) == 0)
    502           {
    503             ssize_t
    504               interpolate;
    505 
    506             if (*option == '+')
    507               break;
    508             i++;
    509             if (i == (ssize_t) argc)
    510               ThrowStreamException(OptionError,"MissingArgument",option);
    511             interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
    512               argv[i]);
    513             if (interpolate < 0)
    514               ThrowStreamException(OptionError,"UnrecognizedInterpolateMethod",
    515                 argv[i]);
    516             break;
    517           }
    518         ThrowStreamException(OptionError,"UnrecognizedOption",option)
    519       }
    520       case 'l':
    521       {
    522         if (LocaleCompare("limit",option+1) == 0)
    523           {
    524             char
    525               *p;
    526 
    527             double
    528               value;
    529 
    530             ssize_t
    531               resource;
    532 
    533             if (*option == '+')
    534               break;
    535             i++;
    536             if (i == (ssize_t) argc)
    537               ThrowStreamException(OptionError,"MissingArgument",option);
    538             resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
    539               argv[i]);
    540             if (resource < 0)
    541               ThrowStreamException(OptionError,"UnrecognizedResourceType",
    542                 argv[i]);
    543             i++;
    544             if (i == (ssize_t) argc)
    545               ThrowStreamException(OptionError,"MissingArgument",option);
    546             value=StringToDouble(argv[i],&p);
    547             (void) value;
    548             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
    549               ThrowStreamInvalidArgumentException(option,argv[i]);
    550             break;
    551           }
    552         if (LocaleCompare("list",option+1) == 0)
    553           {
    554             ssize_t
    555               list;
    556 
    557             if (*option == '+')
    558               break;
    559             i++;
    560             if (i == (ssize_t) argc)
    561               ThrowStreamException(OptionError,"MissingArgument",option);
    562             list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
    563             if (list < 0)
    564               ThrowStreamException(OptionError,"UnrecognizedListType",argv[i]);
    565             status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
    566               argv+j,exception);
    567             DestroyStream();
    568             return(status == 0 ? MagickTrue : MagickFalse);
    569           }
    570         if (LocaleCompare("log",option+1) == 0)
    571           {
    572             if (*option == '+')
    573               break;
    574             i++;
    575             if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL))
    576               ThrowStreamException(OptionError,"MissingArgument",option);
    577             break;
    578           }
    579         ThrowStreamException(OptionError,"UnrecognizedOption",option)
    580       }
    581       case 'm':
    582       {
    583         if (LocaleCompare("map",option+1) == 0)
    584           {
    585             (void) CopyMagickString(argv[i]+1,"san",MagickPathExtent);
    586             if (*option == '+')
    587               break;
    588             i++;
    589             SetStreamInfoMap(stream_info,argv[i]);
    590             break;
    591           }
    592         if (LocaleCompare("monitor",option+1) == 0)
    593           break;
    594         ThrowStreamException(OptionError,"UnrecognizedOption",option)
    595       }
    596       case 'q':
    597       {
    598         if (LocaleCompare("quantize",option+1) == 0)
    599           {
    600             ssize_t
    601               colorspace;
    602 
    603             if (*option == '+')
    604               break;
    605             i++;
    606             if (i == (ssize_t) argc)
    607               ThrowStreamException(OptionError,"MissingArgument",option);
    608             colorspace=ParseCommandOption(MagickColorspaceOptions,
    609               MagickFalse,argv[i]);
    610             if (colorspace < 0)
    611               ThrowStreamException(OptionError,"UnrecognizedColorspace",
    612                 argv[i]);
    613             break;
    614           }
    615         if (LocaleCompare("quiet",option+1) == 0)
    616           break;
    617         ThrowStreamException(OptionError,"UnrecognizedOption",option)
    618       }
    619       case 'r':
    620       {
    621         if (LocaleCompare("regard-warnings",option+1) == 0)
    622           break;
    623         if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
    624           {
    625             respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
    626             break;
    627           }
    628         ThrowStreamException(OptionError,"UnrecognizedOption",option)
    629       }
    630       case 's':
    631       {
    632         if (LocaleCompare("sampling-factor",option+1) == 0)
    633           {
    634             if (*option == '+')
    635               break;
    636             i++;
    637             if (i == (ssize_t) argc)
    638               ThrowStreamException(OptionError,"MissingArgument",option);
    639             if (IsGeometry(argv[i]) == MagickFalse)
    640               ThrowStreamInvalidArgumentException(option,argv[i]);
    641             break;
    642           }
    643         if (LocaleCompare("seed",option+1) == 0)
    644           {
    645             if (*option == '+')
    646               break;
    647             i++;
    648             if (i == (ssize_t) argc)
    649               ThrowStreamException(OptionError,"MissingArgument",option);
    650             if (IsGeometry(argv[i]) == MagickFalse)
    651               ThrowStreamInvalidArgumentException(option,argv[i]);
    652             break;
    653           }
    654         if (LocaleCompare("set",option+1) == 0)
    655           {
    656             i++;
    657             if (i == (ssize_t) argc)
    658               ThrowStreamException(OptionError,"MissingArgument",option);
    659             if (*option == '+')
    660               break;
    661             i++;
    662             if (i == (ssize_t) argc)
    663               ThrowStreamException(OptionError,"MissingArgument",option);
    664             break;
    665           }
    666         if (LocaleCompare("size",option+1) == 0)
    667           {
    668             if (*option == '+')
    669               break;
    670             i++;
    671             if (i == (ssize_t) argc)
    672               ThrowStreamException(OptionError,"MissingArgument",option);
    673             if (IsGeometry(argv[i]) == MagickFalse)
    674               ThrowStreamInvalidArgumentException(option,argv[i]);
    675             break;
    676           }
    677         if (LocaleCompare("storage-type",option+1) == 0)
    678           {
    679             ssize_t
    680               type;
    681 
    682             if (*option == '+')
    683               break;
    684             i++;
    685             if (i == (ssize_t) argc)
    686               ThrowStreamException(OptionError,"MissingArgument",option);
    687             type=ParseCommandOption(MagickStorageOptions,MagickFalse,argv[i]);
    688             if (type < 0)
    689               ThrowStreamException(OptionError,"UnrecognizedStorageType",
    690                 argv[i]);
    691             SetStreamInfoStorageType(stream_info,(StorageType) type);
    692             break;
    693           }
    694         if (LocaleCompare("synchronize",option+1) == 0)
    695           break;
    696         ThrowStreamException(OptionError,"UnrecognizedOption",option)
    697       }
    698       case 't':
    699       {
    700         if (LocaleCompare("taint",option+1) == 0)
    701           break;
    702         if (LocaleCompare("transparent-color",option+1) == 0)
    703           {
    704             if (*option == '+')
    705               break;
    706             i++;
    707             if (i == (ssize_t) argc)
    708               ThrowStreamException(OptionError,"MissingArgument",option);
    709             break;
    710           }
    711         ThrowStreamException(OptionError,"UnrecognizedOption",option)
    712       }
    713       case 'v':
    714       {
    715         if (LocaleCompare("verbose",option+1) == 0)
    716           break;
    717         if ((LocaleCompare("version",option+1) == 0) ||
    718             (LocaleCompare("-version",option+1) == 0))
    719           {
    720             ListMagickVersion(stdout);
    721             break;
    722           }
    723         if (LocaleCompare("virtual-pixel",option+1) == 0)
    724           {
    725             ssize_t
    726               method;
    727 
    728             if (*option == '+')
    729               break;
    730             i++;
    731             if (i == (ssize_t) argc)
    732               ThrowStreamException(OptionError,"MissingArgument",option);
    733             method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
    734               argv[i]);
    735             if (method < 0)
    736               ThrowStreamException(OptionError,"UnrecognizedVirtualPixelMethod",
    737                 argv[i]);
    738             break;
    739           }
    740         ThrowStreamException(OptionError,"UnrecognizedOption",option)
    741       }
    742       case '?':
    743         break;
    744       default:
    745         ThrowStreamException(OptionError,"UnrecognizedOption",option)
    746     }
    747     fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
    748       FireOptionFlag) == 0 ?  MagickFalse : MagickTrue;
    749     if (fire != MagickFalse)
    750       FireImageStack(MagickFalse,MagickTrue,MagickTrue);
    751   }
    752   if (k != 0)
    753     ThrowStreamException(OptionError,"UnbalancedParenthesis",argv[i]);
    754   if (i-- != (ssize_t) (argc-1))
    755     ThrowStreamException(OptionError,"MissingAnImageFilename",argv[i]);
    756   if (image == (Image *) NULL)
    757     ThrowStreamException(OptionError,"MissingAnImageFilename",argv[i]);
    758   FinalizeImageSettings(image_info,image,MagickTrue);
    759   if (image == (Image *) NULL)
    760     ThrowStreamException(OptionError,"MissingAnImageFilename",argv[i]);
    761   DestroyStream();
    762   return(status != 0 ? MagickTrue : MagickFalse);
    763 }
    764