cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % CCCC OOO M M PPPP OOO SSSSS IIIII TTTTT EEEEE % |
| 7 | % C O O MM MM P P O O SS I T E % |
| 8 | % C O O M M M PPPP O O SSS I T EEE % |
| 9 | % C O O M M P O O SS I T E % |
| 10 | % CCCC OOO M M P OOO SSSSS IIIII T EEEEE % |
| 11 | % % |
| 12 | % % |
| 13 | % MagickWand Image Composite Methods % |
| 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 | % July 1992 % |
| 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 | % Use the composite program to overlap one image over another. |
| 37 | % |
| 38 | */ |
| 39 | |
| 40 | /* |
| 41 | Include declarations. |
| 42 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 43 | #include "MagickWand/studio.h" |
| 44 | #include "MagickWand/MagickWand.h" |
| 45 | #include "MagickWand/mogrify-private.h" |
| 46 | #include "MagickCore/string-private.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 47 | |
| 48 | /* |
| 49 | Typedef declarations. |
| 50 | */ |
| 51 | typedef struct _CompositeOptions |
| 52 | { |
cristy | ab01585 | 2011-07-06 01:03:32 +0000 | [diff] [blame] | 53 | ChannelType |
| 54 | channel; |
| 55 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 56 | char |
| 57 | *compose_args, |
| 58 | *geometry; |
| 59 | |
| 60 | CompositeOperator |
| 61 | compose; |
| 62 | |
| 63 | GravityType |
| 64 | gravity; |
| 65 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 66 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 67 | stegano; |
| 68 | |
| 69 | RectangleInfo |
| 70 | offset; |
| 71 | |
| 72 | MagickBooleanType |
| 73 | stereo, |
| 74 | tile; |
| 75 | } CompositeOptions; |
| 76 | |
| 77 | /* |
| 78 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 79 | % % |
| 80 | % % |
| 81 | % % |
| 82 | % C o m p o s i t e I m a g e C o m m a n d % |
| 83 | % % |
| 84 | % % |
| 85 | % % |
| 86 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 87 | % |
| 88 | % CompositeImageCommand() reads one or more images and an optional mask and |
| 89 | % composites them into a new image. |
| 90 | % |
| 91 | % The format of the CompositeImageCommand method is: |
| 92 | % |
| 93 | % MagickBooleanType CompositeImageCommand(ImageInfo *image_info,int argc, |
| 94 | % char **argv,char **metadata,ExceptionInfo *exception) |
| 95 | % |
| 96 | % A description of each parameter follows: |
| 97 | % |
| 98 | % o image_info: the image info. |
| 99 | % |
| 100 | % o argc: the number of elements in the argument vector. |
| 101 | % |
| 102 | % o argv: A text array containing the command line arguments. |
| 103 | % |
| 104 | % o metadata: any metadata is returned here. |
| 105 | % |
| 106 | % o exception: return any errors or warnings in this structure. |
| 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); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 118 | assert(image_info->signature == MagickCoreSignature); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 119 | assert(image != (Image **) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 120 | assert((*image)->signature == MagickCoreSignature); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 | { |
cristy | f2a82ee | 2014-05-26 17:49:54 +0000 | [diff] [blame] | 127 | ChannelType |
| 128 | channel_mask; |
| 129 | |
| 130 | channel_mask=SetImageChannelMask(composite_image, |
| 131 | composite_options->channel); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 132 | assert(composite_image->signature == MagickCoreSignature); |
cristy | bd5a96c | 2011-08-21 00:04:26 +0000 | [diff] [blame] | 133 | switch (composite_options->compose) |
| 134 | { |
| 135 | case BlendCompositeOp: |
| 136 | case BlurCompositeOp: |
| 137 | case DisplaceCompositeOp: |
| 138 | case DistortCompositeOp: |
| 139 | case DissolveCompositeOp: |
| 140 | case ModulateCompositeOp: |
| 141 | case ThresholdCompositeOp: |
cristy | dd9344f | 2015-01-04 18:56:43 +0000 | [diff] [blame] | 142 | { |
cristy | e9b9857 | 2015-03-25 19:49:41 +0000 | [diff] [blame] | 143 | (void) SetImageArtifact(*image,"compose:args", |
cristy | bd5a96c | 2011-08-21 00:04:26 +0000 | [diff] [blame] | 144 | composite_options->compose_args); |
| 145 | break; |
cristy | dd9344f | 2015-01-04 18:56:43 +0000 | [diff] [blame] | 146 | } |
cristy | bd5a96c | 2011-08-21 00:04:26 +0000 | [diff] [blame] | 147 | default: |
| 148 | break; |
| 149 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 150 | /* |
| 151 | Composite image. |
| 152 | */ |
| 153 | if (composite_options->stegano != 0) |
| 154 | { |
| 155 | Image |
| 156 | *stegano_image; |
| 157 | |
| 158 | (*image)->offset=composite_options->stegano-1; |
| 159 | stegano_image=SteganoImage(*image,composite_image,exception); |
| 160 | if (stegano_image != (Image *) NULL) |
| 161 | { |
| 162 | *image=DestroyImageList(*image); |
| 163 | *image=stegano_image; |
| 164 | } |
| 165 | } |
| 166 | else |
| 167 | if (composite_options->stereo != MagickFalse) |
| 168 | { |
| 169 | Image |
| 170 | *stereo_image; |
| 171 | |
| 172 | stereo_image=StereoAnaglyphImage(*image,composite_image, |
| 173 | composite_options->offset.x,composite_options->offset.y, |
| 174 | exception); |
| 175 | if (stereo_image != (Image *) NULL) |
| 176 | { |
| 177 | *image=DestroyImageList(*image); |
| 178 | *image=stereo_image; |
| 179 | } |
| 180 | } |
| 181 | else |
| 182 | if (composite_options->tile != MagickFalse) |
| 183 | { |
cristy | 9d314ff | 2011-03-09 01:30:28 +0000 | [diff] [blame] | 184 | size_t |
| 185 | columns; |
| 186 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 187 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 188 | x, |
| 189 | y; |
| 190 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 191 | /* |
| 192 | Tile the composite image. |
| 193 | */ |
cristy | e9b9857 | 2015-03-25 19:49:41 +0000 | [diff] [blame] | 194 | (void) SetImageArtifact(*image,"compose:outside-overlay","false"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 195 | columns=composite_image->columns; |
cristy | eaedf06 | 2010-05-29 22:36:02 +0000 | [diff] [blame] | 196 | for (y=0; y < (ssize_t) (*image)->rows; y+=(ssize_t) composite_image->rows) |
| 197 | for (x=0; x < (ssize_t) (*image)->columns; x+=(ssize_t) columns) |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 198 | status&=CompositeImage(*image,composite_image, |
cristy | 3917240 | 2012-03-30 13:04:39 +0000 | [diff] [blame] | 199 | composite_options->compose,MagickTrue,x,y,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 200 | } |
| 201 | else |
| 202 | { |
| 203 | RectangleInfo |
| 204 | geometry; |
| 205 | |
| 206 | /* |
| 207 | Work out gravity Adjustment of Offset |
| 208 | */ |
| 209 | SetGeometry(*image,&geometry); |
| 210 | (void) ParseAbsoluteGeometry(composite_options->geometry, |
| 211 | &geometry); |
| 212 | geometry.width=composite_image->columns; |
| 213 | geometry.height=composite_image->rows; |
| 214 | GravityAdjustGeometry((*image)->columns,(*image)->rows, |
| 215 | composite_options->gravity, &geometry); |
| 216 | (*image)->gravity=(GravityType) composite_options->gravity; |
| 217 | /* |
| 218 | Digitally composite image. |
| 219 | */ |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 220 | status&=CompositeImage(*image,composite_image, |
cristy | 3917240 | 2012-03-30 13:04:39 +0000 | [diff] [blame] | 221 | composite_options->compose,MagickTrue,geometry.x,geometry.y, |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 222 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 223 | } |
cristy | f2a82ee | 2014-05-26 17:49:54 +0000 | [diff] [blame] | 224 | (void) SetPixelChannelMask(composite_image,channel_mask); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 225 | } |
| 226 | return(status != 0 ? MagickTrue : MagickFalse); |
| 227 | } |
| 228 | |
| 229 | static MagickBooleanType CompositeUsage(void) |
| 230 | { |
| 231 | const char |
| 232 | **p; |
| 233 | |
| 234 | static const char |
| 235 | *miscellaneous[]= |
| 236 | { |
| 237 | "-debug events display copious debugging information", |
| 238 | "-help print program options", |
| 239 | "-list type print a list of supported option arguments", |
| 240 | "-log format format of debugging information", |
| 241 | "-version print version information", |
| 242 | (char *) NULL |
| 243 | }, |
| 244 | *operators[]= |
| 245 | { |
| 246 | "-blend geometry blend images", |
| 247 | "-border geometry surround image with a border of color", |
| 248 | "-bordercolor color border color", |
cristy | 17ada02 | 2014-11-07 22:12:23 +0000 | [diff] [blame] | 249 | "-channel mask set the image channel mask", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 250 | "-colors value preferred number of colors in the image", |
| 251 | "-decipher filename convert cipher pixels to plain pixels", |
| 252 | "-displace geometry shift lookup according to a relative displacement map", |
| 253 | "-dissolve value dissolve the two images a given percent", |
| 254 | "-distort geometry shift lookup according to a absolute distortion map", |
| 255 | "-encipher filename convert plain pixels to cipher pixels", |
| 256 | "-extract geometry extract area from image", |
| 257 | "-geometry geometry location of the composite image", |
| 258 | "-identify identify the format and characteristics of the image", |
| 259 | "-monochrome transform image to black and white", |
| 260 | "-negate replace every pixel with its complementary color ", |
| 261 | "-profile filename add ICM or IPTC information profile to image", |
| 262 | "-quantize colorspace reduce colors in this colorspace", |
| 263 | "-repage geometry size and location of an image canvas (operator)", |
| 264 | "-rotate degrees apply Paeth rotation to the image", |
| 265 | "-resize geometry resize the image", |
| 266 | "-sharpen geometry sharpen the image", |
| 267 | "-shave geometry shave pixels from the image edges", |
| 268 | "-stegano offset hide watermark within an image", |
| 269 | "-stereo geometry combine two image to create a stereo anaglyph", |
| 270 | "-strip strip image of all profiles and comments", |
| 271 | "-thumbnail geometry create a thumbnail of the image", |
| 272 | "-transform affine transform image", |
| 273 | "-type type image type", |
| 274 | "-unsharp geometry sharpen the image", |
| 275 | "-watermark geometry percent brightness and saturation of a watermark", |
| 276 | "-write filename write images to this file", |
| 277 | (char *) NULL |
| 278 | }, |
| 279 | *settings[]= |
| 280 | { |
| 281 | "-affine matrix affine transform matrix", |
| 282 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 283 | " transparent, extract, background, or shape", |
| 284 | "-authenticate password", |
| 285 | " decipher image with this password", |
| 286 | "-blue-primary point chromaticity blue primary point", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 287 | "-colorspace type alternate image colorspace", |
| 288 | "-comment string annotate image with comment", |
| 289 | "-compose operator composite operator", |
| 290 | "-compress type type of pixel compression when writing the image", |
| 291 | "-define format:option", |
| 292 | " define one or more image format options", |
| 293 | "-depth value image depth", |
| 294 | "-density geometry horizontal and vertical density of the image", |
| 295 | "-display server get image or font from this X server", |
| 296 | "-dispose method layer disposal method", |
| 297 | "-dither method apply error diffusion to image", |
| 298 | "-encoding type text encoding type", |
| 299 | "-endian type endianness (MSB or LSB) of the image", |
| 300 | "-filter type use this filter when resizing an image", |
| 301 | "-font name render text with this font", |
| 302 | "-format \"string\" output formatted image characteristics", |
| 303 | "-gravity type which direction to gravitate towards", |
| 304 | "-green-primary point chromaticity green primary point", |
| 305 | "-interlace type type of image interlacing scheme", |
| 306 | "-interpolate method pixel color interpolation method", |
| 307 | "-label string assign a label to an image", |
| 308 | "-limit type value pixel cache resource limit", |
cristy | e9252c2 | 2013-07-30 15:43:21 +0000 | [diff] [blame] | 309 | "-matte store matte channel if the image has one", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 310 | "-monitor monitor progress", |
| 311 | "-page geometry size and location of an image canvas (setting)", |
| 312 | "-pointsize value font point size", |
| 313 | "-quality value JPEG/MIFF/PNG compression level", |
| 314 | "-quiet suppress all warning messages", |
| 315 | "-red-primary point chromaticity red primary point", |
| 316 | "-regard-warnings pay attention to warning messages", |
| 317 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 318 | "-sampling-factor geometry", |
| 319 | " horizontal and vertical sampling factor", |
| 320 | "-scene value image scene number", |
| 321 | "-seed value seed a new sequence of pseudo-random numbers", |
| 322 | "-size geometry width and height of image", |
cristy | e9252c2 | 2013-07-30 15:43:21 +0000 | [diff] [blame] | 323 | "-support factor resize support: > 1.0 is blurry, < 1.0 is sharp", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 324 | "-synchronize synchronize image to storage device", |
| 325 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 326 | "-transparent-color color", |
| 327 | " transparent color", |
| 328 | "-treedepth value color tree depth", |
| 329 | "-tile repeat composite operation across and down image", |
| 330 | "-units type the units of image resolution", |
| 331 | "-verbose print detailed information about the image", |
| 332 | "-virtual-pixel method", |
| 333 | " virtual pixel access method", |
| 334 | "-white-point point chromaticity white point", |
| 335 | (char *) NULL |
| 336 | }, |
| 337 | *stack_operators[]= |
| 338 | { |
| 339 | "-swap indexes swap two images in the image sequence", |
| 340 | (char *) NULL |
| 341 | }; |
| 342 | |
| 343 | |
cristy | 4f7a613 | 2012-12-23 00:35:19 +0000 | [diff] [blame] | 344 | ListMagickVersion(stdout); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 345 | (void) printf("Usage: %s [options ...] image [options ...] composite\n" |
| 346 | " [ [options ...] mask ] [options ...] composite\n", |
| 347 | GetClientName()); |
| 348 | (void) printf("\nImage Settings:\n"); |
| 349 | for (p=settings; *p != (char *) NULL; p++) |
| 350 | (void) printf(" %s\n",*p); |
| 351 | (void) printf("\nImage Operators:\n"); |
| 352 | for (p=operators; *p != (char *) NULL; p++) |
| 353 | (void) printf(" %s\n",*p); |
| 354 | (void) printf("\nImage Stack Operators:\n"); |
| 355 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 356 | (void) printf(" %s\n",*p); |
| 357 | (void) printf("\nMiscellaneous Options:\n"); |
| 358 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 359 | (void) printf(" %s\n",*p); |
| 360 | (void) printf( |
anthony | e5b3965 | 2012-04-21 05:37:29 +0000 | [diff] [blame] | 361 | "\nBy default, the image format of 'file' is determined by its magic\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 362 | (void) printf( |
| 363 | "number. To specify a particular image format, precede the filename\n"); |
| 364 | (void) printf( |
| 365 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 366 | (void) printf( |
| 367 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 368 | (void) printf("'-' for standard input or output.\n"); |
| 369 | return(MagickFalse); |
| 370 | } |
| 371 | |
| 372 | static void GetCompositeOptions(CompositeOptions *composite_options) |
| 373 | { |
| 374 | (void) ResetMagickMemory(composite_options,0,sizeof(*composite_options)); |
cristy | ab01585 | 2011-07-06 01:03:32 +0000 | [diff] [blame] | 375 | composite_options->channel=DefaultChannels; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 376 | composite_options->compose=OverCompositeOp; |
| 377 | } |
| 378 | |
| 379 | static void RelinquishCompositeOptions(CompositeOptions *composite_options) |
| 380 | { |
| 381 | if (composite_options->compose_args != (char *) NULL) |
| 382 | composite_options->compose_args=(char *) |
| 383 | RelinquishMagickMemory(composite_options->compose_args); |
cristy | df40958 | 2015-06-12 16:35:04 +0000 | [diff] [blame] | 384 | if (composite_options->geometry != (char *) NULL) |
| 385 | composite_options->geometry=(char *) |
| 386 | RelinquishMagickMemory(composite_options->geometry); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 387 | } |
| 388 | |
| 389 | WandExport MagickBooleanType CompositeImageCommand(ImageInfo *image_info, |
| 390 | int argc,char **argv,char **metadata,ExceptionInfo *exception) |
| 391 | { |
| 392 | #define NotInitialized (unsigned int) (~0) |
| 393 | #define DestroyComposite() \ |
| 394 | { \ |
| 395 | RelinquishCompositeOptions(&composite_options); \ |
| 396 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 397 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 398 | argv[i]=DestroyString(argv[i]); \ |
| 399 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 400 | } |
| 401 | #define ThrowCompositeException(asperity,tag,option) \ |
| 402 | { \ |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 403 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 404 | option == (char *) NULL ? GetExceptionMessage(errno) : option); \ |
| 405 | DestroyComposite(); \ |
| 406 | return(MagickFalse); \ |
| 407 | } |
| 408 | #define ThrowCompositeInvalidArgumentException(option,argument) \ |
| 409 | { \ |
| 410 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
anthony | e5b3965 | 2012-04-21 05:37:29 +0000 | [diff] [blame] | 411 | "InvalidArgument","'%s': %s",option,argument); \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 412 | DestroyComposite(); \ |
| 413 | return(MagickFalse); \ |
| 414 | } |
| 415 | |
| 416 | char |
| 417 | *filename, |
| 418 | *option; |
| 419 | |
| 420 | CompositeOptions |
| 421 | composite_options; |
| 422 | |
| 423 | const char |
| 424 | *format; |
| 425 | |
| 426 | Image |
| 427 | *composite_image, |
| 428 | *image, |
| 429 | *images, |
| 430 | *mask_image; |
| 431 | |
| 432 | ImageStack |
| 433 | image_stack[MaxImageStackDepth+1]; |
| 434 | |
| 435 | MagickBooleanType |
| 436 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 437 | pend, |
| 438 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 439 | |
| 440 | MagickStatusType |
| 441 | status; |
| 442 | |
cristy | 9d314ff | 2011-03-09 01:30:28 +0000 | [diff] [blame] | 443 | register ssize_t |
| 444 | i; |
| 445 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 446 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 447 | j, |
| 448 | k; |
| 449 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 450 | /* |
| 451 | Set default. |
| 452 | */ |
| 453 | assert(image_info != (ImageInfo *) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 454 | assert(image_info->signature == MagickCoreSignature); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 | { |
cristy | 4f7a613 | 2012-12-23 00:35:19 +0000 | [diff] [blame] | 464 | ListMagickVersion(stdout); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 465 | return(MagickFalse); |
| 466 | } |
| 467 | } |
| 468 | if (argc < 4) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 469 | return(CompositeUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 470 | GetCompositeOptions(&composite_options); |
| 471 | filename=(char *) NULL; |
| 472 | format="%w,%h,%m"; |
| 473 | j=1; |
| 474 | k=0; |
| 475 | NewImageStack(); |
| 476 | option=(char *) NULL; |
| 477 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 478 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 479 | status=MagickTrue; |
| 480 | /* |
| 481 | Check command syntax. |
| 482 | */ |
| 483 | composite_image=NewImageList(); |
| 484 | image=NewImageList(); |
| 485 | mask_image=NewImageList(); |
| 486 | ReadCommandlLine(argc,&argv); |
| 487 | status=ExpandFilenames(&argc,&argv); |
| 488 | if (status == MagickFalse) |
| 489 | ThrowCompositeException(ResourceLimitError,"MemoryAllocationFailed", |
| 490 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 491 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 492 | { |
| 493 | option=argv[i]; |
| 494 | if (LocaleCompare(option,"(") == 0) |
| 495 | { |
| 496 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 497 | if (k == MaxImageStackDepth) |
| 498 | ThrowCompositeException(OptionError,"ParenthesisNestedTooDeeply", |
| 499 | option); |
| 500 | PushImageStack(); |
| 501 | continue; |
| 502 | } |
| 503 | if (LocaleCompare(option,")") == 0) |
| 504 | { |
| 505 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 506 | if (k == 0) |
| 507 | ThrowCompositeException(OptionError,"UnableToParseExpression",option); |
| 508 | PopImageStack(); |
| 509 | continue; |
| 510 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 511 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 512 | { |
| 513 | Image |
| 514 | *images; |
| 515 | |
| 516 | /* |
| 517 | Read input image. |
| 518 | */ |
| 519 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 520 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 521 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 522 | filename=argv[++i]; |
cristy | 1b58f25 | 2012-03-01 01:41:41 +0000 | [diff] [blame] | 523 | images=ReadImages(image_info,filename,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 524 | status&=(images != (Image *) NULL) && |
| 525 | (exception->severity < ErrorException); |
| 526 | if (images == (Image *) NULL) |
| 527 | continue; |
| 528 | AppendImageStack(images); |
| 529 | continue; |
| 530 | } |
| 531 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 532 | switch (*(option+1)) |
| 533 | { |
| 534 | case 'a': |
| 535 | { |
| 536 | if (LocaleCompare("affine",option+1) == 0) |
| 537 | { |
| 538 | if (*option == '+') |
| 539 | break; |
| 540 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 541 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 542 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 543 | if (IsGeometry(argv[i]) == MagickFalse) |
| 544 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 545 | break; |
| 546 | } |
| 547 | if (LocaleCompare("alpha",option+1) == 0) |
| 548 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 549 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 550 | type; |
| 551 | |
| 552 | if (*option == '+') |
| 553 | break; |
| 554 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 555 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 556 | ThrowCompositeException(OptionError,"MissingArgument",option); |
cristy | 288a353 | 2012-08-28 00:19:44 +0000 | [diff] [blame] | 557 | type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 558 | if (type < 0) |
| 559 | ThrowCompositeException(OptionError, |
cristy | b15b06c | 2012-08-28 11:36:48 +0000 | [diff] [blame] | 560 | "UnrecognizedAlphaChannelOption",argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 561 | break; |
| 562 | } |
| 563 | if (LocaleCompare("authenticate",option+1) == 0) |
| 564 | { |
| 565 | if (*option == '+') |
| 566 | break; |
| 567 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 568 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 569 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 570 | break; |
| 571 | } |
| 572 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 573 | } |
| 574 | case 'b': |
| 575 | { |
| 576 | if (LocaleCompare("background",option+1) == 0) |
| 577 | { |
| 578 | if (*option == '+') |
| 579 | break; |
| 580 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 581 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 582 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 583 | break; |
| 584 | } |
| 585 | if (LocaleCompare("blend",option+1) == 0) |
| 586 | { |
| 587 | (void) CloneString(&composite_options.compose_args,(char *) NULL); |
| 588 | if (*option == '+') |
| 589 | break; |
| 590 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 591 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 592 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 593 | if (IsGeometry(argv[i]) == MagickFalse) |
| 594 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 595 | (void) CloneString(&composite_options.compose_args,argv[i]); |
| 596 | composite_options.compose=BlendCompositeOp; |
| 597 | break; |
| 598 | } |
| 599 | if (LocaleCompare("blur",option+1) == 0) |
| 600 | { |
| 601 | (void) CloneString(&composite_options.compose_args,(char *) NULL); |
| 602 | if (*option == '+') |
| 603 | break; |
| 604 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 605 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 606 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 607 | if (IsGeometry(argv[i]) == MagickFalse) |
| 608 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 609 | (void) CloneString(&composite_options.compose_args,argv[i]); |
| 610 | composite_options.compose=BlurCompositeOp; |
| 611 | break; |
| 612 | } |
| 613 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 614 | { |
| 615 | if (*option == '+') |
| 616 | break; |
| 617 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 618 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 619 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 620 | if (IsGeometry(argv[i]) == MagickFalse) |
| 621 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 622 | break; |
| 623 | } |
| 624 | if (LocaleCompare("border",option+1) == 0) |
| 625 | { |
| 626 | if (*option == '+') |
| 627 | break; |
| 628 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 629 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 630 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 631 | if (IsGeometry(argv[i]) == MagickFalse) |
| 632 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 633 | break; |
| 634 | } |
| 635 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 636 | { |
| 637 | if (*option == '+') |
| 638 | break; |
| 639 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 640 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 641 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 642 | break; |
| 643 | } |
| 644 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 645 | } |
| 646 | case 'c': |
| 647 | { |
| 648 | if (LocaleCompare("cache",option+1) == 0) |
| 649 | { |
| 650 | if (*option == '+') |
| 651 | break; |
| 652 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 653 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 654 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 655 | if (IsGeometry(argv[i]) == MagickFalse) |
| 656 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 657 | break; |
| 658 | } |
| 659 | if (LocaleCompare("channel",option+1) == 0) |
| 660 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 661 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 662 | channel; |
| 663 | |
| 664 | if (*option == '+') |
| 665 | { |
cristy | ab01585 | 2011-07-06 01:03:32 +0000 | [diff] [blame] | 666 | composite_options.channel=DefaultChannels; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 667 | break; |
| 668 | } |
| 669 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 670 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 671 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 672 | channel=ParseChannelOption(argv[i]); |
| 673 | if (channel < 0) |
| 674 | ThrowCompositeException(OptionError,"UnrecognizedChannelType", |
| 675 | argv[i]); |
cristy | ab01585 | 2011-07-06 01:03:32 +0000 | [diff] [blame] | 676 | composite_options.channel=(ChannelType) channel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 677 | break; |
| 678 | } |
| 679 | if (LocaleCompare("colors",option+1) == 0) |
| 680 | { |
| 681 | if (*option == '+') |
| 682 | break; |
| 683 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 684 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 685 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 686 | if (IsGeometry(argv[i]) == MagickFalse) |
| 687 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 688 | break; |
| 689 | } |
| 690 | if (LocaleCompare("colorspace",option+1) == 0) |
| 691 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 692 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 693 | colorspace; |
| 694 | |
| 695 | if (*option == '+') |
| 696 | break; |
| 697 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 698 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 699 | ThrowCompositeException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 700 | colorspace=ParseCommandOption(MagickColorspaceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 701 | MagickFalse,argv[i]); |
| 702 | if (colorspace < 0) |
| 703 | ThrowCompositeException(OptionError,"UnrecognizedColorspace", |
| 704 | argv[i]); |
| 705 | break; |
| 706 | } |
| 707 | if (LocaleCompare("comment",option+1) == 0) |
| 708 | { |
| 709 | if (*option == '+') |
| 710 | break; |
| 711 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 712 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 713 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 714 | break; |
| 715 | } |
| 716 | if (LocaleCompare("compose",option+1) == 0) |
| 717 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 718 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 719 | compose; |
| 720 | |
| 721 | composite_options.compose=UndefinedCompositeOp; |
| 722 | if (*option == '+') |
| 723 | break; |
| 724 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 725 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 726 | ThrowCompositeException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 727 | compose=ParseCommandOption(MagickComposeOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 728 | argv[i]); |
| 729 | if (compose < 0) |
| 730 | ThrowCompositeException(OptionError,"UnrecognizedComposeOperator", |
| 731 | argv[i]); |
| 732 | composite_options.compose=(CompositeOperator) compose; |
| 733 | break; |
| 734 | } |
| 735 | if (LocaleCompare("compress",option+1) == 0) |
| 736 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 737 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 738 | compress; |
| 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 | ThrowCompositeException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 745 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 746 | argv[i]); |
| 747 | if (compress < 0) |
| 748 | ThrowCompositeException(OptionError, |
| 749 | "UnrecognizedImageCompression",argv[i]); |
| 750 | break; |
| 751 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 752 | if (LocaleCompare("concurrent",option+1) == 0) |
| 753 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 754 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 755 | } |
| 756 | case 'd': |
| 757 | { |
| 758 | if (LocaleCompare("debug",option+1) == 0) |
| 759 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 760 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 761 | event; |
| 762 | |
| 763 | if (*option == '+') |
| 764 | break; |
| 765 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 766 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 767 | ThrowCompositeException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 768 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 769 | if (event < 0) |
| 770 | ThrowCompositeException(OptionError,"UnrecognizedEventType", |
| 771 | argv[i]); |
| 772 | (void) SetLogEventMask(argv[i]); |
| 773 | break; |
| 774 | } |
| 775 | if (LocaleCompare("decipher",option+1) == 0) |
| 776 | { |
| 777 | if (*option == '+') |
| 778 | break; |
| 779 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 780 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 781 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 782 | break; |
| 783 | } |
| 784 | if (LocaleCompare("define",option+1) == 0) |
| 785 | { |
| 786 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 787 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 788 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 789 | if (*option == '+') |
| 790 | { |
| 791 | const char |
| 792 | *define; |
| 793 | |
| 794 | define=GetImageOption(image_info,argv[i]); |
| 795 | if (define == (const char *) NULL) |
| 796 | ThrowCompositeException(OptionError,"NoSuchOption",argv[i]); |
| 797 | break; |
| 798 | } |
| 799 | break; |
| 800 | } |
| 801 | if (LocaleCompare("density",option+1) == 0) |
| 802 | { |
| 803 | if (*option == '+') |
| 804 | break; |
| 805 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 806 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 807 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 808 | if (IsGeometry(argv[i]) == MagickFalse) |
| 809 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 810 | break; |
| 811 | } |
| 812 | if (LocaleCompare("depth",option+1) == 0) |
| 813 | { |
| 814 | if (*option == '+') |
| 815 | break; |
| 816 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 817 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 818 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 819 | if (IsGeometry(argv[i]) == MagickFalse) |
| 820 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 821 | break; |
| 822 | } |
| 823 | if (LocaleCompare("displace",option+1) == 0) |
| 824 | { |
| 825 | (void) CloneString(&composite_options.compose_args,(char *) NULL); |
| 826 | if (*option == '+') |
| 827 | break; |
| 828 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 829 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 830 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 831 | if (IsGeometry(argv[i]) == MagickFalse) |
| 832 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 833 | (void) CloneString(&composite_options.compose_args,argv[i]); |
| 834 | composite_options.compose=DisplaceCompositeOp; |
| 835 | break; |
| 836 | } |
| 837 | if (LocaleCompare("display",option+1) == 0) |
| 838 | { |
| 839 | if (*option == '+') |
| 840 | break; |
| 841 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 842 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 843 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 844 | break; |
| 845 | } |
| 846 | if (LocaleCompare("dispose",option+1) == 0) |
| 847 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 848 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 849 | dispose; |
| 850 | |
| 851 | if (*option == '+') |
| 852 | break; |
| 853 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 854 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 855 | ThrowCompositeException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 856 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 857 | if (dispose < 0) |
| 858 | ThrowCompositeException(OptionError,"UnrecognizedDisposeMethod", |
| 859 | argv[i]); |
| 860 | break; |
| 861 | } |
| 862 | if (LocaleCompare("dissolve",option+1) == 0) |
| 863 | { |
| 864 | (void) CloneString(&composite_options.compose_args,(char *) NULL); |
| 865 | if (*option == '+') |
| 866 | break; |
| 867 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 868 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 869 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 870 | if (IsGeometry(argv[i]) == MagickFalse) |
| 871 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 872 | (void) CloneString(&composite_options.compose_args,argv[i]); |
| 873 | composite_options.compose=DissolveCompositeOp; |
| 874 | break; |
| 875 | } |
| 876 | if (LocaleCompare("distort",option+1) == 0) |
| 877 | { |
| 878 | (void) CloneString(&composite_options.compose_args,(char *) NULL); |
| 879 | if (*option == '+') |
| 880 | break; |
| 881 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 882 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 883 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 884 | if (IsGeometry(argv[i]) == MagickFalse) |
| 885 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 886 | (void) CloneString(&composite_options.compose_args,argv[i]); |
| 887 | composite_options.compose=DistortCompositeOp; |
| 888 | break; |
| 889 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 890 | if (LocaleCompare("dither",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 891 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 892 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 893 | method; |
| 894 | |
| 895 | if (*option == '+') |
| 896 | break; |
| 897 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 898 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 899 | ThrowCompositeException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 900 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 901 | if (method < 0) |
| 902 | ThrowCompositeException(OptionError,"UnrecognizedDitherMethod", |
| 903 | argv[i]); |
| 904 | break; |
| 905 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 906 | if (LocaleCompare("duration",option+1) == 0) |
| 907 | { |
| 908 | if (*option == '+') |
| 909 | break; |
| 910 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 911 | if (i == (ssize_t) argc) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 912 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 913 | if (IsGeometry(argv[i]) == MagickFalse) |
| 914 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 915 | break; |
| 916 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 917 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 918 | } |
| 919 | case 'e': |
| 920 | { |
| 921 | if (LocaleCompare("encipher",option+1) == 0) |
| 922 | { |
| 923 | if (*option == '+') |
| 924 | break; |
| 925 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 926 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 927 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 928 | break; |
| 929 | } |
| 930 | if (LocaleCompare("encoding",option+1) == 0) |
| 931 | { |
| 932 | if (*option == '+') |
| 933 | break; |
| 934 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 935 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 936 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 937 | break; |
| 938 | } |
| 939 | if (LocaleCompare("endian",option+1) == 0) |
| 940 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 941 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 942 | endian; |
| 943 | |
| 944 | if (*option == '+') |
| 945 | break; |
| 946 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 947 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 948 | ThrowCompositeException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 949 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 950 | argv[i]); |
| 951 | if (endian < 0) |
| 952 | ThrowCompositeException(OptionError,"UnrecognizedEndianType", |
| 953 | argv[i]); |
| 954 | break; |
| 955 | } |
| 956 | if (LocaleCompare("extract",option+1) == 0) |
| 957 | { |
| 958 | if (*option == '+') |
| 959 | break; |
| 960 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 961 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 962 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 963 | if (IsGeometry(argv[i]) == MagickFalse) |
| 964 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 965 | break; |
| 966 | } |
| 967 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 968 | } |
| 969 | case 'f': |
| 970 | { |
| 971 | if (LocaleCompare("filter",option+1) == 0) |
| 972 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 973 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 974 | filter; |
| 975 | |
| 976 | if (*option == '+') |
| 977 | break; |
| 978 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 979 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 980 | ThrowCompositeException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 981 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 982 | if (filter < 0) |
| 983 | ThrowCompositeException(OptionError,"UnrecognizedImageFilter", |
| 984 | argv[i]); |
| 985 | break; |
| 986 | } |
| 987 | if (LocaleCompare("font",option+1) == 0) |
| 988 | { |
| 989 | if (*option == '+') |
| 990 | break; |
| 991 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 992 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 993 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 994 | break; |
| 995 | } |
| 996 | if (LocaleCompare("format",option+1) == 0) |
| 997 | { |
| 998 | if (*option == '+') |
| 999 | break; |
| 1000 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1001 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1002 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1003 | format=argv[i]; |
| 1004 | break; |
| 1005 | } |
| 1006 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 1007 | } |
| 1008 | case 'g': |
| 1009 | { |
| 1010 | if (LocaleCompare("geometry",option+1) == 0) |
| 1011 | { |
| 1012 | (void) CloneString(&composite_options.geometry,(char *) NULL); |
| 1013 | if (*option == '+') |
| 1014 | break; |
| 1015 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1016 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1017 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1018 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1019 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1020 | (void) CloneString(&composite_options.geometry,argv[i]); |
| 1021 | break; |
| 1022 | } |
| 1023 | if (LocaleCompare("gravity",option+1) == 0) |
| 1024 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1025 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1026 | gravity; |
| 1027 | |
| 1028 | composite_options.gravity=UndefinedGravity; |
| 1029 | if (*option == '+') |
| 1030 | break; |
| 1031 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1032 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1033 | ThrowCompositeException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1034 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1035 | argv[i]); |
| 1036 | if (gravity < 0) |
| 1037 | ThrowCompositeException(OptionError,"UnrecognizedGravityType", |
| 1038 | argv[i]); |
| 1039 | composite_options.gravity=(GravityType) gravity; |
| 1040 | break; |
| 1041 | } |
| 1042 | if (LocaleCompare("green-primary",option+1) == 0) |
| 1043 | { |
| 1044 | if (*option == '+') |
| 1045 | break; |
| 1046 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1047 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1048 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1049 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1050 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1051 | break; |
| 1052 | } |
| 1053 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 1054 | } |
| 1055 | case 'h': |
| 1056 | { |
| 1057 | if ((LocaleCompare("help",option+1) == 0) || |
| 1058 | (LocaleCompare("-help",option+1) == 0)) |
| 1059 | return(CompositeUsage()); |
| 1060 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 1061 | } |
| 1062 | case 'i': |
| 1063 | { |
| 1064 | if (LocaleCompare("identify",option+1) == 0) |
| 1065 | break; |
| 1066 | if (LocaleCompare("interlace",option+1) == 0) |
| 1067 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1068 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1069 | interlace; |
| 1070 | |
| 1071 | if (*option == '+') |
| 1072 | break; |
| 1073 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1074 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1075 | ThrowCompositeException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1076 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1077 | argv[i]); |
| 1078 | if (interlace < 0) |
| 1079 | ThrowCompositeException(OptionError, |
| 1080 | "UnrecognizedInterlaceType",argv[i]); |
| 1081 | break; |
| 1082 | } |
| 1083 | if (LocaleCompare("interpolate",option+1) == 0) |
| 1084 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1085 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1086 | interpolate; |
| 1087 | |
| 1088 | if (*option == '+') |
| 1089 | break; |
| 1090 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1091 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1092 | ThrowCompositeException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1093 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1094 | argv[i]); |
| 1095 | if (interpolate < 0) |
| 1096 | ThrowCompositeException(OptionError, |
| 1097 | "UnrecognizedInterpolateMethod",argv[i]); |
| 1098 | break; |
| 1099 | } |
| 1100 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 1101 | } |
| 1102 | case 'l': |
| 1103 | { |
| 1104 | if (LocaleCompare("label",option+1) == 0) |
| 1105 | { |
| 1106 | if (*option == '+') |
| 1107 | break; |
| 1108 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1109 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1110 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1111 | break; |
| 1112 | } |
| 1113 | if (LocaleCompare("limit",option+1) == 0) |
| 1114 | { |
| 1115 | char |
| 1116 | *p; |
| 1117 | |
| 1118 | double |
| 1119 | value; |
| 1120 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1121 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1122 | resource; |
| 1123 | |
| 1124 | if (*option == '+') |
| 1125 | break; |
| 1126 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1127 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1128 | ThrowCompositeException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1129 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1130 | argv[i]); |
| 1131 | if (resource < 0) |
| 1132 | ThrowCompositeException(OptionError,"UnrecognizedResourceType", |
| 1133 | argv[i]); |
| 1134 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1135 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1136 | ThrowCompositeException(OptionError,"MissingArgument",option); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1137 | value=StringToDouble(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 1138 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1139 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 1140 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1141 | break; |
| 1142 | } |
| 1143 | if (LocaleCompare("list",option+1) == 0) |
| 1144 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1145 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1146 | list; |
| 1147 | |
| 1148 | if (*option == '+') |
| 1149 | break; |
| 1150 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1151 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1152 | ThrowCompositeException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1153 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1154 | if (list < 0) |
| 1155 | ThrowCompositeException(OptionError,"UnrecognizedListType", |
| 1156 | argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 1157 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1158 | argv+j,exception); |
| 1159 | DestroyComposite(); |
cristy | 32ce239 | 2014-09-24 19:08:53 +0000 | [diff] [blame] | 1160 | return(status == 0 ? MagickTrue : MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1161 | } |
| 1162 | if (LocaleCompare("log",option+1) == 0) |
| 1163 | { |
| 1164 | if (*option == '+') |
| 1165 | break; |
| 1166 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1167 | if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1168 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1169 | break; |
| 1170 | } |
| 1171 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 1172 | } |
| 1173 | case 'm': |
| 1174 | { |
| 1175 | if (LocaleCompare("matte",option+1) == 0) |
| 1176 | break; |
| 1177 | if (LocaleCompare("monitor",option+1) == 0) |
| 1178 | break; |
| 1179 | if (LocaleCompare("monochrome",option+1) == 0) |
| 1180 | break; |
| 1181 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 1182 | } |
| 1183 | case 'n': |
| 1184 | { |
| 1185 | if (LocaleCompare("negate",option+1) == 0) |
| 1186 | break; |
| 1187 | if (LocaleCompare("noop",option+1) == 0) |
| 1188 | break; |
| 1189 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 1190 | } |
| 1191 | case 'p': |
| 1192 | { |
| 1193 | if (LocaleCompare("page",option+1) == 0) |
| 1194 | { |
| 1195 | if (*option == '+') |
| 1196 | break; |
| 1197 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1198 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1199 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1200 | break; |
| 1201 | } |
| 1202 | if (LocaleCompare("pointsize",option+1) == 0) |
| 1203 | { |
| 1204 | if (*option == '+') |
| 1205 | break; |
| 1206 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 1207 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1208 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1209 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1210 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1211 | break; |
| 1212 | } |
| 1213 | if (LocaleCompare("process",option+1) == 0) |
| 1214 | { |
| 1215 | if (*option == '+') |
| 1216 | break; |
| 1217 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1218 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1219 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1220 | break; |
| 1221 | } |
| 1222 | if (LocaleCompare("profile",option+1) == 0) |
| 1223 | { |
| 1224 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1225 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1226 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1227 | break; |
| 1228 | } |
| 1229 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 1230 | } |
| 1231 | case 'q': |
| 1232 | { |
| 1233 | if (LocaleCompare("quality",option+1) == 0) |
| 1234 | { |
| 1235 | if (*option == '+') |
| 1236 | break; |
| 1237 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1238 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1239 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1240 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1241 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1242 | break; |
| 1243 | } |
| 1244 | if (LocaleCompare("quantize",option+1) == 0) |
| 1245 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1246 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1247 | colorspace; |
| 1248 | |
| 1249 | if (*option == '+') |
| 1250 | break; |
| 1251 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 1252 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1253 | ThrowCompositeException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1254 | colorspace=ParseCommandOption(MagickColorspaceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1255 | MagickFalse,argv[i]); |
| 1256 | if (colorspace < 0) |
| 1257 | ThrowCompositeException(OptionError,"UnrecognizedColorspace", |
| 1258 | argv[i]); |
| 1259 | break; |
| 1260 | } |
| 1261 | if (LocaleCompare("quiet",option+1) == 0) |
| 1262 | break; |
| 1263 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 1264 | } |
| 1265 | case 'r': |
| 1266 | { |
| 1267 | if (LocaleCompare("red-primary",option+1) == 0) |
| 1268 | { |
| 1269 | if (*option == '+') |
| 1270 | break; |
| 1271 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1272 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1273 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1274 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1275 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1276 | break; |
| 1277 | } |
| 1278 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 1279 | break; |
| 1280 | if (LocaleCompare("render",option+1) == 0) |
| 1281 | break; |
| 1282 | if (LocaleCompare("repage",option+1) == 0) |
| 1283 | { |
| 1284 | if (*option == '+') |
| 1285 | break; |
| 1286 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1287 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1288 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1289 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1290 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1291 | break; |
| 1292 | } |
| 1293 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 1294 | { |
| 1295 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 1296 | break; |
| 1297 | } |
| 1298 | if (LocaleCompare("resize",option+1) == 0) |
| 1299 | { |
| 1300 | if (*option == '+') |
| 1301 | break; |
| 1302 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1303 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1304 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1305 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1306 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1307 | break; |
| 1308 | } |
| 1309 | if (LocaleCompare("rotate",option+1) == 0) |
| 1310 | { |
| 1311 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1312 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1313 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1314 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1315 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1316 | break; |
| 1317 | } |
| 1318 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 1319 | } |
| 1320 | case 's': |
| 1321 | { |
| 1322 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 1323 | { |
| 1324 | if (*option == '+') |
| 1325 | break; |
| 1326 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1327 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1328 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1329 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1330 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1331 | break; |
| 1332 | } |
| 1333 | if (LocaleCompare("scene",option+1) == 0) |
| 1334 | { |
| 1335 | if (*option == '+') |
| 1336 | break; |
| 1337 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1338 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1339 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1340 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1341 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1342 | break; |
| 1343 | } |
| 1344 | if (LocaleCompare("seed",option+1) == 0) |
| 1345 | { |
| 1346 | if (*option == '+') |
| 1347 | break; |
| 1348 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 1349 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1350 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1351 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1352 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1353 | break; |
| 1354 | } |
| 1355 | if (LocaleCompare("sharpen",option+1) == 0) |
| 1356 | { |
| 1357 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1358 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1359 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1360 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1361 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1362 | break; |
| 1363 | } |
| 1364 | if (LocaleCompare("shave",option+1) == 0) |
| 1365 | { |
| 1366 | if (*option == '+') |
| 1367 | break; |
| 1368 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 1369 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1370 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1371 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1372 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1373 | break; |
| 1374 | } |
| 1375 | if (LocaleCompare("size",option+1) == 0) |
| 1376 | { |
| 1377 | if (*option == '+') |
| 1378 | break; |
| 1379 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1380 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1381 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1382 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1383 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1384 | break; |
| 1385 | } |
| 1386 | if (LocaleCompare("stegano",option+1) == 0) |
| 1387 | { |
| 1388 | composite_options.stegano=0; |
| 1389 | if (*option == '+') |
| 1390 | break; |
| 1391 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1392 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1393 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1394 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1395 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 1396 | composite_options.stegano=(ssize_t) StringToLong(argv[i])+1; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1397 | break; |
| 1398 | } |
| 1399 | if (LocaleCompare("stereo",option+1) == 0) |
| 1400 | { |
| 1401 | MagickStatusType |
| 1402 | flags; |
| 1403 | |
| 1404 | composite_options.stereo=MagickFalse; |
| 1405 | if (*option == '+') |
| 1406 | break; |
| 1407 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1408 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1409 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1410 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1411 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1412 | flags=ParseAbsoluteGeometry(argv[i],&composite_options.offset); |
| 1413 | if ((flags & YValue) == 0) |
| 1414 | composite_options.offset.y=composite_options.offset.x; |
| 1415 | composite_options.stereo=MagickTrue; |
| 1416 | break; |
| 1417 | } |
| 1418 | if (LocaleCompare("strip",option+1) == 0) |
| 1419 | break; |
| 1420 | if (LocaleCompare("support",option+1) == 0) |
| 1421 | { |
| 1422 | i++; /* deprecated */ |
| 1423 | break; |
| 1424 | } |
| 1425 | if (LocaleCompare("swap",option+1) == 0) |
| 1426 | { |
| 1427 | if (*option == '+') |
| 1428 | break; |
| 1429 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 1430 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1431 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1432 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1433 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1434 | break; |
| 1435 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 1436 | if (LocaleCompare("synchronize",option+1) == 0) |
| 1437 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1438 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 1439 | } |
| 1440 | case 't': |
| 1441 | { |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 1442 | if (LocaleCompare("taint",option+1) == 0) |
| 1443 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1444 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 1445 | { |
| 1446 | if (*option == '+') |
| 1447 | break; |
| 1448 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1449 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1450 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1451 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1452 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1453 | break; |
| 1454 | } |
| 1455 | if (LocaleCompare("tile",option+1) == 0) |
| 1456 | { |
| 1457 | composite_options.tile=(*option == '-') ? MagickTrue : MagickFalse; |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1458 | (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1459 | break; |
| 1460 | } |
| 1461 | if (LocaleCompare("transform",option+1) == 0) |
| 1462 | break; |
| 1463 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 1464 | { |
| 1465 | if (*option == '+') |
| 1466 | break; |
| 1467 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 1468 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1469 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1470 | break; |
| 1471 | } |
| 1472 | if (LocaleCompare("treedepth",option+1) == 0) |
| 1473 | { |
| 1474 | if (*option == '+') |
| 1475 | break; |
| 1476 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1477 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1478 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1479 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1480 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1481 | break; |
| 1482 | } |
| 1483 | if (LocaleCompare("type",option+1) == 0) |
| 1484 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1485 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1486 | type; |
| 1487 | |
| 1488 | if (*option == '+') |
| 1489 | break; |
| 1490 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1491 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1492 | ThrowCompositeException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1493 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1494 | if (type < 0) |
| 1495 | ThrowCompositeException(OptionError,"UnrecognizedImageType", |
| 1496 | argv[i]); |
| 1497 | break; |
| 1498 | } |
| 1499 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 1500 | } |
| 1501 | case 'u': |
| 1502 | { |
| 1503 | if (LocaleCompare("units",option+1) == 0) |
| 1504 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1505 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1506 | units; |
| 1507 | |
| 1508 | if (*option == '+') |
| 1509 | break; |
| 1510 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1511 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1512 | ThrowCompositeException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1513 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1514 | argv[i]); |
| 1515 | if (units < 0) |
| 1516 | ThrowCompositeException(OptionError,"UnrecognizedUnitsType", |
| 1517 | argv[i]); |
| 1518 | break; |
| 1519 | } |
| 1520 | if (LocaleCompare("unsharp",option+1) == 0) |
| 1521 | { |
| 1522 | (void) CloneString(&composite_options.compose_args,(char *) NULL); |
| 1523 | if (*option == '+') |
| 1524 | break; |
| 1525 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1526 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1527 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1528 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1529 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1530 | (void) CloneString(&composite_options.compose_args,argv[i]); |
| 1531 | composite_options.compose=ThresholdCompositeOp; |
| 1532 | break; |
| 1533 | } |
| 1534 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 1535 | } |
| 1536 | case 'v': |
| 1537 | { |
| 1538 | if (LocaleCompare("verbose",option+1) == 0) |
| 1539 | break; |
| 1540 | if ((LocaleCompare("version",option+1) == 0) || |
| 1541 | (LocaleCompare("-version",option+1) == 0)) |
| 1542 | { |
cristy | 4f7a613 | 2012-12-23 00:35:19 +0000 | [diff] [blame] | 1543 | ListMagickVersion(stdout); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1544 | break; |
| 1545 | } |
| 1546 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 1547 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1548 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1549 | method; |
| 1550 | |
| 1551 | if (*option == '+') |
| 1552 | break; |
| 1553 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1554 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1555 | ThrowCompositeException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1556 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1557 | argv[i]); |
| 1558 | if (method < 0) |
| 1559 | ThrowCompositeException(OptionError, |
| 1560 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 1561 | break; |
| 1562 | } |
| 1563 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 1564 | } |
| 1565 | case 'w': |
| 1566 | { |
| 1567 | if (LocaleCompare("watermark",option+1) == 0) |
| 1568 | { |
| 1569 | (void) CloneString(&composite_options.compose_args,(char *) NULL); |
| 1570 | if (*option == '+') |
| 1571 | break; |
| 1572 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1573 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1574 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1575 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1576 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1577 | (void) CloneString(&composite_options.compose_args,argv[i]); |
| 1578 | composite_options.compose=ModulateCompositeOp; |
| 1579 | break; |
| 1580 | } |
| 1581 | if (LocaleCompare("white-point",option+1) == 0) |
| 1582 | { |
| 1583 | if (*option == '+') |
| 1584 | break; |
| 1585 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1586 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1587 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1588 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1589 | ThrowCompositeInvalidArgumentException(option,argv[i]); |
| 1590 | break; |
| 1591 | } |
| 1592 | if (LocaleCompare("write",option+1) == 0) |
| 1593 | { |
| 1594 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1595 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1596 | ThrowCompositeException(OptionError,"MissingArgument",option); |
| 1597 | break; |
| 1598 | } |
| 1599 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 1600 | } |
| 1601 | case '?': |
| 1602 | break; |
| 1603 | default: |
| 1604 | ThrowCompositeException(OptionError,"UnrecognizedOption",option) |
| 1605 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1606 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 1607 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1608 | if (fire != MagickFalse) |
| 1609 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 1610 | } |
| 1611 | if (k != 0) |
| 1612 | ThrowCompositeException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1613 | if (i-- != (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1614 | ThrowCompositeException(OptionError,"MissingAnImageFilename",argv[i]); |
| 1615 | if ((image == (Image *) NULL) || (GetImageListLength(image) < 2)) |
| 1616 | ThrowCompositeException(OptionError,"MissingAnImageFilename",argv[argc-1]); |
| 1617 | FinalizeImageSettings(image_info,image,MagickTrue); |
cristy | 94f2007 | 2009-09-12 02:12:36 +0000 | [diff] [blame] | 1618 | if ((image == (Image *) NULL) || (GetImageListLength(image) < 2)) |
| 1619 | ThrowCompositeException(OptionError,"MissingAnImageFilename",argv[argc-1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1620 | /* |
| 1621 | Composite images. |
| 1622 | */ |
| 1623 | RemoveImageStack(composite_image); |
| 1624 | RemoveImageStack(images); |
| 1625 | (void) TransformImage(&composite_image,(char *) NULL, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 1626 | composite_image->geometry,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1627 | RemoveImageStack(mask_image); |
| 1628 | if (mask_image != (Image *) NULL) |
| 1629 | { |
| 1630 | if ((composite_options.compose == DisplaceCompositeOp) || |
| 1631 | (composite_options.compose == DistortCompositeOp)) |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 1632 | status&=CompositeImage(composite_image,mask_image, |
| 1633 | CopyGreenCompositeOp,MagickTrue,0,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1634 | else |
cristy | fe83185 | 2013-02-12 14:56:07 +0000 | [diff] [blame] | 1635 | status&=CompositeImage(composite_image,mask_image,IntensityCompositeOp, |
| 1636 | MagickTrue,0,0,exception); |
| 1637 | mask_image=DestroyImage(mask_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1638 | } |
| 1639 | status&=CompositeImageList(image_info,&images,composite_image, |
| 1640 | &composite_options,exception); |
| 1641 | composite_image=DestroyImage(composite_image); |
| 1642 | /* |
| 1643 | Write composite images. |
| 1644 | */ |
| 1645 | status&=WriteImages(image_info,images,argv[argc-1],exception); |
| 1646 | if (metadata != (char **) NULL) |
| 1647 | { |
| 1648 | char |
| 1649 | *text; |
| 1650 | |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1651 | text=InterpretImageProperties(image_info,images,format,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1652 | if (text == (char *) NULL) |
| 1653 | ThrowCompositeException(ResourceLimitError,"MemoryAllocationFailed", |
| 1654 | GetExceptionMessage(errno)); |
| 1655 | (void) ConcatenateString(&(*metadata),text); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1656 | text=DestroyString(text); |
| 1657 | } |
| 1658 | images=DestroyImage(images); |
| 1659 | RelinquishCompositeOptions(&composite_options); |
| 1660 | DestroyComposite(); |
| 1661 | return(status != 0 ? MagickTrue : MagickFalse); |
| 1662 | } |