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