cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % IIIII DDDD EEEEE N N TTTTT IIIII FFFFF Y Y % |
| 7 | % I D D E NN N T I F Y Y % |
| 8 | % I D D EEE N N N T I FFF Y % |
| 9 | % I D D E N NN T I F Y % |
| 10 | % IIIII DDDD EEEEE N N T IIIII F Y % |
| 11 | % % |
| 12 | % % |
| 13 | % Identify an Image Format and Characteristics. % |
| 14 | % % |
| 15 | % Software Design % |
cristy | de984cd | 2013-12-01 14:49:27 +0000 | [diff] [blame] | 16 | % Cristy % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 17 | % September 1994 % |
| 18 | % % |
| 19 | % % |
Cristy | 7ce65e7 | 2015-12-12 18:03:16 -0500 | [diff] [blame] | 20 | % Copyright 1999-2016 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 | % The identify program describes the format and characteristics of one or more |
| 37 | % image files. It also reports if an image is incomplete or corrupt. The |
| 38 | % information returned includes the image number, the file name, the width and |
| 39 | % height of the image, whether the image is colormapped or not, the number of |
| 40 | % colors in the image, the number of bytes in the image, the format of the |
| 41 | % image (JPEG, PNM, etc.), and finally the number of seconds it took to read |
| 42 | % and process the image. Many more attributes are available with the verbose |
| 43 | % option. |
| 44 | % |
| 45 | */ |
| 46 | |
| 47 | /* |
| 48 | Include declarations. |
| 49 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 50 | #include "MagickWand/studio.h" |
| 51 | #include "MagickWand/MagickWand.h" |
| 52 | #include "MagickWand/mogrify-private.h" |
cristy | 196372d | 2011-11-05 00:07:32 +0000 | [diff] [blame] | 53 | #include "MagickCore/string-private.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 54 | |
| 55 | /* |
| 56 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 57 | % % |
| 58 | % % |
| 59 | % % |
| 60 | + I d e n t i f y I m a g e C o m m a n d % |
| 61 | % % |
| 62 | % % |
| 63 | % % |
| 64 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 65 | % |
| 66 | % IdentifyImageCommand() describes the format and characteristics of one or |
| 67 | % more image files. It will also report if an image is incomplete or corrupt. |
| 68 | % The information displayed includes the scene number, the file name, the |
| 69 | % width and height of the image, whether the image is colormapped or not, |
| 70 | % the number of colors in the image, the number of bytes in the image, the |
| 71 | % format of the image (JPEG, PNM, etc.), and finally the number of seconds |
| 72 | % it took to read and process the image. |
| 73 | % |
| 74 | % The format of the IdentifyImageCommand method is: |
| 75 | % |
| 76 | % MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,int argc, |
| 77 | % char **argv,char **metadata,ExceptionInfo *exception) |
| 78 | % |
| 79 | % A description of each parameter follows: |
| 80 | % |
| 81 | % o image_info: the image info. |
| 82 | % |
| 83 | % o argc: the number of elements in the argument vector. |
| 84 | % |
| 85 | % o argv: A text array containing the command line arguments. |
| 86 | % |
| 87 | % o metadata: any metadata is returned here. |
| 88 | % |
| 89 | % o exception: return any errors or warnings in this structure. |
| 90 | % |
| 91 | */ |
| 92 | |
| 93 | static MagickBooleanType IdentifyUsage(void) |
| 94 | { |
| 95 | const char |
| 96 | **p; |
| 97 | |
| 98 | static const char |
| 99 | *miscellaneous[]= |
| 100 | { |
| 101 | "-debug events display copious debugging information", |
| 102 | "-help print program options", |
| 103 | "-list type print a list of supported option arguments", |
| 104 | "-log format format of debugging information", |
| 105 | "-version print version information", |
| 106 | (char *) NULL |
| 107 | }, |
cristy | e48c6a9 | 2010-02-01 01:25:42 +0000 | [diff] [blame] | 108 | *operators[]= |
| 109 | { |
cristy | 17ada02 | 2014-11-07 22:12:23 +0000 | [diff] [blame] | 110 | "-channel mask set the image channel mask", |
cristy | 0a09e9d | 2013-09-01 19:08:23 +0000 | [diff] [blame] | 111 | "-grayscale method convert image to grayscale", |
cristy | e48c6a9 | 2010-02-01 01:25:42 +0000 | [diff] [blame] | 112 | "-negate replace every pixel with its complementary color ", |
| 113 | (char *) NULL |
| 114 | }, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 115 | *settings[]= |
| 116 | { |
| 117 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 118 | " transparent, extract, background, or shape", |
| 119 | "-antialias remove pixel-aliasing", |
| 120 | "-authenticate password", |
| 121 | " decipher image with this password", |
cristy | 1e61810 | 2013-03-17 14:52:31 +0000 | [diff] [blame] | 122 | "-clip clip along the first path from the 8BIM profile", |
| 123 | "-clip-mask filename associate a clip mask with the image", |
| 124 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 125 | "-colorspace type alternate image colorspace", |
| 126 | "-crop geometry cut out a rectangular region of the image", |
| 127 | "-define format:option", |
| 128 | " define one or more image format options", |
| 129 | "-density geometry horizontal and vertical density of the image", |
| 130 | "-depth value image depth", |
cristy | 605e80d | 2012-09-12 11:34:39 +0000 | [diff] [blame] | 131 | "-endian type endianness (MSB or LSB) of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 132 | "-extract geometry extract area from image", |
cristy | 1415422 | 2012-06-15 23:21:49 +0000 | [diff] [blame] | 133 | "-features distance analyze image features (e.g. contrast, correlation)", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 134 | "-format \"string\" output formatted image characteristics", |
| 135 | "-fuzz distance colors within this distance are considered equal", |
cristy | cd483f1 | 2010-01-26 15:30:08 +0000 | [diff] [blame] | 136 | "-gamma value of gamma correction", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 137 | "-interlace type type of image interlacing scheme", |
| 138 | "-interpolate method pixel color interpolation method", |
| 139 | "-limit type value pixel cache resource limit", |
cristy | e9252c2 | 2013-07-30 15:43:21 +0000 | [diff] [blame] | 140 | "-matte store matte channel if the image has one", |
cristy | bd4a3c2 | 2014-01-07 15:09:37 +0000 | [diff] [blame] | 141 | "-moments report image moments", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 142 | "-monitor monitor progress", |
| 143 | "-ping efficiently determine image attributes", |
cristy | a1b1486 | 2013-09-01 23:53:47 +0000 | [diff] [blame] | 144 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 145 | "-quiet suppress all warning messages", |
cristy | 327030c | 2015-07-25 18:05:50 +0000 | [diff] [blame] | 146 | "-read-mask filename associate a read mask with the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 147 | "-regard-warnings pay attention to warning messages", |
| 148 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 149 | "-sampling-factor geometry", |
| 150 | " horizontal and vertical sampling factor", |
| 151 | "-seed value seed a new sequence of pseudo-random numbers", |
| 152 | "-set attribute value set an image attribute", |
| 153 | "-size geometry width and height of image", |
| 154 | "-strip strip image of all profiles and comments", |
cristy | 045bd90 | 2010-01-30 18:56:24 +0000 | [diff] [blame] | 155 | "-unique display the number of unique colors in the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 156 | "-units type the units of image resolution", |
| 157 | "-verbose print detailed information about the image", |
| 158 | "-virtual-pixel method", |
| 159 | " virtual pixel access method", |
| 160 | (char *) NULL |
| 161 | }; |
| 162 | |
cristy | 4f7a613 | 2012-12-23 00:35:19 +0000 | [diff] [blame] | 163 | ListMagickVersion(stdout); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 164 | (void) printf("Usage: %s [options ...] file [ [options ...] " |
| 165 | "file ... ]\n",GetClientName()); |
| 166 | (void) printf("\nImage Settings:\n"); |
| 167 | for (p=settings; *p != (char *) NULL; p++) |
| 168 | (void) printf(" %s\n",*p); |
cristy | e48c6a9 | 2010-02-01 01:25:42 +0000 | [diff] [blame] | 169 | (void) printf("\nImage Operators:\n"); |
| 170 | for (p=operators; *p != (char *) NULL; p++) |
| 171 | (void) printf(" %s\n",*p); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 172 | (void) printf("\nMiscellaneous Options:\n"); |
| 173 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 174 | (void) printf(" %s\n",*p); |
| 175 | (void) printf( |
anthony | e5b3965 | 2012-04-21 05:37:29 +0000 | [diff] [blame] | 176 | "\nBy default, the image format of 'file' is determined by its magic\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 177 | (void) printf( |
| 178 | "number. To specify a particular image format, precede the filename\n"); |
| 179 | (void) printf( |
| 180 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 181 | (void) printf( |
| 182 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 183 | (void) printf("'-' for standard input or output.\n"); |
| 184 | return(MagickFalse); |
| 185 | } |
| 186 | |
| 187 | WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info, |
| 188 | int argc,char **argv,char **metadata,ExceptionInfo *exception) |
| 189 | { |
| 190 | #define DestroyIdentify() \ |
| 191 | { \ |
| 192 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 193 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 194 | argv[i]=DestroyString(argv[i]); \ |
| 195 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 196 | } |
| 197 | #define ThrowIdentifyException(asperity,tag,option) \ |
| 198 | { \ |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 199 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 200 | option); \ |
| 201 | DestroyIdentify(); \ |
| 202 | return(MagickFalse); \ |
| 203 | } |
| 204 | #define ThrowIdentifyInvalidArgumentException(option,argument) \ |
| 205 | { \ |
| 206 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
anthony | e5b3965 | 2012-04-21 05:37:29 +0000 | [diff] [blame] | 207 | "InvalidArgument","'%s': %s",option,argument); \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 208 | DestroyIdentify(); \ |
| 209 | return(MagickFalse); \ |
| 210 | } |
| 211 | |
| 212 | const char |
| 213 | *format, |
| 214 | *option; |
| 215 | |
| 216 | Image |
| 217 | *image; |
| 218 | |
| 219 | ImageStack |
| 220 | image_stack[MaxImageStackDepth+1]; |
| 221 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 222 | MagickBooleanType |
| 223 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 224 | pend, |
| 225 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 226 | |
| 227 | MagickStatusType |
| 228 | status; |
| 229 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 230 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 231 | i; |
| 232 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 233 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 234 | count; |
| 235 | |
cristy | 9d314ff | 2011-03-09 01:30:28 +0000 | [diff] [blame] | 236 | ssize_t |
| 237 | j, |
| 238 | k; |
| 239 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 240 | /* |
| 241 | Set defaults. |
| 242 | */ |
| 243 | assert(image_info != (ImageInfo *) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 244 | assert(image_info->signature == MagickCoreSignature); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 245 | if (image_info->debug != MagickFalse) |
| 246 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 247 | assert(exception != (ExceptionInfo *) NULL); |
| 248 | if (argc == 2) |
| 249 | { |
| 250 | option=argv[1]; |
| 251 | if ((LocaleCompare("version",option+1) == 0) || |
| 252 | (LocaleCompare("-version",option+1) == 0)) |
| 253 | { |
cristy | 4f7a613 | 2012-12-23 00:35:19 +0000 | [diff] [blame] | 254 | ListMagickVersion(stdout); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 255 | return(MagickFalse); |
| 256 | } |
| 257 | } |
| 258 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 259 | return(IdentifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 260 | count=0; |
| 261 | format=NULL; |
| 262 | j=1; |
| 263 | k=0; |
| 264 | NewImageStack(); |
| 265 | option=(char *) NULL; |
| 266 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 267 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 268 | status=MagickTrue; |
| 269 | /* |
| 270 | Identify an image. |
| 271 | */ |
| 272 | ReadCommandlLine(argc,&argv); |
| 273 | status=ExpandFilenames(&argc,&argv); |
| 274 | if (status == MagickFalse) |
| 275 | ThrowIdentifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 276 | GetExceptionMessage(errno)); |
| 277 | image_info->ping=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 278 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 279 | { |
| 280 | option=argv[i]; |
| 281 | if (LocaleCompare(option,"(") == 0) |
| 282 | { |
| 283 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 284 | if (k == MaxImageStackDepth) |
| 285 | ThrowIdentifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 286 | option); |
| 287 | PushImageStack(); |
| 288 | continue; |
| 289 | } |
| 290 | if (LocaleCompare(option,")") == 0) |
| 291 | { |
| 292 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 293 | if (k == 0) |
| 294 | ThrowIdentifyException(OptionError,"UnableToParseExpression",option); |
| 295 | PopImageStack(); |
| 296 | continue; |
| 297 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 298 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 299 | { |
| 300 | char |
| 301 | *filename; |
| 302 | |
| 303 | Image |
| 304 | *images; |
| 305 | |
| 306 | ImageInfo |
| 307 | *identify_info; |
| 308 | |
| 309 | /* |
| 310 | Read input image. |
| 311 | */ |
| 312 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 313 | identify_info=CloneImageInfo(image_info); |
| 314 | identify_info->verbose=MagickFalse; |
| 315 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 316 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 317 | filename=argv[++i]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 318 | if (identify_info->ping != MagickFalse) |
cristy | 1b58f25 | 2012-03-01 01:41:41 +0000 | [diff] [blame] | 319 | images=PingImages(identify_info,filename,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 320 | else |
cristy | 1b58f25 | 2012-03-01 01:41:41 +0000 | [diff] [blame] | 321 | images=ReadImages(identify_info,filename,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 322 | identify_info=DestroyImageInfo(identify_info); |
| 323 | status&=(images != (Image *) NULL) && |
| 324 | (exception->severity < ErrorException); |
| 325 | if (images == (Image *) NULL) |
| 326 | continue; |
| 327 | AppendImageStack(images); |
| 328 | FinalizeImageSettings(image_info,image,MagickFalse); |
dirk | 0ccbde8 | 2015-10-09 08:59:31 +0200 | [diff] [blame] | 329 | count=0; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 330 | for ( ; image != (Image *) NULL; image=GetNextImageInList(image)) |
| 331 | { |
| 332 | if (image->scene == 0) |
| 333 | image->scene=count++; |
| 334 | if (format == (char *) NULL) |
| 335 | { |
cristy | a403727 | 2011-08-28 15:11:39 +0000 | [diff] [blame] | 336 | (void) IdentifyImage(image,stdout,image_info->verbose,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 337 | continue; |
| 338 | } |
| 339 | if (metadata != (char **) NULL) |
| 340 | { |
| 341 | char |
| 342 | *text; |
| 343 | |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 344 | text=InterpretImageProperties(image_info,image,format,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 345 | if (text == (char *) NULL) |
| 346 | ThrowIdentifyException(ResourceLimitError, |
| 347 | "MemoryAllocationFailed",GetExceptionMessage(errno)); |
| 348 | (void) ConcatenateString(&(*metadata),text); |
| 349 | text=DestroyString(text); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 350 | } |
| 351 | } |
| 352 | RemoveAllImageStack(); |
| 353 | continue; |
| 354 | } |
| 355 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 356 | switch (*(option+1)) |
| 357 | { |
| 358 | case 'a': |
| 359 | { |
| 360 | if (LocaleCompare("alpha",option+1) == 0) |
| 361 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 362 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 363 | type; |
| 364 | |
| 365 | if (*option == '+') |
| 366 | break; |
| 367 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 368 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 369 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
cristy | 77ffd93 | 2012-09-05 11:19:57 +0000 | [diff] [blame] | 370 | type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse, |
| 371 | argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 372 | if (type < 0) |
cristy | 77ffd93 | 2012-09-05 11:19:57 +0000 | [diff] [blame] | 373 | ThrowIdentifyException(OptionError, |
| 374 | "UnrecognizedAlphaChannelOption",argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 375 | break; |
| 376 | } |
| 377 | if (LocaleCompare("antialias",option+1) == 0) |
| 378 | break; |
| 379 | if (LocaleCompare("authenticate",option+1) == 0) |
| 380 | { |
| 381 | if (*option == '+') |
| 382 | break; |
| 383 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 384 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 385 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 386 | break; |
| 387 | } |
| 388 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
| 389 | } |
| 390 | case 'c': |
| 391 | { |
| 392 | if (LocaleCompare("cache",option+1) == 0) |
| 393 | { |
| 394 | if (*option == '+') |
| 395 | break; |
| 396 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 397 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 398 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 399 | if (IsGeometry(argv[i]) == MagickFalse) |
| 400 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
| 401 | break; |
| 402 | } |
| 403 | if (LocaleCompare("channel",option+1) == 0) |
| 404 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 405 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 406 | channel; |
| 407 | |
| 408 | if (*option == '+') |
| 409 | break; |
| 410 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 411 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 412 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 413 | channel=ParseChannelOption(argv[i]); |
| 414 | if (channel < 0) |
| 415 | ThrowIdentifyException(OptionError,"UnrecognizedChannelType", |
| 416 | argv[i]); |
| 417 | break; |
| 418 | } |
cristy | 1e61810 | 2013-03-17 14:52:31 +0000 | [diff] [blame] | 419 | if (LocaleCompare("clip",option+1) == 0) |
| 420 | break; |
| 421 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 422 | { |
| 423 | if (*option == '+') |
| 424 | break; |
| 425 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 426 | if (i == (ssize_t) argc) |
cristy | 1e61810 | 2013-03-17 14:52:31 +0000 | [diff] [blame] | 427 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 428 | break; |
| 429 | } |
| 430 | if (LocaleCompare("clip-path",option+1) == 0) |
| 431 | { |
| 432 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 433 | if (i == (ssize_t) argc) |
cristy | 1e61810 | 2013-03-17 14:52:31 +0000 | [diff] [blame] | 434 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 435 | break; |
| 436 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 437 | if (LocaleCompare("colorspace",option+1) == 0) |
| 438 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 439 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 440 | colorspace; |
| 441 | |
| 442 | if (*option == '+') |
| 443 | break; |
| 444 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 445 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 446 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 447 | colorspace=ParseCommandOption(MagickColorspaceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 448 | MagickFalse,argv[i]); |
| 449 | if (colorspace < 0) |
| 450 | ThrowIdentifyException(OptionError,"UnrecognizedColorspace", |
| 451 | argv[i]); |
| 452 | break; |
| 453 | } |
| 454 | if (LocaleCompare("crop",option+1) == 0) |
| 455 | { |
| 456 | if (*option == '+') |
| 457 | break; |
| 458 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 459 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 460 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 461 | if (IsGeometry(argv[i]) == MagickFalse) |
| 462 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
| 463 | image_info->ping=MagickFalse; |
| 464 | break; |
| 465 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 466 | if (LocaleCompare("concurrent",option+1) == 0) |
| 467 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 468 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
| 469 | } |
| 470 | case 'd': |
| 471 | { |
| 472 | if (LocaleCompare("debug",option+1) == 0) |
| 473 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 474 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 475 | event; |
| 476 | |
| 477 | if (*option == '+') |
| 478 | break; |
| 479 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 480 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 481 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 482 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 483 | if (event < 0) |
| 484 | ThrowIdentifyException(OptionError,"UnrecognizedEventType", |
| 485 | argv[i]); |
| 486 | (void) SetLogEventMask(argv[i]); |
| 487 | break; |
| 488 | } |
| 489 | if (LocaleCompare("define",option+1) == 0) |
| 490 | { |
| 491 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 492 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 493 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 494 | if (*option == '+') |
| 495 | { |
| 496 | const char |
| 497 | *define; |
| 498 | |
| 499 | define=GetImageOption(image_info,argv[i]); |
| 500 | if (define == (const char *) NULL) |
| 501 | ThrowIdentifyException(OptionError,"NoSuchOption",argv[i]); |
| 502 | break; |
| 503 | } |
cristy | fc0f4c5 | 2014-02-12 23:47:26 +0000 | [diff] [blame] | 504 | if (LocaleNCompare("identify:locate",argv[i],15) == 0) |
cristy | 7d8529e | 2013-09-01 17:03:36 +0000 | [diff] [blame] | 505 | image_info->ping=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 506 | break; |
| 507 | } |
| 508 | if (LocaleCompare("density",option+1) == 0) |
| 509 | { |
| 510 | if (*option == '+') |
| 511 | break; |
| 512 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 513 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 514 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 515 | if (IsGeometry(argv[i]) == MagickFalse) |
| 516 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
| 517 | break; |
| 518 | } |
| 519 | if (LocaleCompare("depth",option+1) == 0) |
| 520 | { |
| 521 | if (*option == '+') |
| 522 | break; |
| 523 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 524 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 525 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 526 | if (IsGeometry(argv[i]) == MagickFalse) |
| 527 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
| 528 | break; |
| 529 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 530 | if (LocaleCompare("duration",option+1) == 0) |
| 531 | { |
| 532 | if (*option == '+') |
| 533 | break; |
| 534 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 535 | if (i == (ssize_t) argc) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 536 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 537 | if (IsGeometry(argv[i]) == MagickFalse) |
| 538 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
| 539 | break; |
| 540 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 541 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
| 542 | } |
cristy | 1e61810 | 2013-03-17 14:52:31 +0000 | [diff] [blame] | 543 | case 'e': |
cristy | 605e80d | 2012-09-12 11:34:39 +0000 | [diff] [blame] | 544 | { |
| 545 | if (LocaleCompare("endian",option+1) == 0) |
| 546 | { |
| 547 | ssize_t |
| 548 | endian; |
| 549 | |
| 550 | if (*option == '+') |
| 551 | break; |
| 552 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 553 | if (i == (ssize_t) argc) |
cristy | 605e80d | 2012-09-12 11:34:39 +0000 | [diff] [blame] | 554 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 555 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse, |
| 556 | argv[i]); |
| 557 | if (endian < 0) |
| 558 | ThrowIdentifyException(OptionError,"UnrecognizedEndianType", |
| 559 | argv[i]); |
| 560 | break; |
| 561 | } |
| 562 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
| 563 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 564 | case 'f': |
| 565 | { |
cristy | 549a37e | 2010-01-26 15:24:15 +0000 | [diff] [blame] | 566 | if (LocaleCompare("features",option+1) == 0) |
cristy | cd483f1 | 2010-01-26 15:30:08 +0000 | [diff] [blame] | 567 | { |
| 568 | if (*option == '+') |
| 569 | break; |
| 570 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 571 | if (i == (ssize_t) argc) |
cristy | cd483f1 | 2010-01-26 15:30:08 +0000 | [diff] [blame] | 572 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 573 | if (IsGeometry(argv[i]) == MagickFalse) |
| 574 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
| 575 | break; |
| 576 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 577 | if (LocaleCompare("format",option+1) == 0) |
| 578 | { |
| 579 | format=(char *) NULL; |
| 580 | if (*option == '+') |
| 581 | break; |
| 582 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 583 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 584 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 585 | format=argv[i]; |
| 586 | break; |
| 587 | } |
| 588 | if (LocaleCompare("fuzz",option+1) == 0) |
| 589 | { |
| 590 | if (*option == '+') |
| 591 | break; |
| 592 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 593 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 594 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 595 | if (IsGeometry(argv[i]) == MagickFalse) |
| 596 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
| 597 | break; |
| 598 | } |
| 599 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
| 600 | } |
| 601 | case 'g': |
| 602 | { |
| 603 | if (LocaleCompare("gamma",option+1) == 0) |
| 604 | { |
| 605 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 606 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 607 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 608 | if (IsGeometry(argv[i]) == MagickFalse) |
| 609 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
| 610 | break; |
| 611 | } |
cristy | 0a09e9d | 2013-09-01 19:08:23 +0000 | [diff] [blame] | 612 | if (LocaleCompare("grayscale",option+1) == 0) |
| 613 | { |
| 614 | ssize_t |
| 615 | method; |
| 616 | |
| 617 | if (*option == '+') |
| 618 | break; |
| 619 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 620 | if (i == (ssize_t) argc) |
cristy | 0a09e9d | 2013-09-01 19:08:23 +0000 | [diff] [blame] | 621 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 622 | method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse, |
| 623 | argv[i]); |
| 624 | if (method < 0) |
| 625 | ThrowIdentifyException(OptionError,"UnrecognizedIntensityMethod", |
| 626 | argv[i]); |
| 627 | break; |
| 628 | } |
| 629 | if (LocaleCompare("green-primary",option+1) == 0) |
| 630 | { |
| 631 | if (*option == '+') |
| 632 | break; |
| 633 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 634 | if (i == (ssize_t) argc) |
cristy | 0a09e9d | 2013-09-01 19:08:23 +0000 | [diff] [blame] | 635 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 636 | if (IsGeometry(argv[i]) == MagickFalse) |
| 637 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
| 638 | break; |
| 639 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 640 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
| 641 | } |
| 642 | case 'h': |
| 643 | { |
| 644 | if ((LocaleCompare("help",option+1) == 0) || |
| 645 | (LocaleCompare("-help",option+1) == 0)) |
| 646 | return(IdentifyUsage()); |
| 647 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
| 648 | } |
| 649 | case 'i': |
| 650 | { |
| 651 | if (LocaleCompare("interlace",option+1) == 0) |
| 652 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 653 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 654 | interlace; |
| 655 | |
| 656 | if (*option == '+') |
| 657 | break; |
| 658 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 659 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 660 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 661 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 662 | argv[i]); |
| 663 | if (interlace < 0) |
| 664 | ThrowIdentifyException(OptionError, |
| 665 | "UnrecognizedInterlaceType",argv[i]); |
| 666 | break; |
| 667 | } |
| 668 | if (LocaleCompare("interpolate",option+1) == 0) |
| 669 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 670 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 671 | interpolate; |
| 672 | |
| 673 | if (*option == '+') |
| 674 | break; |
| 675 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 676 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 677 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 678 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 679 | argv[i]); |
| 680 | if (interpolate < 0) |
| 681 | ThrowIdentifyException(OptionError, |
| 682 | "UnrecognizedInterpolateMethod",argv[i]); |
| 683 | break; |
| 684 | } |
| 685 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
| 686 | } |
| 687 | case 'l': |
| 688 | { |
| 689 | if (LocaleCompare("limit",option+1) == 0) |
| 690 | { |
| 691 | char |
| 692 | *p; |
| 693 | |
| 694 | double |
| 695 | value; |
| 696 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 697 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 698 | resource; |
| 699 | |
| 700 | if (*option == '+') |
| 701 | break; |
| 702 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 703 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 704 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 705 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 706 | argv[i]); |
| 707 | if (resource < 0) |
| 708 | ThrowIdentifyException(OptionError,"UnrecognizedResourceType", |
| 709 | argv[i]); |
| 710 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 711 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 712 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 713 | value=StringToDouble(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 714 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 715 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 716 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
| 717 | break; |
| 718 | } |
| 719 | if (LocaleCompare("list",option+1) == 0) |
| 720 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 721 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 722 | list; |
| 723 | |
| 724 | if (*option == '+') |
| 725 | break; |
| 726 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 727 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 728 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 729 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 730 | if (list < 0) |
| 731 | ThrowIdentifyException(OptionError,"UnrecognizedListType", |
| 732 | argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 733 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 734 | argv+j,exception); |
| 735 | DestroyIdentify(); |
cristy | 32ce239 | 2014-09-24 19:08:53 +0000 | [diff] [blame] | 736 | return(status == 0 ? MagickTrue : MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 737 | } |
| 738 | if (LocaleCompare("log",option+1) == 0) |
| 739 | { |
| 740 | if (*option == '+') |
| 741 | break; |
| 742 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 743 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 744 | (strchr(argv[i],'%') == (char *) NULL)) |
| 745 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 746 | break; |
| 747 | } |
| 748 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
| 749 | } |
| 750 | case 'm': |
| 751 | { |
cristy | 5048d30 | 2012-08-07 01:05:16 +0000 | [diff] [blame] | 752 | if (LocaleCompare("mask",option+1) == 0) |
| 753 | { |
| 754 | if (*option == '+') |
| 755 | break; |
| 756 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 757 | if (i == (ssize_t) argc) |
cristy | 5048d30 | 2012-08-07 01:05:16 +0000 | [diff] [blame] | 758 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 759 | break; |
| 760 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 761 | if (LocaleCompare("matte",option+1) == 0) |
| 762 | break; |
cristy | e444b04 | 2014-01-07 15:28:15 +0000 | [diff] [blame] | 763 | if (LocaleCompare("moments",option+1) == 0) |
cristy | d12341f | 2014-01-07 15:34:13 +0000 | [diff] [blame] | 764 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 765 | if (LocaleCompare("monitor",option+1) == 0) |
| 766 | break; |
| 767 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
| 768 | } |
cristy | e48c6a9 | 2010-02-01 01:25:42 +0000 | [diff] [blame] | 769 | case 'n': |
| 770 | { |
| 771 | if (LocaleCompare("negate",option+1) == 0) |
| 772 | break; |
| 773 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
| 774 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 775 | case 'p': |
| 776 | { |
| 777 | if (LocaleCompare("ping",option+1) == 0) |
| 778 | break; |
cristy | a1b1486 | 2013-09-01 23:53:47 +0000 | [diff] [blame] | 779 | if (LocaleCompare("precision",option+1) == 0) |
| 780 | { |
| 781 | if (*option == '+') |
| 782 | break; |
| 783 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 784 | if (i == (ssize_t) argc) |
cristy | a1b1486 | 2013-09-01 23:53:47 +0000 | [diff] [blame] | 785 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 786 | if (IsGeometry(argv[i]) == MagickFalse) |
| 787 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
| 788 | break; |
| 789 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 790 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
| 791 | } |
| 792 | case 'q': |
| 793 | { |
| 794 | if (LocaleCompare("quiet",option+1) == 0) |
| 795 | break; |
| 796 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
| 797 | } |
| 798 | case 'r': |
| 799 | { |
| 800 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 801 | break; |
| 802 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 803 | { |
| 804 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 805 | break; |
| 806 | } |
| 807 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
| 808 | } |
| 809 | case 's': |
| 810 | { |
| 811 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 812 | { |
| 813 | if (*option == '+') |
| 814 | break; |
| 815 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 816 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 817 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 818 | if (IsGeometry(argv[i]) == MagickFalse) |
| 819 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
| 820 | break; |
| 821 | } |
| 822 | if (LocaleCompare("seed",option+1) == 0) |
| 823 | { |
| 824 | if (*option == '+') |
| 825 | break; |
| 826 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 827 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 828 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 829 | if (IsGeometry(argv[i]) == MagickFalse) |
| 830 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
| 831 | break; |
| 832 | } |
| 833 | if (LocaleCompare("set",option+1) == 0) |
| 834 | { |
| 835 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 836 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 837 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 838 | if (*option == '+') |
| 839 | break; |
| 840 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 841 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 842 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 843 | break; |
| 844 | } |
| 845 | if (LocaleCompare("size",option+1) == 0) |
| 846 | { |
| 847 | if (*option == '+') |
| 848 | break; |
| 849 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 850 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 851 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 852 | if (IsGeometry(argv[i]) == MagickFalse) |
| 853 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
| 854 | break; |
| 855 | } |
| 856 | if (LocaleCompare("strip",option+1) == 0) |
| 857 | break; |
| 858 | if (LocaleCompare("support",option+1) == 0) |
| 859 | { |
| 860 | if (*option == '+') |
| 861 | break; |
| 862 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 863 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 864 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
| 865 | if (IsGeometry(argv[i]) == MagickFalse) |
| 866 | ThrowIdentifyInvalidArgumentException(option,argv[i]); |
| 867 | break; |
| 868 | } |
| 869 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
| 870 | } |
| 871 | case 'u': |
| 872 | { |
cristy | 045bd90 | 2010-01-30 18:56:24 +0000 | [diff] [blame] | 873 | if (LocaleCompare("unique",option+1) == 0) |
| 874 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 875 | if (LocaleCompare("units",option+1) == 0) |
| 876 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 877 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 878 | units; |
| 879 | |
| 880 | if (*option == '+') |
| 881 | break; |
| 882 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 883 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 884 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 885 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 886 | argv[i]); |
| 887 | if (units < 0) |
| 888 | ThrowIdentifyException(OptionError,"UnrecognizedUnitsType", |
| 889 | argv[i]); |
| 890 | break; |
| 891 | } |
| 892 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
| 893 | } |
| 894 | case 'v': |
| 895 | { |
| 896 | if (LocaleCompare("verbose",option+1) == 0) |
| 897 | break; |
| 898 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 899 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 900 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 901 | method; |
| 902 | |
| 903 | if (*option == '+') |
| 904 | break; |
| 905 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 906 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 907 | ThrowIdentifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 908 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 909 | argv[i]); |
| 910 | if (method < 0) |
| 911 | ThrowIdentifyException(OptionError, |
| 912 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 913 | break; |
| 914 | } |
| 915 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
| 916 | } |
| 917 | case '?': |
| 918 | break; |
| 919 | default: |
| 920 | ThrowIdentifyException(OptionError,"UnrecognizedOption",option) |
| 921 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 922 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 923 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 924 | if (fire != MagickFalse) |
| 925 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 926 | } |
| 927 | if (k != 0) |
| 928 | ThrowIdentifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 929 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 930 | ThrowIdentifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 931 | DestroyIdentify(); |
| 932 | return(status != 0 ? MagickTrue : MagickFalse); |
| 933 | } |