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