]> granicus.if.org Git - imagemagick/blob - wand/stream.c
reverted Robidoux filter to a Keys cubic
[imagemagick] / wand / stream.c
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 %                             John Cristy                                     %
17 %                              July 1992                                      %
18 %                                                                             %
19 %                                                                             %
20 %  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
21 %  dedicated to making software imaging solutions freely available.           %
22 %                                                                             %
23 %  You may not use this file except in compliance with the License.  You may  %
24 %  obtain a copy of the License at                                            %
25 %                                                                             %
26 %    http://www.imagemagick.org/script/license.php                            %
27 %                                                                             %
28 %  Unless required by applicable law or agreed to in writing, software        %
29 %  distributed under the License is distributed on an "AS IS" BASIS,          %
30 %  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
31 %  See the License for the specific language governing permissions and        %
32 %  limitations under the License.                                             %
33 %                                                                             %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %
36 %  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 \f
44 /*
45   Include declarations.
46 */
47 #include "wand/studio.h"
48 #include "wand/MagickWand.h"
49 #include "wand/mogrify-private.h"
50 #include "magick/stream-private.h"
51 \f
52 /*
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 %                                                                             %
55 %                                                                             %
56 %                                                                             %
57 %   S t r e a m I m a g e C o m m a n d                                       %
58 %                                                                             %
59 %                                                                             %
60 %                                                                             %
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 %
63 %  StreamImageCommand() is a lightweight method designed to extract pixels
64 %  from large image files to a raw format using a minimum of system resources.
65 %  The entire image or any regular portion of the image can be extracted.
66 %
67 %  The format of the StreamImageCommand method is:
68 %
69 %      MagickBooleanType StreamImageCommand(ImageInfo *image_info,int argc,
70 %        char **argv,char **metadata,ExceptionInfo *exception)
71 %
72 %  A description of each parameter follows:
73 %
74 %    o image_info: the image info.
75 %
76 %    o argc: the number of elements in the argument vector.
77 %
78 %    o argv: A text array containing the command line arguments.
79 %
80 %    o metadata: any metadata is returned here.
81 %
82 %    o exception: return any errors or warnings in this structure.
83 %
84 %
85 */
86
87 static MagickBooleanType StreamUsage(void)
88 {
89   const char
90     **p;
91
92   static const char
93     *miscellaneous[]=
94     {
95       "-debug events        display copious debugging information",
96       "-help                print program options",
97       "-list type           print a list of supported option arguments",
98       "-log format          format of debugging information",
99       "-version             print version information",
100       (char *) NULL
101     },
102     *settings[]=
103     {
104       "-authenticate password",
105       "                     decipher image with this password",
106       "-channel type        apply option to select image channels",
107       "-colorspace type     alternate image colorspace",
108       "-compress type       type of pixel compression when writing the image",
109       "-define format:option",
110       "                     define one or more image format options",
111       "-density geometry    horizontal and vertical density of the image",
112       "-depth value         image depth",
113       "-extract geometry    extract area from image",
114       "-identify            identify the format and characteristics of the image",
115       "-interlace type      type of image interlacing scheme",
116       "-interpolate method  pixel color interpolation method",
117       "-limit type value    pixel cache resource limit",
118       "-map components      one or more pixel components",
119       "-monitor             monitor progress",
120       "-quantize colorspace reduce colors in this colorspace",
121       "-quiet               suppress all warning messages",
122       "-regard-warnings     pay attention to warning messages",
123       "-respect-parentheses settings remain in effect until parenthesis boundary",
124       "-sampling-factor geometry",
125       "                     horizontal and vertical sampling factor",
126       "-seed value          seed a new sequence of pseudo-random numbers",
127       "-set attribute value set an image attribute",
128       "-size geometry       width and height of image",
129       "-storage-type type   pixel storage type",
130       "-synchronize         synchronize image to storage device",
131       "-taint               declare the image as modified",
132       "-transparent-color color",
133       "                     transparent color",
134       "-verbose             print detailed information about the image",
135       "-virtual-pixel method",
136       "                     virtual pixel access method",
137       (char *) NULL
138     };
139
140   (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
141   (void) printf("Copyright: %s\n",GetMagickCopyright());
142   (void) printf("Features: %s\n\n",GetMagickFeatures());
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   ssize_t
203     j,
204     k;
205
206   MagickBooleanType
207     fire,
208     pend;
209
210   MagickStatusType
211     status;
212
213   register ssize_t
214     i;
215
216   StreamInfo
217     *stream_info;
218
219   /*
220     Set defaults.
221   */
222   assert(image_info != (ImageInfo *) NULL);
223   assert(image_info->signature == MagickSignature);
224   if (image_info->debug != MagickFalse)
225     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
226   assert(exception != (ExceptionInfo *) NULL);
227   (void) metadata;
228   if (argc == 2)
229     {
230       option=argv[1];
231       if ((LocaleCompare("version",option+1) == 0) ||
232           (LocaleCompare("-version",option+1) == 0))
233         {
234           (void) fprintf(stdout,"Version: %s\n",
235             GetMagickVersion((size_t *) NULL));
236           (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
237           (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
238           return(MagickFalse);
239         }
240     }
241   if (argc < 3)
242     return(StreamUsage());
243   format="%w,%h,%m";
244   j=1;
245   k=0;
246   NewImageStack();
247   option=(char *) NULL;
248   pend=MagickFalse;
249   stream_info=AcquireStreamInfo(image_info);
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 (IsMagickOption(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,MaxTextExtent);
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-1))
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-1))
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-1))
359               ThrowStreamException(OptionError,"MissingArgument",option);
360             colorspace=ParseMagickOption(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-1))
376               ThrowStreamException(OptionError,"MissingArgument",option);
377             compress=ParseMagickOption(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=ParseMagickOption(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-1))
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-1))
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=ParseMagickOption(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=ParseMagickOption(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=ParseMagickOption(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=strtod(argv[i],&p);
547             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
548               ThrowStreamInvalidArgumentException(option,argv[i]);
549             break;
550           }
551         if (LocaleCompare("list",option+1) == 0)
552           {
553             ssize_t
554               list;
555
556             if (*option == '+')
557               break;
558             i++;
559             if (i == (ssize_t) argc)
560               ThrowStreamException(OptionError,"MissingArgument",option);
561             list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
562             if (list < 0)
563               ThrowStreamException(OptionError,"UnrecognizedListType",argv[i]);
564             status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
565               argv+j,exception);
566             DestroyStream();
567             return(status != 0 ? MagickFalse : MagickTrue);
568           }
569         if (LocaleCompare("log",option+1) == 0)
570           {
571             if (*option == '+')
572               break;
573             i++;
574             if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL))
575               ThrowStreamException(OptionError,"MissingArgument",option);
576             break;
577           }
578         ThrowStreamException(OptionError,"UnrecognizedOption",option)
579       }
580       case 'm':
581       {
582         if (LocaleCompare("map",option+1) == 0)
583           {
584             (void) CopyMagickString(argv[i]+1,"san",MaxTextExtent);
585             if (*option == '+')
586               break;
587             i++;
588             SetStreamInfoMap(stream_info,argv[i]);
589             break;
590           }
591         if (LocaleCompare("monitor",option+1) == 0)
592           break;
593         ThrowStreamException(OptionError,"UnrecognizedOption",option)
594       }
595       case 'q':
596       {
597         if (LocaleCompare("quantize",option+1) == 0)
598           {
599             ssize_t
600               colorspace;
601
602             if (*option == '+')
603               break;
604             i++;
605             if (i == (ssize_t) (argc-1))
606               ThrowStreamException(OptionError,"MissingArgument",option);
607             colorspace=ParseMagickOption(MagickColorspaceOptions,
608               MagickFalse,argv[i]);
609             if (colorspace < 0)
610               ThrowStreamException(OptionError,"UnrecognizedColorspace",
611                 argv[i]);
612             break;
613           }
614         if (LocaleCompare("quiet",option+1) == 0)
615           break;
616         ThrowStreamException(OptionError,"UnrecognizedOption",option)
617       }
618       case 'r':
619       {
620         if (LocaleCompare("regard-warnings",option+1) == 0)
621           break;
622         if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
623           {
624             respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
625             break;
626           }
627         ThrowStreamException(OptionError,"UnrecognizedOption",option)
628       }
629       case 's':
630       {
631         if (LocaleCompare("sampling-factor",option+1) == 0)
632           {
633             if (*option == '+')
634               break;
635             i++;
636             if (i == (ssize_t) argc)
637               ThrowStreamException(OptionError,"MissingArgument",option);
638             if (IsGeometry(argv[i]) == MagickFalse)
639               ThrowStreamInvalidArgumentException(option,argv[i]);
640             break;
641           }
642         if (LocaleCompare("seed",option+1) == 0)
643           {
644             if (*option == '+')
645               break;
646             i++;
647             if (i == (ssize_t) (argc-1))
648               ThrowStreamException(OptionError,"MissingArgument",option);
649             if (IsGeometry(argv[i]) == MagickFalse)
650               ThrowStreamInvalidArgumentException(option,argv[i]);
651             break;
652           }
653         if (LocaleCompare("set",option+1) == 0)
654           {
655             i++;
656             if (i == (ssize_t) argc)
657               ThrowStreamException(OptionError,"MissingArgument",option);
658             if (*option == '+')
659               break;
660             i++;
661             if (i == (ssize_t) argc)
662               ThrowStreamException(OptionError,"MissingArgument",option);
663             break;
664           }
665         if (LocaleCompare("size",option+1) == 0)
666           {
667             if (*option == '+')
668               break;
669             i++;
670             if (i == (ssize_t) argc)
671               ThrowStreamException(OptionError,"MissingArgument",option);
672             if (IsGeometry(argv[i]) == MagickFalse)
673               ThrowStreamInvalidArgumentException(option,argv[i]);
674             break;
675           }
676         if (LocaleCompare("storage-type",option+1) == 0)
677           {
678             ssize_t
679               type;
680
681             if (*option == '+')
682               break;
683             i++;
684             if (i == (ssize_t) (argc-1))
685               ThrowStreamException(OptionError,"MissingArgument",option);
686             type=ParseMagickOption(MagickStorageOptions,MagickFalse,argv[i]);
687             if (type < 0)
688               ThrowStreamException(OptionError,"UnrecognizedStorageType",
689                 argv[i]);
690             SetStreamInfoStorageType(stream_info,(StorageType) type);
691             break;
692           }
693         if (LocaleCompare("synchronize",option+1) == 0)
694           break;
695         ThrowStreamException(OptionError,"UnrecognizedOption",option)
696       }
697       case 't':
698       {
699         if (LocaleCompare("taint",option+1) == 0)
700           break;
701         if (LocaleCompare("transparent-color",option+1) == 0)
702           {
703             if (*option == '+')
704               break;
705             i++;
706             if (i == (ssize_t) (argc-1))
707               ThrowStreamException(OptionError,"MissingArgument",option);
708             break;
709           }
710         ThrowStreamException(OptionError,"UnrecognizedOption",option)
711       }
712       case 'v':
713       {
714         if (LocaleCompare("verbose",option+1) == 0)
715           break;
716         if ((LocaleCompare("version",option+1) == 0) ||
717             (LocaleCompare("-version",option+1) == 0))
718           {
719             (void) fprintf(stdout,"Version: %s\n",
720               GetMagickVersion((size_t *) NULL));
721             (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
722             (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
723             break;
724           }
725         if (LocaleCompare("virtual-pixel",option+1) == 0)
726           {
727             ssize_t
728               method;
729
730             if (*option == '+')
731               break;
732             i++;
733             if (i == (ssize_t) (argc-1))
734               ThrowStreamException(OptionError,"MissingArgument",option);
735             method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
736               argv[i]);
737             if (method < 0)
738               ThrowStreamException(OptionError,
739                 "UnrecognizedVirtualPixelMethod",argv[i]);
740             break;
741           }
742         ThrowStreamException(OptionError,"UnrecognizedOption",option)
743       }
744       case '?':
745         break;
746       default:
747         ThrowStreamException(OptionError,"UnrecognizedOption",option)
748     }
749     fire=ParseMagickOption(MagickImageListOptions,MagickFalse,option+1) < 0 ?
750       MagickFalse : MagickTrue;
751     if (fire != MagickFalse)
752       FireImageStack(MagickFalse,MagickTrue,MagickTrue);
753   }
754   if (k != 0)
755     ThrowStreamException(OptionError,"UnbalancedParenthesis",argv[i]);
756   if (i-- != (ssize_t) (argc-1))
757     ThrowStreamException(OptionError,"MissingAnImageFilename",argv[i]);
758   if (image == (Image *) NULL)
759     ThrowStreamException(OptionError,"MissingAnImageFilename",argv[i]);
760   FinalizeImageSettings(image_info,image,MagickTrue);
761   if (image == (Image *) NULL)
762     ThrowStreamException(OptionError,"MissingAnImageFilename",argv[i]);
763   DestroyStream();
764   return(status != 0 ? MagickTrue : MagickFalse);
765 }