| 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 | #include "wand/studio.h" |
|---|
| 44 | #include "wand/MagickWand.h" |
|---|
| 45 | #include "wand/mogrify-private.h" |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | typedef struct _CompositeOptions |
|---|
| 51 | { |
|---|
| 52 | ChannelType |
|---|
| 53 | channel; |
|---|
| 54 | |
|---|
| 55 | char |
|---|
| 56 | *blend_geometry, |
|---|
| 57 | *displace_geometry, |
|---|
| 58 | *dissolve_geometry, |
|---|
| 59 | *geometry, |
|---|
| 60 | *unsharp_geometry, |
|---|
| 61 | *watermark_geometry; |
|---|
| 62 | |
|---|
| 63 | CompositeOperator |
|---|
| 64 | compose; |
|---|
| 65 | |
|---|
| 66 | GravityType |
|---|
| 67 | gravity; |
|---|
| 68 | |
|---|
| 69 | long |
|---|
| 70 | stegano; |
|---|
| 71 | |
|---|
| 72 | MagickBooleanType |
|---|
| 73 | stereo, |
|---|
| 74 | tile; |
|---|
| 75 | } CompositeOptions; |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | static MagickBooleanType CompositeImageList(ImageInfo *image_info,Image **image, |
|---|
| 111 | Image *composite_image,CompositeOptions *composite_options, |
|---|
| 112 | ExceptionInfo *exception) |
|---|
| 113 | { |
|---|
| 114 | MagickStatusType |
|---|
| 115 | status; |
|---|
| 116 | |
|---|
| 117 | assert(image_info != (ImageInfo *) NULL); |
|---|
| 118 | assert(image_info->signature == MagickSignature); |
|---|
| 119 | assert(image != (Image **) NULL); |
|---|
| 120 | assert((*image)->signature == MagickSignature); |
|---|
| 121 | if ((*image)->debug != MagickFalse) |
|---|
| 122 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); |
|---|
| 123 | assert(exception != (ExceptionInfo *) NULL); |
|---|
| 124 | status=MagickTrue; |
|---|
| 125 | if (composite_image != (Image *) NULL) |
|---|
| 126 | { |
|---|
| 127 | assert(composite_image->signature == MagickSignature); |
|---|
| 128 | if (composite_options->compose == BlendCompositeOp) |
|---|
| 129 | (void) CloneString(&composite_image->geometry, |
|---|
| 130 | composite_options->blend_geometry); |
|---|
| 131 | if (composite_options->compose == DisplaceCompositeOp) |
|---|
| 132 | (void) CloneString(&composite_image->geometry, |
|---|
| 133 | composite_options->displace_geometry); |
|---|
| 134 | if (composite_options->compose == DissolveCompositeOp) |
|---|
| 135 | (void) CloneString(&composite_image->geometry, |
|---|
| 136 | composite_options->dissolve_geometry); |
|---|
| 137 | if (composite_options->compose == ModulateCompositeOp) |
|---|
| 138 | (void) CloneString(&composite_image->geometry, |
|---|
| 139 | composite_options->watermark_geometry); |
|---|
| 140 | if (composite_options->compose == ThresholdCompositeOp) |
|---|
| 141 | (void) CloneString(&composite_image->geometry, |
|---|
| 142 | composite_options->unsharp_geometry); |
|---|
| 143 | |
|---|
| 144 | |
|---|
| 145 | |
|---|
| 146 | if (composite_options->stegano != 0) |
|---|
| 147 | { |
|---|
| 148 | Image |
|---|
| 149 | *stegano_image; |
|---|
| 150 | |
|---|
| 151 | (*image)->offset=composite_options->stegano-1; |
|---|
| 152 | stegano_image=SteganoImage(*image,composite_image,exception); |
|---|
| 153 | if (stegano_image != (Image *) NULL) |
|---|
| 154 | { |
|---|
| 155 | *image=DestroyImageList(*image); |
|---|
| 156 | *image=stegano_image; |
|---|
| 157 | } |
|---|
| 158 | } |
|---|
| 159 | else |
|---|
| 160 | if (composite_options->stereo != MagickFalse) |
|---|
| 161 | { |
|---|
| 162 | Image |
|---|
| 163 | *stereo_image; |
|---|
| 164 | |
|---|
| 165 | stereo_image=StereoImage(*image,composite_image,exception); |
|---|
| 166 | if (stereo_image != (Image *) NULL) |
|---|
| 167 | { |
|---|
| 168 | *image=DestroyImageList(*image); |
|---|
| 169 | *image=stereo_image; |
|---|
| 170 | } |
|---|
| 171 | } |
|---|
| 172 | else |
|---|
| 173 | if (composite_options->tile != MagickFalse) |
|---|
| 174 | { |
|---|
| 175 | long |
|---|
| 176 | x, |
|---|
| 177 | y; |
|---|
| 178 | |
|---|
| 179 | unsigned long |
|---|
| 180 | columns; |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | |
|---|
| 184 | |
|---|
| 185 | (void) SetImageArtifact(composite_image,"modify-outside-overlay", |
|---|
| 186 | "false"); |
|---|
| 187 | columns=composite_image->columns; |
|---|
| 188 | for (y=0; y < (long) (*image)->rows; y+=composite_image->rows) |
|---|
| 189 | for (x=0; x < (long) (*image)->columns; x+=columns) |
|---|
| 190 | status&=CompositeImageChannel(*image, |
|---|
| 191 | composite_options->channel,composite_options->compose, |
|---|
| 192 | composite_image,x,y); |
|---|
| 193 | GetImageException(*image,exception); |
|---|
| 194 | } |
|---|
| 195 | else |
|---|
| 196 | { |
|---|
| 197 | char |
|---|
| 198 | composite_geometry[MaxTextExtent]; |
|---|
| 199 | |
|---|
| 200 | RectangleInfo |
|---|
| 201 | geometry; |
|---|
| 202 | |
|---|
| 203 | |
|---|
| 204 | |
|---|
| 205 | |
|---|
| 206 | SetGeometry(*image,&geometry); |
|---|
| 207 | (void) ParseAbsoluteGeometry(composite_options->geometry, |
|---|
| 208 | &geometry); |
|---|
| 209 | (void) FormatMagickString(composite_geometry,MaxTextExtent, |
|---|
| 210 | "%lux%lu%+ld%+ld",composite_image->columns, |
|---|
| 211 | composite_image->rows,geometry.x,geometry.y); |
|---|
| 212 | (*image)->gravity=(GravityType) composite_options->gravity; |
|---|
| 213 | (void) ParseGravityGeometry(*image,composite_geometry,&geometry); |
|---|
| 214 | status&=CompositeImageChannel(*image,composite_options->channel, |
|---|
| 215 | composite_options->compose,composite_image,geometry.x, |
|---|
| 216 | geometry.y); |
|---|
| 217 | GetImageException(*image,exception); |
|---|
| 218 | } |
|---|
| 219 | } |
|---|
| 220 | return(status != 0 ? MagickTrue : MagickFalse); |
|---|
| 221 | } |
|---|
| 222 | |
|---|
| 223 | static void CompositeUsage(void) |
|---|
| 224 | { |
|---|
| 225 | const char |
|---|
| 226 | **p; |
|---|
| 227 | |
|---|
| 228 | static const char |
|---|
| 229 | *miscellaneous[]= |
|---|
| 230 | { |
|---|
| 231 | "-debug events display copious debugging information", |
|---|
| 232 | "-help print program options", |
|---|
| 233 | "-list type print a list of supported option arguments", |
|---|
| 234 | "-log format format of debugging information", |
|---|
| 235 | "-version print version information", |
|---|
| 236 | (char *) NULL |
|---|
| 237 | }, |
|---|
| 238 | *operators[]= |
|---|
| 239 | { |
|---|
| 240 | "-blend geometry blend images", |
|---|
| 241 | "-border geometry surround image with a border of color", |
|---|
| 242 | "-bordercolor color border color", |
|---|
| 243 | "-colors value preferred number of colors in the image", |
|---|
| 244 | "-decipher filename convert cipher pixels to plain pixels", |
|---|
| 245 | "-displace geometry shift image pixels defined by a displacement map", |
|---|
| 246 | "-dissolve value dissolve the two images a given percent", |
|---|
| 247 | "-encipher filename convert plain pixels to cipher pixels", |
|---|
| 248 | "-extract geometry extract area from image", |
|---|
| 249 | "-geometry geometry location of the composite image", |
|---|
| 250 | "-identify identify the format and characteristics of the image", |
|---|
| 251 | "-monochrome transform image to black and white", |
|---|
| 252 | "-negate replace every pixel with its complementary color ", |
|---|
| 253 | "-profile filename add ICM or IPTC information profile to image", |
|---|
| 254 | "-quantize colorspace reduce colors in this colorspace", |
|---|
| 255 | "-repage geometry size and location of an image canvas (operator)", |
|---|
| 256 | "-rotate degrees apply Paeth rotation to the image", |
|---|
| 257 | "-resize geometry resize the image", |
|---|
| 258 | "-sharpen geometry sharpen the image", |
|---|
| 259 | "-shave geometry shave pixels from the image edges", |
|---|
| 260 | "-stegano offset hide watermark within an image", |
|---|
| 261 | "-stereo combine two image to create a stereo anaglyph", |
|---|
| 262 | "-strip strip image of all profiles and comments", |
|---|
| 263 | "-thumbnail geometry create a thumbnail of the image", |
|---|
| 264 | "-transform affine transform image", |
|---|
| 265 | "-type type image type", |
|---|
| 266 | "-unsharp geometry sharpen the image", |
|---|
| 267 | "-watermark geometry percent brightness and saturation of a watermark", |
|---|
| 268 | "-write filename write images to this file", |
|---|
| 269 | (char *) NULL |
|---|
| 270 | }, |
|---|
| 271 | *settings[]= |
|---|
| 272 | { |
|---|
| 273 | "-affine matrix affine transform matrix", |
|---|
| 274 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
|---|
| 275 | "-authenticate password", |
|---|
| 276 | " decipher image with this password", |
|---|
| 277 | "-blue-primary point chromaticity blue primary point", |
|---|
| 278 | "-channel type apply option to select image channels", |
|---|
| 279 | "-colorspace type alternate image colorspace", |
|---|
| 280 | "-comment string annotate image with comment", |
|---|
| 281 | "-compose operator composite operator", |
|---|
| 282 | "-compress type type of pixel compression when writing the image", |
|---|
| 283 | "-define format:option", |
|---|
| 284 | " define one or more image format options", |
|---|
| 285 | "-depth value image depth", |
|---|
| 286 | "-density geometry horizontal and vertical density of the image", |
|---|
| 287 | "-display server get image or font from this X server", |
|---|
| 288 | "-dispose method layer disposal method", |
|---|
| 289 | "-dither method apply error diffusion to image", |
|---|
| 290 | "-encoding type text encoding type", |
|---|
| 291 | "-endian type endianness (MSB or LSB) of the image", |
|---|
| 292 | "-filter type use this filter when resizing an image", |
|---|
| 293 | "-font name render text with this font", |
|---|
| 294 | "-format \"string\" output formatted image characteristics", |
|---|
| 295 | "-gravity type which direction to gravitate towards", |
|---|
| 296 | "-green-primary point chromaticity green primary point", |
|---|
| 297 | "-interlace type type of image interlacing scheme", |
|---|
| 298 | "-interpolate method pixel color interpolation method", |
|---|
| 299 | "-label string assign a label to an image", |
|---|
| 300 | "-limit type value pixel cache resource limit", |
|---|
| 301 | "-monitor monitor progress", |
|---|
| 302 | "-page geometry size and location of an image canvas (setting)", |
|---|
| 303 | "-pointsize value font point size", |
|---|
| 304 | "-quality value JPEG/MIFF/PNG compression level", |
|---|
| 305 | "-quiet suppress all warning messages", |
|---|
| 306 | "-red-primary point chromaticity red primary point", |
|---|
| 307 | "-regard-warnings pay attention to warning messages", |
|---|
| 308 | "-respect-parenthesis settings remain in effect until parenthesis boundary", |
|---|
| 309 | "-sampling-factor geometry", |
|---|
| 310 | " horizontal and vertical sampling factor", |
|---|
| 311 | "-scene value image scene number", |
|---|
| 312 | "-seed value seed a new sequence of pseudo-random numbers", |
|---|
| 313 | "-size geometry width and height of image", |
|---|
| 314 | "-transparent-color color", |
|---|
| 315 | " transparent color", |
|---|
| 316 | "-treedepth value color tree depth", |
|---|
| 317 | "-tile repeat composite operation across and down image", |
|---|
| 318 | "-units type the units of image resolution", |
|---|
| 319 | "-verbose print detailed information about the image", |
|---|
| 320 | "-virtual-pixel method", |
|---|
| 321 | " virtual pixel access method", |
|---|
| 322 | "-white-point point chromaticity white point", |
|---|
| 323 | (char *) NULL |
|---|
| 324 | }, |
|---|
| 325 | *stack_operators[]= |
|---|
| 326 | { |
|---|
| 327 | "-swap indexes swap two images in the image sequence", |
|---|
| 328 | (char *) NULL |
|---|
| 329 | }; |
|---|
| 330 | |
|---|
| 331 | |
|---|
| 332 | (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL)); |
|---|
| 333 | (void) printf("Copyright: %s\n\n",GetMagickCopyright()); |
|---|
| 334 | (void) printf("Usage: %s [options ...] image [options ...] composite\n" |
|---|
| 335 | " [ [options ...] mask ] [options ...] composite\n", |
|---|
| 336 | GetClientName()); |
|---|
| 337 | (void) printf("\nImage Settings:\n"); |
|---|
| 338 | for (p=settings; *p != (char *) NULL; p++) |
|---|
| 339 | (void) printf(" %s\n",*p); |
|---|
| 340 | (void) printf("\nImage Operators:\n"); |
|---|
| 341 | for (p=operators; *p != (char *) NULL; p++) |
|---|
| 342 | (void) printf(" %s\n",*p); |
|---|
| 343 | (void) printf("\nImage Stack Operators:\n"); |
|---|
| 344 | for (p=stack_operators; *p != (char *) NULL; p++) |
|---|
| 345 | (void) printf(" %s\n",*p); |
|---|
| 346 | (void) printf("\nMiscellaneous Options:\n"); |
|---|
| 347 | for (p=miscellaneous; *p != (char *) NULL; p++) |
|---|
| 348 | (void) printf(" %s\n",*p); |
|---|
| 349 | (void) printf( |
|---|
| 350 | "\nBy default, the image format of `file' is determined by its magic\n"); |
|---|
| 351 | (void) printf( |
|---|
| 352 | "number. To specify a particular image format, precede the filename\n"); |
|---|
| 353 | (void) printf( |
|---|
| 354 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
|---|
| 355 | (void) printf( |
|---|
| 356 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
|---|
| 357 | (void) printf("'-' for standard input or output.\n"); |
|---|
| 358 | exit(0); |
|---|
| 359 | } |
|---|
| 360 | |
|---|
| 361 | static void GetCompositeOptions(CompositeOptions *composite_options) |
|---|
| 362 | { |
|---|
| 363 | (void) ResetMagickMemory(composite_options,0,sizeof(*composite_options)); |
|---|
| 364 | composite_options->channel=DefaultChannels; |
|---|
| 365 | composite_options->compose=OverCompositeOp; |
|---|
| 366 | } |
|---|
| 367 | |
|---|
| 368 | static void RelinquishCompositeOptions(CompositeOptions *composite_options) |
|---|
| 369 | { |
|---|
| 370 | if (composite_options->blend_geometry != (char *) NULL) |
|---|
| 371 | composite_options->blend_geometry=(char *) |
|---|
| 372 | RelinquishMagickMemory(composite_options->blend_geometry); |
|---|
| 373 | if (composite_options->displace_geometry != (char *) NULL) |
|---|
| 374 | composite_options->displace_geometry=(char *) |
|---|
| 375 | RelinquishMagickMemory(composite_options->displace_geometry); |
|---|
| 376 | if (composite_options->dissolve_geometry != (char *) NULL) |
|---|
| 377 | composite_options->dissolve_geometry=(char *) |
|---|
| 378 | RelinquishMagickMemory(composite_options->dissolve_geometry); |
|---|
| 379 | if (composite_options->geometry != (char *) NULL) |
|---|
| 380 | composite_options->geometry=(char *) |
|---|
| 381 | RelinquishMagickMemory(composite_options->geometry); |
|---|
| 382 | if (composite_options->unsharp_geometry != (char *) NULL) |
|---|
| 383 | composite_options->unsharp_geometry=(char *) |
|---|
| 384 | RelinquishMagickMemory(composite_options->unsharp_geometry); |
|---|
| 385 | if (composite_options->watermark_geometry != (char *) NULL) |
|---|
| 386 | composite_options->watermark_geometry=(char *) |
|---|
| 387 | RelinquishMagickMemory(composite_options->watermark_geometry); |
|---|
| 388 | } |
|---|
| 389 | |
|---|
| 390 | WandExport MagickBooleanType CompositeImageCommand(ImageInfo *image_info, |
|---|
| 391 | int argc,char **argv,char **metadata,ExceptionInfo *exception) |
|---|
| 392 | { |
|---|
| 393 | #define NotInitialized (unsigned int) (~0) |
|---|
| 394 | #define DestroyComposite() \ |
|---|
| 395 | { \ |
|---|
| 396 | RelinquishCompositeOptions(&composite_options); \ |
|---|
| 397 | DestroyImageStack(); \ |
|---|
| 398 | for (i=0; i < (long) argc; i++) \ |
|---|
| 399 | argv[i]=DestroyString(argv[i]); \ |
|---|
| 400 | argv=(char **) RelinquishMagickMemory(argv); \ |
|---|
| 401 | } |
|---|
| 402 | #define ThrowCompositeException(asperity,tag,option) \ |
|---|
| 403 | { \ |
|---|
| 404 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
|---|
| 405 | option == (char *) NULL ? strerror(errno) : option); \ |
|---|
| 406 | DestroyComposite(); \ |
|---|
| 407 | return(MagickFalse); \ |
|---|
| 408 | } |
|---|
| 409 | #define ThrowCompositeInvalidArgumentException(option,argument) \ |
|---|
| 410 | { \ |
|---|
| 411 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
|---|
| 412 | "InvalidArgument","`%s': %s",argument,option); \ |
|---|
| 413 | DestroyComposite(); \ |
|---|
| 414 | return(MagickFalse); \ |
|---|
| 415 | } |
|---|
| 416 | |
|---|
| 417 | char |
|---|
| 418 | *filename, |
|---|
| 419 | *option; |
|---|
| 420 | |
|---|
| 421 | CompositeOptions |
|---|
| 422 | composite_options; |
|---|
| 423 | |
|---|
| 424 | const char |
|---|
| 425 | *format; |
|---|
| 426 | |
|---|
| 427 | Image |
|---|
| 428 | *composite_image, |
|---|
| 429 | *image, |
|---|
| 430 | *images, |
|---|
| 431 | *mask_image; |
|---|
| 432 | |
|---|
| 433 | ImageStack |
|---|
| 434 | image_stack[MaxImageStackDepth+1]; |
|---|
| 435 | |
|---|
| 436 | MagickBooleanType |
|---|
| 437 | fire, |
|---|
| 438 | pend; |
|---|
| 439 | |
|---|
| 440 | MagickStatusType |
|---|
| 441 | status; |
|---|
| 442 | |
|---|
| 443 | long |
|---|
| 444 | j, |
|---|
| 445 | k; |
|---|
| 446 | |
|---|
| 447 | register long |
|---|
| 448 | i; |
|---|
| 449 | |
|---|
| 450 | |
|---|
| 451 | |
|---|
| 452 | |
|---|
| 453 | assert(image_info != (ImageInfo *) NULL); |
|---|
| 454 | assert(image_info->signature == MagickSignature); |
|---|
| 455 | if (image_info->debug != MagickFalse) |
|---|
| 456 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
|---|
| 457 | assert(exception != (ExceptionInfo *) NULL); |
|---|
| 458 | if (argc == 2) |
|---|
| 459 | { |
|---|
| 460 | option=argv[1]; |
|---|
| 461 | if ((LocaleCompare("version",option+1) == 0) || |
|---|
| 462 | (LocaleCompare("-version",option+1) == 0)) |
|---|
| 463 | { |
|---|
| 464 | (void) fprintf(stdout,"Version: %s\n", |
|---|
| 465 | GetMagickVersion((unsigned long *) NULL)); |
|---|
| 466 | (void) fprintf(stdout,"Copyright: %s\n\n",GetMagickCopyright()); |
|---|
| 467 | return(MagickFalse); |
|---|
| 468 | } |
|---|
| 469 | } |
|---|
| 470 | if (argc < 4) |
|---|
| 471 | CompositeUsage(); |
|---|
| 472 | GetCompositeOptions(&composite_options); |
|---|
| 473 | filename=(char *) NULL; |
|---|
| 474 | format="%w,%h,%m"; |
|---|
| 475 | j=1; |
|---|
| 476 | k=0; |
|---|
| 477 | NewImageStack(); |
|---|
| 478 | option=(char *) NULL; |
|---|
| 479 | pend=MagickFalse; |
|---|
| 480 | status=MagickTrue; |
|---|
| 481 | |
|---|
| 482 | |
|---|
| 483 | |
|---|
| 484 | composite_image=NewImageList(); |
|---|
| 485 | image=NewImageList(); |
|---|
| 486 | mask_image=NewImageList(); |
|---|
| 487 | ReadCommandlLine(argc,&argv); |
|---|
| 488 | status=ExpandFilenames(&argc,&argv); |
|---|
| 489 | if (status == MagickFalse) |
|---|
| 490 | ThrowCompositeException(ResourceLimitError,"MemoryAllocationFailed", |
|---|
| 491 | strerror(errno)); |
|---|
| 492 | for (i=1; i < (long) (argc-1); i++) |
|---|
| 493 | { |
|---|
| 494 | option=argv[i]; |
|---|
| 495 | if (LocaleCompare(option,"(") == 0) |
|---|
| 496 | { |
|---|
| 497 | FireImageStack(MagickFalse,MagickTrue,pend); |
|---|
| 498 | if (k == MaxImageStackDepth) |
|---|
| 499 | ThrowCompositeException(OptionError,"ParenthesisNestedTooDeeply", |
|---|
| 500 | option); |
|---|
| 501 | PushImageStack(); |
|---|
| 502 | continue; |
|---|
| 503 | } |
|---|
| 504 | if (LocaleCompare(option,")") == 0) |
|---|
| 505 | { |
|---|
| 506 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
|---|
| 507 | if (k == 0) |
|---|
| 508 | ThrowCompositeException(OptionError,"UnableToParseExpression",option); |
|---|
| 509 | PopImageStack(); |
|---|
| 510 | continue; |
|---|
| 511 | } |
|---|
| 512 | if (IsMagickOption(option) == MagickFalse) |
|---|
| 513 | { |
|---|
| 514 | Image |
|---|
| 515 | *images; |
|---|
| 516 | |
|---|
| 517 | |
|---|
| 518 | |
|---|
| 519 | |
|---|
| 520 | FireImageStack(MagickFalse,MagickTrue,pend); |
|---|
| 521 | filename=argv[i]; |
|---|
| 522 | if ((LocaleCompare(filename,"--") == 0) && (i < (argc-1))) |
|---|
| 523 | filename=argv[++i]; |
|---|
| 524 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
|---|
| 525 | images=ReadImages(image_info,exception); |
|---|
| 526 | status&=(images != (Image *) NULL) && |
|---|
| 527 | (exception->severity < ErrorException); |
|---|
| 528 | if (images == (Image *) NULL) |
|---|
| 529 | continue; |
|---|
| 530 | AppendImageStack(images); |
|---|
| 531 | continue; |
|---|
| 532 | } |
|---|
| 533 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
|---|
| 534 | switch (*(option+1)) |
|---|
| 535 | { |
|---|
| 536 | case 'a': |
|---|
| 537 | { |
|---|
| 538 | if (LocaleCompare("affine",option+1) == 0) |
|---|
| 539 | { |
|---|
| 540 | if (*option == '+') |
|---|
| 541 | break; |
|---|
| 542 | i++; |
|---|
| 543 | if (i == (long) argc) |
|---|
| 544 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 545 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 546 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
|---|
| 547 | break; |
|---|
| 548 | } |
|---|
| 549 | if (LocaleCompare("alpha",option+1) == 0) |
|---|
| 550 | { |
|---|
| 551 | long |
|---|
| 552 | type; |
|---|
| 553 | |
|---|
| 554 | if (*option == '+') |
|---|
| 555 | break; |
|---|
| 556 | i++; |
|---|
| 557 | if (i == (long) argc) |
|---|
| 558 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 559 | type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]); |
|---|
| 560 | if (type < 0) |
|---|
| 561 | ThrowCompositeException(OptionError, |
|---|
| 562 | "UnrecognizedAlphaChannelType",argv[i]); |
|---|
| 563 | break; |
|---|
| 564 | } |
|---|
| 565 | if (LocaleCompare("authenticate",option+1) == 0) |
|---|
| 566 | { |
|---|
| 567 | if (*option == '+') |
|---|
| 568 | break; |
|---|
| 569 | i++; |
|---|
| 570 | if (i == (long) argc) |
|---|
| 571 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 572 | break; |
|---|
| 573 | } |
|---|
| 574 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
|---|
| 575 | } |
|---|
| 576 | case 'b': |
|---|
| 577 | { |
|---|
| 578 | if (LocaleCompare("background",option+1) == 0) |
|---|
| 579 | { |
|---|
| 580 | if (*option == '+') |
|---|
| 581 | break; |
|---|
| 582 | i++; |
|---|
| 583 | if (i == (long) argc) |
|---|
| 584 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 585 | break; |
|---|
| 586 | } |
|---|
| 587 | if (LocaleCompare("blend",option+1) == 0) |
|---|
| 588 | { |
|---|
| 589 | (void) CloneString(&composite_options.blend_geometry,(char *) NULL); |
|---|
| 590 | if (*option == '+') |
|---|
| 591 | break; |
|---|
| 592 | i++; |
|---|
| 593 | if (i == (long) argc) |
|---|
| 594 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 595 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 596 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
|---|
| 597 | (void) CloneString(&composite_options.blend_geometry,argv[i]); |
|---|
| 598 | composite_options.compose=BlendCompositeOp; |
|---|
| 599 | break; |
|---|
| 600 | } |
|---|
| 601 | if (LocaleCompare("blue-primary",option+1) == 0) |
|---|
| 602 | { |
|---|
| 603 | if (*option == '+') |
|---|
| 604 | break; |
|---|
| 605 | i++; |
|---|
| 606 | if (i == (long) argc) |
|---|
| 607 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 608 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 609 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
|---|
| 610 | break; |
|---|
| 611 | } |
|---|
| 612 | if (LocaleCompare("border",option+1) == 0) |
|---|
| 613 | { |
|---|
| 614 | if (*option == '+') |
|---|
| 615 | break; |
|---|
| 616 | i++; |
|---|
| 617 | if (i == (long) (argc-1)) |
|---|
| 618 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 619 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 620 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
|---|
| 621 | break; |
|---|
| 622 | } |
|---|
| 623 | if (LocaleCompare("bordercolor",option+1) == 0) |
|---|
| 624 | { |
|---|
| 625 | if (*option == '+') |
|---|
| 626 | break; |
|---|
| 627 | i++; |
|---|
| 628 | if (i == (long) (argc-1)) |
|---|
| 629 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 630 | break; |
|---|
| 631 | } |
|---|
| 632 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
|---|
| 633 | } |
|---|
| 634 | case 'c': |
|---|
| 635 | { |
|---|
| 636 | if (LocaleCompare("cache",option+1) == 0) |
|---|
| 637 | { |
|---|
| 638 | if (*option == '+') |
|---|
| 639 | break; |
|---|
| 640 | i++; |
|---|
| 641 | if (i == (long) argc) |
|---|
| 642 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 643 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 644 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
|---|
| 645 | break; |
|---|
| 646 | } |
|---|
| 647 | if (LocaleCompare("channel",option+1) == 0) |
|---|
| 648 | { |
|---|
| 649 | long |
|---|
| 650 | channel; |
|---|
| 651 | |
|---|
| 652 | if (*option == '+') |
|---|
| 653 | { |
|---|
| 654 | composite_options.channel=DefaultChannels; |
|---|
| 655 | break; |
|---|
| 656 | } |
|---|
| 657 | i++; |
|---|
| 658 | if (i == (long) (argc-1)) |
|---|
| 659 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 660 | channel=ParseChannelOption(argv[i]); |
|---|
| 661 | if (channel < 0) |
|---|
| 662 | ThrowCompositeException(OptionError,"UnrecognizedChannelType", |
|---|
| 663 | argv[i]); |
|---|
| 664 | composite_options.channel=(ChannelType) channel; |
|---|
| 665 | break; |
|---|
| 666 | } |
|---|
| 667 | if (LocaleCompare("colors",option+1) == 0) |
|---|
| 668 | { |
|---|
| 669 | if (*option == '+') |
|---|
| 670 | break; |
|---|
| 671 | i++; |
|---|
| 672 | if (i == (long) argc) |
|---|
| 673 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 674 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 675 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
|---|
| 676 | break; |
|---|
| 677 | } |
|---|
| 678 | if (LocaleCompare("colorspace",option+1) == 0) |
|---|
| 679 | { |
|---|
| 680 | long |
|---|
| 681 | colorspace; |
|---|
| 682 | |
|---|
| 683 | if (*option == '+') |
|---|
| 684 | break; |
|---|
| 685 | i++; |
|---|
| 686 | if (i == (long) argc) |
|---|
| 687 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 688 | colorspace=ParseMagickOption(MagickColorspaceOptions, |
|---|
| 689 | MagickFalse,argv[i]); |
|---|
| 690 | if (colorspace < 0) |
|---|
| 691 | ThrowCompositeException(OptionError,"UnrecognizedColorspace", |
|---|
| 692 | argv[i]); |
|---|
| 693 | break; |
|---|
| 694 | } |
|---|
| 695 | if (LocaleCompare("comment",option+1) == 0) |
|---|
| 696 | { |
|---|
| 697 | if (*option == '+') |
|---|
| 698 | break; |
|---|
| 699 | i++; |
|---|
| 700 | if (i == (long) argc) |
|---|
| 701 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 702 | break; |
|---|
| 703 | } |
|---|
| 704 | if (LocaleCompare("compose",option+1) == 0) |
|---|
| 705 | { |
|---|
| 706 | long |
|---|
| 707 | compose; |
|---|
| 708 | |
|---|
| 709 | composite_options.compose=UndefinedCompositeOp; |
|---|
| 710 | if (*option == '+') |
|---|
| 711 | break; |
|---|
| 712 | i++; |
|---|
| 713 | if (i == (long) argc) |
|---|
| 714 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 715 | compose=ParseMagickOption(MagickComposeOptions,MagickFalse, |
|---|
| 716 | argv[i]); |
|---|
| 717 | if (compose < 0) |
|---|
| 718 | ThrowCompositeException(OptionError,"UnrecognizedComposeOperator", |
|---|
| 719 | argv[i]); |
|---|
| 720 | composite_options.compose=(CompositeOperator) compose; |
|---|
| 721 | break; |
|---|
| 722 | } |
|---|
| 723 | if (LocaleCompare("compress",option+1) == 0) |
|---|
| 724 | { |
|---|
| 725 | long |
|---|
| 726 | compress; |
|---|
| 727 | |
|---|
| 728 | if (*option == '+') |
|---|
| 729 | break; |
|---|
| 730 | i++; |
|---|
| 731 | if (i == (long) argc) |
|---|
| 732 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 733 | compress=ParseMagickOption(MagickCompressOptions,MagickFalse, |
|---|
| 734 | argv[i]); |
|---|
| 735 | if (compress < 0) |
|---|
| 736 | ThrowCompositeException(OptionError, |
|---|
| 737 | "UnrecognizedImageCompression",argv[i]); |
|---|
| 738 | break; |
|---|
| 739 | } |
|---|
| 740 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
|---|
| 741 | } |
|---|
| 742 | case 'd': |
|---|
| 743 | { |
|---|
| 744 | if (LocaleCompare("debug",option+1) == 0) |
|---|
| 745 | { |
|---|
| 746 | long |
|---|
| 747 | event; |
|---|
| 748 | |
|---|
| 749 | if (*option == '+') |
|---|
| 750 | break; |
|---|
| 751 | i++; |
|---|
| 752 | if (i == (long) argc) |
|---|
| 753 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 754 | event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]); |
|---|
| 755 | if (event < 0) |
|---|
| 756 | ThrowCompositeException(OptionError,"UnrecognizedEventType", |
|---|
| 757 | argv[i]); |
|---|
| 758 | (void) SetLogEventMask(argv[i]); |
|---|
| 759 | break; |
|---|
| 760 | } |
|---|
| 761 | if (LocaleCompare("decipher",option+1) == 0) |
|---|
| 762 | { |
|---|
| 763 | if (*option == '+') |
|---|
| 764 | break; |
|---|
| 765 | i++; |
|---|
| 766 | if (i == (long) (argc-1)) |
|---|
| 767 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 768 | break; |
|---|
| 769 | } |
|---|
| 770 | if (LocaleCompare("define",option+1) == 0) |
|---|
| 771 | { |
|---|
| 772 | i++; |
|---|
| 773 | if (i == (long) argc) |
|---|
| 774 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 775 | if (*option == '+') |
|---|
| 776 | { |
|---|
| 777 | const char |
|---|
| 778 | *define; |
|---|
| 779 | |
|---|
| 780 | define=GetImageOption(image_info,argv[i]); |
|---|
| 781 | if (define == (const char *) NULL) |
|---|
| 782 | ThrowCompositeException(OptionError,"NoSuchOption",argv[i]); |
|---|
| 783 | break; |
|---|
| 784 | } |
|---|
| 785 | break; |
|---|
| 786 | } |
|---|
| 787 | if (LocaleCompare("density",option+1) == 0) |
|---|
| 788 | { |
|---|
| 789 | if (*option == '+') |
|---|
| 790 | break; |
|---|
| 791 | i++; |
|---|
| 792 | if (i == (long) argc) |
|---|
| 793 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 794 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 795 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
|---|
| 796 | break; |
|---|
| 797 | } |
|---|
| 798 | if (LocaleCompare("depth",option+1) == 0) |
|---|
| 799 | { |
|---|
| 800 | if (*option == '+') |
|---|
| 801 | break; |
|---|
| 802 | i++; |
|---|
| 803 | if (i == (long) argc) |
|---|
| 804 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 805 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 806 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
|---|
| 807 | break; |
|---|
| 808 | } |
|---|
| 809 | if (LocaleCompare("displace",option+1) == 0) |
|---|
| 810 | { |
|---|
| 811 | (void) CloneString(&composite_options.displace_geometry, |
|---|
| 812 | (char *) NULL); |
|---|
| 813 | if (*option == '+') |
|---|
| 814 | break; |
|---|
| 815 | i++; |
|---|
| 816 | if (i == (long) argc) |
|---|
| 817 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 818 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 819 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
|---|
| 820 | (void) CloneString(&composite_options.displace_geometry,argv[i]); |
|---|
| 821 | composite_options.compose=DisplaceCompositeOp; |
|---|
| 822 | break; |
|---|
| 823 | } |
|---|
| 824 | if (LocaleCompare("display",option+1) == 0) |
|---|
| 825 | { |
|---|
| 826 | if (*option == '+') |
|---|
| 827 | break; |
|---|
| 828 | i++; |
|---|
| 829 | if (i == (long) argc) |
|---|
| 830 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 831 | break; |
|---|
| 832 | } |
|---|
| 833 | if (LocaleCompare("dispose",option+1) == 0) |
|---|
| 834 | { |
|---|
| 835 | long |
|---|
| 836 | dispose; |
|---|
| 837 | |
|---|
| 838 | if (*option == '+') |
|---|
| 839 | break; |
|---|
| 840 | i++; |
|---|
| 841 | if (i == (long) argc) |
|---|
| 842 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 843 | dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]); |
|---|
| 844 | if (dispose < 0) |
|---|
| 845 | ThrowCompositeException(OptionError,"UnrecognizedDisposeMethod", |
|---|
| 846 | argv[i]); |
|---|
| 847 | break; |
|---|
| 848 | } |
|---|
| 849 | if (LocaleCompare("dissolve",option+1) == 0) |
|---|
| 850 | { |
|---|
| 851 | (void) CloneString(&composite_options.dissolve_geometry, |
|---|
| 852 | (char *) NULL); |
|---|
| 853 | if (*option == '+') |
|---|
| 854 | break; |
|---|
| 855 | i++; |
|---|
| 856 | if (i == (long) argc) |
|---|
| 857 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 858 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 859 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
|---|
| 860 | (void) CloneString(&composite_options.dissolve_geometry,argv[i]); |
|---|
| 861 | composite_options.compose=DissolveCompositeOp; |
|---|
| 862 | break; |
|---|
| 863 | } |
|---|
| 864 | if (LocaleCompare("method",option+1) == 0) |
|---|
| 865 | { |
|---|
| 866 | long |
|---|
| 867 | method; |
|---|
| 868 | |
|---|
| 869 | if (*option == '+') |
|---|
| 870 | break; |
|---|
| 871 | i++; |
|---|
| 872 | if (i == (long) argc) |
|---|
| 873 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 874 | method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]); |
|---|
| 875 | if (method < 0) |
|---|
| 876 | ThrowCompositeException(OptionError,"UnrecognizedDitherMethod", |
|---|
| 877 | argv[i]); |
|---|
| 878 | break; |
|---|
| 879 | } |
|---|
| 880 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
|---|
| 881 | } |
|---|
| 882 | case 'e': |
|---|
| 883 | { |
|---|
| 884 | if (LocaleCompare("encipher",option+1) == 0) |
|---|
| 885 | { |
|---|
| 886 | if (*option == '+') |
|---|
| 887 | break; |
|---|
| 888 | i++; |
|---|
| 889 | if (i == (long) (argc-1)) |
|---|
| 890 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 891 | break; |
|---|
| 892 | } |
|---|
| 893 | if (LocaleCompare("encoding",option+1) == 0) |
|---|
| 894 | { |
|---|
| 895 | if (*option == '+') |
|---|
| 896 | break; |
|---|
| 897 | i++; |
|---|
| 898 | if (i == (long) argc) |
|---|
| 899 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 900 | break; |
|---|
| 901 | } |
|---|
| 902 | if (LocaleCompare("endian",option+1) == 0) |
|---|
| 903 | { |
|---|
| 904 | long |
|---|
| 905 | endian; |
|---|
| 906 | |
|---|
| 907 | if (*option == '+') |
|---|
| 908 | break; |
|---|
| 909 | i++; |
|---|
| 910 | if (i == (long) argc) |
|---|
| 911 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 912 | endian=ParseMagickOption(MagickEndianOptions,MagickFalse, |
|---|
| 913 | argv[i]); |
|---|
| 914 | if (endian < 0) |
|---|
| 915 | ThrowCompositeException(OptionError,"UnrecognizedEndianType", |
|---|
| 916 | argv[i]); |
|---|
| 917 | break; |
|---|
| 918 | } |
|---|
| 919 | if (LocaleCompare("extract",option+1) == 0) |
|---|
| 920 | { |
|---|
| 921 | if (*option == '+') |
|---|
| 922 | break; |
|---|
| 923 | i++; |
|---|
| 924 | if (i == (long) argc) |
|---|
| 925 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 926 | if (IsGeometry(argv[i]) == MagickFalse) |
|---|
| 927 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
|---|
| 928 | break; |
|---|
| 929 | } |
|---|
| 930 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
|---|
| 931 | } |
|---|
| 932 | case 'f': |
|---|
| 933 | { |
|---|
| 934 | if (LocaleCompare("filter",option+1) == 0) |
|---|
| 935 | { |
|---|
| 936 | long |
|---|
| 937 | filter; |
|---|
| 938 | |
|---|
| 939 | if (*option == '+') |
|---|
| 940 | break; |
|---|
| 941 | i++; |
|---|
| 942 | if (i == (long) argc) |
|---|
| 943 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 944 | filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]); |
|---|
| 945 | if (filter < 0) |
|---|
| 946 | ThrowCompositeException(OptionError,"UnrecognizedImageFilter", |
|---|
| 947 | argv[i]); |
|---|
| 948 | break; |
|---|
| 949 | } |
|---|
| 950 | if (LocaleCompare("font",option+1) == 0) |
|---|
| 951 | { |
|---|
| 952 | if (*option == '+') |
|---|
| 953 | break; |
|---|
| 954 | i++; |
|---|
| 955 | if (i == (long) argc) |
|---|
| 956 | ThrowCompositeException(OptionError,"MissingArgument",option); |
|---|
| 957 | break; |
|---|
| 958 | } |
|---|
| 959 | if (LocaleCompare("format" |
|---|