cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % M M OOO GGGGG RRRR IIIII FFFFF Y Y % |
| 7 | % MM MM O O G R R I F Y Y % |
| 8 | % M M M O O G GGG RRRR I FFF Y % |
| 9 | % M M O O G G R R I F Y % |
| 10 | % M M OOO GGGG R R IIIII F Y % |
| 11 | % % |
| 12 | % % |
| 13 | % MagickWand Module Methods % |
| 14 | % % |
| 15 | % Software Design % |
| 16 | % John Cristy % |
| 17 | % March 2000 % |
| 18 | % % |
| 19 | % % |
cristy | 1454be7 | 2011-12-19 01:52:48 +0000 | [diff] [blame^] | 20 | % Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 21 | % dedicated to making software imaging solutions freely available. % |
| 22 | % % |
| 23 | % You may not use this file except in compliance with the License. You may % |
| 24 | % obtain a copy of the License at % |
| 25 | % % |
| 26 | % http://www.imagemagick.org/script/license.php % |
| 27 | % % |
| 28 | % Unless required by applicable law or agreed to in writing, software % |
| 29 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 30 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 31 | % See the License for the specific language governing permissions and % |
| 32 | % limitations under the License. % |
| 33 | % % |
| 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 35 | % |
| 36 | % Use the mogrify program to resize an image, blur, crop, despeckle, dither, |
| 37 | % draw on, flip, join, re-sample, and much more. This tool is similiar to |
| 38 | % convert except that the original image file is overwritten (unless you |
| 39 | % change the file suffix with the -format option) with any changes you |
cristy | 6a917d9 | 2009-10-06 19:23:54 +0000 | [diff] [blame] | 40 | % request. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 41 | % |
| 42 | */ |
| 43 | |
| 44 | /* |
| 45 | Include declarations. |
| 46 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 47 | #include "MagickWand/studio.h" |
| 48 | #include "MagickWand/MagickWand.h" |
| 49 | #include "MagickWand/mogrify-private.h" |
| 50 | #undef DegreesToRadians |
| 51 | #undef RadiansToDegrees |
| 52 | #include "MagickCore/image-private.h" |
| 53 | #include "MagickCore/monitor-private.h" |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 54 | #include "MagickCore/string-private.h" |
cristy | 0740a98 | 2011-10-13 15:01:01 +0000 | [diff] [blame] | 55 | #include "MagickCore/thread-private.h" |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 56 | #include "MagickCore/utility-private.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 57 | |
| 58 | /* |
cristy | 154fa9d | 2011-08-05 14:25:15 +0000 | [diff] [blame] | 59 | Constant declaration. |
| 60 | */ |
cristy | 3a557c0 | 2011-08-06 19:48:02 +0000 | [diff] [blame] | 61 | static const char |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 62 | MogrifyBackgroundColor[] = "#ffffff", /* white */ |
| 63 | MogrifyBorderColor[] = "#dfdfdf", /* gray */ |
| 64 | MogrifyMatteColor[] = "#bdbdbd"; /* gray */ |
cristy | 154fa9d | 2011-08-05 14:25:15 +0000 | [diff] [blame] | 65 | |
| 66 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 67 | Define declarations. |
| 68 | */ |
| 69 | #define UndefinedCompressionQuality 0UL |
| 70 | |
| 71 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 72 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 73 | % % |
| 74 | % % |
| 75 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 76 | % M a g i c k C o m m a n d G e n e s i s % |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 77 | % % |
| 78 | % % |
| 79 | % % |
| 80 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 81 | % |
| 82 | % MagickCommandGenesis() applies image processing options to an image as |
| 83 | % prescribed by command line options. |
| 84 | % |
| 85 | % The format of the MagickCommandGenesis method is: |
| 86 | % |
| 87 | % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 88 | % MagickCommand command,int argc,char **argv,char **metadata, |
| 89 | % ExceptionInfo *exception) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 90 | % |
| 91 | % A description of each parameter follows: |
| 92 | % |
| 93 | % o image_info: the image info. |
| 94 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 95 | % o command: Choose from ConvertImageCommand, IdentifyImageCommand, |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 96 | % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 97 | % ConjureImageCommand, StreamImageCommand, ImportImageCommand, |
| 98 | % DisplayImageCommand, or AnimateImageCommand. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 99 | % |
| 100 | % o argc: Specifies a pointer to an integer describing the number of |
| 101 | % elements in the argument vector. |
| 102 | % |
| 103 | % o argv: Specifies a pointer to a text array containing the command line |
| 104 | % arguments. |
| 105 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 106 | % o metadata: any metadata is returned here. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 107 | % |
| 108 | % o exception: return any errors or warnings in this structure. |
| 109 | % |
| 110 | */ |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 111 | |
| 112 | static inline double MagickMin(const double x,const double y) |
| 113 | { |
| 114 | if (x < y) |
| 115 | return(x); |
| 116 | return(y); |
| 117 | } |
| 118 | |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 119 | WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
| 120 | MagickCommand command,int argc,char **argv,char **metadata, |
| 121 | ExceptionInfo *exception) |
| 122 | { |
| 123 | char |
| 124 | *option; |
| 125 | |
| 126 | double |
| 127 | duration, |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 128 | serial; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 129 | |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 130 | MagickBooleanType |
| 131 | concurrent, |
| 132 | regard_warnings, |
| 133 | status; |
| 134 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 135 | register ssize_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 136 | i; |
| 137 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 138 | size_t |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 139 | iterations, |
| 140 | n, |
| 141 | number_threads; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 142 | |
cristy | d0a94fa | 2010-03-12 14:18:11 +0000 | [diff] [blame] | 143 | (void) setlocale(LC_ALL,""); |
| 144 | (void) setlocale(LC_NUMERIC,"C"); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 145 | concurrent=MagickFalse; |
| 146 | duration=(-1.0); |
| 147 | iterations=1; |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 148 | status=MagickFalse; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 149 | regard_warnings=MagickFalse; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 150 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 151 | { |
| 152 | option=argv[i]; |
| 153 | if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) |
| 154 | continue; |
| 155 | if (LocaleCompare("bench",option+1) == 0) |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 156 | iterations=StringToUnsignedLong(argv[++i]); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 157 | if (LocaleCompare("concurrent",option+1) == 0) |
| 158 | concurrent=MagickTrue; |
| 159 | if (LocaleCompare("debug",option+1) == 0) |
| 160 | (void) SetLogEventMask(argv[++i]); |
| 161 | if (LocaleCompare("duration",option+1) == 0) |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 162 | duration=StringToDouble(argv[++i],(char **) NULL); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 163 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 164 | regard_warnings=MagickTrue; |
| 165 | } |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 166 | if (iterations == 1) |
| 167 | { |
| 168 | status=command(image_info,argc,argv,metadata,exception); |
| 169 | if (exception->severity != UndefinedException) |
| 170 | { |
| 171 | if ((exception->severity > ErrorException) || |
| 172 | (regard_warnings != MagickFalse)) |
| 173 | status=MagickTrue; |
| 174 | CatchException(exception); |
| 175 | } |
| 176 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 177 | { |
| 178 | (void) fputs(*metadata,stdout); |
| 179 | (void) fputc('\n',stdout); |
| 180 | *metadata=DestroyString(*metadata); |
| 181 | } |
| 182 | return(status); |
| 183 | } |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 184 | number_threads=GetOpenMPMaximumThreads(); |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 185 | serial=0.0; |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 186 | for (n=1; n <= number_threads; n++) |
| 187 | { |
| 188 | double |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 189 | e, |
| 190 | parallel, |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 191 | user_time; |
| 192 | |
| 193 | TimerInfo |
| 194 | *timer; |
| 195 | |
| 196 | SetOpenMPMaximumThreads(n); |
| 197 | timer=AcquireTimerInfo(); |
| 198 | if (concurrent == MagickFalse) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 199 | { |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 200 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 201 | { |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 202 | if (status != MagickFalse) |
| 203 | continue; |
| 204 | if (duration > 0) |
| 205 | { |
| 206 | if (GetElapsedTime(timer) > duration) |
| 207 | continue; |
| 208 | (void) ContinueTimer(timer); |
| 209 | } |
| 210 | status=command(image_info,argc,argv,metadata,exception); |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 211 | if (exception->severity != UndefinedException) |
| 212 | { |
| 213 | if ((exception->severity > ErrorException) || |
| 214 | (regard_warnings != MagickFalse)) |
| 215 | status=MagickTrue; |
| 216 | CatchException(exception); |
| 217 | } |
| 218 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 219 | { |
| 220 | (void) fputs(*metadata,stdout); |
| 221 | (void) fputc('\n',stdout); |
| 222 | *metadata=DestroyString(*metadata); |
| 223 | } |
| 224 | } |
| 225 | } |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 226 | else |
| 227 | { |
| 228 | SetOpenMPNested(1); |
| 229 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
| 230 | # pragma omp parallel for shared(status) |
| 231 | #endif |
| 232 | for (i=0; i < (ssize_t) iterations; i++) |
| 233 | { |
| 234 | if (status != MagickFalse) |
| 235 | continue; |
| 236 | if (duration > 0) |
| 237 | { |
| 238 | if (GetElapsedTime(timer) > duration) |
| 239 | continue; |
| 240 | (void) ContinueTimer(timer); |
| 241 | } |
| 242 | status=command(image_info,argc,argv,metadata,exception); |
| 243 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
| 244 | # pragma omp critical (MagickCore_CommandGenesis) |
| 245 | #endif |
| 246 | { |
| 247 | if (exception->severity != UndefinedException) |
| 248 | { |
| 249 | if ((exception->severity > ErrorException) || |
| 250 | (regard_warnings != MagickFalse)) |
| 251 | status=MagickTrue; |
| 252 | CatchException(exception); |
| 253 | } |
| 254 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 255 | { |
| 256 | (void) fputs(*metadata,stdout); |
| 257 | (void) fputc('\n',stdout); |
| 258 | *metadata=DestroyString(*metadata); |
| 259 | } |
| 260 | } |
| 261 | } |
| 262 | } |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 263 | user_time=GetUserTime(timer); |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 264 | parallel=GetElapsedTime(timer); |
| 265 | e=1.0; |
| 266 | if (n == 1) |
| 267 | serial=parallel; |
| 268 | else |
| 269 | e=((1.0/(1.0/((serial/(serial+parallel))+(1.0-(serial/(serial+parallel)))/ |
| 270 | (double) n)))-(1.0/(double) n))/(1.0-1.0/(double) n); |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 271 | (void) FormatLocaleFile(stderr, |
cristy | 91ce84d | 2011-12-09 23:02:25 +0000 | [diff] [blame] | 272 | "Performance[%.20g]: %.20gi %0.3fips %0.3fe %0.3fu %lu:%02lu.%03lu\n", |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 273 | (double) n,(double) iterations,(double) iterations/parallel,e, |
| 274 | user_time,(unsigned long) (parallel/60.0),(unsigned long) |
| 275 | floor(fmod(parallel,60.0)),(unsigned long) |
| 276 | (1000.0*(parallel-floor(parallel))+0.5)); |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 277 | timer=DestroyTimerInfo(timer); |
| 278 | } |
cristy | 1f9e1ed | 2009-11-18 04:09:38 +0000 | [diff] [blame] | 279 | return(status); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | /* |
| 283 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 284 | % % |
| 285 | % % |
| 286 | % % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 287 | + M o g r i f y I m a g e % |
| 288 | % % |
| 289 | % % |
| 290 | % % |
| 291 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 292 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 293 | % MogrifyImage() applies simple single image processing options to a single |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 294 | % image that may be part of a large list, but also handles any 'region' |
| 295 | % image handling. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 296 | % |
| 297 | % The image in the list may be modified in three different ways... |
| 298 | % |
| 299 | % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 300 | % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 301 | % * replace by a list of images (only the -separate option!) |
| 302 | % |
| 303 | % In each case the result is returned into the list, and a pointer to the |
| 304 | % modified image (last image added if replaced by a list of images) is |
| 305 | % returned. |
| 306 | % |
| 307 | % ASIDE: The -crop is present but restricted to non-tile single image crops |
| 308 | % |
| 309 | % This means if all the images are being processed (such as by |
| 310 | % MogrifyImages(), next image to be processed will be as per the pointer |
| 311 | % (*image)->next. Also the image list may grow as a result of some specific |
| 312 | % operations but as images are never merged or deleted, it will never shrink |
| 313 | % in length. Typically the list will remain the same length. |
| 314 | % |
| 315 | % WARNING: As the image pointed to may be replaced, the first image in the |
| 316 | % list may also change. GetFirstImageInList() should be used by caller if |
| 317 | % they wish return the Image pointer to the first image in list. |
| 318 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 319 | % |
| 320 | % The format of the MogrifyImage method is: |
| 321 | % |
| 322 | % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 323 | % const char **argv,Image **image) |
| 324 | % |
| 325 | % A description of each parameter follows: |
| 326 | % |
| 327 | % o image_info: the image info.. |
| 328 | % |
| 329 | % o argc: Specifies a pointer to an integer describing the number of |
| 330 | % elements in the argument vector. |
| 331 | % |
| 332 | % o argv: Specifies a pointer to a text array containing the command line |
| 333 | % arguments. |
| 334 | % |
| 335 | % o image: the image. |
| 336 | % |
| 337 | % o exception: return any errors or warnings in this structure. |
| 338 | % |
| 339 | */ |
| 340 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 341 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 342 | ExceptionInfo *exception) |
| 343 | { |
| 344 | char |
| 345 | key[MaxTextExtent]; |
| 346 | |
| 347 | ExceptionInfo |
| 348 | *sans_exception; |
| 349 | |
| 350 | Image |
| 351 | *image; |
| 352 | |
| 353 | ImageInfo |
| 354 | *read_info; |
| 355 | |
cristy | fcd785b | 2011-11-08 01:48:33 +0000 | [diff] [blame] | 356 | /* |
| 357 | Read an image into a image cache if not already present. Return the image |
| 358 | that is in the cache under that filename. |
| 359 | */ |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 360 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 361 | sans_exception=AcquireExceptionInfo(); |
| 362 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 363 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 364 | if (image != (Image *) NULL) |
| 365 | return(image); |
| 366 | read_info=CloneImageInfo(image_info); |
| 367 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 368 | image=ReadImage(read_info,exception); |
| 369 | read_info=DestroyImageInfo(read_info); |
| 370 | if (image != (Image *) NULL) |
| 371 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 372 | return(image); |
| 373 | } |
| 374 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 375 | static MagickBooleanType IsPathWritable(const char *path) |
| 376 | { |
| 377 | if (IsPathAccessible(path) == MagickFalse) |
| 378 | return(MagickFalse); |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 379 | if (access_utf8(path,W_OK) != 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 380 | return(MagickFalse); |
| 381 | return(MagickTrue); |
| 382 | } |
| 383 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 384 | static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 385 | { |
| 386 | if (x > y) |
| 387 | return(x); |
| 388 | return(y); |
| 389 | } |
| 390 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 391 | static MagickBooleanType MonitorProgress(const char *text, |
| 392 | const MagickOffsetType offset,const MagickSizeType extent, |
| 393 | void *wand_unused(client_data)) |
| 394 | { |
| 395 | char |
| 396 | message[MaxTextExtent], |
| 397 | tag[MaxTextExtent]; |
| 398 | |
| 399 | const char |
| 400 | *locale_message; |
| 401 | |
| 402 | register char |
| 403 | *p; |
| 404 | |
| 405 | if (extent < 2) |
| 406 | return(MagickTrue); |
| 407 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 408 | p=strrchr(tag,'/'); |
| 409 | if (p != (char *) NULL) |
| 410 | *p='\0'; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 411 | (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 412 | locale_message=GetLocaleMessage(message); |
| 413 | if (locale_message == message) |
| 414 | locale_message=tag; |
| 415 | if (p == (char *) NULL) |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 416 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", |
| 417 | locale_message,(long) offset,(unsigned long) extent,(long) |
| 418 | (100L*offset/(extent-1))); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 419 | else |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 420 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 421 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 422 | (100L*offset/(extent-1))); |
| 423 | if (offset == (MagickOffsetType) (extent-1)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 424 | (void) FormatLocaleFile(stderr,"\n"); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 425 | (void) fflush(stderr); |
| 426 | return(MagickTrue); |
| 427 | } |
| 428 | |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 429 | static Image *SparseColorOption(const Image *image, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 430 | const SparseColorMethod method,const char *arguments, |
| 431 | const MagickBooleanType color_from_image,ExceptionInfo *exception) |
| 432 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 433 | char |
| 434 | token[MaxTextExtent]; |
| 435 | |
| 436 | const char |
| 437 | *p; |
| 438 | |
| 439 | double |
| 440 | *sparse_arguments; |
| 441 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 442 | Image |
| 443 | *sparse_image; |
| 444 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 445 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 446 | color; |
| 447 | |
| 448 | MagickBooleanType |
| 449 | error; |
| 450 | |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 451 | register size_t |
| 452 | x; |
| 453 | |
| 454 | size_t |
| 455 | number_arguments, |
| 456 | number_colors; |
| 457 | |
cristy | f4425a7 | 2011-11-08 01:52:04 +0000 | [diff] [blame] | 458 | /* |
| 459 | SparseColorOption() parses the complex -sparse-color argument into an an |
| 460 | array of floating point values then calls SparseColorImage(). Argument is |
| 461 | a complex mix of floating-point pixel coodinates, and color specifications |
| 462 | (or direct floating point numbers). The number of floats needed to |
| 463 | represent a color varies depending on the current channel setting. |
| 464 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 465 | assert(image != (Image *) NULL); |
| 466 | assert(image->signature == MagickSignature); |
| 467 | if (image->debug != MagickFalse) |
| 468 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 469 | assert(exception != (ExceptionInfo *) NULL); |
| 470 | assert(exception->signature == MagickSignature); |
| 471 | /* |
| 472 | Limit channels according to image - and add up number of color channel. |
| 473 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 474 | number_colors=0; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 475 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 476 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 477 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 478 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 479 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 480 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 481 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 482 | (image->colorspace == CMYKColorspace)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 483 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 484 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 485 | (image->matte != MagickFalse)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 486 | number_colors++; |
| 487 | |
| 488 | /* |
| 489 | Read string, to determine number of arguments needed, |
| 490 | */ |
| 491 | p=arguments; |
| 492 | x=0; |
| 493 | while( *p != '\0' ) |
| 494 | { |
| 495 | GetMagickToken(p,&p,token); |
| 496 | if ( token[0] == ',' ) continue; |
| 497 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 498 | if ( color_from_image ) { |
| 499 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 500 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 501 | "Color arg given, when colors are coming from image"); |
| 502 | return( (Image *)NULL); |
| 503 | } |
| 504 | x += number_colors; /* color argument */ |
| 505 | } |
| 506 | else { |
| 507 | x++; /* floating point argument */ |
| 508 | } |
| 509 | } |
| 510 | error=MagickTrue; |
| 511 | if ( color_from_image ) { |
| 512 | /* just the control points are being given */ |
| 513 | error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; |
| 514 | number_arguments=(x/2)*(2+number_colors); |
| 515 | } |
| 516 | else { |
| 517 | /* control points and color values */ |
| 518 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; |
| 519 | number_arguments=x; |
| 520 | } |
| 521 | if ( error ) { |
| 522 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 523 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 524 | "Invalid number of Arguments"); |
| 525 | return( (Image *)NULL); |
| 526 | } |
| 527 | |
| 528 | /* Allocate and fill in the floating point arguments */ |
| 529 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 530 | sizeof(*sparse_arguments)); |
| 531 | if (sparse_arguments == (double *) NULL) { |
| 532 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 533 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 534 | return( (Image *)NULL); |
| 535 | } |
| 536 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 537 | sizeof(*sparse_arguments)); |
| 538 | p=arguments; |
| 539 | x=0; |
| 540 | while( *p != '\0' && x < number_arguments ) { |
| 541 | /* X coordinate */ |
| 542 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 543 | if ( token[0] == '\0' ) break; |
| 544 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 545 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 546 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 547 | "Color found, instead of X-coord"); |
| 548 | error = MagickTrue; |
| 549 | break; |
| 550 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 551 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 552 | /* Y coordinate */ |
| 553 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 554 | if ( token[0] == '\0' ) break; |
| 555 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 556 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 557 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 558 | "Color found, instead of Y-coord"); |
| 559 | error = MagickTrue; |
| 560 | break; |
| 561 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 562 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 563 | /* color values for this control point */ |
| 564 | #if 0 |
| 565 | if ( (color_from_image ) { |
| 566 | /* get color from image */ |
| 567 | /* HOW??? */ |
| 568 | } |
| 569 | else |
| 570 | #endif |
| 571 | { |
| 572 | /* color name or function given in string argument */ |
| 573 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 574 | if ( token[0] == '\0' ) break; |
| 575 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 576 | /* Color string given */ |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 577 | (void) QueryColorCompliance(token,AllCompliance,&color,exception); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 578 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 579 | sparse_arguments[x++] = QuantumScale*color.red; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 580 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 581 | sparse_arguments[x++] = QuantumScale*color.green; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 582 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 583 | sparse_arguments[x++] = QuantumScale*color.blue; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 584 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 585 | (image->colorspace == CMYKColorspace)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 586 | sparse_arguments[x++] = QuantumScale*color.black; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 587 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 588 | (image->matte != MagickFalse)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 589 | sparse_arguments[x++] = QuantumScale*color.alpha; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 590 | } |
| 591 | else { |
| 592 | /* Colors given as a set of floating point values - experimental */ |
| 593 | /* NB: token contains the first floating point value to use! */ |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 594 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 595 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 596 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 597 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 598 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 599 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 600 | token[0] = ','; /* used this token - get another */ |
| 601 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 602 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 603 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 604 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 605 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 606 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 607 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 608 | token[0] = ','; /* used this token - get another */ |
| 609 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 610 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 611 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 612 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 613 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 614 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 615 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 616 | token[0] = ','; /* used this token - get another */ |
| 617 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 618 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 619 | (image->colorspace == CMYKColorspace)) |
| 620 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 621 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 622 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 623 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 624 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 625 | token[0] = ','; /* used this token - get another */ |
| 626 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 627 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 628 | (image->matte != MagickFalse)) |
| 629 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 630 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 631 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 632 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 633 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 634 | token[0] = ','; /* used this token - get another */ |
| 635 | } |
| 636 | } |
| 637 | } |
| 638 | } |
| 639 | if ( number_arguments != x && !error ) { |
| 640 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
| 641 | "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error"); |
| 642 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 643 | return( (Image *)NULL); |
| 644 | } |
| 645 | if ( error ) |
| 646 | return( (Image *)NULL); |
| 647 | |
| 648 | /* Call the Interpolation function with the parsed arguments */ |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 649 | sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, |
| 650 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 651 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 652 | return( sparse_image ); |
| 653 | } |
| 654 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 655 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 656 | const char **argv,Image **image,ExceptionInfo *exception) |
| 657 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 658 | ChannelType |
| 659 | channel; |
| 660 | |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 661 | CompositeOperator |
| 662 | compose; |
| 663 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 664 | const char |
| 665 | *format, |
| 666 | *option; |
| 667 | |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 668 | double |
| 669 | attenuate; |
| 670 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 671 | DrawInfo |
| 672 | *draw_info; |
| 673 | |
| 674 | GeometryInfo |
| 675 | geometry_info; |
| 676 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 677 | Image |
| 678 | *region_image; |
| 679 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 680 | ImageInfo |
| 681 | *mogrify_info; |
| 682 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 683 | MagickStatusType |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 684 | status; |
| 685 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 686 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 687 | fill; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 688 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 689 | MagickStatusType |
| 690 | flags; |
| 691 | |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 692 | PixelInterpolateMethod |
| 693 | interpolate_method; |
| 694 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 695 | QuantizeInfo |
| 696 | *quantize_info; |
| 697 | |
| 698 | RectangleInfo |
| 699 | geometry, |
| 700 | region_geometry; |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame] | 701 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 702 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 703 | i; |
| 704 | |
| 705 | /* |
| 706 | Initialize method variables. |
| 707 | */ |
| 708 | assert(image_info != (const ImageInfo *) NULL); |
| 709 | assert(image_info->signature == MagickSignature); |
| 710 | assert(image != (Image **) NULL); |
| 711 | assert((*image)->signature == MagickSignature); |
| 712 | if ((*image)->debug != MagickFalse) |
| 713 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); |
| 714 | if (argc < 0) |
| 715 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 716 | mogrify_info=CloneImageInfo(image_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 717 | draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL); |
| 718 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 719 | SetGeometryInfo(&geometry_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 720 | GetPixelInfo(*image,&fill); |
cristy | 9d8c8ce | 2011-10-25 16:13:52 +0000 | [diff] [blame] | 721 | fill=(*image)->background_color; |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 722 | attenuate=1.0; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 723 | compose=(*image)->compose; |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 724 | interpolate_method=UndefinedInterpolatePixel; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 725 | channel=mogrify_info->channel; |
| 726 | format=GetImageOption(mogrify_info,"format"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 727 | SetGeometry(*image,®ion_geometry); |
| 728 | region_image=NewImageList(); |
| 729 | /* |
| 730 | Transmogrify the image. |
| 731 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 732 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 733 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 734 | Image |
| 735 | *mogrify_image; |
| 736 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 737 | ssize_t |
| 738 | count; |
| 739 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 740 | option=argv[i]; |
| 741 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 742 | continue; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 743 | count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option), |
| 744 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 745 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 746 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 747 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 748 | mogrify_image=(Image *)NULL; |
| 749 | switch (*(option+1)) |
| 750 | { |
| 751 | case 'a': |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 752 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 753 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 754 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 755 | /* |
| 756 | Adaptive blur image. |
| 757 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 758 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 759 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 760 | if ((flags & SigmaValue) == 0) |
| 761 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 762 | if ((flags & XiValue) == 0) |
| 763 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 764 | mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho, |
cristy | 4c11c2b | 2011-09-05 20:17:07 +0000 | [diff] [blame] | 765 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 766 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 767 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 768 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 769 | { |
| 770 | /* |
| 771 | Adaptive resize image. |
| 772 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 773 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 774 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 775 | mogrify_image=AdaptiveResizeImage(*image,geometry.width, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 776 | geometry.height,interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 777 | break; |
| 778 | } |
| 779 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 780 | { |
| 781 | /* |
| 782 | Adaptive sharpen image. |
| 783 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 784 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 785 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 786 | if ((flags & SigmaValue) == 0) |
| 787 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 788 | if ((flags & XiValue) == 0) |
| 789 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 790 | mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho, |
cristy | 4c11c2b | 2011-09-05 20:17:07 +0000 | [diff] [blame] | 791 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 792 | break; |
| 793 | } |
| 794 | if (LocaleCompare("affine",option+1) == 0) |
| 795 | { |
| 796 | /* |
| 797 | Affine matrix. |
| 798 | */ |
| 799 | if (*option == '+') |
| 800 | { |
| 801 | GetAffineMatrix(&draw_info->affine); |
| 802 | break; |
| 803 | } |
| 804 | (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); |
| 805 | break; |
| 806 | } |
| 807 | if (LocaleCompare("alpha",option+1) == 0) |
| 808 | { |
| 809 | AlphaChannelType |
| 810 | alpha_type; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 811 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 812 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 813 | alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions, |
| 814 | MagickFalse,argv[i+1]); |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 815 | (void) SetImageAlphaChannel(*image,alpha_type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 816 | break; |
| 817 | } |
| 818 | if (LocaleCompare("annotate",option+1) == 0) |
| 819 | { |
| 820 | char |
| 821 | *text, |
| 822 | geometry[MaxTextExtent]; |
| 823 | |
| 824 | /* |
| 825 | Annotate image. |
| 826 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 827 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 828 | SetGeometryInfo(&geometry_info); |
| 829 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 830 | if ((flags & SigmaValue) == 0) |
| 831 | geometry_info.sigma=geometry_info.rho; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 832 | text=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 833 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 834 | if (text == (char *) NULL) |
| 835 | break; |
| 836 | (void) CloneString(&draw_info->text,text); |
| 837 | text=DestroyString(text); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 838 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 839 | geometry_info.xi,geometry_info.psi); |
| 840 | (void) CloneString(&draw_info->geometry,geometry); |
| 841 | draw_info->affine.sx=cos(DegreesToRadians( |
| 842 | fmod(geometry_info.rho,360.0))); |
| 843 | draw_info->affine.rx=sin(DegreesToRadians( |
| 844 | fmod(geometry_info.rho,360.0))); |
| 845 | draw_info->affine.ry=(-sin(DegreesToRadians( |
| 846 | fmod(geometry_info.sigma,360.0)))); |
| 847 | draw_info->affine.sy=cos(DegreesToRadians( |
| 848 | fmod(geometry_info.sigma,360.0))); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 849 | (void) AnnotateImage(*image,draw_info,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 850 | break; |
| 851 | } |
| 852 | if (LocaleCompare("antialias",option+1) == 0) |
| 853 | { |
| 854 | draw_info->stroke_antialias=(*option == '-') ? MagickTrue : |
| 855 | MagickFalse; |
| 856 | draw_info->text_antialias=(*option == '-') ? MagickTrue : |
| 857 | MagickFalse; |
| 858 | break; |
| 859 | } |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 860 | if (LocaleCompare("attenuate",option+1) == 0) |
| 861 | { |
| 862 | if (*option == '+') |
| 863 | { |
| 864 | attenuate=1.0; |
| 865 | break; |
| 866 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 867 | attenuate=StringToDouble(argv[i+1],(char **) NULL); |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 868 | break; |
| 869 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 870 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 871 | { |
| 872 | /* |
| 873 | Auto Adjust Gamma of image based on its mean |
| 874 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 875 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9511120 | 2011-08-09 19:41:42 +0000 | [diff] [blame] | 876 | (void) AutoGammaImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 877 | break; |
| 878 | } |
| 879 | if (LocaleCompare("auto-level",option+1) == 0) |
| 880 | { |
| 881 | /* |
| 882 | Perfectly Normalize (max/min stretch) the image |
| 883 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 884 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9511120 | 2011-08-09 19:41:42 +0000 | [diff] [blame] | 885 | (void) AutoLevelImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 886 | break; |
| 887 | } |
| 888 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 889 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 890 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 891 | switch ((*image)->orientation) |
| 892 | { |
| 893 | case TopRightOrientation: |
| 894 | { |
| 895 | mogrify_image=FlopImage(*image,exception); |
| 896 | break; |
| 897 | } |
| 898 | case BottomRightOrientation: |
| 899 | { |
| 900 | mogrify_image=RotateImage(*image,180.0,exception); |
| 901 | break; |
| 902 | } |
| 903 | case BottomLeftOrientation: |
| 904 | { |
| 905 | mogrify_image=FlipImage(*image,exception); |
| 906 | break; |
| 907 | } |
| 908 | case LeftTopOrientation: |
| 909 | { |
| 910 | mogrify_image=TransposeImage(*image,exception); |
| 911 | break; |
| 912 | } |
| 913 | case RightTopOrientation: |
| 914 | { |
| 915 | mogrify_image=RotateImage(*image,90.0,exception); |
| 916 | break; |
| 917 | } |
| 918 | case RightBottomOrientation: |
| 919 | { |
| 920 | mogrify_image=TransverseImage(*image,exception); |
| 921 | break; |
| 922 | } |
| 923 | case LeftBottomOrientation: |
| 924 | { |
| 925 | mogrify_image=RotateImage(*image,270.0,exception); |
| 926 | break; |
| 927 | } |
| 928 | default: |
| 929 | break; |
| 930 | } |
| 931 | if (mogrify_image != (Image *) NULL) |
| 932 | mogrify_image->orientation=TopLeftOrientation; |
| 933 | break; |
| 934 | } |
| 935 | break; |
| 936 | } |
| 937 | case 'b': |
| 938 | { |
| 939 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 940 | { |
| 941 | /* |
| 942 | Black threshold image. |
| 943 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 944 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 945 | (void) BlackThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 946 | break; |
| 947 | } |
| 948 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 949 | { |
| 950 | /* |
| 951 | Blue shift image. |
| 952 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 953 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 954 | geometry_info.rho=1.5; |
| 955 | if (*option == '-') |
| 956 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 957 | mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception); |
| 958 | break; |
| 959 | } |
| 960 | if (LocaleCompare("blur",option+1) == 0) |
| 961 | { |
| 962 | /* |
| 963 | Gaussian blur image. |
| 964 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 965 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 966 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 967 | if ((flags & SigmaValue) == 0) |
| 968 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 969 | if ((flags & XiValue) == 0) |
| 970 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 971 | mogrify_image=BlurImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 972 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 973 | break; |
| 974 | } |
| 975 | if (LocaleCompare("border",option+1) == 0) |
| 976 | { |
| 977 | /* |
| 978 | Surround image with a border of solid color. |
| 979 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 980 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 981 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 982 | if ((flags & SigmaValue) == 0) |
| 983 | geometry.height=geometry.width; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 984 | mogrify_image=BorderImage(*image,&geometry,compose,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 985 | break; |
| 986 | } |
| 987 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 988 | { |
| 989 | if (*option == '+') |
| 990 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 991 | (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 992 | &draw_info->border_color,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 993 | break; |
| 994 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 995 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 996 | &draw_info->border_color,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 997 | break; |
| 998 | } |
| 999 | if (LocaleCompare("box",option+1) == 0) |
| 1000 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1001 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 1002 | &draw_info->undercolor,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1003 | break; |
| 1004 | } |
| 1005 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 1006 | { |
| 1007 | double |
| 1008 | brightness, |
| 1009 | contrast; |
| 1010 | |
| 1011 | GeometryInfo |
| 1012 | geometry_info; |
| 1013 | |
| 1014 | MagickStatusType |
| 1015 | flags; |
| 1016 | |
| 1017 | /* |
| 1018 | Brightness / contrast image. |
| 1019 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1020 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1021 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1022 | brightness=geometry_info.rho; |
| 1023 | contrast=0.0; |
| 1024 | if ((flags & SigmaValue) != 0) |
| 1025 | contrast=geometry_info.sigma; |
cristy | 444eda6 | 2011-08-10 02:07:46 +0000 | [diff] [blame] | 1026 | (void) BrightnessContrastImage(*image,brightness,contrast, |
| 1027 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1028 | break; |
| 1029 | } |
| 1030 | break; |
| 1031 | } |
| 1032 | case 'c': |
| 1033 | { |
| 1034 | if (LocaleCompare("cdl",option+1) == 0) |
| 1035 | { |
| 1036 | char |
| 1037 | *color_correction_collection; |
| 1038 | |
| 1039 | /* |
| 1040 | Color correct with a color decision list. |
| 1041 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1042 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1043 | color_correction_collection=FileToString(argv[i+1],~0,exception); |
| 1044 | if (color_correction_collection == (char *) NULL) |
| 1045 | break; |
cristy | 1bfa9f0 | 2011-08-11 02:35:43 +0000 | [diff] [blame] | 1046 | (void) ColorDecisionListImage(*image,color_correction_collection, |
| 1047 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1048 | break; |
| 1049 | } |
| 1050 | if (LocaleCompare("channel",option+1) == 0) |
| 1051 | { |
| 1052 | if (*option == '+') |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 1053 | channel=DefaultChannels; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1054 | else |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 1055 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | e2a912b | 2011-12-05 20:02:07 +0000 | [diff] [blame] | 1056 | SetPixelChannelMapMask(*image,channel); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1057 | break; |
| 1058 | } |
| 1059 | if (LocaleCompare("charcoal",option+1) == 0) |
| 1060 | { |
| 1061 | /* |
| 1062 | Charcoal image. |
| 1063 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1064 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1065 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1066 | if ((flags & SigmaValue) == 0) |
| 1067 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1068 | if ((flags & XiValue) == 0) |
| 1069 | geometry_info.xi=1.0; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1070 | mogrify_image=CharcoalImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1071 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1072 | break; |
| 1073 | } |
| 1074 | if (LocaleCompare("chop",option+1) == 0) |
| 1075 | { |
| 1076 | /* |
| 1077 | Chop the image. |
| 1078 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1079 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1080 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1081 | mogrify_image=ChopImage(*image,&geometry,exception); |
| 1082 | break; |
| 1083 | } |
| 1084 | if (LocaleCompare("clamp",option+1) == 0) |
| 1085 | { |
| 1086 | /* |
| 1087 | Clamp image. |
| 1088 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1089 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 092d71c | 2011-10-14 18:01:29 +0000 | [diff] [blame] | 1090 | (void) ClampImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1091 | break; |
| 1092 | } |
| 1093 | if (LocaleCompare("clip",option+1) == 0) |
| 1094 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1095 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1096 | if (*option == '+') |
| 1097 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1098 | (void) SetImageClipMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1099 | break; |
| 1100 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1101 | (void) ClipImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1102 | break; |
| 1103 | } |
| 1104 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1105 | { |
| 1106 | CacheView |
| 1107 | *mask_view; |
| 1108 | |
| 1109 | Image |
| 1110 | *mask_image; |
| 1111 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1112 | register Quantum |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1113 | *restrict q; |
| 1114 | |
| 1115 | register ssize_t |
| 1116 | x; |
| 1117 | |
| 1118 | ssize_t |
| 1119 | y; |
| 1120 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1121 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1122 | if (*option == '+') |
| 1123 | { |
| 1124 | /* |
| 1125 | Remove a mask. |
| 1126 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1127 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1128 | break; |
| 1129 | } |
| 1130 | /* |
| 1131 | Set the image mask. |
| 1132 | FUTURE: This Should Be a SetImageAlphaChannel() call, Or two. |
| 1133 | */ |
| 1134 | mask_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1135 | if (mask_image == (Image *) NULL) |
| 1136 | break; |
cristy | 574cc26 | 2011-08-05 01:23:58 +0000 | [diff] [blame] | 1137 | if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1138 | return(MagickFalse); |
| 1139 | mask_view=AcquireCacheView(mask_image); |
| 1140 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1141 | { |
| 1142 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1143 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 1144 | if (q == (Quantum *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1145 | break; |
| 1146 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1147 | { |
| 1148 | if (mask_image->matte == MagickFalse) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1149 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 1150 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1151 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1152 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1153 | q+=GetPixelChannels(mask_image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1154 | } |
| 1155 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
| 1156 | break; |
| 1157 | } |
| 1158 | mask_view=DestroyCacheView(mask_view); |
| 1159 | mask_image->matte=MagickTrue; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1160 | (void) SetImageClipMask(*image,mask_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1161 | break; |
| 1162 | } |
| 1163 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1164 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1165 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1166 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1167 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1168 | break; |
| 1169 | } |
| 1170 | if (LocaleCompare("colorize",option+1) == 0) |
| 1171 | { |
| 1172 | /* |
| 1173 | Colorize the image. |
| 1174 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1175 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | c7e6ff6 | 2011-10-03 13:46:11 +0000 | [diff] [blame] | 1176 | mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1177 | break; |
| 1178 | } |
| 1179 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1180 | { |
| 1181 | KernelInfo |
| 1182 | *kernel; |
| 1183 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1184 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1185 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1186 | if (kernel == (KernelInfo *) NULL) |
| 1187 | break; |
| 1188 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 1189 | kernel=DestroyKernelInfo(kernel); |
| 1190 | break; |
| 1191 | } |
| 1192 | if (LocaleCompare("colors",option+1) == 0) |
| 1193 | { |
| 1194 | /* |
| 1195 | Reduce the number of colors in the image. |
| 1196 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1197 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1198 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
| 1199 | if (quantize_info->number_colors == 0) |
| 1200 | break; |
| 1201 | if (((*image)->storage_class == DirectClass) || |
| 1202 | (*image)->colors > quantize_info->number_colors) |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1203 | (void) QuantizeImage(quantize_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1204 | else |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1205 | (void) CompressImageColormap(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1206 | break; |
| 1207 | } |
| 1208 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1209 | { |
| 1210 | ColorspaceType |
| 1211 | colorspace; |
| 1212 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1213 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1214 | if (*option == '+') |
| 1215 | { |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 1216 | (void) TransformImageColorspace(*image,RGBColorspace,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1217 | break; |
| 1218 | } |
| 1219 | colorspace=(ColorspaceType) ParseCommandOption( |
| 1220 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 1221 | (void) TransformImageColorspace(*image,colorspace,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1222 | break; |
| 1223 | } |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1224 | if (LocaleCompare("compose",option+1) == 0) |
| 1225 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1226 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1227 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 1228 | MagickFalse,argv[i+1]); |
| 1229 | break; |
| 1230 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1231 | if (LocaleCompare("contrast",option+1) == 0) |
| 1232 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1233 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1234 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1235 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1236 | break; |
| 1237 | } |
| 1238 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1239 | { |
| 1240 | double |
| 1241 | black_point, |
| 1242 | white_point; |
| 1243 | |
| 1244 | MagickStatusType |
| 1245 | flags; |
| 1246 | |
| 1247 | /* |
| 1248 | Contrast stretch image. |
| 1249 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1250 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1251 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1252 | black_point=geometry_info.rho; |
| 1253 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1254 | black_point; |
| 1255 | if ((flags & PercentValue) != 0) |
| 1256 | { |
| 1257 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1258 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1259 | } |
| 1260 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1261 | white_point; |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1262 | (void) ContrastStretchImage(*image,black_point,white_point, |
| 1263 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1264 | break; |
| 1265 | } |
| 1266 | if (LocaleCompare("convolve",option+1) == 0) |
| 1267 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1268 | KernelInfo |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1269 | *kernel_info; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1270 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1271 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1272 | kernel_info=AcquireKernelInfo(argv[i+1]); |
| 1273 | if (kernel_info == (KernelInfo *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1274 | break; |
cristy | 0a92238 | 2011-07-16 15:30:34 +0000 | [diff] [blame] | 1275 | kernel_info->bias=(*image)->bias; |
cristy | 5e6be1e | 2011-07-16 01:23:39 +0000 | [diff] [blame] | 1276 | mogrify_image=ConvolveImage(*image,kernel_info,exception); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1277 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1278 | break; |
| 1279 | } |
| 1280 | if (LocaleCompare("crop",option+1) == 0) |
| 1281 | { |
| 1282 | /* |
| 1283 | Crop a image to a smaller size |
| 1284 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1285 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1286 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1287 | break; |
| 1288 | } |
| 1289 | if (LocaleCompare("cycle",option+1) == 0) |
| 1290 | { |
| 1291 | /* |
| 1292 | Cycle an image colormap. |
| 1293 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1294 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1295 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]), |
| 1296 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1297 | break; |
| 1298 | } |
| 1299 | break; |
| 1300 | } |
| 1301 | case 'd': |
| 1302 | { |
| 1303 | if (LocaleCompare("decipher",option+1) == 0) |
| 1304 | { |
| 1305 | StringInfo |
| 1306 | *passkey; |
| 1307 | |
| 1308 | /* |
| 1309 | Decipher pixels. |
| 1310 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1311 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1312 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1313 | if (passkey != (StringInfo *) NULL) |
| 1314 | { |
| 1315 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1316 | passkey=DestroyStringInfo(passkey); |
| 1317 | } |
| 1318 | break; |
| 1319 | } |
| 1320 | if (LocaleCompare("density",option+1) == 0) |
| 1321 | { |
| 1322 | /* |
| 1323 | Set image density. |
| 1324 | */ |
| 1325 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1326 | break; |
| 1327 | } |
| 1328 | if (LocaleCompare("depth",option+1) == 0) |
| 1329 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1330 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1331 | if (*option == '+') |
| 1332 | { |
cristy | 8a11cb1 | 2011-10-19 23:53:34 +0000 | [diff] [blame] | 1333 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1334 | break; |
| 1335 | } |
cristy | 8a11cb1 | 2011-10-19 23:53:34 +0000 | [diff] [blame] | 1336 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]), |
| 1337 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1338 | break; |
| 1339 | } |
| 1340 | if (LocaleCompare("deskew",option+1) == 0) |
| 1341 | { |
| 1342 | double |
| 1343 | threshold; |
| 1344 | |
| 1345 | /* |
| 1346 | Straighten the image. |
| 1347 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1348 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1349 | if (*option == '+') |
| 1350 | threshold=40.0*QuantumRange/100.0; |
| 1351 | else |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 1352 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 1353 | 1.0); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1354 | mogrify_image=DeskewImage(*image,threshold,exception); |
| 1355 | break; |
| 1356 | } |
| 1357 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1358 | { |
| 1359 | /* |
| 1360 | Reduce the speckles within an image. |
| 1361 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1362 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1363 | mogrify_image=DespeckleImage(*image,exception); |
| 1364 | break; |
| 1365 | } |
| 1366 | if (LocaleCompare("display",option+1) == 0) |
| 1367 | { |
| 1368 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1369 | break; |
| 1370 | } |
| 1371 | if (LocaleCompare("distort",option+1) == 0) |
| 1372 | { |
| 1373 | char |
| 1374 | *args, |
| 1375 | token[MaxTextExtent]; |
| 1376 | |
| 1377 | const char |
| 1378 | *p; |
| 1379 | |
| 1380 | DistortImageMethod |
| 1381 | method; |
| 1382 | |
| 1383 | double |
| 1384 | *arguments; |
| 1385 | |
| 1386 | register ssize_t |
| 1387 | x; |
| 1388 | |
| 1389 | size_t |
| 1390 | number_arguments; |
| 1391 | |
| 1392 | /* |
| 1393 | Distort image. |
| 1394 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1395 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1396 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, |
| 1397 | MagickFalse,argv[i+1]); |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1398 | if (method == ResizeDistortion) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1399 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1400 | double |
| 1401 | resize_args[2]; |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1402 | |
| 1403 | /* |
| 1404 | Special Case - Argument is actually a resize geometry! |
| 1405 | Convert that to an appropriate distortion argument array. |
| 1406 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1407 | (void) ParseRegionGeometry(*image,argv[i+2],&geometry, |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1408 | exception); |
| 1409 | resize_args[0]=(double) geometry.width; |
| 1410 | resize_args[1]=(double) geometry.height; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1411 | mogrify_image=DistortImage(*image,method,(size_t)2, |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1412 | resize_args,MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1413 | break; |
| 1414 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1415 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1416 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1417 | if (args == (char *) NULL) |
| 1418 | break; |
| 1419 | p=(char *) args; |
| 1420 | for (x=0; *p != '\0'; x++) |
| 1421 | { |
| 1422 | GetMagickToken(p,&p,token); |
| 1423 | if (*token == ',') |
| 1424 | GetMagickToken(p,&p,token); |
| 1425 | } |
| 1426 | number_arguments=(size_t) x; |
| 1427 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1428 | sizeof(*arguments)); |
| 1429 | if (arguments == (double *) NULL) |
| 1430 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1431 | "MemoryAllocationFailed",(*image)->filename); |
| 1432 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1433 | sizeof(*arguments)); |
| 1434 | p=(char *) args; |
| 1435 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 1436 | { |
| 1437 | GetMagickToken(p,&p,token); |
| 1438 | if (*token == ',') |
| 1439 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1440 | arguments[x]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1441 | } |
| 1442 | args=DestroyString(args); |
| 1443 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
| 1444 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1445 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1446 | break; |
| 1447 | } |
| 1448 | if (LocaleCompare("dither",option+1) == 0) |
| 1449 | { |
| 1450 | if (*option == '+') |
| 1451 | { |
| 1452 | quantize_info->dither=MagickFalse; |
| 1453 | break; |
| 1454 | } |
| 1455 | quantize_info->dither=MagickTrue; |
| 1456 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
| 1457 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1458 | if (quantize_info->dither_method == NoDitherMethod) |
| 1459 | quantize_info->dither=MagickFalse; |
| 1460 | break; |
| 1461 | } |
| 1462 | if (LocaleCompare("draw",option+1) == 0) |
| 1463 | { |
| 1464 | /* |
| 1465 | Draw image. |
| 1466 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1467 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1468 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1469 | (void) DrawImage(*image,draw_info,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1470 | break; |
| 1471 | } |
| 1472 | break; |
| 1473 | } |
| 1474 | case 'e': |
| 1475 | { |
| 1476 | if (LocaleCompare("edge",option+1) == 0) |
| 1477 | { |
| 1478 | /* |
| 1479 | Enhance edges in the image. |
| 1480 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1481 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1482 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1483 | if ((flags & SigmaValue) == 0) |
| 1484 | geometry_info.sigma=1.0; |
cristy | 8ae632d | 2011-09-05 17:29:53 +0000 | [diff] [blame] | 1485 | mogrify_image=EdgeImage(*image,geometry_info.rho, |
| 1486 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1487 | break; |
| 1488 | } |
| 1489 | if (LocaleCompare("emboss",option+1) == 0) |
| 1490 | { |
| 1491 | /* |
| 1492 | Gaussian embossen image. |
| 1493 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1494 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1495 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1496 | if ((flags & SigmaValue) == 0) |
| 1497 | geometry_info.sigma=1.0; |
| 1498 | mogrify_image=EmbossImage(*image,geometry_info.rho, |
| 1499 | geometry_info.sigma,exception); |
| 1500 | break; |
| 1501 | } |
| 1502 | if (LocaleCompare("encipher",option+1) == 0) |
| 1503 | { |
| 1504 | StringInfo |
| 1505 | *passkey; |
| 1506 | |
| 1507 | /* |
| 1508 | Encipher pixels. |
| 1509 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1510 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1511 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1512 | if (passkey != (StringInfo *) NULL) |
| 1513 | { |
| 1514 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1515 | passkey=DestroyStringInfo(passkey); |
| 1516 | } |
| 1517 | break; |
| 1518 | } |
| 1519 | if (LocaleCompare("encoding",option+1) == 0) |
| 1520 | { |
| 1521 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1522 | break; |
| 1523 | } |
| 1524 | if (LocaleCompare("enhance",option+1) == 0) |
| 1525 | { |
| 1526 | /* |
| 1527 | Enhance image. |
| 1528 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1529 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1530 | mogrify_image=EnhanceImage(*image,exception); |
| 1531 | break; |
| 1532 | } |
| 1533 | if (LocaleCompare("equalize",option+1) == 0) |
| 1534 | { |
| 1535 | /* |
| 1536 | Equalize image. |
| 1537 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1538 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 6d8c3d7 | 2011-08-22 01:20:01 +0000 | [diff] [blame] | 1539 | (void) EqualizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1540 | break; |
| 1541 | } |
| 1542 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1543 | { |
| 1544 | double |
| 1545 | constant; |
| 1546 | |
| 1547 | MagickEvaluateOperator |
| 1548 | op; |
| 1549 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1550 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1551 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 1552 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 1553 | constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+ |
| 1554 | 1.0); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1555 | (void) EvaluateImage(*image,op,constant,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1556 | break; |
| 1557 | } |
| 1558 | if (LocaleCompare("extent",option+1) == 0) |
| 1559 | { |
| 1560 | /* |
| 1561 | Set the image extent. |
| 1562 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1563 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1564 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1565 | if (geometry.width == 0) |
| 1566 | geometry.width=(*image)->columns; |
| 1567 | if (geometry.height == 0) |
| 1568 | geometry.height=(*image)->rows; |
| 1569 | mogrify_image=ExtentImage(*image,&geometry,exception); |
| 1570 | break; |
| 1571 | } |
| 1572 | break; |
| 1573 | } |
| 1574 | case 'f': |
| 1575 | { |
| 1576 | if (LocaleCompare("family",option+1) == 0) |
| 1577 | { |
| 1578 | if (*option == '+') |
| 1579 | { |
| 1580 | if (draw_info->family != (char *) NULL) |
| 1581 | draw_info->family=DestroyString(draw_info->family); |
| 1582 | break; |
| 1583 | } |
| 1584 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1585 | break; |
| 1586 | } |
| 1587 | if (LocaleCompare("features",option+1) == 0) |
| 1588 | { |
| 1589 | if (*option == '+') |
| 1590 | { |
| 1591 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1592 | break; |
| 1593 | } |
| 1594 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1595 | break; |
| 1596 | } |
| 1597 | if (LocaleCompare("fill",option+1) == 0) |
| 1598 | { |
| 1599 | ExceptionInfo |
| 1600 | *sans; |
| 1601 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1602 | GetPixelInfo(*image,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1603 | if (*option == '+') |
| 1604 | { |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1605 | (void) QueryColorCompliance("none",AllCompliance,&fill, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1606 | exception); |
| 1607 | (void) QueryColorCompliance("none",AllCompliance, |
| 1608 | &draw_info->fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1609 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1610 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1611 | break; |
| 1612 | } |
| 1613 | sans=AcquireExceptionInfo(); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1614 | (void) QueryColorCompliance(argv[i+1],AllCompliance,&fill, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1615 | sans); |
| 1616 | status=QueryColorCompliance(argv[i+1],AllCompliance, |
| 1617 | &draw_info->fill,sans); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1618 | sans=DestroyExceptionInfo(sans); |
| 1619 | if (status == MagickFalse) |
| 1620 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 1621 | exception); |
| 1622 | break; |
| 1623 | } |
| 1624 | if (LocaleCompare("flip",option+1) == 0) |
| 1625 | { |
| 1626 | /* |
| 1627 | Flip image scanlines. |
| 1628 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1629 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1630 | mogrify_image=FlipImage(*image,exception); |
| 1631 | break; |
| 1632 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1633 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1634 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1635 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1636 | target; |
| 1637 | |
| 1638 | /* |
| 1639 | Floodfill image. |
| 1640 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1641 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1642 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1643 | (void) QueryColorCompliance(argv[i+2],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1644 | exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1645 | (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x, |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 1646 | geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1647 | break; |
| 1648 | } |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1649 | if (LocaleCompare("flop",option+1) == 0) |
| 1650 | { |
| 1651 | /* |
| 1652 | Flop image scanlines. |
| 1653 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1654 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1655 | mogrify_image=FlopImage(*image,exception); |
| 1656 | break; |
| 1657 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1658 | if (LocaleCompare("font",option+1) == 0) |
| 1659 | { |
| 1660 | if (*option == '+') |
| 1661 | { |
| 1662 | if (draw_info->font != (char *) NULL) |
| 1663 | draw_info->font=DestroyString(draw_info->font); |
| 1664 | break; |
| 1665 | } |
| 1666 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1667 | break; |
| 1668 | } |
| 1669 | if (LocaleCompare("format",option+1) == 0) |
| 1670 | { |
| 1671 | format=argv[i+1]; |
| 1672 | break; |
| 1673 | } |
| 1674 | if (LocaleCompare("frame",option+1) == 0) |
| 1675 | { |
| 1676 | FrameInfo |
| 1677 | frame_info; |
| 1678 | |
| 1679 | /* |
| 1680 | Surround image with an ornamental border. |
| 1681 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1682 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1683 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1684 | frame_info.width=geometry.width; |
| 1685 | frame_info.height=geometry.height; |
| 1686 | if ((flags & HeightValue) == 0) |
| 1687 | frame_info.height=geometry.width; |
| 1688 | frame_info.outer_bevel=geometry.x; |
| 1689 | frame_info.inner_bevel=geometry.y; |
| 1690 | frame_info.x=(ssize_t) frame_info.width; |
| 1691 | frame_info.y=(ssize_t) frame_info.height; |
| 1692 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1693 | frame_info.height=(*image)->rows+2*frame_info.height; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1694 | mogrify_image=FrameImage(*image,&frame_info,compose,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1695 | break; |
| 1696 | } |
| 1697 | if (LocaleCompare("function",option+1) == 0) |
| 1698 | { |
| 1699 | char |
| 1700 | *arguments, |
| 1701 | token[MaxTextExtent]; |
| 1702 | |
| 1703 | const char |
| 1704 | *p; |
| 1705 | |
| 1706 | double |
| 1707 | *parameters; |
| 1708 | |
| 1709 | MagickFunction |
| 1710 | function; |
| 1711 | |
| 1712 | register ssize_t |
| 1713 | x; |
| 1714 | |
| 1715 | size_t |
| 1716 | number_parameters; |
| 1717 | |
| 1718 | /* |
| 1719 | Function Modify Image Values |
| 1720 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1721 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1722 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, |
| 1723 | MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1724 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1725 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1726 | if (arguments == (char *) NULL) |
| 1727 | break; |
| 1728 | p=(char *) arguments; |
| 1729 | for (x=0; *p != '\0'; x++) |
| 1730 | { |
| 1731 | GetMagickToken(p,&p,token); |
| 1732 | if (*token == ',') |
| 1733 | GetMagickToken(p,&p,token); |
| 1734 | } |
| 1735 | number_parameters=(size_t) x; |
| 1736 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1737 | sizeof(*parameters)); |
| 1738 | if (parameters == (double *) NULL) |
| 1739 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1740 | "MemoryAllocationFailed",(*image)->filename); |
| 1741 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1742 | sizeof(*parameters)); |
| 1743 | p=(char *) arguments; |
| 1744 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
| 1745 | { |
| 1746 | GetMagickToken(p,&p,token); |
| 1747 | if (*token == ',') |
| 1748 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1749 | parameters[x]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1750 | } |
| 1751 | arguments=DestroyString(arguments); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1752 | (void) FunctionImage(*image,function,number_parameters,parameters, |
| 1753 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1754 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1755 | break; |
| 1756 | } |
| 1757 | break; |
| 1758 | } |
| 1759 | case 'g': |
| 1760 | { |
| 1761 | if (LocaleCompare("gamma",option+1) == 0) |
| 1762 | { |
| 1763 | /* |
| 1764 | Gamma image. |
| 1765 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1766 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1767 | if (*option == '+') |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1768 | (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1769 | else |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1770 | (void) GammaImage(*image,StringToDouble(argv[i+1], |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 1771 | (char **) NULL),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1772 | break; |
| 1773 | } |
| 1774 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1775 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1776 | { |
| 1777 | /* |
| 1778 | Gaussian blur image. |
| 1779 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1780 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1781 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1782 | if ((flags & SigmaValue) == 0) |
| 1783 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1784 | if ((flags & XiValue) == 0) |
| 1785 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1786 | mogrify_image=GaussianBlurImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1787 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1788 | break; |
| 1789 | } |
| 1790 | if (LocaleCompare("geometry",option+1) == 0) |
| 1791 | { |
| 1792 | /* |
| 1793 | Record Image offset, Resize last image. |
| 1794 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1795 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1796 | if (*option == '+') |
| 1797 | { |
| 1798 | if ((*image)->geometry != (char *) NULL) |
| 1799 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1800 | break; |
| 1801 | } |
| 1802 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1803 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1804 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1805 | else |
| 1806 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 1807 | (*image)->filter,(*image)->blur,exception); |
| 1808 | break; |
| 1809 | } |
| 1810 | if (LocaleCompare("gravity",option+1) == 0) |
| 1811 | { |
| 1812 | if (*option == '+') |
| 1813 | { |
| 1814 | draw_info->gravity=UndefinedGravity; |
| 1815 | break; |
| 1816 | } |
| 1817 | draw_info->gravity=(GravityType) ParseCommandOption( |
| 1818 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1819 | break; |
| 1820 | } |
| 1821 | break; |
| 1822 | } |
| 1823 | case 'h': |
| 1824 | { |
| 1825 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1826 | { |
| 1827 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1828 | break; |
| 1829 | } |
| 1830 | break; |
| 1831 | } |
| 1832 | case 'i': |
| 1833 | { |
| 1834 | if (LocaleCompare("identify",option+1) == 0) |
| 1835 | { |
| 1836 | char |
| 1837 | *text; |
| 1838 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1839 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1840 | if (format == (char *) NULL) |
| 1841 | { |
cristy | a403727 | 2011-08-28 15:11:39 +0000 | [diff] [blame] | 1842 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose, |
| 1843 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1844 | break; |
| 1845 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1846 | text=InterpretImageProperties(mogrify_info,*image,format, |
| 1847 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1848 | if (text == (char *) NULL) |
| 1849 | break; |
| 1850 | (void) fputs(text,stdout); |
| 1851 | (void) fputc('\n',stdout); |
| 1852 | text=DestroyString(text); |
| 1853 | break; |
| 1854 | } |
| 1855 | if (LocaleCompare("implode",option+1) == 0) |
| 1856 | { |
| 1857 | /* |
| 1858 | Implode image. |
| 1859 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1860 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1861 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 76f512e | 2011-09-12 01:26:56 +0000 | [diff] [blame] | 1862 | mogrify_image=ImplodeImage(*image,geometry_info.rho, |
| 1863 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1864 | break; |
| 1865 | } |
| 1866 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1867 | { |
| 1868 | if (*option == '+') |
| 1869 | (void) ParseGeometry("0",&geometry_info); |
| 1870 | else |
| 1871 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1872 | draw_info->interline_spacing=geometry_info.rho; |
| 1873 | break; |
| 1874 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 1875 | if (LocaleCompare("interpolate",option+1) == 0) |
| 1876 | { |
| 1877 | interpolate_method=(PixelInterpolateMethod) ParseCommandOption( |
| 1878 | MagickInterpolateOptions,MagickFalse,argv[i+1]); |
| 1879 | break; |
| 1880 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1881 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1882 | { |
| 1883 | if (*option == '+') |
| 1884 | (void) ParseGeometry("0",&geometry_info); |
| 1885 | else |
| 1886 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1887 | draw_info->interword_spacing=geometry_info.rho; |
| 1888 | break; |
| 1889 | } |
| 1890 | break; |
| 1891 | } |
| 1892 | case 'k': |
| 1893 | { |
| 1894 | if (LocaleCompare("kerning",option+1) == 0) |
| 1895 | { |
| 1896 | if (*option == '+') |
| 1897 | (void) ParseGeometry("0",&geometry_info); |
| 1898 | else |
| 1899 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1900 | draw_info->kerning=geometry_info.rho; |
| 1901 | break; |
| 1902 | } |
| 1903 | break; |
| 1904 | } |
| 1905 | case 'l': |
| 1906 | { |
| 1907 | if (LocaleCompare("lat",option+1) == 0) |
| 1908 | { |
| 1909 | /* |
| 1910 | Local adaptive threshold image. |
| 1911 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1912 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1913 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1914 | if ((flags & PercentValue) != 0) |
| 1915 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 1916 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
cristy | de5cc63 | 2011-07-18 14:47:00 +0000 | [diff] [blame] | 1917 | geometry_info.rho,(size_t) geometry_info.sigma,(double) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1918 | geometry_info.xi,exception); |
| 1919 | break; |
| 1920 | } |
| 1921 | if (LocaleCompare("level",option+1) == 0) |
| 1922 | { |
| 1923 | MagickRealType |
| 1924 | black_point, |
| 1925 | gamma, |
| 1926 | white_point; |
| 1927 | |
| 1928 | MagickStatusType |
| 1929 | flags; |
| 1930 | |
| 1931 | /* |
| 1932 | Parse levels. |
| 1933 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1934 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1935 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1936 | black_point=geometry_info.rho; |
| 1937 | white_point=(MagickRealType) QuantumRange; |
| 1938 | if ((flags & SigmaValue) != 0) |
| 1939 | white_point=geometry_info.sigma; |
| 1940 | gamma=1.0; |
| 1941 | if ((flags & XiValue) != 0) |
| 1942 | gamma=geometry_info.xi; |
| 1943 | if ((flags & PercentValue) != 0) |
| 1944 | { |
| 1945 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 1946 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 1947 | } |
| 1948 | if ((flags & SigmaValue) == 0) |
| 1949 | white_point=(MagickRealType) QuantumRange-black_point; |
| 1950 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1951 | (void) LevelizeImage(*image,black_point,white_point,gamma, |
| 1952 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1953 | else |
cristy | 01e9afd | 2011-08-10 17:38:41 +0000 | [diff] [blame] | 1954 | (void) LevelImage(*image,black_point,white_point,gamma, |
| 1955 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1956 | break; |
| 1957 | } |
| 1958 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1959 | { |
| 1960 | char |
| 1961 | token[MaxTextExtent]; |
| 1962 | |
| 1963 | const char |
| 1964 | *p; |
| 1965 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1966 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1967 | black_point, |
| 1968 | white_point; |
| 1969 | |
| 1970 | p=(const char *) argv[i+1]; |
| 1971 | GetMagickToken(p,&p,token); /* get black point color */ |
| 1972 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1973 | (void) QueryColorCompliance(token,AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1974 | &black_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1975 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1976 | (void) QueryColorCompliance("#000000",AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1977 | &black_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1978 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1979 | GetMagickToken(p,&p,token); |
| 1980 | if (*token == '\0') |
| 1981 | white_point=black_point; /* set everything to that color */ |
| 1982 | else |
| 1983 | { |
| 1984 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 1985 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 1986 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1987 | (void) QueryColorCompliance(token,AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1988 | &white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1989 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1990 | (void) QueryColorCompliance("#ffffff",AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1991 | &white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1992 | } |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 1993 | (void) LevelImageColors(*image,&black_point,&white_point, |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1994 | *option == '+' ? MagickTrue : MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1995 | break; |
| 1996 | } |
| 1997 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 1998 | { |
| 1999 | double |
| 2000 | black_point, |
| 2001 | white_point; |
| 2002 | |
| 2003 | MagickStatusType |
| 2004 | flags; |
| 2005 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2006 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2007 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2008 | black_point=geometry_info.rho; |
| 2009 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 2010 | if ((flags & SigmaValue) != 0) |
| 2011 | white_point=geometry_info.sigma; |
| 2012 | if ((flags & PercentValue) != 0) |
| 2013 | { |
| 2014 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 2015 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 2016 | } |
| 2017 | if ((flags & SigmaValue) == 0) |
| 2018 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 2019 | black_point; |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2020 | (void) LinearStretchImage(*image,black_point,white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2021 | break; |
| 2022 | } |
| 2023 | if (LocaleCompare("linewidth",option+1) == 0) |
| 2024 | { |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2025 | draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2026 | break; |
| 2027 | } |
| 2028 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 2029 | { |
| 2030 | /* |
| 2031 | Liquid rescale image. |
| 2032 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2033 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2034 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2035 | if ((flags & XValue) == 0) |
| 2036 | geometry.x=1; |
| 2037 | if ((flags & YValue) == 0) |
| 2038 | geometry.y=0; |
| 2039 | mogrify_image=LiquidRescaleImage(*image,geometry.width, |
| 2040 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 2041 | break; |
| 2042 | } |
| 2043 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 2044 | { |
| 2045 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 2046 | break; |
| 2047 | } |
| 2048 | break; |
| 2049 | } |
| 2050 | case 'm': |
| 2051 | { |
| 2052 | if (LocaleCompare("map",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2053 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2054 | Image |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2055 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2056 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2057 | /* |
| 2058 | Transform image colors to match this set of colors. |
| 2059 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2060 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2061 | if (*option == '+') |
| 2062 | break; |
| 2063 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2064 | if (remap_image == (Image *) NULL) |
| 2065 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2066 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2067 | remap_image=DestroyImage(remap_image); |
| 2068 | break; |
| 2069 | } |
| 2070 | if (LocaleCompare("mask",option+1) == 0) |
| 2071 | { |
| 2072 | Image |
| 2073 | *mask; |
| 2074 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2075 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2076 | if (*option == '+') |
| 2077 | { |
| 2078 | /* |
| 2079 | Remove a mask. |
| 2080 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2081 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2082 | break; |
| 2083 | } |
| 2084 | /* |
| 2085 | Set the image mask. |
| 2086 | */ |
| 2087 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2088 | if (mask == (Image *) NULL) |
| 2089 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2090 | (void) SetImageMask(*image,mask,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2091 | mask=DestroyImage(mask); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2092 | break; |
| 2093 | } |
| 2094 | if (LocaleCompare("matte",option+1) == 0) |
| 2095 | { |
| 2096 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 2097 | SetAlphaChannel : DeactivateAlphaChannel,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2098 | break; |
| 2099 | } |
| 2100 | if (LocaleCompare("median",option+1) == 0) |
| 2101 | { |
| 2102 | /* |
| 2103 | Median filter image. |
| 2104 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2105 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2106 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2107 | if ((flags & SigmaValue) == 0) |
| 2108 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2109 | mogrify_image=StatisticImage(*image,MedianStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2110 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2111 | break; |
| 2112 | } |
| 2113 | if (LocaleCompare("mode",option+1) == 0) |
| 2114 | { |
| 2115 | /* |
| 2116 | Mode image. |
| 2117 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2118 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2119 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2120 | if ((flags & SigmaValue) == 0) |
| 2121 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2122 | mogrify_image=StatisticImage(*image,ModeStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2123 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2124 | break; |
| 2125 | } |
| 2126 | if (LocaleCompare("modulate",option+1) == 0) |
| 2127 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2128 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2129 | (void) ModulateImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2130 | break; |
| 2131 | } |
| 2132 | if (LocaleCompare("monitor",option+1) == 0) |
| 2133 | { |
| 2134 | if (*option == '+') |
| 2135 | { |
| 2136 | (void) SetImageProgressMonitor(*image, |
| 2137 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2138 | break; |
| 2139 | } |
| 2140 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2141 | (void *) NULL); |
| 2142 | break; |
| 2143 | } |
| 2144 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2145 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2146 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2147 | (void) SetImageType(*image,BilevelType,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2148 | break; |
| 2149 | } |
| 2150 | if (LocaleCompare("morphology",option+1) == 0) |
| 2151 | { |
| 2152 | char |
| 2153 | token[MaxTextExtent]; |
| 2154 | |
| 2155 | const char |
| 2156 | *p; |
| 2157 | |
| 2158 | KernelInfo |
| 2159 | *kernel; |
| 2160 | |
| 2161 | MorphologyMethod |
| 2162 | method; |
| 2163 | |
| 2164 | ssize_t |
| 2165 | iterations; |
| 2166 | |
| 2167 | /* |
| 2168 | Morphological Image Operation |
| 2169 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2170 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2171 | p=argv[i+1]; |
| 2172 | GetMagickToken(p,&p,token); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2173 | method=(MorphologyMethod) ParseCommandOption( |
| 2174 | MagickMorphologyOptions,MagickFalse,token); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2175 | iterations=1L; |
| 2176 | GetMagickToken(p,&p,token); |
| 2177 | if ((*p == ':') || (*p == ',')) |
| 2178 | GetMagickToken(p,&p,token); |
| 2179 | if ((*p != '\0')) |
| 2180 | iterations=(ssize_t) StringToLong(p); |
| 2181 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2182 | if (kernel == (KernelInfo *) NULL) |
| 2183 | { |
| 2184 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2185 | OptionError,"UnabletoParseKernel","morphology"); |
| 2186 | status=MagickFalse; |
| 2187 | break; |
| 2188 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2189 | mogrify_image=MorphologyImage(*image,method,iterations,kernel, |
| 2190 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2191 | kernel=DestroyKernelInfo(kernel); |
| 2192 | break; |
| 2193 | } |
| 2194 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2195 | { |
| 2196 | /* |
| 2197 | Motion blur image. |
| 2198 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2199 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2200 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2201 | if ((flags & SigmaValue) == 0) |
| 2202 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2203 | mogrify_image=MotionBlurImage(*image,geometry_info.rho, |
cristy | 7497f48 | 2011-12-08 01:57:31 +0000 | [diff] [blame] | 2204 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2205 | break; |
| 2206 | } |
| 2207 | break; |
| 2208 | } |
| 2209 | case 'n': |
| 2210 | { |
| 2211 | if (LocaleCompare("negate",option+1) == 0) |
| 2212 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2213 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2214 | (void) NegateImage(*image,*option == '+' ? MagickTrue : |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 2215 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2216 | break; |
| 2217 | } |
| 2218 | if (LocaleCompare("noise",option+1) == 0) |
| 2219 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2220 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2221 | if (*option == '-') |
| 2222 | { |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2223 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2224 | if ((flags & SigmaValue) == 0) |
| 2225 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2226 | mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2227 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2228 | } |
| 2229 | else |
| 2230 | { |
| 2231 | NoiseType |
| 2232 | noise; |
| 2233 | |
| 2234 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
| 2235 | MagickFalse,argv[i+1]); |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 2236 | mogrify_image=AddNoiseImage(*image,noise,attenuate,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2237 | } |
| 2238 | break; |
| 2239 | } |
| 2240 | if (LocaleCompare("normalize",option+1) == 0) |
| 2241 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2242 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 2243 | (void) NormalizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2244 | break; |
| 2245 | } |
| 2246 | break; |
| 2247 | } |
| 2248 | case 'o': |
| 2249 | { |
| 2250 | if (LocaleCompare("opaque",option+1) == 0) |
| 2251 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2252 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2253 | target; |
| 2254 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2255 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2256 | (void) QueryColorCompliance(argv[i+1],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2257 | exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 2258 | (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ? |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 2259 | MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2260 | break; |
| 2261 | } |
| 2262 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2263 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2264 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 1302067 | 2011-07-08 02:33:26 +0000 | [diff] [blame] | 2265 | (void) OrderedPosterizeImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2266 | break; |
| 2267 | } |
| 2268 | break; |
| 2269 | } |
| 2270 | case 'p': |
| 2271 | { |
| 2272 | if (LocaleCompare("paint",option+1) == 0) |
| 2273 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2274 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2275 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 14973ba | 2011-08-27 23:48:07 +0000 | [diff] [blame] | 2276 | mogrify_image=OilPaintImage(*image,geometry_info.rho, |
| 2277 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2278 | break; |
| 2279 | } |
| 2280 | if (LocaleCompare("pen",option+1) == 0) |
| 2281 | { |
| 2282 | if (*option == '+') |
| 2283 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2284 | (void) QueryColorCompliance("none",AllCompliance, |
| 2285 | &draw_info->fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2286 | break; |
| 2287 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2288 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 2289 | &draw_info->fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2290 | break; |
| 2291 | } |
| 2292 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2293 | { |
| 2294 | if (*option == '+') |
| 2295 | (void) ParseGeometry("12",&geometry_info); |
| 2296 | else |
| 2297 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2298 | draw_info->pointsize=geometry_info.rho; |
| 2299 | break; |
| 2300 | } |
| 2301 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2302 | { |
cristy | e9e3d38 | 2011-12-14 01:50:13 +0000 | [diff] [blame] | 2303 | const char |
| 2304 | *caption; |
| 2305 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2306 | double |
| 2307 | angle; |
| 2308 | |
| 2309 | RandomInfo |
| 2310 | *random_info; |
| 2311 | |
| 2312 | /* |
| 2313 | Simulate a Polaroid picture. |
| 2314 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2315 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2316 | random_info=AcquireRandomInfo(); |
| 2317 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2318 | random_info=DestroyRandomInfo(random_info); |
| 2319 | if (*option == '-') |
| 2320 | { |
| 2321 | SetGeometryInfo(&geometry_info); |
| 2322 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2323 | angle=geometry_info.rho; |
| 2324 | } |
cristy | e9e3d38 | 2011-12-14 01:50:13 +0000 | [diff] [blame] | 2325 | caption=GetImageProperty(*image,"caption",exception); |
| 2326 | mogrify_image=PolaroidImage(*image,draw_info,caption,angle, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2327 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2328 | break; |
| 2329 | } |
| 2330 | if (LocaleCompare("posterize",option+1) == 0) |
| 2331 | { |
| 2332 | /* |
| 2333 | Posterize image. |
| 2334 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2335 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2336 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2337 | quantize_info->dither,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2338 | break; |
| 2339 | } |
| 2340 | if (LocaleCompare("preview",option+1) == 0) |
| 2341 | { |
| 2342 | PreviewType |
| 2343 | preview_type; |
| 2344 | |
| 2345 | /* |
| 2346 | Preview image. |
| 2347 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2348 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2349 | if (*option == '+') |
| 2350 | preview_type=UndefinedPreview; |
| 2351 | else |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2352 | preview_type=(PreviewType) ParseCommandOption( |
| 2353 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2354 | mogrify_image=PreviewImage(*image,preview_type,exception); |
| 2355 | break; |
| 2356 | } |
| 2357 | if (LocaleCompare("profile",option+1) == 0) |
| 2358 | { |
| 2359 | const char |
| 2360 | *name; |
| 2361 | |
| 2362 | const StringInfo |
| 2363 | *profile; |
| 2364 | |
| 2365 | Image |
| 2366 | *profile_image; |
| 2367 | |
| 2368 | ImageInfo |
| 2369 | *profile_info; |
| 2370 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2371 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2372 | if (*option == '+') |
| 2373 | { |
| 2374 | /* |
| 2375 | Remove a profile from the image. |
| 2376 | */ |
| 2377 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
cristy | 092d71c | 2011-10-14 18:01:29 +0000 | [diff] [blame] | 2378 | NULL,0,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2379 | break; |
| 2380 | } |
| 2381 | /* |
| 2382 | Associate a profile with the image. |
| 2383 | */ |
| 2384 | profile_info=CloneImageInfo(mogrify_info); |
| 2385 | profile=GetImageProfile(*image,"iptc"); |
| 2386 | if (profile != (StringInfo *) NULL) |
| 2387 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2388 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2389 | profile_info=DestroyImageInfo(profile_info); |
| 2390 | if (profile_image == (Image *) NULL) |
| 2391 | { |
| 2392 | StringInfo |
| 2393 | *profile; |
| 2394 | |
| 2395 | profile_info=CloneImageInfo(mogrify_info); |
| 2396 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2397 | MaxTextExtent); |
| 2398 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
| 2399 | if (profile != (StringInfo *) NULL) |
| 2400 | { |
| 2401 | (void) ProfileImage(*image,profile_info->magick, |
| 2402 | GetStringInfoDatum(profile),(size_t) |
cristy | 3fac9ec | 2011-11-17 18:04:39 +0000 | [diff] [blame] | 2403 | GetStringInfoLength(profile),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2404 | profile=DestroyStringInfo(profile); |
| 2405 | } |
| 2406 | profile_info=DestroyImageInfo(profile_info); |
| 2407 | break; |
| 2408 | } |
| 2409 | ResetImageProfileIterator(profile_image); |
| 2410 | name=GetNextImageProfile(profile_image); |
| 2411 | while (name != (const char *) NULL) |
| 2412 | { |
| 2413 | profile=GetImageProfile(profile_image,name); |
| 2414 | if (profile != (StringInfo *) NULL) |
| 2415 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
cristy | 3fac9ec | 2011-11-17 18:04:39 +0000 | [diff] [blame] | 2416 | (size_t) GetStringInfoLength(profile),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2417 | name=GetNextImageProfile(profile_image); |
| 2418 | } |
| 2419 | profile_image=DestroyImage(profile_image); |
| 2420 | break; |
| 2421 | } |
| 2422 | break; |
| 2423 | } |
| 2424 | case 'q': |
| 2425 | { |
| 2426 | if (LocaleCompare("quantize",option+1) == 0) |
| 2427 | { |
| 2428 | if (*option == '+') |
| 2429 | { |
| 2430 | quantize_info->colorspace=UndefinedColorspace; |
| 2431 | break; |
| 2432 | } |
| 2433 | quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
| 2434 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2435 | break; |
| 2436 | } |
| 2437 | break; |
| 2438 | } |
| 2439 | case 'r': |
| 2440 | { |
| 2441 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2442 | { |
| 2443 | /* |
| 2444 | Radial blur image. |
| 2445 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2446 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 6435bd9 | 2011-09-10 02:10:07 +0000 | [diff] [blame] | 2447 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2448 | mogrify_image=RadialBlurImage(*image,geometry_info.rho, |
| 2449 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2450 | break; |
| 2451 | } |
| 2452 | if (LocaleCompare("raise",option+1) == 0) |
| 2453 | { |
| 2454 | /* |
| 2455 | Surround image with a raise of solid color. |
| 2456 | */ |
| 2457 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2458 | if ((flags & SigmaValue) == 0) |
| 2459 | geometry.height=geometry.width; |
| 2460 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
cristy | 6170ac3 | 2011-08-28 14:15:37 +0000 | [diff] [blame] | 2461 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2462 | break; |
| 2463 | } |
| 2464 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2465 | { |
| 2466 | /* |
| 2467 | Threshold image. |
| 2468 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2469 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2470 | (void) RandomThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2471 | break; |
| 2472 | } |
| 2473 | if (LocaleCompare("recolor",option+1) == 0) |
| 2474 | { |
| 2475 | KernelInfo |
| 2476 | *kernel; |
| 2477 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2478 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2479 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2480 | if (kernel == (KernelInfo *) NULL) |
| 2481 | break; |
| 2482 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 2483 | kernel=DestroyKernelInfo(kernel); |
| 2484 | break; |
| 2485 | } |
| 2486 | if (LocaleCompare("region",option+1) == 0) |
| 2487 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2488 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2489 | if (region_image != (Image *) NULL) |
| 2490 | { |
| 2491 | /* |
| 2492 | Composite region. |
| 2493 | */ |
| 2494 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2495 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 2496 | region_geometry.x,region_geometry.y,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2497 | *image=DestroyImage(*image); |
| 2498 | *image=region_image; |
| 2499 | region_image = (Image *) NULL; |
| 2500 | } |
| 2501 | if (*option == '+') |
| 2502 | break; |
| 2503 | /* |
| 2504 | Apply transformations to a selected region of the image. |
| 2505 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2506 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2507 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2508 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2509 | if (mogrify_image == (Image *) NULL) |
| 2510 | break; |
| 2511 | region_image=(*image); |
| 2512 | *image=mogrify_image; |
| 2513 | mogrify_image=(Image *) NULL; |
| 2514 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2515 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2516 | if (LocaleCompare("render",option+1) == 0) |
| 2517 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2518 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2519 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2520 | break; |
| 2521 | } |
| 2522 | if (LocaleCompare("remap",option+1) == 0) |
| 2523 | { |
| 2524 | Image |
| 2525 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2526 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2527 | /* |
| 2528 | Transform image colors to match this set of colors. |
| 2529 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2530 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2531 | if (*option == '+') |
| 2532 | break; |
| 2533 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2534 | if (remap_image == (Image *) NULL) |
| 2535 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2536 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2537 | remap_image=DestroyImage(remap_image); |
| 2538 | break; |
| 2539 | } |
| 2540 | if (LocaleCompare("repage",option+1) == 0) |
| 2541 | { |
| 2542 | if (*option == '+') |
| 2543 | { |
| 2544 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2545 | break; |
| 2546 | } |
| 2547 | (void) ResetImagePage(*image,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2548 | break; |
| 2549 | } |
| 2550 | if (LocaleCompare("resample",option+1) == 0) |
| 2551 | { |
| 2552 | /* |
| 2553 | Resample image. |
| 2554 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2555 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2556 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2557 | if ((flags & SigmaValue) == 0) |
| 2558 | geometry_info.sigma=geometry_info.rho; |
| 2559 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
| 2560 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2561 | break; |
| 2562 | } |
| 2563 | if (LocaleCompare("resize",option+1) == 0) |
| 2564 | { |
| 2565 | /* |
| 2566 | Resize image. |
| 2567 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2568 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2569 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2570 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2571 | (*image)->filter,(*image)->blur,exception); |
| 2572 | break; |
| 2573 | } |
| 2574 | if (LocaleCompare("roll",option+1) == 0) |
| 2575 | { |
| 2576 | /* |
| 2577 | Roll image. |
| 2578 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2579 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2580 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2581 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2582 | break; |
| 2583 | } |
| 2584 | if (LocaleCompare("rotate",option+1) == 0) |
| 2585 | { |
| 2586 | char |
| 2587 | *geometry; |
| 2588 | |
| 2589 | /* |
| 2590 | Check for conditional image rotation. |
| 2591 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2592 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2593 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2594 | if ((*image)->columns <= (*image)->rows) |
| 2595 | break; |
| 2596 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2597 | if ((*image)->columns >= (*image)->rows) |
| 2598 | break; |
| 2599 | /* |
| 2600 | Rotate image. |
| 2601 | */ |
| 2602 | geometry=ConstantString(argv[i+1]); |
| 2603 | (void) SubstituteString(&geometry,">",""); |
| 2604 | (void) SubstituteString(&geometry,"<",""); |
| 2605 | (void) ParseGeometry(geometry,&geometry_info); |
| 2606 | geometry=DestroyString(geometry); |
| 2607 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
| 2608 | break; |
| 2609 | } |
| 2610 | break; |
| 2611 | } |
| 2612 | case 's': |
| 2613 | { |
| 2614 | if (LocaleCompare("sample",option+1) == 0) |
| 2615 | { |
| 2616 | /* |
| 2617 | Sample image with pixel replication. |
| 2618 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2619 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2620 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2621 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
| 2622 | exception); |
| 2623 | break; |
| 2624 | } |
| 2625 | if (LocaleCompare("scale",option+1) == 0) |
| 2626 | { |
| 2627 | /* |
| 2628 | Resize image. |
| 2629 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2630 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2631 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2632 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2633 | exception); |
| 2634 | break; |
| 2635 | } |
| 2636 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2637 | { |
| 2638 | /* |
| 2639 | Selectively blur pixels within a contrast threshold. |
| 2640 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2641 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2642 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2643 | if ((flags & PercentValue) != 0) |
| 2644 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2645 | mogrify_image=SelectiveBlurImage(*image,geometry_info.rho, |
cristy | 1e7aa31 | 2011-09-10 20:01:36 +0000 | [diff] [blame] | 2646 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2647 | break; |
| 2648 | } |
| 2649 | if (LocaleCompare("separate",option+1) == 0) |
| 2650 | { |
| 2651 | /* |
| 2652 | Break channels into separate images. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2653 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2654 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 2655 | mogrify_image=SeparateImages(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2656 | break; |
| 2657 | } |
| 2658 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2659 | { |
| 2660 | double |
| 2661 | threshold; |
| 2662 | |
| 2663 | /* |
| 2664 | Sepia-tone image. |
| 2665 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2666 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2667 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 2668 | 1.0); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2669 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
| 2670 | break; |
| 2671 | } |
| 2672 | if (LocaleCompare("segment",option+1) == 0) |
| 2673 | { |
| 2674 | /* |
| 2675 | Segment image. |
| 2676 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2677 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2678 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2679 | if ((flags & SigmaValue) == 0) |
| 2680 | geometry_info.sigma=1.0; |
| 2681 | (void) SegmentImage(*image,(*image)->colorspace, |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2682 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 2683 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2684 | break; |
| 2685 | } |
| 2686 | if (LocaleCompare("set",option+1) == 0) |
| 2687 | { |
| 2688 | char |
| 2689 | *value; |
| 2690 | |
| 2691 | /* |
| 2692 | Set image option. |
| 2693 | */ |
| 2694 | if (*option == '+') |
| 2695 | { |
| 2696 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2697 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2698 | else |
| 2699 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2700 | { |
| 2701 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
| 2702 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2703 | } |
| 2704 | else |
| 2705 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2706 | break; |
| 2707 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2708 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2709 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2710 | if (value == (char *) NULL) |
| 2711 | break; |
| 2712 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2713 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2714 | exception); |
| 2715 | else |
| 2716 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2717 | { |
| 2718 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
| 2719 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
| 2720 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2721 | } |
| 2722 | else |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 2723 | (void) SetImageProperty(*image,argv[i+1],value,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2724 | value=DestroyString(value); |
| 2725 | break; |
| 2726 | } |
| 2727 | if (LocaleCompare("shade",option+1) == 0) |
| 2728 | { |
| 2729 | /* |
| 2730 | Shade image. |
| 2731 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2732 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2733 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2734 | if ((flags & SigmaValue) == 0) |
| 2735 | geometry_info.sigma=1.0; |
| 2736 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2737 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2738 | break; |
| 2739 | } |
| 2740 | if (LocaleCompare("shadow",option+1) == 0) |
| 2741 | { |
| 2742 | /* |
| 2743 | Shadow image. |
| 2744 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2745 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2746 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2747 | if ((flags & SigmaValue) == 0) |
| 2748 | geometry_info.sigma=1.0; |
| 2749 | if ((flags & XiValue) == 0) |
| 2750 | geometry_info.xi=4.0; |
| 2751 | if ((flags & PsiValue) == 0) |
| 2752 | geometry_info.psi=4.0; |
| 2753 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
cristy | eb6e658 | 2011-12-09 09:14:23 +0000 | [diff] [blame] | 2754 | geometry_info.sigma,(*image)->bias,(ssize_t) |
| 2755 | ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5), |
| 2756 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2757 | break; |
| 2758 | } |
| 2759 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2760 | { |
| 2761 | /* |
| 2762 | Sharpen image. |
| 2763 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2764 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2765 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2766 | if ((flags & SigmaValue) == 0) |
| 2767 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2768 | if ((flags & XiValue) == 0) |
| 2769 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2770 | mogrify_image=SharpenImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2771 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2772 | break; |
| 2773 | } |
| 2774 | if (LocaleCompare("shave",option+1) == 0) |
| 2775 | { |
| 2776 | /* |
| 2777 | Shave the image edges. |
| 2778 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2779 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2780 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2781 | mogrify_image=ShaveImage(*image,&geometry,exception); |
| 2782 | break; |
| 2783 | } |
| 2784 | if (LocaleCompare("shear",option+1) == 0) |
| 2785 | { |
| 2786 | /* |
| 2787 | Shear image. |
| 2788 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2789 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2790 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2791 | if ((flags & SigmaValue) == 0) |
| 2792 | geometry_info.sigma=geometry_info.rho; |
| 2793 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2794 | geometry_info.sigma,exception); |
| 2795 | break; |
| 2796 | } |
| 2797 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2798 | { |
| 2799 | /* |
| 2800 | Sigmoidal non-linearity contrast control. |
| 2801 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2802 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2803 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2804 | if ((flags & SigmaValue) == 0) |
| 2805 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 2806 | if ((flags & PercentValue) != 0) |
| 2807 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2808 | 100.0; |
cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 2809 | (void) SigmoidalContrastImage(*image,(*option == '-') ? |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2810 | MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma, |
| 2811 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2812 | break; |
| 2813 | } |
| 2814 | if (LocaleCompare("sketch",option+1) == 0) |
| 2815 | { |
| 2816 | /* |
| 2817 | Sketch image. |
| 2818 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2819 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2820 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2821 | if ((flags & SigmaValue) == 0) |
| 2822 | geometry_info.sigma=1.0; |
| 2823 | mogrify_image=SketchImage(*image,geometry_info.rho, |
cristy | f7ef025 | 2011-09-09 14:50:06 +0000 | [diff] [blame] | 2824 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2825 | break; |
| 2826 | } |
| 2827 | if (LocaleCompare("solarize",option+1) == 0) |
| 2828 | { |
| 2829 | double |
| 2830 | threshold; |
| 2831 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2832 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2833 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 2834 | 1.0); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 2835 | (void) SolarizeImage(*image,threshold,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2836 | break; |
| 2837 | } |
| 2838 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2839 | { |
| 2840 | SparseColorMethod |
| 2841 | method; |
| 2842 | |
| 2843 | char |
| 2844 | *arguments; |
| 2845 | |
| 2846 | /* |
| 2847 | Sparse Color Interpolated Gradient |
| 2848 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2849 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2850 | method=(SparseColorMethod) ParseCommandOption( |
| 2851 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2852 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2853 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2854 | if (arguments == (char *) NULL) |
| 2855 | break; |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 2856 | mogrify_image=SparseColorOption(*image,method,arguments, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2857 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2858 | arguments=DestroyString(arguments); |
| 2859 | break; |
| 2860 | } |
| 2861 | if (LocaleCompare("splice",option+1) == 0) |
| 2862 | { |
| 2863 | /* |
| 2864 | Splice a solid color into the image. |
| 2865 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2866 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2867 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 2868 | mogrify_image=SpliceImage(*image,&geometry,exception); |
| 2869 | break; |
| 2870 | } |
| 2871 | if (LocaleCompare("spread",option+1) == 0) |
| 2872 | { |
| 2873 | /* |
| 2874 | Spread an image. |
| 2875 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2876 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2877 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame] | 2878 | mogrify_image=SpreadImage(*image,geometry_info.rho, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2879 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2880 | break; |
| 2881 | } |
| 2882 | if (LocaleCompare("statistic",option+1) == 0) |
| 2883 | { |
| 2884 | StatisticType |
| 2885 | type; |
| 2886 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2887 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2888 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
| 2889 | MagickFalse,argv[i+1]); |
| 2890 | (void) ParseGeometry(argv[i+2],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2891 | mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho, |
| 2892 | (size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2893 | break; |
| 2894 | } |
| 2895 | if (LocaleCompare("stretch",option+1) == 0) |
| 2896 | { |
| 2897 | if (*option == '+') |
| 2898 | { |
| 2899 | draw_info->stretch=UndefinedStretch; |
| 2900 | break; |
| 2901 | } |
| 2902 | draw_info->stretch=(StretchType) ParseCommandOption( |
| 2903 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2904 | break; |
| 2905 | } |
| 2906 | if (LocaleCompare("strip",option+1) == 0) |
| 2907 | { |
| 2908 | /* |
| 2909 | Strip image of profiles and comments. |
| 2910 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2911 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 2912 | (void) StripImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2913 | break; |
| 2914 | } |
| 2915 | if (LocaleCompare("stroke",option+1) == 0) |
| 2916 | { |
| 2917 | ExceptionInfo |
| 2918 | *sans; |
| 2919 | |
| 2920 | if (*option == '+') |
| 2921 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2922 | (void) QueryColorCompliance("none",AllCompliance, |
| 2923 | &draw_info->stroke,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2924 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2925 | draw_info->stroke_pattern=DestroyImage( |
| 2926 | draw_info->stroke_pattern); |
| 2927 | break; |
| 2928 | } |
| 2929 | sans=AcquireExceptionInfo(); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2930 | status=QueryColorCompliance(argv[i+1],AllCompliance, |
| 2931 | &draw_info->stroke,sans); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2932 | sans=DestroyExceptionInfo(sans); |
| 2933 | if (status == MagickFalse) |
| 2934 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2935 | exception); |
| 2936 | break; |
| 2937 | } |
| 2938 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2939 | { |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2940 | draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2941 | break; |
| 2942 | } |
| 2943 | if (LocaleCompare("style",option+1) == 0) |
| 2944 | { |
| 2945 | if (*option == '+') |
| 2946 | { |
| 2947 | draw_info->style=UndefinedStyle; |
| 2948 | break; |
| 2949 | } |
| 2950 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 2951 | MagickFalse,argv[i+1]); |
| 2952 | break; |
| 2953 | } |
| 2954 | if (LocaleCompare("swirl",option+1) == 0) |
| 2955 | { |
| 2956 | /* |
| 2957 | Swirl image. |
| 2958 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2959 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2960 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 76f512e | 2011-09-12 01:26:56 +0000 | [diff] [blame] | 2961 | mogrify_image=SwirlImage(*image,geometry_info.rho, |
| 2962 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2963 | break; |
| 2964 | } |
| 2965 | break; |
| 2966 | } |
| 2967 | case 't': |
| 2968 | { |
| 2969 | if (LocaleCompare("threshold",option+1) == 0) |
| 2970 | { |
| 2971 | double |
| 2972 | threshold; |
| 2973 | |
| 2974 | /* |
| 2975 | Threshold image. |
| 2976 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2977 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2978 | if (*option == '+') |
anthony | 247a86d | 2011-05-03 13:18:18 +0000 | [diff] [blame] | 2979 | threshold=(double) QuantumRange/2; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2980 | else |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2981 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 2982 | 1.0); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 2983 | (void) BilevelImage(*image,threshold,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2984 | break; |
| 2985 | } |
| 2986 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2987 | { |
| 2988 | /* |
| 2989 | Thumbnail image. |
| 2990 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2991 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2992 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2993 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2994 | exception); |
| 2995 | break; |
| 2996 | } |
| 2997 | if (LocaleCompare("tile",option+1) == 0) |
| 2998 | { |
| 2999 | if (*option == '+') |
| 3000 | { |
| 3001 | if (draw_info->fill_pattern != (Image *) NULL) |
| 3002 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 3003 | break; |
| 3004 | } |
| 3005 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 3006 | exception); |
| 3007 | break; |
| 3008 | } |
| 3009 | if (LocaleCompare("tint",option+1) == 0) |
| 3010 | { |
| 3011 | /* |
| 3012 | Tint the image. |
| 3013 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3014 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 3015 | mogrify_image=TintImage(*image,argv[i+1],&fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3016 | break; |
| 3017 | } |
| 3018 | if (LocaleCompare("transform",option+1) == 0) |
| 3019 | { |
| 3020 | /* |
| 3021 | Affine transform image. |
| 3022 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3023 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3024 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
| 3025 | exception); |
| 3026 | break; |
| 3027 | } |
| 3028 | if (LocaleCompare("transparent",option+1) == 0) |
| 3029 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 3030 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3031 | target; |
| 3032 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3033 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 3034 | (void) QueryColorCompliance(argv[i+1],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 3035 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3036 | (void) TransparentPaintImage(*image,&target,(Quantum) |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 3037 | TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue, |
cristy | 82d7af5 | 2011-10-16 16:26:41 +0000 | [diff] [blame] | 3038 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3039 | break; |
| 3040 | } |
| 3041 | if (LocaleCompare("transpose",option+1) == 0) |
| 3042 | { |
| 3043 | /* |
| 3044 | Transpose image scanlines. |
| 3045 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3046 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3047 | mogrify_image=TransposeImage(*image,exception); |
| 3048 | break; |
| 3049 | } |
| 3050 | if (LocaleCompare("transverse",option+1) == 0) |
| 3051 | { |
| 3052 | /* |
| 3053 | Transverse image scanlines. |
| 3054 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3055 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3056 | mogrify_image=TransverseImage(*image,exception); |
| 3057 | break; |
| 3058 | } |
| 3059 | if (LocaleCompare("treedepth",option+1) == 0) |
| 3060 | { |
| 3061 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
| 3062 | break; |
| 3063 | } |
| 3064 | if (LocaleCompare("trim",option+1) == 0) |
| 3065 | { |
| 3066 | /* |
| 3067 | Trim image. |
| 3068 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3069 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3070 | mogrify_image=TrimImage(*image,exception); |
| 3071 | break; |
| 3072 | } |
| 3073 | if (LocaleCompare("type",option+1) == 0) |
| 3074 | { |
| 3075 | ImageType |
| 3076 | type; |
| 3077 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3078 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3079 | if (*option == '+') |
| 3080 | type=UndefinedType; |
| 3081 | else |
| 3082 | type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 3083 | argv[i+1]); |
| 3084 | (*image)->type=UndefinedType; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3085 | (void) SetImageType(*image,type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3086 | break; |
| 3087 | } |
| 3088 | break; |
| 3089 | } |
| 3090 | case 'u': |
| 3091 | { |
| 3092 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3093 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 3094 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 3095 | &draw_info->undercolor,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3096 | break; |
| 3097 | } |
| 3098 | if (LocaleCompare("unique",option+1) == 0) |
| 3099 | { |
| 3100 | if (*option == '+') |
| 3101 | { |
| 3102 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
| 3103 | break; |
| 3104 | } |
| 3105 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
| 3106 | (void) SetImageArtifact(*image,"verbose","true"); |
| 3107 | break; |
| 3108 | } |
| 3109 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3110 | { |
| 3111 | /* |
| 3112 | Unique image colors. |
| 3113 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3114 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3115 | mogrify_image=UniqueImageColors(*image,exception); |
| 3116 | break; |
| 3117 | } |
| 3118 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3119 | { |
| 3120 | /* |
| 3121 | Unsharp mask image. |
| 3122 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3123 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3124 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3125 | if ((flags & SigmaValue) == 0) |
| 3126 | geometry_info.sigma=1.0; |
| 3127 | if ((flags & XiValue) == 0) |
| 3128 | geometry_info.xi=1.0; |
| 3129 | if ((flags & PsiValue) == 0) |
| 3130 | geometry_info.psi=0.05; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3131 | mogrify_image=UnsharpMaskImage(*image,geometry_info.rho, |
| 3132 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3133 | break; |
| 3134 | } |
| 3135 | break; |
| 3136 | } |
| 3137 | case 'v': |
| 3138 | { |
| 3139 | if (LocaleCompare("verbose",option+1) == 0) |
| 3140 | { |
| 3141 | (void) SetImageArtifact(*image,option+1, |
| 3142 | *option == '+' ? "false" : "true"); |
| 3143 | break; |
| 3144 | } |
| 3145 | if (LocaleCompare("vignette",option+1) == 0) |
| 3146 | { |
| 3147 | /* |
| 3148 | Vignette image. |
| 3149 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3150 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3151 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3152 | if ((flags & SigmaValue) == 0) |
| 3153 | geometry_info.sigma=1.0; |
| 3154 | if ((flags & XiValue) == 0) |
| 3155 | geometry_info.xi=0.1*(*image)->columns; |
| 3156 | if ((flags & PsiValue) == 0) |
| 3157 | geometry_info.psi=0.1*(*image)->rows; |
| 3158 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
cristy | eb6e658 | 2011-12-09 09:14:23 +0000 | [diff] [blame] | 3159 | geometry_info.sigma,(*image)->bias,(ssize_t) |
| 3160 | ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5), |
| 3161 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3162 | break; |
| 3163 | } |
| 3164 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3165 | { |
| 3166 | if (*option == '+') |
| 3167 | { |
| 3168 | (void) SetImageVirtualPixelMethod(*image, |
| 3169 | UndefinedVirtualPixelMethod); |
| 3170 | break; |
| 3171 | } |
| 3172 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3173 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 3174 | argv[i+1])); |
| 3175 | break; |
| 3176 | } |
| 3177 | break; |
| 3178 | } |
| 3179 | case 'w': |
| 3180 | { |
| 3181 | if (LocaleCompare("wave",option+1) == 0) |
| 3182 | { |
| 3183 | /* |
| 3184 | Wave image. |
| 3185 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3186 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3187 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3188 | if ((flags & SigmaValue) == 0) |
| 3189 | geometry_info.sigma=1.0; |
| 3190 | mogrify_image=WaveImage(*image,geometry_info.rho, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 3191 | geometry_info.sigma,interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3192 | break; |
| 3193 | } |
| 3194 | if (LocaleCompare("weight",option+1) == 0) |
| 3195 | { |
| 3196 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
| 3197 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3198 | draw_info->weight=0; |
| 3199 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3200 | draw_info->weight=700; |
| 3201 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3202 | if (draw_info->weight <= 800) |
| 3203 | draw_info->weight+=100; |
| 3204 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3205 | if (draw_info->weight >= 100) |
| 3206 | draw_info->weight-=100; |
| 3207 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3208 | draw_info->weight=400; |
| 3209 | break; |
| 3210 | } |
| 3211 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3212 | { |
| 3213 | /* |
| 3214 | White threshold image. |
| 3215 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3216 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3217 | (void) WhiteThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3218 | break; |
| 3219 | } |
| 3220 | break; |
| 3221 | } |
| 3222 | default: |
| 3223 | break; |
| 3224 | } |
| 3225 | /* |
| 3226 | Replace current image with any image that was generated |
| 3227 | */ |
| 3228 | if (mogrify_image != (Image *) NULL) |
| 3229 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3230 | i+=count; |
| 3231 | } |
| 3232 | if (region_image != (Image *) NULL) |
| 3233 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3234 | /* |
| 3235 | Composite transformed region onto image. |
| 3236 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3237 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3238 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3239 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 3240 | region_geometry.x,region_geometry.y,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3241 | *image=DestroyImage(*image); |
| 3242 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3243 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3244 | } |
| 3245 | /* |
| 3246 | Free resources. |
| 3247 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3248 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3249 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3250 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 82d7af5 | 2011-10-16 16:26:41 +0000 | [diff] [blame] | 3251 | status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3252 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3253 | } |
| 3254 | |
| 3255 | /* |
| 3256 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3257 | % % |
| 3258 | % % |
| 3259 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3260 | + M o g r i f y I m a g e C o m m a n d % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3261 | % % |
| 3262 | % % |
| 3263 | % % |
| 3264 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3265 | % |
| 3266 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3267 | % transforms include image scaling, image rotation, color reduction, and |
| 3268 | % others. The transmogrified image overwrites the original image. |
| 3269 | % |
| 3270 | % The format of the MogrifyImageCommand method is: |
| 3271 | % |
| 3272 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3273 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3274 | % |
| 3275 | % A description of each parameter follows: |
| 3276 | % |
| 3277 | % o image_info: the image info. |
| 3278 | % |
| 3279 | % o argc: the number of elements in the argument vector. |
| 3280 | % |
| 3281 | % o argv: A text array containing the command line arguments. |
| 3282 | % |
| 3283 | % o metadata: any metadata is returned here. |
| 3284 | % |
| 3285 | % o exception: return any errors or warnings in this structure. |
| 3286 | % |
| 3287 | */ |
| 3288 | |
| 3289 | static MagickBooleanType MogrifyUsage(void) |
| 3290 | { |
| 3291 | static const char |
| 3292 | *miscellaneous[]= |
| 3293 | { |
| 3294 | "-debug events display copious debugging information", |
| 3295 | "-help print program options", |
| 3296 | "-list type print a list of supported option arguments", |
| 3297 | "-log format format of debugging information", |
| 3298 | "-version print version information", |
| 3299 | (char *) NULL |
| 3300 | }, |
| 3301 | *operators[]= |
| 3302 | { |
| 3303 | "-adaptive-blur geometry", |
| 3304 | " adaptively blur pixels; decrease effect near edges", |
| 3305 | "-adaptive-resize geometry", |
| 3306 | " adaptively resize image using 'mesh' interpolation", |
| 3307 | "-adaptive-sharpen geometry", |
| 3308 | " adaptively sharpen pixels; increase effect near edges", |
| 3309 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3310 | " transparent, extract, background, or shape", |
| 3311 | "-annotate geometry text", |
| 3312 | " annotate the image with text", |
| 3313 | "-auto-gamma automagically adjust gamma level of image", |
| 3314 | "-auto-level automagically adjust color levels of image", |
| 3315 | "-auto-orient automagically orient (rotate) image", |
| 3316 | "-bench iterations measure performance", |
| 3317 | "-black-threshold value", |
| 3318 | " force all pixels below the threshold into black", |
| 3319 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3320 | "-blur geometry reduce image noise and reduce detail levels", |
| 3321 | "-border geometry surround image with a border of color", |
| 3322 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3323 | "-brightness-contrast geometry", |
| 3324 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3325 | "-cdl filename color correct with a color decision list", |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 3326 | "-charcoal geometry simulate a charcoal drawing", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3327 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3328 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3329 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3330 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3331 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3332 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3333 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3334 | "-contrast enhance or reduce the image contrast", |
| 3335 | "-contrast-stretch geometry", |
| 3336 | " improve contrast by `stretching' the intensity range", |
| 3337 | "-convolve coefficients", |
| 3338 | " apply a convolution kernel to the image", |
| 3339 | "-cycle amount cycle the image colormap", |
| 3340 | "-decipher filename convert cipher pixels to plain pixels", |
| 3341 | "-deskew threshold straighten an image", |
| 3342 | "-despeckle reduce the speckles within an image", |
| 3343 | "-distort method args", |
| 3344 | " distort images according to given method ad args", |
| 3345 | "-draw string annotate the image with a graphic primitive", |
| 3346 | "-edge radius apply a filter to detect edges in the image", |
| 3347 | "-encipher filename convert plain pixels to cipher pixels", |
| 3348 | "-emboss radius emboss an image", |
| 3349 | "-enhance apply a digital filter to enhance a noisy image", |
| 3350 | "-equalize perform histogram equalization to an image", |
| 3351 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3352 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3353 | "-extent geometry set the image size", |
| 3354 | "-extract geometry extract area from image", |
| 3355 | "-fft implements the discrete Fourier transform (DFT)", |
| 3356 | "-flip flip image vertically", |
| 3357 | "-floodfill geometry color", |
| 3358 | " floodfill the image with color", |
| 3359 | "-flop flop image horizontally", |
| 3360 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3361 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3362 | " apply function over image values", |
| 3363 | "-gamma value level of gamma correction", |
| 3364 | "-gaussian-blur geometry", |
| 3365 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3366 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3367 | "-identify identify the format and characteristics of the image", |
| 3368 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3369 | "-implode amount implode image pixels about the center", |
| 3370 | "-lat geometry local adaptive thresholding", |
| 3371 | "-layers method optimize, merge, or compare image layers", |
| 3372 | "-level value adjust the level of image contrast", |
| 3373 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3374 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3375 | "-linear-stretch geometry", |
| 3376 | " improve contrast by `stretching with saturation'", |
| 3377 | "-liquid-rescale geometry", |
| 3378 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3379 | "-median geometry apply a median filter to the image", |
glennrp | 30d2dc6 | 2011-06-25 03:17:16 +0000 | [diff] [blame] | 3380 | "-mode geometry make each pixel the 'predominant color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3381 | "-modulate value vary the brightness, saturation, and hue", |
| 3382 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3383 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3384 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3385 | "-motion-blur geometry", |
| 3386 | " simulate motion blur", |
| 3387 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3388 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3389 | "-normalize transform image to span the full range of colors", |
| 3390 | "-opaque color change this color to the fill color", |
| 3391 | "-ordered-dither NxN", |
| 3392 | " add a noise pattern to the image with specific", |
| 3393 | " amplitudes", |
| 3394 | "-paint radius simulate an oil painting", |
| 3395 | "-polaroid angle simulate a Polaroid picture", |
| 3396 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3397 | "-profile filename add, delete, or apply an image profile", |
| 3398 | "-quantize colorspace reduce colors in this colorspace", |
| 3399 | "-radial-blur angle radial blur the image", |
| 3400 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3401 | "-random-threshold low,high", |
| 3402 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3403 | "-region geometry apply options to a portion of the image", |
| 3404 | "-render render vector graphics", |
| 3405 | "-repage geometry size and location of an image canvas", |
| 3406 | "-resample geometry change the resolution of an image", |
| 3407 | "-resize geometry resize the image", |
| 3408 | "-roll geometry roll an image vertically or horizontally", |
| 3409 | "-rotate degrees apply Paeth rotation to the image", |
| 3410 | "-sample geometry scale image with pixel sampling", |
| 3411 | "-scale geometry scale the image", |
| 3412 | "-segment values segment an image", |
| 3413 | "-selective-blur geometry", |
| 3414 | " selectively blur pixels within a contrast threshold", |
| 3415 | "-sepia-tone threshold", |
| 3416 | " simulate a sepia-toned photo", |
| 3417 | "-set property value set an image property", |
| 3418 | "-shade degrees shade the image using a distant light source", |
| 3419 | "-shadow geometry simulate an image shadow", |
| 3420 | "-sharpen geometry sharpen the image", |
| 3421 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3422 | "-shear geometry slide one edge of the image along the X or Y axis", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3423 | "-sigmoidal-contrast geometry", |
| 3424 | " increase the contrast without saturating highlights or shadows", |
| 3425 | "-sketch geometry simulate a pencil sketch", |
| 3426 | "-solarize threshold negate all pixels above the threshold level", |
| 3427 | "-sparse-color method args", |
| 3428 | " fill in a image based on a few color points", |
| 3429 | "-splice geometry splice the background color into the image", |
| 3430 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3431 | "-statistic type radius", |
| 3432 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3433 | "-strip strip image of all profiles and comments", |
| 3434 | "-swirl degrees swirl image pixels about the center", |
| 3435 | "-threshold value threshold the image", |
| 3436 | "-thumbnail geometry create a thumbnail of the image", |
| 3437 | "-tile filename tile image when filling a graphic primitive", |
| 3438 | "-tint value tint the image with the fill color", |
| 3439 | "-transform affine transform image", |
| 3440 | "-transparent color make this color transparent within the image", |
| 3441 | "-transpose flip image vertically and rotate 90 degrees", |
| 3442 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3443 | "-trim trim image edges", |
| 3444 | "-type type image type", |
| 3445 | "-unique-colors discard all but one of any pixel color", |
| 3446 | "-unsharp geometry sharpen the image", |
| 3447 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3448 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3449 | "-white-threshold value", |
| 3450 | " force all pixels above the threshold into white", |
| 3451 | (char *) NULL |
| 3452 | }, |
| 3453 | *sequence_operators[]= |
| 3454 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3455 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3456 | "-clut apply a color lookup table to the image", |
| 3457 | "-coalesce merge a sequence of images", |
| 3458 | "-combine combine a sequence of images", |
| 3459 | "-composite composite image", |
| 3460 | "-crop geometry cut out a rectangular region of the image", |
| 3461 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3462 | "-evaluate-sequence operator", |
| 3463 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3464 | "-flatten flatten a sequence of images", |
| 3465 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3466 | "-hald-clut apply a Hald color lookup table to the image", |
| 3467 | "-morph value morph an image sequence", |
| 3468 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3469 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3470 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3471 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3472 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3473 | "-write filename write images to this file", |
| 3474 | (char *) NULL |
| 3475 | }, |
| 3476 | *settings[]= |
| 3477 | { |
| 3478 | "-adjoin join images into a single multi-image file", |
| 3479 | "-affine matrix affine transform matrix", |
| 3480 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3481 | "-antialias remove pixel-aliasing", |
| 3482 | "-authenticate password", |
| 3483 | " decipher image with this password", |
| 3484 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3485 | "-background color background color", |
| 3486 | "-bias value add bias when convolving an image", |
| 3487 | "-black-point-compensation", |
| 3488 | " use black point compensation", |
| 3489 | "-blue-primary point chromaticity blue primary point", |
| 3490 | "-bordercolor color border color", |
| 3491 | "-caption string assign a caption to an image", |
| 3492 | "-channel type apply option to select image channels", |
| 3493 | "-colors value preferred number of colors in the image", |
| 3494 | "-colorspace type alternate image colorspace", |
| 3495 | "-comment string annotate image with comment", |
| 3496 | "-compose operator set image composite operator", |
| 3497 | "-compress type type of pixel compression when writing the image", |
| 3498 | "-define format:option", |
| 3499 | " define one or more image format options", |
| 3500 | "-delay value display the next image after pausing", |
| 3501 | "-density geometry horizontal and vertical density of the image", |
| 3502 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3503 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3504 | "-display server get image or font from this X server", |
| 3505 | "-dispose method layer disposal method", |
| 3506 | "-dither method apply error diffusion to image", |
| 3507 | "-encoding type text encoding type", |
| 3508 | "-endian type endianness (MSB or LSB) of the image", |
| 3509 | "-family name render text with this font family", |
| 3510 | "-fill color color to use when filling a graphic primitive", |
| 3511 | "-filter type use this filter when resizing an image", |
| 3512 | "-font name render text with this font", |
| 3513 | "-format \"string\" output formatted image characteristics", |
| 3514 | "-fuzz distance colors within this distance are considered equal", |
| 3515 | "-gravity type horizontal and vertical text placement", |
| 3516 | "-green-primary point chromaticity green primary point", |
| 3517 | "-intent type type of rendering intent when managing the image color", |
| 3518 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3519 | "-interline-spacing value", |
| 3520 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3521 | "-interpolate method pixel color interpolation method", |
| 3522 | "-interword-spacing value", |
| 3523 | " set the space between two words", |
| 3524 | "-kerning value set the space between two letters", |
| 3525 | "-label string assign a label to an image", |
| 3526 | "-limit type value pixel cache resource limit", |
| 3527 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3528 | "-mask filename associate a mask with the image", |
| 3529 | "-mattecolor color frame color", |
| 3530 | "-monitor monitor progress", |
| 3531 | "-orient type image orientation", |
| 3532 | "-page geometry size and location of an image canvas (setting)", |
| 3533 | "-ping efficiently determine image attributes", |
| 3534 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3535 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3536 | "-preview type image preview type", |
| 3537 | "-quality value JPEG/MIFF/PNG compression level", |
| 3538 | "-quiet suppress all warning messages", |
| 3539 | "-red-primary point chromaticity red primary point", |
| 3540 | "-regard-warnings pay attention to warning messages", |
| 3541 | "-remap filename transform image colors to match this set of colors", |
| 3542 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3543 | "-sampling-factor geometry", |
| 3544 | " horizontal and vertical sampling factor", |
| 3545 | "-scene value image scene number", |
| 3546 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3547 | "-size geometry width and height of image", |
| 3548 | "-stretch type render text with this font stretch", |
| 3549 | "-stroke color graphic primitive stroke color", |
| 3550 | "-strokewidth value graphic primitive stroke width", |
| 3551 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3552 | "-synchronize synchronize image to storage device", |
| 3553 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3554 | "-texture filename name of texture to tile onto the image background", |
| 3555 | "-tile-offset geometry", |
| 3556 | " tile offset", |
| 3557 | "-treedepth value color tree depth", |
| 3558 | "-transparent-color color", |
| 3559 | " transparent color", |
| 3560 | "-undercolor color annotation bounding box color", |
| 3561 | "-units type the units of image resolution", |
| 3562 | "-verbose print detailed information about the image", |
| 3563 | "-view FlashPix viewing transforms", |
| 3564 | "-virtual-pixel method", |
| 3565 | " virtual pixel access method", |
| 3566 | "-weight type render text with this font weight", |
| 3567 | "-white-point point chromaticity white point", |
| 3568 | (char *) NULL |
| 3569 | }, |
| 3570 | *stack_operators[]= |
| 3571 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3572 | "-delete indexes delete the image from the image sequence", |
| 3573 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3574 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3575 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3576 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3577 | "-swap indexes swap two images in the image sequence", |
| 3578 | (char *) NULL |
| 3579 | }; |
| 3580 | |
| 3581 | const char |
| 3582 | **p; |
| 3583 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3584 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3585 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3586 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3587 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3588 | GetClientName()); |
| 3589 | (void) printf("\nImage Settings:\n"); |
| 3590 | for (p=settings; *p != (char *) NULL; p++) |
| 3591 | (void) printf(" %s\n",*p); |
| 3592 | (void) printf("\nImage Operators:\n"); |
| 3593 | for (p=operators; *p != (char *) NULL; p++) |
| 3594 | (void) printf(" %s\n",*p); |
| 3595 | (void) printf("\nImage Sequence Operators:\n"); |
| 3596 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3597 | (void) printf(" %s\n",*p); |
| 3598 | (void) printf("\nImage Stack Operators:\n"); |
| 3599 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3600 | (void) printf(" %s\n",*p); |
| 3601 | (void) printf("\nMiscellaneous Options:\n"); |
| 3602 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3603 | (void) printf(" %s\n",*p); |
| 3604 | (void) printf( |
| 3605 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3606 | (void) printf( |
| 3607 | "number. To specify a particular image format, precede the filename\n"); |
| 3608 | (void) printf( |
| 3609 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3610 | (void) printf( |
| 3611 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3612 | (void) printf("'-' for standard input or output.\n"); |
| 3613 | return(MagickFalse); |
| 3614 | } |
| 3615 | |
| 3616 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3617 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3618 | { |
| 3619 | #define DestroyMogrify() \ |
| 3620 | { \ |
| 3621 | if (format != (char *) NULL) \ |
| 3622 | format=DestroyString(format); \ |
| 3623 | if (path != (char *) NULL) \ |
| 3624 | path=DestroyString(path); \ |
| 3625 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3626 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3627 | argv[i]=DestroyString(argv[i]); \ |
| 3628 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3629 | } |
| 3630 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3631 | { \ |
| 3632 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3633 | option); \ |
| 3634 | DestroyMogrify(); \ |
| 3635 | return(MagickFalse); \ |
| 3636 | } |
| 3637 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3638 | { \ |
| 3639 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3640 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3641 | DestroyMogrify(); \ |
| 3642 | return(MagickFalse); \ |
| 3643 | } |
| 3644 | |
| 3645 | char |
| 3646 | *format, |
| 3647 | *option, |
| 3648 | *path; |
| 3649 | |
| 3650 | Image |
| 3651 | *image; |
| 3652 | |
| 3653 | ImageStack |
| 3654 | image_stack[MaxImageStackDepth+1]; |
| 3655 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3656 | MagickBooleanType |
| 3657 | global_colormap; |
| 3658 | |
| 3659 | MagickBooleanType |
| 3660 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3661 | pend, |
| 3662 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3663 | |
| 3664 | MagickStatusType |
| 3665 | status; |
| 3666 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3667 | register ssize_t |
| 3668 | i; |
| 3669 | |
| 3670 | ssize_t |
| 3671 | j, |
| 3672 | k; |
| 3673 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3674 | /* |
| 3675 | Set defaults. |
| 3676 | */ |
| 3677 | assert(image_info != (ImageInfo *) NULL); |
| 3678 | assert(image_info->signature == MagickSignature); |
| 3679 | if (image_info->debug != MagickFalse) |
| 3680 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3681 | assert(exception != (ExceptionInfo *) NULL); |
| 3682 | if (argc == 2) |
| 3683 | { |
| 3684 | option=argv[1]; |
| 3685 | if ((LocaleCompare("version",option+1) == 0) || |
| 3686 | (LocaleCompare("-version",option+1) == 0)) |
| 3687 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3688 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3689 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 3690 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 3691 | GetMagickCopyright()); |
| 3692 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 3693 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3694 | return(MagickFalse); |
| 3695 | } |
| 3696 | } |
| 3697 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3698 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3699 | format=(char *) NULL; |
| 3700 | path=(char *) NULL; |
| 3701 | global_colormap=MagickFalse; |
| 3702 | k=0; |
| 3703 | j=1; |
| 3704 | NewImageStack(); |
| 3705 | option=(char *) NULL; |
| 3706 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3707 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3708 | status=MagickTrue; |
| 3709 | /* |
| 3710 | Parse command line. |
| 3711 | */ |
| 3712 | ReadCommandlLine(argc,&argv); |
| 3713 | status=ExpandFilenames(&argc,&argv); |
| 3714 | if (status == MagickFalse) |
| 3715 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3716 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3717 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3718 | { |
| 3719 | option=argv[i]; |
| 3720 | if (LocaleCompare(option,"(") == 0) |
| 3721 | { |
| 3722 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3723 | if (k == MaxImageStackDepth) |
| 3724 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3725 | option); |
| 3726 | PushImageStack(); |
| 3727 | continue; |
| 3728 | } |
| 3729 | if (LocaleCompare(option,")") == 0) |
| 3730 | { |
| 3731 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3732 | if (k == 0) |
| 3733 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3734 | PopImageStack(); |
| 3735 | continue; |
| 3736 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3737 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3738 | { |
| 3739 | char |
| 3740 | backup_filename[MaxTextExtent], |
| 3741 | *filename; |
| 3742 | |
| 3743 | Image |
| 3744 | *images; |
| 3745 | |
| 3746 | /* |
| 3747 | Option is a file name: begin by reading image from specified file. |
| 3748 | */ |
| 3749 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3750 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3751 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3752 | filename=argv[++i]; |
| 3753 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 3754 | images=ReadImages(image_info,exception); |
| 3755 | status&=(images != (Image *) NULL) && |
| 3756 | (exception->severity < ErrorException); |
| 3757 | if (images == (Image *) NULL) |
| 3758 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3759 | if (format != (char *) NULL) |
| 3760 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3761 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3762 | if (path != (char *) NULL) |
| 3763 | { |
| 3764 | GetPathComponent(option,TailPath,filename); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3765 | (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3766 | path,*DirectorySeparator,filename); |
| 3767 | } |
| 3768 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3769 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3770 | AppendImageStack(images); |
| 3771 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3772 | if (global_colormap != MagickFalse) |
| 3773 | { |
| 3774 | QuantizeInfo |
| 3775 | *quantize_info; |
| 3776 | |
| 3777 | quantize_info=AcquireQuantizeInfo(image_info); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3778 | (void) RemapImages(quantize_info,images,(Image *) NULL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3779 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3780 | } |
| 3781 | *backup_filename='\0'; |
| 3782 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3783 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3784 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3785 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3786 | i; |
| 3787 | |
| 3788 | /* |
| 3789 | Rename image file as backup. |
| 3790 | */ |
| 3791 | (void) CopyMagickString(backup_filename,image->filename, |
| 3792 | MaxTextExtent); |
| 3793 | for (i=0; i < 6; i++) |
| 3794 | { |
| 3795 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3796 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3797 | break; |
| 3798 | } |
| 3799 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
cristy | 320684d | 2011-09-23 14:55:47 +0000 | [diff] [blame] | 3800 | (rename_utf8(image->filename,backup_filename) != 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3801 | *backup_filename='\0'; |
| 3802 | } |
| 3803 | /* |
| 3804 | Write transmogrified image to disk. |
| 3805 | */ |
| 3806 | image_info->synchronize=MagickTrue; |
| 3807 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3808 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 3809 | (void) remove_utf8(backup_filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3810 | RemoveAllImageStack(); |
| 3811 | continue; |
| 3812 | } |
| 3813 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3814 | switch (*(option+1)) |
| 3815 | { |
| 3816 | case 'a': |
| 3817 | { |
| 3818 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3819 | { |
| 3820 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3821 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3822 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3823 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3824 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3825 | break; |
| 3826 | } |
| 3827 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3828 | { |
| 3829 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3830 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3831 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3832 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3833 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3834 | break; |
| 3835 | } |
| 3836 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3837 | { |
| 3838 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3839 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3840 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3841 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3842 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3843 | break; |
| 3844 | } |
| 3845 | if (LocaleCompare("affine",option+1) == 0) |
| 3846 | { |
| 3847 | if (*option == '+') |
| 3848 | break; |
| 3849 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3850 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3851 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3852 | break; |
| 3853 | } |
| 3854 | if (LocaleCompare("alpha",option+1) == 0) |
| 3855 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3856 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3857 | type; |
| 3858 | |
| 3859 | if (*option == '+') |
| 3860 | break; |
| 3861 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3862 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3863 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3864 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3865 | if (type < 0) |
| 3866 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3867 | argv[i]); |
| 3868 | break; |
| 3869 | } |
| 3870 | if (LocaleCompare("annotate",option+1) == 0) |
| 3871 | { |
| 3872 | if (*option == '+') |
| 3873 | break; |
| 3874 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3875 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3876 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3877 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3878 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3879 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3880 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3881 | i++; |
| 3882 | break; |
| 3883 | } |
| 3884 | if (LocaleCompare("antialias",option+1) == 0) |
| 3885 | break; |
| 3886 | if (LocaleCompare("append",option+1) == 0) |
| 3887 | break; |
| 3888 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3889 | { |
| 3890 | if (*option == '+') |
| 3891 | break; |
| 3892 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3893 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3894 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3895 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3896 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3897 | break; |
| 3898 | } |
| 3899 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3900 | { |
| 3901 | if (*option == '+') |
| 3902 | break; |
| 3903 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3904 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3905 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3906 | break; |
| 3907 | } |
| 3908 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3909 | break; |
| 3910 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3911 | break; |
| 3912 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3913 | break; |
| 3914 | if (LocaleCompare("average",option+1) == 0) |
| 3915 | break; |
| 3916 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3917 | } |
| 3918 | case 'b': |
| 3919 | { |
| 3920 | if (LocaleCompare("background",option+1) == 0) |
| 3921 | { |
| 3922 | if (*option == '+') |
| 3923 | break; |
| 3924 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3925 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3926 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3927 | break; |
| 3928 | } |
| 3929 | if (LocaleCompare("bias",option+1) == 0) |
| 3930 | { |
| 3931 | if (*option == '+') |
| 3932 | break; |
| 3933 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3934 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3935 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3936 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3937 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3938 | break; |
| 3939 | } |
| 3940 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 3941 | break; |
| 3942 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 3943 | { |
| 3944 | if (*option == '+') |
| 3945 | break; |
| 3946 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3947 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3948 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3949 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3950 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3951 | break; |
| 3952 | } |
| 3953 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3954 | { |
| 3955 | if (*option == '+') |
| 3956 | break; |
| 3957 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3958 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3959 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3960 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3961 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3962 | break; |
| 3963 | } |
| 3964 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3965 | { |
| 3966 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3967 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3968 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3969 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3970 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3971 | break; |
| 3972 | } |
| 3973 | if (LocaleCompare("blur",option+1) == 0) |
| 3974 | { |
| 3975 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3976 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3977 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3978 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3979 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3980 | break; |
| 3981 | } |
| 3982 | if (LocaleCompare("border",option+1) == 0) |
| 3983 | { |
| 3984 | if (*option == '+') |
| 3985 | break; |
| 3986 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3987 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3988 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3989 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3990 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3991 | break; |
| 3992 | } |
| 3993 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3994 | { |
| 3995 | if (*option == '+') |
| 3996 | break; |
| 3997 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3998 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3999 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4000 | break; |
| 4001 | } |
| 4002 | if (LocaleCompare("box",option+1) == 0) |
| 4003 | { |
| 4004 | if (*option == '+') |
| 4005 | break; |
| 4006 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4007 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4008 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4009 | break; |
| 4010 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 4011 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 4012 | { |
| 4013 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4014 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 4015 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4016 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4017 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4018 | break; |
| 4019 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4020 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4021 | } |
| 4022 | case 'c': |
| 4023 | { |
| 4024 | if (LocaleCompare("cache",option+1) == 0) |
| 4025 | { |
| 4026 | if (*option == '+') |
| 4027 | break; |
| 4028 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4029 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4030 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4031 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4032 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4033 | break; |
| 4034 | } |
| 4035 | if (LocaleCompare("caption",option+1) == 0) |
| 4036 | { |
| 4037 | if (*option == '+') |
| 4038 | break; |
| 4039 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4040 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4041 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4042 | break; |
| 4043 | } |
| 4044 | if (LocaleCompare("channel",option+1) == 0) |
| 4045 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4046 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4047 | channel; |
| 4048 | |
| 4049 | if (*option == '+') |
| 4050 | break; |
| 4051 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4052 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4053 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4054 | channel=ParseChannelOption(argv[i]); |
| 4055 | if (channel < 0) |
| 4056 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 4057 | argv[i]); |
| 4058 | break; |
| 4059 | } |
| 4060 | if (LocaleCompare("cdl",option+1) == 0) |
| 4061 | { |
| 4062 | if (*option == '+') |
| 4063 | break; |
| 4064 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4065 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4066 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4067 | break; |
| 4068 | } |
| 4069 | if (LocaleCompare("charcoal",option+1) == 0) |
| 4070 | { |
| 4071 | if (*option == '+') |
| 4072 | break; |
| 4073 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4074 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4075 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4076 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4077 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4078 | break; |
| 4079 | } |
| 4080 | if (LocaleCompare("chop",option+1) == 0) |
| 4081 | { |
| 4082 | if (*option == '+') |
| 4083 | break; |
| 4084 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4085 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4086 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4087 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4088 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4089 | break; |
| 4090 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4091 | if (LocaleCompare("clamp",option+1) == 0) |
| 4092 | break; |
| 4093 | if (LocaleCompare("clip",option+1) == 0) |
| 4094 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4095 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4096 | { |
| 4097 | if (*option == '+') |
| 4098 | break; |
| 4099 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4100 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4101 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4102 | break; |
| 4103 | } |
| 4104 | if (LocaleCompare("clut",option+1) == 0) |
| 4105 | break; |
| 4106 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4107 | break; |
| 4108 | if (LocaleCompare("colorize",option+1) == 0) |
| 4109 | { |
| 4110 | if (*option == '+') |
| 4111 | break; |
| 4112 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4113 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4114 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4115 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4116 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4117 | break; |
| 4118 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4119 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4120 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4121 | KernelInfo |
| 4122 | *kernel_info; |
| 4123 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4124 | if (*option == '+') |
| 4125 | break; |
| 4126 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4127 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4128 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4129 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4130 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4131 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4132 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4133 | break; |
| 4134 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4135 | if (LocaleCompare("colors",option+1) == 0) |
| 4136 | { |
| 4137 | if (*option == '+') |
| 4138 | break; |
| 4139 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4140 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4141 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4142 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4143 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4144 | break; |
| 4145 | } |
| 4146 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4147 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4148 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4149 | colorspace; |
| 4150 | |
| 4151 | if (*option == '+') |
| 4152 | break; |
| 4153 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4154 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4155 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4156 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4157 | argv[i]); |
| 4158 | if (colorspace < 0) |
| 4159 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4160 | argv[i]); |
| 4161 | break; |
| 4162 | } |
| 4163 | if (LocaleCompare("combine",option+1) == 0) |
| 4164 | break; |
| 4165 | if (LocaleCompare("comment",option+1) == 0) |
| 4166 | { |
| 4167 | if (*option == '+') |
| 4168 | break; |
| 4169 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4170 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4171 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4172 | break; |
| 4173 | } |
| 4174 | if (LocaleCompare("composite",option+1) == 0) |
| 4175 | break; |
| 4176 | if (LocaleCompare("compress",option+1) == 0) |
| 4177 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4178 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4179 | compress; |
| 4180 | |
| 4181 | if (*option == '+') |
| 4182 | break; |
| 4183 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4184 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4185 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4186 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4187 | argv[i]); |
| 4188 | if (compress < 0) |
| 4189 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4190 | argv[i]); |
| 4191 | break; |
| 4192 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4193 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4194 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4195 | if (LocaleCompare("contrast",option+1) == 0) |
| 4196 | break; |
| 4197 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4198 | { |
| 4199 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4200 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4201 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4202 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4203 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4204 | break; |
| 4205 | } |
| 4206 | if (LocaleCompare("convolve",option+1) == 0) |
| 4207 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4208 | KernelInfo |
| 4209 | *kernel_info; |
| 4210 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4211 | if (*option == '+') |
| 4212 | break; |
| 4213 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4214 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4215 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4216 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4217 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4218 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4219 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4220 | break; |
| 4221 | } |
| 4222 | if (LocaleCompare("crop",option+1) == 0) |
| 4223 | { |
| 4224 | if (*option == '+') |
| 4225 | break; |
| 4226 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4227 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4228 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4229 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4230 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4231 | break; |
| 4232 | } |
| 4233 | if (LocaleCompare("cycle",option+1) == 0) |
| 4234 | { |
| 4235 | if (*option == '+') |
| 4236 | break; |
| 4237 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4238 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4239 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4240 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4241 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4242 | break; |
| 4243 | } |
| 4244 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4245 | } |
| 4246 | case 'd': |
| 4247 | { |
| 4248 | if (LocaleCompare("decipher",option+1) == 0) |
| 4249 | { |
| 4250 | if (*option == '+') |
| 4251 | break; |
| 4252 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4253 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4254 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4255 | break; |
| 4256 | } |
| 4257 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4258 | break; |
| 4259 | if (LocaleCompare("debug",option+1) == 0) |
| 4260 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4261 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4262 | event; |
| 4263 | |
| 4264 | if (*option == '+') |
| 4265 | break; |
| 4266 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4267 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4268 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4269 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4270 | if (event < 0) |
| 4271 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4272 | argv[i]); |
| 4273 | (void) SetLogEventMask(argv[i]); |
| 4274 | break; |
| 4275 | } |
| 4276 | if (LocaleCompare("define",option+1) == 0) |
| 4277 | { |
| 4278 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4279 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4280 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4281 | if (*option == '+') |
| 4282 | { |
| 4283 | const char |
| 4284 | *define; |
| 4285 | |
| 4286 | define=GetImageOption(image_info,argv[i]); |
| 4287 | if (define == (const char *) NULL) |
| 4288 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4289 | break; |
| 4290 | } |
| 4291 | break; |
| 4292 | } |
| 4293 | if (LocaleCompare("delay",option+1) == 0) |
| 4294 | { |
| 4295 | if (*option == '+') |
| 4296 | break; |
| 4297 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4298 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4299 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4300 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4301 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4302 | break; |
| 4303 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4304 | if (LocaleCompare("delete",option+1) == 0) |
| 4305 | { |
| 4306 | if (*option == '+') |
| 4307 | break; |
| 4308 | i++; |
| 4309 | if (i == (ssize_t) (argc-1)) |
| 4310 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4311 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4312 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4313 | break; |
| 4314 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4315 | if (LocaleCompare("density",option+1) == 0) |
| 4316 | { |
| 4317 | if (*option == '+') |
| 4318 | break; |
| 4319 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4320 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4321 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4322 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4323 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4324 | break; |
| 4325 | } |
| 4326 | if (LocaleCompare("depth",option+1) == 0) |
| 4327 | { |
| 4328 | if (*option == '+') |
| 4329 | break; |
| 4330 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4331 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4332 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4333 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4334 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4335 | break; |
| 4336 | } |
| 4337 | if (LocaleCompare("deskew",option+1) == 0) |
| 4338 | { |
| 4339 | if (*option == '+') |
| 4340 | break; |
| 4341 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4342 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4343 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4344 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4345 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4346 | break; |
| 4347 | } |
| 4348 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4349 | break; |
| 4350 | if (LocaleCompare("dft",option+1) == 0) |
| 4351 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4352 | if (LocaleCompare("direction",option+1) == 0) |
| 4353 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4354 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4355 | direction; |
| 4356 | |
| 4357 | if (*option == '+') |
| 4358 | break; |
| 4359 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4360 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4361 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4362 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4363 | argv[i]); |
| 4364 | if (direction < 0) |
| 4365 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4366 | argv[i]); |
| 4367 | break; |
| 4368 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4369 | if (LocaleCompare("display",option+1) == 0) |
| 4370 | { |
| 4371 | if (*option == '+') |
| 4372 | break; |
| 4373 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4374 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4375 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4376 | break; |
| 4377 | } |
| 4378 | if (LocaleCompare("dispose",option+1) == 0) |
| 4379 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4380 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4381 | dispose; |
| 4382 | |
| 4383 | if (*option == '+') |
| 4384 | break; |
| 4385 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4386 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4387 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4388 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4389 | if (dispose < 0) |
| 4390 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4391 | argv[i]); |
| 4392 | break; |
| 4393 | } |
| 4394 | if (LocaleCompare("distort",option+1) == 0) |
| 4395 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4396 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4397 | op; |
| 4398 | |
| 4399 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4400 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4401 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4402 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4403 | if (op < 0) |
| 4404 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4405 | argv[i]); |
| 4406 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4407 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4408 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4409 | break; |
| 4410 | } |
| 4411 | if (LocaleCompare("dither",option+1) == 0) |
| 4412 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4413 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4414 | method; |
| 4415 | |
| 4416 | if (*option == '+') |
| 4417 | break; |
| 4418 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4419 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4420 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4421 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4422 | if (method < 0) |
| 4423 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4424 | argv[i]); |
| 4425 | break; |
| 4426 | } |
| 4427 | if (LocaleCompare("draw",option+1) == 0) |
| 4428 | { |
| 4429 | if (*option == '+') |
| 4430 | break; |
| 4431 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4432 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4433 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4434 | break; |
| 4435 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4436 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4437 | { |
| 4438 | if (*option == '+') |
| 4439 | break; |
| 4440 | i++; |
| 4441 | if (i == (ssize_t) (argc-1)) |
| 4442 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4443 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4444 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4445 | break; |
| 4446 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4447 | if (LocaleCompare("duration",option+1) == 0) |
| 4448 | { |
| 4449 | if (*option == '+') |
| 4450 | break; |
| 4451 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4452 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4453 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4454 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4455 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4456 | break; |
| 4457 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4458 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4459 | } |
| 4460 | case 'e': |
| 4461 | { |
| 4462 | if (LocaleCompare("edge",option+1) == 0) |
| 4463 | { |
| 4464 | if (*option == '+') |
| 4465 | break; |
| 4466 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4467 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4468 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4469 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4470 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4471 | break; |
| 4472 | } |
| 4473 | if (LocaleCompare("emboss",option+1) == 0) |
| 4474 | { |
| 4475 | if (*option == '+') |
| 4476 | break; |
| 4477 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4478 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4479 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4480 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4481 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4482 | break; |
| 4483 | } |
| 4484 | if (LocaleCompare("encipher",option+1) == 0) |
| 4485 | { |
| 4486 | if (*option == '+') |
| 4487 | break; |
| 4488 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4489 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4490 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4491 | break; |
| 4492 | } |
| 4493 | if (LocaleCompare("encoding",option+1) == 0) |
| 4494 | { |
| 4495 | if (*option == '+') |
| 4496 | break; |
| 4497 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4498 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4499 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4500 | break; |
| 4501 | } |
| 4502 | if (LocaleCompare("endian",option+1) == 0) |
| 4503 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4504 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4505 | endian; |
| 4506 | |
| 4507 | if (*option == '+') |
| 4508 | break; |
| 4509 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4510 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4511 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4512 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4513 | if (endian < 0) |
| 4514 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4515 | argv[i]); |
| 4516 | break; |
| 4517 | } |
| 4518 | if (LocaleCompare("enhance",option+1) == 0) |
| 4519 | break; |
| 4520 | if (LocaleCompare("equalize",option+1) == 0) |
| 4521 | break; |
| 4522 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4523 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4524 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4525 | op; |
| 4526 | |
| 4527 | if (*option == '+') |
| 4528 | break; |
| 4529 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4530 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4531 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4532 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4533 | if (op < 0) |
| 4534 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4535 | argv[i]); |
| 4536 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4537 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4538 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4539 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4540 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4541 | break; |
| 4542 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4543 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4544 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4545 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4546 | op; |
| 4547 | |
| 4548 | if (*option == '+') |
| 4549 | break; |
| 4550 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4551 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4552 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4553 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4554 | if (op < 0) |
| 4555 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4556 | argv[i]); |
| 4557 | break; |
| 4558 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4559 | if (LocaleCompare("extent",option+1) == 0) |
| 4560 | { |
| 4561 | if (*option == '+') |
| 4562 | break; |
| 4563 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4564 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4565 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4566 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4567 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4568 | break; |
| 4569 | } |
| 4570 | if (LocaleCompare("extract",option+1) == 0) |
| 4571 | { |
| 4572 | if (*option == '+') |
| 4573 | break; |
| 4574 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4575 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4576 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4577 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4578 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4579 | break; |
| 4580 | } |
| 4581 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4582 | } |
| 4583 | case 'f': |
| 4584 | { |
| 4585 | if (LocaleCompare("family",option+1) == 0) |
| 4586 | { |
| 4587 | if (*option == '+') |
| 4588 | break; |
| 4589 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4590 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4591 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4592 | break; |
| 4593 | } |
| 4594 | if (LocaleCompare("fill",option+1) == 0) |
| 4595 | { |
| 4596 | if (*option == '+') |
| 4597 | break; |
| 4598 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4599 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4600 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4601 | break; |
| 4602 | } |
| 4603 | if (LocaleCompare("filter",option+1) == 0) |
| 4604 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4605 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4606 | filter; |
| 4607 | |
| 4608 | if (*option == '+') |
| 4609 | break; |
| 4610 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4611 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4612 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4613 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4614 | if (filter < 0) |
| 4615 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4616 | argv[i]); |
| 4617 | break; |
| 4618 | } |
| 4619 | if (LocaleCompare("flatten",option+1) == 0) |
| 4620 | break; |
| 4621 | if (LocaleCompare("flip",option+1) == 0) |
| 4622 | break; |
| 4623 | if (LocaleCompare("flop",option+1) == 0) |
| 4624 | break; |
| 4625 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4626 | { |
| 4627 | if (*option == '+') |
| 4628 | break; |
| 4629 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4630 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4631 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4632 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4633 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4634 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4635 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4636 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4637 | break; |
| 4638 | } |
| 4639 | if (LocaleCompare("font",option+1) == 0) |
| 4640 | { |
| 4641 | if (*option == '+') |
| 4642 | break; |
| 4643 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4644 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4645 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4646 | break; |
| 4647 | } |
| 4648 | if (LocaleCompare("format",option+1) == 0) |
| 4649 | { |
| 4650 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4651 | (void) CloneString(&format,(char *) NULL); |
| 4652 | if (*option == '+') |
| 4653 | break; |
| 4654 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4655 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4656 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4657 | (void) CloneString(&format,argv[i]); |
| 4658 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4659 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4660 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4661 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4662 | if (*image_info->magick == '\0') |
| 4663 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4664 | format); |
| 4665 | break; |
| 4666 | } |
| 4667 | if (LocaleCompare("frame",option+1) == 0) |
| 4668 | { |
| 4669 | if (*option == '+') |
| 4670 | break; |
| 4671 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4672 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4673 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4674 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4675 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4676 | break; |
| 4677 | } |
| 4678 | if (LocaleCompare("function",option+1) == 0) |
| 4679 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4680 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4681 | op; |
| 4682 | |
| 4683 | if (*option == '+') |
| 4684 | break; |
| 4685 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4686 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4687 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4688 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4689 | if (op < 0) |
| 4690 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4691 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4692 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4693 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4694 | break; |
| 4695 | } |
| 4696 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4697 | { |
| 4698 | if (*option == '+') |
| 4699 | break; |
| 4700 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4701 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4702 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4703 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4704 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4705 | break; |
| 4706 | } |
| 4707 | if (LocaleCompare("fx",option+1) == 0) |
| 4708 | { |
| 4709 | if (*option == '+') |
| 4710 | break; |
| 4711 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4712 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4713 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4714 | break; |
| 4715 | } |
| 4716 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4717 | } |
| 4718 | case 'g': |
| 4719 | { |
| 4720 | if (LocaleCompare("gamma",option+1) == 0) |
| 4721 | { |
| 4722 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4723 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4724 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4725 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4726 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4727 | break; |
| 4728 | } |
| 4729 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4730 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4731 | { |
| 4732 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4733 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4734 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4735 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4736 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4737 | break; |
| 4738 | } |
| 4739 | if (LocaleCompare("geometry",option+1) == 0) |
| 4740 | { |
| 4741 | if (*option == '+') |
| 4742 | break; |
| 4743 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4744 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4745 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4746 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4747 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4748 | break; |
| 4749 | } |
| 4750 | if (LocaleCompare("gravity",option+1) == 0) |
| 4751 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4752 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4753 | gravity; |
| 4754 | |
| 4755 | if (*option == '+') |
| 4756 | break; |
| 4757 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4758 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4759 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4760 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4761 | if (gravity < 0) |
| 4762 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4763 | argv[i]); |
| 4764 | break; |
| 4765 | } |
| 4766 | if (LocaleCompare("green-primary",option+1) == 0) |
| 4767 | { |
| 4768 | if (*option == '+') |
| 4769 | break; |
| 4770 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4771 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4772 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4773 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4774 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4775 | break; |
| 4776 | } |
| 4777 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4778 | } |
| 4779 | case 'h': |
| 4780 | { |
| 4781 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4782 | break; |
| 4783 | if ((LocaleCompare("help",option+1) == 0) || |
| 4784 | (LocaleCompare("-help",option+1) == 0)) |
| 4785 | return(MogrifyUsage()); |
| 4786 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4787 | } |
| 4788 | case 'i': |
| 4789 | { |
| 4790 | if (LocaleCompare("identify",option+1) == 0) |
| 4791 | break; |
| 4792 | if (LocaleCompare("idft",option+1) == 0) |
| 4793 | break; |
| 4794 | if (LocaleCompare("implode",option+1) == 0) |
| 4795 | { |
| 4796 | if (*option == '+') |
| 4797 | break; |
| 4798 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4799 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4800 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4801 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4802 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4803 | break; |
| 4804 | } |
| 4805 | if (LocaleCompare("intent",option+1) == 0) |
| 4806 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4807 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4808 | intent; |
| 4809 | |
| 4810 | if (*option == '+') |
| 4811 | break; |
| 4812 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4813 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4814 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4815 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4816 | if (intent < 0) |
| 4817 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4818 | argv[i]); |
| 4819 | break; |
| 4820 | } |
| 4821 | if (LocaleCompare("interlace",option+1) == 0) |
| 4822 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4823 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4824 | interlace; |
| 4825 | |
| 4826 | if (*option == '+') |
| 4827 | break; |
| 4828 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4829 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4830 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4831 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4832 | argv[i]); |
| 4833 | if (interlace < 0) |
| 4834 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4835 | argv[i]); |
| 4836 | break; |
| 4837 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4838 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4839 | { |
| 4840 | if (*option == '+') |
| 4841 | break; |
| 4842 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4843 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4844 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4845 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4846 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4847 | break; |
| 4848 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4849 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4850 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4851 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4852 | interpolate; |
| 4853 | |
| 4854 | if (*option == '+') |
| 4855 | break; |
| 4856 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4857 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4858 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4859 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4860 | argv[i]); |
| 4861 | if (interpolate < 0) |
| 4862 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4863 | argv[i]); |
| 4864 | break; |
| 4865 | } |
| 4866 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4867 | { |
| 4868 | if (*option == '+') |
| 4869 | break; |
| 4870 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4871 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4872 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4873 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4874 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4875 | break; |
| 4876 | } |
| 4877 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4878 | } |
| 4879 | case 'k': |
| 4880 | { |
| 4881 | if (LocaleCompare("kerning",option+1) == 0) |
| 4882 | { |
| 4883 | if (*option == '+') |
| 4884 | break; |
| 4885 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4886 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4887 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4888 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4889 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4890 | break; |
| 4891 | } |
| 4892 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4893 | } |
| 4894 | case 'l': |
| 4895 | { |
| 4896 | if (LocaleCompare("label",option+1) == 0) |
| 4897 | { |
| 4898 | if (*option == '+') |
| 4899 | break; |
| 4900 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4901 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4902 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4903 | break; |
| 4904 | } |
| 4905 | if (LocaleCompare("lat",option+1) == 0) |
| 4906 | { |
| 4907 | if (*option == '+') |
| 4908 | break; |
| 4909 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4910 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4911 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4912 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4913 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4914 | } |
| 4915 | if (LocaleCompare("layers",option+1) == 0) |
| 4916 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4917 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4918 | type; |
| 4919 | |
| 4920 | if (*option == '+') |
| 4921 | break; |
| 4922 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4923 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4924 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4925 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4926 | if (type < 0) |
| 4927 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4928 | argv[i]); |
| 4929 | break; |
| 4930 | } |
| 4931 | if (LocaleCompare("level",option+1) == 0) |
| 4932 | { |
| 4933 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4934 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4935 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4936 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4937 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4938 | break; |
| 4939 | } |
| 4940 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4941 | { |
| 4942 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4943 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4944 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4945 | break; |
| 4946 | } |
| 4947 | if (LocaleCompare("linewidth",option+1) == 0) |
| 4948 | { |
| 4949 | if (*option == '+') |
| 4950 | break; |
| 4951 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4952 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4953 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4954 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4955 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4956 | break; |
| 4957 | } |
| 4958 | if (LocaleCompare("limit",option+1) == 0) |
| 4959 | { |
| 4960 | char |
| 4961 | *p; |
| 4962 | |
| 4963 | double |
| 4964 | value; |
| 4965 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4966 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4967 | resource; |
| 4968 | |
| 4969 | if (*option == '+') |
| 4970 | break; |
| 4971 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4972 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4973 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4974 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4975 | argv[i]); |
| 4976 | if (resource < 0) |
| 4977 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4978 | argv[i]); |
| 4979 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4980 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4981 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 4982 | value=StringToDouble(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4983 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4984 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4985 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4986 | break; |
| 4987 | } |
| 4988 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4989 | { |
| 4990 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4991 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4992 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4993 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4994 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4995 | break; |
| 4996 | } |
| 4997 | if (LocaleCompare("list",option+1) == 0) |
| 4998 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4999 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5000 | list; |
| 5001 | |
| 5002 | if (*option == '+') |
| 5003 | break; |
| 5004 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5005 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5006 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5007 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5008 | if (list < 0) |
| 5009 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 5010 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5011 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 5012 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5013 | } |
| 5014 | if (LocaleCompare("log",option+1) == 0) |
| 5015 | { |
| 5016 | if (*option == '+') |
| 5017 | break; |
| 5018 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5019 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5020 | (strchr(argv[i],'%') == (char *) NULL)) |
| 5021 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5022 | break; |
| 5023 | } |
| 5024 | if (LocaleCompare("loop",option+1) == 0) |
| 5025 | { |
| 5026 | if (*option == '+') |
| 5027 | break; |
| 5028 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5029 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5030 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5031 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5032 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5033 | break; |
| 5034 | } |
| 5035 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5036 | } |
| 5037 | case 'm': |
| 5038 | { |
| 5039 | if (LocaleCompare("map",option+1) == 0) |
| 5040 | { |
| 5041 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 5042 | if (*option == '+') |
| 5043 | break; |
| 5044 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5045 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5046 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5047 | break; |
| 5048 | } |
| 5049 | if (LocaleCompare("mask",option+1) == 0) |
| 5050 | { |
| 5051 | if (*option == '+') |
| 5052 | break; |
| 5053 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5054 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5055 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5056 | break; |
| 5057 | } |
| 5058 | if (LocaleCompare("matte",option+1) == 0) |
| 5059 | break; |
| 5060 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 5061 | { |
| 5062 | if (*option == '+') |
| 5063 | break; |
| 5064 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5065 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5066 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5067 | break; |
| 5068 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5069 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5070 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5071 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5072 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5073 | if (LocaleCompare("modulate",option+1) == 0) |
| 5074 | { |
| 5075 | if (*option == '+') |
| 5076 | break; |
| 5077 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5078 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5079 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5080 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5081 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5082 | break; |
| 5083 | } |
| 5084 | if (LocaleCompare("median",option+1) == 0) |
| 5085 | { |
| 5086 | if (*option == '+') |
| 5087 | break; |
| 5088 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5089 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5090 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5091 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5092 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5093 | break; |
| 5094 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5095 | if (LocaleCompare("mode",option+1) == 0) |
| 5096 | { |
| 5097 | if (*option == '+') |
| 5098 | break; |
| 5099 | i++; |
| 5100 | if (i == (ssize_t) argc) |
| 5101 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5102 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5103 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5104 | break; |
| 5105 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5106 | if (LocaleCompare("monitor",option+1) == 0) |
| 5107 | break; |
| 5108 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5109 | break; |
| 5110 | if (LocaleCompare("morph",option+1) == 0) |
| 5111 | { |
| 5112 | if (*option == '+') |
| 5113 | break; |
| 5114 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5115 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5116 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5117 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5118 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5119 | break; |
| 5120 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5121 | if (LocaleCompare("morphology",option+1) == 0) |
| 5122 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5123 | char |
| 5124 | token[MaxTextExtent]; |
| 5125 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5126 | KernelInfo |
| 5127 | *kernel_info; |
| 5128 | |
| 5129 | ssize_t |
| 5130 | op; |
| 5131 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5132 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5133 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5134 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5135 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5136 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5137 | if (op < 0) |
| 5138 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5139 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5140 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5141 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5142 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5143 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5144 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5145 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5146 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5147 | break; |
| 5148 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5149 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5150 | break; |
| 5151 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5152 | { |
| 5153 | if (*option == '+') |
| 5154 | break; |
| 5155 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5156 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5157 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5158 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5159 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5160 | break; |
| 5161 | } |
| 5162 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5163 | } |
| 5164 | case 'n': |
| 5165 | { |
| 5166 | if (LocaleCompare("negate",option+1) == 0) |
| 5167 | break; |
| 5168 | if (LocaleCompare("noise",option+1) == 0) |
| 5169 | { |
| 5170 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5171 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5172 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5173 | if (*option == '+') |
| 5174 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5175 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5176 | noise; |
| 5177 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5178 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5179 | if (noise < 0) |
| 5180 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5181 | argv[i]); |
| 5182 | break; |
| 5183 | } |
| 5184 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5185 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5186 | break; |
| 5187 | } |
| 5188 | if (LocaleCompare("noop",option+1) == 0) |
| 5189 | break; |
| 5190 | if (LocaleCompare("normalize",option+1) == 0) |
| 5191 | break; |
| 5192 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5193 | } |
| 5194 | case 'o': |
| 5195 | { |
| 5196 | if (LocaleCompare("opaque",option+1) == 0) |
| 5197 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5198 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5199 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5200 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5201 | break; |
| 5202 | } |
| 5203 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5204 | { |
| 5205 | if (*option == '+') |
| 5206 | break; |
| 5207 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5208 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5209 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5210 | break; |
| 5211 | } |
| 5212 | if (LocaleCompare("orient",option+1) == 0) |
| 5213 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5214 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5215 | orientation; |
| 5216 | |
| 5217 | orientation=UndefinedOrientation; |
| 5218 | if (*option == '+') |
| 5219 | break; |
| 5220 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5221 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5222 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5223 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5224 | argv[i]); |
| 5225 | if (orientation < 0) |
| 5226 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5227 | argv[i]); |
| 5228 | break; |
| 5229 | } |
| 5230 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5231 | } |
| 5232 | case 'p': |
| 5233 | { |
| 5234 | if (LocaleCompare("page",option+1) == 0) |
| 5235 | { |
| 5236 | if (*option == '+') |
| 5237 | break; |
| 5238 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5239 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5240 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5241 | break; |
| 5242 | } |
| 5243 | if (LocaleCompare("paint",option+1) == 0) |
| 5244 | { |
| 5245 | if (*option == '+') |
| 5246 | break; |
| 5247 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5248 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5249 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5250 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5251 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5252 | break; |
| 5253 | } |
| 5254 | if (LocaleCompare("path",option+1) == 0) |
| 5255 | { |
| 5256 | (void) CloneString(&path,(char *) NULL); |
| 5257 | if (*option == '+') |
| 5258 | break; |
| 5259 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5260 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5261 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5262 | (void) CloneString(&path,argv[i]); |
| 5263 | break; |
| 5264 | } |
| 5265 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5266 | { |
| 5267 | if (*option == '+') |
| 5268 | break; |
| 5269 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5270 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5271 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5272 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5273 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5274 | break; |
| 5275 | } |
| 5276 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5277 | { |
| 5278 | if (*option == '+') |
| 5279 | break; |
| 5280 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5281 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5282 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5283 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5284 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5285 | break; |
| 5286 | } |
| 5287 | if (LocaleCompare("posterize",option+1) == 0) |
| 5288 | { |
| 5289 | if (*option == '+') |
| 5290 | break; |
| 5291 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5292 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5293 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5294 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5295 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5296 | break; |
| 5297 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5298 | if (LocaleCompare("precision",option+1) == 0) |
| 5299 | { |
| 5300 | if (*option == '+') |
| 5301 | break; |
| 5302 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5303 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5304 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5305 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5306 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5307 | break; |
| 5308 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5309 | if (LocaleCompare("print",option+1) == 0) |
| 5310 | { |
| 5311 | if (*option == '+') |
| 5312 | break; |
| 5313 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5314 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5315 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5316 | break; |
| 5317 | } |
| 5318 | if (LocaleCompare("process",option+1) == 0) |
| 5319 | { |
| 5320 | if (*option == '+') |
| 5321 | break; |
| 5322 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5323 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5324 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5325 | break; |
| 5326 | } |
| 5327 | if (LocaleCompare("profile",option+1) == 0) |
| 5328 | { |
| 5329 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5330 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5331 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5332 | break; |
| 5333 | } |
| 5334 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5335 | } |
| 5336 | case 'q': |
| 5337 | { |
| 5338 | if (LocaleCompare("quality",option+1) == 0) |
| 5339 | { |
| 5340 | if (*option == '+') |
| 5341 | break; |
| 5342 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5343 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5344 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5345 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5346 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5347 | break; |
| 5348 | } |
| 5349 | if (LocaleCompare("quantize",option+1) == 0) |
| 5350 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5351 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5352 | colorspace; |
| 5353 | |
| 5354 | if (*option == '+') |
| 5355 | break; |
| 5356 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5357 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5358 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5359 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5360 | argv[i]); |
| 5361 | if (colorspace < 0) |
| 5362 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5363 | argv[i]); |
| 5364 | break; |
| 5365 | } |
| 5366 | if (LocaleCompare("quiet",option+1) == 0) |
| 5367 | break; |
| 5368 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5369 | } |
| 5370 | case 'r': |
| 5371 | { |
| 5372 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5373 | { |
| 5374 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5375 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5376 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5377 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5378 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5379 | break; |
| 5380 | } |
| 5381 | if (LocaleCompare("raise",option+1) == 0) |
| 5382 | { |
| 5383 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5384 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5385 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5386 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5387 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5388 | break; |
| 5389 | } |
| 5390 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5391 | { |
| 5392 | if (*option == '+') |
| 5393 | break; |
| 5394 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5395 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5396 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5397 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5398 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5399 | break; |
| 5400 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5401 | if (LocaleCompare("recolor",option+1) == 0) |
| 5402 | { |
| 5403 | if (*option == '+') |
| 5404 | break; |
| 5405 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5406 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5407 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5408 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5409 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5410 | break; |
| 5411 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5412 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5413 | { |
| 5414 | if (*option == '+') |
| 5415 | break; |
| 5416 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5417 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5418 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5419 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5420 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5421 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5422 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5423 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5424 | if (LocaleCompare("region",option+1) == 0) |
| 5425 | { |
| 5426 | if (*option == '+') |
| 5427 | break; |
| 5428 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5429 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5430 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5431 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5432 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5433 | break; |
| 5434 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5435 | if (LocaleCompare("remap",option+1) == 0) |
| 5436 | { |
| 5437 | if (*option == '+') |
| 5438 | break; |
| 5439 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5440 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5441 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5442 | break; |
| 5443 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5444 | if (LocaleCompare("render",option+1) == 0) |
| 5445 | break; |
| 5446 | if (LocaleCompare("repage",option+1) == 0) |
| 5447 | { |
| 5448 | if (*option == '+') |
| 5449 | break; |
| 5450 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5451 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5452 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5453 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5454 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5455 | break; |
| 5456 | } |
| 5457 | if (LocaleCompare("resample",option+1) == 0) |
| 5458 | { |
| 5459 | if (*option == '+') |
| 5460 | break; |
| 5461 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5462 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5463 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5464 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5465 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5466 | break; |
| 5467 | } |
| 5468 | if (LocaleCompare("resize",option+1) == 0) |
| 5469 | { |
| 5470 | if (*option == '+') |
| 5471 | break; |
| 5472 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5473 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5474 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5475 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5476 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5477 | break; |
| 5478 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5479 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5480 | { |
| 5481 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5482 | break; |
| 5483 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5484 | if (LocaleCompare("reverse",option+1) == 0) |
| 5485 | break; |
| 5486 | if (LocaleCompare("roll",option+1) == 0) |
| 5487 | { |
| 5488 | if (*option == '+') |
| 5489 | break; |
| 5490 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5491 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5492 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5493 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5494 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5495 | break; |
| 5496 | } |
| 5497 | if (LocaleCompare("rotate",option+1) == 0) |
| 5498 | { |
| 5499 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5500 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5501 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5502 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5503 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5504 | break; |
| 5505 | } |
| 5506 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5507 | } |
| 5508 | case 's': |
| 5509 | { |
| 5510 | if (LocaleCompare("sample",option+1) == 0) |
| 5511 | { |
| 5512 | if (*option == '+') |
| 5513 | break; |
| 5514 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5515 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5516 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5517 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5518 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5519 | break; |
| 5520 | } |
| 5521 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5522 | { |
| 5523 | if (*option == '+') |
| 5524 | break; |
| 5525 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5526 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5527 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5528 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5529 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5530 | break; |
| 5531 | } |
| 5532 | if (LocaleCompare("scale",option+1) == 0) |
| 5533 | { |
| 5534 | if (*option == '+') |
| 5535 | break; |
| 5536 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5537 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5538 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5539 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5540 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5541 | break; |
| 5542 | } |
| 5543 | if (LocaleCompare("scene",option+1) == 0) |
| 5544 | { |
| 5545 | if (*option == '+') |
| 5546 | break; |
| 5547 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5548 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5549 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5550 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5551 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5552 | break; |
| 5553 | } |
| 5554 | if (LocaleCompare("seed",option+1) == 0) |
| 5555 | { |
| 5556 | if (*option == '+') |
| 5557 | break; |
| 5558 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5559 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5560 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5561 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5562 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5563 | break; |
| 5564 | } |
| 5565 | if (LocaleCompare("segment",option+1) == 0) |
| 5566 | { |
| 5567 | if (*option == '+') |
| 5568 | break; |
| 5569 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5570 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5571 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5572 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5573 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5574 | break; |
| 5575 | } |
| 5576 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5577 | { |
| 5578 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5579 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5580 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5581 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5582 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5583 | break; |
| 5584 | } |
| 5585 | if (LocaleCompare("separate",option+1) == 0) |
| 5586 | break; |
| 5587 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5588 | { |
| 5589 | if (*option == '+') |
| 5590 | break; |
| 5591 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5592 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5593 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5594 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5595 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5596 | break; |
| 5597 | } |
| 5598 | if (LocaleCompare("set",option+1) == 0) |
| 5599 | { |
| 5600 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5601 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5602 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5603 | if (*option == '+') |
| 5604 | break; |
| 5605 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5606 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5607 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5608 | break; |
| 5609 | } |
| 5610 | if (LocaleCompare("shade",option+1) == 0) |
| 5611 | { |
| 5612 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5613 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5614 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5615 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5616 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5617 | break; |
| 5618 | } |
| 5619 | if (LocaleCompare("shadow",option+1) == 0) |
| 5620 | { |
| 5621 | if (*option == '+') |
| 5622 | break; |
| 5623 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5624 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5625 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5626 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5627 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5628 | break; |
| 5629 | } |
| 5630 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5631 | { |
| 5632 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5633 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5634 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5635 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5636 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5637 | break; |
| 5638 | } |
| 5639 | if (LocaleCompare("shave",option+1) == 0) |
| 5640 | { |
| 5641 | if (*option == '+') |
| 5642 | break; |
| 5643 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5644 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5645 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5646 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5647 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5648 | break; |
| 5649 | } |
| 5650 | if (LocaleCompare("shear",option+1) == 0) |
| 5651 | { |
| 5652 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5653 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5654 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5655 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5656 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5657 | break; |
| 5658 | } |
| 5659 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5660 | { |
| 5661 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5662 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5663 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5664 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5665 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5666 | break; |
| 5667 | } |
| 5668 | if (LocaleCompare("size",option+1) == 0) |
| 5669 | { |
| 5670 | if (*option == '+') |
| 5671 | break; |
| 5672 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5673 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5674 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5675 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5676 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5677 | break; |
| 5678 | } |
| 5679 | if (LocaleCompare("sketch",option+1) == 0) |
| 5680 | { |
| 5681 | if (*option == '+') |
| 5682 | break; |
| 5683 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5684 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5685 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5686 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5687 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5688 | break; |
| 5689 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5690 | if (LocaleCompare("smush",option+1) == 0) |
| 5691 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5692 | i++; |
| 5693 | if (i == (ssize_t) argc) |
| 5694 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5695 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5696 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5697 | i++; |
| 5698 | break; |
| 5699 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5700 | if (LocaleCompare("solarize",option+1) == 0) |
| 5701 | { |
| 5702 | if (*option == '+') |
| 5703 | break; |
| 5704 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5705 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5706 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5707 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5708 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5709 | break; |
| 5710 | } |
| 5711 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5712 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5713 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5714 | op; |
| 5715 | |
| 5716 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5717 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5718 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5719 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5720 | if (op < 0) |
| 5721 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5722 | argv[i]); |
| 5723 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5724 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5725 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5726 | break; |
| 5727 | } |
| 5728 | if (LocaleCompare("spread",option+1) == 0) |
| 5729 | { |
| 5730 | if (*option == '+') |
| 5731 | break; |
| 5732 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5733 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5734 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5735 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5736 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5737 | break; |
| 5738 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5739 | if (LocaleCompare("statistic",option+1) == 0) |
| 5740 | { |
| 5741 | ssize_t |
| 5742 | op; |
| 5743 | |
| 5744 | if (*option == '+') |
| 5745 | break; |
| 5746 | i++; |
| 5747 | if (i == (ssize_t) argc) |
| 5748 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5749 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5750 | if (op < 0) |
| 5751 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5752 | argv[i]); |
| 5753 | i++; |
| 5754 | if (i == (ssize_t) (argc-1)) |
| 5755 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5756 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5757 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5758 | break; |
| 5759 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5760 | if (LocaleCompare("stretch",option+1) == 0) |
| 5761 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5762 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5763 | stretch; |
| 5764 | |
| 5765 | if (*option == '+') |
| 5766 | break; |
| 5767 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5768 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5769 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5770 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5771 | if (stretch < 0) |
| 5772 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5773 | argv[i]); |
| 5774 | break; |
| 5775 | } |
| 5776 | if (LocaleCompare("strip",option+1) == 0) |
| 5777 | break; |
| 5778 | if (LocaleCompare("stroke",option+1) == 0) |
| 5779 | { |
| 5780 | if (*option == '+') |
| 5781 | break; |
| 5782 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5783 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5784 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5785 | break; |
| 5786 | } |
| 5787 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5788 | { |
| 5789 | if (*option == '+') |
| 5790 | break; |
| 5791 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5792 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5793 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5794 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5795 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5796 | break; |
| 5797 | } |
| 5798 | if (LocaleCompare("style",option+1) == 0) |
| 5799 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5800 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5801 | style; |
| 5802 | |
| 5803 | if (*option == '+') |
| 5804 | break; |
| 5805 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5806 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5807 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5808 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5809 | if (style < 0) |
| 5810 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5811 | argv[i]); |
| 5812 | break; |
| 5813 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5814 | if (LocaleCompare("swap",option+1) == 0) |
| 5815 | { |
| 5816 | if (*option == '+') |
| 5817 | break; |
| 5818 | i++; |
| 5819 | if (i == (ssize_t) (argc-1)) |
| 5820 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5821 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5822 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5823 | break; |
| 5824 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5825 | if (LocaleCompare("swirl",option+1) == 0) |
| 5826 | { |
| 5827 | if (*option == '+') |
| 5828 | break; |
| 5829 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5830 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5831 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5832 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5833 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5834 | break; |
| 5835 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5836 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5837 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5838 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5839 | } |
| 5840 | case 't': |
| 5841 | { |
| 5842 | if (LocaleCompare("taint",option+1) == 0) |
| 5843 | break; |
| 5844 | if (LocaleCompare("texture",option+1) == 0) |
| 5845 | { |
| 5846 | if (*option == '+') |
| 5847 | break; |
| 5848 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5849 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5850 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5851 | break; |
| 5852 | } |
| 5853 | if (LocaleCompare("tile",option+1) == 0) |
| 5854 | { |
| 5855 | if (*option == '+') |
| 5856 | break; |
| 5857 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5858 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5859 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5860 | break; |
| 5861 | } |
| 5862 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5863 | { |
| 5864 | if (*option == '+') |
| 5865 | break; |
| 5866 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5867 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5868 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5869 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5870 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5871 | break; |
| 5872 | } |
| 5873 | if (LocaleCompare("tint",option+1) == 0) |
| 5874 | { |
| 5875 | if (*option == '+') |
| 5876 | break; |
| 5877 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5878 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5879 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5880 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5881 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5882 | break; |
| 5883 | } |
| 5884 | if (LocaleCompare("transform",option+1) == 0) |
| 5885 | break; |
| 5886 | if (LocaleCompare("transpose",option+1) == 0) |
| 5887 | break; |
| 5888 | if (LocaleCompare("transverse",option+1) == 0) |
| 5889 | break; |
| 5890 | if (LocaleCompare("threshold",option+1) == 0) |
| 5891 | { |
| 5892 | if (*option == '+') |
| 5893 | break; |
| 5894 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5895 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5896 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5897 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5898 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5899 | break; |
| 5900 | } |
| 5901 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5902 | { |
| 5903 | if (*option == '+') |
| 5904 | break; |
| 5905 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5906 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5907 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5908 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5909 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5910 | break; |
| 5911 | } |
| 5912 | if (LocaleCompare("transparent",option+1) == 0) |
| 5913 | { |
| 5914 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5915 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5916 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5917 | break; |
| 5918 | } |
| 5919 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 5920 | { |
| 5921 | if (*option == '+') |
| 5922 | break; |
| 5923 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5924 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5925 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5926 | break; |
| 5927 | } |
| 5928 | if (LocaleCompare("treedepth",option+1) == 0) |
| 5929 | { |
| 5930 | if (*option == '+') |
| 5931 | break; |
| 5932 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5933 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5934 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5935 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5936 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5937 | break; |
| 5938 | } |
| 5939 | if (LocaleCompare("trim",option+1) == 0) |
| 5940 | break; |
| 5941 | if (LocaleCompare("type",option+1) == 0) |
| 5942 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5943 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5944 | type; |
| 5945 | |
| 5946 | if (*option == '+') |
| 5947 | break; |
| 5948 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5949 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5950 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5951 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5952 | if (type < 0) |
| 5953 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5954 | argv[i]); |
| 5955 | break; |
| 5956 | } |
| 5957 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5958 | } |
| 5959 | case 'u': |
| 5960 | { |
| 5961 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5962 | { |
| 5963 | if (*option == '+') |
| 5964 | break; |
| 5965 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5966 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5967 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5968 | break; |
| 5969 | } |
| 5970 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5971 | break; |
| 5972 | if (LocaleCompare("units",option+1) == 0) |
| 5973 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5974 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5975 | units; |
| 5976 | |
| 5977 | if (*option == '+') |
| 5978 | break; |
| 5979 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5980 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5981 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5982 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5983 | argv[i]); |
| 5984 | if (units < 0) |
| 5985 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5986 | argv[i]); |
| 5987 | break; |
| 5988 | } |
| 5989 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5990 | { |
| 5991 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5992 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5993 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5994 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5995 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5996 | break; |
| 5997 | } |
| 5998 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5999 | } |
| 6000 | case 'v': |
| 6001 | { |
| 6002 | if (LocaleCompare("verbose",option+1) == 0) |
| 6003 | { |
| 6004 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 6005 | break; |
| 6006 | } |
| 6007 | if ((LocaleCompare("version",option+1) == 0) || |
| 6008 | (LocaleCompare("-version",option+1) == 0)) |
| 6009 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6010 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6011 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 6012 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 6013 | GetMagickCopyright()); |
| 6014 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 6015 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6016 | break; |
| 6017 | } |
| 6018 | if (LocaleCompare("view",option+1) == 0) |
| 6019 | { |
| 6020 | if (*option == '+') |
| 6021 | break; |
| 6022 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6023 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6024 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6025 | break; |
| 6026 | } |
| 6027 | if (LocaleCompare("vignette",option+1) == 0) |
| 6028 | { |
| 6029 | if (*option == '+') |
| 6030 | break; |
| 6031 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6032 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6033 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6034 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6035 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6036 | break; |
| 6037 | } |
| 6038 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 6039 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6040 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6041 | method; |
| 6042 | |
| 6043 | if (*option == '+') |
| 6044 | break; |
| 6045 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6046 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6047 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6048 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6049 | argv[i]); |
| 6050 | if (method < 0) |
| 6051 | ThrowMogrifyException(OptionError, |
| 6052 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 6053 | break; |
| 6054 | } |
| 6055 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6056 | } |
| 6057 | case 'w': |
| 6058 | { |
| 6059 | if (LocaleCompare("wave",option+1) == 0) |
| 6060 | { |
| 6061 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6062 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6063 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6064 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6065 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6066 | break; |
| 6067 | } |
| 6068 | if (LocaleCompare("weight",option+1) == 0) |
| 6069 | { |
| 6070 | if (*option == '+') |
| 6071 | break; |
| 6072 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6073 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6074 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6075 | break; |
| 6076 | } |
| 6077 | if (LocaleCompare("white-point",option+1) == 0) |
| 6078 | { |
| 6079 | if (*option == '+') |
| 6080 | break; |
| 6081 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6082 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6083 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6084 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6085 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6086 | break; |
| 6087 | } |
| 6088 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6089 | { |
| 6090 | if (*option == '+') |
| 6091 | break; |
| 6092 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6093 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6094 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6095 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6096 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6097 | break; |
| 6098 | } |
| 6099 | if (LocaleCompare("write",option+1) == 0) |
| 6100 | { |
| 6101 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6102 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6103 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6104 | break; |
| 6105 | } |
| 6106 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6107 | } |
| 6108 | case '?': |
| 6109 | break; |
| 6110 | default: |
| 6111 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6112 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6113 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 6114 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6115 | if (fire != MagickFalse) |
| 6116 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6117 | } |
| 6118 | if (k != 0) |
| 6119 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6120 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6121 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6122 | DestroyMogrify(); |
| 6123 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6124 | } |
| 6125 | |
| 6126 | /* |
| 6127 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6128 | % % |
| 6129 | % % |
| 6130 | % % |
| 6131 | + M o g r i f y I m a g e I n f o % |
| 6132 | % % |
| 6133 | % % |
| 6134 | % % |
| 6135 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6136 | % |
| 6137 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6138 | % prescribed by command line options. |
| 6139 | % |
| 6140 | % The format of the MogrifyImageInfo method is: |
| 6141 | % |
| 6142 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6143 | % const char **argv,ExceptionInfo *exception) |
| 6144 | % |
| 6145 | % A description of each parameter follows: |
| 6146 | % |
| 6147 | % o image_info: the image info.. |
| 6148 | % |
| 6149 | % o argc: Specifies a pointer to an integer describing the number of |
| 6150 | % elements in the argument vector. |
| 6151 | % |
| 6152 | % o argv: Specifies a pointer to a text array containing the command line |
| 6153 | % arguments. |
| 6154 | % |
| 6155 | % o exception: return any errors or warnings in this structure. |
| 6156 | % |
| 6157 | */ |
| 6158 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6159 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6160 | { |
| 6161 | const char |
| 6162 | *option; |
| 6163 | |
| 6164 | GeometryInfo |
| 6165 | geometry_info; |
| 6166 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6167 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6168 | count; |
| 6169 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6170 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6171 | i; |
| 6172 | |
| 6173 | /* |
| 6174 | Initialize method variables. |
| 6175 | */ |
| 6176 | assert(image_info != (ImageInfo *) NULL); |
| 6177 | assert(image_info->signature == MagickSignature); |
| 6178 | if (image_info->debug != MagickFalse) |
| 6179 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6180 | image_info->filename); |
| 6181 | if (argc < 0) |
| 6182 | return(MagickTrue); |
| 6183 | /* |
| 6184 | Set the image settings. |
| 6185 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6186 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6187 | { |
| 6188 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6189 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6190 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6191 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6192 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6193 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6194 | break; |
| 6195 | switch (*(option+1)) |
| 6196 | { |
| 6197 | case 'a': |
| 6198 | { |
| 6199 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6200 | { |
| 6201 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6202 | break; |
| 6203 | } |
| 6204 | if (LocaleCompare("antialias",option+1) == 0) |
| 6205 | { |
| 6206 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6207 | break; |
| 6208 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6209 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6210 | { |
| 6211 | if (*option == '+') |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 6212 | (void) DeleteImageOption(image_info,option+1); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6213 | else |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 6214 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6215 | break; |
| 6216 | } |
| 6217 | break; |
| 6218 | } |
| 6219 | case 'b': |
| 6220 | { |
| 6221 | if (LocaleCompare("background",option+1) == 0) |
| 6222 | { |
| 6223 | if (*option == '+') |
| 6224 | { |
| 6225 | (void) DeleteImageOption(image_info,option+1); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6226 | (void) QueryColorCompliance(MogrifyBackgroundColor, |
| 6227 | AllCompliance,&image_info->background_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6228 | break; |
| 6229 | } |
| 6230 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6231 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6232 | &image_info->background_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6233 | break; |
| 6234 | } |
| 6235 | if (LocaleCompare("bias",option+1) == 0) |
| 6236 | { |
| 6237 | if (*option == '+') |
| 6238 | { |
| 6239 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6240 | break; |
| 6241 | } |
| 6242 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6243 | break; |
| 6244 | } |
| 6245 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6246 | { |
| 6247 | if (*option == '+') |
| 6248 | { |
| 6249 | (void) SetImageOption(image_info,option+1,"false"); |
| 6250 | break; |
| 6251 | } |
| 6252 | (void) SetImageOption(image_info,option+1,"true"); |
| 6253 | break; |
| 6254 | } |
| 6255 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6256 | { |
| 6257 | if (*option == '+') |
| 6258 | { |
| 6259 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6260 | break; |
| 6261 | } |
| 6262 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6263 | break; |
| 6264 | } |
| 6265 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6266 | { |
| 6267 | if (*option == '+') |
| 6268 | { |
| 6269 | (void) DeleteImageOption(image_info,option+1); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6270 | (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6271 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6272 | break; |
| 6273 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6274 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6275 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6276 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6277 | break; |
| 6278 | } |
| 6279 | if (LocaleCompare("box",option+1) == 0) |
| 6280 | { |
| 6281 | if (*option == '+') |
| 6282 | { |
| 6283 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6284 | break; |
| 6285 | } |
| 6286 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6287 | break; |
| 6288 | } |
| 6289 | break; |
| 6290 | } |
| 6291 | case 'c': |
| 6292 | { |
| 6293 | if (LocaleCompare("cache",option+1) == 0) |
| 6294 | { |
| 6295 | MagickSizeType |
| 6296 | limit; |
| 6297 | |
| 6298 | limit=MagickResourceInfinity; |
| 6299 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 6300 | limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1], |
| 6301 | 100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6302 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6303 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6304 | break; |
| 6305 | } |
| 6306 | if (LocaleCompare("caption",option+1) == 0) |
| 6307 | { |
| 6308 | if (*option == '+') |
| 6309 | { |
| 6310 | (void) DeleteImageOption(image_info,option+1); |
| 6311 | break; |
| 6312 | } |
| 6313 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6314 | break; |
| 6315 | } |
| 6316 | if (LocaleCompare("channel",option+1) == 0) |
| 6317 | { |
| 6318 | if (*option == '+') |
| 6319 | { |
| 6320 | image_info->channel=DefaultChannels; |
| 6321 | break; |
| 6322 | } |
| 6323 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6324 | break; |
| 6325 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6326 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6327 | { |
| 6328 | if (*option == '+') |
| 6329 | { |
| 6330 | image_info->colorspace=UndefinedColorspace; |
| 6331 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6332 | break; |
| 6333 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6334 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6335 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6336 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6337 | break; |
| 6338 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6339 | if (LocaleCompare("comment",option+1) == 0) |
| 6340 | { |
| 6341 | if (*option == '+') |
| 6342 | { |
| 6343 | (void) DeleteImageOption(image_info,option+1); |
| 6344 | break; |
| 6345 | } |
| 6346 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6347 | break; |
| 6348 | } |
| 6349 | if (LocaleCompare("compose",option+1) == 0) |
| 6350 | { |
| 6351 | if (*option == '+') |
| 6352 | { |
| 6353 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6354 | break; |
| 6355 | } |
| 6356 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6357 | break; |
| 6358 | } |
| 6359 | if (LocaleCompare("compress",option+1) == 0) |
| 6360 | { |
| 6361 | if (*option == '+') |
| 6362 | { |
| 6363 | image_info->compression=UndefinedCompression; |
| 6364 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6365 | break; |
| 6366 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6367 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6368 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6369 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6370 | break; |
| 6371 | } |
| 6372 | break; |
| 6373 | } |
| 6374 | case 'd': |
| 6375 | { |
| 6376 | if (LocaleCompare("debug",option+1) == 0) |
| 6377 | { |
| 6378 | if (*option == '+') |
| 6379 | (void) SetLogEventMask("none"); |
| 6380 | else |
| 6381 | (void) SetLogEventMask(argv[i+1]); |
| 6382 | image_info->debug=IsEventLogging(); |
| 6383 | break; |
| 6384 | } |
| 6385 | if (LocaleCompare("define",option+1) == 0) |
| 6386 | { |
| 6387 | if (*option == '+') |
| 6388 | { |
| 6389 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6390 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6391 | else |
| 6392 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6393 | break; |
| 6394 | } |
| 6395 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6396 | { |
| 6397 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6398 | exception); |
| 6399 | break; |
| 6400 | } |
| 6401 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6402 | break; |
| 6403 | } |
| 6404 | if (LocaleCompare("delay",option+1) == 0) |
| 6405 | { |
| 6406 | if (*option == '+') |
| 6407 | { |
| 6408 | (void) SetImageOption(image_info,option+1,"0"); |
| 6409 | break; |
| 6410 | } |
| 6411 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6412 | break; |
| 6413 | } |
| 6414 | if (LocaleCompare("density",option+1) == 0) |
| 6415 | { |
| 6416 | /* |
| 6417 | Set image density. |
| 6418 | */ |
| 6419 | if (*option == '+') |
| 6420 | { |
| 6421 | if (image_info->density != (char *) NULL) |
| 6422 | image_info->density=DestroyString(image_info->density); |
| 6423 | (void) SetImageOption(image_info,option+1,"72"); |
| 6424 | break; |
| 6425 | } |
| 6426 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6427 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6428 | break; |
| 6429 | } |
| 6430 | if (LocaleCompare("depth",option+1) == 0) |
| 6431 | { |
| 6432 | if (*option == '+') |
| 6433 | { |
| 6434 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6435 | break; |
| 6436 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6437 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6438 | break; |
| 6439 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6440 | if (LocaleCompare("direction",option+1) == 0) |
| 6441 | { |
| 6442 | if (*option == '+') |
| 6443 | { |
| 6444 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6445 | break; |
| 6446 | } |
| 6447 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6448 | break; |
| 6449 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6450 | if (LocaleCompare("display",option+1) == 0) |
| 6451 | { |
| 6452 | if (*option == '+') |
| 6453 | { |
| 6454 | if (image_info->server_name != (char *) NULL) |
| 6455 | image_info->server_name=DestroyString( |
| 6456 | image_info->server_name); |
| 6457 | break; |
| 6458 | } |
| 6459 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6460 | break; |
| 6461 | } |
| 6462 | if (LocaleCompare("dispose",option+1) == 0) |
| 6463 | { |
| 6464 | if (*option == '+') |
| 6465 | { |
| 6466 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6467 | break; |
| 6468 | } |
| 6469 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6470 | break; |
| 6471 | } |
| 6472 | if (LocaleCompare("dither",option+1) == 0) |
| 6473 | { |
| 6474 | if (*option == '+') |
| 6475 | { |
| 6476 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6477 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6478 | break; |
| 6479 | } |
| 6480 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6481 | image_info->dither=MagickTrue; |
| 6482 | break; |
| 6483 | } |
| 6484 | break; |
| 6485 | } |
| 6486 | case 'e': |
| 6487 | { |
| 6488 | if (LocaleCompare("encoding",option+1) == 0) |
| 6489 | { |
| 6490 | if (*option == '+') |
| 6491 | { |
| 6492 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6493 | break; |
| 6494 | } |
| 6495 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6496 | break; |
| 6497 | } |
| 6498 | if (LocaleCompare("endian",option+1) == 0) |
| 6499 | { |
| 6500 | if (*option == '+') |
| 6501 | { |
| 6502 | image_info->endian=UndefinedEndian; |
| 6503 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6504 | break; |
| 6505 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6506 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6507 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6508 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6509 | break; |
| 6510 | } |
| 6511 | if (LocaleCompare("extract",option+1) == 0) |
| 6512 | { |
| 6513 | /* |
| 6514 | Set image extract geometry. |
| 6515 | */ |
| 6516 | if (*option == '+') |
| 6517 | { |
| 6518 | if (image_info->extract != (char *) NULL) |
| 6519 | image_info->extract=DestroyString(image_info->extract); |
| 6520 | break; |
| 6521 | } |
| 6522 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6523 | break; |
| 6524 | } |
| 6525 | break; |
| 6526 | } |
| 6527 | case 'f': |
| 6528 | { |
| 6529 | if (LocaleCompare("fill",option+1) == 0) |
| 6530 | { |
| 6531 | if (*option == '+') |
| 6532 | { |
| 6533 | (void) SetImageOption(image_info,option+1,"none"); |
| 6534 | break; |
| 6535 | } |
| 6536 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6537 | break; |
| 6538 | } |
| 6539 | if (LocaleCompare("filter",option+1) == 0) |
| 6540 | { |
| 6541 | if (*option == '+') |
| 6542 | { |
| 6543 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6544 | break; |
| 6545 | } |
| 6546 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6547 | break; |
| 6548 | } |
| 6549 | if (LocaleCompare("font",option+1) == 0) |
| 6550 | { |
| 6551 | if (*option == '+') |
| 6552 | { |
| 6553 | if (image_info->font != (char *) NULL) |
| 6554 | image_info->font=DestroyString(image_info->font); |
| 6555 | break; |
| 6556 | } |
| 6557 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6558 | break; |
| 6559 | } |
| 6560 | if (LocaleCompare("format",option+1) == 0) |
| 6561 | { |
| 6562 | register const char |
| 6563 | *q; |
| 6564 | |
| 6565 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6566 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6567 | image_info->ping=MagickFalse; |
| 6568 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6569 | break; |
| 6570 | } |
| 6571 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6572 | { |
| 6573 | if (*option == '+') |
| 6574 | { |
| 6575 | image_info->fuzz=0.0; |
| 6576 | (void) SetImageOption(image_info,option+1,"0"); |
| 6577 | break; |
| 6578 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 6579 | image_info->fuzz=StringToDoubleInterval(argv[i+1],(double) |
| 6580 | QuantumRange+1.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6581 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6582 | break; |
| 6583 | } |
| 6584 | break; |
| 6585 | } |
| 6586 | case 'g': |
| 6587 | { |
| 6588 | if (LocaleCompare("gravity",option+1) == 0) |
| 6589 | { |
| 6590 | if (*option == '+') |
| 6591 | { |
| 6592 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6593 | break; |
| 6594 | } |
| 6595 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6596 | break; |
| 6597 | } |
| 6598 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6599 | { |
| 6600 | if (*option == '+') |
| 6601 | { |
| 6602 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6603 | break; |
| 6604 | } |
| 6605 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6606 | break; |
| 6607 | } |
| 6608 | break; |
| 6609 | } |
| 6610 | case 'i': |
| 6611 | { |
| 6612 | if (LocaleCompare("intent",option+1) == 0) |
| 6613 | { |
| 6614 | if (*option == '+') |
| 6615 | { |
| 6616 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6617 | break; |
| 6618 | } |
| 6619 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6620 | break; |
| 6621 | } |
| 6622 | if (LocaleCompare("interlace",option+1) == 0) |
| 6623 | { |
| 6624 | if (*option == '+') |
| 6625 | { |
| 6626 | image_info->interlace=UndefinedInterlace; |
| 6627 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6628 | break; |
| 6629 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6630 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6631 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6632 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6633 | break; |
| 6634 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6635 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6636 | { |
| 6637 | if (*option == '+') |
| 6638 | { |
| 6639 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6640 | break; |
| 6641 | } |
| 6642 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6643 | break; |
| 6644 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6645 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6646 | { |
| 6647 | if (*option == '+') |
| 6648 | { |
| 6649 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6650 | break; |
| 6651 | } |
| 6652 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6653 | break; |
| 6654 | } |
| 6655 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6656 | { |
| 6657 | if (*option == '+') |
| 6658 | { |
| 6659 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6660 | break; |
| 6661 | } |
| 6662 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6663 | break; |
| 6664 | } |
| 6665 | break; |
| 6666 | } |
| 6667 | case 'k': |
| 6668 | { |
| 6669 | if (LocaleCompare("kerning",option+1) == 0) |
| 6670 | { |
| 6671 | if (*option == '+') |
| 6672 | { |
| 6673 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6674 | break; |
| 6675 | } |
| 6676 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6677 | break; |
| 6678 | } |
| 6679 | break; |
| 6680 | } |
| 6681 | case 'l': |
| 6682 | { |
| 6683 | if (LocaleCompare("label",option+1) == 0) |
| 6684 | { |
| 6685 | if (*option == '+') |
| 6686 | { |
| 6687 | (void) DeleteImageOption(image_info,option+1); |
| 6688 | break; |
| 6689 | } |
| 6690 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6691 | break; |
| 6692 | } |
| 6693 | if (LocaleCompare("limit",option+1) == 0) |
| 6694 | { |
| 6695 | MagickSizeType |
| 6696 | limit; |
| 6697 | |
| 6698 | ResourceType |
| 6699 | type; |
| 6700 | |
| 6701 | if (*option == '+') |
| 6702 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6703 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6704 | MagickFalse,argv[i+1]); |
| 6705 | limit=MagickResourceInfinity; |
| 6706 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | c062734 | 2011-11-18 21:15:24 +0000 | [diff] [blame] | 6707 | limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6708 | (void) SetMagickResourceLimit(type,limit); |
| 6709 | break; |
| 6710 | } |
| 6711 | if (LocaleCompare("list",option+1) == 0) |
| 6712 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6713 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6714 | list; |
| 6715 | |
| 6716 | /* |
| 6717 | Display configuration list. |
| 6718 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6719 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6720 | switch (list) |
| 6721 | { |
| 6722 | case MagickCoderOptions: |
| 6723 | { |
| 6724 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6725 | break; |
| 6726 | } |
| 6727 | case MagickColorOptions: |
| 6728 | { |
| 6729 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6730 | break; |
| 6731 | } |
| 6732 | case MagickConfigureOptions: |
| 6733 | { |
| 6734 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6735 | break; |
| 6736 | } |
| 6737 | case MagickDelegateOptions: |
| 6738 | { |
| 6739 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6740 | break; |
| 6741 | } |
| 6742 | case MagickFontOptions: |
| 6743 | { |
| 6744 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6745 | break; |
| 6746 | } |
| 6747 | case MagickFormatOptions: |
| 6748 | { |
| 6749 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6750 | break; |
| 6751 | } |
| 6752 | case MagickLocaleOptions: |
| 6753 | { |
| 6754 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6755 | break; |
| 6756 | } |
| 6757 | case MagickLogOptions: |
| 6758 | { |
| 6759 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6760 | break; |
| 6761 | } |
| 6762 | case MagickMagicOptions: |
| 6763 | { |
| 6764 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6765 | break; |
| 6766 | } |
| 6767 | case MagickMimeOptions: |
| 6768 | { |
| 6769 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6770 | break; |
| 6771 | } |
| 6772 | case MagickModuleOptions: |
| 6773 | { |
| 6774 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6775 | break; |
| 6776 | } |
| 6777 | case MagickPolicyOptions: |
| 6778 | { |
| 6779 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6780 | break; |
| 6781 | } |
| 6782 | case MagickResourceOptions: |
| 6783 | { |
| 6784 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6785 | break; |
| 6786 | } |
| 6787 | case MagickThresholdOptions: |
| 6788 | { |
| 6789 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6790 | break; |
| 6791 | } |
| 6792 | default: |
| 6793 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6794 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6795 | exception); |
| 6796 | break; |
| 6797 | } |
| 6798 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6799 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6800 | } |
| 6801 | if (LocaleCompare("log",option+1) == 0) |
| 6802 | { |
| 6803 | if (*option == '+') |
| 6804 | break; |
| 6805 | (void) SetLogFormat(argv[i+1]); |
| 6806 | break; |
| 6807 | } |
| 6808 | if (LocaleCompare("loop",option+1) == 0) |
| 6809 | { |
| 6810 | if (*option == '+') |
| 6811 | { |
| 6812 | (void) SetImageOption(image_info,option+1,"0"); |
| 6813 | break; |
| 6814 | } |
| 6815 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6816 | break; |
| 6817 | } |
| 6818 | break; |
| 6819 | } |
| 6820 | case 'm': |
| 6821 | { |
| 6822 | if (LocaleCompare("matte",option+1) == 0) |
| 6823 | { |
| 6824 | if (*option == '+') |
| 6825 | { |
| 6826 | (void) SetImageOption(image_info,option+1,"false"); |
| 6827 | break; |
| 6828 | } |
| 6829 | (void) SetImageOption(image_info,option+1,"true"); |
| 6830 | break; |
| 6831 | } |
| 6832 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6833 | { |
| 6834 | if (*option == '+') |
| 6835 | { |
| 6836 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6837 | (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance, |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6838 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6839 | break; |
| 6840 | } |
| 6841 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6842 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6843 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6844 | break; |
| 6845 | } |
| 6846 | if (LocaleCompare("monitor",option+1) == 0) |
| 6847 | { |
| 6848 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6849 | (void *) NULL); |
| 6850 | break; |
| 6851 | } |
| 6852 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6853 | { |
| 6854 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6855 | break; |
| 6856 | } |
| 6857 | break; |
| 6858 | } |
| 6859 | case 'o': |
| 6860 | { |
| 6861 | if (LocaleCompare("orient",option+1) == 0) |
| 6862 | { |
| 6863 | if (*option == '+') |
| 6864 | { |
| 6865 | image_info->orientation=UndefinedOrientation; |
| 6866 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6867 | break; |
| 6868 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6869 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6870 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6871 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6872 | break; |
| 6873 | } |
| 6874 | } |
| 6875 | case 'p': |
| 6876 | { |
| 6877 | if (LocaleCompare("page",option+1) == 0) |
| 6878 | { |
| 6879 | char |
| 6880 | *canonical_page, |
| 6881 | page[MaxTextExtent]; |
| 6882 | |
| 6883 | const char |
| 6884 | *image_option; |
| 6885 | |
| 6886 | MagickStatusType |
| 6887 | flags; |
| 6888 | |
| 6889 | RectangleInfo |
| 6890 | geometry; |
| 6891 | |
| 6892 | if (*option == '+') |
| 6893 | { |
| 6894 | (void) DeleteImageOption(image_info,option+1); |
| 6895 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6896 | break; |
| 6897 | } |
| 6898 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6899 | image_option=GetImageOption(image_info,"page"); |
| 6900 | if (image_option != (const char *) NULL) |
| 6901 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6902 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6903 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6904 | canonical_page=DestroyString(canonical_page); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6905 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6906 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6907 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6908 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6909 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6910 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6911 | (void) SetImageOption(image_info,option+1,page); |
| 6912 | (void) CloneString(&image_info->page,page); |
| 6913 | break; |
| 6914 | } |
| 6915 | if (LocaleCompare("pen",option+1) == 0) |
| 6916 | { |
| 6917 | if (*option == '+') |
| 6918 | { |
| 6919 | (void) SetImageOption(image_info,option+1,"none"); |
| 6920 | break; |
| 6921 | } |
| 6922 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6923 | break; |
| 6924 | } |
| 6925 | if (LocaleCompare("ping",option+1) == 0) |
| 6926 | { |
| 6927 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6928 | break; |
| 6929 | } |
| 6930 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6931 | { |
| 6932 | if (*option == '+') |
| 6933 | geometry_info.rho=0.0; |
| 6934 | else |
| 6935 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6936 | image_info->pointsize=geometry_info.rho; |
| 6937 | break; |
| 6938 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6939 | if (LocaleCompare("precision",option+1) == 0) |
| 6940 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6941 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6942 | break; |
| 6943 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6944 | if (LocaleCompare("preview",option+1) == 0) |
| 6945 | { |
| 6946 | /* |
| 6947 | Preview image. |
| 6948 | */ |
| 6949 | if (*option == '+') |
| 6950 | { |
| 6951 | image_info->preview_type=UndefinedPreview; |
| 6952 | break; |
| 6953 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6954 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6955 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6956 | break; |
| 6957 | } |
| 6958 | break; |
| 6959 | } |
| 6960 | case 'q': |
| 6961 | { |
| 6962 | if (LocaleCompare("quality",option+1) == 0) |
| 6963 | { |
| 6964 | /* |
| 6965 | Set image compression quality. |
| 6966 | */ |
| 6967 | if (*option == '+') |
| 6968 | { |
| 6969 | image_info->quality=UndefinedCompressionQuality; |
| 6970 | (void) SetImageOption(image_info,option+1,"0"); |
| 6971 | break; |
| 6972 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6973 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6974 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6975 | break; |
| 6976 | } |
| 6977 | if (LocaleCompare("quiet",option+1) == 0) |
| 6978 | { |
| 6979 | static WarningHandler |
| 6980 | warning_handler = (WarningHandler) NULL; |
| 6981 | |
| 6982 | if (*option == '+') |
| 6983 | { |
| 6984 | /* |
| 6985 | Restore error or warning messages. |
| 6986 | */ |
| 6987 | warning_handler=SetWarningHandler(warning_handler); |
| 6988 | break; |
| 6989 | } |
| 6990 | /* |
| 6991 | Suppress error or warning messages. |
| 6992 | */ |
| 6993 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6994 | break; |
| 6995 | } |
| 6996 | break; |
| 6997 | } |
| 6998 | case 'r': |
| 6999 | { |
| 7000 | if (LocaleCompare("red-primary",option+1) == 0) |
| 7001 | { |
| 7002 | if (*option == '+') |
| 7003 | { |
| 7004 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7005 | break; |
| 7006 | } |
| 7007 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7008 | break; |
| 7009 | } |
| 7010 | break; |
| 7011 | } |
| 7012 | case 's': |
| 7013 | { |
| 7014 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 7015 | { |
| 7016 | /* |
| 7017 | Set image sampling factor. |
| 7018 | */ |
| 7019 | if (*option == '+') |
| 7020 | { |
| 7021 | if (image_info->sampling_factor != (char *) NULL) |
| 7022 | image_info->sampling_factor=DestroyString( |
| 7023 | image_info->sampling_factor); |
| 7024 | break; |
| 7025 | } |
| 7026 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 7027 | break; |
| 7028 | } |
| 7029 | if (LocaleCompare("scene",option+1) == 0) |
| 7030 | { |
| 7031 | /* |
| 7032 | Set image scene. |
| 7033 | */ |
| 7034 | if (*option == '+') |
| 7035 | { |
| 7036 | image_info->scene=0; |
| 7037 | (void) SetImageOption(image_info,option+1,"0"); |
| 7038 | break; |
| 7039 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7040 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7041 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7042 | break; |
| 7043 | } |
| 7044 | if (LocaleCompare("seed",option+1) == 0) |
| 7045 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7046 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7047 | seed; |
| 7048 | |
| 7049 | if (*option == '+') |
| 7050 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7051 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7052 | SeedPseudoRandomGenerator(seed); |
| 7053 | break; |
| 7054 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7055 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7056 | SeedPseudoRandomGenerator(seed); |
| 7057 | break; |
| 7058 | } |
| 7059 | if (LocaleCompare("size",option+1) == 0) |
| 7060 | { |
| 7061 | if (*option == '+') |
| 7062 | { |
| 7063 | if (image_info->size != (char *) NULL) |
| 7064 | image_info->size=DestroyString(image_info->size); |
| 7065 | break; |
| 7066 | } |
| 7067 | (void) CloneString(&image_info->size,argv[i+1]); |
| 7068 | break; |
| 7069 | } |
| 7070 | if (LocaleCompare("stroke",option+1) == 0) |
| 7071 | { |
| 7072 | if (*option == '+') |
| 7073 | { |
| 7074 | (void) SetImageOption(image_info,option+1,"none"); |
| 7075 | break; |
| 7076 | } |
| 7077 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7078 | break; |
| 7079 | } |
| 7080 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7081 | { |
| 7082 | if (*option == '+') |
| 7083 | { |
| 7084 | (void) SetImageOption(image_info,option+1,"0"); |
| 7085 | break; |
| 7086 | } |
| 7087 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7088 | break; |
| 7089 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7090 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7091 | { |
| 7092 | if (*option == '+') |
| 7093 | { |
| 7094 | image_info->synchronize=MagickFalse; |
| 7095 | break; |
| 7096 | } |
| 7097 | image_info->synchronize=MagickTrue; |
| 7098 | break; |
| 7099 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7100 | break; |
| 7101 | } |
| 7102 | case 't': |
| 7103 | { |
| 7104 | if (LocaleCompare("taint",option+1) == 0) |
| 7105 | { |
| 7106 | if (*option == '+') |
| 7107 | { |
| 7108 | (void) SetImageOption(image_info,option+1,"false"); |
| 7109 | break; |
| 7110 | } |
| 7111 | (void) SetImageOption(image_info,option+1,"true"); |
| 7112 | break; |
| 7113 | } |
| 7114 | if (LocaleCompare("texture",option+1) == 0) |
| 7115 | { |
| 7116 | if (*option == '+') |
| 7117 | { |
| 7118 | if (image_info->texture != (char *) NULL) |
| 7119 | image_info->texture=DestroyString(image_info->texture); |
| 7120 | break; |
| 7121 | } |
| 7122 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7123 | break; |
| 7124 | } |
| 7125 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7126 | { |
| 7127 | if (*option == '+') |
| 7128 | { |
| 7129 | (void) SetImageOption(image_info,option+1,"0"); |
| 7130 | break; |
| 7131 | } |
| 7132 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7133 | break; |
| 7134 | } |
| 7135 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7136 | { |
| 7137 | if (*option == '+') |
| 7138 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 7139 | (void) QueryColorCompliance("none",AllCompliance, |
| 7140 | &image_info->transparent_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7141 | (void) SetImageOption(image_info,option+1,"none"); |
| 7142 | break; |
| 7143 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 7144 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 7145 | &image_info->transparent_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7146 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7147 | break; |
| 7148 | } |
| 7149 | if (LocaleCompare("type",option+1) == 0) |
| 7150 | { |
| 7151 | if (*option == '+') |
| 7152 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7153 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7154 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7155 | break; |
| 7156 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7157 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7158 | MagickFalse,argv[i+1]); |
| 7159 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7160 | break; |
| 7161 | } |
| 7162 | break; |
| 7163 | } |
| 7164 | case 'u': |
| 7165 | { |
| 7166 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7167 | { |
| 7168 | if (*option == '+') |
| 7169 | { |
| 7170 | (void) DeleteImageOption(image_info,option+1); |
| 7171 | break; |
| 7172 | } |
| 7173 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7174 | break; |
| 7175 | } |
| 7176 | if (LocaleCompare("units",option+1) == 0) |
| 7177 | { |
| 7178 | if (*option == '+') |
| 7179 | { |
| 7180 | image_info->units=UndefinedResolution; |
| 7181 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7182 | break; |
| 7183 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7184 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7185 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7186 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7187 | break; |
| 7188 | } |
| 7189 | break; |
| 7190 | } |
| 7191 | case 'v': |
| 7192 | { |
| 7193 | if (LocaleCompare("verbose",option+1) == 0) |
| 7194 | { |
| 7195 | if (*option == '+') |
| 7196 | { |
| 7197 | image_info->verbose=MagickFalse; |
| 7198 | break; |
| 7199 | } |
| 7200 | image_info->verbose=MagickTrue; |
| 7201 | image_info->ping=MagickFalse; |
| 7202 | break; |
| 7203 | } |
| 7204 | if (LocaleCompare("view",option+1) == 0) |
| 7205 | { |
| 7206 | if (*option == '+') |
| 7207 | { |
| 7208 | if (image_info->view != (char *) NULL) |
| 7209 | image_info->view=DestroyString(image_info->view); |
| 7210 | break; |
| 7211 | } |
| 7212 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7213 | break; |
| 7214 | } |
| 7215 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7216 | { |
| 7217 | if (*option == '+') |
| 7218 | { |
| 7219 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7220 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7221 | break; |
| 7222 | } |
| 7223 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7224 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7225 | argv[i+1]); |
| 7226 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7227 | break; |
| 7228 | } |
| 7229 | break; |
| 7230 | } |
| 7231 | case 'w': |
| 7232 | { |
| 7233 | if (LocaleCompare("white-point",option+1) == 0) |
| 7234 | { |
| 7235 | if (*option == '+') |
| 7236 | { |
| 7237 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7238 | break; |
| 7239 | } |
| 7240 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7241 | break; |
| 7242 | } |
| 7243 | break; |
| 7244 | } |
| 7245 | default: |
| 7246 | break; |
| 7247 | } |
| 7248 | i+=count; |
| 7249 | } |
| 7250 | return(MagickTrue); |
| 7251 | } |
| 7252 | |
| 7253 | /* |
| 7254 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7255 | % % |
| 7256 | % % |
| 7257 | % % |
| 7258 | + M o g r i f y I m a g e L i s t % |
| 7259 | % % |
| 7260 | % % |
| 7261 | % % |
| 7262 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7263 | % |
| 7264 | % MogrifyImageList() applies any command line options that might affect the |
| 7265 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7266 | % |
| 7267 | % The format of the MogrifyImage method is: |
| 7268 | % |
| 7269 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7270 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7271 | % |
| 7272 | % A description of each parameter follows: |
| 7273 | % |
| 7274 | % o image_info: the image info.. |
| 7275 | % |
| 7276 | % o argc: Specifies a pointer to an integer describing the number of |
| 7277 | % elements in the argument vector. |
| 7278 | % |
| 7279 | % o argv: Specifies a pointer to a text array containing the command line |
| 7280 | % arguments. |
| 7281 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7282 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7283 | % |
| 7284 | % o exception: return any errors or warnings in this structure. |
| 7285 | % |
| 7286 | */ |
| 7287 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7288 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7289 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7290 | const char |
| 7291 | *option; |
| 7292 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7293 | ImageInfo |
| 7294 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7295 | |
| 7296 | MagickStatusType |
| 7297 | status; |
| 7298 | |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7299 | PixelInterpolateMethod |
| 7300 | interpolate_method; |
| 7301 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7302 | QuantizeInfo |
| 7303 | *quantize_info; |
| 7304 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7305 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7306 | i; |
| 7307 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7308 | ssize_t |
| 7309 | count, |
| 7310 | index; |
| 7311 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7312 | /* |
| 7313 | Apply options to the image list. |
| 7314 | */ |
| 7315 | assert(image_info != (ImageInfo *) NULL); |
| 7316 | assert(image_info->signature == MagickSignature); |
| 7317 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7318 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7319 | assert((*images)->signature == MagickSignature); |
| 7320 | if ((*images)->debug != MagickFalse) |
| 7321 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7322 | (*images)->filename); |
| 7323 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7324 | return(MagickTrue); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7325 | interpolate_method=UndefinedInterpolatePixel; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7326 | mogrify_info=CloneImageInfo(image_info); |
| 7327 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7328 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7329 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7330 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7331 | if (*images == (Image *) NULL) |
| 7332 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7333 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7334 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7335 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7336 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7337 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7338 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7339 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7340 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7341 | switch (*(option+1)) |
| 7342 | { |
| 7343 | case 'a': |
| 7344 | { |
| 7345 | if (LocaleCompare("affinity",option+1) == 0) |
| 7346 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7347 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7348 | if (*option == '+') |
| 7349 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7350 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7351 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7352 | break; |
| 7353 | } |
| 7354 | i++; |
| 7355 | break; |
| 7356 | } |
| 7357 | if (LocaleCompare("append",option+1) == 0) |
| 7358 | { |
| 7359 | Image |
| 7360 | *append_image; |
| 7361 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7362 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7363 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7364 | MagickFalse,exception); |
| 7365 | if (append_image == (Image *) NULL) |
| 7366 | { |
| 7367 | status=MagickFalse; |
| 7368 | break; |
| 7369 | } |
| 7370 | *images=DestroyImageList(*images); |
| 7371 | *images=append_image; |
| 7372 | break; |
| 7373 | } |
| 7374 | if (LocaleCompare("average",option+1) == 0) |
| 7375 | { |
| 7376 | Image |
| 7377 | *average_image; |
| 7378 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7379 | /* |
| 7380 | Average an image sequence (deprecated). |
| 7381 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7382 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7383 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7384 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7385 | if (average_image == (Image *) NULL) |
| 7386 | { |
| 7387 | status=MagickFalse; |
| 7388 | break; |
| 7389 | } |
| 7390 | *images=DestroyImageList(*images); |
| 7391 | *images=average_image; |
| 7392 | break; |
| 7393 | } |
| 7394 | break; |
| 7395 | } |
| 7396 | case 'c': |
| 7397 | { |
| 7398 | if (LocaleCompare("channel",option+1) == 0) |
| 7399 | { |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7400 | ChannelType |
| 7401 | channel; |
| 7402 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7403 | if (*option == '+') |
| 7404 | { |
| 7405 | channel=DefaultChannels; |
| 7406 | break; |
| 7407 | } |
| 7408 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | e2a912b | 2011-12-05 20:02:07 +0000 | [diff] [blame] | 7409 | SetPixelChannelMapMask(*images,channel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7410 | break; |
| 7411 | } |
| 7412 | if (LocaleCompare("clut",option+1) == 0) |
| 7413 | { |
| 7414 | Image |
| 7415 | *clut_image, |
| 7416 | *image; |
| 7417 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7418 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7419 | image=RemoveFirstImageFromList(images); |
| 7420 | clut_image=RemoveFirstImageFromList(images); |
| 7421 | if (clut_image == (Image *) NULL) |
| 7422 | { |
| 7423 | status=MagickFalse; |
| 7424 | break; |
| 7425 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7426 | (void) ClutImage(image,clut_image,interpolate_method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7427 | clut_image=DestroyImage(clut_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7428 | *images=DestroyImageList(*images); |
| 7429 | *images=image; |
| 7430 | break; |
| 7431 | } |
| 7432 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7433 | { |
| 7434 | Image |
| 7435 | *coalesce_image; |
| 7436 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7437 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7438 | coalesce_image=CoalesceImages(*images,exception); |
| 7439 | if (coalesce_image == (Image *) NULL) |
| 7440 | { |
| 7441 | status=MagickFalse; |
| 7442 | break; |
| 7443 | } |
| 7444 | *images=DestroyImageList(*images); |
| 7445 | *images=coalesce_image; |
| 7446 | break; |
| 7447 | } |
| 7448 | if (LocaleCompare("combine",option+1) == 0) |
| 7449 | { |
| 7450 | Image |
| 7451 | *combine_image; |
| 7452 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7453 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 7454 | combine_image=CombineImages(*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7455 | if (combine_image == (Image *) NULL) |
| 7456 | { |
| 7457 | status=MagickFalse; |
| 7458 | break; |
| 7459 | } |
| 7460 | *images=DestroyImageList(*images); |
| 7461 | *images=combine_image; |
| 7462 | break; |
| 7463 | } |
| 7464 | if (LocaleCompare("composite",option+1) == 0) |
| 7465 | { |
| 7466 | Image |
| 7467 | *mask_image, |
| 7468 | *composite_image, |
| 7469 | *image; |
| 7470 | |
| 7471 | RectangleInfo |
| 7472 | geometry; |
| 7473 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7474 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7475 | image=RemoveFirstImageFromList(images); |
| 7476 | composite_image=RemoveFirstImageFromList(images); |
| 7477 | if (composite_image == (Image *) NULL) |
| 7478 | { |
| 7479 | status=MagickFalse; |
| 7480 | break; |
| 7481 | } |
| 7482 | (void) TransformImage(&composite_image,(char *) NULL, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 7483 | composite_image->geometry,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7484 | SetGeometry(composite_image,&geometry); |
| 7485 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7486 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7487 | &geometry); |
| 7488 | mask_image=RemoveFirstImageFromList(images); |
| 7489 | if (mask_image != (Image *) NULL) |
| 7490 | { |
| 7491 | if ((image->compose == DisplaceCompositeOp) || |
| 7492 | (image->compose == DistortCompositeOp)) |
| 7493 | { |
| 7494 | /* |
| 7495 | Merge Y displacement into X displacement image. |
| 7496 | */ |
| 7497 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 7498 | mask_image,0,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7499 | mask_image=DestroyImage(mask_image); |
| 7500 | } |
| 7501 | else |
| 7502 | { |
| 7503 | /* |
| 7504 | Set a blending mask for the composition. |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7505 | Posible error, what if image->mask already set. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7506 | */ |
| 7507 | image->mask=mask_image; |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 7508 | (void) NegateImage(image->mask,MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7509 | } |
| 7510 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7511 | (void) CompositeImage(image,image->compose,composite_image, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 7512 | geometry.x,geometry.y,exception); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7513 | if (mask_image != (Image *) NULL) |
| 7514 | mask_image=image->mask=DestroyImage(image->mask); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7515 | composite_image=DestroyImage(composite_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7516 | *images=DestroyImageList(*images); |
| 7517 | *images=image; |
| 7518 | break; |
| 7519 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7520 | break; |
| 7521 | } |
| 7522 | case 'd': |
| 7523 | { |
| 7524 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7525 | { |
| 7526 | Image |
| 7527 | *deconstruct_image; |
| 7528 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7529 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7530 | deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer, |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 7531 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7532 | if (deconstruct_image == (Image *) NULL) |
| 7533 | { |
| 7534 | status=MagickFalse; |
| 7535 | break; |
| 7536 | } |
| 7537 | *images=DestroyImageList(*images); |
| 7538 | *images=deconstruct_image; |
| 7539 | break; |
| 7540 | } |
| 7541 | if (LocaleCompare("delete",option+1) == 0) |
| 7542 | { |
| 7543 | if (*option == '+') |
| 7544 | DeleteImages(images,"-1",exception); |
| 7545 | else |
| 7546 | DeleteImages(images,argv[i+1],exception); |
| 7547 | break; |
| 7548 | } |
| 7549 | if (LocaleCompare("dither",option+1) == 0) |
| 7550 | { |
| 7551 | if (*option == '+') |
| 7552 | { |
| 7553 | quantize_info->dither=MagickFalse; |
| 7554 | break; |
| 7555 | } |
| 7556 | quantize_info->dither=MagickTrue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7557 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7558 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7559 | break; |
| 7560 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7561 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7562 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7563 | Image |
| 7564 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7565 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7566 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7567 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7568 | else |
| 7569 | { |
| 7570 | const char |
| 7571 | *p; |
| 7572 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7573 | size_t |
| 7574 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7575 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7576 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7577 | p=strchr(argv[i+1],','); |
| 7578 | if (p == (const char *) NULL) |
| 7579 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7580 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7581 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7582 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7583 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7584 | } |
| 7585 | AppendImageToList(images, duplicate_images); |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7586 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7587 | break; |
| 7588 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7589 | break; |
| 7590 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7591 | case 'e': |
| 7592 | { |
| 7593 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7594 | { |
| 7595 | Image |
| 7596 | *evaluate_image; |
| 7597 | |
| 7598 | MagickEvaluateOperator |
| 7599 | op; |
| 7600 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7601 | (void) SyncImageSettings(mogrify_info,*images,exception); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7602 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 7603 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7604 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7605 | if (evaluate_image == (Image *) NULL) |
| 7606 | { |
| 7607 | status=MagickFalse; |
| 7608 | break; |
| 7609 | } |
| 7610 | *images=DestroyImageList(*images); |
| 7611 | *images=evaluate_image; |
| 7612 | break; |
| 7613 | } |
| 7614 | break; |
| 7615 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7616 | case 'f': |
| 7617 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7618 | if (LocaleCompare("fft",option+1) == 0) |
| 7619 | { |
| 7620 | Image |
| 7621 | *fourier_image; |
| 7622 | |
| 7623 | /* |
| 7624 | Implements the discrete Fourier transform (DFT). |
| 7625 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7626 | (void) SyncImageSettings(mogrify_info,*images,exception); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7627 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7628 | MagickTrue : MagickFalse,exception); |
| 7629 | if (fourier_image == (Image *) NULL) |
| 7630 | break; |
| 7631 | *images=DestroyImage(*images); |
| 7632 | *images=fourier_image; |
| 7633 | break; |
| 7634 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7635 | if (LocaleCompare("flatten",option+1) == 0) |
| 7636 | { |
| 7637 | Image |
| 7638 | *flatten_image; |
| 7639 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7640 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7641 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7642 | if (flatten_image == (Image *) NULL) |
| 7643 | break; |
| 7644 | *images=DestroyImageList(*images); |
| 7645 | *images=flatten_image; |
| 7646 | break; |
| 7647 | } |
| 7648 | if (LocaleCompare("fx",option+1) == 0) |
| 7649 | { |
| 7650 | Image |
| 7651 | *fx_image; |
| 7652 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7653 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 7654 | fx_image=FxImage(*images,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7655 | if (fx_image == (Image *) NULL) |
| 7656 | { |
| 7657 | status=MagickFalse; |
| 7658 | break; |
| 7659 | } |
| 7660 | *images=DestroyImageList(*images); |
| 7661 | *images=fx_image; |
| 7662 | break; |
| 7663 | } |
| 7664 | break; |
| 7665 | } |
| 7666 | case 'h': |
| 7667 | { |
| 7668 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7669 | { |
| 7670 | Image |
| 7671 | *hald_image, |
| 7672 | *image; |
| 7673 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7674 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7675 | image=RemoveFirstImageFromList(images); |
| 7676 | hald_image=RemoveFirstImageFromList(images); |
| 7677 | if (hald_image == (Image *) NULL) |
| 7678 | { |
| 7679 | status=MagickFalse; |
| 7680 | break; |
| 7681 | } |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 7682 | (void) HaldClutImage(image,hald_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7683 | hald_image=DestroyImage(hald_image); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7684 | if (*images != (Image *) NULL) |
| 7685 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7686 | *images=image; |
| 7687 | break; |
| 7688 | } |
| 7689 | break; |
| 7690 | } |
| 7691 | case 'i': |
| 7692 | { |
| 7693 | if (LocaleCompare("ift",option+1) == 0) |
| 7694 | { |
| 7695 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7696 | *fourier_image, |
| 7697 | *magnitude_image, |
| 7698 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7699 | |
| 7700 | /* |
| 7701 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7702 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7703 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7704 | magnitude_image=RemoveFirstImageFromList(images); |
| 7705 | phase_image=RemoveFirstImageFromList(images); |
| 7706 | if (phase_image == (Image *) NULL) |
| 7707 | { |
| 7708 | status=MagickFalse; |
| 7709 | break; |
| 7710 | } |
| 7711 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7712 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7713 | if (fourier_image == (Image *) NULL) |
| 7714 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7715 | if (*images != (Image *) NULL) |
| 7716 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7717 | *images=fourier_image; |
| 7718 | break; |
| 7719 | } |
| 7720 | if (LocaleCompare("insert",option+1) == 0) |
| 7721 | { |
| 7722 | Image |
| 7723 | *p, |
| 7724 | *q; |
| 7725 | |
| 7726 | index=0; |
| 7727 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7728 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7729 | p=RemoveLastImageFromList(images); |
| 7730 | if (p == (Image *) NULL) |
| 7731 | { |
| 7732 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7733 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7734 | status=MagickFalse; |
| 7735 | break; |
| 7736 | } |
| 7737 | q=p; |
| 7738 | if (index == 0) |
| 7739 | PrependImageToList(images,q); |
| 7740 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7741 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7742 | AppendImageToList(images,q); |
| 7743 | else |
| 7744 | { |
| 7745 | q=GetImageFromList(*images,index-1); |
| 7746 | if (q == (Image *) NULL) |
| 7747 | { |
| 7748 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7749 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7750 | status=MagickFalse; |
| 7751 | break; |
| 7752 | } |
| 7753 | InsertImageInList(&q,p); |
| 7754 | } |
| 7755 | *images=GetFirstImageInList(q); |
| 7756 | break; |
| 7757 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7758 | if (LocaleCompare("interpolate",option+1) == 0) |
| 7759 | { |
| 7760 | interpolate_method=(PixelInterpolateMethod) ParseCommandOption( |
| 7761 | MagickInterpolateOptions,MagickFalse,argv[i+1]); |
| 7762 | break; |
| 7763 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7764 | break; |
| 7765 | } |
| 7766 | case 'l': |
| 7767 | { |
| 7768 | if (LocaleCompare("layers",option+1) == 0) |
| 7769 | { |
| 7770 | Image |
| 7771 | *layers; |
| 7772 | |
| 7773 | ImageLayerMethod |
| 7774 | method; |
| 7775 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7776 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7777 | layers=(Image *) NULL; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7778 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7779 | MagickFalse,argv[i+1]); |
| 7780 | switch (method) |
| 7781 | { |
| 7782 | case CoalesceLayer: |
| 7783 | { |
| 7784 | layers=CoalesceImages(*images,exception); |
| 7785 | break; |
| 7786 | } |
| 7787 | case CompareAnyLayer: |
| 7788 | case CompareClearLayer: |
| 7789 | case CompareOverlayLayer: |
| 7790 | default: |
| 7791 | { |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7792 | layers=CompareImagesLayers(*images,method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7793 | break; |
| 7794 | } |
| 7795 | case MergeLayer: |
| 7796 | case FlattenLayer: |
| 7797 | case MosaicLayer: |
| 7798 | case TrimBoundsLayer: |
| 7799 | { |
| 7800 | layers=MergeImageLayers(*images,method,exception); |
| 7801 | break; |
| 7802 | } |
| 7803 | case DisposeLayer: |
| 7804 | { |
| 7805 | layers=DisposeImages(*images,exception); |
| 7806 | break; |
| 7807 | } |
| 7808 | case OptimizeImageLayer: |
| 7809 | { |
| 7810 | layers=OptimizeImageLayers(*images,exception); |
| 7811 | break; |
| 7812 | } |
| 7813 | case OptimizePlusLayer: |
| 7814 | { |
| 7815 | layers=OptimizePlusImageLayers(*images,exception); |
| 7816 | break; |
| 7817 | } |
| 7818 | case OptimizeTransLayer: |
| 7819 | { |
| 7820 | OptimizeImageTransparency(*images,exception); |
| 7821 | break; |
| 7822 | } |
| 7823 | case RemoveDupsLayer: |
| 7824 | { |
| 7825 | RemoveDuplicateLayers(images,exception); |
| 7826 | break; |
| 7827 | } |
| 7828 | case RemoveZeroLayer: |
| 7829 | { |
| 7830 | RemoveZeroDelayLayers(images,exception); |
| 7831 | break; |
| 7832 | } |
| 7833 | case OptimizeLayer: |
| 7834 | { |
| 7835 | /* |
| 7836 | General Purpose, GIF Animation Optimizer. |
| 7837 | */ |
| 7838 | layers=CoalesceImages(*images,exception); |
| 7839 | if (layers == (Image *) NULL) |
| 7840 | { |
| 7841 | status=MagickFalse; |
| 7842 | break; |
| 7843 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7844 | *images=DestroyImageList(*images); |
| 7845 | *images=layers; |
| 7846 | layers=OptimizeImageLayers(*images,exception); |
| 7847 | if (layers == (Image *) NULL) |
| 7848 | { |
| 7849 | status=MagickFalse; |
| 7850 | break; |
| 7851 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7852 | *images=DestroyImageList(*images); |
| 7853 | *images=layers; |
| 7854 | layers=(Image *) NULL; |
| 7855 | OptimizeImageTransparency(*images,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7856 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7857 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7858 | break; |
| 7859 | } |
| 7860 | case CompositeLayer: |
| 7861 | { |
| 7862 | CompositeOperator |
| 7863 | compose; |
| 7864 | |
| 7865 | Image |
| 7866 | *source; |
| 7867 | |
| 7868 | RectangleInfo |
| 7869 | geometry; |
| 7870 | |
| 7871 | /* |
| 7872 | Split image sequence at the first 'NULL:' image. |
| 7873 | */ |
| 7874 | source=(*images); |
| 7875 | while (source != (Image *) NULL) |
| 7876 | { |
| 7877 | source=GetNextImageInList(source); |
| 7878 | if ((source != (Image *) NULL) && |
| 7879 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7880 | break; |
| 7881 | } |
| 7882 | if (source != (Image *) NULL) |
| 7883 | { |
| 7884 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7885 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7886 | source=(Image *) NULL; |
| 7887 | else |
| 7888 | { |
| 7889 | /* |
| 7890 | Separate the two lists, junk the null: image. |
| 7891 | */ |
| 7892 | source=SplitImageList(source->previous); |
| 7893 | DeleteImageFromList(&source); |
| 7894 | } |
| 7895 | } |
| 7896 | if (source == (Image *) NULL) |
| 7897 | { |
| 7898 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7899 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7900 | status=MagickFalse; |
| 7901 | break; |
| 7902 | } |
| 7903 | /* |
| 7904 | Adjust offset with gravity and virtual canvas. |
| 7905 | */ |
| 7906 | SetGeometry(*images,&geometry); |
| 7907 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7908 | geometry.width=source->page.width != 0 ? |
| 7909 | source->page.width : source->columns; |
| 7910 | geometry.height=source->page.height != 0 ? |
| 7911 | source->page.height : source->rows; |
| 7912 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7913 | (*images)->page.width : (*images)->columns, |
| 7914 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7915 | (*images)->rows,(*images)->gravity,&geometry); |
| 7916 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7917 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7918 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7919 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7920 | MagickComposeOptions,MagickFalse,option); |
| 7921 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7922 | exception); |
| 7923 | source=DestroyImageList(source); |
| 7924 | break; |
| 7925 | } |
| 7926 | } |
| 7927 | if (layers == (Image *) NULL) |
| 7928 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7929 | *images=DestroyImageList(*images); |
| 7930 | *images=layers; |
| 7931 | break; |
| 7932 | } |
| 7933 | break; |
| 7934 | } |
| 7935 | case 'm': |
| 7936 | { |
| 7937 | if (LocaleCompare("map",option+1) == 0) |
| 7938 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7939 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7940 | if (*option == '+') |
| 7941 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7942 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7943 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7944 | break; |
| 7945 | } |
| 7946 | i++; |
| 7947 | break; |
| 7948 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7949 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7950 | { |
| 7951 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7952 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7953 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7954 | /* |
| 7955 | Maximum image sequence (deprecated). |
| 7956 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7957 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7958 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7959 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7960 | { |
| 7961 | status=MagickFalse; |
| 7962 | break; |
| 7963 | } |
| 7964 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7965 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7966 | break; |
| 7967 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7968 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7969 | { |
| 7970 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7971 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7972 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7973 | /* |
| 7974 | Minimum image sequence (deprecated). |
| 7975 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7976 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7977 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7978 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7979 | { |
| 7980 | status=MagickFalse; |
| 7981 | break; |
| 7982 | } |
| 7983 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7984 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7985 | break; |
| 7986 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7987 | if (LocaleCompare("morph",option+1) == 0) |
| 7988 | { |
| 7989 | Image |
| 7990 | *morph_image; |
| 7991 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7992 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7993 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7994 | exception); |
| 7995 | if (morph_image == (Image *) NULL) |
| 7996 | { |
| 7997 | status=MagickFalse; |
| 7998 | break; |
| 7999 | } |
| 8000 | *images=DestroyImageList(*images); |
| 8001 | *images=morph_image; |
| 8002 | break; |
| 8003 | } |
| 8004 | if (LocaleCompare("mosaic",option+1) == 0) |
| 8005 | { |
| 8006 | Image |
| 8007 | *mosaic_image; |
| 8008 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8009 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8010 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 8011 | if (mosaic_image == (Image *) NULL) |
| 8012 | { |
| 8013 | status=MagickFalse; |
| 8014 | break; |
| 8015 | } |
| 8016 | *images=DestroyImageList(*images); |
| 8017 | *images=mosaic_image; |
| 8018 | break; |
| 8019 | } |
| 8020 | break; |
| 8021 | } |
| 8022 | case 'p': |
| 8023 | { |
| 8024 | if (LocaleCompare("print",option+1) == 0) |
| 8025 | { |
| 8026 | char |
| 8027 | *string; |
| 8028 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8029 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 8030 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1], |
| 8031 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8032 | if (string == (char *) NULL) |
| 8033 | break; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8034 | (void) FormatLocaleFile(stdout,"%s",string); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8035 | string=DestroyString(string); |
| 8036 | } |
| 8037 | if (LocaleCompare("process",option+1) == 0) |
| 8038 | { |
| 8039 | char |
| 8040 | **arguments; |
| 8041 | |
| 8042 | int |
| 8043 | j, |
| 8044 | number_arguments; |
| 8045 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8046 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8047 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 8048 | if (arguments == (char **) NULL) |
| 8049 | break; |
| 8050 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 8051 | { |
| 8052 | char |
| 8053 | breaker, |
| 8054 | quote, |
| 8055 | *token; |
| 8056 | |
| 8057 | const char |
| 8058 | *arguments; |
| 8059 | |
| 8060 | int |
| 8061 | next, |
| 8062 | status; |
| 8063 | |
| 8064 | size_t |
| 8065 | length; |
| 8066 | |
| 8067 | TokenInfo |
| 8068 | *token_info; |
| 8069 | |
| 8070 | /* |
| 8071 | Support old style syntax, filter="-option arg". |
| 8072 | */ |
| 8073 | length=strlen(argv[i+1]); |
| 8074 | token=(char *) NULL; |
cristy | 37e0b38 | 2011-06-07 13:31:21 +0000 | [diff] [blame] | 8075 | if (~length >= (MaxTextExtent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8076 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8077 | sizeof(*token)); |
| 8078 | if (token == (char *) NULL) |
| 8079 | break; |
| 8080 | next=0; |
| 8081 | arguments=argv[i+1]; |
| 8082 | token_info=AcquireTokenInfo(); |
| 8083 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8084 | "\"",'\0',&breaker,&next,"e); |
| 8085 | token_info=DestroyTokenInfo(token_info); |
| 8086 | if (status == 0) |
| 8087 | { |
| 8088 | const char |
| 8089 | *argv; |
| 8090 | |
| 8091 | argv=(&(arguments[next])); |
| 8092 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8093 | exception); |
| 8094 | } |
| 8095 | token=DestroyString(token); |
| 8096 | break; |
| 8097 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8098 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8099 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8100 | number_arguments-2,(const char **) arguments+2,exception); |
| 8101 | for (j=0; j < number_arguments; j++) |
| 8102 | arguments[j]=DestroyString(arguments[j]); |
| 8103 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8104 | break; |
| 8105 | } |
| 8106 | break; |
| 8107 | } |
| 8108 | case 'r': |
| 8109 | { |
| 8110 | if (LocaleCompare("reverse",option+1) == 0) |
| 8111 | { |
| 8112 | ReverseImageList(images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8113 | break; |
| 8114 | } |
| 8115 | break; |
| 8116 | } |
| 8117 | case 's': |
| 8118 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8119 | if (LocaleCompare("smush",option+1) == 0) |
| 8120 | { |
| 8121 | Image |
| 8122 | *smush_image; |
| 8123 | |
| 8124 | ssize_t |
| 8125 | offset; |
| 8126 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8127 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8128 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8129 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8130 | MagickFalse,offset,exception); |
| 8131 | if (smush_image == (Image *) NULL) |
| 8132 | { |
| 8133 | status=MagickFalse; |
| 8134 | break; |
| 8135 | } |
| 8136 | *images=DestroyImageList(*images); |
| 8137 | *images=smush_image; |
| 8138 | break; |
| 8139 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8140 | if (LocaleCompare("swap",option+1) == 0) |
| 8141 | { |
| 8142 | Image |
| 8143 | *p, |
| 8144 | *q, |
| 8145 | *swap; |
| 8146 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8147 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8148 | swap_index; |
| 8149 | |
| 8150 | index=(-1); |
| 8151 | swap_index=(-2); |
| 8152 | if (*option != '+') |
| 8153 | { |
| 8154 | GeometryInfo |
| 8155 | geometry_info; |
| 8156 | |
| 8157 | MagickStatusType |
| 8158 | flags; |
| 8159 | |
| 8160 | swap_index=(-1); |
| 8161 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8162 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8163 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8164 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8165 | } |
| 8166 | p=GetImageFromList(*images,index); |
| 8167 | q=GetImageFromList(*images,swap_index); |
| 8168 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8169 | { |
| 8170 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8171 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8172 | status=MagickFalse; |
| 8173 | break; |
| 8174 | } |
| 8175 | if (p == q) |
| 8176 | break; |
| 8177 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8178 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8179 | ReplaceImageInList(&q,swap); |
| 8180 | *images=GetFirstImageInList(q); |
| 8181 | break; |
| 8182 | } |
| 8183 | break; |
| 8184 | } |
| 8185 | case 'w': |
| 8186 | { |
| 8187 | if (LocaleCompare("write",option+1) == 0) |
| 8188 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8189 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8190 | key[MaxTextExtent]; |
| 8191 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8192 | Image |
| 8193 | *write_images; |
| 8194 | |
| 8195 | ImageInfo |
| 8196 | *write_info; |
| 8197 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8198 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8199 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8200 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8201 | write_images=(*images); |
| 8202 | if (*option == '+') |
| 8203 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8204 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8205 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8206 | write_info=DestroyImageInfo(write_info); |
| 8207 | if (*option == '+') |
| 8208 | write_images=DestroyImageList(write_images); |
| 8209 | break; |
| 8210 | } |
| 8211 | break; |
| 8212 | } |
| 8213 | default: |
| 8214 | break; |
| 8215 | } |
| 8216 | i+=count; |
| 8217 | } |
| 8218 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8219 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8220 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8221 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8222 | } |
| 8223 | |
| 8224 | /* |
| 8225 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8226 | % % |
| 8227 | % % |
| 8228 | % % |
| 8229 | + M o g r i f y I m a g e s % |
| 8230 | % % |
| 8231 | % % |
| 8232 | % % |
| 8233 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8234 | % |
| 8235 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8236 | % prescribed by command line options. |
| 8237 | % |
| 8238 | % The format of the MogrifyImage method is: |
| 8239 | % |
| 8240 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8241 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8242 | % Image **images,Exceptioninfo *exception) |
| 8243 | % |
| 8244 | % A description of each parameter follows: |
| 8245 | % |
| 8246 | % o image_info: the image info.. |
| 8247 | % |
| 8248 | % o post: If true, post process image list operators otherwise pre-process. |
| 8249 | % |
| 8250 | % o argc: Specifies a pointer to an integer describing the number of |
| 8251 | % elements in the argument vector. |
| 8252 | % |
| 8253 | % o argv: Specifies a pointer to a text array containing the command line |
| 8254 | % arguments. |
| 8255 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8256 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8257 | % |
| 8258 | % o exception: return any errors or warnings in this structure. |
| 8259 | % |
| 8260 | */ |
| 8261 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8262 | const MagickBooleanType post,const int argc,const char **argv, |
| 8263 | Image **images,ExceptionInfo *exception) |
| 8264 | { |
| 8265 | #define MogrifyImageTag "Mogrify/Image" |
| 8266 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8267 | MagickStatusType |
| 8268 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8269 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8270 | MagickBooleanType |
| 8271 | proceed; |
| 8272 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8273 | size_t |
| 8274 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8275 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8276 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8277 | i; |
| 8278 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8279 | assert(image_info != (ImageInfo *) NULL); |
| 8280 | assert(image_info->signature == MagickSignature); |
| 8281 | if (images == (Image **) NULL) |
| 8282 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8283 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8284 | assert((*images)->signature == MagickSignature); |
| 8285 | if ((*images)->debug != MagickFalse) |
| 8286 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8287 | (*images)->filename); |
| 8288 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8289 | return(MagickTrue); |
| 8290 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8291 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8292 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8293 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8294 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8295 | (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc, |
| 8296 | post?"post":"pre"); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8297 | #endif |
| 8298 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8299 | /* |
| 8300 | Pre-process multi-image sequence operators |
| 8301 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8302 | if (post == MagickFalse) |
| 8303 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8304 | /* |
| 8305 | For each image, process simple single image operators |
| 8306 | */ |
| 8307 | i=0; |
| 8308 | n=GetImageListLength(*images); |
cristy | 9f027d1 | 2011-09-21 01:17:17 +0000 | [diff] [blame] | 8309 | for ( ; ; ) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8310 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8311 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8312 | (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long) |
| 8313 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8314 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8315 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8316 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8317 | if (proceed == MagickFalse) |
| 8318 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8319 | if ( (*images)->next == (Image *) NULL ) |
| 8320 | break; |
| 8321 | *images=(*images)->next; |
| 8322 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8323 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8324 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8325 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8326 | (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long) |
| 8327 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8328 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8329 | |
| 8330 | /* |
| 8331 | Post-process, multi-image sequence operators |
| 8332 | */ |
| 8333 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8334 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8335 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8336 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8337 | } |