| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | #include "wand/studio.h" |
|---|
| 45 | #include "wand/MagickWand.h" |
|---|
| 46 | #include "wand/mogrify-private.h" |
|---|
| 47 | #include "magick/xwindow-private.h" |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | static MagickBooleanType ImportUsage(void) |
|---|
| 93 | { |
|---|
| 94 | const char |
|---|
| 95 | **p; |
|---|
| 96 | |
|---|
| 97 | static const char |
|---|
| 98 | *miscellaneous[]= |
|---|
| 99 | { |
|---|
| 100 | "-debug events display copious debugging information", |
|---|
| 101 | "-help print program options", |
|---|
| 102 | "-list type print a list of supported option arguments", |
|---|
| 103 | "-log format format of debugging information", |
|---|
| 104 | "-version print version information", |
|---|
| 105 | (char *) NULL |
|---|
| 106 | }, |
|---|
| 107 | *operators[]= |
|---|
| 108 | { |
|---|
| 109 | "-annotate geometry text", |
|---|
| 110 | " annotate the image with text", |
|---|
| 111 | "-border include image borders in the output image", |
|---|
| 112 | "-colors value preferred number of colors in the image", |
|---|
| 113 | "-crop geometry preferred size and location of the cropped image", |
|---|
| 114 | "-encipher filename convert plain pixels to cipher pixels", |
|---|
| 115 | "-geometry geometry preferred size or location of the image", |
|---|
| 116 | "-help print program options", |
|---|
| 117 | "-monochrome transform image to black and white", |
|---|
| 118 | "-negate replace every pixel with its complementary color ", |
|---|
| 119 | "-repage geometry size and location of an image canvas", |
|---|
| 120 | "-quantize colorspace reduce colors in this colorspace", |
|---|
| 121 | "-resize geometry resize the image", |
|---|
| 122 | "-rotate degrees apply Paeth rotation to the image", |
|---|
| 123 | "-strip strip image of all profiles and comments", |
|---|
| 124 | "-thumbnail geometry create a thumbnail of the image", |
|---|
| 125 | "-transparent color make this color transparent within the image", |
|---|
| 126 | "-trim trim image edges", |
|---|
| 127 | "-type type image type", |
|---|
| 128 | (char *) NULL |
|---|
| 129 | }, |
|---|
| 130 | *settings[]= |
|---|
| 131 | { |
|---|
| 132 | "-adjoin join images into a single multi-image file", |
|---|
| 133 | "-channel type apply option to select image channels", |
|---|
| 134 | "-colorspace type alternate image colorspace", |
|---|
| 135 | "-comment string annotate image with comment", |
|---|
| 136 | "-compress type type of pixel compression when writing the image", |
|---|
| 137 | "-define format:option", |
|---|
| 138 | " define one or more image format options", |
|---|
| 139 | "-density geometry horizontal and vertical density of the image", |
|---|
| 140 | "-depth value image depth", |
|---|
| 141 | "-descend obtain image by descending window hierarchy", |
|---|
| 142 | "-display server X server to contact", |
|---|
| 143 | "-dispose method layer disposal method", |
|---|
| 144 | "-dither method apply error diffusion to image", |
|---|
| 145 | "-delay value display the next image after pausing", |
|---|
| 146 | "-encipher filename convert plain pixels to cipher pixels", |
|---|
| 147 | "-endian type endianness (MSB or LSB) of the image", |
|---|
| 148 | "-encoding type text encoding type", |
|---|
| 149 | "-filter type use this filter when resizing an image", |
|---|
| 150 | "-format \"string\" output formatted image characteristics", |
|---|
| 151 | "-frame include window manager frame", |
|---|
| 152 | "-gravity direction which direction to gravitate towards", |
|---|
| 153 | "-identify identify the format and characteristics of the image", |
|---|
| 154 | "-interlace type None, Line, Plane, or Partition", |
|---|
| 155 | "-interpolate method pixel color interpolation method", |
|---|
| 156 | "-label string assign a label to an image", |
|---|
| 157 | "-limit type value Area, Disk, Map, or Memory resource limit", |
|---|
| 158 | "-monitor monitor progress", |
|---|
| 159 | "-page geometry size and location of an image canvas", |
|---|
| 160 | "-pause value seconds delay between snapshots", |
|---|
| 161 | "-pointsize value font point size", |
|---|
| 162 | "-quality value JPEG/MIFF/PNG compression level", |
|---|
| 163 | "-quiet suppress all warning messages", |
|---|
| 164 | "-regard-warnings pay attention to warning messages", |
|---|
| 165 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
|---|
| 166 | "-sampling-factor geometry", |
|---|
| 167 | " horizontal and vertical sampling factor", |
|---|
| 168 | "-scene value image scene number", |
|---|
| 169 | "-screen select image from root window", |
|---|
| 170 | "-seed value seed a new sequence of pseudo-random numbers", |
|---|
| 171 | "-set property value set an image property", |
|---|
| 172 | "-silent operate silently, i.e. don't ring any bells ", |
|---|
| 173 | "-snaps value number of screen snapshots", |
|---|
| 174 | "-transparent-color color", |
|---|
| 175 | " transparent color", |
|---|
| 176 | "-treedepth value color tree depth", |
|---|
| 177 | "-verbose print detailed information about the image", |
|---|
| 178 | "-virtual-pixel method", |
|---|
| 179 | " Constant, Edge, Mirror, or Tile", |
|---|
| 180 | "-window id select window with this id or name", |
|---|
| 181 | (char *) NULL |
|---|
| 182 | }; |
|---|
| 183 | |
|---|
| 184 | (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL)); |
|---|
| 185 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
|---|
| 186 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
|---|
| 187 | (void) printf("Usage: %s [options ...] [ file ]\n", |
|---|
| 188 | GetClientName()); |
|---|
| 189 | (void) printf("\nImage Settings:\n"); |
|---|
| 190 | for (p=settings; *p != (char *) NULL; p++) |
|---|
| 191 | (void) printf(" %s\n",*p); |
|---|
| 192 | (void) printf("\nImage Operators:\n"); |
|---|
| 193 | for (p=operators; *p != (char *) NULL; p++) |
|---|
| 194 | (void) printf(" %s\n",*p); |
|---|
| 195 | (void) printf("\nMiscellaneous Options:\n"); |
|---|
| 196 | for (p=miscellaneous; *p != (char *) NULL; p++) |
|---|
| 197 | (void) printf(" %s\n",*p); |
|---|
| 198 | (void) printf( |
|---|
| 199 | "\nBy default, 'file' is written in the MIFF image format. To\n"); |
|---|
| 200 | (void) printf( |
|---|
| 201 | "specify a particular image format, precede the filename with an image\n"); |
|---|
| 202 | (void) printf( |
|---|
| 203 | "format name and a colon (i.e. ps:image) or specify the image type as\n"); |
|---|
| 204 | (void) printf( |
|---|
| 205 | "the filename suffix (i.e. image.ps). Specify 'file' as '-' for\n"); |
|---|
| 206 | (void) printf("standard input or output.\n"); |
|---|
| 207 | return(MagickFalse); |
|---|
| 208 | } |
|---|
| 209 | |
|---|
| 210 | static inline long MagickMax(const long x,const long y) |
|---|
| 211 | { |
|---|
| 212 | if (x > y) |
|---|
| 213 | return(x); |
|---|
| 214 | return(y); |
|---|
| 215 | } |
|---|
| 216 | |
|---|
| 217 | WandExport MagickBooleanType ImportImageCommand(ImageInfo *image_info, |
|---|
| 218 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
|---|
| 219 | { |
|---|
| 220 | #if defined(MAGICKCORE_X11_DELEGATE) |
|---|
| 221 | #define DestroyImport() \ |
|---|
| 222 | { \ |
|---|
| 223 | XDestroyResourceInfo(&resource_info); \ |
|---|
| 224 | if (display != (Display *) NULL) \ |
|---|
| 225 | { \ |
|---|
| 226 | XCloseDisplay(display); \ |
|---|
| 227 | display=(Display *) NULL; \ |
|---|
| 228 | } \ |
|---|
| 229 | DestroyImageStack(); \ |
|---|
| 230 | if (target_window != (char *) NULL) \ |
|---|
| 231 | target_window=DestroyString(target_window); \ |
|---|
| 232 | for (i=0; i < (long) argc; i++) \ |
|---|
| 233 | argv[i]=DestroyString(argv[i]); \ |
|---|
| 234 | argv=(char **) RelinquishMagickMemory(argv); \ |
|---|
| 235 | } |
|---|
| 236 | #define ThrowImportException(asperity,tag,option) \ |
|---|
| 237 | { \ |
|---|
| 238 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
|---|
| 239 | option); \ |
|---|
| 240 | DestroyImport(); \ |
|---|
| 241 | return(MagickFalse); \ |
|---|
| 242 | } |
|---|
| 243 | #define ThrowImportInvalidArgumentException(option,argument) \ |
|---|
| 244 | { \ |
|---|
| 245 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
|---|
| 246 | "InvalidArgument","`%s': %s",option,argument); \ |
|---|
| 247 | DestroyImport(); \ |
|---|
| 248 | return(MagickFalse); \ |
|---|
| 249 | } |
|---|
| 250 | |
|---|
| 251 | char |
|---|
| 252 | *filename, |
|---|
| 253 | *option, |
|---|
| 254 | *resource_value, |
|---|
| 255 | *server_name, |
|---|
| 256 | *target_window; |
|---|
| 257 | |
|---|
| 258 | Display |
|---|
| 259 | *display; |
|---|
| 260 | |
|---|
| 261 | Image |
|---|
| 262 | *image; |
|---|
| 263 | |
|---|
| 264 | ImageStack |
|---|
| 265 | image_stack[MaxImageStackDepth+1]; |
|---|
| 266 | |
|---|
| 267 | long |
|---|
| 268 | j, |
|---|
| 269 | k, |
|---|
| 270 | snapshots; |
|---|
| 271 | |
|---|
| 272 | MagickBooleanType |
|---|
| 273 | fire, |
|---|
| 274 | pend; |
|---|
| 275 | |
|---|
| 276 | MagickStatusType |
|---|
| 277 | status; |
|---|
| 278 | |
|---|
| 279 | QuantizeInfo |
|---|
| 280 | *quantize_info; |
|---|
| 281 | |
|---|
| 282 | register long |
|---|
| 283 | i; |
|---|
| 284 | |
|---|
| 285 | XImportInfo |
|---|
| 286 | ximage_info; |
|---|
| 287 | |
|---|
| 288 | XResourceInfo |
|---|
| 289 | resource_info; |
|---|
| 290 | |
|---|
| 291 | XrmDatabase |
|---|
| 292 | resource_database; |
|---|
| 293 | |
|---|
| 294 | |
|---|
| 295 | |
|---|
| 296 | |
|---|
| 297 | assert(image_info != (ImageInfo *) NULL); |
|---|
| 298 | assert(image_info->signature == MagickSignature); |
|---|
| 299 | if (image_info->debug != MagickFalse) |
|---|
| 300 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
|---|
| 301 | assert(exception != (ExceptionInfo *) NULL); |
|---|
| 302 | if (argc == 2) |
|---|
| 303 | { |
|---|
| 304 | option=argv[1]; |
|---|
| 305 | if ((LocaleCompare("version",option+1) == 0) || |
|---|
| 306 | (LocaleCompare("-version",option+1) == 0)) |
|---|
| 307 | { |
|---|
| 308 | (void) fprintf(stdout,"Version: %s\n", |
|---|
| 309 | GetMagickVersion((unsigned long *) NULL)); |
|---|
| 310 | (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright()); |
|---|
| 311 | (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures()); |
|---|
| 312 | return(MagickFalse); |
|---|
| 313 | } |
|---|
| 314 | } |
|---|
| 315 | display=(Display *) NULL; |
|---|
| 316 | j=1; |
|---|
| 317 | k=0; |
|---|
| 318 | NewImageStack(); |
|---|
| 319 | option=(char *) NULL; |
|---|
| 320 | pend=MagickFalse; |
|---|
| 321 | resource_database=(XrmDatabase) NULL; |
|---|
| 322 | (void) ResetMagickMemory(&resource_info,0,sizeof(resource_info)); |
|---|
| 323 | server_name=(char *) NULL; |
|---|
| 324 | status=MagickTrue; |
|---|
| 325 | SetNotifyHandlers; |
|---|
| 326 | target_window=(char *) NULL; |
|---|
| 327 | |
|---|
| 328 | |
|---|
| 329 | |
|---|
| 330 | ReadCommandlLine(argc,&argv); |
|---|
| 331 | status=ExpandFilenames(&argc,&argv); |
|---|
| 332 | if (status == MagickFalse) |
|---|
| 333 | ThrowImportException(ResourceLimitError,"MemoryAllocationFailed", |
|---|
| 334 | GetExceptionMessage(errno)); |
|---|
| 335 | for (i=1; i < (long) argc; i++) |
|---|
| 336 | { |
|---|
| 337 | |
|---|
| 338 | |
|---|
| 339 | |
|---|
| 340 | option=argv[i]; |
|---|
| 341 | if (LocaleCompare("display",option+1) == 0) |
|---|
| 342 | { |
|---|
| 343 | |
|---|
| 344 | |
|---|
| 345 | |
|---|
| 346 | i++; |
|---|
| 347 | if (i == (long) argc) |
|---|
| 348 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 349 | server_name=argv[i]; |
|---|
| 350 | } |
|---|
| 351 | if ((LocaleCompare("help",option+1) == 0) || |
|---|
| 352 | (LocaleCompare("-help",option+1) == 0)) |
|---|
| 353 | return(ImportUsage()); |
|---|
| 354 | } |
|---|
| 355 | |
|---|
| 356 | |
|---|
| 357 | |
|---|
| 358 | display=XOpenDisplay(server_name); |
|---|
| 359 | if (display == (Display *) NULL) |
|---|
| 360 | ThrowImportException(XServerError,"UnableToOpenXServer", |
|---|
| 361 | XDisplayName(server_name)); |
|---|
| 362 | (void) XSetErrorHandler(XError); |
|---|
| 363 | resource_database=XGetResourceDatabase(display,GetClientName()); |
|---|
| 364 | XGetImportInfo(&ximage_info); |
|---|
| 365 | XGetResourceInfo(image_info,resource_database,GetClientName(), |
|---|
| 366 | &resource_info); |
|---|
| 367 | quantize_info=resource_info.quantize_info; |
|---|
| 368 | resource_value=XGetResourceInstance(resource_database,GetClientName(), |
|---|
| 369 | "border","False"); |
|---|
| 370 | ximage_info.borders=IsMagickTrue(resource_value); |
|---|
| 371 | resource_value=XGetResourceInstance(resource_database,GetClientName(), |
|---|
| 372 | "delay","0"); |
|---|
| 373 | resource_info.delay=(unsigned int) atoi(resource_value); |
|---|
| 374 | image_info->density=XGetResourceInstance(resource_database,GetClientName(), |
|---|
| 375 | "density",(char *) NULL); |
|---|
| 376 | resource_value=XGetResourceInstance(resource_database,GetClientName(), |
|---|
| 377 | "descend","True"); |
|---|
| 378 | ximage_info.descend=IsMagickTrue(resource_value); |
|---|
| 379 | resource_value=XGetResourceInstance(resource_database,GetClientName(), |
|---|
| 380 | "frame","False"); |
|---|
| 381 | ximage_info.frame=IsMagickTrue(resource_value); |
|---|
| 382 | resource_value=XGetResourceInstance(resource_database,GetClientName(), |
|---|
| 383 | "interlace","none"); |
|---|
| 384 | image_info->interlace=UndefinedInterlace; |
|---|
| 385 | if (LocaleCompare("None",resource_value) == 0) |
|---|
| 386 | image_info->interlace=NoInterlace; |
|---|
| 387 | if (LocaleCompare("Line",resource_value) == 0) |
|---|
| 388 | image_info->interlace=LineInterlace; |
|---|
| 389 | if (LocaleCompare("Plane",resource_value) == 0) |
|---|
| 390 | image_info->interlace=PlaneInterlace; |
|---|
| 391 | if (LocaleCompare("Partition",resource_value) == 0) |
|---|
| 392 | image_info->interlace=PartitionInterlace; |
|---|
| 393 | if (image_info->interlace == UndefinedInterlace) |
|---|
| 394 | ThrowImportException(OptionError,"Unrecognized interlace type", |
|---|
| 395 | resource_value); |
|---|
| 396 | image_info->page=XGetResourceInstance(resource_database,GetClientName(), |
|---|
| 397 | "pageGeometry",(char *) NULL); |
|---|
| 398 | resource_value=XGetResourceInstance(resource_database,GetClientName(), |
|---|
| 399 | "pause","0"); |
|---|
| 400 | resource_info.pause=(unsigned int) atol(resource_value); |
|---|
| 401 | resource_value=XGetResourceInstance(resource_database,GetClientName(), |
|---|
| 402 | "quality","85"); |
|---|
| 403 | image_info->quality=(unsigned long) atol(resource_value); |
|---|
| 404 | resource_value=XGetResourceInstance(resource_database,GetClientName(), |
|---|
| 405 | "screen","False"); |
|---|
| 406 | ximage_info.screen=IsMagickTrue(resource_value); |
|---|
| 407 | resource_value=XGetResourceInstance(resource_database,GetClientName(), |
|---|
| 408 | "silent","False"); |
|---|
| 409 | ximage_info.silent=IsMagickTrue(resource_value); |
|---|
| 410 | resource_value=XGetResourceInstance(resource_database,GetClientName(), |
|---|
| 411 | "verbose","False"); |
|---|
| 412 | image_info->verbose=IsMagickTrue(resource_value); |
|---|
| 413 | resource_value=XGetResourceInstance(resource_database,GetClientName(), |
|---|
| 414 | "dither","True"); |
|---|
| 415 | quantize_info->dither=IsMagickTrue(resource_value); |
|---|
| 416 | snapshots=1; |
|---|
| 417 | status=MagickTrue; |
|---|
| 418 | filename=(char *) NULL; |
|---|
| 419 | |
|---|
| 420 | |
|---|
| 421 | |
|---|
| 422 | for (i=1; i < (long) argc; i++) |
|---|
| 423 | { |
|---|
| 424 | option=argv[i]; |
|---|
| 425 | if (LocaleCompare(option,"(") == 0) |
|---|
| 426 | { |
|---|
| 427 | FireImageStack(MagickFalse,MagickTrue,pend); |
|---|
| 428 | if (k == MaxImageStackDepth) |
|---|
| 429 | ThrowImportException(OptionError,"ParenthesisNestedTooDeeply", |
|---|
| 430 | option); |
|---|
| 431 | PushImageStack(); |
|---|
| 432 | continue; |
|---|
| 433 | } |
|---|
| 434 | if (LocaleCompare(option,")") == 0) |
|---|
| 435 | { |
|---|
| 436 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
|---|
| 437 | if (k == 0) |
|---|
| 438 | ThrowImportException(OptionError,"UnableToParseExpression",option); |
|---|
| 439 | PopImageStack(); |
|---|
| 440 | continue; |
|---|
| 441 | } |
|---|
| 442 | if (IsMagickOption(option) == MagickFalse) |
|---|
| 443 | { |
|---|
| 444 | Image |
|---|
| 445 | *images; |
|---|
| 446 | |
|---|
| 447 | unsigned long |
|---|
| 448 | scene; |
|---|
| 449 | |
|---|
| 450 | |
|---|
| 451 | |
|---|
| 452 | |
|---|
| 453 | FireImageStack(MagickFalse,MagickFalse,pend); |
|---|
| 454 | filename=argv[i]; |
|---|
| 455 | if (target_window != (char *) NULL) |
|---|
| 456 | (void) CopyMagickString(image_info->filename,target_window, |
|---|
| 457 | MaxTextExtent); |
|---|
| 458 | for (scene=0; scene < (unsigned long) MagickMax(snapshots,1); scene++) |
|---|
| 459 | { |
|---|
| 460 | (void) sleep(resource_info.pause); |
|---|
| 461 | images=XImportImage(image_info,&ximage_info); |
|---|
| 462 | status&=(images != (Image *) NULL) && |
|---|
| 463 | (exception->severity < ErrorException); |
|---|
| 464 | if (images == (Image *) NULL) |
|---|
| 465 | continue; |
|---|
| 466 | (void) CopyMagickString(images->filename,filename,MaxTextExtent); |
|---|
| 467 | (void) CopyMagickString(images->magick,"PS",MaxTextExtent); |
|---|
| 468 | images->scene=scene; |
|---|
| 469 | AppendImageStack(images); |
|---|
| 470 | } |
|---|
| 471 | continue; |
|---|
| 472 | } |
|---|
| 473 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
|---|
| 474 | switch(*(option+1)) |
|---|
| 475 | { |
|---|
| 476 | case 'a': |
|---|
| 477 | { |
|---|
| 478 | if (LocaleCompare("adjoin",option+1) == 0) |
|---|
| 479 | break; |
|---|
| 480 | if (LocaleCompare("annotate",option+1) == 0) |
|---|
| 481 | { |
|---|
| 482 | if (*option == '+') |
|---|
| 483 | break; |
|---|
| 484 | i++; |
|---|
| 485 | if (i == (long) (argc-1)) |
|---|
| 486 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 487 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 488 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 489 | if (i == (long) (argc-1)) |
|---|
| 490 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 491 | i++; |
|---|
| 492 | break; |
|---|
| 493 | } |
|---|
| 494 | ThrowImportException(OptionError,"UnrecognizedOption",option); |
|---|
| 495 | } |
|---|
| 496 | case 'b': |
|---|
| 497 | { |
|---|
| 498 | if (LocaleCompare("border",option+1) == 0) |
|---|
| 499 | { |
|---|
| 500 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
|---|
| 501 | ximage_info.borders=(*option == '-') ? MagickTrue : MagickFalse; |
|---|
| 502 | break; |
|---|
| 503 | } |
|---|
| 504 | if (LocaleCompare("bordercolor",option+1) == 0) |
|---|
| 505 | { |
|---|
| 506 | if (*option == '+') |
|---|
| 507 | break; |
|---|
| 508 | i++; |
|---|
| 509 | if (i == (long) argc) |
|---|
| 510 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 511 | break; |
|---|
| 512 | } |
|---|
| 513 | ThrowImportException(OptionError,"UnrecognizedOption",option); |
|---|
| 514 | } |
|---|
| 515 | case 'c': |
|---|
| 516 | { |
|---|
| 517 | if (LocaleCompare("cache",option+1) == 0) |
|---|
| 518 | { |
|---|
| 519 | if (*option == '+') |
|---|
| 520 | break; |
|---|
| 521 | i++; |
|---|
| 522 | if (i == (long) argc) |
|---|
| 523 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 524 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 525 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 526 | break; |
|---|
| 527 | } |
|---|
| 528 | if (LocaleCompare("channel",option+1) == 0) |
|---|
| 529 | { |
|---|
| 530 | long |
|---|
| 531 | channel; |
|---|
| 532 | |
|---|
| 533 | if (*option == '+') |
|---|
| 534 | break; |
|---|
| 535 | i++; |
|---|
| 536 | if (i == (long) (argc-1)) |
|---|
| 537 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 538 | channel=ParseChannelOption(argv[i]); |
|---|
| 539 | if (channel < 0) |
|---|
| 540 | ThrowImportException(OptionError,"UnrecognizedChannelType", |
|---|
| 541 | argv[i]); |
|---|
| 542 | break; |
|---|
| 543 | } |
|---|
| 544 | if (LocaleCompare("colors",option+1) == 0) |
|---|
| 545 | { |
|---|
| 546 | quantize_info->number_colors=0; |
|---|
| 547 | if (*option == '+') |
|---|
| 548 | break; |
|---|
| 549 | i++; |
|---|
| 550 | if (i == (long) argc) |
|---|
| 551 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 552 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 553 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 554 | quantize_info->number_colors=(unsigned long) atol(argv[i]); |
|---|
| 555 | break; |
|---|
| 556 | } |
|---|
| 557 | if (LocaleCompare("colorspace",option+1) == 0) |
|---|
| 558 | { |
|---|
| 559 | long |
|---|
| 560 | colorspace; |
|---|
| 561 | |
|---|
| 562 | if (*option == '+') |
|---|
| 563 | break; |
|---|
| 564 | i++; |
|---|
| 565 | if (i == (long) argc) |
|---|
| 566 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 567 | colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse, |
|---|
| 568 | argv[i]); |
|---|
| 569 | if (colorspace < 0) |
|---|
| 570 | ThrowImportException(OptionError,"UnrecognizedColorspace", |
|---|
| 571 | argv[i]); |
|---|
| 572 | break; |
|---|
| 573 | } |
|---|
| 574 | if (LocaleCompare("comment",option+1) == 0) |
|---|
| 575 | { |
|---|
| 576 | if (*option == '+') |
|---|
| 577 | break; |
|---|
| 578 | i++; |
|---|
| 579 | if (i == (long) argc) |
|---|
| 580 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 581 | status=SetImageOption(image_info,"comment",argv[i]); |
|---|
| 582 | if (status == MagickFalse) |
|---|
| 583 | ThrowImportException(OptionError,"UnrecognizedOption",argv[i]); |
|---|
| 584 | break; |
|---|
| 585 | } |
|---|
| 586 | if (LocaleCompare("compress",option+1) == 0) |
|---|
| 587 | { |
|---|
| 588 | long |
|---|
| 589 | compress; |
|---|
| 590 | |
|---|
| 591 | if (*option == '+') |
|---|
| 592 | break; |
|---|
| 593 | i++; |
|---|
| 594 | if (i == (long) argc) |
|---|
| 595 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 596 | compress=ParseMagickOption(MagickCompressOptions,MagickFalse, |
|---|
| 597 | argv[i]); |
|---|
| 598 | if (compress < 0) |
|---|
| 599 | ThrowImportException(OptionError,"UnrecognizedImageCompression", |
|---|
| 600 | argv[i]); |
|---|
| 601 | break; |
|---|
| 602 | } |
|---|
| 603 | if (LocaleCompare("concurrent",option+1) == 0) |
|---|
| 604 | break; |
|---|
| 605 | if (LocaleCompare("crop",option+1) == 0) |
|---|
| 606 | { |
|---|
| 607 | if (*option == '+') |
|---|
| 608 | break; |
|---|
| 609 | i++; |
|---|
| 610 | if (i == (long) argc) |
|---|
| 611 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 612 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 613 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 614 | break; |
|---|
| 615 | } |
|---|
| 616 | ThrowImportException(OptionError,"UnrecognizedOption",option); |
|---|
| 617 | } |
|---|
| 618 | case 'd': |
|---|
| 619 | { |
|---|
| 620 | if (LocaleCompare("debug",option+1) == 0) |
|---|
| 621 | { |
|---|
| 622 | long |
|---|
| 623 | event; |
|---|
| 624 | |
|---|
| 625 | if (*option == '+') |
|---|
| 626 | break; |
|---|
| 627 | i++; |
|---|
| 628 | if (i == (long) argc) |
|---|
| 629 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 630 | event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]); |
|---|
| 631 | if (event < 0) |
|---|
| 632 | ThrowImportException(OptionError,"UnrecognizedEventType",argv[i]); |
|---|
| 633 | (void) SetLogEventMask(argv[i]); |
|---|
| 634 | break; |
|---|
| 635 | } |
|---|
| 636 | if (LocaleCompare("define",option+1) == 0) |
|---|
| 637 | { |
|---|
| 638 | i++; |
|---|
| 639 | if (i == (long) argc) |
|---|
| 640 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 641 | if (*option == '+') |
|---|
| 642 | { |
|---|
| 643 | const char |
|---|
| 644 | *define; |
|---|
| 645 | |
|---|
| 646 | define=GetImageOption(image_info,argv[i]); |
|---|
| 647 | if (define == (char *) NULL) |
|---|
| 648 | ThrowImportException(OptionError,"NoSuchOption",argv[i]); |
|---|
| 649 | break; |
|---|
| 650 | } |
|---|
| 651 | break; |
|---|
| 652 | } |
|---|
| 653 | if (LocaleCompare("delay",option+1) == 0) |
|---|
| 654 | { |
|---|
| 655 | if (*option == '+') |
|---|
| 656 | break; |
|---|
| 657 | i++; |
|---|
| 658 | if (i == (long) argc) |
|---|
| 659 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 660 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 661 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 662 | status=SetImageOption(image_info,"delay",argv[i]); |
|---|
| 663 | if (status == MagickFalse) |
|---|
| 664 | ThrowImportException(OptionError,"UnrecognizedOption",argv[i]); |
|---|
| 665 | break; |
|---|
| 666 | } |
|---|
| 667 | if (LocaleCompare("density",option+1) == 0) |
|---|
| 668 | { |
|---|
| 669 | if (*option == '+') |
|---|
| 670 | break; |
|---|
| 671 | i++; |
|---|
| 672 | if (i == (long) argc) |
|---|
| 673 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 674 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 675 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 676 | break; |
|---|
| 677 | } |
|---|
| 678 | if (LocaleCompare("depth",option+1) == 0) |
|---|
| 679 | { |
|---|
| 680 | if (*option == '+') |
|---|
| 681 | break; |
|---|
| 682 | i++; |
|---|
| 683 | if (i == (long) argc) |
|---|
| 684 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 685 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 686 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 687 | break; |
|---|
| 688 | } |
|---|
| 689 | if (LocaleCompare("descend",option+1) == 0) |
|---|
| 690 | { |
|---|
| 691 | ximage_info.descend=(*option == '-') ? MagickTrue : MagickFalse; |
|---|
| 692 | break; |
|---|
| 693 | } |
|---|
| 694 | if (LocaleCompare("display",option+1) == 0) |
|---|
| 695 | { |
|---|
| 696 | if (*option == '+') |
|---|
| 697 | break; |
|---|
| 698 | i++; |
|---|
| 699 | if (i == (long) argc) |
|---|
| 700 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 701 | break; |
|---|
| 702 | } |
|---|
| 703 | if (LocaleCompare("dispose",option+1) == 0) |
|---|
| 704 | { |
|---|
| 705 | long |
|---|
| 706 | dispose; |
|---|
| 707 | |
|---|
| 708 | if (*option == '+') |
|---|
| 709 | break; |
|---|
| 710 | i++; |
|---|
| 711 | if (i == (long) argc) |
|---|
| 712 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 713 | dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]); |
|---|
| 714 | if (dispose < 0) |
|---|
| 715 | ThrowImportException(OptionError,"UnrecognizedDisposeMethod", |
|---|
| 716 | argv[i]); |
|---|
| 717 | break; |
|---|
| 718 | } |
|---|
| 719 | if (LocaleCompare("dither",option+1) == 0) |
|---|
| 720 | { |
|---|
| 721 | long |
|---|
| 722 | method; |
|---|
| 723 | |
|---|
| 724 | quantize_info->dither=MagickFalse; |
|---|
| 725 | if (*option == '+') |
|---|
| 726 | break; |
|---|
| 727 | i++; |
|---|
| 728 | if (i == (long) argc) |
|---|
| 729 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 730 | method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]); |
|---|
| 731 | if (method < 0) |
|---|
| 732 | ThrowImportException(OptionError,"UnrecognizedDitherMethod", |
|---|
| 733 | argv[i]); |
|---|
| 734 | quantize_info->dither=MagickTrue; |
|---|
| 735 | quantize_info->dither_method=(DitherMethod) method; |
|---|
| 736 | break; |
|---|
| 737 | } |
|---|
| 738 | if (LocaleCompare("duration",option+1) == 0) |
|---|
| 739 | { |
|---|
| 740 | if (*option == '+') |
|---|
| 741 | break; |
|---|
| 742 | i++; |
|---|
| 743 | if (i == (long) (argc-1)) |
|---|
| 744 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 745 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 746 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 747 | break; |
|---|
| 748 | } |
|---|
| 749 | ThrowImportException(OptionError,"UnrecognizedOption",option); |
|---|
| 750 | } |
|---|
| 751 | case 'e': |
|---|
| 752 | { |
|---|
| 753 | if (LocaleCompare("encipher",option+1) == 0) |
|---|
| 754 | { |
|---|
| 755 | if (*option == '+') |
|---|
| 756 | break; |
|---|
| 757 | i++; |
|---|
| 758 | if (i == (long) (argc-1)) |
|---|
| 759 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 760 | break; |
|---|
| 761 | } |
|---|
| 762 | if (LocaleCompare("encoding",option+1) == 0) |
|---|
| 763 | { |
|---|
| 764 | if (*option == '+') |
|---|
| 765 | break; |
|---|
| 766 | i++; |
|---|
| 767 | if (i == (long) argc) |
|---|
| 768 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 769 | break; |
|---|
| 770 | } |
|---|
| 771 | if (LocaleCompare("endian",option+1) == 0) |
|---|
| 772 | { |
|---|
| 773 | long |
|---|
| 774 | endian; |
|---|
| 775 | |
|---|
| 776 | if (*option == '+') |
|---|
| 777 | break; |
|---|
| 778 | i++; |
|---|
| 779 | if (i == (long) argc) |
|---|
| 780 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 781 | endian=ParseMagickOption(MagickEndianOptions,MagickFalse, |
|---|
| 782 | argv[i]); |
|---|
| 783 | if (endian < 0) |
|---|
| 784 | ThrowImportException(OptionError,"UnrecognizedEndianType", |
|---|
| 785 | argv[i]); |
|---|
| 786 | break; |
|---|
| 787 | } |
|---|
| 788 | ThrowImportException(OptionError,"UnrecognizedOption",option); |
|---|
| 789 | } |
|---|
| 790 | case 'f': |
|---|
| 791 | { |
|---|
| 792 | if (LocaleCompare("filter",option+1) == 0) |
|---|
| 793 | { |
|---|
| 794 | long |
|---|
| 795 | filter; |
|---|
| 796 | |
|---|
| 797 | if (*option == '+') |
|---|
| 798 | break; |
|---|
| 799 | i++; |
|---|
| 800 | if (i == (long) (argc-1)) |
|---|
| 801 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 802 | filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]); |
|---|
| 803 | if (filter < 0) |
|---|
| 804 | ThrowImportException(OptionError,"UnrecognizedImageFilter", |
|---|
| 805 | argv[i]); |
|---|
| 806 | break; |
|---|
| 807 | } |
|---|
| 808 | if (LocaleCompare("frame",option+1) == 0) |
|---|
| 809 | { |
|---|
| 810 | (void) CopyMagickString(argv[i]+1,"sans0",MaxTextExtent); |
|---|
| 811 | ximage_info.frame=(*option == '-') ? MagickTrue : MagickFalse; |
|---|
| 812 | break; |
|---|
| 813 | } |
|---|
| 814 | if (LocaleCompare("format",option+1) == 0) |
|---|
| 815 | { |
|---|
| 816 | if (*option == '+') |
|---|
| 817 | break; |
|---|
| 818 | i++; |
|---|
| 819 | if (i == (long) (argc-1)) |
|---|
| 820 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 821 | break; |
|---|
| 822 | } |
|---|
| 823 | ThrowImportException(OptionError,"UnrecognizedOption",option); |
|---|
| 824 | } |
|---|
| 825 | case 'g': |
|---|
| 826 | { |
|---|
| 827 | if (LocaleCompare("geometry",option+1) == 0) |
|---|
| 828 | { |
|---|
| 829 | if (*option == '+') |
|---|
| 830 | break; |
|---|
| 831 | i++; |
|---|
| 832 | if (i == (long) argc) |
|---|
| 833 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 834 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 835 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 836 | break; |
|---|
| 837 | } |
|---|
| 838 | if (LocaleCompare("gravity",option+1) == 0) |
|---|
| 839 | { |
|---|
| 840 | long |
|---|
| 841 | gravity; |
|---|
| 842 | |
|---|
| 843 | if (*option == '+') |
|---|
| 844 | break; |
|---|
| 845 | i++; |
|---|
| 846 | if (i == (long) argc) |
|---|
| 847 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 848 | gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,argv[i]); |
|---|
| 849 | if (gravity < 0) |
|---|
| 850 | ThrowImportException(OptionError,"UnrecognizedGravityType", |
|---|
| 851 | argv[i]); |
|---|
| 852 | break; |
|---|
| 853 | } |
|---|
| 854 | ThrowImportException(OptionError,"UnrecognizedOption",option); |
|---|
| 855 | } |
|---|
| 856 | case 'h': |
|---|
| 857 | { |
|---|
| 858 | if (LocaleCompare("help",option+1) == 0) |
|---|
| 859 | break; |
|---|
| 860 | ThrowImportException(OptionError,"UnrecognizedOption",option); |
|---|
| 861 | } |
|---|
| 862 | case 'i': |
|---|
| 863 | { |
|---|
| 864 | if (LocaleCompare("identify",option+1) == 0) |
|---|
| 865 | break; |
|---|
| 866 | if (LocaleCompare("interlace",option+1) == 0) |
|---|
| 867 | { |
|---|
| 868 | long |
|---|
| 869 | interlace; |
|---|
| 870 | |
|---|
| 871 | if (*option == '+') |
|---|
| 872 | break; |
|---|
| 873 | i++; |
|---|
| 874 | if (i == (long) argc) |
|---|
| 875 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 876 | interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse, |
|---|
| 877 | argv[i]); |
|---|
| 878 | if (interlace < 0) |
|---|
| 879 | ThrowImportException(OptionError,"UnrecognizedInterlaceType", |
|---|
| 880 | argv[i]); |
|---|
| 881 | break; |
|---|
| 882 | } |
|---|
| 883 | if (LocaleCompare("interpolate",option+1) == 0) |
|---|
| 884 | { |
|---|
| 885 | long |
|---|
| 886 | interpolate; |
|---|
| 887 | |
|---|
| 888 | if (*option == '+') |
|---|
| 889 | break; |
|---|
| 890 | i++; |
|---|
| 891 | if (i == (long) argc) |
|---|
| 892 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 893 | interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse, |
|---|
| 894 | argv[i]); |
|---|
| 895 | if (interpolate < 0) |
|---|
| 896 | ThrowImportException(OptionError,"UnrecognizedInterpolateMethod", |
|---|
| 897 | argv[i]); |
|---|
| 898 | break; |
|---|
| 899 | } |
|---|
| 900 | ThrowImportException(OptionError,"UnrecognizedOption",option); |
|---|
| 901 | } |
|---|
| 902 | case 'l': |
|---|
| 903 | { |
|---|
| 904 | if (LocaleCompare("label",option+1) == 0) |
|---|
| 905 | { |
|---|
| 906 | if (*option == '+') |
|---|
| 907 | break; |
|---|
| 908 | i++; |
|---|
| 909 | if (i == (long) argc) |
|---|
| 910 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 911 | status=SetImageOption(image_info,"label",argv[i]); |
|---|
| 912 | if (status == MagickFalse) |
|---|
| 913 | ThrowImportException(OptionError,"UnrecognizedOption",argv[i]); |
|---|
| 914 | break; |
|---|
| 915 | } |
|---|
| 916 | if (LocaleCompare("limit",option+1) == 0) |
|---|
| 917 | { |
|---|
| 918 | char |
|---|
| 919 | *p; |
|---|
| 920 | |
|---|
| 921 | double |
|---|
| 922 | value; |
|---|
| 923 | |
|---|
| 924 | long |
|---|
| 925 | resource; |
|---|
| 926 | |
|---|
| 927 | if (*option == '+') |
|---|
| 928 | break; |
|---|
| 929 | i++; |
|---|
| 930 | if (i == (long) argc) |
|---|
| 931 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 932 | resource=ParseMagickOption(MagickResourceOptions,MagickFalse, |
|---|
| 933 | argv[i]); |
|---|
| 934 | if (resource < 0) |
|---|
| 935 | ThrowImportException(OptionError,"UnrecognizedResourceType", |
|---|
| 936 | argv[i]); |
|---|
| 937 | i++; |
|---|
| 938 | if (i == (long) argc) |
|---|
| 939 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 940 | value=strtod(argv[i],&p); |
|---|
| 941 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
|---|
| 942 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 943 | break; |
|---|
| 944 | } |
|---|
| 945 | if (LocaleCompare("list",option+1) == 0) |
|---|
| 946 | { |
|---|
| 947 | long |
|---|
| 948 | list; |
|---|
| 949 | |
|---|
| 950 | if (*option == '+') |
|---|
| 951 | break; |
|---|
| 952 | i++; |
|---|
| 953 | if (i == (long) argc) |
|---|
| 954 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 955 | list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]); |
|---|
| 956 | if (list < 0) |
|---|
| 957 | ThrowImportException(OptionError,"UnrecognizedListType",argv[i]); |
|---|
| 958 | (void) MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
|---|
| 959 | argv+j,exception); |
|---|
| 960 | DestroyImport(); |
|---|
| 961 | return(MagickTrue); |
|---|
| 962 | } |
|---|
| 963 | if (LocaleCompare("log",option+1) == 0) |
|---|
| 964 | { |
|---|
| 965 | if (*option == '+') |
|---|
| 966 | break; |
|---|
| 967 | i++; |
|---|
| 968 | if ((i == (long) argc) || (strchr(argv[i],'%') == (char *) NULL)) |
|---|
| 969 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 970 | break; |
|---|
| 971 | } |
|---|
| 972 | ThrowImportException(OptionError,"UnrecognizedOption",option); |
|---|
| 973 | } |
|---|
| 974 | case 'm': |
|---|
| 975 | { |
|---|
| 976 | if (LocaleCompare("monitor",option+1) == 0) |
|---|
| 977 | break; |
|---|
| 978 | if (LocaleCompare("monochrome",option+1) == 0) |
|---|
| 979 | { |
|---|
| 980 | if (*option == '+') |
|---|
| 981 | break; |
|---|
| 982 | quantize_info->number_colors=2; |
|---|
| 983 | quantize_info->colorspace=GRAYColorspace; |
|---|
| 984 | break; |
|---|
| 985 | } |
|---|
| 986 | ThrowImportException(OptionError,"UnrecognizedOption",option); |
|---|
| 987 | } |
|---|
| 988 | case 'n': |
|---|
| 989 | { |
|---|
| 990 | if (LocaleCompare("negate",option+1) == 0) |
|---|
| 991 | break; |
|---|
| 992 | ThrowImportException(OptionError,"UnrecognizedOption",option); |
|---|
| 993 | } |
|---|
| 994 | case 'p': |
|---|
| 995 | { |
|---|
| 996 | if (LocaleCompare("page",option+1) == 0) |
|---|
| 997 | { |
|---|
| 998 | if (*option == '+') |
|---|
| 999 | break; |
|---|
| 1000 | i++; |
|---|
| 1001 | if (i == (long) argc) |
|---|
| 1002 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1003 | status=SetImageOption(image_info,"page",argv[i]); |
|---|
| 1004 | if (status == MagickFalse) |
|---|
| 1005 | ThrowImportException(OptionError,"UnrecognizedOption",argv[i]); |
|---|
| 1006 | break; |
|---|
| 1007 | } |
|---|
| 1008 | if (LocaleCompare("pause",option+1) == 0) |
|---|
| 1009 | { |
|---|
| 1010 | resource_info.pause=0; |
|---|
| 1011 | if (*option == '+') |
|---|
| 1012 | break; |
|---|
| 1013 | i++; |
|---|
| 1014 | if (i == (long) argc) |
|---|
| 1015 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1016 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 1017 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 1018 | resource_info.pause=(unsigned int) atoi(argv[i]); |
|---|
| 1019 | break; |
|---|
| 1020 | } |
|---|
| 1021 | if (LocaleCompare("ping",option+1) == 0) |
|---|
| 1022 | break; |
|---|
| 1023 | if (LocaleCompare("pointsize",option+1) == 0) |
|---|
| 1024 | { |
|---|
| 1025 | if (*option == '+') |
|---|
| 1026 | break; |
|---|
| 1027 | i++; |
|---|
| 1028 | if (i == (long) argc) |
|---|
| 1029 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1030 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 1031 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 1032 | break; |
|---|
| 1033 | } |
|---|
| 1034 | ThrowImportException(OptionError,"UnrecognizedOption",option); |
|---|
| 1035 | } |
|---|
| 1036 | case 'q': |
|---|
| 1037 | { |
|---|
| 1038 | if (LocaleCompare("quality",option+1) == 0) |
|---|
| 1039 | { |
|---|
| 1040 | if (*option == '+') |
|---|
| 1041 | break; |
|---|
| 1042 | i++; |
|---|
| 1043 | if (i == (long) argc) |
|---|
| 1044 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1045 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 1046 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 1047 | break; |
|---|
| 1048 | } |
|---|
| 1049 | if (LocaleCompare("quantize",option+1) == 0) |
|---|
| 1050 | { |
|---|
| 1051 | long |
|---|
| 1052 | colorspace; |
|---|
| 1053 | |
|---|
| 1054 | if (*option == '+') |
|---|
| 1055 | break; |
|---|
| 1056 | i++; |
|---|
| 1057 | if (i == (long) (argc-1)) |
|---|
| 1058 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1059 | colorspace=ParseMagickOption(MagickColorspaceOptions, |
|---|
| 1060 | MagickFalse,argv[i]); |
|---|
| 1061 | if (colorspace < 0) |
|---|
| 1062 | ThrowImportException(OptionError,"UnrecognizedColorspace", |
|---|
| 1063 | argv[i]); |
|---|
| 1064 | break; |
|---|
| 1065 | } |
|---|
| 1066 | if (LocaleCompare("quiet",option+1) == 0) |
|---|
| 1067 | break; |
|---|
| 1068 | ThrowImportException(OptionError,"UnrecognizedOption",option); |
|---|
| 1069 | } |
|---|
| 1070 | case 'r': |
|---|
| 1071 | { |
|---|
| 1072 | if (LocaleCompare("regard-warnings",option+1) == 0) |
|---|
| 1073 | break; |
|---|
| 1074 | if (LocaleCompare("repage",option+1) == 0) |
|---|
| 1075 | { |
|---|
| 1076 | if (*option == '+') |
|---|
| 1077 | break; |
|---|
| 1078 | i++; |
|---|
| 1079 | if (i == (long) (argc-1)) |
|---|
| 1080 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1081 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 1082 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 1083 | break; |
|---|
| 1084 | } |
|---|
| 1085 | if (LocaleCompare("resize",option+1) == 0) |
|---|
| 1086 | { |
|---|
| 1087 | if (*option == '+') |
|---|
| 1088 | break; |
|---|
| 1089 | i++; |
|---|
| 1090 | if (i == (long) argc) |
|---|
| 1091 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1092 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 1093 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 1094 | break; |
|---|
| 1095 | } |
|---|
| 1096 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
|---|
| 1097 | { |
|---|
| 1098 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
|---|
| 1099 | break; |
|---|
| 1100 | } |
|---|
| 1101 | if (LocaleCompare("rotate",option+1) == 0) |
|---|
| 1102 | { |
|---|
| 1103 | i++; |
|---|
| 1104 | if (i == (long) argc) |
|---|
| 1105 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1106 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 1107 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 1108 | break; |
|---|
| 1109 | } |
|---|
| 1110 | ThrowImportException(OptionError,"UnrecognizedOption",option); |
|---|
| 1111 | } |
|---|
| 1112 | case 's': |
|---|
| 1113 | { |
|---|
| 1114 | if (LocaleCompare("sampling-factor",option+1) == 0) |
|---|
| 1115 | { |
|---|
| 1116 | if (*option == '+') |
|---|
| 1117 | break; |
|---|
| 1118 | i++; |
|---|
| 1119 | if (i == (long) argc) |
|---|
| 1120 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1121 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 1122 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 1123 | break; |
|---|
| 1124 | } |
|---|
| 1125 | if (LocaleCompare("scene",option+1) == 0) |
|---|
| 1126 | { |
|---|
| 1127 | if (*option == '+') |
|---|
| 1128 | break; |
|---|
| 1129 | i++; |
|---|
| 1130 | if (i == (long) argc) |
|---|
| 1131 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1132 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 1133 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 1134 | break; |
|---|
| 1135 | } |
|---|
| 1136 | if (LocaleCompare("set",option+1) == 0) |
|---|
| 1137 | { |
|---|
| 1138 | i++; |
|---|
| 1139 | if (i == (long) argc) |
|---|
| 1140 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1141 | if (*option == '+') |
|---|
| 1142 | break; |
|---|
| 1143 | i++; |
|---|
| 1144 | if (i == (long) argc) |
|---|
| 1145 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1146 | break; |
|---|
| 1147 | } |
|---|
| 1148 | if (LocaleCompare("screen",option+1) == 0) |
|---|
| 1149 | { |
|---|
| 1150 | ximage_info.screen=(*option == '-') ? MagickTrue : MagickFalse; |
|---|
| 1151 | break; |
|---|
| 1152 | } |
|---|
| 1153 | if (LocaleCompare("seed",option+1) == 0) |
|---|
| 1154 | { |
|---|
| 1155 | if (*option == '+') |
|---|
| 1156 | break; |
|---|
| 1157 | i++; |
|---|
| 1158 | if (i == (long) (argc-1)) |
|---|
| 1159 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1160 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 1161 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 1162 | break; |
|---|
| 1163 | } |
|---|
| 1164 | if (LocaleCompare("silent",option+1) == 0) |
|---|
| 1165 | { |
|---|
| 1166 | ximage_info.silent=(*option == '-') ? MagickTrue : MagickFalse; |
|---|
| 1167 | break; |
|---|
| 1168 | } |
|---|
| 1169 | if (LocaleCompare("snaps",option+1) == 0) |
|---|
| 1170 | { |
|---|
| 1171 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
|---|
| 1172 | i++; |
|---|
| 1173 | if (i == (long) argc) |
|---|
| 1174 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1175 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 1176 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 1177 | snapshots=atol(argv[i]); |
|---|
| 1178 | break; |
|---|
| 1179 | } |
|---|
| 1180 | if (LocaleCompare("strip",option+1) == 0) |
|---|
| 1181 | break; |
|---|
| 1182 | if (LocaleCompare("support",option+1) == 0) |
|---|
| 1183 | { |
|---|
| 1184 | i++; |
|---|
| 1185 | break; |
|---|
| 1186 | } |
|---|
| 1187 | ThrowImportException(OptionError,"UnrecognizedOption",option); |
|---|
| 1188 | } |
|---|
| 1189 | case 't': |
|---|
| 1190 | { |
|---|
| 1191 | if (LocaleCompare("thumnail",option+1) == 0) |
|---|
| 1192 | { |
|---|
| 1193 | if (*option == '+') |
|---|
| 1194 | break; |
|---|
| 1195 | i++; |
|---|
| 1196 | if (i == (long) argc) |
|---|
| 1197 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1198 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 1199 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 1200 | break; |
|---|
| 1201 | } |
|---|
| 1202 | if (LocaleCompare("transparent",option+1) == 0) |
|---|
| 1203 | { |
|---|
| 1204 | i++; |
|---|
| 1205 | if (i == (long) argc) |
|---|
| 1206 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1207 | break; |
|---|
| 1208 | } |
|---|
| 1209 | if (LocaleCompare("transparent-color",option+1) == 0) |
|---|
| 1210 | { |
|---|
| 1211 | if (*option == '+') |
|---|
| 1212 | break; |
|---|
| 1213 | i++; |
|---|
| 1214 | if (i == (long) (argc-1)) |
|---|
| 1215 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1216 | break; |
|---|
| 1217 | } |
|---|
| 1218 | if (LocaleCompare("treedepth",option+1) == 0) |
|---|
| 1219 | { |
|---|
| 1220 | quantize_info->tree_depth=0; |
|---|
| 1221 | if (*option == '+') |
|---|
| 1222 | break; |
|---|
| 1223 | i++; |
|---|
| 1224 | if (i == (long) argc) |
|---|
| 1225 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1226 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 1227 | ThrowImportInvalidArgumentException(option,argv[i]); |
|---|
| 1228 | quantize_info->tree_depth=(unsigned long) atol(argv[i]); |
|---|
| 1229 | break; |
|---|
| 1230 | } |
|---|
| 1231 | if (LocaleCompare("trim",option+1) == 0) |
|---|
| 1232 | break; |
|---|
| 1233 | if (LocaleCompare("type",option+1) == 0) |
|---|
| 1234 | { |
|---|
| 1235 | long |
|---|
| 1236 | type; |
|---|
| 1237 | |
|---|
| 1238 | if (*option == '+') |
|---|
| 1239 | break; |
|---|
| 1240 | i++; |
|---|
| 1241 | if (i == (long) argc) |
|---|
| 1242 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1243 | type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]); |
|---|
| 1244 | if (type < 0) |
|---|
| 1245 | ThrowImportException(OptionError,"UnrecognizedImageType",argv[i]); |
|---|
| 1246 | break; |
|---|
| 1247 | } |
|---|
| 1248 | ThrowImportException(OptionError,"UnrecognizedOption",option); |
|---|
| 1249 | } |
|---|
| 1250 | case 'w': |
|---|
| 1251 | { |
|---|
| 1252 | i++; |
|---|
| 1253 | if (i == (long) argc) |
|---|
| 1254 | ThrowImportException(OptionError,"MissingArgument",option); |
|---|
| 1255 | (void) CloneString(&target_window,argv[i]); |
|---|
| 1256 | break; |
|---|
| 1257 | } |
|---|
| 1258 | case 'v': |
|---|
| 1259 | { |
|---|
| 1260 | if (LocaleCompare("verbose",option+1) == 0) |
|---|
| 1261 | break; |
|---|
| 1262 | if ((LocaleCompare("version",option+1) == 0) || |
|---|
| 1263 | (LocaleCompare("-version",option+1) == 0)) |
|---|
| 1264 | { |
|---|
| 1265 | (void) fprintf(stdout,"Version: %s\n", |
|---|
| 1266 | GetMagickVersion((unsigned long *) NULL)); |
|---|
| 1267 | (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright()); |
|---|
| 1268 | (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures()); |
|---|
| 1269 | break; |
|---|
| 1270 | } |
|---|
| 1271 | ThrowImportException(OptionError,"UnrecognizedOption",option); |
|---|
| 1272 | } |
|---|
| 1273 | case '?': |
|---|
| 1274 | break; |
|---|
| 1275 | default: |
|---|
| 1276 | ThrowImportException(OptionError,"UnrecognizedOption",option); |
|---|
| 1277 | } |
|---|
| 1278 | fire=ParseMagickOption(MagickImageListOptions,MagickFalse,option+1) < 0 ? |
|---|
| 1279 | MagickFalse : MagickTrue; |
|---|
| 1280 | if (fire != MagickFalse) |
|---|
| 1281 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
|---|
| 1282 | } |
|---|
| 1283 | if (k != 0) |
|---|
| 1284 | ThrowImportException(OptionError,"UnbalancedParenthesis",argv[i]); |
|---|
| 1285 | if (i-- != argc) |
|---|
| 1286 | ThrowImportException(OptionError,"MissingAnImageFilename",argv[i]); |
|---|
| 1287 | if (image == (Image *) NULL) |
|---|
| 1288 | ThrowImportException(OptionError,"MissingAnImageFilename",argv[argc-1]); |
|---|
| 1289 | FinalizeImageSettings(image_info,image,MagickTrue); |
|---|
| 1290 | status&=WriteImages(image_info,image,filename,exception); |
|---|
| 1291 | DestroyImport(); |
|---|
| 1292 | return(status != 0 ? MagickTrue : MagickFalse); |
|---|
| 1293 | #else |
|---|
| 1294 | (void) argc; |
|---|
| 1295 | (void) argv; |
|---|
| 1296 | (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError, |
|---|
| 1297 | "DelegateLibrarySupportNotBuiltIn","`%s' (X11)",image_info->filename); |
|---|
| 1298 | return(ImportUsage()); |
|---|
| 1299 | #endif |
|---|
| 1300 | } |
|---|