|
MagickWand
6.7.5
|
00001 /* 00002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00003 % % 00004 % % 00005 % % 00006 % M M OOO GGGGG RRRR IIIII FFFFF Y Y % 00007 % MM MM O O G R R I F Y Y % 00008 % M M M O O G GGG RRRR I FFF Y % 00009 % M M O O G G R R I F Y % 00010 % M M OOO GGGG R R IIIII F Y % 00011 % % 00012 % % 00013 % MagickWand Module Methods % 00014 % % 00015 % Software Design % 00016 % John Cristy % 00017 % March 2000 % 00018 % % 00019 % % 00020 % Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization % 00021 % dedicated to making software imaging solutions freely available. % 00022 % % 00023 % You may not use this file except in compliance with the License. You may % 00024 % obtain a copy of the License at % 00025 % % 00026 % http://www.imagemagick.org/script/license.php % 00027 % % 00028 % Unless required by applicable law or agreed to in writing, software % 00029 % distributed under the License is distributed on an "AS IS" BASIS, % 00030 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % 00031 % See the License for the specific language governing permissions and % 00032 % limitations under the License. % 00033 % % 00034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00035 % 00036 % Use the mogrify program to resize an image, blur, crop, despeckle, dither, 00037 % draw on, flip, join, re-sample, and much more. This tool is similiar to 00038 % convert except that the original image file is overwritten (unless you 00039 % change the file suffix with the -format option) with any changes you 00040 % request. 00041 % 00042 */ 00043 00044 /* 00045 Include declarations. 00046 */ 00047 #include "MagickWand/studio.h" 00048 #include "MagickWand/MagickWand.h" 00049 #include "MagickWand/mogrify-private.h" 00050 #undef DegreesToRadians 00051 #undef RadiansToDegrees 00052 #include "MagickCore/image-private.h" 00053 #include "MagickCore/monitor-private.h" 00054 #include "MagickCore/string-private.h" 00055 #include "MagickCore/thread-private.h" 00056 #include "MagickCore/utility-private.h" 00057 00058 /* 00059 Constant declaration. 00060 */ 00061 static const char 00062 MogrifyBackgroundColor[] = "#ffffff", /* white */ 00063 MogrifyBorderColor[] = "#dfdfdf", /* gray */ 00064 MogrifyMatteColor[] = "#bdbdbd"; /* gray */ 00065 00066 /* 00067 Define declarations. 00068 */ 00069 #define UndefinedCompressionQuality 0UL 00070 00071 /* 00072 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00073 % % 00074 % % 00075 % % 00076 % M a g i c k C o m m a n d G e n e s i s % 00077 % % 00078 % % 00079 % % 00080 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00081 % 00082 % MagickCommandGenesis() applies image processing options to an image as 00083 % prescribed by command line options. 00084 % 00085 % The format of the MagickCommandGenesis method is: 00086 % 00087 % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, 00088 % MagickCommand command,int argc,char **argv,char **metadata, 00089 % ExceptionInfo *exception) 00090 % 00091 % A description of each parameter follows: 00092 % 00093 % o image_info: the image info. 00094 % 00095 % o command: Choose from ConvertImageCommand, IdentifyImageCommand, 00096 % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand, 00097 % ConjureImageCommand, StreamImageCommand, ImportImageCommand, 00098 % DisplayImageCommand, or AnimateImageCommand. 00099 % 00100 % o argc: Specifies a pointer to an integer describing the number of 00101 % elements in the argument vector. 00102 % 00103 % o argv: Specifies a pointer to a text array containing the command line 00104 % arguments. 00105 % 00106 % o metadata: any metadata is returned here. 00107 % 00108 % o exception: return any errors or warnings in this structure. 00109 % 00110 */ 00111 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, 00112 MagickCommand command,int argc,char **argv,char **metadata, 00113 ExceptionInfo *exception) 00114 { 00115 char 00116 *option; 00117 00118 double 00119 duration, 00120 serial; 00121 00122 MagickBooleanType 00123 concurrent, 00124 regard_warnings, 00125 status; 00126 00127 register ssize_t 00128 i; 00129 00130 size_t 00131 iterations, 00132 number_threads; 00133 00134 ssize_t 00135 n; 00136 00137 (void) setlocale(LC_ALL,""); 00138 (void) setlocale(LC_NUMERIC,"C"); 00139 concurrent=MagickFalse; 00140 duration=(-1.0); 00141 iterations=1; 00142 status=MagickFalse; 00143 regard_warnings=MagickFalse; 00144 for (i=1; i < (ssize_t) (argc-1); i++) 00145 { 00146 option=argv[i]; 00147 if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) 00148 continue; 00149 if (LocaleCompare("bench",option+1) == 0) 00150 iterations=StringToUnsignedLong(argv[++i]); 00151 if (LocaleCompare("concurrent",option+1) == 0) 00152 concurrent=MagickTrue; 00153 if (LocaleCompare("debug",option+1) == 0) 00154 (void) SetLogEventMask(argv[++i]); 00155 if (LocaleCompare("duration",option+1) == 0) 00156 duration=StringToDouble(argv[++i],(char **) NULL); 00157 if (LocaleCompare("regard-warnings",option+1) == 0) 00158 regard_warnings=MagickTrue; 00159 } 00160 if (iterations == 1) 00161 { 00162 status=command(image_info,argc,argv,metadata,exception); 00163 if (exception->severity != UndefinedException) 00164 { 00165 if ((exception->severity > ErrorException) || 00166 (regard_warnings != MagickFalse)) 00167 status=MagickTrue; 00168 CatchException(exception); 00169 } 00170 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) 00171 { 00172 (void) fputs(*metadata,stdout); 00173 (void) fputc('\n',stdout); 00174 *metadata=DestroyString(*metadata); 00175 } 00176 return(status); 00177 } 00178 number_threads=GetOpenMPMaximumThreads(); 00179 serial=0.0; 00180 for (n=1; n <= (ssize_t) number_threads; n++) 00181 { 00182 double 00183 e, 00184 parallel, 00185 user_time; 00186 00187 TimerInfo 00188 *timer; 00189 00190 SetOpenMPMaximumThreads((int) n); 00191 timer=AcquireTimerInfo(); 00192 if (concurrent == MagickFalse) 00193 { 00194 for (i=0; i < (ssize_t) iterations; i++) 00195 { 00196 if (status != MagickFalse) 00197 continue; 00198 if (duration > 0) 00199 { 00200 if (GetElapsedTime(timer) > duration) 00201 continue; 00202 (void) ContinueTimer(timer); 00203 } 00204 status=command(image_info,argc,argv,metadata,exception); 00205 if (exception->severity != UndefinedException) 00206 { 00207 if ((exception->severity > ErrorException) || 00208 (regard_warnings != MagickFalse)) 00209 status=MagickTrue; 00210 CatchException(exception); 00211 } 00212 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) 00213 { 00214 (void) fputs(*metadata,stdout); 00215 (void) fputc('\n',stdout); 00216 *metadata=DestroyString(*metadata); 00217 } 00218 } 00219 } 00220 else 00221 { 00222 SetOpenMPNested(1); 00223 #if defined(MAGICKCORE_OPENMP_SUPPORT) 00224 # pragma omp parallel for shared(status) 00225 #endif 00226 for (i=0; i < (ssize_t) iterations; i++) 00227 { 00228 if (status != MagickFalse) 00229 continue; 00230 if (duration > 0) 00231 { 00232 if (GetElapsedTime(timer) > duration) 00233 continue; 00234 (void) ContinueTimer(timer); 00235 } 00236 status=command(image_info,argc,argv,metadata,exception); 00237 #if defined(MAGICKCORE_OPENMP_SUPPORT) 00238 # pragma omp critical (MagickCore_CommandGenesis) 00239 #endif 00240 { 00241 if (exception->severity != UndefinedException) 00242 { 00243 if ((exception->severity > ErrorException) || 00244 (regard_warnings != MagickFalse)) 00245 status=MagickTrue; 00246 CatchException(exception); 00247 } 00248 if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) 00249 { 00250 (void) fputs(*metadata,stdout); 00251 (void) fputc('\n',stdout); 00252 *metadata=DestroyString(*metadata); 00253 } 00254 } 00255 } 00256 } 00257 user_time=GetUserTime(timer); 00258 parallel=GetElapsedTime(timer); 00259 e=1.0; 00260 if (n == 1) 00261 serial=parallel; 00262 else 00263 e=((1.0/(1.0/((serial/(serial+parallel))+(1.0-(serial/(serial+parallel)))/ 00264 (double) n)))-(1.0/(double) n))/(1.0-1.0/(double) n); 00265 (void) FormatLocaleFile(stderr, 00266 "Performance[%.20g]: %.20gi %0.3fips %0.3fe %0.3fu %lu:%02lu.%03lu\n", 00267 (double) n,(double) iterations,(double) iterations/parallel,e, 00268 user_time,(unsigned long) (parallel/60.0),(unsigned long) 00269 floor(fmod(parallel,60.0)),(unsigned long) 00270 (1000.0*(parallel-floor(parallel))+0.5)); 00271 timer=DestroyTimerInfo(timer); 00272 } 00273 return(status); 00274 } 00275 00276 /* 00277 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00278 % % 00279 % % 00280 % % 00281 + M o g r i f y I m a g e % 00282 % % 00283 % % 00284 % % 00285 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00286 % 00287 % MogrifyImage() applies simple single image processing options to a single 00288 % image that may be part of a large list, but also handles any 'region' 00289 % image handling. 00290 % 00291 % The image in the list may be modified in three different ways... 00292 % 00293 % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), 00294 % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) 00295 % * replace by a list of images (only the -separate option!) 00296 % 00297 % In each case the result is returned into the list, and a pointer to the 00298 % modified image (last image added if replaced by a list of images) is 00299 % returned. 00300 % 00301 % ASIDE: The -crop is present but restricted to non-tile single image crops 00302 % 00303 % This means if all the images are being processed (such as by 00304 % MogrifyImages(), next image to be processed will be as per the pointer 00305 % (*image)->next. Also the image list may grow as a result of some specific 00306 % operations but as images are never merged or deleted, it will never shrink 00307 % in length. Typically the list will remain the same length. 00308 % 00309 % WARNING: As the image pointed to may be replaced, the first image in the 00310 % list may also change. GetFirstImageInList() should be used by caller if 00311 % they wish return the Image pointer to the first image in list. 00312 % 00313 % 00314 % The format of the MogrifyImage method is: 00315 % 00316 % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, 00317 % const char **argv,Image **image) 00318 % 00319 % A description of each parameter follows: 00320 % 00321 % o image_info: the image info.. 00322 % 00323 % o argc: Specifies a pointer to an integer describing the number of 00324 % elements in the argument vector. 00325 % 00326 % o argv: Specifies a pointer to a text array containing the command line 00327 % arguments. 00328 % 00329 % o image: the image. 00330 % 00331 % o exception: return any errors or warnings in this structure. 00332 % 00333 */ 00334 00335 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, 00336 ExceptionInfo *exception) 00337 { 00338 char 00339 key[MaxTextExtent]; 00340 00341 ExceptionInfo 00342 *sans_exception; 00343 00344 Image 00345 *image; 00346 00347 ImageInfo 00348 *read_info; 00349 00350 /* 00351 Read an image into a image cache if not already present. Return the image 00352 that is in the cache under that filename. 00353 */ 00354 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); 00355 sans_exception=AcquireExceptionInfo(); 00356 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); 00357 sans_exception=DestroyExceptionInfo(sans_exception); 00358 if (image != (Image *) NULL) 00359 return(image); 00360 read_info=CloneImageInfo(image_info); 00361 (void) CopyMagickString(read_info->filename,path,MaxTextExtent); 00362 image=ReadImage(read_info,exception); 00363 read_info=DestroyImageInfo(read_info); 00364 if (image != (Image *) NULL) 00365 (void) SetImageRegistry(ImageRegistryType,key,image,exception); 00366 return(image); 00367 } 00368 00369 static MagickBooleanType IsPathWritable(const char *path) 00370 { 00371 if (IsPathAccessible(path) == MagickFalse) 00372 return(MagickFalse); 00373 if (access_utf8(path,W_OK) != 0) 00374 return(MagickFalse); 00375 return(MagickTrue); 00376 } 00377 00378 static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) 00379 { 00380 if (x > y) 00381 return(x); 00382 return(y); 00383 } 00384 00385 static MagickBooleanType MonitorProgress(const char *text, 00386 const MagickOffsetType offset,const MagickSizeType extent, 00387 void *wand_unused(client_data)) 00388 { 00389 char 00390 message[MaxTextExtent], 00391 tag[MaxTextExtent]; 00392 00393 const char 00394 *locale_message; 00395 00396 register char 00397 *p; 00398 00399 if (extent < 2) 00400 return(MagickTrue); 00401 (void) CopyMagickMemory(tag,text,MaxTextExtent); 00402 p=strrchr(tag,'/'); 00403 if (p != (char *) NULL) 00404 *p='\0'; 00405 (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); 00406 locale_message=GetLocaleMessage(message); 00407 if (locale_message == message) 00408 locale_message=tag; 00409 if (p == (char *) NULL) 00410 (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", 00411 locale_message,(long) offset,(unsigned long) extent,(long) 00412 (100L*offset/(extent-1))); 00413 else 00414 (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", 00415 locale_message,p+1,(long) offset,(unsigned long) extent,(long) 00416 (100L*offset/(extent-1))); 00417 if (offset == (MagickOffsetType) (extent-1)) 00418 (void) FormatLocaleFile(stderr,"\n"); 00419 (void) fflush(stderr); 00420 return(MagickTrue); 00421 } 00422 00423 static Image *SparseColorOption(const Image *image, 00424 const SparseColorMethod method,const char *arguments, 00425 const MagickBooleanType color_from_image,ExceptionInfo *exception) 00426 { 00427 char 00428 token[MaxTextExtent]; 00429 00430 const char 00431 *p; 00432 00433 double 00434 *sparse_arguments; 00435 00436 Image 00437 *sparse_image; 00438 00439 PixelInfo 00440 color; 00441 00442 MagickBooleanType 00443 error; 00444 00445 register size_t 00446 x; 00447 00448 size_t 00449 number_arguments, 00450 number_colors; 00451 00452 /* 00453 SparseColorOption() parses the complex -sparse-color argument into an an 00454 array of floating point values then calls SparseColorImage(). Argument is 00455 a complex mix of floating-point pixel coodinates, and color specifications 00456 (or direct floating point numbers). The number of floats needed to 00457 represent a color varies depending on the current channel setting. 00458 */ 00459 assert(image != (Image *) NULL); 00460 assert(image->signature == MagickSignature); 00461 if (image->debug != MagickFalse) 00462 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 00463 assert(exception != (ExceptionInfo *) NULL); 00464 assert(exception->signature == MagickSignature); 00465 /* 00466 Limit channels according to image - and add up number of color channel. 00467 */ 00468 number_colors=0; 00469 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) 00470 number_colors++; 00471 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) 00472 number_colors++; 00473 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) 00474 number_colors++; 00475 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && 00476 (image->colorspace == CMYKColorspace)) 00477 number_colors++; 00478 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && 00479 (image->matte != MagickFalse)) 00480 number_colors++; 00481 00482 /* 00483 Read string, to determine number of arguments needed, 00484 */ 00485 p=arguments; 00486 x=0; 00487 while( *p != '\0' ) 00488 { 00489 GetMagickToken(p,&p,token); 00490 if ( token[0] == ',' ) continue; 00491 if ( isalpha((int) token[0]) || token[0] == '#' ) { 00492 if ( color_from_image ) { 00493 (void) ThrowMagickException(exception,GetMagickModule(), 00494 OptionError, "InvalidArgument", "`%s': %s", "sparse-color", 00495 "Color arg given, when colors are coming from image"); 00496 return( (Image *)NULL); 00497 } 00498 x += number_colors; /* color argument */ 00499 } 00500 else { 00501 x++; /* floating point argument */ 00502 } 00503 } 00504 error=MagickTrue; 00505 if ( color_from_image ) { 00506 /* just the control points are being given */ 00507 error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; 00508 number_arguments=(x/2)*(2+number_colors); 00509 } 00510 else { 00511 /* control points and color values */ 00512 error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; 00513 number_arguments=x; 00514 } 00515 if ( error ) { 00516 (void) ThrowMagickException(exception,GetMagickModule(), 00517 OptionError, "InvalidArgument", "`%s': %s", "sparse-color", 00518 "Invalid number of Arguments"); 00519 return( (Image *)NULL); 00520 } 00521 00522 /* Allocate and fill in the floating point arguments */ 00523 sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, 00524 sizeof(*sparse_arguments)); 00525 if (sparse_arguments == (double *) NULL) { 00526 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, 00527 "MemoryAllocationFailed","%s","SparseColorOption"); 00528 return( (Image *)NULL); 00529 } 00530 (void) ResetMagickMemory(sparse_arguments,0,number_arguments* 00531 sizeof(*sparse_arguments)); 00532 p=arguments; 00533 x=0; 00534 while( *p != '\0' && x < number_arguments ) { 00535 /* X coordinate */ 00536 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); 00537 if ( token[0] == '\0' ) break; 00538 if ( isalpha((int) token[0]) || token[0] == '#' ) { 00539 (void) ThrowMagickException(exception,GetMagickModule(), 00540 OptionError, "InvalidArgument", "`%s': %s", "sparse-color", 00541 "Color found, instead of X-coord"); 00542 error = MagickTrue; 00543 break; 00544 } 00545 sparse_arguments[x++]=StringToDouble(token,(char **) NULL); 00546 /* Y coordinate */ 00547 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); 00548 if ( token[0] == '\0' ) break; 00549 if ( isalpha((int) token[0]) || token[0] == '#' ) { 00550 (void) ThrowMagickException(exception,GetMagickModule(), 00551 OptionError, "InvalidArgument", "`%s': %s", "sparse-color", 00552 "Color found, instead of Y-coord"); 00553 error = MagickTrue; 00554 break; 00555 } 00556 sparse_arguments[x++]=StringToDouble(token,(char **) NULL); 00557 /* color values for this control point */ 00558 #if 0 00559 if ( (color_from_image ) { 00560 /* get color from image */ 00561 /* HOW??? */ 00562 } 00563 else 00564 #endif 00565 { 00566 /* color name or function given in string argument */ 00567 token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); 00568 if ( token[0] == '\0' ) break; 00569 if ( isalpha((int) token[0]) || token[0] == '#' ) { 00570 /* Color string given */ 00571 (void) QueryColorCompliance(token,AllCompliance,&color,exception); 00572 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) 00573 sparse_arguments[x++] = QuantumScale*color.red; 00574 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) 00575 sparse_arguments[x++] = QuantumScale*color.green; 00576 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) 00577 sparse_arguments[x++] = QuantumScale*color.blue; 00578 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && 00579 (image->colorspace == CMYKColorspace)) 00580 sparse_arguments[x++] = QuantumScale*color.black; 00581 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && 00582 (image->matte != MagickFalse)) 00583 sparse_arguments[x++] = QuantumScale*color.alpha; 00584 } 00585 else { 00586 /* Colors given as a set of floating point values - experimental */ 00587 /* NB: token contains the first floating point value to use! */ 00588 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) 00589 { 00590 while ( token[0] == ',' ) GetMagickToken(p,&p,token); 00591 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) 00592 break; 00593 sparse_arguments[x++]=StringToDouble(token,(char **) NULL); 00594 token[0] = ','; /* used this token - get another */ 00595 } 00596 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) 00597 { 00598 while ( token[0] == ',' ) GetMagickToken(p,&p,token); 00599 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) 00600 break; 00601 sparse_arguments[x++]=StringToDouble(token,(char **) NULL); 00602 token[0] = ','; /* used this token - get another */ 00603 } 00604 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) 00605 { 00606 while ( token[0] == ',' ) GetMagickToken(p,&p,token); 00607 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) 00608 break; 00609 sparse_arguments[x++]=StringToDouble(token,(char **) NULL); 00610 token[0] = ','; /* used this token - get another */ 00611 } 00612 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && 00613 (image->colorspace == CMYKColorspace)) 00614 { 00615 while ( token[0] == ',' ) GetMagickToken(p,&p,token); 00616 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) 00617 break; 00618 sparse_arguments[x++]=StringToDouble(token,(char **) NULL); 00619 token[0] = ','; /* used this token - get another */ 00620 } 00621 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && 00622 (image->matte != MagickFalse)) 00623 { 00624 while ( token[0] == ',' ) GetMagickToken(p,&p,token); 00625 if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) 00626 break; 00627 sparse_arguments[x++]=StringToDouble(token,(char **) NULL); 00628 token[0] = ','; /* used this token - get another */ 00629 } 00630 } 00631 } 00632 } 00633 if ( number_arguments != x && !error ) { 00634 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, 00635 "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error"); 00636 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); 00637 return( (Image *)NULL); 00638 } 00639 if ( error ) 00640 return( (Image *)NULL); 00641 00642 /* Call the Interpolation function with the parsed arguments */ 00643 sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, 00644 exception); 00645 sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); 00646 return( sparse_image ); 00647 } 00648 00649 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, 00650 const char **argv,Image **image,ExceptionInfo *exception) 00651 { 00652 CompositeOperator 00653 compose; 00654 00655 const char 00656 *format, 00657 *option; 00658 00659 double 00660 attenuate; 00661 00662 DrawInfo 00663 *draw_info; 00664 00665 GeometryInfo 00666 geometry_info; 00667 00668 Image 00669 *region_image; 00670 00671 ImageInfo 00672 *mogrify_info; 00673 00674 MagickStatusType 00675 status; 00676 00677 PixelInfo 00678 fill; 00679 00680 MagickStatusType 00681 flags; 00682 00683 PixelInterpolateMethod 00684 interpolate_method; 00685 00686 QuantizeInfo 00687 *quantize_info; 00688 00689 RectangleInfo 00690 geometry, 00691 region_geometry; 00692 00693 register ssize_t 00694 i; 00695 00696 /* 00697 Initialize method variables. 00698 */ 00699 assert(image_info != (const ImageInfo *) NULL); 00700 assert(image_info->signature == MagickSignature); 00701 assert(image != (Image **) NULL); 00702 assert((*image)->signature == MagickSignature); 00703 if ((*image)->debug != MagickFalse) 00704 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); 00705 if (argc < 0) 00706 return(MagickTrue); 00707 mogrify_info=CloneImageInfo(image_info); 00708 draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL); 00709 quantize_info=AcquireQuantizeInfo(mogrify_info); 00710 SetGeometryInfo(&geometry_info); 00711 GetPixelInfo(*image,&fill); 00712 fill=(*image)->background_color; 00713 attenuate=1.0; 00714 compose=(*image)->compose; 00715 interpolate_method=UndefinedInterpolatePixel; 00716 format=GetImageOption(mogrify_info,"format"); 00717 SetGeometry(*image,®ion_geometry); 00718 region_image=NewImageList(); 00719 /* 00720 Transmogrify the image. 00721 */ 00722 for (i=0; i < (ssize_t) argc; i++) 00723 { 00724 Image 00725 *mogrify_image; 00726 00727 ssize_t 00728 count; 00729 00730 option=argv[i]; 00731 if (IsCommandOption(option) == MagickFalse) 00732 continue; 00733 count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option), 00734 0L); 00735 if ((i+count) >= (ssize_t) argc) 00736 break; 00737 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); 00738 mogrify_image=(Image *)NULL; 00739 switch (*(option+1)) 00740 { 00741 case 'a': 00742 { 00743 if (LocaleCompare("adaptive-blur",option+1) == 0) 00744 { 00745 /* 00746 Adaptive blur image. 00747 */ 00748 (void) SyncImageSettings(mogrify_info,*image,exception); 00749 flags=ParseGeometry(argv[i+1],&geometry_info); 00750 if ((flags & SigmaValue) == 0) 00751 geometry_info.sigma=1.0; 00752 if ((flags & XiValue) == 0) 00753 geometry_info.xi=0.0; 00754 mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho, 00755 geometry_info.sigma,geometry_info.xi,exception); 00756 break; 00757 } 00758 if (LocaleCompare("adaptive-resize",option+1) == 0) 00759 { 00760 /* 00761 Adaptive resize image. 00762 */ 00763 (void) SyncImageSettings(mogrify_info,*image,exception); 00764 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); 00765 mogrify_image=AdaptiveResizeImage(*image,geometry.width, 00766 geometry.height,exception); 00767 break; 00768 } 00769 if (LocaleCompare("adaptive-sharpen",option+1) == 0) 00770 { 00771 /* 00772 Adaptive sharpen image. 00773 */ 00774 (void) SyncImageSettings(mogrify_info,*image,exception); 00775 flags=ParseGeometry(argv[i+1],&geometry_info); 00776 if ((flags & SigmaValue) == 0) 00777 geometry_info.sigma=1.0; 00778 if ((flags & XiValue) == 0) 00779 geometry_info.xi=0.0; 00780 mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho, 00781 geometry_info.sigma,geometry_info.xi,exception); 00782 break; 00783 } 00784 if (LocaleCompare("affine",option+1) == 0) 00785 { 00786 /* 00787 Affine matrix. 00788 */ 00789 if (*option == '+') 00790 { 00791 GetAffineMatrix(&draw_info->affine); 00792 break; 00793 } 00794 (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); 00795 break; 00796 } 00797 if (LocaleCompare("alpha",option+1) == 0) 00798 { 00799 AlphaChannelType 00800 alpha_type; 00801 00802 (void) SyncImageSettings(mogrify_info,*image,exception); 00803 alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions, 00804 MagickFalse,argv[i+1]); 00805 (void) SetImageAlphaChannel(*image,alpha_type,exception); 00806 break; 00807 } 00808 if (LocaleCompare("annotate",option+1) == 0) 00809 { 00810 char 00811 *text, 00812 geometry[MaxTextExtent]; 00813 00814 /* 00815 Annotate image. 00816 */ 00817 (void) SyncImageSettings(mogrify_info,*image,exception); 00818 SetGeometryInfo(&geometry_info); 00819 flags=ParseGeometry(argv[i+1],&geometry_info); 00820 if ((flags & SigmaValue) == 0) 00821 geometry_info.sigma=geometry_info.rho; 00822 text=InterpretImageProperties(mogrify_info,*image,argv[i+2], 00823 exception); 00824 if (text == (char *) NULL) 00825 break; 00826 (void) CloneString(&draw_info->text,text); 00827 text=DestroyString(text); 00828 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", 00829 geometry_info.xi,geometry_info.psi); 00830 (void) CloneString(&draw_info->geometry,geometry); 00831 draw_info->affine.sx=cos(DegreesToRadians( 00832 fmod(geometry_info.rho,360.0))); 00833 draw_info->affine.rx=sin(DegreesToRadians( 00834 fmod(geometry_info.rho,360.0))); 00835 draw_info->affine.ry=(-sin(DegreesToRadians( 00836 fmod(geometry_info.sigma,360.0)))); 00837 draw_info->affine.sy=cos(DegreesToRadians( 00838 fmod(geometry_info.sigma,360.0))); 00839 (void) AnnotateImage(*image,draw_info,exception); 00840 break; 00841 } 00842 if (LocaleCompare("antialias",option+1) == 0) 00843 { 00844 draw_info->stroke_antialias=(*option == '-') ? MagickTrue : 00845 MagickFalse; 00846 draw_info->text_antialias=(*option == '-') ? MagickTrue : 00847 MagickFalse; 00848 break; 00849 } 00850 if (LocaleCompare("attenuate",option+1) == 0) 00851 { 00852 if (*option == '+') 00853 { 00854 attenuate=1.0; 00855 break; 00856 } 00857 attenuate=StringToDouble(argv[i+1],(char **) NULL); 00858 break; 00859 } 00860 if (LocaleCompare("auto-gamma",option+1) == 0) 00861 { 00862 /* 00863 Auto Adjust Gamma of image based on its mean 00864 */ 00865 (void) SyncImageSettings(mogrify_info,*image,exception); 00866 (void) AutoGammaImage(*image,exception); 00867 break; 00868 } 00869 if (LocaleCompare("auto-level",option+1) == 0) 00870 { 00871 /* 00872 Perfectly Normalize (max/min stretch) the image 00873 */ 00874 (void) SyncImageSettings(mogrify_info,*image,exception); 00875 (void) AutoLevelImage(*image,exception); 00876 break; 00877 } 00878 if (LocaleCompare("auto-orient",option+1) == 0) 00879 { 00880 (void) SyncImageSettings(mogrify_info,*image,exception); 00881 switch ((*image)->orientation) 00882 { 00883 case TopRightOrientation: 00884 { 00885 mogrify_image=FlopImage(*image,exception); 00886 break; 00887 } 00888 case BottomRightOrientation: 00889 { 00890 mogrify_image=RotateImage(*image,180.0,exception); 00891 break; 00892 } 00893 case BottomLeftOrientation: 00894 { 00895 mogrify_image=FlipImage(*image,exception); 00896 break; 00897 } 00898 case LeftTopOrientation: 00899 { 00900 mogrify_image=TransposeImage(*image,exception); 00901 break; 00902 } 00903 case RightTopOrientation: 00904 { 00905 mogrify_image=RotateImage(*image,90.0,exception); 00906 break; 00907 } 00908 case RightBottomOrientation: 00909 { 00910 mogrify_image=TransverseImage(*image,exception); 00911 break; 00912 } 00913 case LeftBottomOrientation: 00914 { 00915 mogrify_image=RotateImage(*image,270.0,exception); 00916 break; 00917 } 00918 default: 00919 break; 00920 } 00921 if (mogrify_image != (Image *) NULL) 00922 mogrify_image->orientation=TopLeftOrientation; 00923 break; 00924 } 00925 break; 00926 } 00927 case 'b': 00928 { 00929 if (LocaleCompare("black-threshold",option+1) == 0) 00930 { 00931 /* 00932 Black threshold image. 00933 */ 00934 (void) SyncImageSettings(mogrify_info,*image,exception); 00935 (void) BlackThresholdImage(*image,argv[i+1],exception); 00936 break; 00937 } 00938 if (LocaleCompare("blue-shift",option+1) == 0) 00939 { 00940 /* 00941 Blue shift image. 00942 */ 00943 (void) SyncImageSettings(mogrify_info,*image,exception); 00944 geometry_info.rho=1.5; 00945 if (*option == '-') 00946 flags=ParseGeometry(argv[i+1],&geometry_info); 00947 mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception); 00948 break; 00949 } 00950 if (LocaleCompare("blur",option+1) == 0) 00951 { 00952 /* 00953 Gaussian blur image. 00954 */ 00955 (void) SyncImageSettings(mogrify_info,*image,exception); 00956 flags=ParseGeometry(argv[i+1],&geometry_info); 00957 if ((flags & SigmaValue) == 0) 00958 geometry_info.sigma=1.0; 00959 if ((flags & XiValue) == 0) 00960 geometry_info.xi=0.0; 00961 mogrify_image=BlurImage(*image,geometry_info.rho, 00962 geometry_info.sigma,geometry_info.xi,exception); 00963 break; 00964 } 00965 if (LocaleCompare("border",option+1) == 0) 00966 { 00967 /* 00968 Surround image with a border of solid color. 00969 */ 00970 (void) SyncImageSettings(mogrify_info,*image,exception); 00971 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); 00972 if ((flags & SigmaValue) == 0) 00973 geometry.height=geometry.width; 00974 mogrify_image=BorderImage(*image,&geometry,compose,exception); 00975 break; 00976 } 00977 if (LocaleCompare("bordercolor",option+1) == 0) 00978 { 00979 if (*option == '+') 00980 { 00981 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, 00982 &draw_info->border_color,exception); 00983 break; 00984 } 00985 (void) QueryColorCompliance(argv[i+1],AllCompliance, 00986 &draw_info->border_color,exception); 00987 break; 00988 } 00989 if (LocaleCompare("box",option+1) == 0) 00990 { 00991 (void) QueryColorCompliance(argv[i+1],AllCompliance, 00992 &draw_info->undercolor,exception); 00993 break; 00994 } 00995 if (LocaleCompare("brightness-contrast",option+1) == 0) 00996 { 00997 double 00998 brightness, 00999 contrast; 01000 01001 GeometryInfo 01002 geometry_info; 01003 01004 MagickStatusType 01005 flags; 01006 01007 /* 01008 Brightness / contrast image. 01009 */ 01010 (void) SyncImageSettings(mogrify_info,*image,exception); 01011 flags=ParseGeometry(argv[i+1],&geometry_info); 01012 brightness=geometry_info.rho; 01013 contrast=0.0; 01014 if ((flags & SigmaValue) != 0) 01015 contrast=geometry_info.sigma; 01016 (void) BrightnessContrastImage(*image,brightness,contrast, 01017 exception); 01018 break; 01019 } 01020 break; 01021 } 01022 case 'c': 01023 { 01024 if (LocaleCompare("cdl",option+1) == 0) 01025 { 01026 char 01027 *color_correction_collection; 01028 01029 /* 01030 Color correct with a color decision list. 01031 */ 01032 (void) SyncImageSettings(mogrify_info,*image,exception); 01033 color_correction_collection=FileToString(argv[i+1],~0,exception); 01034 if (color_correction_collection == (char *) NULL) 01035 break; 01036 (void) ColorDecisionListImage(*image,color_correction_collection, 01037 exception); 01038 break; 01039 } 01040 if (LocaleCompare("charcoal",option+1) == 0) 01041 { 01042 /* 01043 Charcoal image. 01044 */ 01045 (void) SyncImageSettings(mogrify_info,*image,exception); 01046 flags=ParseGeometry(argv[i+1],&geometry_info); 01047 if ((flags & SigmaValue) == 0) 01048 geometry_info.sigma=1.0; 01049 if ((flags & XiValue) == 0) 01050 geometry_info.xi=1.0; 01051 mogrify_image=CharcoalImage(*image,geometry_info.rho, 01052 geometry_info.sigma,geometry_info.xi,exception); 01053 break; 01054 } 01055 if (LocaleCompare("chop",option+1) == 0) 01056 { 01057 /* 01058 Chop the image. 01059 */ 01060 (void) SyncImageSettings(mogrify_info,*image,exception); 01061 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); 01062 mogrify_image=ChopImage(*image,&geometry,exception); 01063 break; 01064 } 01065 if (LocaleCompare("clamp",option+1) == 0) 01066 { 01067 /* 01068 Clamp image. 01069 */ 01070 (void) SyncImageSettings(mogrify_info,*image,exception); 01071 (void) ClampImage(*image,exception); 01072 break; 01073 } 01074 if (LocaleCompare("clip",option+1) == 0) 01075 { 01076 (void) SyncImageSettings(mogrify_info,*image,exception); 01077 if (*option == '+') 01078 { 01079 (void) SetImageMask(*image,(Image *) NULL,exception); 01080 break; 01081 } 01082 (void) ClipImage(*image,exception); 01083 break; 01084 } 01085 if (LocaleCompare("clip-mask",option+1) == 0) 01086 { 01087 CacheView 01088 *mask_view; 01089 01090 Image 01091 *mask_image; 01092 01093 register Quantum 01094 *restrict q; 01095 01096 register ssize_t 01097 x; 01098 01099 ssize_t 01100 y; 01101 01102 (void) SyncImageSettings(mogrify_info,*image,exception); 01103 if (*option == '+') 01104 { 01105 /* 01106 Remove a mask. 01107 */ 01108 (void) SetImageMask(*image,(Image *) NULL,exception); 01109 break; 01110 } 01111 /* 01112 Set the image mask. 01113 FUTURE: This Should Be a SetImageAlphaChannel() call, Or two. 01114 */ 01115 mask_image=GetImageCache(mogrify_info,argv[i+1],exception); 01116 if (mask_image == (Image *) NULL) 01117 break; 01118 if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse) 01119 return(MagickFalse); 01120 mask_view=AcquireCacheView(mask_image); 01121 for (y=0; y < (ssize_t) mask_image->rows; y++) 01122 { 01123 q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, 01124 exception); 01125 if (q == (Quantum *) NULL) 01126 break; 01127 for (x=0; x < (ssize_t) mask_image->columns; x++) 01128 { 01129 if (mask_image->matte == MagickFalse) 01130 SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); 01131 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); 01132 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); 01133 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); 01134 q+=GetPixelChannels(mask_image); 01135 } 01136 if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) 01137 break; 01138 } 01139 mask_view=DestroyCacheView(mask_view); 01140 mask_image->matte=MagickTrue; 01141 (void) SetImageMask(*image,mask_image,exception); 01142 break; 01143 } 01144 if (LocaleCompare("clip-path",option+1) == 0) 01145 { 01146 (void) SyncImageSettings(mogrify_info,*image,exception); 01147 (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : 01148 MagickFalse,exception); 01149 break; 01150 } 01151 if (LocaleCompare("colorize",option+1) == 0) 01152 { 01153 /* 01154 Colorize the image. 01155 */ 01156 (void) SyncImageSettings(mogrify_info,*image,exception); 01157 mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception); 01158 break; 01159 } 01160 if (LocaleCompare("color-matrix",option+1) == 0) 01161 { 01162 KernelInfo 01163 *kernel; 01164 01165 (void) SyncImageSettings(mogrify_info,*image,exception); 01166 kernel=AcquireKernelInfo(argv[i+1]); 01167 if (kernel == (KernelInfo *) NULL) 01168 break; 01169 /* FUTURE: check on size of the matrix */ 01170 mogrify_image=ColorMatrixImage(*image,kernel,exception); 01171 kernel=DestroyKernelInfo(kernel); 01172 break; 01173 } 01174 if (LocaleCompare("colors",option+1) == 0) 01175 { 01176 /* 01177 Reduce the number of colors in the image. 01178 */ 01179 (void) SyncImageSettings(mogrify_info,*image,exception); 01180 quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); 01181 if (quantize_info->number_colors == 0) 01182 break; 01183 if (((*image)->storage_class == DirectClass) || 01184 (*image)->colors > quantize_info->number_colors) 01185 (void) QuantizeImage(quantize_info,*image,exception); 01186 else 01187 (void) CompressImageColormap(*image,exception); 01188 break; 01189 } 01190 if (LocaleCompare("colorspace",option+1) == 0) 01191 { 01192 ColorspaceType 01193 colorspace; 01194 01195 (void) SyncImageSettings(mogrify_info,*image,exception); 01196 if (*option == '+') 01197 { 01198 (void) TransformImageColorspace(*image,RGBColorspace,exception); 01199 break; 01200 } 01201 colorspace=(ColorspaceType) ParseCommandOption( 01202 MagickColorspaceOptions,MagickFalse,argv[i+1]); 01203 (void) TransformImageColorspace(*image,colorspace,exception); 01204 break; 01205 } 01206 if (LocaleCompare("compose",option+1) == 0) 01207 { 01208 (void) SyncImageSettings(mogrify_info,*image,exception); 01209 compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, 01210 MagickFalse,argv[i+1]); 01211 break; 01212 } 01213 if (LocaleCompare("contrast",option+1) == 0) 01214 { 01215 (void) SyncImageSettings(mogrify_info,*image,exception); 01216 (void) ContrastImage(*image,(*option == '-') ? MagickTrue : 01217 MagickFalse,exception); 01218 break; 01219 } 01220 if (LocaleCompare("contrast-stretch",option+1) == 0) 01221 { 01222 double 01223 black_point, 01224 white_point; 01225 01226 MagickStatusType 01227 flags; 01228 01229 /* 01230 Contrast stretch image. 01231 */ 01232 (void) SyncImageSettings(mogrify_info,*image,exception); 01233 flags=ParseGeometry(argv[i+1],&geometry_info); 01234 black_point=geometry_info.rho; 01235 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : 01236 black_point; 01237 if ((flags & PercentValue) != 0) 01238 { 01239 black_point*=(double) (*image)->columns*(*image)->rows/100.0; 01240 white_point*=(double) (*image)->columns*(*image)->rows/100.0; 01241 } 01242 white_point=(MagickRealType) (*image)->columns*(*image)->rows- 01243 white_point; 01244 (void) ContrastStretchImage(*image,black_point,white_point, 01245 exception); 01246 break; 01247 } 01248 if (LocaleCompare("convolve",option+1) == 0) 01249 { 01250 KernelInfo 01251 *kernel_info; 01252 01253 (void) SyncImageSettings(mogrify_info,*image,exception); 01254 kernel_info=AcquireKernelInfo(argv[i+1]); 01255 if (kernel_info == (KernelInfo *) NULL) 01256 break; 01257 kernel_info->bias=(*image)->bias; 01258 mogrify_image=ConvolveImage(*image,kernel_info,exception); 01259 kernel_info=DestroyKernelInfo(kernel_info); 01260 break; 01261 } 01262 if (LocaleCompare("crop",option+1) == 0) 01263 { 01264 /* 01265 Crop a image to a smaller size 01266 */ 01267 (void) SyncImageSettings(mogrify_info,*image,exception); 01268 mogrify_image=CropImageToTiles(*image,argv[i+1],exception); 01269 break; 01270 } 01271 if (LocaleCompare("cycle",option+1) == 0) 01272 { 01273 /* 01274 Cycle an image colormap. 01275 */ 01276 (void) SyncImageSettings(mogrify_info,*image,exception); 01277 (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]), 01278 exception); 01279 break; 01280 } 01281 break; 01282 } 01283 case 'd': 01284 { 01285 if (LocaleCompare("decipher",option+1) == 0) 01286 { 01287 StringInfo 01288 *passkey; 01289 01290 /* 01291 Decipher pixels. 01292 */ 01293 (void) SyncImageSettings(mogrify_info,*image,exception); 01294 passkey=FileToStringInfo(argv[i+1],~0,exception); 01295 if (passkey != (StringInfo *) NULL) 01296 { 01297 (void) PasskeyDecipherImage(*image,passkey,exception); 01298 passkey=DestroyStringInfo(passkey); 01299 } 01300 break; 01301 } 01302 if (LocaleCompare("density",option+1) == 0) 01303 { 01304 /* 01305 Set image density. 01306 */ 01307 (void) CloneString(&draw_info->density,argv[i+1]); 01308 break; 01309 } 01310 if (LocaleCompare("depth",option+1) == 0) 01311 { 01312 (void) SyncImageSettings(mogrify_info,*image,exception); 01313 if (*option == '+') 01314 { 01315 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception); 01316 break; 01317 } 01318 (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]), 01319 exception); 01320 break; 01321 } 01322 if (LocaleCompare("deskew",option+1) == 0) 01323 { 01324 double 01325 threshold; 01326 01327 /* 01328 Straighten the image. 01329 */ 01330 (void) SyncImageSettings(mogrify_info,*image,exception); 01331 if (*option == '+') 01332 threshold=40.0*QuantumRange/100.0; 01333 else 01334 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ 01335 1.0); 01336 mogrify_image=DeskewImage(*image,threshold,exception); 01337 break; 01338 } 01339 if (LocaleCompare("despeckle",option+1) == 0) 01340 { 01341 /* 01342 Reduce the speckles within an image. 01343 */ 01344 (void) SyncImageSettings(mogrify_info,*image,exception); 01345 mogrify_image=DespeckleImage(*image,exception); 01346 break; 01347 } 01348 if (LocaleCompare("display",option+1) == 0) 01349 { 01350 (void) CloneString(&draw_info->server_name,argv[i+1]); 01351 break; 01352 } 01353 if (LocaleCompare("distort",option+1) == 0) 01354 { 01355 char 01356 *args, 01357 token[MaxTextExtent]; 01358 01359 const char 01360 *p; 01361 01362 DistortImageMethod 01363 method; 01364 01365 double 01366 *arguments; 01367 01368 register ssize_t 01369 x; 01370 01371 size_t 01372 number_arguments; 01373 01374 /* 01375 Distort image. 01376 */ 01377 (void) SyncImageSettings(mogrify_info,*image,exception); 01378 method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, 01379 MagickFalse,argv[i+1]); 01380 if (method == ResizeDistortion) 01381 { 01382 double 01383 resize_args[2]; 01384 01385 /* 01386 Special Case - Argument is actually a resize geometry! 01387 Convert that to an appropriate distortion argument array. 01388 */ 01389 (void) ParseRegionGeometry(*image,argv[i+2],&geometry, 01390 exception); 01391 resize_args[0]=(double) geometry.width; 01392 resize_args[1]=(double) geometry.height; 01393 mogrify_image=DistortImage(*image,method,(size_t)2, 01394 resize_args,MagickTrue,exception); 01395 break; 01396 } 01397 args=InterpretImageProperties(mogrify_info,*image,argv[i+2], 01398 exception); 01399 if (args == (char *) NULL) 01400 break; 01401 p=(char *) args; 01402 for (x=0; *p != '\0'; x++) 01403 { 01404 GetMagickToken(p,&p,token); 01405 if (*token == ',') 01406 GetMagickToken(p,&p,token); 01407 } 01408 number_arguments=(size_t) x; 01409 arguments=(double *) AcquireQuantumMemory(number_arguments, 01410 sizeof(*arguments)); 01411 if (arguments == (double *) NULL) 01412 ThrowWandFatalException(ResourceLimitFatalError, 01413 "MemoryAllocationFailed",(*image)->filename); 01414 (void) ResetMagickMemory(arguments,0,number_arguments* 01415 sizeof(*arguments)); 01416 p=(char *) args; 01417 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) 01418 { 01419 GetMagickToken(p,&p,token); 01420 if (*token == ',') 01421 GetMagickToken(p,&p,token); 01422 arguments[x]=StringToDouble(token,(char **) NULL); 01423 } 01424 args=DestroyString(args); 01425 mogrify_image=DistortImage(*image,method,number_arguments,arguments, 01426 (*option == '+') ? MagickTrue : MagickFalse,exception); 01427 arguments=(double *) RelinquishMagickMemory(arguments); 01428 break; 01429 } 01430 if (LocaleCompare("dither",option+1) == 0) 01431 { 01432 if (*option == '+') 01433 { 01434 quantize_info->dither=MagickFalse; 01435 break; 01436 } 01437 quantize_info->dither=MagickTrue; 01438 quantize_info->dither_method=(DitherMethod) ParseCommandOption( 01439 MagickDitherOptions,MagickFalse,argv[i+1]); 01440 if (quantize_info->dither_method == NoDitherMethod) 01441 quantize_info->dither=MagickFalse; 01442 break; 01443 } 01444 if (LocaleCompare("draw",option+1) == 0) 01445 { 01446 /* 01447 Draw image. 01448 */ 01449 (void) SyncImageSettings(mogrify_info,*image,exception); 01450 (void) CloneString(&draw_info->primitive,argv[i+1]); 01451 (void) DrawImage(*image,draw_info,exception); 01452 break; 01453 } 01454 break; 01455 } 01456 case 'e': 01457 { 01458 if (LocaleCompare("edge",option+1) == 0) 01459 { 01460 /* 01461 Enhance edges in the image. 01462 */ 01463 (void) SyncImageSettings(mogrify_info,*image,exception); 01464 flags=ParseGeometry(argv[i+1],&geometry_info); 01465 if ((flags & SigmaValue) == 0) 01466 geometry_info.sigma=1.0; 01467 mogrify_image=EdgeImage(*image,geometry_info.rho, 01468 geometry_info.sigma,exception); 01469 break; 01470 } 01471 if (LocaleCompare("emboss",option+1) == 0) 01472 { 01473 /* 01474 Emboss image. 01475 */ 01476 (void) SyncImageSettings(mogrify_info,*image,exception); 01477 flags=ParseGeometry(argv[i+1],&geometry_info); 01478 if ((flags & SigmaValue) == 0) 01479 geometry_info.sigma=1.0; 01480 mogrify_image=EmbossImage(*image,geometry_info.rho, 01481 geometry_info.sigma,exception); 01482 break; 01483 } 01484 if (LocaleCompare("encipher",option+1) == 0) 01485 { 01486 StringInfo 01487 *passkey; 01488 01489 /* 01490 Encipher pixels. 01491 */ 01492 (void) SyncImageSettings(mogrify_info,*image,exception); 01493 passkey=FileToStringInfo(argv[i+1],~0,exception); 01494 if (passkey != (StringInfo *) NULL) 01495 { 01496 (void) PasskeyEncipherImage(*image,passkey,exception); 01497 passkey=DestroyStringInfo(passkey); 01498 } 01499 break; 01500 } 01501 if (LocaleCompare("encoding",option+1) == 0) 01502 { 01503 (void) CloneString(&draw_info->encoding,argv[i+1]); 01504 break; 01505 } 01506 if (LocaleCompare("enhance",option+1) == 0) 01507 { 01508 /* 01509 Enhance image. 01510 */ 01511 (void) SyncImageSettings(mogrify_info,*image,exception); 01512 mogrify_image=EnhanceImage(*image,exception); 01513 break; 01514 } 01515 if (LocaleCompare("equalize",option+1) == 0) 01516 { 01517 /* 01518 Equalize image. 01519 */ 01520 (void) SyncImageSettings(mogrify_info,*image,exception); 01521 (void) EqualizeImage(*image,exception); 01522 break; 01523 } 01524 if (LocaleCompare("evaluate",option+1) == 0) 01525 { 01526 double 01527 constant; 01528 01529 MagickEvaluateOperator 01530 op; 01531 01532 (void) SyncImageSettings(mogrify_info,*image,exception); 01533 op=(MagickEvaluateOperator) ParseCommandOption( 01534 MagickEvaluateOptions,MagickFalse,argv[i+1]); 01535 constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+ 01536 1.0); 01537 (void) EvaluateImage(*image,op,constant,exception); 01538 break; 01539 } 01540 if (LocaleCompare("extent",option+1) == 0) 01541 { 01542 /* 01543 Set the image extent. 01544 */ 01545 (void) SyncImageSettings(mogrify_info,*image,exception); 01546 flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); 01547 if (geometry.width == 0) 01548 geometry.width=(*image)->columns; 01549 if (geometry.height == 0) 01550 geometry.height=(*image)->rows; 01551 mogrify_image=ExtentImage(*image,&geometry,exception); 01552 break; 01553 } 01554 break; 01555 } 01556 case 'f': 01557 { 01558 if (LocaleCompare("family",option+1) == 0) 01559 { 01560 if (*option == '+') 01561 { 01562 if (draw_info->family != (char *) NULL) 01563 draw_info->family=DestroyString(draw_info->family); 01564 break; 01565 } 01566 (void) CloneString(&draw_info->family,argv[i+1]); 01567 break; 01568 } 01569 if (LocaleCompare("features",option+1) == 0) 01570 { 01571 if (*option == '+') 01572 { 01573 (void) DeleteImageArtifact(*image,"identify:features"); 01574 break; 01575 } 01576 (void) SetImageArtifact(*image,"identify:features",argv[i+1]); 01577 break; 01578 } 01579 if (LocaleCompare("fill",option+1) == 0) 01580 { 01581 ExceptionInfo 01582 *sans; 01583 01584 PixelInfo 01585 color; 01586 01587 GetPixelInfo(*image,&fill); 01588 if (*option == '+') 01589 { 01590 (void) QueryColorCompliance("none",AllCompliance,&fill, 01591 exception); 01592 draw_info->fill=fill; 01593 if (draw_info->fill_pattern != (Image *) NULL) 01594 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); 01595 break; 01596 } 01597 sans=AcquireExceptionInfo(); 01598 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans); 01599 sans=DestroyExceptionInfo(sans); 01600 if (status == MagickFalse) 01601 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], 01602 exception); 01603 else 01604 draw_info->fill=fill=color; 01605 break; 01606 } 01607 if (LocaleCompare("flip",option+1) == 0) 01608 { 01609 /* 01610 Flip image scanlines. 01611 */ 01612 (void) SyncImageSettings(mogrify_info,*image,exception); 01613 mogrify_image=FlipImage(*image,exception); 01614 break; 01615 } 01616 if (LocaleCompare("floodfill",option+1) == 0) 01617 { 01618 PixelInfo 01619 target; 01620 01621 /* 01622 Floodfill image. 01623 */ 01624 (void) SyncImageSettings(mogrify_info,*image,exception); 01625 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); 01626 (void) QueryColorCompliance(argv[i+2],AllCompliance,&target, 01627 exception); 01628 (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x, 01629 geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception); 01630 break; 01631 } 01632 if (LocaleCompare("flop",option+1) == 0) 01633 { 01634 /* 01635 Flop image scanlines. 01636 */ 01637 (void) SyncImageSettings(mogrify_info,*image,exception); 01638 mogrify_image=FlopImage(*image,exception); 01639 break; 01640 } 01641 if (LocaleCompare("font",option+1) == 0) 01642 { 01643 if (*option == '+') 01644 { 01645 if (draw_info->font != (char *) NULL) 01646 draw_info->font=DestroyString(draw_info->font); 01647 break; 01648 } 01649 (void) CloneString(&draw_info->font,argv[i+1]); 01650 break; 01651 } 01652 if (LocaleCompare("format",option+1) == 0) 01653 { 01654 format=argv[i+1]; 01655 break; 01656 } 01657 if (LocaleCompare("frame",option+1) == 0) 01658 { 01659 FrameInfo 01660 frame_info; 01661 01662 /* 01663 Surround image with an ornamental border. 01664 */ 01665 (void) SyncImageSettings(mogrify_info,*image,exception); 01666 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); 01667 frame_info.width=geometry.width; 01668 frame_info.height=geometry.height; 01669 if ((flags & HeightValue) == 0) 01670 frame_info.height=geometry.width; 01671 frame_info.outer_bevel=geometry.x; 01672 frame_info.inner_bevel=geometry.y; 01673 frame_info.x=(ssize_t) frame_info.width; 01674 frame_info.y=(ssize_t) frame_info.height; 01675 frame_info.width=(*image)->columns+2*frame_info.width; 01676 frame_info.height=(*image)->rows+2*frame_info.height; 01677 mogrify_image=FrameImage(*image,&frame_info,compose,exception); 01678 break; 01679 } 01680 if (LocaleCompare("function",option+1) == 0) 01681 { 01682 char 01683 *arguments, 01684 token[MaxTextExtent]; 01685 01686 const char 01687 *p; 01688 01689 double 01690 *parameters; 01691 01692 MagickFunction 01693 function; 01694 01695 register ssize_t 01696 x; 01697 01698 size_t 01699 number_parameters; 01700 01701 /* 01702 Function Modify Image Values 01703 */ 01704 (void) SyncImageSettings(mogrify_info,*image,exception); 01705 function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, 01706 MagickFalse,argv[i+1]); 01707 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], 01708 exception); 01709 if (arguments == (char *) NULL) 01710 break; 01711 p=(char *) arguments; 01712 for (x=0; *p != '\0'; x++) 01713 { 01714 GetMagickToken(p,&p,token); 01715 if (*token == ',') 01716 GetMagickToken(p,&p,token); 01717 } 01718 number_parameters=(size_t) x; 01719 parameters=(double *) AcquireQuantumMemory(number_parameters, 01720 sizeof(*parameters)); 01721 if (parameters == (double *) NULL) 01722 ThrowWandFatalException(ResourceLimitFatalError, 01723 "MemoryAllocationFailed",(*image)->filename); 01724 (void) ResetMagickMemory(parameters,0,number_parameters* 01725 sizeof(*parameters)); 01726 p=(char *) arguments; 01727 for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) 01728 { 01729 GetMagickToken(p,&p,token); 01730 if (*token == ',') 01731 GetMagickToken(p,&p,token); 01732 parameters[x]=StringToDouble(token,(char **) NULL); 01733 } 01734 arguments=DestroyString(arguments); 01735 (void) FunctionImage(*image,function,number_parameters,parameters, 01736 exception); 01737 parameters=(double *) RelinquishMagickMemory(parameters); 01738 break; 01739 } 01740 break; 01741 } 01742 case 'g': 01743 { 01744 if (LocaleCompare("gamma",option+1) == 0) 01745 { 01746 /* 01747 Gamma image. 01748 */ 01749 (void) SyncImageSettings(mogrify_info,*image,exception); 01750 if (*option == '+') 01751 (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL); 01752 else 01753 (void) GammaImage(*image,StringToDouble(argv[i+1], 01754 (char **) NULL),exception); 01755 break; 01756 } 01757 if ((LocaleCompare("gaussian-blur",option+1) == 0) || 01758 (LocaleCompare("gaussian",option+1) == 0)) 01759 { 01760 /* 01761 Gaussian blur image. 01762 */ 01763 (void) SyncImageSettings(mogrify_info,*image,exception); 01764 flags=ParseGeometry(argv[i+1],&geometry_info); 01765 if ((flags & SigmaValue) == 0) 01766 geometry_info.sigma=1.0; 01767 mogrify_image=GaussianBlurImage(*image,geometry_info.rho, 01768 geometry_info.sigma,exception); 01769 break; 01770 } 01771 if (LocaleCompare("geometry",option+1) == 0) 01772 { 01773 /* 01774 Record Image offset, Resize last image. 01775 */ 01776 (void) SyncImageSettings(mogrify_info,*image,exception); 01777 if (*option == '+') 01778 { 01779 if ((*image)->geometry != (char *) NULL) 01780 (*image)->geometry=DestroyString((*image)->geometry); 01781 break; 01782 } 01783 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); 01784 if (((flags & XValue) != 0) || ((flags & YValue) != 0)) 01785 (void) CloneString(&(*image)->geometry,argv[i+1]); 01786 else 01787 mogrify_image=ResizeImage(*image,geometry.width,geometry.height, 01788 (*image)->filter,(*image)->blur,exception); 01789 break; 01790 } 01791 if (LocaleCompare("gravity",option+1) == 0) 01792 { 01793 if (*option == '+') 01794 { 01795 draw_info->gravity=UndefinedGravity; 01796 break; 01797 } 01798 draw_info->gravity=(GravityType) ParseCommandOption( 01799 MagickGravityOptions,MagickFalse,argv[i+1]); 01800 break; 01801 } 01802 break; 01803 } 01804 case 'h': 01805 { 01806 if (LocaleCompare("highlight-color",option+1) == 0) 01807 { 01808 (void) SetImageArtifact(*image,option+1,argv[i+1]); 01809 break; 01810 } 01811 break; 01812 } 01813 case 'i': 01814 { 01815 if (LocaleCompare("identify",option+1) == 0) 01816 { 01817 char 01818 *text; 01819 01820 (void) SyncImageSettings(mogrify_info,*image,exception); 01821 if (format == (char *) NULL) 01822 { 01823 (void) IdentifyImage(*image,stdout,mogrify_info->verbose, 01824 exception); 01825 break; 01826 } 01827 text=InterpretImageProperties(mogrify_info,*image,format, 01828 exception); 01829 if (text == (char *) NULL) 01830 break; 01831 (void) fputs(text,stdout); 01832 (void) fputc('\n',stdout); 01833 text=DestroyString(text); 01834 break; 01835 } 01836 if (LocaleCompare("implode",option+1) == 0) 01837 { 01838 /* 01839 Implode image. 01840 */ 01841 (void) SyncImageSettings(mogrify_info,*image,exception); 01842 (void) ParseGeometry(argv[i+1],&geometry_info); 01843 mogrify_image=ImplodeImage(*image,geometry_info.rho, 01844 interpolate_method,exception); 01845 break; 01846 } 01847 if (LocaleCompare("interline-spacing",option+1) == 0) 01848 { 01849 if (*option == '+') 01850 (void) ParseGeometry("0",&geometry_info); 01851 else 01852 (void) ParseGeometry(argv[i+1],&geometry_info); 01853 draw_info->interline_spacing=geometry_info.rho; 01854 break; 01855 } 01856 if (LocaleCompare("interpolate",option+1) == 0) 01857 { 01858 interpolate_method=(PixelInterpolateMethod) ParseCommandOption( 01859 MagickInterpolateOptions,MagickFalse,argv[i+1]); 01860 break; 01861 } 01862 if (LocaleCompare("interword-spacing",option+1) == 0) 01863 { 01864 if (*option == '+') 01865 (void) ParseGeometry("0",&geometry_info); 01866 else 01867 (void) ParseGeometry(argv[i+1],&geometry_info); 01868 draw_info->interword_spacing=geometry_info.rho; 01869 break; 01870 } 01871 if (LocaleCompare("interpolative-resize",option+1) == 0) 01872 { 01873 /* 01874 Interpolative resize image. 01875 */ 01876 (void) SyncImageSettings(mogrify_info,*image,exception); 01877 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); 01878 mogrify_image=InterpolativeResizeImage(*image,geometry.width, 01879 geometry.height,interpolate_method,exception); 01880 break; 01881 } 01882 break; 01883 } 01884 case 'k': 01885 { 01886 if (LocaleCompare("kerning",option+1) == 0) 01887 { 01888 if (*option == '+') 01889 (void) ParseGeometry("0",&geometry_info); 01890 else 01891 (void) ParseGeometry(argv[i+1],&geometry_info); 01892 draw_info->kerning=geometry_info.rho; 01893 break; 01894 } 01895 break; 01896 } 01897 case 'l': 01898 { 01899 if (LocaleCompare("lat",option+1) == 0) 01900 { 01901 /* 01902 Local adaptive threshold image. 01903 */ 01904 (void) SyncImageSettings(mogrify_info,*image,exception); 01905 flags=ParseGeometry(argv[i+1],&geometry_info); 01906 if ((flags & PercentValue) != 0) 01907 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; 01908 mogrify_image=AdaptiveThresholdImage(*image,(size_t) 01909 geometry_info.rho,(size_t) geometry_info.sigma,(double) 01910 geometry_info.xi,exception); 01911 break; 01912 } 01913 if (LocaleCompare("level",option+1) == 0) 01914 { 01915 MagickRealType 01916 black_point, 01917 gamma, 01918 white_point; 01919 01920 MagickStatusType 01921 flags; 01922 01923 /* 01924 Parse levels. 01925 */ 01926 (void) SyncImageSettings(mogrify_info,*image,exception); 01927 flags=ParseGeometry(argv[i+1],&geometry_info); 01928 black_point=geometry_info.rho; 01929 white_point=(MagickRealType) QuantumRange; 01930 if ((flags & SigmaValue) != 0) 01931 white_point=geometry_info.sigma; 01932 gamma=1.0; 01933 if ((flags & XiValue) != 0) 01934 gamma=geometry_info.xi; 01935 if ((flags & PercentValue) != 0) 01936 { 01937 black_point*=(MagickRealType) (QuantumRange/100.0); 01938 white_point*=(MagickRealType) (QuantumRange/100.0); 01939 } 01940 if ((flags & SigmaValue) == 0) 01941 white_point=(MagickRealType) QuantumRange-black_point; 01942 if ((*option == '+') || ((flags & AspectValue) != 0)) 01943 (void) LevelizeImage(*image,black_point,white_point,gamma, 01944 exception); 01945 else 01946 (void) LevelImage(*image,black_point,white_point,gamma, 01947 exception); 01948 break; 01949 } 01950 if (LocaleCompare("level-colors",option+1) == 0) 01951 { 01952 char 01953 token[MaxTextExtent]; 01954 01955 const char 01956 *p; 01957 01958 PixelInfo 01959 black_point, 01960 white_point; 01961 01962 p=(const char *) argv[i+1]; 01963 GetMagickToken(p,&p,token); /* get black point color */ 01964 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) 01965 (void) QueryColorCompliance(token,AllCompliance, 01966 &black_point,exception); 01967 else 01968 (void) QueryColorCompliance("#000000",AllCompliance, 01969 &black_point,exception); 01970 if (isalpha((int) token[0]) || (token[0] == '#')) 01971 GetMagickToken(p,&p,token); 01972 if (*token == '\0') 01973 white_point=black_point; /* set everything to that color */ 01974 else 01975 { 01976 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) 01977 GetMagickToken(p,&p,token); /* Get white point color. */ 01978 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) 01979 (void) QueryColorCompliance(token,AllCompliance, 01980 &white_point,exception); 01981 else 01982 (void) QueryColorCompliance("#ffffff",AllCompliance, 01983 &white_point,exception); 01984 } 01985 (void) LevelImageColors(*image,&black_point,&white_point, 01986 *option == '+' ? MagickTrue : MagickFalse,exception); 01987 break; 01988 } 01989 if (LocaleCompare("linear-stretch",option+1) == 0) 01990 { 01991 double 01992 black_point, 01993 white_point; 01994 01995 MagickStatusType 01996 flags; 01997 01998 (void) SyncImageSettings(mogrify_info,*image,exception); 01999 flags=ParseGeometry(argv[i+1],&geometry_info); 02000 black_point=geometry_info.rho; 02001 white_point=(MagickRealType) (*image)->columns*(*image)->rows; 02002 if ((flags & SigmaValue) != 0) 02003 white_point=geometry_info.sigma; 02004 if ((flags & PercentValue) != 0) 02005 { 02006 black_point*=(double) (*image)->columns*(*image)->rows/100.0; 02007 white_point*=(double) (*image)->columns*(*image)->rows/100.0; 02008 } 02009 if ((flags & SigmaValue) == 0) 02010 white_point=(MagickRealType) (*image)->columns*(*image)->rows- 02011 black_point; 02012 (void) LinearStretchImage(*image,black_point,white_point,exception); 02013 break; 02014 } 02015 if (LocaleCompare("liquid-rescale",option+1) == 0) 02016 { 02017 /* 02018 Liquid rescale image. 02019 */ 02020 (void) SyncImageSettings(mogrify_info,*image,exception); 02021 flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); 02022 if ((flags & XValue) == 0) 02023 geometry.x=1; 02024 if ((flags & YValue) == 0) 02025 geometry.y=0; 02026 mogrify_image=LiquidRescaleImage(*image,geometry.width, 02027 geometry.height,1.0*geometry.x,1.0*geometry.y,exception); 02028 break; 02029 } 02030 if (LocaleCompare("lowlight-color",option+1) == 0) 02031 { 02032 (void) SetImageArtifact(*image,option+1,argv[i+1]); 02033 break; 02034 } 02035 break; 02036 } 02037 case 'm': 02038 { 02039 if (LocaleCompare("map",option+1) == 0) 02040 { 02041 Image 02042 *remap_image; 02043 02044 /* 02045 Transform image colors to match this set of colors. 02046 */ 02047 (void) SyncImageSettings(mogrify_info,*image,exception); 02048 if (*option == '+') 02049 break; 02050 remap_image=GetImageCache(mogrify_info,argv[i+1],exception); 02051 if (remap_image == (Image *) NULL) 02052 break; 02053 (void) RemapImage(quantize_info,*image,remap_image,exception); 02054 remap_image=DestroyImage(remap_image); 02055 break; 02056 } 02057 if (LocaleCompare("mask",option+1) == 0) 02058 { 02059 Image 02060 *mask; 02061 02062 (void) SyncImageSettings(mogrify_info,*image,exception); 02063 if (*option == '+') 02064 { 02065 /* 02066 Remove a mask. 02067 */ 02068 (void) SetImageMask(*image,(Image *) NULL,exception); 02069 break; 02070 } 02071 /* 02072 Set the image mask. 02073 */ 02074 mask=GetImageCache(mogrify_info,argv[i+1],exception); 02075 if (mask == (Image *) NULL) 02076 break; 02077 (void) SetImageMask(*image,mask,exception); 02078 mask=DestroyImage(mask); 02079 break; 02080 } 02081 if (LocaleCompare("matte",option+1) == 0) 02082 { 02083 (void) SetImageAlphaChannel(*image,(*option == '-') ? 02084 SetAlphaChannel : DeactivateAlphaChannel,exception); 02085 break; 02086 } 02087 if (LocaleCompare("median",option+1) == 0) 02088 { 02089 /* 02090 Median filter image. 02091 */ 02092 (void) SyncImageSettings(mogrify_info,*image,exception); 02093 flags=ParseGeometry(argv[i+1],&geometry_info); 02094 if ((flags & SigmaValue) == 0) 02095 geometry_info.sigma=geometry_info.rho; 02096 mogrify_image=StatisticImage(*image,MedianStatistic,(size_t) 02097 geometry_info.rho,(size_t) geometry_info.sigma,exception); 02098 break; 02099 } 02100 if (LocaleCompare("mode",option+1) == 0) 02101 { 02102 /* 02103 Mode image. 02104 */ 02105 (void) SyncImageSettings(mogrify_info,*image,exception); 02106 flags=ParseGeometry(argv[i+1],&geometry_info); 02107 if ((flags & SigmaValue) == 0) 02108 geometry_info.sigma=geometry_info.rho; 02109 mogrify_image=StatisticImage(*image,ModeStatistic,(size_t) 02110 geometry_info.rho,(size_t) geometry_info.sigma,exception); 02111 break; 02112 } 02113 if (LocaleCompare("modulate",option+1) == 0) 02114 { 02115 (void) SyncImageSettings(mogrify_info,*image,exception); 02116 (void) ModulateImage(*image,argv[i+1],exception); 02117 break; 02118 } 02119 if (LocaleCompare("monitor",option+1) == 0) 02120 { 02121 if (*option == '+') 02122 { 02123 (void) SetImageProgressMonitor(*image, 02124 (MagickProgressMonitor) NULL,(void *) NULL); 02125 break; 02126 } 02127 (void) SetImageProgressMonitor(*image,MonitorProgress, 02128 (void *) NULL); 02129 break; 02130 } 02131 if (LocaleCompare("monochrome",option+1) == 0) 02132 { 02133 (void) SyncImageSettings(mogrify_info,*image,exception); 02134 (void) SetImageType(*image,BilevelType,exception); 02135 break; 02136 } 02137 if (LocaleCompare("morphology",option+1) == 0) 02138 { 02139 char 02140 token[MaxTextExtent]; 02141 02142 const char 02143 *p; 02144 02145 KernelInfo 02146 *kernel; 02147 02148 MorphologyMethod 02149 method; 02150 02151 ssize_t 02152 iterations; 02153 02154 /* 02155 Morphological Image Operation 02156 */ 02157 (void) SyncImageSettings(mogrify_info,*image,exception); 02158 p=argv[i+1]; 02159 GetMagickToken(p,&p,token); 02160 method=(MorphologyMethod) ParseCommandOption( 02161 MagickMorphologyOptions,MagickFalse,token); 02162 iterations=1L; 02163 GetMagickToken(p,&p,token); 02164 if ((*p == ':') || (*p == ',')) 02165 GetMagickToken(p,&p,token); 02166 if ((*p != '\0')) 02167 iterations=(ssize_t) StringToLong(p); 02168 kernel=AcquireKernelInfo(argv[i+2]); 02169 if (kernel == (KernelInfo *) NULL) 02170 { 02171 (void) ThrowMagickException(exception,GetMagickModule(), 02172 OptionError,"UnabletoParseKernel","morphology"); 02173 status=MagickFalse; 02174 break; 02175 } 02176 mogrify_image=MorphologyImage(*image,method,iterations,kernel, 02177 exception); 02178 kernel=DestroyKernelInfo(kernel); 02179 break; 02180 } 02181 if (LocaleCompare("motion-blur",option+1) == 0) 02182 { 02183 /* 02184 Motion blur image. 02185 */ 02186 (void) SyncImageSettings(mogrify_info,*image,exception); 02187 flags=ParseGeometry(argv[i+1],&geometry_info); 02188 if ((flags & SigmaValue) == 0) 02189 geometry_info.sigma=1.0; 02190 mogrify_image=MotionBlurImage(*image,geometry_info.rho, 02191 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); 02192 break; 02193 } 02194 break; 02195 } 02196 case 'n': 02197 { 02198 if (LocaleCompare("negate",option+1) == 0) 02199 { 02200 (void) SyncImageSettings(mogrify_info,*image,exception); 02201 (void) NegateImage(*image,*option == '+' ? MagickTrue : 02202 MagickFalse,exception); 02203 break; 02204 } 02205 if (LocaleCompare("noise",option+1) == 0) 02206 { 02207 (void) SyncImageSettings(mogrify_info,*image,exception); 02208 if (*option == '-') 02209 { 02210 flags=ParseGeometry(argv[i+1],&geometry_info); 02211 if ((flags & SigmaValue) == 0) 02212 geometry_info.sigma=geometry_info.rho; 02213 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t) 02214 geometry_info.rho,(size_t) geometry_info.sigma,exception); 02215 } 02216 else 02217 { 02218 NoiseType 02219 noise; 02220 02221 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, 02222 MagickFalse,argv[i+1]); 02223 mogrify_image=AddNoiseImage(*image,noise,attenuate,exception); 02224 } 02225 break; 02226 } 02227 if (LocaleCompare("normalize",option+1) == 0) 02228 { 02229 (void) SyncImageSettings(mogrify_info,*image,exception); 02230 (void) NormalizeImage(*image,exception); 02231 break; 02232 } 02233 break; 02234 } 02235 case 'o': 02236 { 02237 if (LocaleCompare("opaque",option+1) == 0) 02238 { 02239 PixelInfo 02240 target; 02241 02242 (void) SyncImageSettings(mogrify_info,*image,exception); 02243 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target, 02244 exception); 02245 (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ? 02246 MagickFalse : MagickTrue,exception); 02247 break; 02248 } 02249 if (LocaleCompare("ordered-dither",option+1) == 0) 02250 { 02251 (void) SyncImageSettings(mogrify_info,*image,exception); 02252 (void) OrderedPosterizeImage(*image,argv[i+1],exception); 02253 break; 02254 } 02255 break; 02256 } 02257 case 'p': 02258 { 02259 if (LocaleCompare("paint",option+1) == 0) 02260 { 02261 (void) SyncImageSettings(mogrify_info,*image,exception); 02262 (void) ParseGeometry(argv[i+1],&geometry_info); 02263 mogrify_image=OilPaintImage(*image,geometry_info.rho, 02264 geometry_info.sigma,exception); 02265 break; 02266 } 02267 if (LocaleCompare("pointsize",option+1) == 0) 02268 { 02269 if (*option == '+') 02270 (void) ParseGeometry("12",&geometry_info); 02271 else 02272 (void) ParseGeometry(argv[i+1],&geometry_info); 02273 draw_info->pointsize=geometry_info.rho; 02274 break; 02275 } 02276 if (LocaleCompare("polaroid",option+1) == 0) 02277 { 02278 const char 02279 *caption; 02280 02281 double 02282 angle; 02283 02284 RandomInfo 02285 *random_info; 02286 02287 /* 02288 Simulate a Polaroid picture. 02289 */ 02290 (void) SyncImageSettings(mogrify_info,*image,exception); 02291 random_info=AcquireRandomInfo(); 02292 angle=22.5*(GetPseudoRandomValue(random_info)-0.5); 02293 random_info=DestroyRandomInfo(random_info); 02294 if (*option == '-') 02295 { 02296 SetGeometryInfo(&geometry_info); 02297 flags=ParseGeometry(argv[i+1],&geometry_info); 02298 angle=geometry_info.rho; 02299 } 02300 caption=GetImageProperty(*image,"caption",exception); 02301 mogrify_image=PolaroidImage(*image,draw_info,caption,angle, 02302 interpolate_method,exception); 02303 break; 02304 } 02305 if (LocaleCompare("posterize",option+1) == 0) 02306 { 02307 /* 02308 Posterize image. 02309 */ 02310 (void) SyncImageSettings(mogrify_info,*image,exception); 02311 (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), 02312 quantize_info->dither,exception); 02313 break; 02314 } 02315 if (LocaleCompare("preview",option+1) == 0) 02316 { 02317 PreviewType 02318 preview_type; 02319 02320 /* 02321 Preview image. 02322 */ 02323 (void) SyncImageSettings(mogrify_info,*image,exception); 02324 if (*option == '+') 02325 preview_type=UndefinedPreview; 02326 else 02327 preview_type=(PreviewType) ParseCommandOption( 02328 MagickPreviewOptions,MagickFalse,argv[i+1]); 02329 mogrify_image=PreviewImage(*image,preview_type,exception); 02330 break; 02331 } 02332 if (LocaleCompare("profile",option+1) == 0) 02333 { 02334 const char 02335 *name; 02336 02337 const StringInfo 02338 *profile; 02339 02340 Image 02341 *profile_image; 02342 02343 ImageInfo 02344 *profile_info; 02345 02346 (void) SyncImageSettings(mogrify_info,*image,exception); 02347 if (*option == '+') 02348 { 02349 /* 02350 Remove a profile from the image. 02351 */ 02352 (void) ProfileImage(*image,argv[i+1],(const unsigned char *) 02353 NULL,0,exception); 02354 break; 02355 } 02356 /* 02357 Associate a profile with the image. 02358 */ 02359 profile_info=CloneImageInfo(mogrify_info); 02360 profile=GetImageProfile(*image,"iptc"); 02361 if (profile != (StringInfo *) NULL) 02362 profile_info->profile=(void *) CloneStringInfo(profile); 02363 profile_image=GetImageCache(profile_info,argv[i+1],exception); 02364 profile_info=DestroyImageInfo(profile_info); 02365 if (profile_image == (Image *) NULL) 02366 { 02367 StringInfo 02368 *profile; 02369 02370 profile_info=CloneImageInfo(mogrify_info); 02371 (void) CopyMagickString(profile_info->filename,argv[i+1], 02372 MaxTextExtent); 02373 profile=FileToStringInfo(profile_info->filename,~0UL,exception); 02374 if (profile != (StringInfo *) NULL) 02375 { 02376 (void) ProfileImage(*image,profile_info->magick, 02377 GetStringInfoDatum(profile),(size_t) 02378 GetStringInfoLength(profile),exception); 02379 profile=DestroyStringInfo(profile); 02380 } 02381 profile_info=DestroyImageInfo(profile_info); 02382 break; 02383 } 02384 ResetImageProfileIterator(profile_image); 02385 name=GetNextImageProfile(profile_image); 02386 while (name != (const char *) NULL) 02387 { 02388 profile=GetImageProfile(profile_image,name); 02389 if (profile != (StringInfo *) NULL) 02390 (void) ProfileImage(*image,name,GetStringInfoDatum(profile), 02391 (size_t) GetStringInfoLength(profile),exception); 02392 name=GetNextImageProfile(profile_image); 02393 } 02394 profile_image=DestroyImage(profile_image); 02395 break; 02396 } 02397 break; 02398 } 02399 case 'q': 02400 { 02401 if (LocaleCompare("quantize",option+1) == 0) 02402 { 02403 if (*option == '+') 02404 { 02405 quantize_info->colorspace=UndefinedColorspace; 02406 break; 02407 } 02408 quantize_info->colorspace=(ColorspaceType) ParseCommandOption( 02409 MagickColorspaceOptions,MagickFalse,argv[i+1]); 02410 break; 02411 } 02412 break; 02413 } 02414 case 'r': 02415 { 02416 if (LocaleCompare("radial-blur",option+1) == 0) 02417 { 02418 /* 02419 Radial blur image. 02420 */ 02421 (void) SyncImageSettings(mogrify_info,*image,exception); 02422 flags=ParseGeometry(argv[i+1],&geometry_info); 02423 mogrify_image=RadialBlurImage(*image,geometry_info.rho, 02424 geometry_info.sigma,exception); 02425 break; 02426 } 02427 if (LocaleCompare("raise",option+1) == 0) 02428 { 02429 /* 02430 Surround image with a raise of solid color. 02431 */ 02432 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); 02433 if ((flags & SigmaValue) == 0) 02434 geometry.height=geometry.width; 02435 (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : 02436 MagickFalse,exception); 02437 break; 02438 } 02439 if (LocaleCompare("random-threshold",option+1) == 0) 02440 { 02441 /* 02442 Threshold image. 02443 */ 02444 (void) SyncImageSettings(mogrify_info,*image,exception); 02445 (void) RandomThresholdImage(*image,argv[i+1],exception); 02446 break; 02447 } 02448 if (LocaleCompare("region",option+1) == 0) 02449 { 02450 (void) SyncImageSettings(mogrify_info,*image,exception); 02451 if (region_image != (Image *) NULL) 02452 { 02453 /* 02454 Composite region. 02455 */ 02456 (void) CompositeImage(region_image,region_image->matte != 02457 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, 02458 region_geometry.x,region_geometry.y,exception); 02459 *image=DestroyImage(*image); 02460 *image=region_image; 02461 region_image = (Image *) NULL; 02462 } 02463 if (*option == '+') 02464 break; 02465 /* 02466 Apply transformations to a selected region of the image. 02467 */ 02468 (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, 02469 exception); 02470 mogrify_image=CropImage(*image,®ion_geometry,exception); 02471 if (mogrify_image == (Image *) NULL) 02472 break; 02473 region_image=(*image); 02474 *image=mogrify_image; 02475 mogrify_image=(Image *) NULL; 02476 break; 02477 } 02478 if (LocaleCompare("render",option+1) == 0) 02479 { 02480 (void) SyncImageSettings(mogrify_info,*image,exception); 02481 draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; 02482 break; 02483 } 02484 if (LocaleCompare("remap",option+1) == 0) 02485 { 02486 Image 02487 *remap_image; 02488 02489 /* 02490 Transform image colors to match this set of colors. 02491 */ 02492 (void) SyncImageSettings(mogrify_info,*image,exception); 02493 if (*option == '+') 02494 break; 02495 remap_image=GetImageCache(mogrify_info,argv[i+1],exception); 02496 if (remap_image == (Image *) NULL) 02497 break; 02498 (void) RemapImage(quantize_info,*image,remap_image,exception); 02499 remap_image=DestroyImage(remap_image); 02500 break; 02501 } 02502 if (LocaleCompare("repage",option+1) == 0) 02503 { 02504 if (*option == '+') 02505 { 02506 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); 02507 break; 02508 } 02509 (void) ResetImagePage(*image,argv[i+1]); 02510 break; 02511 } 02512 if (LocaleCompare("resample",option+1) == 0) 02513 { 02514 /* 02515 Resample image. 02516 */ 02517 (void) SyncImageSettings(mogrify_info,*image,exception); 02518 flags=ParseGeometry(argv[i+1],&geometry_info); 02519 if ((flags & SigmaValue) == 0) 02520 geometry_info.sigma=geometry_info.rho; 02521 mogrify_image=ResampleImage(*image,geometry_info.rho, 02522 geometry_info.sigma,(*image)->filter,(*image)->blur,exception); 02523 break; 02524 } 02525 if (LocaleCompare("resize",option+1) == 0) 02526 { 02527 /* 02528 Resize image. 02529 */ 02530 (void) SyncImageSettings(mogrify_info,*image,exception); 02531 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); 02532 mogrify_image=ResizeImage(*image,geometry.width,geometry.height, 02533 (*image)->filter,(*image)->blur,exception); 02534 break; 02535 } 02536 if (LocaleCompare("roll",option+1) == 0) 02537 { 02538 /* 02539 Roll image. 02540 */ 02541 (void) SyncImageSettings(mogrify_info,*image,exception); 02542 (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); 02543 mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); 02544 break; 02545 } 02546 if (LocaleCompare("rotate",option+1) == 0) 02547 { 02548 char 02549 *geometry; 02550 02551 /* 02552 Check for conditional image rotation. 02553 */ 02554 (void) SyncImageSettings(mogrify_info,*image,exception); 02555 if (strchr(argv[i+1],'>') != (char *) NULL) 02556 if ((*image)->columns <= (*image)->rows) 02557 break; 02558 if (strchr(argv[i+1],'<') != (char *) NULL) 02559 if ((*image)->columns >= (*image)->rows) 02560 break; 02561 /* 02562 Rotate image. 02563 */ 02564 geometry=ConstantString(argv[i+1]); 02565 (void) SubstituteString(&geometry,">",""); 02566 (void) SubstituteString(&geometry,"<",""); 02567 (void) ParseGeometry(geometry,&geometry_info); 02568 geometry=DestroyString(geometry); 02569 mogrify_image=RotateImage(*image,geometry_info.rho,exception); 02570 break; 02571 } 02572 break; 02573 } 02574 case 's': 02575 { 02576 if (LocaleCompare("sample",option+1) == 0) 02577 { 02578 /* 02579 Sample image with pixel replication. 02580 */ 02581 (void) SyncImageSettings(mogrify_info,*image,exception); 02582 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); 02583 mogrify_image=SampleImage(*image,geometry.width,geometry.height, 02584 exception); 02585 break; 02586 } 02587 if (LocaleCompare("scale",option+1) == 0) 02588 { 02589 /* 02590 Resize image. 02591 */ 02592 (void) SyncImageSettings(mogrify_info,*image,exception); 02593 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); 02594 mogrify_image=ScaleImage(*image,geometry.width,geometry.height, 02595 exception); 02596 break; 02597 } 02598 if (LocaleCompare("selective-blur",option+1) == 0) 02599 { 02600 /* 02601 Selectively blur pixels within a contrast threshold. 02602 */ 02603 (void) SyncImageSettings(mogrify_info,*image,exception); 02604 flags=ParseGeometry(argv[i+1],&geometry_info); 02605 if ((flags & PercentValue) != 0) 02606 geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; 02607 mogrify_image=SelectiveBlurImage(*image,geometry_info.rho, 02608 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); 02609 break; 02610 } 02611 if (LocaleCompare("separate",option+1) == 0) 02612 { 02613 /* 02614 Break channels into separate images. 02615 */ 02616 (void) SyncImageSettings(mogrify_info,*image,exception); 02617 mogrify_image=SeparateImages(*image,exception); 02618 break; 02619 } 02620 if (LocaleCompare("sepia-tone",option+1) == 0) 02621 { 02622 double 02623 threshold; 02624 02625 /* 02626 Sepia-tone image. 02627 */ 02628 (void) SyncImageSettings(mogrify_info,*image,exception); 02629 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ 02630 1.0); 02631 mogrify_image=SepiaToneImage(*image,threshold,exception); 02632 break; 02633 } 02634 if (LocaleCompare("segment",option+1) == 0) 02635 { 02636 /* 02637 Segment image. 02638 */ 02639 (void) SyncImageSettings(mogrify_info,*image,exception); 02640 flags=ParseGeometry(argv[i+1],&geometry_info); 02641 if ((flags & SigmaValue) == 0) 02642 geometry_info.sigma=1.0; 02643 (void) SegmentImage(*image,(*image)->colorspace, 02644 mogrify_info->verbose,geometry_info.rho,geometry_info.sigma, 02645 exception); 02646 break; 02647 } 02648 if (LocaleCompare("set",option+1) == 0) 02649 { 02650 char 02651 *value; 02652 02653 /* 02654 Set image option. 02655 */ 02656 if (*option == '+') 02657 { 02658 if (LocaleNCompare(argv[i+1],"registry:",9) == 0) 02659 (void) DeleteImageRegistry(argv[i+1]+9); 02660 else 02661 if (LocaleNCompare(argv[i+1],"option:",7) == 0) 02662 { 02663 (void) DeleteImageOption(mogrify_info,argv[i+1]+7); 02664 (void) DeleteImageArtifact(*image,argv[i+1]+7); 02665 } 02666 else 02667 (void) DeleteImageProperty(*image,argv[i+1]); 02668 break; 02669 } 02670 value=InterpretImageProperties(mogrify_info,*image,argv[i+2], 02671 exception); 02672 if (value == (char *) NULL) 02673 break; 02674 if (LocaleNCompare(argv[i+1],"registry:",9) == 0) 02675 (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, 02676 exception); 02677 else 02678 if (LocaleNCompare(argv[i+1],"option:",7) == 0) 02679 { 02680 (void) SetImageOption(image_info,argv[i+1]+7,value); 02681 (void) SetImageOption(mogrify_info,argv[i+1]+7,value); 02682 (void) SetImageArtifact(*image,argv[i+1]+7,value); 02683 } 02684 else 02685 (void) SetImageProperty(*image,argv[i+1],value,exception); 02686 value=DestroyString(value); 02687 break; 02688 } 02689 if (LocaleCompare("shade",option+1) == 0) 02690 { 02691 /* 02692 Shade image. 02693 */ 02694 (void) SyncImageSettings(mogrify_info,*image,exception); 02695 flags=ParseGeometry(argv[i+1],&geometry_info); 02696 if ((flags & SigmaValue) == 0) 02697 geometry_info.sigma=1.0; 02698 mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : 02699 MagickFalse,geometry_info.rho,geometry_info.sigma,exception); 02700 break; 02701 } 02702 if (LocaleCompare("shadow",option+1) == 0) 02703 { 02704 /* 02705 Shadow image. 02706 */ 02707 (void) SyncImageSettings(mogrify_info,*image,exception); 02708 flags=ParseGeometry(argv[i+1],&geometry_info); 02709 if ((flags & SigmaValue) == 0) 02710 geometry_info.sigma=1.0; 02711 if ((flags & XiValue) == 0) 02712 geometry_info.xi=4.0; 02713 if ((flags & PsiValue) == 0) 02714 geometry_info.psi=4.0; 02715 mogrify_image=ShadowImage(*image,geometry_info.rho, 02716 geometry_info.sigma,(*image)->bias,(ssize_t) 02717 ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5), 02718 exception); 02719 break; 02720 } 02721 if (LocaleCompare("sharpen",option+1) == 0) 02722 { 02723 /* 02724 Sharpen image. 02725 */ 02726 (void) SyncImageSettings(mogrify_info,*image,exception); 02727 flags=ParseGeometry(argv[i+1],&geometry_info); 02728 if ((flags & SigmaValue) == 0) 02729 geometry_info.sigma=1.0; 02730 if ((flags & XiValue) == 0) 02731 geometry_info.xi=0.0; 02732 mogrify_image=SharpenImage(*image,geometry_info.rho, 02733 geometry_info.sigma,geometry_info.xi,exception); 02734 break; 02735 } 02736 if (LocaleCompare("shave",option+1) == 0) 02737 { 02738 /* 02739 Shave the image edges. 02740 */ 02741 (void) SyncImageSettings(mogrify_info,*image,exception); 02742 flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); 02743 mogrify_image=ShaveImage(*image,&geometry,exception); 02744 break; 02745 } 02746 if (LocaleCompare("shear",option+1) == 0) 02747 { 02748 /* 02749 Shear image. 02750 */ 02751 (void) SyncImageSettings(mogrify_info,*image,exception); 02752 flags=ParseGeometry(argv[i+1],&geometry_info); 02753 if ((flags & SigmaValue) == 0) 02754 geometry_info.sigma=geometry_info.rho; 02755 mogrify_image=ShearImage(*image,geometry_info.rho, 02756 geometry_info.sigma,exception); 02757 break; 02758 } 02759 if (LocaleCompare("sigmoidal-contrast",option+1) == 0) 02760 { 02761 /* 02762 Sigmoidal non-linearity contrast control. 02763 */ 02764 (void) SyncImageSettings(mogrify_info,*image,exception); 02765 flags=ParseGeometry(argv[i+1],&geometry_info); 02766 if ((flags & SigmaValue) == 0) 02767 geometry_info.sigma=(double) QuantumRange/2.0; 02768 if ((flags & PercentValue) != 0) 02769 geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ 02770 100.0; 02771 (void) SigmoidalContrastImage(*image,(*option == '-') ? 02772 MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma, 02773 exception); 02774 break; 02775 } 02776 if (LocaleCompare("sketch",option+1) == 0) 02777 { 02778 /* 02779 Sketch image. 02780 */ 02781 (void) SyncImageSettings(mogrify_info,*image,exception); 02782 flags=ParseGeometry(argv[i+1],&geometry_info); 02783 if ((flags & SigmaValue) == 0) 02784 geometry_info.sigma=1.0; 02785 mogrify_image=SketchImage(*image,geometry_info.rho, 02786 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); 02787 break; 02788 } 02789 if (LocaleCompare("solarize",option+1) == 0) 02790 { 02791 double 02792 threshold; 02793 02794 (void) SyncImageSettings(mogrify_info,*image,exception); 02795 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ 02796 1.0); 02797 (void) SolarizeImage(*image,threshold,exception); 02798 break; 02799 } 02800 if (LocaleCompare("sparse-color",option+1) == 0) 02801 { 02802 SparseColorMethod 02803 method; 02804 02805 char 02806 *arguments; 02807 02808 /* 02809 Sparse Color Interpolated Gradient 02810 */ 02811 (void) SyncImageSettings(mogrify_info,*image,exception); 02812 method=(SparseColorMethod) ParseCommandOption( 02813 MagickSparseColorOptions,MagickFalse,argv[i+1]); 02814 arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], 02815 exception); 02816 if (arguments == (char *) NULL) 02817 break; 02818 mogrify_image=SparseColorOption(*image,method,arguments, 02819 option[0] == '+' ? MagickTrue : MagickFalse,exception); 02820 arguments=DestroyString(arguments); 02821 break; 02822 } 02823 if (LocaleCompare("splice",option+1) == 0) 02824 { 02825 /* 02826 Splice a solid color into the image. 02827 */ 02828 (void) SyncImageSettings(mogrify_info,*image,exception); 02829 (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); 02830 mogrify_image=SpliceImage(*image,&geometry,exception); 02831 break; 02832 } 02833 if (LocaleCompare("spread",option+1) == 0) 02834 { 02835 /* 02836 Spread an image. 02837 */ 02838 (void) SyncImageSettings(mogrify_info,*image,exception); 02839 (void) ParseGeometry(argv[i+1],&geometry_info); 02840 mogrify_image=SpreadImage(*image,geometry_info.rho, 02841 interpolate_method,exception); 02842 break; 02843 } 02844 if (LocaleCompare("statistic",option+1) == 0) 02845 { 02846 StatisticType 02847 type; 02848 02849 (void) SyncImageSettings(mogrify_info,*image,exception); 02850 type=(StatisticType) ParseCommandOption(MagickStatisticOptions, 02851 MagickFalse,argv[i+1]); 02852 (void) ParseGeometry(argv[i+2],&geometry_info); 02853 mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho, 02854 (size_t) geometry_info.sigma,exception); 02855 break; 02856 } 02857 if (LocaleCompare("stretch",option+1) == 0) 02858 { 02859 if (*option == '+') 02860 { 02861 draw_info->stretch=UndefinedStretch; 02862 break; 02863 } 02864 draw_info->stretch=(StretchType) ParseCommandOption( 02865 MagickStretchOptions,MagickFalse,argv[i+1]); 02866 break; 02867 } 02868 if (LocaleCompare("strip",option+1) == 0) 02869 { 02870 /* 02871 Strip image of profiles and comments. 02872 */ 02873 (void) SyncImageSettings(mogrify_info,*image,exception); 02874 (void) StripImage(*image,exception); 02875 break; 02876 } 02877 if (LocaleCompare("stroke",option+1) == 0) 02878 { 02879 ExceptionInfo 02880 *sans; 02881 02882 PixelInfo 02883 color; 02884 02885 if (*option == '+') 02886 { 02887 (void) QueryColorCompliance("none",AllCompliance, 02888 &draw_info->stroke,exception); 02889 if (draw_info->stroke_pattern != (Image *) NULL) 02890 draw_info->stroke_pattern=DestroyImage( 02891 draw_info->stroke_pattern); 02892 break; 02893 } 02894 sans=AcquireExceptionInfo(); 02895 status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans); 02896 sans=DestroyExceptionInfo(sans); 02897 if (status == MagickFalse) 02898 draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], 02899 exception); 02900 else 02901 draw_info->stroke=color; 02902 break; 02903 } 02904 if (LocaleCompare("strokewidth",option+1) == 0) 02905 { 02906 draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL); 02907 break; 02908 } 02909 if (LocaleCompare("style",option+1) == 0) 02910 { 02911 if (*option == '+') 02912 { 02913 draw_info->style=UndefinedStyle; 02914 break; 02915 } 02916 draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, 02917 MagickFalse,argv[i+1]); 02918 break; 02919 } 02920 if (LocaleCompare("swirl",option+1) == 0) 02921 { 02922 /* 02923 Swirl image. 02924 */ 02925 (void) SyncImageSettings(mogrify_info,*image,exception); 02926 (void) ParseGeometry(argv[i+1],&geometry_info); 02927 mogrify_image=SwirlImage(*image,geometry_info.rho, 02928 interpolate_method,exception); 02929 break; 02930 } 02931 break; 02932 } 02933 case 't': 02934 { 02935 if (LocaleCompare("threshold",option+1) == 0) 02936 { 02937 double 02938 threshold; 02939 02940 /* 02941 Threshold image. 02942 */ 02943 (void) SyncImageSettings(mogrify_info,*image,exception); 02944 if (*option == '+') 02945 threshold=(double) QuantumRange/2; 02946 else 02947 threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ 02948 1.0); 02949 (void) BilevelImage(*image,threshold,exception); 02950 break; 02951 } 02952 if (LocaleCompare("thumbnail",option+1) == 0) 02953 { 02954 /* 02955 Thumbnail image. 02956 */ 02957 (void) SyncImageSettings(mogrify_info,*image,exception); 02958 (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); 02959 mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, 02960 exception); 02961 break; 02962 } 02963 if (LocaleCompare("tile",option+1) == 0) 02964 { 02965 if (*option == '+') 02966 { 02967 if (draw_info->fill_pattern != (Image *) NULL) 02968 draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); 02969 break; 02970 } 02971 draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], 02972 exception); 02973 break; 02974 } 02975 if (LocaleCompare("tint",option+1) == 0) 02976 { 02977 /* 02978 Tint the image. 02979 */ 02980 (void) SyncImageSettings(mogrify_info,*image,exception); 02981 mogrify_image=TintImage(*image,argv[i+1],&fill,exception); 02982 break; 02983 } 02984 if (LocaleCompare("transform",option+1) == 0) 02985 { 02986 /* 02987 Affine transform image. 02988 */ 02989 (void) SyncImageSettings(mogrify_info,*image,exception); 02990 mogrify_image=AffineTransformImage(*image,&draw_info->affine, 02991 exception); 02992 break; 02993 } 02994 if (LocaleCompare("transparent",option+1) == 0) 02995 { 02996 PixelInfo 02997 target; 02998 02999 (void) SyncImageSettings(mogrify_info,*image,exception); 03000 (void) QueryColorCompliance(argv[i+1],AllCompliance,&target, 03001 exception); 03002 (void) TransparentPaintImage(*image,&target,(Quantum) 03003 TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue, 03004 exception); 03005 break; 03006 } 03007 if (LocaleCompare("transpose",option+1) == 0) 03008 { 03009 /* 03010 Transpose image scanlines. 03011 */ 03012 (void) SyncImageSettings(mogrify_info,*image,exception); 03013 mogrify_image=TransposeImage(*image,exception); 03014 break; 03015 } 03016 if (LocaleCompare("transverse",option+1) == 0) 03017 { 03018 /* 03019 Transverse image scanlines. 03020 */ 03021 (void) SyncImageSettings(mogrify_info,*image,exception); 03022 mogrify_image=TransverseImage(*image,exception); 03023 break; 03024 } 03025 if (LocaleCompare("treedepth",option+1) == 0) 03026 { 03027 quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); 03028 break; 03029 } 03030 if (LocaleCompare("trim",option+1) == 0) 03031 { 03032 /* 03033 Trim image. 03034 */ 03035 (void) SyncImageSettings(mogrify_info,*image,exception); 03036 mogrify_image=TrimImage(*image,exception); 03037 break; 03038 } 03039 if (LocaleCompare("type",option+1) == 0) 03040 { 03041 ImageType 03042 type; 03043 03044 (void) SyncImageSettings(mogrify_info,*image,exception); 03045 if (*option == '+') 03046 type=UndefinedType; 03047 else 03048 type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, 03049 argv[i+1]); 03050 (*image)->type=UndefinedType; 03051 (void) SetImageType(*image,type,exception); 03052 break; 03053 } 03054 break; 03055 } 03056 case 'u': 03057 { 03058 if (LocaleCompare("undercolor",option+1) == 0) 03059 { 03060 (void) QueryColorCompliance(argv[i+1],AllCompliance, 03061 &draw_info->undercolor,exception); 03062 break; 03063 } 03064 if (LocaleCompare("unique",option+1) == 0) 03065 { 03066 if (*option == '+') 03067 { 03068 (void) DeleteImageArtifact(*image,"identify:unique-colors"); 03069 break; 03070 } 03071 (void) SetImageArtifact(*image,"identify:unique-colors","true"); 03072 (void) SetImageArtifact(*image,"verbose","true"); 03073 break; 03074 } 03075 if (LocaleCompare("unique-colors",option+1) == 0) 03076 { 03077 /* 03078 Unique image colors. 03079 */ 03080 (void) SyncImageSettings(mogrify_info,*image,exception); 03081 mogrify_image=UniqueImageColors(*image,exception); 03082 break; 03083 } 03084 if (LocaleCompare("unsharp",option+1) == 0) 03085 { 03086 /* 03087 Unsharp mask image. 03088 */ 03089 (void) SyncImageSettings(mogrify_info,*image,exception); 03090 flags=ParseGeometry(argv[i+1],&geometry_info); 03091 if ((flags & SigmaValue) == 0) 03092 geometry_info.sigma=1.0; 03093 if ((flags & XiValue) == 0) 03094 geometry_info.xi=1.0; 03095 if ((flags & PsiValue) == 0) 03096 geometry_info.psi=0.05; 03097 mogrify_image=UnsharpMaskImage(*image,geometry_info.rho, 03098 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); 03099 break; 03100 } 03101 break; 03102 } 03103 case 'v': 03104 { 03105 if (LocaleCompare("verbose",option+1) == 0) 03106 { 03107 (void) SetImageArtifact(*image,option+1, 03108 *option == '+' ? "false" : "true"); 03109 break; 03110 } 03111 if (LocaleCompare("vignette",option+1) == 0) 03112 { 03113 /* 03114 Vignette image. 03115 */ 03116 (void) SyncImageSettings(mogrify_info,*image,exception); 03117 flags=ParseGeometry(argv[i+1],&geometry_info); 03118 if ((flags & SigmaValue) == 0) 03119 geometry_info.sigma=1.0; 03120 if ((flags & XiValue) == 0) 03121 geometry_info.xi=0.1*(*image)->columns; 03122 if ((flags & PsiValue) == 0) 03123 geometry_info.psi=0.1*(*image)->rows; 03124 mogrify_image=VignetteImage(*image,geometry_info.rho, 03125 geometry_info.sigma,(*image)->bias,(ssize_t) 03126 ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5), 03127 exception); 03128 break; 03129 } 03130 if (LocaleCompare("virtual-pixel",option+1) == 0) 03131 { 03132 if (*option == '+') 03133 { 03134 (void) SetImageVirtualPixelMethod(*image, 03135 UndefinedVirtualPixelMethod,exception); 03136 break; 03137 } 03138 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) 03139 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, 03140 argv[i+1]),exception); 03141 break; 03142 } 03143 break; 03144 } 03145 case 'w': 03146 { 03147 if (LocaleCompare("wave",option+1) == 0) 03148 { 03149 /* 03150 Wave image. 03151 */ 03152 (void) SyncImageSettings(mogrify_info,*image,exception); 03153 flags=ParseGeometry(argv[i+1],&geometry_info); 03154 if ((flags & SigmaValue) == 0) 03155 geometry_info.sigma=1.0; 03156 mogrify_image=WaveImage(*image,geometry_info.rho, 03157 geometry_info.sigma,interpolate_method,exception); 03158 break; 03159 } 03160 if (LocaleCompare("weight",option+1) == 0) 03161 { 03162 draw_info->weight=StringToUnsignedLong(argv[i+1]); 03163 if (LocaleCompare(argv[i+1],"all") == 0) 03164 draw_info->weight=0; 03165 if (LocaleCompare(argv[i+1],"bold") == 0) 03166 draw_info->weight=700; 03167 if (LocaleCompare(argv[i+1],"bolder") == 0) 03168 if (draw_info->weight <= 800) 03169 draw_info->weight+=100; 03170 if (LocaleCompare(argv[i+1],"lighter") == 0) 03171 if (draw_info->weight >= 100) 03172 draw_info->weight-=100; 03173 if (LocaleCompare(argv[i+1],"normal") == 0) 03174 draw_info->weight=400; 03175 break; 03176 } 03177 if (LocaleCompare("white-threshold",option+1) == 0) 03178 { 03179 /* 03180 White threshold image. 03181 */ 03182 (void) SyncImageSettings(mogrify_info,*image,exception); 03183 (void) WhiteThresholdImage(*image,argv[i+1],exception); 03184 break; 03185 } 03186 break; 03187 } 03188 default: 03189 break; 03190 } 03191 /* 03192 Replace current image with any image that was generated 03193 */ 03194 if (mogrify_image != (Image *) NULL) 03195 ReplaceImageInListReturnLast(image,mogrify_image); 03196 i+=count; 03197 } 03198 if (region_image != (Image *) NULL) 03199 { 03200 /* 03201 Composite transformed region onto image. 03202 */ 03203 (void) SyncImageSettings(mogrify_info,*image,exception); 03204 (void) CompositeImage(region_image,region_image->matte != 03205 MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, 03206 region_geometry.x,region_geometry.y,exception); 03207 *image=DestroyImage(*image); 03208 *image=region_image; 03209 region_image = (Image *) NULL; 03210 } 03211 /* 03212 Free resources. 03213 */ 03214 quantize_info=DestroyQuantizeInfo(quantize_info); 03215 draw_info=DestroyDrawInfo(draw_info); 03216 mogrify_info=DestroyImageInfo(mogrify_info); 03217 status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0); 03218 return(status == 0 ? MagickFalse : MagickTrue); 03219 } 03220 03221 /* 03222 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 03223 % % 03224 % % 03225 % % 03226 + M o g r i f y I m a g e C o m m a n d % 03227 % % 03228 % % 03229 % % 03230 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 03231 % 03232 % MogrifyImageCommand() transforms an image or a sequence of images. These 03233 % transforms include image scaling, image rotation, color reduction, and 03234 % others. The transmogrified image overwrites the original image. 03235 % 03236 % The format of the MogrifyImageCommand method is: 03237 % 03238 % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, 03239 % const char **argv,char **metadata,ExceptionInfo *exception) 03240 % 03241 % A description of each parameter follows: 03242 % 03243 % o image_info: the image info. 03244 % 03245 % o argc: the number of elements in the argument vector. 03246 % 03247 % o argv: A text array containing the command line arguments. 03248 % 03249 % o metadata: any metadata is returned here. 03250 % 03251 % o exception: return any errors or warnings in this structure. 03252 % 03253 */ 03254 03255 static MagickBooleanType MogrifyUsage(void) 03256 { 03257 static const char 03258 *miscellaneous[]= 03259 { 03260 "-debug events display copious debugging information", 03261 "-help print program options", 03262 "-list type print a list of supported option arguments", 03263 "-log format format of debugging information", 03264 "-version print version information", 03265 (char *) NULL 03266 }, 03267 *operators[]= 03268 { 03269 "-adaptive-blur geometry", 03270 " adaptively blur pixels; decrease effect near edges", 03271 "-adaptive-resize geometry", 03272 " adaptively resize image using 'mesh' interpolation", 03273 "-adaptive-sharpen geometry", 03274 " adaptively sharpen pixels; increase effect near edges", 03275 "-alpha option on, activate, off, deactivate, set, opaque, copy", 03276 " transparent, extract, background, or shape", 03277 "-annotate geometry text", 03278 " annotate the image with text", 03279 "-auto-gamma automagically adjust gamma level of image", 03280 "-auto-level automagically adjust color levels of image", 03281 "-auto-orient automagically orient (rotate) image", 03282 "-bench iterations measure performance", 03283 "-black-threshold value", 03284 " force all pixels below the threshold into black", 03285 "-blue-shift simulate a scene at nighttime in the moonlight", 03286 "-blur geometry reduce image noise and reduce detail levels", 03287 "-border geometry surround image with a border of color", 03288 "-bordercolor color border color", 03289 "-brightness-contrast geometry", 03290 " improve brightness / contrast of the image", 03291 "-cdl filename color correct with a color decision list", 03292 "-charcoal geometry simulate a charcoal drawing", 03293 "-chop geometry remove pixels from the image interior", 03294 "-clamp restrict pixel range from 0 to the quantum depth", 03295 "-clip clip along the first path from the 8BIM profile", 03296 "-clip-mask filename associate a clip mask with the image", 03297 "-clip-path id clip along a named path from the 8BIM profile", 03298 "-colorize value colorize the image with the fill color", 03299 "-color-matrix matrix apply color correction to the image", 03300 "-contrast enhance or reduce the image contrast", 03301 "-contrast-stretch geometry", 03302 " improve contrast by `stretching' the intensity range", 03303 "-convolve coefficients", 03304 " apply a convolution kernel to the image", 03305 "-cycle amount cycle the image colormap", 03306 "-decipher filename convert cipher pixels to plain pixels", 03307 "-deskew threshold straighten an image", 03308 "-despeckle reduce the speckles within an image", 03309 "-distort method args", 03310 " distort images according to given method ad args", 03311 "-draw string annotate the image with a graphic primitive", 03312 "-edge radius apply a filter to detect edges in the image", 03313 "-encipher filename convert plain pixels to cipher pixels", 03314 "-emboss radius emboss an image", 03315 "-enhance apply a digital filter to enhance a noisy image", 03316 "-equalize perform histogram equalization to an image", 03317 "-evaluate operator value", 03318 " evaluate an arithmetic, relational, or logical expression", 03319 "-extent geometry set the image size", 03320 "-extract geometry extract area from image", 03321 "-fft implements the discrete Fourier transform (DFT)", 03322 "-flip flip image vertically", 03323 "-floodfill geometry color", 03324 " floodfill the image with color", 03325 "-flop flop image horizontally", 03326 "-frame geometry surround image with an ornamental border", 03327 "-function name parameters", 03328 " apply function over image values", 03329 "-gamma value level of gamma correction", 03330 "-gaussian-blur geometry", 03331 " reduce image noise and reduce detail levels", 03332 "-geometry geometry preferred size or location of the image", 03333 "-identify identify the format and characteristics of the image", 03334 "-ift implements the inverse discrete Fourier transform (DFT)", 03335 "-implode amount implode image pixels about the center", 03336 "-interpolative-resize geometry", 03337 " resize image using interpolation", 03338 "-lat geometry local adaptive thresholding", 03339 "-layers method optimize, merge, or compare image layers", 03340 "-level value adjust the level of image contrast", 03341 "-level-colors color,color", 03342 " level image with the given colors", 03343 "-linear-stretch geometry", 03344 " improve contrast by `stretching with saturation'", 03345 "-liquid-rescale geometry", 03346 " rescale image with seam-carving", 03347 "-median geometry apply a median filter to the image", 03348 "-mode geometry make each pixel the 'predominant color' of the neighborhood", 03349 "-modulate value vary the brightness, saturation, and hue", 03350 "-monochrome transform image to black and white", 03351 "-morphology method kernel", 03352 " apply a morphology method to the image", 03353 "-motion-blur geometry", 03354 " simulate motion blur", 03355 "-negate replace every pixel with its complementary color ", 03356 "-noise geometry add or reduce noise in an image", 03357 "-normalize transform image to span the full range of colors", 03358 "-opaque color change this color to the fill color", 03359 "-ordered-dither NxN", 03360 " add a noise pattern to the image with specific", 03361 " amplitudes", 03362 "-paint radius simulate an oil painting", 03363 "-polaroid angle simulate a Polaroid picture", 03364 "-posterize levels reduce the image to a limited number of color levels", 03365 "-profile filename add, delete, or apply an image profile", 03366 "-quantize colorspace reduce colors in this colorspace", 03367 "-radial-blur angle radial blur the image", 03368 "-raise value lighten/darken image edges to create a 3-D effect", 03369 "-random-threshold low,high", 03370 " random threshold the image", 03371 "-region geometry apply options to a portion of the image", 03372 "-render render vector graphics", 03373 "-repage geometry size and location of an image canvas", 03374 "-resample geometry change the resolution of an image", 03375 "-resize geometry resize the image", 03376 "-roll geometry roll an image vertically or horizontally", 03377 "-rotate degrees apply Paeth rotation to the image", 03378 "-sample geometry scale image with pixel sampling", 03379 "-scale geometry scale the image", 03380 "-segment values segment an image", 03381 "-selective-blur geometry", 03382 " selectively blur pixels within a contrast threshold", 03383 "-sepia-tone threshold", 03384 " simulate a sepia-toned photo", 03385 "-set property value set an image property", 03386 "-shade degrees shade the image using a distant light source", 03387 "-shadow geometry simulate an image shadow", 03388 "-sharpen geometry sharpen the image", 03389 "-shave geometry shave pixels from the image edges", 03390 "-shear geometry slide one edge of the image along the X or Y axis", 03391 "-sigmoidal-contrast geometry", 03392 " increase the contrast without saturating highlights or shadows", 03393 "-sketch geometry simulate a pencil sketch", 03394 "-solarize threshold negate all pixels above the threshold level", 03395 "-sparse-color method args", 03396 " fill in a image based on a few color points", 03397 "-splice geometry splice the background color into the image", 03398 "-spread radius displace image pixels by a random amount", 03399 "-statistic type radius", 03400 " replace each pixel with corresponding statistic from the neighborhood", 03401 "-strip strip image of all profiles and comments", 03402 "-swirl degrees swirl image pixels about the center", 03403 "-threshold value threshold the image", 03404 "-thumbnail geometry create a thumbnail of the image", 03405 "-tile filename tile image when filling a graphic primitive", 03406 "-tint value tint the image with the fill color", 03407 "-transform affine transform image", 03408 "-transparent color make this color transparent within the image", 03409 "-transpose flip image vertically and rotate 90 degrees", 03410 "-transverse flop image horizontally and rotate 270 degrees", 03411 "-trim trim image edges", 03412 "-type type image type", 03413 "-unique-colors discard all but one of any pixel color", 03414 "-unsharp geometry sharpen the image", 03415 "-vignette geometry soften the edges of the image in vignette style", 03416 "-wave geometry alter an image along a sine wave", 03417 "-white-threshold value", 03418 " force all pixels above the threshold into white", 03419 (char *) NULL 03420 }, 03421 *sequence_operators[]= 03422 { 03423 "-append append an image sequence", 03424 "-clut apply a color lookup table to the image", 03425 "-coalesce merge a sequence of images", 03426 "-combine combine a sequence of images", 03427 "-composite composite image", 03428 "-crop geometry cut out a rectangular region of the image", 03429 "-deconstruct break down an image sequence into constituent parts", 03430 "-evaluate-sequence operator", 03431 " evaluate an arithmetic, relational, or logical expression", 03432 "-flatten flatten a sequence of images", 03433 "-fx expression apply mathematical expression to an image channel(s)", 03434 "-hald-clut apply a Hald color lookup table to the image", 03435 "-morph value morph an image sequence", 03436 "-mosaic create a mosaic from an image sequence", 03437 "-print string interpret string and print to console", 03438 "-process arguments process the image with a custom image filter", 03439 "-separate separate an image channel into a grayscale image", 03440 "-smush geometry smush an image sequence together", 03441 "-write filename write images to this file", 03442 (char *) NULL 03443 }, 03444 *settings[]= 03445 { 03446 "-adjoin join images into a single multi-image file", 03447 "-affine matrix affine transform matrix", 03448 "-alpha option activate, deactivate, reset, or set the alpha channel", 03449 "-antialias remove pixel-aliasing", 03450 "-authenticate password", 03451 " decipher image with this password", 03452 "-attenuate value lessen (or intensify) when adding noise to an image", 03453 "-background color background color", 03454 "-bias value add bias when convolving an image", 03455 "-black-point-compensation", 03456 " use black point compensation", 03457 "-blue-primary point chromaticity blue primary point", 03458 "-bordercolor color border color", 03459 "-caption string assign a caption to an image", 03460 "-channel type apply option to select image channels", 03461 "-colors value preferred number of colors in the image", 03462 "-colorspace type alternate image colorspace", 03463 "-comment string annotate image with comment", 03464 "-compose operator set image composite operator", 03465 "-compress type type of pixel compression when writing the image", 03466 "-define format:option=value", 03467 " define one or more image format options", 03468 "-delay value display the next image after pausing", 03469 "-density geometry horizontal and vertical density of the image", 03470 "-depth value image depth", 03471 "-direction type render text right-to-left or left-to-right", 03472 "-display server get image or font from this X server", 03473 "-dispose method layer disposal method", 03474 "-dither method apply error diffusion to image", 03475 "-encoding type text encoding type", 03476 "-endian type endianness (MSB or LSB) of the image", 03477 "-family name render text with this font family", 03478 "-fill color color to use when filling a graphic primitive", 03479 "-filter type use this filter when resizing an image", 03480 "-font name render text with this font", 03481 "-format \"string\" output formatted image characteristics", 03482 "-fuzz distance colors within this distance are considered equal", 03483 "-gravity type horizontal and vertical text placement", 03484 "-green-primary point chromaticity green primary point", 03485 "-intent type type of rendering intent when managing the image color", 03486 "-interlace type type of image interlacing scheme", 03487 "-interline-spacing value", 03488 " set the space between two text lines", 03489 "-interpolate method pixel color interpolation method", 03490 "-interword-spacing value", 03491 " set the space between two words", 03492 "-kerning value set the space between two letters", 03493 "-label string assign a label to an image", 03494 "-limit type value pixel cache resource limit", 03495 "-loop iterations add Netscape loop extension to your GIF animation", 03496 "-mask filename associate a mask with the image", 03497 "-mattecolor color frame color", 03498 "-monitor monitor progress", 03499 "-orient type image orientation", 03500 "-page geometry size and location of an image canvas (setting)", 03501 "-ping efficiently determine image attributes", 03502 "-pointsize value font point size", 03503 "-precision value maximum number of significant digits to print", 03504 "-preview type image preview type", 03505 "-quality value JPEG/MIFF/PNG compression level", 03506 "-quiet suppress all warning messages", 03507 "-red-primary point chromaticity red primary point", 03508 "-regard-warnings pay attention to warning messages", 03509 "-remap filename transform image colors to match this set of colors", 03510 "-respect-parentheses settings remain in effect until parenthesis boundary", 03511 "-sampling-factor geometry", 03512 " horizontal and vertical sampling factor", 03513 "-scene value image scene number", 03514 "-seed value seed a new sequence of pseudo-random numbers", 03515 "-size geometry width and height of image", 03516 "-stretch type render text with this font stretch", 03517 "-stroke color graphic primitive stroke color", 03518 "-strokewidth value graphic primitive stroke width", 03519 "-style type render text with this font style", 03520 "-synchronize synchronize image to storage device", 03521 "-taint declare the image as modified", 03522 "-texture filename name of texture to tile onto the image background", 03523 "-tile-offset geometry", 03524 " tile offset", 03525 "-treedepth value color tree depth", 03526 "-transparent-color color", 03527 " transparent color", 03528 "-undercolor color annotation bounding box color", 03529 "-units type the units of image resolution", 03530 "-verbose print detailed information about the image", 03531 "-view FlashPix viewing transforms", 03532 "-virtual-pixel method", 03533 " virtual pixel access method", 03534 "-weight type render text with this font weight", 03535 "-white-point point chromaticity white point", 03536 (char *) NULL 03537 }, 03538 *stack_operators[]= 03539 { 03540 "-delete indexes delete the image from the image sequence", 03541 "-duplicate count,indexes", 03542 " duplicate an image one or more times", 03543 "-insert index insert last image into the image sequence", 03544 "-reverse reverse image sequence", 03545 "-swap indexes swap two images in the image sequence", 03546 (char *) NULL 03547 }; 03548 03549 const char 03550 **p; 03551 03552 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); 03553 (void) printf("Copyright: %s\n",GetMagickCopyright()); 03554 (void) printf("Features: %s\n\n",GetMagickFeatures()); 03555 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", 03556 GetClientName()); 03557 (void) printf("\nImage Settings:\n"); 03558 for (p=settings; *p != (char *) NULL; p++) 03559 (void) printf(" %s\n",*p); 03560 (void) printf("\nImage Operators:\n"); 03561 for (p=operators; *p != (char *) NULL; p++) 03562 (void) printf(" %s\n",*p); 03563 (void) printf("\nImage Sequence Operators:\n"); 03564 for (p=sequence_operators; *p != (char *) NULL; p++) 03565 (void) printf(" %s\n",*p); 03566 (void) printf("\nImage Stack Operators:\n"); 03567 for (p=stack_operators; *p != (char *) NULL; p++) 03568 (void) printf(" %s\n",*p); 03569 (void) printf("\nMiscellaneous Options:\n"); 03570 for (p=miscellaneous; *p != (char *) NULL; p++) 03571 (void) printf(" %s\n",*p); 03572 (void) printf( 03573 "\nBy default, the image format of 'file' is determined by its magic\n"); 03574 (void) printf( 03575 "number. To specify a particular image format, precede the filename\n"); 03576 (void) printf( 03577 "with an image format name and a colon (i.e. ps:image) or specify the\n"); 03578 (void) printf( 03579 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); 03580 (void) printf("'-' for standard input or output.\n"); 03581 return(MagickFalse); 03582 } 03583 03584 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, 03585 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) 03586 { 03587 #define DestroyMogrify() \ 03588 { \ 03589 if (format != (char *) NULL) \ 03590 format=DestroyString(format); \ 03591 if (path != (char *) NULL) \ 03592 path=DestroyString(path); \ 03593 DestroyImageStack(); \ 03594 for (i=0; i < (ssize_t) argc; i++) \ 03595 argv[i]=DestroyString(argv[i]); \ 03596 argv=(char **) RelinquishMagickMemory(argv); \ 03597 } 03598 #define ThrowMogrifyException(asperity,tag,option) \ 03599 { \ 03600 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ 03601 option); \ 03602 DestroyMogrify(); \ 03603 return(MagickFalse); \ 03604 } 03605 #define ThrowMogrifyInvalidArgumentException(option,argument) \ 03606 { \ 03607 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ 03608 "InvalidArgument","`%s': %s",argument,option); \ 03609 DestroyMogrify(); \ 03610 return(MagickFalse); \ 03611 } 03612 03613 char 03614 *format, 03615 *option, 03616 *path; 03617 03618 Image 03619 *image; 03620 03621 ImageStack 03622 image_stack[MaxImageStackDepth+1]; 03623 03624 MagickBooleanType 03625 global_colormap; 03626 03627 MagickBooleanType 03628 fire, 03629 pend, 03630 respect_parenthesis; 03631 03632 MagickStatusType 03633 status; 03634 03635 register ssize_t 03636 i; 03637 03638 ssize_t 03639 j, 03640 k; 03641 03642 /* 03643 Set defaults. 03644 */ 03645 assert(image_info != (ImageInfo *) NULL); 03646 assert(image_info->signature == MagickSignature); 03647 if (image_info->debug != MagickFalse) 03648 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 03649 assert(exception != (ExceptionInfo *) NULL); 03650 if (argc == 2) 03651 { 03652 option=argv[1]; 03653 if ((LocaleCompare("version",option+1) == 0) || 03654 (LocaleCompare("-version",option+1) == 0)) 03655 { 03656 (void) FormatLocaleFile(stdout,"Version: %s\n", 03657 GetMagickVersion((size_t *) NULL)); 03658 (void) FormatLocaleFile(stdout,"Copyright: %s\n", 03659 GetMagickCopyright()); 03660 (void) FormatLocaleFile(stdout,"Features: %s\n\n", 03661 GetMagickFeatures()); 03662 return(MagickFalse); 03663 } 03664 } 03665 if (argc < 2) 03666 return(MogrifyUsage()); 03667 format=(char *) NULL; 03668 path=(char *) NULL; 03669 global_colormap=MagickFalse; 03670 k=0; 03671 j=1; 03672 NewImageStack(); 03673 option=(char *) NULL; 03674 pend=MagickFalse; 03675 respect_parenthesis=MagickFalse; 03676 status=MagickTrue; 03677 /* 03678 Parse command line. 03679 */ 03680 ReadCommandlLine(argc,&argv); 03681 status=ExpandFilenames(&argc,&argv); 03682 if (status == MagickFalse) 03683 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", 03684 GetExceptionMessage(errno)); 03685 for (i=1; i < (ssize_t) argc; i++) 03686 { 03687 option=argv[i]; 03688 if (LocaleCompare(option,"(") == 0) 03689 { 03690 FireImageStack(MagickFalse,MagickTrue,pend); 03691 if (k == MaxImageStackDepth) 03692 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", 03693 option); 03694 PushImageStack(); 03695 continue; 03696 } 03697 if (LocaleCompare(option,")") == 0) 03698 { 03699 FireImageStack(MagickFalse,MagickTrue,MagickTrue); 03700 if (k == 0) 03701 ThrowMogrifyException(OptionError,"UnableToParseExpression",option); 03702 PopImageStack(); 03703 continue; 03704 } 03705 if (IsCommandOption(option) == MagickFalse) 03706 { 03707 char 03708 backup_filename[MaxTextExtent], 03709 *filename; 03710 03711 Image 03712 *images; 03713 03714 /* 03715 Option is a file name: begin by reading image from specified file. 03716 */ 03717 FireImageStack(MagickFalse,MagickFalse,pend); 03718 filename=argv[i]; 03719 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) 03720 filename=argv[++i]; 03721 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); 03722 images=ReadImages(image_info,exception); 03723 status&=(images != (Image *) NULL) && 03724 (exception->severity < ErrorException); 03725 if (images == (Image *) NULL) 03726 continue; 03727 if (format != (char *) NULL) 03728 (void) CopyMagickString(images->filename,images->magick_filename, 03729 MaxTextExtent); 03730 if (path != (char *) NULL) 03731 { 03732 GetPathComponent(option,TailPath,filename); 03733 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", 03734 path,*DirectorySeparator,filename); 03735 } 03736 if (format != (char *) NULL) 03737 AppendImageFormat(format,images->filename); 03738 AppendImageStack(images); 03739 FinalizeImageSettings(image_info,image,MagickFalse); 03740 if (global_colormap != MagickFalse) 03741 { 03742 QuantizeInfo 03743 *quantize_info; 03744 03745 quantize_info=AcquireQuantizeInfo(image_info); 03746 (void) RemapImages(quantize_info,images,(Image *) NULL,exception); 03747 quantize_info=DestroyQuantizeInfo(quantize_info); 03748 } 03749 *backup_filename='\0'; 03750 if ((LocaleCompare(image->filename,"-") != 0) && 03751 (IsPathWritable(image->filename) != MagickFalse)) 03752 { 03753 register ssize_t 03754 i; 03755 03756 /* 03757 Rename image file as backup. 03758 */ 03759 (void) CopyMagickString(backup_filename,image->filename, 03760 MaxTextExtent); 03761 for (i=0; i < 6; i++) 03762 { 03763 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); 03764 if (IsPathAccessible(backup_filename) == MagickFalse) 03765 break; 03766 } 03767 if ((IsPathAccessible(backup_filename) != MagickFalse) || 03768 (rename_utf8(image->filename,backup_filename) != 0)) 03769 *backup_filename='\0'; 03770 } 03771 /* 03772 Write transmogrified image to disk. 03773 */ 03774 image_info->synchronize=MagickTrue; 03775 status&=WriteImages(image_info,image,image->filename,exception); 03776 if ((status == MagickFalse) && (*backup_filename != '\0')) 03777 (void) remove_utf8(backup_filename); 03778 RemoveAllImageStack(); 03779 continue; 03780 } 03781 pend=image != (Image *) NULL ? MagickTrue : MagickFalse; 03782 switch (*(option+1)) 03783 { 03784 case 'a': 03785 { 03786 if (LocaleCompare("adaptive-blur",option+1) == 0) 03787 { 03788 i++; 03789 if (i == (ssize_t) argc) 03790 ThrowMogrifyException(OptionError,"MissingArgument",option); 03791 if (IsGeometry(argv[i]) == MagickFalse) 03792 ThrowMogrifyInvalidArgumentException(option,argv[i]); 03793 break; 03794 } 03795 if (LocaleCompare("adaptive-resize",option+1) == 0) 03796 { 03797 i++; 03798 if (i == (ssize_t) argc) 03799 ThrowMogrifyException(OptionError,"MissingArgument",option); 03800 if (IsGeometry(argv[i]) == MagickFalse) 03801 ThrowMogrifyInvalidArgumentException(option,argv[i]); 03802 break; 03803 } 03804 if (LocaleCompare("adaptive-sharpen",option+1) == 0) 03805 { 03806 i++; 03807 if (i == (ssize_t) argc) 03808 ThrowMogrifyException(OptionError,"MissingArgument",option); 03809 if (IsGeometry(argv[i]) == MagickFalse) 03810 ThrowMogrifyInvalidArgumentException(option,argv[i]); 03811 break; 03812 } 03813 if (LocaleCompare("affine",option+1) == 0) 03814 { 03815 if (*option == '+') 03816 break; 03817 i++; 03818 if (i == (ssize_t) argc) 03819 ThrowMogrifyException(OptionError,"MissingArgument",option); 03820 break; 03821 } 03822 if (LocaleCompare("alpha",option+1) == 0) 03823 { 03824 ssize_t 03825 type; 03826 03827 if (*option == '+') 03828 break; 03829 i++; 03830 if (i == (ssize_t) argc) 03831 ThrowMogrifyException(OptionError,"MissingArgument",option); 03832 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); 03833 if (type < 0) 03834 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", 03835 argv[i]); 03836 break; 03837 } 03838 if (LocaleCompare("annotate",option+1) == 0) 03839 { 03840 if (*option == '+') 03841 break; 03842 i++; 03843 if (i == (ssize_t) argc) 03844 ThrowMogrifyException(OptionError,"MissingArgument",option); 03845 if (IsGeometry(argv[i]) == MagickFalse) 03846 ThrowMogrifyInvalidArgumentException(option,argv[i]); 03847 if (i == (ssize_t) argc) 03848 ThrowMogrifyException(OptionError,"MissingArgument",option); 03849 i++; 03850 break; 03851 } 03852 if (LocaleCompare("antialias",option+1) == 0) 03853 break; 03854 if (LocaleCompare("append",option+1) == 0) 03855 break; 03856 if (LocaleCompare("attenuate",option+1) == 0) 03857 { 03858 if (*option == '+') 03859 break; 03860 i++; 03861 if (i == (ssize_t) (argc-1)) 03862 ThrowMogrifyException(OptionError,"MissingArgument",option); 03863 if (IsGeometry(argv[i]) == MagickFalse) 03864 ThrowMogrifyInvalidArgumentException(option,argv[i]); 03865 break; 03866 } 03867 if (LocaleCompare("authenticate",option+1) == 0) 03868 { 03869 if (*option == '+') 03870 break; 03871 i++; 03872 if (i == (ssize_t) argc) 03873 ThrowMogrifyException(OptionError,"MissingArgument",option); 03874 break; 03875 } 03876 if (LocaleCompare("auto-gamma",option+1) == 0) 03877 break; 03878 if (LocaleCompare("auto-level",option+1) == 0) 03879 break; 03880 if (LocaleCompare("auto-orient",option+1) == 0) 03881 break; 03882 if (LocaleCompare("average",option+1) == 0) 03883 break; 03884 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 03885 } 03886 case 'b': 03887 { 03888 if (LocaleCompare("background",option+1) == 0) 03889 { 03890 if (*option == '+') 03891 break; 03892 i++; 03893 if (i == (ssize_t) argc) 03894 ThrowMogrifyException(OptionError,"MissingArgument",option); 03895 break; 03896 } 03897 if (LocaleCompare("bias",option+1) == 0) 03898 { 03899 if (*option == '+') 03900 break; 03901 i++; 03902 if (i == (ssize_t) (argc-1)) 03903 ThrowMogrifyException(OptionError,"MissingArgument",option); 03904 if (IsGeometry(argv[i]) == MagickFalse) 03905 ThrowMogrifyInvalidArgumentException(option,argv[i]); 03906 break; 03907 } 03908 if (LocaleCompare("black-point-compensation",option+1) == 0) 03909 break; 03910 if (LocaleCompare("black-threshold",option+1) == 0) 03911 { 03912 if (*option == '+') 03913 break; 03914 i++; 03915 if (i == (ssize_t) argc) 03916 ThrowMogrifyException(OptionError,"MissingArgument",option); 03917 if (IsGeometry(argv[i]) == MagickFalse) 03918 ThrowMogrifyInvalidArgumentException(option,argv[i]); 03919 break; 03920 } 03921 if (LocaleCompare("blue-primary",option+1) == 0) 03922 { 03923 if (*option == '+') 03924 break; 03925 i++; 03926 if (i == (ssize_t) argc) 03927 ThrowMogrifyException(OptionError,"MissingArgument",option); 03928 if (IsGeometry(argv[i]) == MagickFalse) 03929 ThrowMogrifyInvalidArgumentException(option,argv[i]); 03930 break; 03931 } 03932 if (LocaleCompare("blue-shift",option+1) == 0) 03933 { 03934 i++; 03935 if (i == (ssize_t) argc) 03936 ThrowMogrifyException(OptionError,"MissingArgument",option); 03937 if (IsGeometry(argv[i]) == MagickFalse) 03938 ThrowMogrifyInvalidArgumentException(option,argv[i]); 03939 break; 03940 } 03941 if (LocaleCompare("blur",option+1) == 0) 03942 { 03943 i++; 03944 if (i == (ssize_t) argc) 03945 ThrowMogrifyException(OptionError,"MissingArgument",option); 03946 if (IsGeometry(argv[i]) == MagickFalse) 03947 ThrowMogrifyInvalidArgumentException(option,argv[i]); 03948 break; 03949 } 03950 if (LocaleCompare("border",option+1) == 0) 03951 { 03952 if (*option == '+') 03953 break; 03954 i++; 03955 if (i == (ssize_t) argc) 03956 ThrowMogrifyException(OptionError,"MissingArgument",option); 03957 if (IsGeometry(argv[i]) == MagickFalse) 03958 ThrowMogrifyInvalidArgumentException(option,argv[i]); 03959 break; 03960 } 03961 if (LocaleCompare("bordercolor",option+1) == 0) 03962 { 03963 if (*option == '+') 03964 break; 03965 i++; 03966 if (i == (ssize_t) argc) 03967 ThrowMogrifyException(OptionError,"MissingArgument",option); 03968 break; 03969 } 03970 if (LocaleCompare("box",option+1) == 0) 03971 { 03972 if (*option == '+') 03973 break; 03974 i++; 03975 if (i == (ssize_t) argc) 03976 ThrowMogrifyException(OptionError,"MissingArgument",option); 03977 break; 03978 } 03979 if (LocaleCompare("brightness-contrast",option+1) == 0) 03980 { 03981 i++; 03982 if (i == (ssize_t) argc) 03983 ThrowMogrifyException(OptionError,"MissingArgument",option); 03984 if (IsGeometry(argv[i]) == MagickFalse) 03985 ThrowMogrifyInvalidArgumentException(option,argv[i]); 03986 break; 03987 } 03988 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 03989 } 03990 case 'c': 03991 { 03992 if (LocaleCompare("cache",option+1) == 0) 03993 { 03994 if (*option == '+') 03995 break; 03996 i++; 03997 if (i == (ssize_t) argc) 03998 ThrowMogrifyException(OptionError,"MissingArgument",option); 03999 if (IsGeometry(argv[i]) == MagickFalse) 04000 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04001 break; 04002 } 04003 if (LocaleCompare("caption",option+1) == 0) 04004 { 04005 if (*option == '+') 04006 break; 04007 i++; 04008 if (i == (ssize_t) argc) 04009 ThrowMogrifyException(OptionError,"MissingArgument",option); 04010 break; 04011 } 04012 if (LocaleCompare("channel",option+1) == 0) 04013 { 04014 ssize_t 04015 channel; 04016 04017 if (*option == '+') 04018 break; 04019 i++; 04020 if (i == (ssize_t) (argc-1)) 04021 ThrowMogrifyException(OptionError,"MissingArgument",option); 04022 channel=ParseChannelOption(argv[i]); 04023 if (channel < 0) 04024 ThrowMogrifyException(OptionError,"UnrecognizedChannelType", 04025 argv[i]); 04026 break; 04027 } 04028 if (LocaleCompare("cdl",option+1) == 0) 04029 { 04030 if (*option == '+') 04031 break; 04032 i++; 04033 if (i == (ssize_t) (argc-1)) 04034 ThrowMogrifyException(OptionError,"MissingArgument",option); 04035 break; 04036 } 04037 if (LocaleCompare("charcoal",option+1) == 0) 04038 { 04039 if (*option == '+') 04040 break; 04041 i++; 04042 if (i == (ssize_t) argc) 04043 ThrowMogrifyException(OptionError,"MissingArgument",option); 04044 if (IsGeometry(argv[i]) == MagickFalse) 04045 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04046 break; 04047 } 04048 if (LocaleCompare("chop",option+1) == 0) 04049 { 04050 if (*option == '+') 04051 break; 04052 i++; 04053 if (i == (ssize_t) argc) 04054 ThrowMogrifyException(OptionError,"MissingArgument",option); 04055 if (IsGeometry(argv[i]) == MagickFalse) 04056 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04057 break; 04058 } 04059 if (LocaleCompare("clamp",option+1) == 0) 04060 break; 04061 if (LocaleCompare("clip",option+1) == 0) 04062 break; 04063 if (LocaleCompare("clip-mask",option+1) == 0) 04064 { 04065 if (*option == '+') 04066 break; 04067 i++; 04068 if (i == (ssize_t) argc) 04069 ThrowMogrifyException(OptionError,"MissingArgument",option); 04070 break; 04071 } 04072 if (LocaleCompare("clut",option+1) == 0) 04073 break; 04074 if (LocaleCompare("coalesce",option+1) == 0) 04075 break; 04076 if (LocaleCompare("colorize",option+1) == 0) 04077 { 04078 if (*option == '+') 04079 break; 04080 i++; 04081 if (i == (ssize_t) argc) 04082 ThrowMogrifyException(OptionError,"MissingArgument",option); 04083 if (IsGeometry(argv[i]) == MagickFalse) 04084 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04085 break; 04086 } 04087 if (LocaleCompare("color-matrix",option+1) == 0) 04088 { 04089 KernelInfo 04090 *kernel_info; 04091 04092 if (*option == '+') 04093 break; 04094 i++; 04095 if (i == (ssize_t) (argc-1)) 04096 ThrowMogrifyException(OptionError,"MissingArgument",option); 04097 kernel_info=AcquireKernelInfo(argv[i]); 04098 if (kernel_info == (KernelInfo *) NULL) 04099 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04100 kernel_info=DestroyKernelInfo(kernel_info); 04101 break; 04102 } 04103 if (LocaleCompare("colors",option+1) == 0) 04104 { 04105 if (*option == '+') 04106 break; 04107 i++; 04108 if (i == (ssize_t) argc) 04109 ThrowMogrifyException(OptionError,"MissingArgument",option); 04110 if (IsGeometry(argv[i]) == MagickFalse) 04111 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04112 break; 04113 } 04114 if (LocaleCompare("colorspace",option+1) == 0) 04115 { 04116 ssize_t 04117 colorspace; 04118 04119 if (*option == '+') 04120 break; 04121 i++; 04122 if (i == (ssize_t) argc) 04123 ThrowMogrifyException(OptionError,"MissingArgument",option); 04124 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, 04125 argv[i]); 04126 if (colorspace < 0) 04127 ThrowMogrifyException(OptionError,"UnrecognizedColorspace", 04128 argv[i]); 04129 break; 04130 } 04131 if (LocaleCompare("combine",option+1) == 0) 04132 break; 04133 if (LocaleCompare("comment",option+1) == 0) 04134 { 04135 if (*option == '+') 04136 break; 04137 i++; 04138 if (i == (ssize_t) argc) 04139 ThrowMogrifyException(OptionError,"MissingArgument",option); 04140 break; 04141 } 04142 if (LocaleCompare("composite",option+1) == 0) 04143 break; 04144 if (LocaleCompare("compress",option+1) == 0) 04145 { 04146 ssize_t 04147 compress; 04148 04149 if (*option == '+') 04150 break; 04151 i++; 04152 if (i == (ssize_t) argc) 04153 ThrowMogrifyException(OptionError,"MissingArgument",option); 04154 compress=ParseCommandOption(MagickCompressOptions,MagickFalse, 04155 argv[i]); 04156 if (compress < 0) 04157 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", 04158 argv[i]); 04159 break; 04160 } 04161 if (LocaleCompare("concurrent",option+1) == 0) 04162 break; 04163 if (LocaleCompare("contrast",option+1) == 0) 04164 break; 04165 if (LocaleCompare("contrast-stretch",option+1) == 0) 04166 { 04167 i++; 04168 if (i == (ssize_t) argc) 04169 ThrowMogrifyException(OptionError,"MissingArgument",option); 04170 if (IsGeometry(argv[i]) == MagickFalse) 04171 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04172 break; 04173 } 04174 if (LocaleCompare("convolve",option+1) == 0) 04175 { 04176 KernelInfo 04177 *kernel_info; 04178 04179 if (*option == '+') 04180 break; 04181 i++; 04182 if (i == (ssize_t) argc) 04183 ThrowMogrifyException(OptionError,"MissingArgument",option); 04184 kernel_info=AcquireKernelInfo(argv[i]); 04185 if (kernel_info == (KernelInfo *) NULL) 04186 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04187 kernel_info=DestroyKernelInfo(kernel_info); 04188 break; 04189 } 04190 if (LocaleCompare("crop",option+1) == 0) 04191 { 04192 if (*option == '+') 04193 break; 04194 i++; 04195 if (i == (ssize_t) argc) 04196 ThrowMogrifyException(OptionError,"MissingArgument",option); 04197 if (IsGeometry(argv[i]) == MagickFalse) 04198 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04199 break; 04200 } 04201 if (LocaleCompare("cycle",option+1) == 0) 04202 { 04203 if (*option == '+') 04204 break; 04205 i++; 04206 if (i == (ssize_t) argc) 04207 ThrowMogrifyException(OptionError,"MissingArgument",option); 04208 if (IsGeometry(argv[i]) == MagickFalse) 04209 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04210 break; 04211 } 04212 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 04213 } 04214 case 'd': 04215 { 04216 if (LocaleCompare("decipher",option+1) == 0) 04217 { 04218 if (*option == '+') 04219 break; 04220 i++; 04221 if (i == (ssize_t) (argc-1)) 04222 ThrowMogrifyException(OptionError,"MissingArgument",option); 04223 break; 04224 } 04225 if (LocaleCompare("deconstruct",option+1) == 0) 04226 break; 04227 if (LocaleCompare("debug",option+1) == 0) 04228 { 04229 ssize_t 04230 event; 04231 04232 if (*option == '+') 04233 break; 04234 i++; 04235 if (i == (ssize_t) argc) 04236 ThrowMogrifyException(OptionError,"MissingArgument",option); 04237 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); 04238 if (event < 0) 04239 ThrowMogrifyException(OptionError,"UnrecognizedEventType", 04240 argv[i]); 04241 (void) SetLogEventMask(argv[i]); 04242 break; 04243 } 04244 if (LocaleCompare("define",option+1) == 0) 04245 { 04246 i++; 04247 if (i == (ssize_t) argc) 04248 ThrowMogrifyException(OptionError,"MissingArgument",option); 04249 if (*option == '+') 04250 { 04251 const char 04252 *define; 04253 04254 define=GetImageOption(image_info,argv[i]); 04255 if (define == (const char *) NULL) 04256 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); 04257 break; 04258 } 04259 break; 04260 } 04261 if (LocaleCompare("delay",option+1) == 0) 04262 { 04263 if (*option == '+') 04264 break; 04265 i++; 04266 if (i == (ssize_t) argc) 04267 ThrowMogrifyException(OptionError,"MissingArgument",option); 04268 if (IsGeometry(argv[i]) == MagickFalse) 04269 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04270 break; 04271 } 04272 if (LocaleCompare("delete",option+1) == 0) 04273 { 04274 if (*option == '+') 04275 break; 04276 i++; 04277 if (i == (ssize_t) (argc-1)) 04278 ThrowMogrifyException(OptionError,"MissingArgument",option); 04279 if (IsGeometry(argv[i]) == MagickFalse) 04280 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04281 break; 04282 } 04283 if (LocaleCompare("density",option+1) == 0) 04284 { 04285 if (*option == '+') 04286 break; 04287 i++; 04288 if (i == (ssize_t) argc) 04289 ThrowMogrifyException(OptionError,"MissingArgument",option); 04290 if (IsGeometry(argv[i]) == MagickFalse) 04291 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04292 break; 04293 } 04294 if (LocaleCompare("depth",option+1) == 0) 04295 { 04296 if (*option == '+') 04297 break; 04298 i++; 04299 if (i == (ssize_t) argc) 04300 ThrowMogrifyException(OptionError,"MissingArgument",option); 04301 if (IsGeometry(argv[i]) == MagickFalse) 04302 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04303 break; 04304 } 04305 if (LocaleCompare("deskew",option+1) == 0) 04306 { 04307 if (*option == '+') 04308 break; 04309 i++; 04310 if (i == (ssize_t) argc) 04311 ThrowMogrifyException(OptionError,"MissingArgument",option); 04312 if (IsGeometry(argv[i]) == MagickFalse) 04313 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04314 break; 04315 } 04316 if (LocaleCompare("despeckle",option+1) == 0) 04317 break; 04318 if (LocaleCompare("dft",option+1) == 0) 04319 break; 04320 if (LocaleCompare("direction",option+1) == 0) 04321 { 04322 ssize_t 04323 direction; 04324 04325 if (*option == '+') 04326 break; 04327 i++; 04328 if (i == (ssize_t) argc) 04329 ThrowMogrifyException(OptionError,"MissingArgument",option); 04330 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, 04331 argv[i]); 04332 if (direction < 0) 04333 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", 04334 argv[i]); 04335 break; 04336 } 04337 if (LocaleCompare("display",option+1) == 0) 04338 { 04339 if (*option == '+') 04340 break; 04341 i++; 04342 if (i == (ssize_t) argc) 04343 ThrowMogrifyException(OptionError,"MissingArgument",option); 04344 break; 04345 } 04346 if (LocaleCompare("dispose",option+1) == 0) 04347 { 04348 ssize_t 04349 dispose; 04350 04351 if (*option == '+') 04352 break; 04353 i++; 04354 if (i == (ssize_t) argc) 04355 ThrowMogrifyException(OptionError,"MissingArgument",option); 04356 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); 04357 if (dispose < 0) 04358 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", 04359 argv[i]); 04360 break; 04361 } 04362 if (LocaleCompare("distort",option+1) == 0) 04363 { 04364 ssize_t 04365 op; 04366 04367 i++; 04368 if (i == (ssize_t) argc) 04369 ThrowMogrifyException(OptionError,"MissingArgument",option); 04370 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); 04371 if (op < 0) 04372 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", 04373 argv[i]); 04374 i++; 04375 if (i == (ssize_t) (argc-1)) 04376 ThrowMogrifyException(OptionError,"MissingArgument",option); 04377 break; 04378 } 04379 if (LocaleCompare("dither",option+1) == 0) 04380 { 04381 ssize_t 04382 method; 04383 04384 if (*option == '+') 04385 break; 04386 i++; 04387 if (i == (ssize_t) argc) 04388 ThrowMogrifyException(OptionError,"MissingArgument",option); 04389 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); 04390 if (method < 0) 04391 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", 04392 argv[i]); 04393 break; 04394 } 04395 if (LocaleCompare("draw",option+1) == 0) 04396 { 04397 if (*option == '+') 04398 break; 04399 i++; 04400 if (i == (ssize_t) argc) 04401 ThrowMogrifyException(OptionError,"MissingArgument",option); 04402 break; 04403 } 04404 if (LocaleCompare("duplicate",option+1) == 0) 04405 { 04406 if (*option == '+') 04407 break; 04408 i++; 04409 if (i == (ssize_t) (argc-1)) 04410 ThrowMogrifyException(OptionError,"MissingArgument",option); 04411 if (IsGeometry(argv[i]) == MagickFalse) 04412 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04413 break; 04414 } 04415 if (LocaleCompare("duration",option+1) == 0) 04416 { 04417 if (*option == '+') 04418 break; 04419 i++; 04420 if (i == (ssize_t) (argc-1)) 04421 ThrowMogrifyException(OptionError,"MissingArgument",option); 04422 if (IsGeometry(argv[i]) == MagickFalse) 04423 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04424 break; 04425 } 04426 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 04427 } 04428 case 'e': 04429 { 04430 if (LocaleCompare("edge",option+1) == 0) 04431 { 04432 if (*option == '+') 04433 break; 04434 i++; 04435 if (i == (ssize_t) argc) 04436 ThrowMogrifyException(OptionError,"MissingArgument",option); 04437 if (IsGeometry(argv[i]) == MagickFalse) 04438 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04439 break; 04440 } 04441 if (LocaleCompare("emboss",option+1) == 0) 04442 { 04443 if (*option == '+') 04444 break; 04445 i++; 04446 if (i == (ssize_t) argc) 04447 ThrowMogrifyException(OptionError,"MissingArgument",option); 04448 if (IsGeometry(argv[i]) == MagickFalse) 04449 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04450 break; 04451 } 04452 if (LocaleCompare("encipher",option+1) == 0) 04453 { 04454 if (*option == '+') 04455 break; 04456 i++; 04457 if (i == (ssize_t) argc) 04458 ThrowMogrifyException(OptionError,"MissingArgument",option); 04459 break; 04460 } 04461 if (LocaleCompare("encoding",option+1) == 0) 04462 { 04463 if (*option == '+') 04464 break; 04465 i++; 04466 if (i == (ssize_t) argc) 04467 ThrowMogrifyException(OptionError,"MissingArgument",option); 04468 break; 04469 } 04470 if (LocaleCompare("endian",option+1) == 0) 04471 { 04472 ssize_t 04473 endian; 04474 04475 if (*option == '+') 04476 break; 04477 i++; 04478 if (i == (ssize_t) argc) 04479 ThrowMogrifyException(OptionError,"MissingArgument",option); 04480 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); 04481 if (endian < 0) 04482 ThrowMogrifyException(OptionError,"UnrecognizedEndianType", 04483 argv[i]); 04484 break; 04485 } 04486 if (LocaleCompare("enhance",option+1) == 0) 04487 break; 04488 if (LocaleCompare("equalize",option+1) == 0) 04489 break; 04490 if (LocaleCompare("evaluate",option+1) == 0) 04491 { 04492 ssize_t 04493 op; 04494 04495 if (*option == '+') 04496 break; 04497 i++; 04498 if (i == (ssize_t) argc) 04499 ThrowMogrifyException(OptionError,"MissingArgument",option); 04500 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); 04501 if (op < 0) 04502 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", 04503 argv[i]); 04504 i++; 04505 if (i == (ssize_t) (argc-1)) 04506 ThrowMogrifyException(OptionError,"MissingArgument",option); 04507 if (IsGeometry(argv[i]) == MagickFalse) 04508 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04509 break; 04510 } 04511 if (LocaleCompare("evaluate-sequence",option+1) == 0) 04512 { 04513 ssize_t 04514 op; 04515 04516 if (*option == '+') 04517 break; 04518 i++; 04519 if (i == (ssize_t) argc) 04520 ThrowMogrifyException(OptionError,"MissingArgument",option); 04521 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); 04522 if (op < 0) 04523 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", 04524 argv[i]); 04525 break; 04526 } 04527 if (LocaleCompare("extent",option+1) == 0) 04528 { 04529 if (*option == '+') 04530 break; 04531 i++; 04532 if (i == (ssize_t) argc) 04533 ThrowMogrifyException(OptionError,"MissingArgument",option); 04534 if (IsGeometry(argv[i]) == MagickFalse) 04535 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04536 break; 04537 } 04538 if (LocaleCompare("extract",option+1) == 0) 04539 { 04540 if (*option == '+') 04541 break; 04542 i++; 04543 if (i == (ssize_t) argc) 04544 ThrowMogrifyException(OptionError,"MissingArgument",option); 04545 if (IsGeometry(argv[i]) == MagickFalse) 04546 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04547 break; 04548 } 04549 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 04550 } 04551 case 'f': 04552 { 04553 if (LocaleCompare("family",option+1) == 0) 04554 { 04555 if (*option == '+') 04556 break; 04557 i++; 04558 if (i == (ssize_t) (argc-1)) 04559 ThrowMogrifyException(OptionError,"MissingArgument",option); 04560 break; 04561 } 04562 if (LocaleCompare("fill",option+1) == 0) 04563 { 04564 if (*option == '+') 04565 break; 04566 i++; 04567 if (i == (ssize_t) argc) 04568 ThrowMogrifyException(OptionError,"MissingArgument",option); 04569 break; 04570 } 04571 if (LocaleCompare("filter",option+1) == 0) 04572 { 04573 ssize_t 04574 filter; 04575 04576 if (*option == '+') 04577 break; 04578 i++; 04579 if (i == (ssize_t) argc) 04580 ThrowMogrifyException(OptionError,"MissingArgument",option); 04581 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); 04582 if (filter < 0) 04583 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", 04584 argv[i]); 04585 break; 04586 } 04587 if (LocaleCompare("flatten",option+1) == 0) 04588 break; 04589 if (LocaleCompare("flip",option+1) == 0) 04590 break; 04591 if (LocaleCompare("flop",option+1) == 0) 04592 break; 04593 if (LocaleCompare("floodfill",option+1) == 0) 04594 { 04595 if (*option == '+') 04596 break; 04597 i++; 04598 if (i == (ssize_t) argc) 04599 ThrowMogrifyException(OptionError,"MissingArgument",option); 04600 if (IsGeometry(argv[i]) == MagickFalse) 04601 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04602 i++; 04603 if (i == (ssize_t) argc) 04604 ThrowMogrifyException(OptionError,"MissingArgument",option); 04605 break; 04606 } 04607 if (LocaleCompare("font",option+1) == 0) 04608 { 04609 if (*option == '+') 04610 break; 04611 i++; 04612 if (i == (ssize_t) argc) 04613 ThrowMogrifyException(OptionError,"MissingArgument",option); 04614 break; 04615 } 04616 if (LocaleCompare("format",option+1) == 0) 04617 { 04618 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); 04619 (void) CloneString(&format,(char *) NULL); 04620 if (*option == '+') 04621 break; 04622 i++; 04623 if (i == (ssize_t) argc) 04624 ThrowMogrifyException(OptionError,"MissingArgument",option); 04625 (void) CloneString(&format,argv[i]); 04626 (void) CopyMagickString(image_info->filename,format,MaxTextExtent); 04627 (void) ConcatenateMagickString(image_info->filename,":", 04628 MaxTextExtent); 04629 (void) SetImageInfo(image_info,0,exception); 04630 if (*image_info->magick == '\0') 04631 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", 04632 format); 04633 break; 04634 } 04635 if (LocaleCompare("frame",option+1) == 0) 04636 { 04637 if (*option == '+') 04638 break; 04639 i++; 04640 if (i == (ssize_t) argc) 04641 ThrowMogrifyException(OptionError,"MissingArgument",option); 04642 if (IsGeometry(argv[i]) == MagickFalse) 04643 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04644 break; 04645 } 04646 if (LocaleCompare("function",option+1) == 0) 04647 { 04648 ssize_t 04649 op; 04650 04651 if (*option == '+') 04652 break; 04653 i++; 04654 if (i == (ssize_t) argc) 04655 ThrowMogrifyException(OptionError,"MissingArgument",option); 04656 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); 04657 if (op < 0) 04658 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); 04659 i++; 04660 if (i == (ssize_t) (argc-1)) 04661 ThrowMogrifyException(OptionError,"MissingArgument",option); 04662 break; 04663 } 04664 if (LocaleCompare("fuzz",option+1) == 0) 04665 { 04666 if (*option == '+') 04667 break; 04668 i++; 04669 if (i == (ssize_t) argc) 04670 ThrowMogrifyException(OptionError,"MissingArgument",option); 04671 if (IsGeometry(argv[i]) == MagickFalse) 04672 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04673 break; 04674 } 04675 if (LocaleCompare("fx",option+1) == 0) 04676 { 04677 if (*option == '+') 04678 break; 04679 i++; 04680 if (i == (ssize_t) (argc-1)) 04681 ThrowMogrifyException(OptionError,"MissingArgument",option); 04682 break; 04683 } 04684 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 04685 } 04686 case 'g': 04687 { 04688 if (LocaleCompare("gamma",option+1) == 0) 04689 { 04690 i++; 04691 if (i == (ssize_t) argc) 04692 ThrowMogrifyException(OptionError,"MissingArgument",option); 04693 if (IsGeometry(argv[i]) == MagickFalse) 04694 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04695 break; 04696 } 04697 if ((LocaleCompare("gaussian-blur",option+1) == 0) || 04698 (LocaleCompare("gaussian",option+1) == 0)) 04699 { 04700 i++; 04701 if (i == (ssize_t) argc) 04702 ThrowMogrifyException(OptionError,"MissingArgument",option); 04703 if (IsGeometry(argv[i]) == MagickFalse) 04704 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04705 break; 04706 } 04707 if (LocaleCompare("geometry",option+1) == 0) 04708 { 04709 if (*option == '+') 04710 break; 04711 i++; 04712 if (i == (ssize_t) argc) 04713 ThrowMogrifyException(OptionError,"MissingArgument",option); 04714 if (IsGeometry(argv[i]) == MagickFalse) 04715 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04716 break; 04717 } 04718 if (LocaleCompare("gravity",option+1) == 0) 04719 { 04720 ssize_t 04721 gravity; 04722 04723 if (*option == '+') 04724 break; 04725 i++; 04726 if (i == (ssize_t) argc) 04727 ThrowMogrifyException(OptionError,"MissingArgument",option); 04728 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); 04729 if (gravity < 0) 04730 ThrowMogrifyException(OptionError,"UnrecognizedGravityType", 04731 argv[i]); 04732 break; 04733 } 04734 if (LocaleCompare("green-primary",option+1) == 0) 04735 { 04736 if (*option == '+') 04737 break; 04738 i++; 04739 if (i == (ssize_t) argc) 04740 ThrowMogrifyException(OptionError,"MissingArgument",option); 04741 if (IsGeometry(argv[i]) == MagickFalse) 04742 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04743 break; 04744 } 04745 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 04746 } 04747 case 'h': 04748 { 04749 if (LocaleCompare("hald-clut",option+1) == 0) 04750 break; 04751 if ((LocaleCompare("help",option+1) == 0) || 04752 (LocaleCompare("-help",option+1) == 0)) 04753 return(MogrifyUsage()); 04754 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 04755 } 04756 case 'i': 04757 { 04758 if (LocaleCompare("identify",option+1) == 0) 04759 break; 04760 if (LocaleCompare("idft",option+1) == 0) 04761 break; 04762 if (LocaleCompare("implode",option+1) == 0) 04763 { 04764 if (*option == '+') 04765 break; 04766 i++; 04767 if (i == (ssize_t) argc) 04768 ThrowMogrifyException(OptionError,"MissingArgument",option); 04769 if (IsGeometry(argv[i]) == MagickFalse) 04770 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04771 break; 04772 } 04773 if (LocaleCompare("intent",option+1) == 0) 04774 { 04775 ssize_t 04776 intent; 04777 04778 if (*option == '+') 04779 break; 04780 i++; 04781 if (i == (ssize_t) (argc-1)) 04782 ThrowMogrifyException(OptionError,"MissingArgument",option); 04783 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); 04784 if (intent < 0) 04785 ThrowMogrifyException(OptionError,"UnrecognizedIntentType", 04786 argv[i]); 04787 break; 04788 } 04789 if (LocaleCompare("interlace",option+1) == 0) 04790 { 04791 ssize_t 04792 interlace; 04793 04794 if (*option == '+') 04795 break; 04796 i++; 04797 if (i == (ssize_t) argc) 04798 ThrowMogrifyException(OptionError,"MissingArgument",option); 04799 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, 04800 argv[i]); 04801 if (interlace < 0) 04802 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", 04803 argv[i]); 04804 break; 04805 } 04806 if (LocaleCompare("interline-spacing",option+1) == 0) 04807 { 04808 if (*option == '+') 04809 break; 04810 i++; 04811 if (i == (ssize_t) (argc-1)) 04812 ThrowMogrifyException(OptionError,"MissingArgument",option); 04813 if (IsGeometry(argv[i]) == MagickFalse) 04814 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04815 break; 04816 } 04817 if (LocaleCompare("interpolate",option+1) == 0) 04818 { 04819 ssize_t 04820 interpolate; 04821 04822 if (*option == '+') 04823 break; 04824 i++; 04825 if (i == (ssize_t) argc) 04826 ThrowMogrifyException(OptionError,"MissingArgument",option); 04827 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, 04828 argv[i]); 04829 if (interpolate < 0) 04830 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", 04831 argv[i]); 04832 break; 04833 } 04834 if (LocaleCompare("interword-spacing",option+1) == 0) 04835 { 04836 if (*option == '+') 04837 break; 04838 i++; 04839 if (i == (ssize_t) (argc-1)) 04840 ThrowMogrifyException(OptionError,"MissingArgument",option); 04841 if (IsGeometry(argv[i]) == MagickFalse) 04842 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04843 break; 04844 } 04845 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 04846 } 04847 case 'k': 04848 { 04849 if (LocaleCompare("kerning",option+1) == 0) 04850 { 04851 if (*option == '+') 04852 break; 04853 i++; 04854 if (i == (ssize_t) (argc-1)) 04855 ThrowMogrifyException(OptionError,"MissingArgument",option); 04856 if (IsGeometry(argv[i]) == MagickFalse) 04857 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04858 break; 04859 } 04860 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 04861 } 04862 case 'l': 04863 { 04864 if (LocaleCompare("label",option+1) == 0) 04865 { 04866 if (*option == '+') 04867 break; 04868 i++; 04869 if (i == (ssize_t) argc) 04870 ThrowMogrifyException(OptionError,"MissingArgument",option); 04871 break; 04872 } 04873 if (LocaleCompare("lat",option+1) == 0) 04874 { 04875 if (*option == '+') 04876 break; 04877 i++; 04878 if (i == (ssize_t) argc) 04879 ThrowMogrifyException(OptionError,"MissingArgument",option); 04880 if (IsGeometry(argv[i]) == MagickFalse) 04881 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04882 } 04883 if (LocaleCompare("layers",option+1) == 0) 04884 { 04885 ssize_t 04886 type; 04887 04888 if (*option == '+') 04889 break; 04890 i++; 04891 if (i == (ssize_t) (argc-1)) 04892 ThrowMogrifyException(OptionError,"MissingArgument",option); 04893 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); 04894 if (type < 0) 04895 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", 04896 argv[i]); 04897 break; 04898 } 04899 if (LocaleCompare("level",option+1) == 0) 04900 { 04901 i++; 04902 if (i == (ssize_t) argc) 04903 ThrowMogrifyException(OptionError,"MissingArgument",option); 04904 if (IsGeometry(argv[i]) == MagickFalse) 04905 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04906 break; 04907 } 04908 if (LocaleCompare("level-colors",option+1) == 0) 04909 { 04910 i++; 04911 if (i == (ssize_t) argc) 04912 ThrowMogrifyException(OptionError,"MissingArgument",option); 04913 break; 04914 } 04915 if (LocaleCompare("limit",option+1) == 0) 04916 { 04917 char 04918 *p; 04919 04920 double 04921 value; 04922 04923 ssize_t 04924 resource; 04925 04926 if (*option == '+') 04927 break; 04928 i++; 04929 if (i == (ssize_t) argc) 04930 ThrowMogrifyException(OptionError,"MissingArgument",option); 04931 resource=ParseCommandOption(MagickResourceOptions,MagickFalse, 04932 argv[i]); 04933 if (resource < 0) 04934 ThrowMogrifyException(OptionError,"UnrecognizedResourceType", 04935 argv[i]); 04936 i++; 04937 if (i == (ssize_t) argc) 04938 ThrowMogrifyException(OptionError,"MissingArgument",option); 04939 value=StringToDouble(argv[i],&p); 04940 (void) value; 04941 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) 04942 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04943 break; 04944 } 04945 if (LocaleCompare("liquid-rescale",option+1) == 0) 04946 { 04947 i++; 04948 if (i == (ssize_t) argc) 04949 ThrowMogrifyException(OptionError,"MissingArgument",option); 04950 if (IsGeometry(argv[i]) == MagickFalse) 04951 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04952 break; 04953 } 04954 if (LocaleCompare("list",option+1) == 0) 04955 { 04956 ssize_t 04957 list; 04958 04959 if (*option == '+') 04960 break; 04961 i++; 04962 if (i == (ssize_t) argc) 04963 ThrowMogrifyException(OptionError,"MissingArgument",option); 04964 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); 04965 if (list < 0) 04966 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); 04967 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) 04968 argv+j,exception); 04969 return(status != 0 ? MagickFalse : MagickTrue); 04970 } 04971 if (LocaleCompare("log",option+1) == 0) 04972 { 04973 if (*option == '+') 04974 break; 04975 i++; 04976 if ((i == (ssize_t) argc) || 04977 (strchr(argv[i],'%') == (char *) NULL)) 04978 ThrowMogrifyException(OptionError,"MissingArgument",option); 04979 break; 04980 } 04981 if (LocaleCompare("loop",option+1) == 0) 04982 { 04983 if (*option == '+') 04984 break; 04985 i++; 04986 if (i == (ssize_t) argc) 04987 ThrowMogrifyException(OptionError,"MissingArgument",option); 04988 if (IsGeometry(argv[i]) == MagickFalse) 04989 ThrowMogrifyInvalidArgumentException(option,argv[i]); 04990 break; 04991 } 04992 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 04993 } 04994 case 'm': 04995 { 04996 if (LocaleCompare("map",option+1) == 0) 04997 { 04998 global_colormap=(*option == '+') ? MagickTrue : MagickFalse; 04999 if (*option == '+') 05000 break; 05001 i++; 05002 if (i == (ssize_t) argc) 05003 ThrowMogrifyException(OptionError,"MissingArgument",option); 05004 break; 05005 } 05006 if (LocaleCompare("mask",option+1) == 0) 05007 { 05008 if (*option == '+') 05009 break; 05010 i++; 05011 if (i == (ssize_t) argc) 05012 ThrowMogrifyException(OptionError,"MissingArgument",option); 05013 break; 05014 } 05015 if (LocaleCompare("matte",option+1) == 0) 05016 break; 05017 if (LocaleCompare("mattecolor",option+1) == 0) 05018 { 05019 if (*option == '+') 05020 break; 05021 i++; 05022 if (i == (ssize_t) argc) 05023 ThrowMogrifyException(OptionError,"MissingArgument",option); 05024 break; 05025 } 05026 if (LocaleCompare("maximum",option+1) == 0) 05027 break; 05028 if (LocaleCompare("minimum",option+1) == 0) 05029 break; 05030 if (LocaleCompare("modulate",option+1) == 0) 05031 { 05032 if (*option == '+') 05033 break; 05034 i++; 05035 if (i == (ssize_t) argc) 05036 ThrowMogrifyException(OptionError,"MissingArgument",option); 05037 if (IsGeometry(argv[i]) == MagickFalse) 05038 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05039 break; 05040 } 05041 if (LocaleCompare("median",option+1) == 0) 05042 { 05043 if (*option == '+') 05044 break; 05045 i++; 05046 if (i == (ssize_t) argc) 05047 ThrowMogrifyException(OptionError,"MissingArgument",option); 05048 if (IsGeometry(argv[i]) == MagickFalse) 05049 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05050 break; 05051 } 05052 if (LocaleCompare("mode",option+1) == 0) 05053 { 05054 if (*option == '+') 05055 break; 05056 i++; 05057 if (i == (ssize_t) argc) 05058 ThrowMogrifyException(OptionError,"MissingArgument",option); 05059 if (IsGeometry(argv[i]) == MagickFalse) 05060 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05061 break; 05062 } 05063 if (LocaleCompare("monitor",option+1) == 0) 05064 break; 05065 if (LocaleCompare("monochrome",option+1) == 0) 05066 break; 05067 if (LocaleCompare("morph",option+1) == 0) 05068 { 05069 if (*option == '+') 05070 break; 05071 i++; 05072 if (i == (ssize_t) (argc-1)) 05073 ThrowMogrifyException(OptionError,"MissingArgument",option); 05074 if (IsGeometry(argv[i]) == MagickFalse) 05075 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05076 break; 05077 } 05078 if (LocaleCompare("morphology",option+1) == 0) 05079 { 05080 char 05081 token[MaxTextExtent]; 05082 05083 KernelInfo 05084 *kernel_info; 05085 05086 ssize_t 05087 op; 05088 05089 i++; 05090 if (i == (ssize_t) argc) 05091 ThrowMogrifyException(OptionError,"MissingArgument",option); 05092 GetMagickToken(argv[i],NULL,token); 05093 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); 05094 if (op < 0) 05095 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", 05096 token); 05097 i++; 05098 if (i == (ssize_t) (argc-1)) 05099 ThrowMogrifyException(OptionError,"MissingArgument",option); 05100 kernel_info=AcquireKernelInfo(argv[i]); 05101 if (kernel_info == (KernelInfo *) NULL) 05102 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05103 kernel_info=DestroyKernelInfo(kernel_info); 05104 break; 05105 } 05106 if (LocaleCompare("mosaic",option+1) == 0) 05107 break; 05108 if (LocaleCompare("motion-blur",option+1) == 0) 05109 { 05110 if (*option == '+') 05111 break; 05112 i++; 05113 if (i == (ssize_t) argc) 05114 ThrowMogrifyException(OptionError,"MissingArgument",option); 05115 if (IsGeometry(argv[i]) == MagickFalse) 05116 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05117 break; 05118 } 05119 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 05120 } 05121 case 'n': 05122 { 05123 if (LocaleCompare("negate",option+1) == 0) 05124 break; 05125 if (LocaleCompare("noise",option+1) == 0) 05126 { 05127 i++; 05128 if (i == (ssize_t) argc) 05129 ThrowMogrifyException(OptionError,"MissingArgument",option); 05130 if (*option == '+') 05131 { 05132 ssize_t 05133 noise; 05134 05135 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); 05136 if (noise < 0) 05137 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", 05138 argv[i]); 05139 break; 05140 } 05141 if (IsGeometry(argv[i]) == MagickFalse) 05142 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05143 break; 05144 } 05145 if (LocaleCompare("noop",option+1) == 0) 05146 break; 05147 if (LocaleCompare("normalize",option+1) == 0) 05148 break; 05149 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 05150 } 05151 case 'o': 05152 { 05153 if (LocaleCompare("opaque",option+1) == 0) 05154 { 05155 i++; 05156 if (i == (ssize_t) argc) 05157 ThrowMogrifyException(OptionError,"MissingArgument",option); 05158 break; 05159 } 05160 if (LocaleCompare("ordered-dither",option+1) == 0) 05161 { 05162 if (*option == '+') 05163 break; 05164 i++; 05165 if (i == (ssize_t) argc) 05166 ThrowMogrifyException(OptionError,"MissingArgument",option); 05167 break; 05168 } 05169 if (LocaleCompare("orient",option+1) == 0) 05170 { 05171 ssize_t 05172 orientation; 05173 05174 orientation=UndefinedOrientation; 05175 if (*option == '+') 05176 break; 05177 i++; 05178 if (i == (ssize_t) (argc-1)) 05179 ThrowMogrifyException(OptionError,"MissingArgument",option); 05180 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, 05181 argv[i]); 05182 if (orientation < 0) 05183 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", 05184 argv[i]); 05185 break; 05186 } 05187 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 05188 } 05189 case 'p': 05190 { 05191 if (LocaleCompare("page",option+1) == 0) 05192 { 05193 if (*option == '+') 05194 break; 05195 i++; 05196 if (i == (ssize_t) argc) 05197 ThrowMogrifyException(OptionError,"MissingArgument",option); 05198 break; 05199 } 05200 if (LocaleCompare("paint",option+1) == 0) 05201 { 05202 if (*option == '+') 05203 break; 05204 i++; 05205 if (i == (ssize_t) argc) 05206 ThrowMogrifyException(OptionError,"MissingArgument",option); 05207 if (IsGeometry(argv[i]) == MagickFalse) 05208 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05209 break; 05210 } 05211 if (LocaleCompare("path",option+1) == 0) 05212 { 05213 (void) CloneString(&path,(char *) NULL); 05214 if (*option == '+') 05215 break; 05216 i++; 05217 if (i == (ssize_t) argc) 05218 ThrowMogrifyException(OptionError,"MissingArgument",option); 05219 (void) CloneString(&path,argv[i]); 05220 break; 05221 } 05222 if (LocaleCompare("pointsize",option+1) == 0) 05223 { 05224 if (*option == '+') 05225 break; 05226 i++; 05227 if (i == (ssize_t) argc) 05228 ThrowMogrifyException(OptionError,"MissingArgument",option); 05229 if (IsGeometry(argv[i]) == MagickFalse) 05230 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05231 break; 05232 } 05233 if (LocaleCompare("polaroid",option+1) == 0) 05234 { 05235 if (*option == '+') 05236 break; 05237 i++; 05238 if (i == (ssize_t) argc) 05239 ThrowMogrifyException(OptionError,"MissingArgument",option); 05240 if (IsGeometry(argv[i]) == MagickFalse) 05241 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05242 break; 05243 } 05244 if (LocaleCompare("posterize",option+1) == 0) 05245 { 05246 if (*option == '+') 05247 break; 05248 i++; 05249 if (i == (ssize_t) argc) 05250 ThrowMogrifyException(OptionError,"MissingArgument",option); 05251 if (IsGeometry(argv[i]) == MagickFalse) 05252 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05253 break; 05254 } 05255 if (LocaleCompare("precision",option+1) == 0) 05256 { 05257 if (*option == '+') 05258 break; 05259 i++; 05260 if (i == (ssize_t) argc) 05261 ThrowMogrifyException(OptionError,"MissingArgument",option); 05262 if (IsGeometry(argv[i]) == MagickFalse) 05263 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05264 break; 05265 } 05266 if (LocaleCompare("print",option+1) == 0) 05267 { 05268 if (*option == '+') 05269 break; 05270 i++; 05271 if (i == (ssize_t) argc) 05272 ThrowMogrifyException(OptionError,"MissingArgument",option); 05273 break; 05274 } 05275 if (LocaleCompare("process",option+1) == 0) 05276 { 05277 if (*option == '+') 05278 break; 05279 i++; 05280 if (i == (ssize_t) (argc-1)) 05281 ThrowMogrifyException(OptionError,"MissingArgument",option); 05282 break; 05283 } 05284 if (LocaleCompare("profile",option+1) == 0) 05285 { 05286 i++; 05287 if (i == (ssize_t) argc) 05288 ThrowMogrifyException(OptionError,"MissingArgument",option); 05289 break; 05290 } 05291 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 05292 } 05293 case 'q': 05294 { 05295 if (LocaleCompare("quality",option+1) == 0) 05296 { 05297 if (*option == '+') 05298 break; 05299 i++; 05300 if (i == (ssize_t) argc) 05301 ThrowMogrifyException(OptionError,"MissingArgument",option); 05302 if (IsGeometry(argv[i]) == MagickFalse) 05303 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05304 break; 05305 } 05306 if (LocaleCompare("quantize",option+1) == 0) 05307 { 05308 ssize_t 05309 colorspace; 05310 05311 if (*option == '+') 05312 break; 05313 i++; 05314 if (i == (ssize_t) (argc-1)) 05315 ThrowMogrifyException(OptionError,"MissingArgument",option); 05316 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, 05317 argv[i]); 05318 if (colorspace < 0) 05319 ThrowMogrifyException(OptionError,"UnrecognizedColorspace", 05320 argv[i]); 05321 break; 05322 } 05323 if (LocaleCompare("quiet",option+1) == 0) 05324 break; 05325 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 05326 } 05327 case 'r': 05328 { 05329 if (LocaleCompare("radial-blur",option+1) == 0) 05330 { 05331 i++; 05332 if (i == (ssize_t) argc) 05333 ThrowMogrifyException(OptionError,"MissingArgument",option); 05334 if (IsGeometry(argv[i]) == MagickFalse) 05335 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05336 break; 05337 } 05338 if (LocaleCompare("raise",option+1) == 0) 05339 { 05340 i++; 05341 if (i == (ssize_t) argc) 05342 ThrowMogrifyException(OptionError,"MissingArgument",option); 05343 if (IsGeometry(argv[i]) == MagickFalse) 05344 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05345 break; 05346 } 05347 if (LocaleCompare("random-threshold",option+1) == 0) 05348 { 05349 if (*option == '+') 05350 break; 05351 i++; 05352 if (i == (ssize_t) argc) 05353 ThrowMogrifyException(OptionError,"MissingArgument",option); 05354 if (IsGeometry(argv[i]) == MagickFalse) 05355 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05356 break; 05357 } 05358 if (LocaleCompare("red-primary",option+1) == 0) 05359 { 05360 if (*option == '+') 05361 break; 05362 i++; 05363 if (i == (ssize_t) argc) 05364 ThrowMogrifyException(OptionError,"MissingArgument",option); 05365 if (IsGeometry(argv[i]) == MagickFalse) 05366 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05367 } 05368 if (LocaleCompare("regard-warnings",option+1) == 0) 05369 break; 05370 if (LocaleCompare("region",option+1) == 0) 05371 { 05372 if (*option == '+') 05373 break; 05374 i++; 05375 if (i == (ssize_t) argc) 05376 ThrowMogrifyException(OptionError,"MissingArgument",option); 05377 if (IsGeometry(argv[i]) == MagickFalse) 05378 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05379 break; 05380 } 05381 if (LocaleCompare("remap",option+1) == 0) 05382 { 05383 if (*option == '+') 05384 break; 05385 i++; 05386 if (i == (ssize_t) (argc-1)) 05387 ThrowMogrifyException(OptionError,"MissingArgument",option); 05388 break; 05389 } 05390 if (LocaleCompare("render",option+1) == 0) 05391 break; 05392 if (LocaleCompare("repage",option+1) == 0) 05393 { 05394 if (*option == '+') 05395 break; 05396 i++; 05397 if (i == (ssize_t) argc) 05398 ThrowMogrifyException(OptionError,"MissingArgument",option); 05399 if (IsGeometry(argv[i]) == MagickFalse) 05400 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05401 break; 05402 } 05403 if (LocaleCompare("resample",option+1) == 0) 05404 { 05405 if (*option == '+') 05406 break; 05407 i++; 05408 if (i == (ssize_t) argc) 05409 ThrowMogrifyException(OptionError,"MissingArgument",option); 05410 if (IsGeometry(argv[i]) == MagickFalse) 05411 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05412 break; 05413 } 05414 if (LocaleCompare("resize",option+1) == 0) 05415 { 05416 if (*option == '+') 05417 break; 05418 i++; 05419 if (i == (ssize_t) argc) 05420 ThrowMogrifyException(OptionError,"MissingArgument",option); 05421 if (IsGeometry(argv[i]) == MagickFalse) 05422 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05423 break; 05424 } 05425 if (LocaleNCompare("respect-parentheses",option+1,17) == 0) 05426 { 05427 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; 05428 break; 05429 } 05430 if (LocaleCompare("reverse",option+1) == 0) 05431 break; 05432 if (LocaleCompare("roll",option+1) == 0) 05433 { 05434 if (*option == '+') 05435 break; 05436 i++; 05437 if (i == (ssize_t) argc) 05438 ThrowMogrifyException(OptionError,"MissingArgument",option); 05439 if (IsGeometry(argv[i]) == MagickFalse) 05440 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05441 break; 05442 } 05443 if (LocaleCompare("rotate",option+1) == 0) 05444 { 05445 i++; 05446 if (i == (ssize_t) argc) 05447 ThrowMogrifyException(OptionError,"MissingArgument",option); 05448 if (IsGeometry(argv[i]) == MagickFalse) 05449 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05450 break; 05451 } 05452 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 05453 } 05454 case 's': 05455 { 05456 if (LocaleCompare("sample",option+1) == 0) 05457 { 05458 if (*option == '+') 05459 break; 05460 i++; 05461 if (i == (ssize_t) argc) 05462 ThrowMogrifyException(OptionError,"MissingArgument",option); 05463 if (IsGeometry(argv[i]) == MagickFalse) 05464 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05465 break; 05466 } 05467 if (LocaleCompare("sampling-factor",option+1) == 0) 05468 { 05469 if (*option == '+') 05470 break; 05471 i++; 05472 if (i == (ssize_t) argc) 05473 ThrowMogrifyException(OptionError,"MissingArgument",option); 05474 if (IsGeometry(argv[i]) == MagickFalse) 05475 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05476 break; 05477 } 05478 if (LocaleCompare("scale",option+1) == 0) 05479 { 05480 if (*option == '+') 05481 break; 05482 i++; 05483 if (i == (ssize_t) argc) 05484 ThrowMogrifyException(OptionError,"MissingArgument",option); 05485 if (IsGeometry(argv[i]) == MagickFalse) 05486 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05487 break; 05488 } 05489 if (LocaleCompare("scene",option+1) == 0) 05490 { 05491 if (*option == '+') 05492 break; 05493 i++; 05494 if (i == (ssize_t) argc) 05495 ThrowMogrifyException(OptionError,"MissingArgument",option); 05496 if (IsGeometry(argv[i]) == MagickFalse) 05497 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05498 break; 05499 } 05500 if (LocaleCompare("seed",option+1) == 0) 05501 { 05502 if (*option == '+') 05503 break; 05504 i++; 05505 if (i == (ssize_t) argc) 05506 ThrowMogrifyException(OptionError,"MissingArgument",option); 05507 if (IsGeometry(argv[i]) == MagickFalse) 05508 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05509 break; 05510 } 05511 if (LocaleCompare("segment",option+1) == 0) 05512 { 05513 if (*option == '+') 05514 break; 05515 i++; 05516 if (i == (ssize_t) argc) 05517 ThrowMogrifyException(OptionError,"MissingArgument",option); 05518 if (IsGeometry(argv[i]) == MagickFalse) 05519 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05520 break; 05521 } 05522 if (LocaleCompare("selective-blur",option+1) == 0) 05523 { 05524 i++; 05525 if (i == (ssize_t) argc) 05526 ThrowMogrifyException(OptionError,"MissingArgument",option); 05527 if (IsGeometry(argv[i]) == MagickFalse) 05528 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05529 break; 05530 } 05531 if (LocaleCompare("separate",option+1) == 0) 05532 break; 05533 if (LocaleCompare("sepia-tone",option+1) == 0) 05534 { 05535 if (*option == '+') 05536 break; 05537 i++; 05538 if (i == (ssize_t) argc) 05539 ThrowMogrifyException(OptionError,"MissingArgument",option); 05540 if (IsGeometry(argv[i]) == MagickFalse) 05541 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05542 break; 05543 } 05544 if (LocaleCompare("set",option+1) == 0) 05545 { 05546 i++; 05547 if (i == (ssize_t) argc) 05548 ThrowMogrifyException(OptionError,"MissingArgument",option); 05549 if (*option == '+') 05550 break; 05551 i++; 05552 if (i == (ssize_t) argc) 05553 ThrowMogrifyException(OptionError,"MissingArgument",option); 05554 break; 05555 } 05556 if (LocaleCompare("shade",option+1) == 0) 05557 { 05558 i++; 05559 if (i == (ssize_t) argc) 05560 ThrowMogrifyException(OptionError,"MissingArgument",option); 05561 if (IsGeometry(argv[i]) == MagickFalse) 05562 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05563 break; 05564 } 05565 if (LocaleCompare("shadow",option+1) == 0) 05566 { 05567 if (*option == '+') 05568 break; 05569 i++; 05570 if (i == (ssize_t) argc) 05571 ThrowMogrifyException(OptionError,"MissingArgument",option); 05572 if (IsGeometry(argv[i]) == MagickFalse) 05573 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05574 break; 05575 } 05576 if (LocaleCompare("sharpen",option+1) == 0) 05577 { 05578 i++; 05579 if (i == (ssize_t) argc) 05580 ThrowMogrifyException(OptionError,"MissingArgument",option); 05581 if (IsGeometry(argv[i]) == MagickFalse) 05582 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05583 break; 05584 } 05585 if (LocaleCompare("shave",option+1) == 0) 05586 { 05587 if (*option == '+') 05588 break; 05589 i++; 05590 if (i == (ssize_t) argc) 05591 ThrowMogrifyException(OptionError,"MissingArgument",option); 05592 if (IsGeometry(argv[i]) == MagickFalse) 05593 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05594 break; 05595 } 05596 if (LocaleCompare("shear",option+1) == 0) 05597 { 05598 i++; 05599 if (i == (ssize_t) argc) 05600 ThrowMogrifyException(OptionError,"MissingArgument",option); 05601 if (IsGeometry(argv[i]) == MagickFalse) 05602 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05603 break; 05604 } 05605 if (LocaleCompare("sigmoidal-contrast",option+1) == 0) 05606 { 05607 i++; 05608 if (i == (ssize_t) (argc-1)) 05609 ThrowMogrifyException(OptionError,"MissingArgument",option); 05610 if (IsGeometry(argv[i]) == MagickFalse) 05611 ThrowMogrifyInvalidArgumentException(option,argv[i]); 05612 break; 05613 } 05614 if (LocaleCompare("size",option+1) == 0) 05615 { 05616 if (*option == '+') 05617 break; 05618 i++;