cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % M M OOO N N TTTTT AAA GGGG EEEEE % |
| 7 | % MM MM O O NN N T A A G E % |
| 8 | % M M M O O N N N T AAAAA G GG EEE % |
| 9 | % M M O O N NN T A A G G E % |
| 10 | % M M OOO N N T A A GGG EEEEE % |
| 11 | % % |
| 12 | % % |
| 13 | % MagickWand Methods to Create Image Thumbnails % |
| 14 | % % |
| 15 | % Software Design % |
| 16 | % John Cristy % |
| 17 | % July 1992 % |
| 18 | % % |
| 19 | % % |
cristy | 7e41fe8 | 2010-12-04 23:12:08 +0000 | [diff] [blame] | 20 | % Copyright 1999-2011 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 montage program to create a composite image by combining several |
| 37 | % separate images. The images are tiled on the composite image optionally |
| 38 | % adorned with a border, frame, image name, and more. |
| 39 | % |
| 40 | */ |
| 41 | |
| 42 | /* |
| 43 | Include declarations. |
| 44 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame^] | 45 | #include "MagickWand/studio.h" |
| 46 | #include "MagickWand/MagickWand.h" |
| 47 | #include "MagickWand/mogrify-private.h" |
| 48 | #include "MagickCore/string-private.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 49 | |
| 50 | /* |
| 51 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 52 | % % |
| 53 | % % |
| 54 | % % |
| 55 | + M o n t a g e I m a g e C o m m a n d % |
| 56 | % % |
| 57 | % % |
| 58 | % % |
| 59 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 60 | % |
| 61 | % MontageImageCommand() reads one or more images, applies one or more image |
| 62 | % processing operations, and writes out the image in the same or |
| 63 | % differing format. |
| 64 | % |
| 65 | % The format of the MontageImageCommand method is: |
| 66 | % |
| 67 | % MagickBooleanType MontageImageCommand(ImageInfo *image_info,int argc, |
| 68 | % char **argv,char **metadata,ExceptionInfo *exception) |
| 69 | % |
| 70 | % A description of each parameter follows: |
| 71 | % |
| 72 | % o image_info: the image info. |
| 73 | % |
| 74 | % o argc: the number of elements in the argument vector. |
| 75 | % |
| 76 | % o argv: A text array containing the command line arguments. |
| 77 | % |
| 78 | % o metadata: any metadata is returned here. |
| 79 | % |
| 80 | % o exception: return any errors or warnings in this structure. |
| 81 | % |
| 82 | */ |
| 83 | |
| 84 | static MagickBooleanType MontageUsage(void) |
| 85 | { |
| 86 | const char |
| 87 | **p; |
| 88 | |
| 89 | static const char |
| 90 | *miscellaneous[]= |
| 91 | { |
| 92 | "-debug events display copious debugging information", |
| 93 | "-help print program options", |
| 94 | "-list type print a list of supported option arguments", |
| 95 | "-log format format of debugging information", |
| 96 | "-version print version information", |
| 97 | (char *) NULL |
| 98 | }, |
| 99 | *operators[]= |
| 100 | { |
| 101 | "-adaptive-sharpen geometry", |
| 102 | " adaptively sharpen pixels; increase effect near edges", |
| 103 | " annotate geometry text", |
| 104 | " annotate the image with text", |
| 105 | "-auto-orient automagically orient image", |
| 106 | "-blur geometry reduce image noise and reduce detail levels", |
| 107 | "-border geometry surround image with a border of color", |
| 108 | "-crop geometry preferred size and location of the cropped image", |
| 109 | "-extent geometry set the image size", |
| 110 | "-flatten flatten a sequence of images", |
| 111 | "-flip flip image in the vertical direction", |
| 112 | "-flop flop image in the horizontal direction", |
| 113 | "-frame geometry surround image with an ornamental border", |
| 114 | "-monochrome transform image to black and white", |
| 115 | "-polaroid angle simulate a Polaroid picture", |
| 116 | "-repage geometry size and location of an image canvas (operator)", |
| 117 | "-resize geometry resize the image", |
| 118 | "-rotate degrees apply Paeth rotation to the image", |
| 119 | "-strip strip image of all profiles and comments", |
| 120 | "-transform affine transform image", |
| 121 | "-transpose flip image vertically and rotate 90 degrees", |
| 122 | "-transparent color make this color transparent within the image", |
| 123 | "-type type image type", |
| 124 | "-unsharp geometry sharpen the image", |
| 125 | (char *) NULL |
| 126 | }, |
| 127 | *settings[]= |
| 128 | { |
| 129 | "-adjoin join images into a single multi-image file", |
| 130 | "-affine matrix affine transform matrix", |
| 131 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 132 | " transparent, extract, background, or shape", |
| 133 | "-authenticate password", |
| 134 | " decipher image with this password", |
| 135 | "-blue-primary point chromaticity blue primary point", |
| 136 | "-bordercolor color border color", |
| 137 | "-caption string assign a caption to an image", |
| 138 | "-channel type apply option to select image channels", |
| 139 | "-colors value preferred number of colors in the image", |
| 140 | "-colorspace type alternate image colorsapce", |
| 141 | "-comment string annotate image with comment", |
| 142 | "-compose operator composite operator", |
| 143 | "-compress type type of pixel compression when writing the image", |
| 144 | "-define format:option", |
| 145 | " define one or more image format options", |
| 146 | "-density geometry horizontal and vertical density of the image", |
| 147 | "-depth value image depth", |
| 148 | "-display server query font from this X server", |
| 149 | "-dispose method layer disposal method", |
| 150 | "-dither method apply error diffusion to image", |
| 151 | "-draw string annotate the image with a graphic primitive", |
| 152 | "-encoding type text encoding type", |
| 153 | "-endian type endianness (MSB or LSB) of the image", |
| 154 | "-extract geometry extract area from image", |
| 155 | "-fill color color to use when filling a graphic primitive", |
| 156 | "-filter type use this filter when resizing an image", |
| 157 | "-font name render text with this font", |
| 158 | "-format \"string\" output formatted image characteristics", |
| 159 | "-gamma value level of gamma correction", |
| 160 | "-geometry geometry preferred tile and border sizes", |
| 161 | "-gravity direction which direction to gravitate towards", |
| 162 | "-green-primary point chromaticity green primary point", |
| 163 | "-identify identify the format and characteristics of the image", |
| 164 | "-interlace type type of image interlacing scheme", |
| 165 | "-interpolate method pixel color interpolation method", |
cristy | 837699d | 2010-07-28 23:49:03 +0000 | [diff] [blame] | 166 | "-kerning value set the space between two letters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 167 | "-label string assign a label to an image", |
| 168 | "-limit type value pixel cache resource limit", |
| 169 | "-mattecolor color frame color", |
| 170 | "-mode type framing style", |
| 171 | "-monitor monitor progress", |
| 172 | "-origin geometry image origin", |
| 173 | "-page geometry size and location of an image canvas (setting)", |
| 174 | "-pointsize value font point size", |
| 175 | "-profile filename add, delete, or apply an image profile", |
| 176 | "-quality value JPEG/MIFF/PNG compression level", |
| 177 | "-quantize colorspace reduce colors in this colorspace", |
| 178 | "-quiet suppress all warning messages", |
| 179 | "-red-primary point chromaticity red primary point", |
| 180 | "-regard-warnings pay attention to warning messages", |
| 181 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 182 | "-sampling-factor geometry", |
| 183 | " horizontal and vertical sampling factor", |
| 184 | "-scenes range image scene range", |
| 185 | "-seed value seed a new sequence of pseudo-random numbers", |
| 186 | "-set attribute value set an image attribute", |
| 187 | "-shadow add a shadow beneath a tile to simulate depth", |
| 188 | "-size geometry width and height of image", |
| 189 | "-stroke color color to use when stroking a graphic primitive", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 190 | "-synchronize synchronize image to storage device", |
| 191 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 192 | "-texture filename name of texture to tile onto the image background", |
| 193 | "-thumbnail geometry create a thumbnail of the image", |
| 194 | "-tile geometry number of tiles per row and column", |
| 195 | "-title string decorate the montage image with a title", |
| 196 | "-transparent-color color", |
| 197 | " transparent color", |
| 198 | "-treedepth value color tree depth", |
| 199 | "-trim trim image edges", |
| 200 | "-units type the units of image resolution", |
| 201 | "-verbose print detailed information about the image", |
| 202 | "-virtual-pixel method", |
| 203 | " virtual pixel access method", |
| 204 | "-white-point point chromaticity white point", |
| 205 | (char *) NULL |
| 206 | }, |
| 207 | *sequence_operators[]= |
| 208 | { |
| 209 | "-coalesce merge a sequence of images", |
| 210 | "-composite composite image", |
| 211 | (char *) NULL |
| 212 | }, |
| 213 | *stack_operators[]= |
| 214 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 215 | "-clone indexes clone an image", |
| 216 | "-duplicate count,indexes", |
cristy | 5d28d48 | 2011-03-20 21:59:40 +0000 | [diff] [blame] | 217 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 218 | (char *) NULL |
| 219 | }; |
| 220 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 221 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 222 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 223 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 224 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...] file\n", |
| 225 | GetClientName()); |
| 226 | (void) printf("\nImage Settings:\n"); |
| 227 | for (p=settings; *p != (char *) NULL; p++) |
| 228 | (void) printf(" %s\n",*p); |
| 229 | (void) printf("\nImage Operators:\n"); |
| 230 | for (p=operators; *p != (char *) NULL; p++) |
| 231 | (void) printf(" %s\n",*p); |
| 232 | (void) printf("\nImage Sequence Operators:\n"); |
| 233 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 234 | (void) printf(" %s\n",*p); |
| 235 | (void) printf("\nImage Stack Operators:\n"); |
| 236 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 237 | (void) printf(" %s\n",*p); |
| 238 | (void) printf("\nMiscellaneous Options:\n"); |
| 239 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 240 | (void) printf(" %s\n",*p); |
| 241 | (void) printf( |
| 242 | "\nIn addition to those listed above, you can specify these standard X\n"); |
| 243 | (void) printf( |
| 244 | "resources as command line options: -background, -bordercolor,\n"); |
| 245 | (void) printf( |
| 246 | "-borderwidth, -font, -mattecolor, or -title\n"); |
| 247 | (void) printf( |
| 248 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 249 | (void) printf( |
| 250 | "number. To specify a particular image format, precede the filename\n"); |
| 251 | (void) printf( |
| 252 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 253 | (void) printf( |
| 254 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 255 | (void) printf("'-' for standard input or output.\n"); |
| 256 | return(MagickFalse); |
| 257 | } |
| 258 | |
| 259 | WandExport MagickBooleanType MontageImageCommand(ImageInfo *image_info, |
| 260 | int argc,char **argv,char **metadata,ExceptionInfo *exception) |
| 261 | { |
| 262 | #define DestroyMontage() \ |
| 263 | { \ |
| 264 | if (montage_image != (Image *) NULL) \ |
| 265 | montage_image=DestroyImageList(montage_image); \ |
| 266 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 267 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 268 | argv[i]=DestroyString(argv[i]); \ |
| 269 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 270 | } |
| 271 | #define ThrowMontageException(asperity,tag,option) \ |
| 272 | { \ |
| 273 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 274 | option); \ |
| 275 | DestroyMontage(); \ |
| 276 | return(MagickFalse); \ |
| 277 | } |
| 278 | #define ThrowMontageInvalidArgumentException(option,argument) \ |
| 279 | { \ |
| 280 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 281 | "InvalidArgument","`%s': %s",option,argument); \ |
| 282 | DestroyMontage(); \ |
| 283 | return(MagickFalse); \ |
| 284 | } |
| 285 | |
| 286 | char |
| 287 | *option, |
| 288 | *transparent_color; |
| 289 | |
| 290 | const char |
| 291 | *format; |
| 292 | |
| 293 | Image |
| 294 | *image, |
| 295 | *montage_image; |
| 296 | |
| 297 | ImageStack |
| 298 | image_stack[MaxImageStackDepth+1]; |
| 299 | |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 300 | long |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 301 | first_scene, |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 302 | last_scene; |
| 303 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 304 | MagickBooleanType |
| 305 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 306 | pend, |
| 307 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 308 | |
| 309 | MagickStatusType |
| 310 | status; |
| 311 | |
| 312 | MontageInfo |
| 313 | *montage_info; |
| 314 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 315 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 316 | i; |
| 317 | |
cristy | 9d314ff | 2011-03-09 01:30:28 +0000 | [diff] [blame] | 318 | ssize_t |
| 319 | j, |
| 320 | k, |
| 321 | scene; |
| 322 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 323 | /* |
| 324 | Set defaults. |
| 325 | */ |
| 326 | assert(image_info != (ImageInfo *) NULL); |
| 327 | assert(image_info->signature == MagickSignature); |
| 328 | if (image_info->debug != MagickFalse) |
| 329 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 330 | assert(exception != (ExceptionInfo *) NULL); |
| 331 | if (argc == 2) |
| 332 | { |
| 333 | option=argv[1]; |
| 334 | if ((LocaleCompare("version",option+1) == 0) || |
| 335 | (LocaleCompare("-version",option+1) == 0)) |
| 336 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 337 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 338 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 339 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 340 | GetMagickCopyright()); |
| 341 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 342 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 343 | return(MagickFalse); |
| 344 | } |
| 345 | } |
| 346 | if (argc < 3) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 347 | return(MontageUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 348 | format="%w,%h,%m"; |
| 349 | first_scene=0; |
| 350 | j=1; |
| 351 | k=0; |
| 352 | last_scene=0; |
| 353 | montage_image=NewImageList(); |
| 354 | montage_info=CloneMontageInfo(image_info,(MontageInfo *) NULL); |
| 355 | NewImageStack(); |
| 356 | option=(char *) NULL; |
| 357 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 358 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 359 | scene=0; |
| 360 | status=MagickFalse; |
| 361 | transparent_color=(char *) NULL; |
| 362 | /* |
| 363 | Parse command line. |
| 364 | */ |
| 365 | ReadCommandlLine(argc,&argv); |
| 366 | status=ExpandFilenames(&argc,&argv); |
| 367 | if (status == MagickFalse) |
| 368 | ThrowMontageException(ResourceLimitError,"MemoryAllocationFailed", |
| 369 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 370 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 371 | { |
| 372 | option=argv[i]; |
| 373 | if (LocaleCompare(option,"(") == 0) |
| 374 | { |
| 375 | FireImageStack(MagickTrue,MagickTrue,pend); |
| 376 | if (k == MaxImageStackDepth) |
| 377 | ThrowMontageException(OptionError,"ParenthesisNestedTooDeeply", |
| 378 | option); |
| 379 | PushImageStack(); |
| 380 | continue; |
| 381 | } |
| 382 | if (LocaleCompare(option,")") == 0) |
| 383 | { |
| 384 | FireImageStack(MagickTrue,MagickTrue,MagickTrue); |
| 385 | if (k == 0) |
| 386 | ThrowMontageException(OptionError,"UnableToParseExpression",option); |
| 387 | PopImageStack(); |
| 388 | continue; |
| 389 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 390 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 391 | { |
| 392 | Image |
| 393 | *images; |
| 394 | |
| 395 | FireImageStack(MagickFalse,MagickFalse,pend); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 396 | for (scene=(ssize_t) first_scene; scene <= (ssize_t) last_scene ; scene++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 397 | { |
| 398 | char |
| 399 | *filename; |
| 400 | |
| 401 | /* |
| 402 | Option is a file name: begin by reading image from specified file. |
| 403 | */ |
| 404 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 405 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 406 | filename=argv[++i]; |
| 407 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 408 | if (first_scene != last_scene) |
| 409 | { |
| 410 | char |
| 411 | filename[MaxTextExtent]; |
| 412 | |
| 413 | /* |
| 414 | Form filename for multi-part images. |
| 415 | */ |
| 416 | (void) InterpretImageFilename(image_info,(Image *) NULL, |
| 417 | image_info->filename,(int) scene,filename); |
| 418 | if (LocaleCompare(filename,image_info->filename) == 0) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 419 | (void) FormatLocaleString(filename,MaxTextExtent,"%s.%.20g", |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 420 | image_info->filename,(double) scene); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 421 | (void) CopyMagickString(image_info->filename,filename, |
| 422 | MaxTextExtent); |
| 423 | } |
| 424 | (void) CloneString(&image_info->font,montage_info->font); |
| 425 | images=ReadImages(image_info,exception); |
| 426 | status&=(images != (Image *) NULL) && |
| 427 | (exception->severity < ErrorException); |
| 428 | if (images == (Image *) NULL) |
| 429 | continue; |
| 430 | AppendImageStack(images); |
| 431 | } |
| 432 | continue; |
| 433 | } |
| 434 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 435 | switch (*(option+1)) |
| 436 | { |
| 437 | case 'a': |
| 438 | { |
| 439 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 440 | { |
| 441 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 442 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 443 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 444 | if (IsGeometry(argv[i]) == MagickFalse) |
| 445 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 446 | break; |
| 447 | } |
| 448 | if (LocaleCompare("adjoin",option+1) == 0) |
| 449 | break; |
| 450 | if (LocaleCompare("affine",option+1) == 0) |
| 451 | { |
| 452 | if (*option == '+') |
| 453 | break; |
| 454 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 455 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 456 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 457 | if (IsGeometry(argv[i]) == MagickFalse) |
| 458 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 459 | break; |
| 460 | } |
| 461 | if (LocaleCompare("alpha",option+1) == 0) |
| 462 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 463 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 464 | type; |
| 465 | |
| 466 | if (*option == '+') |
| 467 | break; |
| 468 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 469 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 470 | ThrowMontageException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 471 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 472 | if (type < 0) |
| 473 | ThrowMontageException(OptionError,"UnrecognizedAlphaChannelType", |
| 474 | argv[i]); |
| 475 | break; |
| 476 | } |
| 477 | if (LocaleCompare("annotate",option+1) == 0) |
| 478 | { |
| 479 | if (*option == '+') |
| 480 | break; |
| 481 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 482 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 483 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 484 | if (IsGeometry(argv[i]) == MagickFalse) |
| 485 | ThrowMontageInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 486 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 487 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 488 | i++; |
| 489 | break; |
| 490 | } |
| 491 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 492 | break; |
| 493 | if (LocaleCompare("authenticate",option+1) == 0) |
| 494 | { |
| 495 | if (*option == '+') |
| 496 | break; |
| 497 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 498 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 499 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 500 | break; |
| 501 | } |
| 502 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 503 | } |
| 504 | case 'b': |
| 505 | { |
| 506 | if (LocaleCompare("background",option+1) == 0) |
| 507 | { |
| 508 | if (*option == '+') |
| 509 | break; |
| 510 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 511 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 512 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 513 | (void) QueryColorDatabase(argv[i], |
| 514 | &montage_info->background_color,exception); |
| 515 | break; |
| 516 | } |
| 517 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 518 | { |
| 519 | if (*option == '+') |
| 520 | break; |
| 521 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 522 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 523 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 524 | if (IsGeometry(argv[i]) == MagickFalse) |
| 525 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 526 | break; |
| 527 | } |
| 528 | if (LocaleCompare("blur",option+1) == 0) |
| 529 | { |
| 530 | if (*option == '+') |
| 531 | break; |
| 532 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 533 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 534 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 535 | if (IsGeometry(argv[i]) == MagickFalse) |
| 536 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 537 | break; |
| 538 | } |
| 539 | if (LocaleCompare("border",option+1) == 0) |
| 540 | { |
cristy | 9ce07f6 | 2010-05-21 13:14:10 +0000 | [diff] [blame] | 541 | if (k == 0) |
| 542 | { |
| 543 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 544 | montage_info->border_width=0; |
| 545 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 546 | if (*option == '+') |
| 547 | break; |
| 548 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 549 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 550 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 551 | if (IsGeometry(argv[i]) == MagickFalse) |
| 552 | ThrowMontageInvalidArgumentException(option,argv[i]); |
cristy | 9ce07f6 | 2010-05-21 13:14:10 +0000 | [diff] [blame] | 553 | if (k == 0) |
| 554 | montage_info->border_width=StringToUnsignedLong(argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 555 | break; |
| 556 | } |
| 557 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 558 | { |
| 559 | if (*option == '+') |
| 560 | break; |
| 561 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 562 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 563 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 564 | (void) QueryColorDatabase(argv[i],&montage_info->border_color, |
| 565 | exception); |
| 566 | break; |
| 567 | } |
| 568 | if (LocaleCompare("borderwidth",option+1) == 0) |
| 569 | { |
| 570 | montage_info->border_width=0; |
| 571 | if (*option == '+') |
| 572 | break; |
| 573 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 574 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 575 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 576 | if (IsGeometry(argv[i]) == MagickFalse) |
| 577 | ThrowMontageInvalidArgumentException(option,argv[i]); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 578 | montage_info->border_width=StringToUnsignedLong(argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 579 | break; |
| 580 | } |
| 581 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 582 | } |
| 583 | case 'c': |
| 584 | { |
| 585 | if (LocaleCompare("cache",option+1) == 0) |
| 586 | { |
| 587 | if (*option == '+') |
| 588 | break; |
| 589 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 590 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 591 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 592 | if (IsGeometry(argv[i]) == MagickFalse) |
| 593 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 594 | break; |
| 595 | } |
| 596 | if (LocaleCompare("caption",option+1) == 0) |
| 597 | { |
| 598 | if (*option == '+') |
| 599 | break; |
| 600 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 601 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 602 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 603 | break; |
| 604 | } |
| 605 | if (LocaleCompare("channel",option+1) == 0) |
| 606 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 607 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 608 | channel; |
| 609 | |
| 610 | if (*option == '+') |
| 611 | break; |
| 612 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 613 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 614 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 615 | channel=ParseChannelOption(argv[i]); |
| 616 | if (channel < 0) |
| 617 | ThrowMontageException(OptionError,"UnrecognizedChannelType", |
| 618 | argv[i]); |
| 619 | break; |
| 620 | } |
| 621 | if (LocaleCompare("clone",option+1) == 0) |
| 622 | { |
| 623 | Image |
| 624 | *clone_images; |
| 625 | |
| 626 | clone_images=image; |
| 627 | if (k != 0) |
| 628 | clone_images=image_stack[k-1].image; |
| 629 | if (clone_images == (Image *) NULL) |
| 630 | ThrowMontageException(ImageError,"ImageSequenceRequired",option); |
| 631 | FireImageStack(MagickTrue,MagickTrue,MagickTrue); |
| 632 | if (*option == '+') |
| 633 | clone_images=CloneImages(clone_images,"-1",exception); |
| 634 | else |
| 635 | { |
| 636 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 637 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 638 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 639 | if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse) |
| 640 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 641 | clone_images=CloneImages(clone_images,argv[i],exception); |
| 642 | } |
| 643 | if (clone_images == (Image *) NULL) |
| 644 | ThrowMontageException(OptionError,"NoSuchImage",option); |
| 645 | AppendImageStack(clone_images); |
| 646 | break; |
| 647 | } |
| 648 | if (LocaleCompare("coalesce",option+1) == 0) |
| 649 | break; |
| 650 | if (LocaleCompare("colors",option+1) == 0) |
| 651 | { |
| 652 | if (*option == '+') |
| 653 | break; |
| 654 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 655 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 656 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 657 | if (IsGeometry(argv[i]) == MagickFalse) |
| 658 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 659 | break; |
| 660 | } |
| 661 | if (LocaleCompare("colorspace",option+1) == 0) |
| 662 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 663 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 664 | colorspace; |
| 665 | |
| 666 | if (*option == '+') |
| 667 | break; |
| 668 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 669 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 670 | ThrowMontageException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 671 | colorspace=ParseCommandOption(MagickColorspaceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 672 | MagickFalse,argv[i]); |
| 673 | if (colorspace < 0) |
| 674 | ThrowMontageException(OptionError,"UnrecognizedColorspace", |
| 675 | argv[i]); |
| 676 | break; |
| 677 | } |
| 678 | if (LocaleCompare("comment",option+1) == 0) |
| 679 | { |
| 680 | if (*option == '+') |
| 681 | break; |
| 682 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 683 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 684 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 685 | break; |
| 686 | } |
| 687 | if (LocaleCompare("compose",option+1) == 0) |
| 688 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 689 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 690 | compose; |
| 691 | |
| 692 | if (*option == '+') |
| 693 | break; |
| 694 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 695 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 696 | ThrowMontageException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 697 | compose=ParseCommandOption(MagickComposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 698 | if (compose < 0) |
| 699 | ThrowMontageException(OptionError,"UnrecognizedComposeOperator", |
| 700 | argv[i]); |
| 701 | break; |
| 702 | } |
| 703 | if (LocaleCompare("composite",option+1) == 0) |
| 704 | break; |
| 705 | if (LocaleCompare("compress",option+1) == 0) |
| 706 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 707 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 708 | compress; |
| 709 | |
| 710 | if (*option == '+') |
| 711 | break; |
| 712 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 713 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 714 | ThrowMontageException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 715 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 716 | argv[i]); |
| 717 | if (compress < 0) |
| 718 | ThrowMontageException(OptionError,"UnrecognizedCompressType", |
| 719 | argv[i]); |
| 720 | break; |
| 721 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 722 | if (LocaleCompare("concurrent",option+1) == 0) |
| 723 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 724 | if (LocaleCompare("crop",option+1) == 0) |
| 725 | { |
| 726 | if (*option == '+') |
| 727 | break; |
| 728 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 729 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 730 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 731 | if (IsGeometry(argv[i]) == MagickFalse) |
| 732 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 733 | break; |
| 734 | } |
| 735 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 736 | } |
| 737 | case 'd': |
| 738 | { |
| 739 | if (LocaleCompare("debug",option+1) == 0) |
| 740 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 741 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 742 | event; |
| 743 | |
| 744 | if (*option == '+') |
| 745 | break; |
| 746 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 747 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 748 | ThrowMontageException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 749 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 750 | if (event < 0) |
| 751 | ThrowMontageException(OptionError,"UnrecognizedEventType", |
| 752 | argv[i]); |
| 753 | (void) SetLogEventMask(argv[i]); |
| 754 | break; |
| 755 | } |
| 756 | if (LocaleCompare("define",option+1) == 0) |
| 757 | { |
| 758 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 759 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 760 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 761 | if (*option == '+') |
| 762 | { |
| 763 | const char |
| 764 | *define; |
| 765 | |
| 766 | define=GetImageOption(image_info,argv[i]); |
| 767 | if (define == (const char *) NULL) |
| 768 | ThrowMontageException(OptionError,"NoSuchOption",argv[i]); |
| 769 | break; |
| 770 | } |
| 771 | break; |
| 772 | } |
| 773 | if (LocaleCompare("density",option+1) == 0) |
| 774 | { |
| 775 | if (*option == '+') |
| 776 | break; |
| 777 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 778 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 779 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 780 | if (IsGeometry(argv[i]) == MagickFalse) |
| 781 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 782 | break; |
| 783 | } |
| 784 | if (LocaleCompare("depth",option+1) == 0) |
| 785 | { |
| 786 | if (*option == '+') |
| 787 | break; |
| 788 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 789 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 790 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 791 | if (IsGeometry(argv[i]) == MagickFalse) |
| 792 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 793 | break; |
| 794 | } |
| 795 | if (LocaleCompare("display",option+1) == 0) |
| 796 | { |
| 797 | if (*option == '+') |
| 798 | break; |
| 799 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 800 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 801 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 802 | break; |
| 803 | } |
| 804 | if (LocaleCompare("dispose",option+1) == 0) |
| 805 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 806 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 807 | dispose; |
| 808 | |
| 809 | if (*option == '+') |
| 810 | break; |
| 811 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 812 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 813 | ThrowMontageException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 814 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 815 | if (dispose < 0) |
| 816 | ThrowMontageException(OptionError,"UnrecognizedDisposeMethod", |
| 817 | argv[i]); |
| 818 | break; |
| 819 | } |
| 820 | if (LocaleCompare("dither",option+1) == 0) |
| 821 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 822 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 823 | method; |
| 824 | |
| 825 | if (*option == '+') |
| 826 | break; |
| 827 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 828 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 829 | ThrowMontageException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 830 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 831 | if (method < 0) |
| 832 | ThrowMontageException(OptionError,"UnrecognizedDitherMethod", |
| 833 | argv[i]); |
| 834 | break; |
| 835 | } |
| 836 | if (LocaleCompare("draw",option+1) == 0) |
| 837 | { |
| 838 | if (*option == '+') |
| 839 | break; |
| 840 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 841 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 842 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 843 | break; |
| 844 | } |
cristy | 5d28d48 | 2011-03-20 21:59:40 +0000 | [diff] [blame] | 845 | if (LocaleCompare("duplicate",option+1) == 0) |
| 846 | { |
cristy | 5d28d48 | 2011-03-20 21:59:40 +0000 | [diff] [blame] | 847 | if (*option == '+') |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 848 | break; |
| 849 | i++; |
| 850 | if (i == (ssize_t) (argc-1)) |
| 851 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 852 | if (IsGeometry(argv[i]) == MagickFalse) |
| 853 | ThrowMontageInvalidArgumentException(option,argv[i]); |
cristy | 5d28d48 | 2011-03-20 21:59:40 +0000 | [diff] [blame] | 854 | break; |
| 855 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 856 | if (LocaleCompare("duration",option+1) == 0) |
| 857 | { |
| 858 | if (*option == '+') |
| 859 | break; |
| 860 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 861 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 862 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 863 | if (IsGeometry(argv[i]) == MagickFalse) |
| 864 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 865 | break; |
| 866 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 867 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 868 | } |
| 869 | case 'e': |
| 870 | { |
| 871 | if (LocaleCompare("encoding",option+1) == 0) |
| 872 | { |
| 873 | if (*option == '+') |
| 874 | break; |
| 875 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 876 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 877 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 878 | break; |
| 879 | } |
| 880 | if (LocaleCompare("endian",option+1) == 0) |
| 881 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 882 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 883 | endian; |
| 884 | |
| 885 | if (*option == '+') |
| 886 | break; |
| 887 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 888 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 889 | ThrowMontageException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 890 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 891 | argv[i]); |
| 892 | if (endian < 0) |
| 893 | ThrowMontageException(OptionError,"UnrecognizedEndianType", |
| 894 | argv[i]); |
| 895 | break; |
| 896 | } |
| 897 | if (LocaleCompare("extent",option+1) == 0) |
| 898 | { |
| 899 | if (*option == '+') |
| 900 | break; |
| 901 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 902 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 903 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 904 | if (IsGeometry(argv[i]) == MagickFalse) |
| 905 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 906 | break; |
| 907 | } |
| 908 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 909 | } |
| 910 | case 'f': |
| 911 | { |
| 912 | if (LocaleCompare("fill",option+1) == 0) |
| 913 | { |
| 914 | (void) QueryColorDatabase("none",&montage_info->fill,exception); |
| 915 | if (*option == '+') |
| 916 | break; |
| 917 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 918 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 919 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 920 | (void) QueryColorDatabase(argv[i],&montage_info->fill, |
| 921 | exception); |
| 922 | break; |
| 923 | } |
| 924 | if (LocaleCompare("filter",option+1) == 0) |
| 925 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 926 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 927 | filter; |
| 928 | |
| 929 | if (*option == '+') |
| 930 | break; |
| 931 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 932 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 933 | ThrowMontageException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 934 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 935 | if (filter < 0) |
| 936 | ThrowMontageException(OptionError,"UnrecognizedImageFilter", |
| 937 | argv[i]); |
| 938 | break; |
| 939 | } |
| 940 | if (LocaleCompare("flatten",option+1) == 0) |
| 941 | break; |
| 942 | if (LocaleCompare("flip",option+1) == 0) |
| 943 | break; |
| 944 | if (LocaleCompare("flop",option+1) == 0) |
| 945 | break; |
| 946 | if (LocaleCompare("font",option+1) == 0) |
| 947 | { |
| 948 | if (*option == '+') |
| 949 | break; |
| 950 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 951 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 952 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 953 | (void) CloneString(&montage_info->font,argv[i]); |
| 954 | break; |
| 955 | } |
| 956 | if (LocaleCompare("format",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 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 963 | format=argv[i]; |
| 964 | break; |
| 965 | } |
| 966 | if (LocaleCompare("frame",option+1) == 0) |
| 967 | { |
cristy | 9ce07f6 | 2010-05-21 13:14:10 +0000 | [diff] [blame] | 968 | if (k == 0) |
| 969 | { |
| 970 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 971 | (void) CloneString(&montage_info->frame,(char *) NULL); |
| 972 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 973 | if (*option == '+') |
| 974 | break; |
| 975 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 976 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 977 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 978 | if (IsGeometry(argv[i]) == MagickFalse) |
| 979 | ThrowMontageInvalidArgumentException(option,argv[i]); |
cristy | 9ce07f6 | 2010-05-21 13:14:10 +0000 | [diff] [blame] | 980 | if (k == 0) |
| 981 | (void) CloneString(&montage_info->frame,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 982 | break; |
| 983 | } |
| 984 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 985 | } |
| 986 | case 'g': |
| 987 | { |
| 988 | if (LocaleCompare("gamma",option+1) == 0) |
| 989 | { |
| 990 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 991 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 992 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 993 | if (IsGeometry(argv[i]) == MagickFalse) |
| 994 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 995 | break; |
| 996 | } |
| 997 | if (LocaleCompare("geometry",option+1) == 0) |
| 998 | { |
| 999 | (void) CloneString(&montage_info->geometry,(char *) NULL); |
| 1000 | if (*option == '+') |
| 1001 | break; |
| 1002 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1003 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1004 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1005 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1006 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1007 | (void) CloneString(&montage_info->geometry,argv[i]); |
| 1008 | break; |
| 1009 | } |
| 1010 | if (LocaleCompare("gravity",option+1) == 0) |
| 1011 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1012 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1013 | gravity; |
| 1014 | |
| 1015 | montage_info->gravity=UndefinedGravity; |
| 1016 | if (*option == '+') |
| 1017 | break; |
| 1018 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1019 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1020 | ThrowMontageException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1021 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1022 | argv[i]); |
| 1023 | if (gravity < 0) |
| 1024 | ThrowMontageException(OptionError,"UnrecognizedGravityType", |
| 1025 | argv[i]); |
| 1026 | montage_info->gravity=(GravityType) gravity; |
| 1027 | break; |
| 1028 | } |
| 1029 | if (LocaleCompare("green-primary",option+1) == 0) |
| 1030 | { |
| 1031 | if (*option == '+') |
| 1032 | break; |
| 1033 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1034 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1035 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1036 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1037 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1038 | break; |
| 1039 | } |
| 1040 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 1041 | } |
| 1042 | case 'h': |
| 1043 | { |
| 1044 | if ((LocaleCompare("help",option+1) == 0) || |
| 1045 | (LocaleCompare("-help",option+1) == 0)) |
| 1046 | return(MontageUsage()); |
| 1047 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 1048 | } |
| 1049 | case 'i': |
| 1050 | { |
| 1051 | if (LocaleCompare("identify",option+1) == 0) |
| 1052 | break; |
| 1053 | if (LocaleCompare("interlace",option+1) == 0) |
| 1054 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1055 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1056 | interlace; |
| 1057 | |
| 1058 | if (*option == '+') |
| 1059 | break; |
| 1060 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1061 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1062 | ThrowMontageException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1063 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1064 | argv[i]); |
| 1065 | if (interlace < 0) |
| 1066 | ThrowMontageException(OptionError,"UnrecognizedInterlaceType", |
| 1067 | argv[i]); |
| 1068 | break; |
| 1069 | } |
| 1070 | if (LocaleCompare("interpolate",option+1) == 0) |
| 1071 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1072 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1073 | interpolate; |
| 1074 | |
| 1075 | if (*option == '+') |
| 1076 | break; |
| 1077 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1078 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1079 | ThrowMontageException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1080 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1081 | argv[i]); |
| 1082 | if (interpolate < 0) |
| 1083 | ThrowMontageException(OptionError,"UnrecognizedInterpolateMethod", |
| 1084 | argv[i]); |
| 1085 | break; |
| 1086 | } |
| 1087 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 1088 | } |
cristy | 837699d | 2010-07-28 23:49:03 +0000 | [diff] [blame] | 1089 | case 'k': |
| 1090 | { |
| 1091 | if (LocaleCompare("kerning",option+1) == 0) |
| 1092 | { |
| 1093 | if (*option == '+') |
| 1094 | break; |
| 1095 | i++; |
| 1096 | if (i == (ssize_t) (argc-1)) |
| 1097 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1098 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1099 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1100 | break; |
| 1101 | } |
| 1102 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 1103 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1104 | case 'l': |
| 1105 | { |
| 1106 | if (LocaleCompare("label",option+1) == 0) |
| 1107 | { |
| 1108 | if (*option == '+') |
| 1109 | break; |
| 1110 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1111 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1112 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1113 | break; |
| 1114 | } |
| 1115 | if (LocaleCompare("limit",option+1) == 0) |
| 1116 | { |
| 1117 | char |
| 1118 | *p; |
| 1119 | |
| 1120 | double |
| 1121 | value; |
| 1122 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1123 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1124 | resource; |
| 1125 | |
| 1126 | if (*option == '+') |
| 1127 | break; |
| 1128 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1129 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1130 | ThrowMontageException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1131 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1132 | argv[i]); |
| 1133 | if (resource < 0) |
| 1134 | ThrowMontageException(OptionError,"UnrecognizedResourceType", |
| 1135 | argv[i]); |
| 1136 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1137 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1138 | ThrowMontageException(OptionError,"MissingArgument",option); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1139 | value=InterpretLocaleValue(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 1140 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1141 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 1142 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1143 | break; |
| 1144 | } |
| 1145 | if (LocaleCompare("list",option+1) == 0) |
| 1146 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1147 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1148 | list; |
| 1149 | |
| 1150 | if (*option == '+') |
| 1151 | break; |
| 1152 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1153 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1154 | ThrowMontageException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1155 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1156 | if (list < 0) |
| 1157 | ThrowMontageException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 1158 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1159 | argv+j,exception); |
| 1160 | DestroyMontage(); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 1161 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1162 | } |
| 1163 | if (LocaleCompare("log",option+1) == 0) |
| 1164 | { |
| 1165 | if (*option == '+') |
| 1166 | break; |
| 1167 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1168 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1169 | (strchr(argv[i],'%') == (char *) NULL)) |
| 1170 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1171 | break; |
| 1172 | } |
| 1173 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 1174 | } |
| 1175 | case 'm': |
| 1176 | { |
| 1177 | if (LocaleCompare("matte",option+1) == 0) |
| 1178 | break; |
| 1179 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 1180 | { |
| 1181 | if (*option == '+') |
| 1182 | break; |
| 1183 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1184 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1185 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1186 | (void) QueryColorDatabase(argv[i],&montage_info->matte_color, |
| 1187 | exception); |
| 1188 | break; |
| 1189 | } |
| 1190 | if (LocaleCompare("mode",option+1) == 0) |
| 1191 | { |
| 1192 | MontageMode |
| 1193 | mode; |
| 1194 | |
cristy | db16ded | 2011-02-28 00:02:19 +0000 | [diff] [blame] | 1195 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1196 | if (*option == '+') |
| 1197 | break; |
| 1198 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1199 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1200 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1201 | mode=UndefinedMode; |
| 1202 | if (LocaleCompare("frame",argv[i]) == 0) |
| 1203 | { |
| 1204 | mode=FrameMode; |
| 1205 | (void) CloneString(&montage_info->frame,"15x15+3+3"); |
| 1206 | montage_info->shadow=MagickTrue; |
| 1207 | break; |
| 1208 | } |
| 1209 | if (LocaleCompare("unframe",argv[i]) == 0) |
| 1210 | { |
| 1211 | mode=UnframeMode; |
| 1212 | montage_info->frame=(char *) NULL; |
| 1213 | montage_info->shadow=MagickFalse; |
| 1214 | montage_info->border_width=0; |
| 1215 | break; |
| 1216 | } |
| 1217 | if (LocaleCompare("concatenate",argv[i]) == 0) |
| 1218 | { |
| 1219 | mode=ConcatenateMode; |
| 1220 | montage_info->frame=(char *) NULL; |
| 1221 | montage_info->shadow=MagickFalse; |
| 1222 | montage_info->gravity=(GravityType) NorthWestGravity; |
| 1223 | (void) CloneString(&montage_info->geometry,"+0+0"); |
| 1224 | montage_info->border_width=0; |
| 1225 | break; |
| 1226 | } |
| 1227 | if (mode == UndefinedMode) |
| 1228 | ThrowMontageException(OptionError,"UnrecognizedImageMode", |
| 1229 | argv[i]); |
| 1230 | break; |
| 1231 | } |
| 1232 | if (LocaleCompare("monitor",option+1) == 0) |
| 1233 | break; |
| 1234 | if (LocaleCompare("monochrome",option+1) == 0) |
| 1235 | { |
| 1236 | if (*option == '+') |
| 1237 | break; |
| 1238 | break; |
| 1239 | } |
| 1240 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 1241 | } |
| 1242 | case 'n': |
| 1243 | { |
| 1244 | if (LocaleCompare("noop",option+1) == 0) |
| 1245 | break; |
| 1246 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 1247 | } |
| 1248 | case 'o': |
| 1249 | { |
| 1250 | if (LocaleCompare("origin",option+1) == 0) |
| 1251 | { |
| 1252 | if (*option == '+') |
| 1253 | break; |
| 1254 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1255 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1256 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1257 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1258 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1259 | break; |
| 1260 | } |
| 1261 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 1262 | } |
| 1263 | case 'p': |
| 1264 | { |
| 1265 | if (LocaleCompare("page",option+1) == 0) |
| 1266 | { |
| 1267 | if (*option == '+') |
| 1268 | break; |
| 1269 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1270 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1271 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1272 | break; |
| 1273 | } |
| 1274 | if (LocaleCompare("pointsize",option+1) == 0) |
| 1275 | { |
| 1276 | montage_info->pointsize=12; |
| 1277 | if (*option == '+') |
| 1278 | break; |
| 1279 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1280 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1281 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1282 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1283 | ThrowMontageInvalidArgumentException(option,argv[i]); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1284 | montage_info->pointsize=InterpretLocaleValue(argv[i], |
| 1285 | (char **) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1286 | break; |
| 1287 | } |
| 1288 | if (LocaleCompare("polaroid",option+1) == 0) |
| 1289 | { |
| 1290 | if (*option == '+') |
| 1291 | break; |
| 1292 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1293 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1294 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1295 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1296 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1297 | break; |
| 1298 | } |
| 1299 | if (LocaleCompare("profile",option+1) == 0) |
| 1300 | { |
| 1301 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1302 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1303 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1304 | break; |
| 1305 | } |
| 1306 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 1307 | } |
| 1308 | case 'q': |
| 1309 | { |
| 1310 | if (LocaleCompare("quality",option+1) == 0) |
| 1311 | { |
| 1312 | if (*option == '+') |
| 1313 | break; |
| 1314 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1315 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1316 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1317 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1318 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1319 | break; |
| 1320 | } |
| 1321 | if (LocaleCompare("quantize",option+1) == 0) |
| 1322 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1323 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1324 | colorspace; |
| 1325 | |
| 1326 | if (*option == '+') |
| 1327 | break; |
| 1328 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1329 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1330 | ThrowMontageException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1331 | colorspace=ParseCommandOption(MagickColorspaceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1332 | MagickFalse,argv[i]); |
| 1333 | if (colorspace < 0) |
| 1334 | ThrowMontageException(OptionError,"UnrecognizedColorspace", |
| 1335 | argv[i]); |
| 1336 | break; |
| 1337 | } |
| 1338 | if (LocaleCompare("quiet",option+1) == 0) |
| 1339 | break; |
| 1340 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 1341 | } |
| 1342 | case 'r': |
| 1343 | { |
| 1344 | if (LocaleCompare("red-primary",option+1) == 0) |
| 1345 | { |
| 1346 | if (*option == '+') |
| 1347 | break; |
| 1348 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1349 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1350 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1351 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1352 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1353 | break; |
| 1354 | } |
| 1355 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 1356 | break; |
| 1357 | if (LocaleCompare("render",option+1) == 0) |
| 1358 | break; |
| 1359 | if (LocaleCompare("repage",option+1) == 0) |
| 1360 | { |
| 1361 | if (*option == '+') |
| 1362 | break; |
| 1363 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1364 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1365 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1366 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1367 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1368 | break; |
| 1369 | } |
| 1370 | if (LocaleCompare("resize",option+1) == 0) |
| 1371 | { |
| 1372 | if (*option == '+') |
| 1373 | break; |
| 1374 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1375 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1376 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1377 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1378 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1379 | break; |
| 1380 | } |
| 1381 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 1382 | { |
| 1383 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 1384 | break; |
| 1385 | } |
| 1386 | if (LocaleCompare("rotate",option+1) == 0) |
| 1387 | { |
| 1388 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1389 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1390 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1391 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1392 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1393 | break; |
| 1394 | } |
| 1395 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 1396 | } |
| 1397 | case 's': |
| 1398 | { |
| 1399 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 1400 | { |
| 1401 | if (*option == '+') |
| 1402 | break; |
| 1403 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1404 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1405 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1406 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1407 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1408 | break; |
| 1409 | } |
| 1410 | if (LocaleCompare("seed",option+1) == 0) |
| 1411 | { |
| 1412 | if (*option == '+') |
| 1413 | break; |
| 1414 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1415 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1416 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1417 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1418 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1419 | break; |
| 1420 | } |
| 1421 | if (LocaleCompare("scenes",option+1) == 0) |
| 1422 | { |
| 1423 | first_scene=0; |
| 1424 | last_scene=0; |
| 1425 | if (*option == '+') |
| 1426 | break; |
| 1427 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1428 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1429 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1430 | if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse) |
| 1431 | ThrowMontageInvalidArgumentException(option,argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 1432 | first_scene=(int) StringToLong(argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1433 | last_scene=first_scene; |
| 1434 | (void) sscanf(argv[i],"%ld-%ld",&first_scene,&last_scene); |
| 1435 | break; |
| 1436 | } |
| 1437 | if (LocaleCompare("set",option+1) == 0) |
| 1438 | { |
| 1439 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1440 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1441 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1442 | if (*option == '+') |
| 1443 | break; |
| 1444 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1445 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1446 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1447 | break; |
| 1448 | } |
| 1449 | if (LocaleCompare("shadow",option+1) == 0) |
| 1450 | { |
cristy | 9ce07f6 | 2010-05-21 13:14:10 +0000 | [diff] [blame] | 1451 | if (k == 0) |
| 1452 | { |
| 1453 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 1454 | montage_info->shadow=(*option == '-') ? MagickTrue : |
| 1455 | MagickFalse; |
| 1456 | break; |
| 1457 | } |
| 1458 | if (*option == '+') |
| 1459 | break; |
| 1460 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1461 | if (i == (ssize_t) (argc-1)) |
cristy | 9ce07f6 | 2010-05-21 13:14:10 +0000 | [diff] [blame] | 1462 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1463 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1464 | ThrowMontageInvalidArgumentException(option,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1465 | break; |
| 1466 | } |
| 1467 | if (LocaleCompare("sharpen",option+1) == 0) |
| 1468 | { |
| 1469 | if (*option == '+') |
| 1470 | break; |
| 1471 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1472 | if ((i == (ssize_t) argc) || (IsGeometry(argv[i]) == MagickFalse)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1473 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1474 | break; |
| 1475 | } |
| 1476 | if (LocaleCompare("size",option+1) == 0) |
| 1477 | { |
| 1478 | if (*option == '+') |
| 1479 | break; |
| 1480 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1481 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1482 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1483 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1484 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1485 | break; |
| 1486 | } |
| 1487 | if (LocaleCompare("stroke",option+1) == 0) |
| 1488 | { |
| 1489 | (void) QueryColorDatabase("none",&montage_info->stroke,exception); |
| 1490 | if (*option == '+') |
| 1491 | break; |
| 1492 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1493 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1494 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1495 | (void) QueryColorDatabase(argv[i],&montage_info->stroke, |
| 1496 | exception); |
| 1497 | break; |
| 1498 | } |
| 1499 | if (LocaleCompare("strip",option+1) == 0) |
| 1500 | break; |
| 1501 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 1502 | { |
| 1503 | if (*option == '+') |
| 1504 | break; |
| 1505 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1506 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1507 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1508 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1509 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1510 | break; |
| 1511 | } |
| 1512 | if (LocaleCompare("support",option+1) == 0) |
| 1513 | { |
| 1514 | i++; /* deprecated */ |
| 1515 | break; |
| 1516 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 1517 | if (LocaleCompare("synchronize",option+1) == 0) |
| 1518 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1519 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 1520 | } |
| 1521 | case 't': |
| 1522 | { |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 1523 | if (LocaleCompare("taint",option+1) == 0) |
| 1524 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1525 | if (LocaleCompare("texture",option+1) == 0) |
| 1526 | { |
| 1527 | (void) CloneString(&montage_info->texture,(char *) NULL); |
| 1528 | if (*option == '+') |
| 1529 | break; |
| 1530 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1531 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1532 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1533 | (void) CloneString(&montage_info->texture,argv[i]); |
| 1534 | break; |
| 1535 | } |
| 1536 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 1537 | { |
| 1538 | if (*option == '+') |
| 1539 | break; |
| 1540 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1541 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1542 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1543 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1544 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1545 | break; |
| 1546 | } |
| 1547 | if (LocaleCompare("tile",option+1) == 0) |
| 1548 | { |
cristy | 9ce07f6 | 2010-05-21 13:14:10 +0000 | [diff] [blame] | 1549 | if (k == 0) |
| 1550 | { |
| 1551 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 1552 | (void) CloneString(&montage_info->tile,(char *) NULL); |
| 1553 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1554 | if (*option == '+') |
| 1555 | break; |
| 1556 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1557 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1558 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1559 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1560 | ThrowMontageInvalidArgumentException(option,argv[i]); |
cristy | 9ce07f6 | 2010-05-21 13:14:10 +0000 | [diff] [blame] | 1561 | if (k == 0) |
| 1562 | (void) CloneString(&montage_info->tile,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1563 | break; |
| 1564 | } |
| 1565 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 1566 | { |
| 1567 | if (*option == '+') |
| 1568 | break; |
| 1569 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1570 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1571 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1572 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1573 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1574 | break; |
| 1575 | } |
| 1576 | if (LocaleCompare("tint",option+1) == 0) |
| 1577 | { |
| 1578 | if (*option == '+') |
| 1579 | break; |
| 1580 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1581 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1582 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1583 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1584 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1585 | break; |
| 1586 | } |
| 1587 | if (LocaleCompare("transform",option+1) == 0) |
| 1588 | break; |
| 1589 | if (LocaleCompare("transpose",option+1) == 0) |
| 1590 | break; |
| 1591 | if (LocaleCompare("title",option+1) == 0) |
| 1592 | { |
| 1593 | (void) CloneString(&montage_info->title,(char *) NULL); |
| 1594 | if (*option == '+') |
| 1595 | break; |
| 1596 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1597 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1598 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1599 | (void) CloneString(&montage_info->title,argv[i]); |
| 1600 | break; |
| 1601 | } |
| 1602 | if (LocaleCompare("transform",option+1) == 0) |
| 1603 | break; |
| 1604 | if (LocaleCompare("transparent",option+1) == 0) |
| 1605 | { |
| 1606 | transparent_color=(char *) NULL; |
| 1607 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1608 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1609 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1610 | (void) CloneString(&transparent_color,argv[i]); |
| 1611 | break; |
| 1612 | } |
| 1613 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 1614 | { |
| 1615 | if (*option == '+') |
| 1616 | break; |
| 1617 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1618 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1619 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1620 | break; |
| 1621 | } |
| 1622 | if (LocaleCompare("treedepth",option+1) == 0) |
| 1623 | { |
| 1624 | if (*option == '+') |
| 1625 | break; |
| 1626 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1627 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1628 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1629 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1630 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1631 | break; |
| 1632 | } |
| 1633 | if (LocaleCompare("trim",option+1) == 0) |
| 1634 | break; |
| 1635 | if (LocaleCompare("type",option+1) == 0) |
| 1636 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1637 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1638 | type; |
| 1639 | |
| 1640 | if (*option == '+') |
| 1641 | break; |
| 1642 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1643 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1644 | ThrowMontageException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1645 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1646 | if (type < 0) |
| 1647 | ThrowMontageException(OptionError,"UnrecognizedImageType", |
| 1648 | argv[i]); |
| 1649 | break; |
| 1650 | } |
| 1651 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 1652 | } |
| 1653 | case 'u': |
| 1654 | { |
| 1655 | if (LocaleCompare("units",option+1) == 0) |
| 1656 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1657 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1658 | units; |
| 1659 | |
| 1660 | if (*option == '+') |
| 1661 | break; |
| 1662 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1663 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1664 | ThrowMontageException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1665 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1666 | argv[i]); |
| 1667 | if (units < 0) |
| 1668 | ThrowMontageException(OptionError,"UnrecognizedUnitsType", |
| 1669 | argv[i]); |
| 1670 | break; |
| 1671 | } |
| 1672 | if (LocaleCompare("unsharp",option+1) == 0) |
| 1673 | { |
| 1674 | if (*option == '+') |
| 1675 | break; |
| 1676 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1677 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1678 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1679 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1680 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1681 | break; |
| 1682 | } |
| 1683 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 1684 | } |
| 1685 | case 'v': |
| 1686 | { |
| 1687 | if (LocaleCompare("verbose",option+1) == 0) |
| 1688 | { |
| 1689 | break; |
| 1690 | } |
| 1691 | if ((LocaleCompare("version",option+1) == 0) || |
| 1692 | (LocaleCompare("-version",option+1) == 0)) |
| 1693 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1694 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1695 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1696 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 1697 | GetMagickCopyright()); |
| 1698 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 1699 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1700 | break; |
| 1701 | } |
| 1702 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 1703 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1704 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1705 | method; |
| 1706 | |
| 1707 | if (*option == '+') |
| 1708 | break; |
| 1709 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1710 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1711 | ThrowMontageException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1712 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1713 | argv[i]); |
| 1714 | if (method < 0) |
| 1715 | ThrowMontageException(OptionError, |
| 1716 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 1717 | break; |
| 1718 | } |
| 1719 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 1720 | } |
| 1721 | case 'w': |
| 1722 | { |
| 1723 | if (LocaleCompare("white-point",option+1) == 0) |
| 1724 | { |
| 1725 | if (*option == '+') |
| 1726 | break; |
| 1727 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1728 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1729 | ThrowMontageException(OptionError,"MissingArgument",option); |
| 1730 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1731 | ThrowMontageInvalidArgumentException(option,argv[i]); |
| 1732 | break; |
| 1733 | } |
| 1734 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 1735 | } |
| 1736 | case '?': |
| 1737 | break; |
| 1738 | default: |
| 1739 | ThrowMontageException(OptionError,"UnrecognizedOption",option) |
| 1740 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1741 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 1742 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1743 | if (fire != MagickFalse) |
| 1744 | FireImageStack(MagickTrue,MagickTrue,MagickTrue); |
| 1745 | } |
| 1746 | if (k != 0) |
| 1747 | ThrowMontageException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1748 | if (i-- != (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1749 | ThrowMontageException(OptionError,"MissingAnImageFilename",argv[i]); |
| 1750 | if (image == (Image *) NULL) |
| 1751 | ThrowMontageException(OptionError,"MissingAnImageFilename",argv[argc-1]); |
| 1752 | FinalizeImageSettings(image_info,image,MagickTrue); |
cristy | 94f2007 | 2009-09-12 02:12:36 +0000 | [diff] [blame] | 1753 | if (image == (Image *) NULL) |
| 1754 | ThrowMontageException(OptionError,"MissingAnImageFilename",argv[argc-1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1755 | (void) CopyMagickString(montage_info->filename,argv[argc-1],MaxTextExtent); |
| 1756 | montage_image=MontageImageList(image_info,montage_info,image,exception); |
| 1757 | if (montage_image == (Image *) NULL) |
| 1758 | status=MagickFalse; |
| 1759 | else |
| 1760 | { |
| 1761 | /* |
| 1762 | Write image. |
| 1763 | */ |
| 1764 | GetImageException(montage_image,exception); |
| 1765 | (void) CopyMagickString(image_info->filename,argv[argc-1],MaxTextExtent); |
| 1766 | (void) CopyMagickString(montage_image->magick_filename,argv[argc-1], |
| 1767 | MaxTextExtent); |
| 1768 | if (*montage_image->magick == '\0') |
| 1769 | (void) CopyMagickString(montage_image->magick,image->magick, |
| 1770 | MaxTextExtent); |
| 1771 | status&=WriteImages(image_info,montage_image,argv[argc-1],exception); |
| 1772 | if (metadata != (char **) NULL) |
| 1773 | { |
| 1774 | char |
| 1775 | *text; |
| 1776 | |
| 1777 | text=InterpretImageProperties(image_info,montage_image,format); |
| 1778 | if (text == (char *) NULL) |
| 1779 | ThrowMontageException(ResourceLimitError,"MemoryAllocationFailed", |
| 1780 | GetExceptionMessage(errno)); |
| 1781 | (void) ConcatenateString(&(*metadata),text); |
| 1782 | (void) ConcatenateString(&(*metadata),"\n"); |
| 1783 | text=DestroyString(text); |
| 1784 | } |
| 1785 | } |
| 1786 | montage_info=DestroyMontageInfo(montage_info); |
| 1787 | DestroyMontage(); |
| 1788 | return(status != 0 ? MagickTrue : MagickFalse); |
| 1789 | } |