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 | */ |
| 111 | WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
| 112 | MagickCommand command,int argc,char **argv,char **metadata, |
| 113 | ExceptionInfo *exception) |
| 114 | { |
| 115 | char |
| 116 | *option; |
| 117 | |
| 118 | double |
| 119 | duration, |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 120 | serial; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 121 | |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 122 | MagickBooleanType |
| 123 | concurrent, |
| 124 | regard_warnings, |
| 125 | status; |
| 126 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 127 | register ssize_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 128 | i; |
| 129 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 130 | size_t |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 131 | iterations, |
| 132 | n, |
| 133 | number_threads; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 134 | |
cristy | d0a94fa | 2010-03-12 14:18:11 +0000 | [diff] [blame] | 135 | (void) setlocale(LC_ALL,""); |
| 136 | (void) setlocale(LC_NUMERIC,"C"); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 137 | concurrent=MagickFalse; |
| 138 | duration=(-1.0); |
| 139 | iterations=1; |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 140 | status=MagickFalse; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 141 | regard_warnings=MagickFalse; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 142 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 143 | { |
| 144 | option=argv[i]; |
| 145 | if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) |
| 146 | continue; |
| 147 | if (LocaleCompare("bench",option+1) == 0) |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 148 | iterations=StringToUnsignedLong(argv[++i]); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 149 | if (LocaleCompare("concurrent",option+1) == 0) |
| 150 | concurrent=MagickTrue; |
| 151 | if (LocaleCompare("debug",option+1) == 0) |
| 152 | (void) SetLogEventMask(argv[++i]); |
| 153 | if (LocaleCompare("duration",option+1) == 0) |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 154 | duration=StringToDouble(argv[++i],(char **) NULL); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 155 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 156 | regard_warnings=MagickTrue; |
| 157 | } |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 158 | if (iterations == 1) |
| 159 | { |
| 160 | status=command(image_info,argc,argv,metadata,exception); |
| 161 | if (exception->severity != UndefinedException) |
| 162 | { |
| 163 | if ((exception->severity > ErrorException) || |
| 164 | (regard_warnings != MagickFalse)) |
| 165 | status=MagickTrue; |
| 166 | CatchException(exception); |
| 167 | } |
| 168 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 169 | { |
| 170 | (void) fputs(*metadata,stdout); |
| 171 | (void) fputc('\n',stdout); |
| 172 | *metadata=DestroyString(*metadata); |
| 173 | } |
| 174 | return(status); |
| 175 | } |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 176 | number_threads=GetOpenMPMaximumThreads(); |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 177 | serial=0.0; |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 178 | for (n=1; n <= number_threads; n++) |
| 179 | { |
| 180 | double |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 181 | e, |
| 182 | parallel, |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 183 | user_time; |
| 184 | |
| 185 | TimerInfo |
| 186 | *timer; |
| 187 | |
| 188 | SetOpenMPMaximumThreads(n); |
| 189 | timer=AcquireTimerInfo(); |
| 190 | if (concurrent == MagickFalse) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 191 | { |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 192 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 193 | { |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 194 | if (status != MagickFalse) |
| 195 | continue; |
| 196 | if (duration > 0) |
| 197 | { |
| 198 | if (GetElapsedTime(timer) > duration) |
| 199 | continue; |
| 200 | (void) ContinueTimer(timer); |
| 201 | } |
| 202 | status=command(image_info,argc,argv,metadata,exception); |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 203 | if (exception->severity != UndefinedException) |
| 204 | { |
| 205 | if ((exception->severity > ErrorException) || |
| 206 | (regard_warnings != MagickFalse)) |
| 207 | status=MagickTrue; |
| 208 | CatchException(exception); |
| 209 | } |
| 210 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 211 | { |
| 212 | (void) fputs(*metadata,stdout); |
| 213 | (void) fputc('\n',stdout); |
| 214 | *metadata=DestroyString(*metadata); |
| 215 | } |
| 216 | } |
| 217 | } |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 218 | else |
| 219 | { |
| 220 | SetOpenMPNested(1); |
| 221 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
| 222 | # pragma omp parallel for shared(status) |
| 223 | #endif |
| 224 | for (i=0; i < (ssize_t) iterations; i++) |
| 225 | { |
| 226 | if (status != MagickFalse) |
| 227 | continue; |
| 228 | if (duration > 0) |
| 229 | { |
| 230 | if (GetElapsedTime(timer) > duration) |
| 231 | continue; |
| 232 | (void) ContinueTimer(timer); |
| 233 | } |
| 234 | status=command(image_info,argc,argv,metadata,exception); |
| 235 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
| 236 | # pragma omp critical (MagickCore_CommandGenesis) |
| 237 | #endif |
| 238 | { |
| 239 | if (exception->severity != UndefinedException) |
| 240 | { |
| 241 | if ((exception->severity > ErrorException) || |
| 242 | (regard_warnings != MagickFalse)) |
| 243 | status=MagickTrue; |
| 244 | CatchException(exception); |
| 245 | } |
| 246 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 247 | { |
| 248 | (void) fputs(*metadata,stdout); |
| 249 | (void) fputc('\n',stdout); |
| 250 | *metadata=DestroyString(*metadata); |
| 251 | } |
| 252 | } |
| 253 | } |
| 254 | } |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 255 | user_time=GetUserTime(timer); |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 256 | parallel=GetElapsedTime(timer); |
| 257 | e=1.0; |
| 258 | if (n == 1) |
| 259 | serial=parallel; |
| 260 | else |
| 261 | e=((1.0/(1.0/((serial/(serial+parallel))+(1.0-(serial/(serial+parallel)))/ |
| 262 | (double) n)))-(1.0/(double) n))/(1.0-1.0/(double) n); |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 263 | (void) FormatLocaleFile(stderr, |
cristy | 91ce84d | 2011-12-09 23:02:25 +0000 | [diff] [blame] | 264 | "Performance[%.20g]: %.20gi %0.3fips %0.3fe %0.3fu %lu:%02lu.%03lu\n", |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 265 | (double) n,(double) iterations,(double) iterations/parallel,e, |
| 266 | user_time,(unsigned long) (parallel/60.0),(unsigned long) |
| 267 | floor(fmod(parallel,60.0)),(unsigned long) |
| 268 | (1000.0*(parallel-floor(parallel))+0.5)); |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 269 | timer=DestroyTimerInfo(timer); |
| 270 | } |
cristy | 1f9e1ed | 2009-11-18 04:09:38 +0000 | [diff] [blame] | 271 | return(status); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | /* |
| 275 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 276 | % % |
| 277 | % % |
| 278 | % % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 279 | + M o g r i f y I m a g e % |
| 280 | % % |
| 281 | % % |
| 282 | % % |
| 283 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 284 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 285 | % MogrifyImage() applies simple single image processing options to a single |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 286 | % image that may be part of a large list, but also handles any 'region' |
| 287 | % image handling. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 288 | % |
| 289 | % The image in the list may be modified in three different ways... |
| 290 | % |
| 291 | % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 292 | % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 293 | % * replace by a list of images (only the -separate option!) |
| 294 | % |
| 295 | % In each case the result is returned into the list, and a pointer to the |
| 296 | % modified image (last image added if replaced by a list of images) is |
| 297 | % returned. |
| 298 | % |
| 299 | % ASIDE: The -crop is present but restricted to non-tile single image crops |
| 300 | % |
| 301 | % This means if all the images are being processed (such as by |
| 302 | % MogrifyImages(), next image to be processed will be as per the pointer |
| 303 | % (*image)->next. Also the image list may grow as a result of some specific |
| 304 | % operations but as images are never merged or deleted, it will never shrink |
| 305 | % in length. Typically the list will remain the same length. |
| 306 | % |
| 307 | % WARNING: As the image pointed to may be replaced, the first image in the |
| 308 | % list may also change. GetFirstImageInList() should be used by caller if |
| 309 | % they wish return the Image pointer to the first image in list. |
| 310 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 311 | % |
| 312 | % The format of the MogrifyImage method is: |
| 313 | % |
| 314 | % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 315 | % const char **argv,Image **image) |
| 316 | % |
| 317 | % A description of each parameter follows: |
| 318 | % |
| 319 | % o image_info: the image info.. |
| 320 | % |
| 321 | % o argc: Specifies a pointer to an integer describing the number of |
| 322 | % elements in the argument vector. |
| 323 | % |
| 324 | % o argv: Specifies a pointer to a text array containing the command line |
| 325 | % arguments. |
| 326 | % |
| 327 | % o image: the image. |
| 328 | % |
| 329 | % o exception: return any errors or warnings in this structure. |
| 330 | % |
| 331 | */ |
| 332 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 333 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 334 | ExceptionInfo *exception) |
| 335 | { |
| 336 | char |
| 337 | key[MaxTextExtent]; |
| 338 | |
| 339 | ExceptionInfo |
| 340 | *sans_exception; |
| 341 | |
| 342 | Image |
| 343 | *image; |
| 344 | |
| 345 | ImageInfo |
| 346 | *read_info; |
| 347 | |
cristy | fcd785b | 2011-11-08 01:48:33 +0000 | [diff] [blame] | 348 | /* |
| 349 | Read an image into a image cache if not already present. Return the image |
| 350 | that is in the cache under that filename. |
| 351 | */ |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 352 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 353 | sans_exception=AcquireExceptionInfo(); |
| 354 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 355 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 356 | if (image != (Image *) NULL) |
| 357 | return(image); |
| 358 | read_info=CloneImageInfo(image_info); |
| 359 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 360 | image=ReadImage(read_info,exception); |
| 361 | read_info=DestroyImageInfo(read_info); |
| 362 | if (image != (Image *) NULL) |
| 363 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 364 | return(image); |
| 365 | } |
| 366 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 367 | static MagickBooleanType IsPathWritable(const char *path) |
| 368 | { |
| 369 | if (IsPathAccessible(path) == MagickFalse) |
| 370 | return(MagickFalse); |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 371 | if (access_utf8(path,W_OK) != 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 372 | return(MagickFalse); |
| 373 | return(MagickTrue); |
| 374 | } |
| 375 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 376 | static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 377 | { |
| 378 | if (x > y) |
| 379 | return(x); |
| 380 | return(y); |
| 381 | } |
| 382 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 383 | static MagickBooleanType MonitorProgress(const char *text, |
| 384 | const MagickOffsetType offset,const MagickSizeType extent, |
| 385 | void *wand_unused(client_data)) |
| 386 | { |
| 387 | char |
| 388 | message[MaxTextExtent], |
| 389 | tag[MaxTextExtent]; |
| 390 | |
| 391 | const char |
| 392 | *locale_message; |
| 393 | |
| 394 | register char |
| 395 | *p; |
| 396 | |
| 397 | if (extent < 2) |
| 398 | return(MagickTrue); |
| 399 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 400 | p=strrchr(tag,'/'); |
| 401 | if (p != (char *) NULL) |
| 402 | *p='\0'; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 403 | (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 404 | locale_message=GetLocaleMessage(message); |
| 405 | if (locale_message == message) |
| 406 | locale_message=tag; |
| 407 | if (p == (char *) NULL) |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 408 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", |
| 409 | locale_message,(long) offset,(unsigned long) extent,(long) |
| 410 | (100L*offset/(extent-1))); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 411 | else |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 412 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 413 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 414 | (100L*offset/(extent-1))); |
| 415 | if (offset == (MagickOffsetType) (extent-1)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 416 | (void) FormatLocaleFile(stderr,"\n"); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 417 | (void) fflush(stderr); |
| 418 | return(MagickTrue); |
| 419 | } |
| 420 | |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 421 | static Image *SparseColorOption(const Image *image, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 422 | const SparseColorMethod method,const char *arguments, |
| 423 | const MagickBooleanType color_from_image,ExceptionInfo *exception) |
| 424 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 425 | char |
| 426 | token[MaxTextExtent]; |
| 427 | |
| 428 | const char |
| 429 | *p; |
| 430 | |
| 431 | double |
| 432 | *sparse_arguments; |
| 433 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 434 | Image |
| 435 | *sparse_image; |
| 436 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 437 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 438 | color; |
| 439 | |
| 440 | MagickBooleanType |
| 441 | error; |
| 442 | |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 443 | register size_t |
| 444 | x; |
| 445 | |
| 446 | size_t |
| 447 | number_arguments, |
| 448 | number_colors; |
| 449 | |
cristy | f4425a7 | 2011-11-08 01:52:04 +0000 | [diff] [blame] | 450 | /* |
| 451 | SparseColorOption() parses the complex -sparse-color argument into an an |
| 452 | array of floating point values then calls SparseColorImage(). Argument is |
| 453 | a complex mix of floating-point pixel coodinates, and color specifications |
| 454 | (or direct floating point numbers). The number of floats needed to |
| 455 | represent a color varies depending on the current channel setting. |
| 456 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 457 | assert(image != (Image *) NULL); |
| 458 | assert(image->signature == MagickSignature); |
| 459 | if (image->debug != MagickFalse) |
| 460 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 461 | assert(exception != (ExceptionInfo *) NULL); |
| 462 | assert(exception->signature == MagickSignature); |
| 463 | /* |
| 464 | Limit channels according to image - and add up number of color channel. |
| 465 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 466 | number_colors=0; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 467 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 468 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 469 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 470 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 471 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 472 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 473 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 474 | (image->colorspace == CMYKColorspace)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 475 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 476 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 477 | (image->matte != MagickFalse)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 478 | number_colors++; |
| 479 | |
| 480 | /* |
| 481 | Read string, to determine number of arguments needed, |
| 482 | */ |
| 483 | p=arguments; |
| 484 | x=0; |
| 485 | while( *p != '\0' ) |
| 486 | { |
| 487 | GetMagickToken(p,&p,token); |
| 488 | if ( token[0] == ',' ) continue; |
| 489 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 490 | if ( color_from_image ) { |
| 491 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 492 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 493 | "Color arg given, when colors are coming from image"); |
| 494 | return( (Image *)NULL); |
| 495 | } |
| 496 | x += number_colors; /* color argument */ |
| 497 | } |
| 498 | else { |
| 499 | x++; /* floating point argument */ |
| 500 | } |
| 501 | } |
| 502 | error=MagickTrue; |
| 503 | if ( color_from_image ) { |
| 504 | /* just the control points are being given */ |
| 505 | error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; |
| 506 | number_arguments=(x/2)*(2+number_colors); |
| 507 | } |
| 508 | else { |
| 509 | /* control points and color values */ |
| 510 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; |
| 511 | number_arguments=x; |
| 512 | } |
| 513 | if ( error ) { |
| 514 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 515 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 516 | "Invalid number of Arguments"); |
| 517 | return( (Image *)NULL); |
| 518 | } |
| 519 | |
| 520 | /* Allocate and fill in the floating point arguments */ |
| 521 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 522 | sizeof(*sparse_arguments)); |
| 523 | if (sparse_arguments == (double *) NULL) { |
| 524 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 525 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 526 | return( (Image *)NULL); |
| 527 | } |
| 528 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 529 | sizeof(*sparse_arguments)); |
| 530 | p=arguments; |
| 531 | x=0; |
| 532 | while( *p != '\0' && x < number_arguments ) { |
| 533 | /* X coordinate */ |
| 534 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 535 | if ( token[0] == '\0' ) break; |
| 536 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 537 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 538 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 539 | "Color found, instead of X-coord"); |
| 540 | error = MagickTrue; |
| 541 | break; |
| 542 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 543 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 544 | /* Y coordinate */ |
| 545 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 546 | if ( token[0] == '\0' ) break; |
| 547 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 548 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 549 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 550 | "Color found, instead of Y-coord"); |
| 551 | error = MagickTrue; |
| 552 | break; |
| 553 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 554 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 555 | /* color values for this control point */ |
| 556 | #if 0 |
| 557 | if ( (color_from_image ) { |
| 558 | /* get color from image */ |
| 559 | /* HOW??? */ |
| 560 | } |
| 561 | else |
| 562 | #endif |
| 563 | { |
| 564 | /* color name or function given in string argument */ |
| 565 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 566 | if ( token[0] == '\0' ) break; |
| 567 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 568 | /* Color string given */ |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 569 | (void) QueryColorCompliance(token,AllCompliance,&color,exception); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 570 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 571 | sparse_arguments[x++] = QuantumScale*color.red; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 572 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 573 | sparse_arguments[x++] = QuantumScale*color.green; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 574 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 575 | sparse_arguments[x++] = QuantumScale*color.blue; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 576 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 577 | (image->colorspace == CMYKColorspace)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 578 | sparse_arguments[x++] = QuantumScale*color.black; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 579 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 580 | (image->matte != MagickFalse)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 581 | sparse_arguments[x++] = QuantumScale*color.alpha; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 582 | } |
| 583 | else { |
| 584 | /* Colors given as a set of floating point values - experimental */ |
| 585 | /* NB: token contains the first floating point value to use! */ |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 586 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 587 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 588 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 589 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 590 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 591 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 592 | token[0] = ','; /* used this token - get another */ |
| 593 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 594 | if ((GetPixelGreenTraits(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 ((GetPixelBlueTraits(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 (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 611 | (image->colorspace == CMYKColorspace)) |
| 612 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 613 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 614 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 615 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 616 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 617 | token[0] = ','; /* used this token - get another */ |
| 618 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 619 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 620 | (image->matte != MagickFalse)) |
| 621 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 622 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 623 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 624 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 625 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 626 | token[0] = ','; /* used this token - get another */ |
| 627 | } |
| 628 | } |
| 629 | } |
| 630 | } |
| 631 | if ( number_arguments != x && !error ) { |
| 632 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
| 633 | "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error"); |
| 634 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 635 | return( (Image *)NULL); |
| 636 | } |
| 637 | if ( error ) |
| 638 | return( (Image *)NULL); |
| 639 | |
| 640 | /* Call the Interpolation function with the parsed arguments */ |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 641 | sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, |
| 642 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 643 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 644 | return( sparse_image ); |
| 645 | } |
| 646 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 647 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 648 | const char **argv,Image **image,ExceptionInfo *exception) |
| 649 | { |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 650 | CompositeOperator |
| 651 | compose; |
| 652 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 653 | const char |
| 654 | *format, |
| 655 | *option; |
| 656 | |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 657 | double |
| 658 | attenuate; |
| 659 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 660 | DrawInfo |
| 661 | *draw_info; |
| 662 | |
| 663 | GeometryInfo |
| 664 | geometry_info; |
| 665 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 666 | Image |
| 667 | *region_image; |
| 668 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 669 | ImageInfo |
| 670 | *mogrify_info; |
| 671 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 672 | MagickStatusType |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 673 | status; |
| 674 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 675 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 676 | fill; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 677 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 678 | MagickStatusType |
| 679 | flags; |
| 680 | |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 681 | PixelInterpolateMethod |
| 682 | interpolate_method; |
| 683 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 684 | QuantizeInfo |
| 685 | *quantize_info; |
| 686 | |
| 687 | RectangleInfo |
| 688 | geometry, |
| 689 | region_geometry; |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame] | 690 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 691 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 692 | i; |
| 693 | |
| 694 | /* |
| 695 | Initialize method variables. |
| 696 | */ |
| 697 | assert(image_info != (const ImageInfo *) NULL); |
| 698 | assert(image_info->signature == MagickSignature); |
| 699 | assert(image != (Image **) NULL); |
| 700 | assert((*image)->signature == MagickSignature); |
| 701 | if ((*image)->debug != MagickFalse) |
| 702 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); |
| 703 | if (argc < 0) |
| 704 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 705 | mogrify_info=CloneImageInfo(image_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 706 | draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL); |
| 707 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 708 | SetGeometryInfo(&geometry_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 709 | GetPixelInfo(*image,&fill); |
cristy | 9d8c8ce | 2011-10-25 16:13:52 +0000 | [diff] [blame] | 710 | fill=(*image)->background_color; |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 711 | attenuate=1.0; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 712 | compose=(*image)->compose; |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 713 | interpolate_method=UndefinedInterpolatePixel; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 714 | format=GetImageOption(mogrify_info,"format"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 715 | SetGeometry(*image,®ion_geometry); |
| 716 | region_image=NewImageList(); |
| 717 | /* |
| 718 | Transmogrify the image. |
| 719 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 720 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 721 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 722 | Image |
| 723 | *mogrify_image; |
| 724 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 725 | ssize_t |
| 726 | count; |
| 727 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 728 | option=argv[i]; |
| 729 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 730 | continue; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 731 | count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option), |
| 732 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 733 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 734 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 735 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 736 | mogrify_image=(Image *)NULL; |
| 737 | switch (*(option+1)) |
| 738 | { |
| 739 | case 'a': |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 740 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 741 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 742 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 743 | /* |
| 744 | Adaptive blur image. |
| 745 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 746 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 747 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 748 | if ((flags & SigmaValue) == 0) |
| 749 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 750 | if ((flags & XiValue) == 0) |
| 751 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 752 | mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho, |
cristy | 4c11c2b | 2011-09-05 20:17:07 +0000 | [diff] [blame] | 753 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 754 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 755 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 756 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 757 | { |
| 758 | /* |
| 759 | Adaptive resize image. |
| 760 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 761 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 762 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 763 | mogrify_image=AdaptiveResizeImage(*image,geometry.width, |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 764 | geometry.height,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 765 | break; |
| 766 | } |
| 767 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 768 | { |
| 769 | /* |
| 770 | Adaptive sharpen image. |
| 771 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 772 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 773 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 774 | if ((flags & SigmaValue) == 0) |
| 775 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 776 | if ((flags & XiValue) == 0) |
| 777 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 778 | mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho, |
cristy | 4c11c2b | 2011-09-05 20:17:07 +0000 | [diff] [blame] | 779 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 780 | break; |
| 781 | } |
| 782 | if (LocaleCompare("affine",option+1) == 0) |
| 783 | { |
| 784 | /* |
| 785 | Affine matrix. |
| 786 | */ |
| 787 | if (*option == '+') |
| 788 | { |
| 789 | GetAffineMatrix(&draw_info->affine); |
| 790 | break; |
| 791 | } |
| 792 | (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); |
| 793 | break; |
| 794 | } |
| 795 | if (LocaleCompare("alpha",option+1) == 0) |
| 796 | { |
| 797 | AlphaChannelType |
| 798 | alpha_type; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 799 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 800 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 801 | alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions, |
| 802 | MagickFalse,argv[i+1]); |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 803 | (void) SetImageAlphaChannel(*image,alpha_type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 804 | break; |
| 805 | } |
| 806 | if (LocaleCompare("annotate",option+1) == 0) |
| 807 | { |
| 808 | char |
| 809 | *text, |
| 810 | geometry[MaxTextExtent]; |
| 811 | |
| 812 | /* |
| 813 | Annotate image. |
| 814 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 815 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 816 | SetGeometryInfo(&geometry_info); |
| 817 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 818 | if ((flags & SigmaValue) == 0) |
| 819 | geometry_info.sigma=geometry_info.rho; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 820 | text=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 821 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 822 | if (text == (char *) NULL) |
| 823 | break; |
| 824 | (void) CloneString(&draw_info->text,text); |
| 825 | text=DestroyString(text); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 826 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 827 | geometry_info.xi,geometry_info.psi); |
| 828 | (void) CloneString(&draw_info->geometry,geometry); |
| 829 | draw_info->affine.sx=cos(DegreesToRadians( |
| 830 | fmod(geometry_info.rho,360.0))); |
| 831 | draw_info->affine.rx=sin(DegreesToRadians( |
| 832 | fmod(geometry_info.rho,360.0))); |
| 833 | draw_info->affine.ry=(-sin(DegreesToRadians( |
| 834 | fmod(geometry_info.sigma,360.0)))); |
| 835 | draw_info->affine.sy=cos(DegreesToRadians( |
| 836 | fmod(geometry_info.sigma,360.0))); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 837 | (void) AnnotateImage(*image,draw_info,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 838 | break; |
| 839 | } |
| 840 | if (LocaleCompare("antialias",option+1) == 0) |
| 841 | { |
| 842 | draw_info->stroke_antialias=(*option == '-') ? MagickTrue : |
| 843 | MagickFalse; |
| 844 | draw_info->text_antialias=(*option == '-') ? MagickTrue : |
| 845 | MagickFalse; |
| 846 | break; |
| 847 | } |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 848 | if (LocaleCompare("attenuate",option+1) == 0) |
| 849 | { |
| 850 | if (*option == '+') |
| 851 | { |
| 852 | attenuate=1.0; |
| 853 | break; |
| 854 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 855 | attenuate=StringToDouble(argv[i+1],(char **) NULL); |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 856 | break; |
| 857 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 858 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 859 | { |
| 860 | /* |
| 861 | Auto Adjust Gamma of image based on its mean |
| 862 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 863 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9511120 | 2011-08-09 19:41:42 +0000 | [diff] [blame] | 864 | (void) AutoGammaImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 865 | break; |
| 866 | } |
| 867 | if (LocaleCompare("auto-level",option+1) == 0) |
| 868 | { |
| 869 | /* |
| 870 | Perfectly Normalize (max/min stretch) the image |
| 871 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 872 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9511120 | 2011-08-09 19:41:42 +0000 | [diff] [blame] | 873 | (void) AutoLevelImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 874 | break; |
| 875 | } |
| 876 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 877 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 878 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 879 | switch ((*image)->orientation) |
| 880 | { |
| 881 | case TopRightOrientation: |
| 882 | { |
| 883 | mogrify_image=FlopImage(*image,exception); |
| 884 | break; |
| 885 | } |
| 886 | case BottomRightOrientation: |
| 887 | { |
| 888 | mogrify_image=RotateImage(*image,180.0,exception); |
| 889 | break; |
| 890 | } |
| 891 | case BottomLeftOrientation: |
| 892 | { |
| 893 | mogrify_image=FlipImage(*image,exception); |
| 894 | break; |
| 895 | } |
| 896 | case LeftTopOrientation: |
| 897 | { |
| 898 | mogrify_image=TransposeImage(*image,exception); |
| 899 | break; |
| 900 | } |
| 901 | case RightTopOrientation: |
| 902 | { |
| 903 | mogrify_image=RotateImage(*image,90.0,exception); |
| 904 | break; |
| 905 | } |
| 906 | case RightBottomOrientation: |
| 907 | { |
| 908 | mogrify_image=TransverseImage(*image,exception); |
| 909 | break; |
| 910 | } |
| 911 | case LeftBottomOrientation: |
| 912 | { |
| 913 | mogrify_image=RotateImage(*image,270.0,exception); |
| 914 | break; |
| 915 | } |
| 916 | default: |
| 917 | break; |
| 918 | } |
| 919 | if (mogrify_image != (Image *) NULL) |
| 920 | mogrify_image->orientation=TopLeftOrientation; |
| 921 | break; |
| 922 | } |
| 923 | break; |
| 924 | } |
| 925 | case 'b': |
| 926 | { |
| 927 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 928 | { |
| 929 | /* |
| 930 | Black threshold image. |
| 931 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 932 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 933 | (void) BlackThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 934 | break; |
| 935 | } |
| 936 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 937 | { |
| 938 | /* |
| 939 | Blue shift image. |
| 940 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 941 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 942 | geometry_info.rho=1.5; |
| 943 | if (*option == '-') |
| 944 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 945 | mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception); |
| 946 | break; |
| 947 | } |
| 948 | if (LocaleCompare("blur",option+1) == 0) |
| 949 | { |
| 950 | /* |
| 951 | Gaussian blur 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 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 955 | if ((flags & SigmaValue) == 0) |
| 956 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 957 | if ((flags & XiValue) == 0) |
| 958 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 959 | mogrify_image=BlurImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 960 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 961 | break; |
| 962 | } |
| 963 | if (LocaleCompare("border",option+1) == 0) |
| 964 | { |
| 965 | /* |
| 966 | Surround image with a border of solid color. |
| 967 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 968 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 969 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 970 | if ((flags & SigmaValue) == 0) |
| 971 | geometry.height=geometry.width; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 972 | mogrify_image=BorderImage(*image,&geometry,compose,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 973 | break; |
| 974 | } |
| 975 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 976 | { |
| 977 | if (*option == '+') |
| 978 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 979 | (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 980 | &draw_info->border_color,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 981 | break; |
| 982 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 983 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 984 | &draw_info->border_color,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 985 | break; |
| 986 | } |
| 987 | if (LocaleCompare("box",option+1) == 0) |
| 988 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 989 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 990 | &draw_info->undercolor,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 991 | break; |
| 992 | } |
| 993 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 994 | { |
| 995 | double |
| 996 | brightness, |
| 997 | contrast; |
| 998 | |
| 999 | GeometryInfo |
| 1000 | geometry_info; |
| 1001 | |
| 1002 | MagickStatusType |
| 1003 | flags; |
| 1004 | |
| 1005 | /* |
| 1006 | Brightness / contrast image. |
| 1007 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1008 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1009 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1010 | brightness=geometry_info.rho; |
| 1011 | contrast=0.0; |
| 1012 | if ((flags & SigmaValue) != 0) |
| 1013 | contrast=geometry_info.sigma; |
cristy | 444eda6 | 2011-08-10 02:07:46 +0000 | [diff] [blame] | 1014 | (void) BrightnessContrastImage(*image,brightness,contrast, |
| 1015 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1016 | break; |
| 1017 | } |
| 1018 | break; |
| 1019 | } |
| 1020 | case 'c': |
| 1021 | { |
| 1022 | if (LocaleCompare("cdl",option+1) == 0) |
| 1023 | { |
| 1024 | char |
| 1025 | *color_correction_collection; |
| 1026 | |
| 1027 | /* |
| 1028 | Color correct with a color decision list. |
| 1029 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1030 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1031 | color_correction_collection=FileToString(argv[i+1],~0,exception); |
| 1032 | if (color_correction_collection == (char *) NULL) |
| 1033 | break; |
cristy | 1bfa9f0 | 2011-08-11 02:35:43 +0000 | [diff] [blame] | 1034 | (void) ColorDecisionListImage(*image,color_correction_collection, |
| 1035 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1036 | break; |
| 1037 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1038 | if (LocaleCompare("charcoal",option+1) == 0) |
| 1039 | { |
| 1040 | /* |
| 1041 | Charcoal image. |
| 1042 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1043 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1044 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1045 | if ((flags & SigmaValue) == 0) |
| 1046 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1047 | if ((flags & XiValue) == 0) |
| 1048 | geometry_info.xi=1.0; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1049 | mogrify_image=CharcoalImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1050 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1051 | break; |
| 1052 | } |
| 1053 | if (LocaleCompare("chop",option+1) == 0) |
| 1054 | { |
| 1055 | /* |
| 1056 | Chop the image. |
| 1057 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1058 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1059 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1060 | mogrify_image=ChopImage(*image,&geometry,exception); |
| 1061 | break; |
| 1062 | } |
| 1063 | if (LocaleCompare("clamp",option+1) == 0) |
| 1064 | { |
| 1065 | /* |
| 1066 | Clamp image. |
| 1067 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1068 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 092d71c | 2011-10-14 18:01:29 +0000 | [diff] [blame] | 1069 | (void) ClampImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1070 | break; |
| 1071 | } |
| 1072 | if (LocaleCompare("clip",option+1) == 0) |
| 1073 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1074 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1075 | if (*option == '+') |
| 1076 | { |
cristy | 10a6c61 | 2012-01-29 21:41:05 +0000 | [diff] [blame^] | 1077 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1078 | break; |
| 1079 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1080 | (void) ClipImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1081 | break; |
| 1082 | } |
| 1083 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1084 | { |
| 1085 | CacheView |
| 1086 | *mask_view; |
| 1087 | |
| 1088 | Image |
| 1089 | *mask_image; |
| 1090 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1091 | register Quantum |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1092 | *restrict q; |
| 1093 | |
| 1094 | register ssize_t |
| 1095 | x; |
| 1096 | |
| 1097 | ssize_t |
| 1098 | y; |
| 1099 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1100 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1101 | if (*option == '+') |
| 1102 | { |
| 1103 | /* |
| 1104 | Remove a mask. |
| 1105 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1106 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1107 | break; |
| 1108 | } |
| 1109 | /* |
| 1110 | Set the image mask. |
| 1111 | FUTURE: This Should Be a SetImageAlphaChannel() call, Or two. |
| 1112 | */ |
| 1113 | mask_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1114 | if (mask_image == (Image *) NULL) |
| 1115 | break; |
cristy | 574cc26 | 2011-08-05 01:23:58 +0000 | [diff] [blame] | 1116 | if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1117 | return(MagickFalse); |
| 1118 | mask_view=AcquireCacheView(mask_image); |
| 1119 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1120 | { |
| 1121 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1122 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 1123 | if (q == (Quantum *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1124 | break; |
| 1125 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1126 | { |
| 1127 | if (mask_image->matte == MagickFalse) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1128 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 1129 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1130 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1131 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1132 | q+=GetPixelChannels(mask_image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1133 | } |
| 1134 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
| 1135 | break; |
| 1136 | } |
| 1137 | mask_view=DestroyCacheView(mask_view); |
| 1138 | mask_image->matte=MagickTrue; |
cristy | 10a6c61 | 2012-01-29 21:41:05 +0000 | [diff] [blame^] | 1139 | (void) SetImageMask(*image,mask_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1140 | break; |
| 1141 | } |
| 1142 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1143 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1144 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1145 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1146 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1147 | break; |
| 1148 | } |
| 1149 | if (LocaleCompare("colorize",option+1) == 0) |
| 1150 | { |
| 1151 | /* |
| 1152 | Colorize the image. |
| 1153 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1154 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | c7e6ff6 | 2011-10-03 13:46:11 +0000 | [diff] [blame] | 1155 | mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1156 | break; |
| 1157 | } |
| 1158 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1159 | { |
| 1160 | KernelInfo |
| 1161 | *kernel; |
| 1162 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1163 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1164 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1165 | if (kernel == (KernelInfo *) NULL) |
| 1166 | break; |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1167 | /* FUTURE: check on size of the matrix */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1168 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 1169 | kernel=DestroyKernelInfo(kernel); |
| 1170 | break; |
| 1171 | } |
| 1172 | if (LocaleCompare("colors",option+1) == 0) |
| 1173 | { |
| 1174 | /* |
| 1175 | Reduce the number of colors in the image. |
| 1176 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1177 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1178 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
| 1179 | if (quantize_info->number_colors == 0) |
| 1180 | break; |
| 1181 | if (((*image)->storage_class == DirectClass) || |
| 1182 | (*image)->colors > quantize_info->number_colors) |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1183 | (void) QuantizeImage(quantize_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1184 | else |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1185 | (void) CompressImageColormap(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1186 | break; |
| 1187 | } |
| 1188 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1189 | { |
| 1190 | ColorspaceType |
| 1191 | colorspace; |
| 1192 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1193 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1194 | if (*option == '+') |
| 1195 | { |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 1196 | (void) TransformImageColorspace(*image,RGBColorspace,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1197 | break; |
| 1198 | } |
| 1199 | colorspace=(ColorspaceType) ParseCommandOption( |
| 1200 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 1201 | (void) TransformImageColorspace(*image,colorspace,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1202 | break; |
| 1203 | } |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1204 | if (LocaleCompare("compose",option+1) == 0) |
| 1205 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1206 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1207 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 1208 | MagickFalse,argv[i+1]); |
| 1209 | break; |
| 1210 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1211 | if (LocaleCompare("contrast",option+1) == 0) |
| 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 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1215 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1216 | break; |
| 1217 | } |
| 1218 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1219 | { |
| 1220 | double |
| 1221 | black_point, |
| 1222 | white_point; |
| 1223 | |
| 1224 | MagickStatusType |
| 1225 | flags; |
| 1226 | |
| 1227 | /* |
| 1228 | Contrast stretch image. |
| 1229 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1230 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1231 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1232 | black_point=geometry_info.rho; |
| 1233 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1234 | black_point; |
| 1235 | if ((flags & PercentValue) != 0) |
| 1236 | { |
| 1237 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1238 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1239 | } |
| 1240 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1241 | white_point; |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1242 | (void) ContrastStretchImage(*image,black_point,white_point, |
| 1243 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1244 | break; |
| 1245 | } |
| 1246 | if (LocaleCompare("convolve",option+1) == 0) |
| 1247 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1248 | KernelInfo |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1249 | *kernel_info; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1250 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1251 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1252 | kernel_info=AcquireKernelInfo(argv[i+1]); |
| 1253 | if (kernel_info == (KernelInfo *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1254 | break; |
cristy | 0a92238 | 2011-07-16 15:30:34 +0000 | [diff] [blame] | 1255 | kernel_info->bias=(*image)->bias; |
cristy | 5e6be1e | 2011-07-16 01:23:39 +0000 | [diff] [blame] | 1256 | mogrify_image=ConvolveImage(*image,kernel_info,exception); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1257 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1258 | break; |
| 1259 | } |
| 1260 | if (LocaleCompare("crop",option+1) == 0) |
| 1261 | { |
| 1262 | /* |
| 1263 | Crop a image to a smaller size |
| 1264 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1265 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1266 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1267 | break; |
| 1268 | } |
| 1269 | if (LocaleCompare("cycle",option+1) == 0) |
| 1270 | { |
| 1271 | /* |
| 1272 | Cycle an image colormap. |
| 1273 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1274 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1275 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]), |
| 1276 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1277 | break; |
| 1278 | } |
| 1279 | break; |
| 1280 | } |
| 1281 | case 'd': |
| 1282 | { |
| 1283 | if (LocaleCompare("decipher",option+1) == 0) |
| 1284 | { |
| 1285 | StringInfo |
| 1286 | *passkey; |
| 1287 | |
| 1288 | /* |
| 1289 | Decipher pixels. |
| 1290 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1291 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1292 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1293 | if (passkey != (StringInfo *) NULL) |
| 1294 | { |
| 1295 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1296 | passkey=DestroyStringInfo(passkey); |
| 1297 | } |
| 1298 | break; |
| 1299 | } |
| 1300 | if (LocaleCompare("density",option+1) == 0) |
| 1301 | { |
| 1302 | /* |
| 1303 | Set image density. |
| 1304 | */ |
| 1305 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1306 | break; |
| 1307 | } |
| 1308 | if (LocaleCompare("depth",option+1) == 0) |
| 1309 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1310 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1311 | if (*option == '+') |
| 1312 | { |
cristy | 8a11cb1 | 2011-10-19 23:53:34 +0000 | [diff] [blame] | 1313 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1314 | break; |
| 1315 | } |
cristy | 8a11cb1 | 2011-10-19 23:53:34 +0000 | [diff] [blame] | 1316 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]), |
| 1317 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1318 | break; |
| 1319 | } |
| 1320 | if (LocaleCompare("deskew",option+1) == 0) |
| 1321 | { |
| 1322 | double |
| 1323 | threshold; |
| 1324 | |
| 1325 | /* |
| 1326 | Straighten the image. |
| 1327 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1328 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1329 | if (*option == '+') |
| 1330 | threshold=40.0*QuantumRange/100.0; |
| 1331 | else |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 1332 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 1333 | 1.0); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1334 | mogrify_image=DeskewImage(*image,threshold,exception); |
| 1335 | break; |
| 1336 | } |
| 1337 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1338 | { |
| 1339 | /* |
| 1340 | Reduce the speckles within an image. |
| 1341 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1342 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1343 | mogrify_image=DespeckleImage(*image,exception); |
| 1344 | break; |
| 1345 | } |
| 1346 | if (LocaleCompare("display",option+1) == 0) |
| 1347 | { |
| 1348 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1349 | break; |
| 1350 | } |
| 1351 | if (LocaleCompare("distort",option+1) == 0) |
| 1352 | { |
| 1353 | char |
| 1354 | *args, |
| 1355 | token[MaxTextExtent]; |
| 1356 | |
| 1357 | const char |
| 1358 | *p; |
| 1359 | |
| 1360 | DistortImageMethod |
| 1361 | method; |
| 1362 | |
| 1363 | double |
| 1364 | *arguments; |
| 1365 | |
| 1366 | register ssize_t |
| 1367 | x; |
| 1368 | |
| 1369 | size_t |
| 1370 | number_arguments; |
| 1371 | |
| 1372 | /* |
| 1373 | Distort image. |
| 1374 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1375 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1376 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, |
| 1377 | MagickFalse,argv[i+1]); |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1378 | if (method == ResizeDistortion) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1379 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1380 | double |
| 1381 | resize_args[2]; |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1382 | |
| 1383 | /* |
| 1384 | Special Case - Argument is actually a resize geometry! |
| 1385 | Convert that to an appropriate distortion argument array. |
| 1386 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1387 | (void) ParseRegionGeometry(*image,argv[i+2],&geometry, |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1388 | exception); |
| 1389 | resize_args[0]=(double) geometry.width; |
| 1390 | resize_args[1]=(double) geometry.height; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1391 | mogrify_image=DistortImage(*image,method,(size_t)2, |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1392 | resize_args,MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1393 | break; |
| 1394 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1395 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1396 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1397 | if (args == (char *) NULL) |
| 1398 | break; |
| 1399 | p=(char *) args; |
| 1400 | for (x=0; *p != '\0'; x++) |
| 1401 | { |
| 1402 | GetMagickToken(p,&p,token); |
| 1403 | if (*token == ',') |
| 1404 | GetMagickToken(p,&p,token); |
| 1405 | } |
| 1406 | number_arguments=(size_t) x; |
| 1407 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1408 | sizeof(*arguments)); |
| 1409 | if (arguments == (double *) NULL) |
| 1410 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1411 | "MemoryAllocationFailed",(*image)->filename); |
| 1412 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1413 | sizeof(*arguments)); |
| 1414 | p=(char *) args; |
| 1415 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 1416 | { |
| 1417 | GetMagickToken(p,&p,token); |
| 1418 | if (*token == ',') |
| 1419 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1420 | arguments[x]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1421 | } |
| 1422 | args=DestroyString(args); |
| 1423 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
| 1424 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1425 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1426 | break; |
| 1427 | } |
| 1428 | if (LocaleCompare("dither",option+1) == 0) |
| 1429 | { |
| 1430 | if (*option == '+') |
| 1431 | { |
| 1432 | quantize_info->dither=MagickFalse; |
| 1433 | break; |
| 1434 | } |
| 1435 | quantize_info->dither=MagickTrue; |
| 1436 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
| 1437 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1438 | if (quantize_info->dither_method == NoDitherMethod) |
| 1439 | quantize_info->dither=MagickFalse; |
| 1440 | break; |
| 1441 | } |
| 1442 | if (LocaleCompare("draw",option+1) == 0) |
| 1443 | { |
| 1444 | /* |
| 1445 | Draw image. |
| 1446 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1447 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1448 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1449 | (void) DrawImage(*image,draw_info,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1450 | break; |
| 1451 | } |
| 1452 | break; |
| 1453 | } |
| 1454 | case 'e': |
| 1455 | { |
| 1456 | if (LocaleCompare("edge",option+1) == 0) |
| 1457 | { |
| 1458 | /* |
| 1459 | Enhance edges in the image. |
| 1460 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1461 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1462 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1463 | if ((flags & SigmaValue) == 0) |
| 1464 | geometry_info.sigma=1.0; |
cristy | 8ae632d | 2011-09-05 17:29:53 +0000 | [diff] [blame] | 1465 | mogrify_image=EdgeImage(*image,geometry_info.rho, |
| 1466 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1467 | break; |
| 1468 | } |
| 1469 | if (LocaleCompare("emboss",option+1) == 0) |
| 1470 | { |
| 1471 | /* |
cristy | d89705a | 2012-01-20 02:52:24 +0000 | [diff] [blame] | 1472 | Emboss image. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1473 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1474 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1475 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1476 | if ((flags & SigmaValue) == 0) |
| 1477 | geometry_info.sigma=1.0; |
| 1478 | mogrify_image=EmbossImage(*image,geometry_info.rho, |
| 1479 | geometry_info.sigma,exception); |
| 1480 | break; |
| 1481 | } |
| 1482 | if (LocaleCompare("encipher",option+1) == 0) |
| 1483 | { |
| 1484 | StringInfo |
| 1485 | *passkey; |
| 1486 | |
| 1487 | /* |
| 1488 | Encipher pixels. |
| 1489 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1490 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1491 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1492 | if (passkey != (StringInfo *) NULL) |
| 1493 | { |
| 1494 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1495 | passkey=DestroyStringInfo(passkey); |
| 1496 | } |
| 1497 | break; |
| 1498 | } |
| 1499 | if (LocaleCompare("encoding",option+1) == 0) |
| 1500 | { |
| 1501 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1502 | break; |
| 1503 | } |
| 1504 | if (LocaleCompare("enhance",option+1) == 0) |
| 1505 | { |
| 1506 | /* |
| 1507 | Enhance image. |
| 1508 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1509 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1510 | mogrify_image=EnhanceImage(*image,exception); |
| 1511 | break; |
| 1512 | } |
| 1513 | if (LocaleCompare("equalize",option+1) == 0) |
| 1514 | { |
| 1515 | /* |
| 1516 | Equalize image. |
| 1517 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1518 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 6d8c3d7 | 2011-08-22 01:20:01 +0000 | [diff] [blame] | 1519 | (void) EqualizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1520 | break; |
| 1521 | } |
| 1522 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1523 | { |
| 1524 | double |
| 1525 | constant; |
| 1526 | |
| 1527 | MagickEvaluateOperator |
| 1528 | op; |
| 1529 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1530 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1531 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 1532 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 1533 | constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+ |
| 1534 | 1.0); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1535 | (void) EvaluateImage(*image,op,constant,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1536 | break; |
| 1537 | } |
| 1538 | if (LocaleCompare("extent",option+1) == 0) |
| 1539 | { |
| 1540 | /* |
| 1541 | Set the image extent. |
| 1542 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1543 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1544 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1545 | if (geometry.width == 0) |
| 1546 | geometry.width=(*image)->columns; |
| 1547 | if (geometry.height == 0) |
| 1548 | geometry.height=(*image)->rows; |
| 1549 | mogrify_image=ExtentImage(*image,&geometry,exception); |
| 1550 | break; |
| 1551 | } |
| 1552 | break; |
| 1553 | } |
| 1554 | case 'f': |
| 1555 | { |
| 1556 | if (LocaleCompare("family",option+1) == 0) |
| 1557 | { |
| 1558 | if (*option == '+') |
| 1559 | { |
| 1560 | if (draw_info->family != (char *) NULL) |
| 1561 | draw_info->family=DestroyString(draw_info->family); |
| 1562 | break; |
| 1563 | } |
| 1564 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1565 | break; |
| 1566 | } |
| 1567 | if (LocaleCompare("features",option+1) == 0) |
| 1568 | { |
| 1569 | if (*option == '+') |
| 1570 | { |
| 1571 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1572 | break; |
| 1573 | } |
| 1574 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1575 | break; |
| 1576 | } |
| 1577 | if (LocaleCompare("fill",option+1) == 0) |
| 1578 | { |
| 1579 | ExceptionInfo |
| 1580 | *sans; |
| 1581 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1582 | PixelInfo |
| 1583 | color; |
| 1584 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1585 | GetPixelInfo(*image,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1586 | if (*option == '+') |
| 1587 | { |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1588 | (void) QueryColorCompliance("none",AllCompliance,&fill, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1589 | exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1590 | draw_info->fill=fill; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1591 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1592 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1593 | break; |
| 1594 | } |
| 1595 | sans=AcquireExceptionInfo(); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1596 | status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1597 | sans=DestroyExceptionInfo(sans); |
| 1598 | if (status == MagickFalse) |
| 1599 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 1600 | exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1601 | else |
| 1602 | draw_info->fill=fill=color; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1603 | break; |
| 1604 | } |
| 1605 | if (LocaleCompare("flip",option+1) == 0) |
| 1606 | { |
| 1607 | /* |
| 1608 | Flip image scanlines. |
| 1609 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1610 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1611 | mogrify_image=FlipImage(*image,exception); |
| 1612 | break; |
| 1613 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1614 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1615 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1616 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1617 | target; |
| 1618 | |
| 1619 | /* |
| 1620 | Floodfill image. |
| 1621 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1622 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1623 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1624 | (void) QueryColorCompliance(argv[i+2],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1625 | exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1626 | (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x, |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 1627 | geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1628 | break; |
| 1629 | } |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1630 | if (LocaleCompare("flop",option+1) == 0) |
| 1631 | { |
| 1632 | /* |
| 1633 | Flop image scanlines. |
| 1634 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1635 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1636 | mogrify_image=FlopImage(*image,exception); |
| 1637 | break; |
| 1638 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1639 | if (LocaleCompare("font",option+1) == 0) |
| 1640 | { |
| 1641 | if (*option == '+') |
| 1642 | { |
| 1643 | if (draw_info->font != (char *) NULL) |
| 1644 | draw_info->font=DestroyString(draw_info->font); |
| 1645 | break; |
| 1646 | } |
| 1647 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1648 | break; |
| 1649 | } |
| 1650 | if (LocaleCompare("format",option+1) == 0) |
| 1651 | { |
| 1652 | format=argv[i+1]; |
| 1653 | break; |
| 1654 | } |
| 1655 | if (LocaleCompare("frame",option+1) == 0) |
| 1656 | { |
| 1657 | FrameInfo |
| 1658 | frame_info; |
| 1659 | |
| 1660 | /* |
| 1661 | Surround image with an ornamental border. |
| 1662 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1663 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1664 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1665 | frame_info.width=geometry.width; |
| 1666 | frame_info.height=geometry.height; |
| 1667 | if ((flags & HeightValue) == 0) |
| 1668 | frame_info.height=geometry.width; |
| 1669 | frame_info.outer_bevel=geometry.x; |
| 1670 | frame_info.inner_bevel=geometry.y; |
| 1671 | frame_info.x=(ssize_t) frame_info.width; |
| 1672 | frame_info.y=(ssize_t) frame_info.height; |
| 1673 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1674 | frame_info.height=(*image)->rows+2*frame_info.height; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1675 | mogrify_image=FrameImage(*image,&frame_info,compose,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1676 | break; |
| 1677 | } |
| 1678 | if (LocaleCompare("function",option+1) == 0) |
| 1679 | { |
| 1680 | char |
| 1681 | *arguments, |
| 1682 | token[MaxTextExtent]; |
| 1683 | |
| 1684 | const char |
| 1685 | *p; |
| 1686 | |
| 1687 | double |
| 1688 | *parameters; |
| 1689 | |
| 1690 | MagickFunction |
| 1691 | function; |
| 1692 | |
| 1693 | register ssize_t |
| 1694 | x; |
| 1695 | |
| 1696 | size_t |
| 1697 | number_parameters; |
| 1698 | |
| 1699 | /* |
| 1700 | Function Modify Image Values |
| 1701 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1702 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1703 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, |
| 1704 | MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1705 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1706 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1707 | if (arguments == (char *) NULL) |
| 1708 | break; |
| 1709 | p=(char *) arguments; |
| 1710 | for (x=0; *p != '\0'; x++) |
| 1711 | { |
| 1712 | GetMagickToken(p,&p,token); |
| 1713 | if (*token == ',') |
| 1714 | GetMagickToken(p,&p,token); |
| 1715 | } |
| 1716 | number_parameters=(size_t) x; |
| 1717 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1718 | sizeof(*parameters)); |
| 1719 | if (parameters == (double *) NULL) |
| 1720 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1721 | "MemoryAllocationFailed",(*image)->filename); |
| 1722 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1723 | sizeof(*parameters)); |
| 1724 | p=(char *) arguments; |
| 1725 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
| 1726 | { |
| 1727 | GetMagickToken(p,&p,token); |
| 1728 | if (*token == ',') |
| 1729 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1730 | parameters[x]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1731 | } |
| 1732 | arguments=DestroyString(arguments); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1733 | (void) FunctionImage(*image,function,number_parameters,parameters, |
| 1734 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1735 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1736 | break; |
| 1737 | } |
| 1738 | break; |
| 1739 | } |
| 1740 | case 'g': |
| 1741 | { |
| 1742 | if (LocaleCompare("gamma",option+1) == 0) |
| 1743 | { |
| 1744 | /* |
| 1745 | Gamma image. |
| 1746 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1747 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1748 | if (*option == '+') |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1749 | (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1750 | else |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1751 | (void) GammaImage(*image,StringToDouble(argv[i+1], |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 1752 | (char **) NULL),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1753 | break; |
| 1754 | } |
| 1755 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1756 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1757 | { |
| 1758 | /* |
| 1759 | Gaussian blur image. |
| 1760 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1761 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1762 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1763 | if ((flags & SigmaValue) == 0) |
| 1764 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1765 | mogrify_image=GaussianBlurImage(*image,geometry_info.rho, |
cristy | d89705a | 2012-01-20 02:52:24 +0000 | [diff] [blame] | 1766 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1767 | break; |
| 1768 | } |
| 1769 | if (LocaleCompare("geometry",option+1) == 0) |
| 1770 | { |
| 1771 | /* |
| 1772 | Record Image offset, Resize last image. |
| 1773 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1774 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1775 | if (*option == '+') |
| 1776 | { |
| 1777 | if ((*image)->geometry != (char *) NULL) |
| 1778 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1779 | break; |
| 1780 | } |
| 1781 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1782 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1783 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1784 | else |
| 1785 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 1786 | (*image)->filter,(*image)->blur,exception); |
| 1787 | break; |
| 1788 | } |
| 1789 | if (LocaleCompare("gravity",option+1) == 0) |
| 1790 | { |
| 1791 | if (*option == '+') |
| 1792 | { |
| 1793 | draw_info->gravity=UndefinedGravity; |
| 1794 | break; |
| 1795 | } |
| 1796 | draw_info->gravity=(GravityType) ParseCommandOption( |
| 1797 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1798 | break; |
| 1799 | } |
| 1800 | break; |
| 1801 | } |
| 1802 | case 'h': |
| 1803 | { |
| 1804 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1805 | { |
| 1806 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1807 | break; |
| 1808 | } |
| 1809 | break; |
| 1810 | } |
| 1811 | case 'i': |
| 1812 | { |
| 1813 | if (LocaleCompare("identify",option+1) == 0) |
| 1814 | { |
| 1815 | char |
| 1816 | *text; |
| 1817 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1818 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1819 | if (format == (char *) NULL) |
| 1820 | { |
cristy | a403727 | 2011-08-28 15:11:39 +0000 | [diff] [blame] | 1821 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose, |
| 1822 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1823 | break; |
| 1824 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1825 | text=InterpretImageProperties(mogrify_info,*image,format, |
| 1826 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1827 | if (text == (char *) NULL) |
| 1828 | break; |
| 1829 | (void) fputs(text,stdout); |
| 1830 | (void) fputc('\n',stdout); |
| 1831 | text=DestroyString(text); |
| 1832 | break; |
| 1833 | } |
| 1834 | if (LocaleCompare("implode",option+1) == 0) |
| 1835 | { |
| 1836 | /* |
| 1837 | Implode image. |
| 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 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 76f512e | 2011-09-12 01:26:56 +0000 | [diff] [blame] | 1841 | mogrify_image=ImplodeImage(*image,geometry_info.rho, |
| 1842 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1843 | break; |
| 1844 | } |
| 1845 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1846 | { |
| 1847 | if (*option == '+') |
| 1848 | (void) ParseGeometry("0",&geometry_info); |
| 1849 | else |
| 1850 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1851 | draw_info->interline_spacing=geometry_info.rho; |
| 1852 | break; |
| 1853 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 1854 | if (LocaleCompare("interpolate",option+1) == 0) |
| 1855 | { |
| 1856 | interpolate_method=(PixelInterpolateMethod) ParseCommandOption( |
| 1857 | MagickInterpolateOptions,MagickFalse,argv[i+1]); |
| 1858 | break; |
| 1859 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1860 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1861 | { |
| 1862 | if (*option == '+') |
| 1863 | (void) ParseGeometry("0",&geometry_info); |
| 1864 | else |
| 1865 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1866 | draw_info->interword_spacing=geometry_info.rho; |
| 1867 | break; |
| 1868 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1869 | if (LocaleCompare("interpolative-resize",option+1) == 0) |
| 1870 | { |
| 1871 | /* |
| 1872 | Interpolative resize image. |
| 1873 | */ |
| 1874 | (void) SyncImageSettings(mogrify_info,*image,exception); |
| 1875 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1876 | mogrify_image=InterpolativeResizeImage(*image,geometry.width, |
| 1877 | geometry.height,interpolate_method,exception); |
| 1878 | break; |
| 1879 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1880 | break; |
| 1881 | } |
| 1882 | case 'k': |
| 1883 | { |
| 1884 | if (LocaleCompare("kerning",option+1) == 0) |
| 1885 | { |
| 1886 | if (*option == '+') |
| 1887 | (void) ParseGeometry("0",&geometry_info); |
| 1888 | else |
| 1889 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1890 | draw_info->kerning=geometry_info.rho; |
| 1891 | break; |
| 1892 | } |
| 1893 | break; |
| 1894 | } |
| 1895 | case 'l': |
| 1896 | { |
| 1897 | if (LocaleCompare("lat",option+1) == 0) |
| 1898 | { |
| 1899 | /* |
| 1900 | Local adaptive threshold image. |
| 1901 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1902 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1903 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1904 | if ((flags & PercentValue) != 0) |
| 1905 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 1906 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
cristy | de5cc63 | 2011-07-18 14:47:00 +0000 | [diff] [blame] | 1907 | geometry_info.rho,(size_t) geometry_info.sigma,(double) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1908 | geometry_info.xi,exception); |
| 1909 | break; |
| 1910 | } |
| 1911 | if (LocaleCompare("level",option+1) == 0) |
| 1912 | { |
| 1913 | MagickRealType |
| 1914 | black_point, |
| 1915 | gamma, |
| 1916 | white_point; |
| 1917 | |
| 1918 | MagickStatusType |
| 1919 | flags; |
| 1920 | |
| 1921 | /* |
| 1922 | Parse levels. |
| 1923 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1924 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1925 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1926 | black_point=geometry_info.rho; |
| 1927 | white_point=(MagickRealType) QuantumRange; |
| 1928 | if ((flags & SigmaValue) != 0) |
| 1929 | white_point=geometry_info.sigma; |
| 1930 | gamma=1.0; |
| 1931 | if ((flags & XiValue) != 0) |
| 1932 | gamma=geometry_info.xi; |
| 1933 | if ((flags & PercentValue) != 0) |
| 1934 | { |
| 1935 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 1936 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 1937 | } |
| 1938 | if ((flags & SigmaValue) == 0) |
| 1939 | white_point=(MagickRealType) QuantumRange-black_point; |
| 1940 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1941 | (void) LevelizeImage(*image,black_point,white_point,gamma, |
| 1942 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1943 | else |
cristy | 01e9afd | 2011-08-10 17:38:41 +0000 | [diff] [blame] | 1944 | (void) LevelImage(*image,black_point,white_point,gamma, |
| 1945 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1946 | break; |
| 1947 | } |
| 1948 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1949 | { |
| 1950 | char |
| 1951 | token[MaxTextExtent]; |
| 1952 | |
| 1953 | const char |
| 1954 | *p; |
| 1955 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1956 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1957 | black_point, |
| 1958 | white_point; |
| 1959 | |
| 1960 | p=(const char *) argv[i+1]; |
| 1961 | GetMagickToken(p,&p,token); /* get black point color */ |
| 1962 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1963 | (void) QueryColorCompliance(token,AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1964 | &black_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1965 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1966 | (void) QueryColorCompliance("#000000",AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1967 | &black_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1968 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1969 | GetMagickToken(p,&p,token); |
| 1970 | if (*token == '\0') |
| 1971 | white_point=black_point; /* set everything to that color */ |
| 1972 | else |
| 1973 | { |
| 1974 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 1975 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 1976 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1977 | (void) QueryColorCompliance(token,AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1978 | &white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1979 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1980 | (void) QueryColorCompliance("#ffffff",AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1981 | &white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1982 | } |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 1983 | (void) LevelImageColors(*image,&black_point,&white_point, |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1984 | *option == '+' ? MagickTrue : MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1985 | break; |
| 1986 | } |
| 1987 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 1988 | { |
| 1989 | double |
| 1990 | black_point, |
| 1991 | white_point; |
| 1992 | |
| 1993 | MagickStatusType |
| 1994 | flags; |
| 1995 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1996 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1997 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1998 | black_point=geometry_info.rho; |
| 1999 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 2000 | if ((flags & SigmaValue) != 0) |
| 2001 | white_point=geometry_info.sigma; |
| 2002 | if ((flags & PercentValue) != 0) |
| 2003 | { |
| 2004 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 2005 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 2006 | } |
| 2007 | if ((flags & SigmaValue) == 0) |
| 2008 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 2009 | black_point; |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2010 | (void) LinearStretchImage(*image,black_point,white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2011 | break; |
| 2012 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2013 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 2014 | { |
| 2015 | /* |
| 2016 | Liquid rescale image. |
| 2017 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2018 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2019 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2020 | if ((flags & XValue) == 0) |
| 2021 | geometry.x=1; |
| 2022 | if ((flags & YValue) == 0) |
| 2023 | geometry.y=0; |
| 2024 | mogrify_image=LiquidRescaleImage(*image,geometry.width, |
| 2025 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 2026 | break; |
| 2027 | } |
| 2028 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 2029 | { |
| 2030 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 2031 | break; |
| 2032 | } |
| 2033 | break; |
| 2034 | } |
| 2035 | case 'm': |
| 2036 | { |
| 2037 | if (LocaleCompare("map",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2038 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2039 | Image |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2040 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2041 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2042 | /* |
| 2043 | Transform image colors to match this set of colors. |
| 2044 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2045 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2046 | if (*option == '+') |
| 2047 | break; |
| 2048 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2049 | if (remap_image == (Image *) NULL) |
| 2050 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2051 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2052 | remap_image=DestroyImage(remap_image); |
| 2053 | break; |
| 2054 | } |
| 2055 | if (LocaleCompare("mask",option+1) == 0) |
| 2056 | { |
| 2057 | Image |
| 2058 | *mask; |
| 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 | { |
| 2063 | /* |
| 2064 | Remove a mask. |
| 2065 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2066 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2067 | break; |
| 2068 | } |
| 2069 | /* |
| 2070 | Set the image mask. |
| 2071 | */ |
| 2072 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2073 | if (mask == (Image *) NULL) |
| 2074 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2075 | (void) SetImageMask(*image,mask,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2076 | mask=DestroyImage(mask); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2077 | break; |
| 2078 | } |
| 2079 | if (LocaleCompare("matte",option+1) == 0) |
| 2080 | { |
| 2081 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 2082 | SetAlphaChannel : DeactivateAlphaChannel,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2083 | break; |
| 2084 | } |
| 2085 | if (LocaleCompare("median",option+1) == 0) |
| 2086 | { |
| 2087 | /* |
| 2088 | Median filter image. |
| 2089 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2090 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2091 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2092 | if ((flags & SigmaValue) == 0) |
| 2093 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2094 | mogrify_image=StatisticImage(*image,MedianStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2095 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2096 | break; |
| 2097 | } |
| 2098 | if (LocaleCompare("mode",option+1) == 0) |
| 2099 | { |
| 2100 | /* |
| 2101 | Mode image. |
| 2102 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2103 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2104 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2105 | if ((flags & SigmaValue) == 0) |
| 2106 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2107 | mogrify_image=StatisticImage(*image,ModeStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2108 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2109 | break; |
| 2110 | } |
| 2111 | if (LocaleCompare("modulate",option+1) == 0) |
| 2112 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2113 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2114 | (void) ModulateImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2115 | break; |
| 2116 | } |
| 2117 | if (LocaleCompare("monitor",option+1) == 0) |
| 2118 | { |
| 2119 | if (*option == '+') |
| 2120 | { |
| 2121 | (void) SetImageProgressMonitor(*image, |
| 2122 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2123 | break; |
| 2124 | } |
| 2125 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2126 | (void *) NULL); |
| 2127 | break; |
| 2128 | } |
| 2129 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2130 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2131 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2132 | (void) SetImageType(*image,BilevelType,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2133 | break; |
| 2134 | } |
| 2135 | if (LocaleCompare("morphology",option+1) == 0) |
| 2136 | { |
| 2137 | char |
| 2138 | token[MaxTextExtent]; |
| 2139 | |
| 2140 | const char |
| 2141 | *p; |
| 2142 | |
| 2143 | KernelInfo |
| 2144 | *kernel; |
| 2145 | |
| 2146 | MorphologyMethod |
| 2147 | method; |
| 2148 | |
| 2149 | ssize_t |
| 2150 | iterations; |
| 2151 | |
| 2152 | /* |
| 2153 | Morphological Image Operation |
| 2154 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2155 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2156 | p=argv[i+1]; |
| 2157 | GetMagickToken(p,&p,token); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2158 | method=(MorphologyMethod) ParseCommandOption( |
| 2159 | MagickMorphologyOptions,MagickFalse,token); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2160 | iterations=1L; |
| 2161 | GetMagickToken(p,&p,token); |
| 2162 | if ((*p == ':') || (*p == ',')) |
| 2163 | GetMagickToken(p,&p,token); |
| 2164 | if ((*p != '\0')) |
| 2165 | iterations=(ssize_t) StringToLong(p); |
| 2166 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2167 | if (kernel == (KernelInfo *) NULL) |
| 2168 | { |
| 2169 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2170 | OptionError,"UnabletoParseKernel","morphology"); |
| 2171 | status=MagickFalse; |
| 2172 | break; |
| 2173 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2174 | mogrify_image=MorphologyImage(*image,method,iterations,kernel, |
| 2175 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2176 | kernel=DestroyKernelInfo(kernel); |
| 2177 | break; |
| 2178 | } |
| 2179 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2180 | { |
| 2181 | /* |
| 2182 | Motion blur image. |
| 2183 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2184 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2185 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2186 | if ((flags & SigmaValue) == 0) |
| 2187 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2188 | mogrify_image=MotionBlurImage(*image,geometry_info.rho, |
cristy | 7497f48 | 2011-12-08 01:57:31 +0000 | [diff] [blame] | 2189 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2190 | break; |
| 2191 | } |
| 2192 | break; |
| 2193 | } |
| 2194 | case 'n': |
| 2195 | { |
| 2196 | if (LocaleCompare("negate",option+1) == 0) |
| 2197 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2198 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2199 | (void) NegateImage(*image,*option == '+' ? MagickTrue : |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 2200 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2201 | break; |
| 2202 | } |
| 2203 | if (LocaleCompare("noise",option+1) == 0) |
| 2204 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2205 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2206 | if (*option == '-') |
| 2207 | { |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2208 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2209 | if ((flags & SigmaValue) == 0) |
| 2210 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2211 | mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2212 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2213 | } |
| 2214 | else |
| 2215 | { |
| 2216 | NoiseType |
| 2217 | noise; |
| 2218 | |
| 2219 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
| 2220 | MagickFalse,argv[i+1]); |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 2221 | mogrify_image=AddNoiseImage(*image,noise,attenuate,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2222 | } |
| 2223 | break; |
| 2224 | } |
| 2225 | if (LocaleCompare("normalize",option+1) == 0) |
| 2226 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2227 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 2228 | (void) NormalizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2229 | break; |
| 2230 | } |
| 2231 | break; |
| 2232 | } |
| 2233 | case 'o': |
| 2234 | { |
| 2235 | if (LocaleCompare("opaque",option+1) == 0) |
| 2236 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2237 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2238 | target; |
| 2239 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2240 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2241 | (void) QueryColorCompliance(argv[i+1],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2242 | exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 2243 | (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ? |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 2244 | MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2245 | break; |
| 2246 | } |
| 2247 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2248 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2249 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 1302067 | 2011-07-08 02:33:26 +0000 | [diff] [blame] | 2250 | (void) OrderedPosterizeImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2251 | break; |
| 2252 | } |
| 2253 | break; |
| 2254 | } |
| 2255 | case 'p': |
| 2256 | { |
| 2257 | if (LocaleCompare("paint",option+1) == 0) |
| 2258 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2259 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2260 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 14973ba | 2011-08-27 23:48:07 +0000 | [diff] [blame] | 2261 | mogrify_image=OilPaintImage(*image,geometry_info.rho, |
| 2262 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2263 | break; |
| 2264 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2265 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2266 | { |
| 2267 | if (*option == '+') |
| 2268 | (void) ParseGeometry("12",&geometry_info); |
| 2269 | else |
| 2270 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2271 | draw_info->pointsize=geometry_info.rho; |
| 2272 | break; |
| 2273 | } |
| 2274 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2275 | { |
cristy | e9e3d38 | 2011-12-14 01:50:13 +0000 | [diff] [blame] | 2276 | const char |
| 2277 | *caption; |
| 2278 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2279 | double |
| 2280 | angle; |
| 2281 | |
| 2282 | RandomInfo |
| 2283 | *random_info; |
| 2284 | |
| 2285 | /* |
| 2286 | Simulate a Polaroid picture. |
| 2287 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2288 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2289 | random_info=AcquireRandomInfo(); |
| 2290 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2291 | random_info=DestroyRandomInfo(random_info); |
| 2292 | if (*option == '-') |
| 2293 | { |
| 2294 | SetGeometryInfo(&geometry_info); |
| 2295 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2296 | angle=geometry_info.rho; |
| 2297 | } |
cristy | e9e3d38 | 2011-12-14 01:50:13 +0000 | [diff] [blame] | 2298 | caption=GetImageProperty(*image,"caption",exception); |
| 2299 | mogrify_image=PolaroidImage(*image,draw_info,caption,angle, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2300 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2301 | break; |
| 2302 | } |
| 2303 | if (LocaleCompare("posterize",option+1) == 0) |
| 2304 | { |
| 2305 | /* |
| 2306 | Posterize image. |
| 2307 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2308 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2309 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2310 | quantize_info->dither,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2311 | break; |
| 2312 | } |
| 2313 | if (LocaleCompare("preview",option+1) == 0) |
| 2314 | { |
| 2315 | PreviewType |
| 2316 | preview_type; |
| 2317 | |
| 2318 | /* |
| 2319 | Preview image. |
| 2320 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2321 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2322 | if (*option == '+') |
| 2323 | preview_type=UndefinedPreview; |
| 2324 | else |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2325 | preview_type=(PreviewType) ParseCommandOption( |
| 2326 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2327 | mogrify_image=PreviewImage(*image,preview_type,exception); |
| 2328 | break; |
| 2329 | } |
| 2330 | if (LocaleCompare("profile",option+1) == 0) |
| 2331 | { |
| 2332 | const char |
| 2333 | *name; |
| 2334 | |
| 2335 | const StringInfo |
| 2336 | *profile; |
| 2337 | |
| 2338 | Image |
| 2339 | *profile_image; |
| 2340 | |
| 2341 | ImageInfo |
| 2342 | *profile_info; |
| 2343 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2344 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2345 | if (*option == '+') |
| 2346 | { |
| 2347 | /* |
| 2348 | Remove a profile from the image. |
| 2349 | */ |
| 2350 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
cristy | 092d71c | 2011-10-14 18:01:29 +0000 | [diff] [blame] | 2351 | NULL,0,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2352 | break; |
| 2353 | } |
| 2354 | /* |
| 2355 | Associate a profile with the image. |
| 2356 | */ |
| 2357 | profile_info=CloneImageInfo(mogrify_info); |
| 2358 | profile=GetImageProfile(*image,"iptc"); |
| 2359 | if (profile != (StringInfo *) NULL) |
| 2360 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2361 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2362 | profile_info=DestroyImageInfo(profile_info); |
| 2363 | if (profile_image == (Image *) NULL) |
| 2364 | { |
| 2365 | StringInfo |
| 2366 | *profile; |
| 2367 | |
| 2368 | profile_info=CloneImageInfo(mogrify_info); |
| 2369 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2370 | MaxTextExtent); |
| 2371 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
| 2372 | if (profile != (StringInfo *) NULL) |
| 2373 | { |
| 2374 | (void) ProfileImage(*image,profile_info->magick, |
| 2375 | GetStringInfoDatum(profile),(size_t) |
cristy | 3fac9ec | 2011-11-17 18:04:39 +0000 | [diff] [blame] | 2376 | GetStringInfoLength(profile),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2377 | profile=DestroyStringInfo(profile); |
| 2378 | } |
| 2379 | profile_info=DestroyImageInfo(profile_info); |
| 2380 | break; |
| 2381 | } |
| 2382 | ResetImageProfileIterator(profile_image); |
| 2383 | name=GetNextImageProfile(profile_image); |
| 2384 | while (name != (const char *) NULL) |
| 2385 | { |
| 2386 | profile=GetImageProfile(profile_image,name); |
| 2387 | if (profile != (StringInfo *) NULL) |
| 2388 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
cristy | 3fac9ec | 2011-11-17 18:04:39 +0000 | [diff] [blame] | 2389 | (size_t) GetStringInfoLength(profile),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2390 | name=GetNextImageProfile(profile_image); |
| 2391 | } |
| 2392 | profile_image=DestroyImage(profile_image); |
| 2393 | break; |
| 2394 | } |
| 2395 | break; |
| 2396 | } |
| 2397 | case 'q': |
| 2398 | { |
| 2399 | if (LocaleCompare("quantize",option+1) == 0) |
| 2400 | { |
| 2401 | if (*option == '+') |
| 2402 | { |
| 2403 | quantize_info->colorspace=UndefinedColorspace; |
| 2404 | break; |
| 2405 | } |
| 2406 | quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
| 2407 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2408 | break; |
| 2409 | } |
| 2410 | break; |
| 2411 | } |
| 2412 | case 'r': |
| 2413 | { |
| 2414 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2415 | { |
| 2416 | /* |
| 2417 | Radial blur image. |
| 2418 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2419 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 6435bd9 | 2011-09-10 02:10:07 +0000 | [diff] [blame] | 2420 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2421 | mogrify_image=RadialBlurImage(*image,geometry_info.rho, |
| 2422 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2423 | break; |
| 2424 | } |
| 2425 | if (LocaleCompare("raise",option+1) == 0) |
| 2426 | { |
| 2427 | /* |
| 2428 | Surround image with a raise of solid color. |
| 2429 | */ |
| 2430 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2431 | if ((flags & SigmaValue) == 0) |
| 2432 | geometry.height=geometry.width; |
| 2433 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
cristy | 6170ac3 | 2011-08-28 14:15:37 +0000 | [diff] [blame] | 2434 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2435 | break; |
| 2436 | } |
| 2437 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2438 | { |
| 2439 | /* |
| 2440 | Threshold image. |
| 2441 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2442 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2443 | (void) RandomThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2444 | break; |
| 2445 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2446 | if (LocaleCompare("region",option+1) == 0) |
| 2447 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2448 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2449 | if (region_image != (Image *) NULL) |
| 2450 | { |
| 2451 | /* |
| 2452 | Composite region. |
| 2453 | */ |
| 2454 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2455 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 2456 | region_geometry.x,region_geometry.y,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2457 | *image=DestroyImage(*image); |
| 2458 | *image=region_image; |
| 2459 | region_image = (Image *) NULL; |
| 2460 | } |
| 2461 | if (*option == '+') |
| 2462 | break; |
| 2463 | /* |
| 2464 | Apply transformations to a selected region of the image. |
| 2465 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2466 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2467 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2468 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2469 | if (mogrify_image == (Image *) NULL) |
| 2470 | break; |
| 2471 | region_image=(*image); |
| 2472 | *image=mogrify_image; |
| 2473 | mogrify_image=(Image *) NULL; |
| 2474 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2475 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2476 | if (LocaleCompare("render",option+1) == 0) |
| 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 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2480 | break; |
| 2481 | } |
| 2482 | if (LocaleCompare("remap",option+1) == 0) |
| 2483 | { |
| 2484 | Image |
| 2485 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2486 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2487 | /* |
| 2488 | Transform image colors to match this set of colors. |
| 2489 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2490 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2491 | if (*option == '+') |
| 2492 | break; |
| 2493 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2494 | if (remap_image == (Image *) NULL) |
| 2495 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2496 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2497 | remap_image=DestroyImage(remap_image); |
| 2498 | break; |
| 2499 | } |
| 2500 | if (LocaleCompare("repage",option+1) == 0) |
| 2501 | { |
| 2502 | if (*option == '+') |
| 2503 | { |
| 2504 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2505 | break; |
| 2506 | } |
| 2507 | (void) ResetImagePage(*image,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2508 | break; |
| 2509 | } |
| 2510 | if (LocaleCompare("resample",option+1) == 0) |
| 2511 | { |
| 2512 | /* |
| 2513 | Resample image. |
| 2514 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2515 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2516 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2517 | if ((flags & SigmaValue) == 0) |
| 2518 | geometry_info.sigma=geometry_info.rho; |
| 2519 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
| 2520 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2521 | break; |
| 2522 | } |
| 2523 | if (LocaleCompare("resize",option+1) == 0) |
| 2524 | { |
| 2525 | /* |
| 2526 | Resize image. |
| 2527 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2528 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2529 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2530 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2531 | (*image)->filter,(*image)->blur,exception); |
| 2532 | break; |
| 2533 | } |
| 2534 | if (LocaleCompare("roll",option+1) == 0) |
| 2535 | { |
| 2536 | /* |
| 2537 | Roll image. |
| 2538 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2539 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2540 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2541 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2542 | break; |
| 2543 | } |
| 2544 | if (LocaleCompare("rotate",option+1) == 0) |
| 2545 | { |
| 2546 | char |
| 2547 | *geometry; |
| 2548 | |
| 2549 | /* |
| 2550 | Check for conditional image rotation. |
| 2551 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2552 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2553 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2554 | if ((*image)->columns <= (*image)->rows) |
| 2555 | break; |
| 2556 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2557 | if ((*image)->columns >= (*image)->rows) |
| 2558 | break; |
| 2559 | /* |
| 2560 | Rotate image. |
| 2561 | */ |
| 2562 | geometry=ConstantString(argv[i+1]); |
| 2563 | (void) SubstituteString(&geometry,">",""); |
| 2564 | (void) SubstituteString(&geometry,"<",""); |
| 2565 | (void) ParseGeometry(geometry,&geometry_info); |
| 2566 | geometry=DestroyString(geometry); |
| 2567 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
| 2568 | break; |
| 2569 | } |
| 2570 | break; |
| 2571 | } |
| 2572 | case 's': |
| 2573 | { |
| 2574 | if (LocaleCompare("sample",option+1) == 0) |
| 2575 | { |
| 2576 | /* |
| 2577 | Sample image with pixel replication. |
| 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) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2581 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
| 2582 | exception); |
| 2583 | break; |
| 2584 | } |
| 2585 | if (LocaleCompare("scale",option+1) == 0) |
| 2586 | { |
| 2587 | /* |
| 2588 | Resize image. |
| 2589 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2590 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2591 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2592 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2593 | exception); |
| 2594 | break; |
| 2595 | } |
| 2596 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2597 | { |
| 2598 | /* |
| 2599 | Selectively blur pixels within a contrast threshold. |
| 2600 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2601 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2602 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2603 | if ((flags & PercentValue) != 0) |
| 2604 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2605 | mogrify_image=SelectiveBlurImage(*image,geometry_info.rho, |
cristy | 1e7aa31 | 2011-09-10 20:01:36 +0000 | [diff] [blame] | 2606 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2607 | break; |
| 2608 | } |
| 2609 | if (LocaleCompare("separate",option+1) == 0) |
| 2610 | { |
| 2611 | /* |
| 2612 | Break channels into separate images. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2613 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2614 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 2615 | mogrify_image=SeparateImages(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2616 | break; |
| 2617 | } |
| 2618 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2619 | { |
| 2620 | double |
| 2621 | threshold; |
| 2622 | |
| 2623 | /* |
| 2624 | Sepia-tone image. |
| 2625 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2626 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2627 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 2628 | 1.0); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2629 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
| 2630 | break; |
| 2631 | } |
| 2632 | if (LocaleCompare("segment",option+1) == 0) |
| 2633 | { |
| 2634 | /* |
| 2635 | Segment image. |
| 2636 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2637 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2638 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2639 | if ((flags & SigmaValue) == 0) |
| 2640 | geometry_info.sigma=1.0; |
| 2641 | (void) SegmentImage(*image,(*image)->colorspace, |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2642 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 2643 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2644 | break; |
| 2645 | } |
| 2646 | if (LocaleCompare("set",option+1) == 0) |
| 2647 | { |
| 2648 | char |
| 2649 | *value; |
| 2650 | |
| 2651 | /* |
| 2652 | Set image option. |
| 2653 | */ |
| 2654 | if (*option == '+') |
| 2655 | { |
| 2656 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2657 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2658 | else |
| 2659 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2660 | { |
| 2661 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
| 2662 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2663 | } |
| 2664 | else |
| 2665 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2666 | break; |
| 2667 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2668 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2669 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2670 | if (value == (char *) NULL) |
| 2671 | break; |
| 2672 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2673 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2674 | exception); |
| 2675 | else |
| 2676 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2677 | { |
| 2678 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
| 2679 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
| 2680 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2681 | } |
| 2682 | else |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 2683 | (void) SetImageProperty(*image,argv[i+1],value,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2684 | value=DestroyString(value); |
| 2685 | break; |
| 2686 | } |
| 2687 | if (LocaleCompare("shade",option+1) == 0) |
| 2688 | { |
| 2689 | /* |
| 2690 | Shade image. |
| 2691 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2692 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2693 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2694 | if ((flags & SigmaValue) == 0) |
| 2695 | geometry_info.sigma=1.0; |
| 2696 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2697 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2698 | break; |
| 2699 | } |
| 2700 | if (LocaleCompare("shadow",option+1) == 0) |
| 2701 | { |
| 2702 | /* |
| 2703 | Shadow image. |
| 2704 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2705 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2706 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2707 | if ((flags & SigmaValue) == 0) |
| 2708 | geometry_info.sigma=1.0; |
| 2709 | if ((flags & XiValue) == 0) |
| 2710 | geometry_info.xi=4.0; |
| 2711 | if ((flags & PsiValue) == 0) |
| 2712 | geometry_info.psi=4.0; |
| 2713 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
cristy | eb6e658 | 2011-12-09 09:14:23 +0000 | [diff] [blame] | 2714 | geometry_info.sigma,(*image)->bias,(ssize_t) |
| 2715 | ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5), |
| 2716 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2717 | break; |
| 2718 | } |
| 2719 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2720 | { |
| 2721 | /* |
| 2722 | Sharpen image. |
| 2723 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2724 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2725 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2726 | if ((flags & SigmaValue) == 0) |
| 2727 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2728 | if ((flags & XiValue) == 0) |
| 2729 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2730 | mogrify_image=SharpenImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2731 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2732 | break; |
| 2733 | } |
| 2734 | if (LocaleCompare("shave",option+1) == 0) |
| 2735 | { |
| 2736 | /* |
| 2737 | Shave the image edges. |
| 2738 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2739 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2740 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2741 | mogrify_image=ShaveImage(*image,&geometry,exception); |
| 2742 | break; |
| 2743 | } |
| 2744 | if (LocaleCompare("shear",option+1) == 0) |
| 2745 | { |
| 2746 | /* |
| 2747 | Shear image. |
| 2748 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2749 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2750 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2751 | if ((flags & SigmaValue) == 0) |
| 2752 | geometry_info.sigma=geometry_info.rho; |
| 2753 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2754 | geometry_info.sigma,exception); |
| 2755 | break; |
| 2756 | } |
| 2757 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2758 | { |
| 2759 | /* |
| 2760 | Sigmoidal non-linearity contrast control. |
| 2761 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2762 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2763 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2764 | if ((flags & SigmaValue) == 0) |
| 2765 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 2766 | if ((flags & PercentValue) != 0) |
| 2767 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2768 | 100.0; |
cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 2769 | (void) SigmoidalContrastImage(*image,(*option == '-') ? |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2770 | MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma, |
| 2771 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2772 | break; |
| 2773 | } |
| 2774 | if (LocaleCompare("sketch",option+1) == 0) |
| 2775 | { |
| 2776 | /* |
| 2777 | Sketch image. |
| 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=ParseGeometry(argv[i+1],&geometry_info); |
| 2781 | if ((flags & SigmaValue) == 0) |
| 2782 | geometry_info.sigma=1.0; |
| 2783 | mogrify_image=SketchImage(*image,geometry_info.rho, |
cristy | f7ef025 | 2011-09-09 14:50:06 +0000 | [diff] [blame] | 2784 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2785 | break; |
| 2786 | } |
| 2787 | if (LocaleCompare("solarize",option+1) == 0) |
| 2788 | { |
| 2789 | double |
| 2790 | threshold; |
| 2791 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2792 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2793 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 2794 | 1.0); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 2795 | (void) SolarizeImage(*image,threshold,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2796 | break; |
| 2797 | } |
| 2798 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2799 | { |
| 2800 | SparseColorMethod |
| 2801 | method; |
| 2802 | |
| 2803 | char |
| 2804 | *arguments; |
| 2805 | |
| 2806 | /* |
| 2807 | Sparse Color Interpolated Gradient |
| 2808 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2809 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2810 | method=(SparseColorMethod) ParseCommandOption( |
| 2811 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2812 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2813 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2814 | if (arguments == (char *) NULL) |
| 2815 | break; |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 2816 | mogrify_image=SparseColorOption(*image,method,arguments, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2817 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2818 | arguments=DestroyString(arguments); |
| 2819 | break; |
| 2820 | } |
| 2821 | if (LocaleCompare("splice",option+1) == 0) |
| 2822 | { |
| 2823 | /* |
| 2824 | Splice a solid color into the image. |
| 2825 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2826 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2827 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 2828 | mogrify_image=SpliceImage(*image,&geometry,exception); |
| 2829 | break; |
| 2830 | } |
| 2831 | if (LocaleCompare("spread",option+1) == 0) |
| 2832 | { |
| 2833 | /* |
| 2834 | Spread an image. |
| 2835 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2836 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2837 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame] | 2838 | mogrify_image=SpreadImage(*image,geometry_info.rho, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2839 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2840 | break; |
| 2841 | } |
| 2842 | if (LocaleCompare("statistic",option+1) == 0) |
| 2843 | { |
| 2844 | StatisticType |
| 2845 | type; |
| 2846 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2847 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2848 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
| 2849 | MagickFalse,argv[i+1]); |
| 2850 | (void) ParseGeometry(argv[i+2],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2851 | mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho, |
| 2852 | (size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2853 | break; |
| 2854 | } |
| 2855 | if (LocaleCompare("stretch",option+1) == 0) |
| 2856 | { |
| 2857 | if (*option == '+') |
| 2858 | { |
| 2859 | draw_info->stretch=UndefinedStretch; |
| 2860 | break; |
| 2861 | } |
| 2862 | draw_info->stretch=(StretchType) ParseCommandOption( |
| 2863 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2864 | break; |
| 2865 | } |
| 2866 | if (LocaleCompare("strip",option+1) == 0) |
| 2867 | { |
| 2868 | /* |
| 2869 | Strip image of profiles and comments. |
| 2870 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2871 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 2872 | (void) StripImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2873 | break; |
| 2874 | } |
| 2875 | if (LocaleCompare("stroke",option+1) == 0) |
| 2876 | { |
| 2877 | ExceptionInfo |
| 2878 | *sans; |
| 2879 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2880 | PixelInfo |
| 2881 | color; |
| 2882 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2883 | if (*option == '+') |
| 2884 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2885 | (void) QueryColorCompliance("none",AllCompliance, |
| 2886 | &draw_info->stroke,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2887 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2888 | draw_info->stroke_pattern=DestroyImage( |
| 2889 | draw_info->stroke_pattern); |
| 2890 | break; |
| 2891 | } |
| 2892 | sans=AcquireExceptionInfo(); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2893 | status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2894 | sans=DestroyExceptionInfo(sans); |
| 2895 | if (status == MagickFalse) |
| 2896 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2897 | exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2898 | else |
| 2899 | draw_info->stroke=color; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2900 | break; |
| 2901 | } |
| 2902 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2903 | { |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2904 | draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2905 | break; |
| 2906 | } |
| 2907 | if (LocaleCompare("style",option+1) == 0) |
| 2908 | { |
| 2909 | if (*option == '+') |
| 2910 | { |
| 2911 | draw_info->style=UndefinedStyle; |
| 2912 | break; |
| 2913 | } |
| 2914 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 2915 | MagickFalse,argv[i+1]); |
| 2916 | break; |
| 2917 | } |
| 2918 | if (LocaleCompare("swirl",option+1) == 0) |
| 2919 | { |
| 2920 | /* |
| 2921 | Swirl image. |
| 2922 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2923 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2924 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 76f512e | 2011-09-12 01:26:56 +0000 | [diff] [blame] | 2925 | mogrify_image=SwirlImage(*image,geometry_info.rho, |
| 2926 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2927 | break; |
| 2928 | } |
| 2929 | break; |
| 2930 | } |
| 2931 | case 't': |
| 2932 | { |
| 2933 | if (LocaleCompare("threshold",option+1) == 0) |
| 2934 | { |
| 2935 | double |
| 2936 | threshold; |
| 2937 | |
| 2938 | /* |
| 2939 | Threshold image. |
| 2940 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2941 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2942 | if (*option == '+') |
anthony | 247a86d | 2011-05-03 13:18:18 +0000 | [diff] [blame] | 2943 | threshold=(double) QuantumRange/2; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2944 | else |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2945 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 2946 | 1.0); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 2947 | (void) BilevelImage(*image,threshold,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2948 | break; |
| 2949 | } |
| 2950 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2951 | { |
| 2952 | /* |
| 2953 | Thumbnail image. |
| 2954 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2955 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2956 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2957 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2958 | exception); |
| 2959 | break; |
| 2960 | } |
| 2961 | if (LocaleCompare("tile",option+1) == 0) |
| 2962 | { |
| 2963 | if (*option == '+') |
| 2964 | { |
| 2965 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2966 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2967 | break; |
| 2968 | } |
| 2969 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2970 | exception); |
| 2971 | break; |
| 2972 | } |
| 2973 | if (LocaleCompare("tint",option+1) == 0) |
| 2974 | { |
| 2975 | /* |
| 2976 | Tint the image. |
| 2977 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2978 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2979 | mogrify_image=TintImage(*image,argv[i+1],&fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2980 | break; |
| 2981 | } |
| 2982 | if (LocaleCompare("transform",option+1) == 0) |
| 2983 | { |
| 2984 | /* |
| 2985 | Affine transform image. |
| 2986 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2987 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2988 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
| 2989 | exception); |
| 2990 | break; |
| 2991 | } |
| 2992 | if (LocaleCompare("transparent",option+1) == 0) |
| 2993 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2994 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2995 | target; |
| 2996 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2997 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2998 | (void) QueryColorCompliance(argv[i+1],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2999 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3000 | (void) TransparentPaintImage(*image,&target,(Quantum) |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 3001 | TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue, |
cristy | 82d7af5 | 2011-10-16 16:26:41 +0000 | [diff] [blame] | 3002 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3003 | break; |
| 3004 | } |
| 3005 | if (LocaleCompare("transpose",option+1) == 0) |
| 3006 | { |
| 3007 | /* |
| 3008 | Transpose image scanlines. |
| 3009 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3010 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3011 | mogrify_image=TransposeImage(*image,exception); |
| 3012 | break; |
| 3013 | } |
| 3014 | if (LocaleCompare("transverse",option+1) == 0) |
| 3015 | { |
| 3016 | /* |
| 3017 | Transverse image scanlines. |
| 3018 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3019 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3020 | mogrify_image=TransverseImage(*image,exception); |
| 3021 | break; |
| 3022 | } |
| 3023 | if (LocaleCompare("treedepth",option+1) == 0) |
| 3024 | { |
| 3025 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
| 3026 | break; |
| 3027 | } |
| 3028 | if (LocaleCompare("trim",option+1) == 0) |
| 3029 | { |
| 3030 | /* |
| 3031 | Trim image. |
| 3032 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3033 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3034 | mogrify_image=TrimImage(*image,exception); |
| 3035 | break; |
| 3036 | } |
| 3037 | if (LocaleCompare("type",option+1) == 0) |
| 3038 | { |
| 3039 | ImageType |
| 3040 | type; |
| 3041 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3042 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3043 | if (*option == '+') |
| 3044 | type=UndefinedType; |
| 3045 | else |
| 3046 | type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 3047 | argv[i+1]); |
| 3048 | (*image)->type=UndefinedType; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3049 | (void) SetImageType(*image,type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3050 | break; |
| 3051 | } |
| 3052 | break; |
| 3053 | } |
| 3054 | case 'u': |
| 3055 | { |
| 3056 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3057 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 3058 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 3059 | &draw_info->undercolor,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3060 | break; |
| 3061 | } |
| 3062 | if (LocaleCompare("unique",option+1) == 0) |
| 3063 | { |
| 3064 | if (*option == '+') |
| 3065 | { |
| 3066 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
| 3067 | break; |
| 3068 | } |
| 3069 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
| 3070 | (void) SetImageArtifact(*image,"verbose","true"); |
| 3071 | break; |
| 3072 | } |
| 3073 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3074 | { |
| 3075 | /* |
| 3076 | Unique image colors. |
| 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 | mogrify_image=UniqueImageColors(*image,exception); |
| 3080 | break; |
| 3081 | } |
| 3082 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3083 | { |
| 3084 | /* |
| 3085 | Unsharp mask image. |
| 3086 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3087 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3088 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3089 | if ((flags & SigmaValue) == 0) |
| 3090 | geometry_info.sigma=1.0; |
| 3091 | if ((flags & XiValue) == 0) |
| 3092 | geometry_info.xi=1.0; |
| 3093 | if ((flags & PsiValue) == 0) |
| 3094 | geometry_info.psi=0.05; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3095 | mogrify_image=UnsharpMaskImage(*image,geometry_info.rho, |
| 3096 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3097 | break; |
| 3098 | } |
| 3099 | break; |
| 3100 | } |
| 3101 | case 'v': |
| 3102 | { |
| 3103 | if (LocaleCompare("verbose",option+1) == 0) |
| 3104 | { |
| 3105 | (void) SetImageArtifact(*image,option+1, |
| 3106 | *option == '+' ? "false" : "true"); |
| 3107 | break; |
| 3108 | } |
| 3109 | if (LocaleCompare("vignette",option+1) == 0) |
| 3110 | { |
| 3111 | /* |
| 3112 | Vignette image. |
| 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 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3116 | if ((flags & SigmaValue) == 0) |
| 3117 | geometry_info.sigma=1.0; |
| 3118 | if ((flags & XiValue) == 0) |
| 3119 | geometry_info.xi=0.1*(*image)->columns; |
| 3120 | if ((flags & PsiValue) == 0) |
| 3121 | geometry_info.psi=0.1*(*image)->rows; |
| 3122 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
cristy | eb6e658 | 2011-12-09 09:14:23 +0000 | [diff] [blame] | 3123 | geometry_info.sigma,(*image)->bias,(ssize_t) |
| 3124 | ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5), |
| 3125 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3126 | break; |
| 3127 | } |
| 3128 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3129 | { |
| 3130 | if (*option == '+') |
| 3131 | { |
| 3132 | (void) SetImageVirtualPixelMethod(*image, |
| 3133 | UndefinedVirtualPixelMethod); |
| 3134 | break; |
| 3135 | } |
| 3136 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3137 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 3138 | argv[i+1])); |
| 3139 | break; |
| 3140 | } |
| 3141 | break; |
| 3142 | } |
| 3143 | case 'w': |
| 3144 | { |
| 3145 | if (LocaleCompare("wave",option+1) == 0) |
| 3146 | { |
| 3147 | /* |
| 3148 | Wave 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 | mogrify_image=WaveImage(*image,geometry_info.rho, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 3155 | geometry_info.sigma,interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3156 | break; |
| 3157 | } |
| 3158 | if (LocaleCompare("weight",option+1) == 0) |
| 3159 | { |
| 3160 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
| 3161 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3162 | draw_info->weight=0; |
| 3163 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3164 | draw_info->weight=700; |
| 3165 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3166 | if (draw_info->weight <= 800) |
| 3167 | draw_info->weight+=100; |
| 3168 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3169 | if (draw_info->weight >= 100) |
| 3170 | draw_info->weight-=100; |
| 3171 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3172 | draw_info->weight=400; |
| 3173 | break; |
| 3174 | } |
| 3175 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3176 | { |
| 3177 | /* |
| 3178 | White threshold image. |
| 3179 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3180 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3181 | (void) WhiteThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3182 | break; |
| 3183 | } |
| 3184 | break; |
| 3185 | } |
| 3186 | default: |
| 3187 | break; |
| 3188 | } |
| 3189 | /* |
| 3190 | Replace current image with any image that was generated |
| 3191 | */ |
| 3192 | if (mogrify_image != (Image *) NULL) |
| 3193 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3194 | i+=count; |
| 3195 | } |
| 3196 | if (region_image != (Image *) NULL) |
| 3197 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3198 | /* |
| 3199 | Composite transformed region onto image. |
| 3200 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3201 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3202 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3203 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 3204 | region_geometry.x,region_geometry.y,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3205 | *image=DestroyImage(*image); |
| 3206 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3207 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3208 | } |
| 3209 | /* |
| 3210 | Free resources. |
| 3211 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3212 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3213 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3214 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 82d7af5 | 2011-10-16 16:26:41 +0000 | [diff] [blame] | 3215 | status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3216 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3217 | } |
| 3218 | |
| 3219 | /* |
| 3220 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3221 | % % |
| 3222 | % % |
| 3223 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3224 | + 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] | 3225 | % % |
| 3226 | % % |
| 3227 | % % |
| 3228 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3229 | % |
| 3230 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3231 | % transforms include image scaling, image rotation, color reduction, and |
| 3232 | % others. The transmogrified image overwrites the original image. |
| 3233 | % |
| 3234 | % The format of the MogrifyImageCommand method is: |
| 3235 | % |
| 3236 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3237 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3238 | % |
| 3239 | % A description of each parameter follows: |
| 3240 | % |
| 3241 | % o image_info: the image info. |
| 3242 | % |
| 3243 | % o argc: the number of elements in the argument vector. |
| 3244 | % |
| 3245 | % o argv: A text array containing the command line arguments. |
| 3246 | % |
| 3247 | % o metadata: any metadata is returned here. |
| 3248 | % |
| 3249 | % o exception: return any errors or warnings in this structure. |
| 3250 | % |
| 3251 | */ |
| 3252 | |
| 3253 | static MagickBooleanType MogrifyUsage(void) |
| 3254 | { |
| 3255 | static const char |
| 3256 | *miscellaneous[]= |
| 3257 | { |
| 3258 | "-debug events display copious debugging information", |
| 3259 | "-help print program options", |
| 3260 | "-list type print a list of supported option arguments", |
| 3261 | "-log format format of debugging information", |
| 3262 | "-version print version information", |
| 3263 | (char *) NULL |
| 3264 | }, |
| 3265 | *operators[]= |
| 3266 | { |
| 3267 | "-adaptive-blur geometry", |
| 3268 | " adaptively blur pixels; decrease effect near edges", |
| 3269 | "-adaptive-resize geometry", |
| 3270 | " adaptively resize image using 'mesh' interpolation", |
| 3271 | "-adaptive-sharpen geometry", |
| 3272 | " adaptively sharpen pixels; increase effect near edges", |
| 3273 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3274 | " transparent, extract, background, or shape", |
| 3275 | "-annotate geometry text", |
| 3276 | " annotate the image with text", |
| 3277 | "-auto-gamma automagically adjust gamma level of image", |
| 3278 | "-auto-level automagically adjust color levels of image", |
| 3279 | "-auto-orient automagically orient (rotate) image", |
| 3280 | "-bench iterations measure performance", |
| 3281 | "-black-threshold value", |
| 3282 | " force all pixels below the threshold into black", |
| 3283 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3284 | "-blur geometry reduce image noise and reduce detail levels", |
| 3285 | "-border geometry surround image with a border of color", |
| 3286 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3287 | "-brightness-contrast geometry", |
| 3288 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3289 | "-cdl filename color correct with a color decision list", |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 3290 | "-charcoal geometry simulate a charcoal drawing", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3291 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3292 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3293 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3294 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3295 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3296 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3297 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3298 | "-contrast enhance or reduce the image contrast", |
| 3299 | "-contrast-stretch geometry", |
| 3300 | " improve contrast by `stretching' the intensity range", |
| 3301 | "-convolve coefficients", |
| 3302 | " apply a convolution kernel to the image", |
| 3303 | "-cycle amount cycle the image colormap", |
| 3304 | "-decipher filename convert cipher pixels to plain pixels", |
| 3305 | "-deskew threshold straighten an image", |
| 3306 | "-despeckle reduce the speckles within an image", |
| 3307 | "-distort method args", |
| 3308 | " distort images according to given method ad args", |
| 3309 | "-draw string annotate the image with a graphic primitive", |
| 3310 | "-edge radius apply a filter to detect edges in the image", |
| 3311 | "-encipher filename convert plain pixels to cipher pixels", |
| 3312 | "-emboss radius emboss an image", |
| 3313 | "-enhance apply a digital filter to enhance a noisy image", |
| 3314 | "-equalize perform histogram equalization to an image", |
| 3315 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3316 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3317 | "-extent geometry set the image size", |
| 3318 | "-extract geometry extract area from image", |
| 3319 | "-fft implements the discrete Fourier transform (DFT)", |
| 3320 | "-flip flip image vertically", |
| 3321 | "-floodfill geometry color", |
| 3322 | " floodfill the image with color", |
| 3323 | "-flop flop image horizontally", |
| 3324 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3325 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3326 | " apply function over image values", |
| 3327 | "-gamma value level of gamma correction", |
| 3328 | "-gaussian-blur geometry", |
| 3329 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3330 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3331 | "-identify identify the format and characteristics of the image", |
| 3332 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3333 | "-implode amount implode image pixels about the center", |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3334 | "-interpolative-resize geometry", |
| 3335 | " resize image using interpolation", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3336 | "-lat geometry local adaptive thresholding", |
| 3337 | "-layers method optimize, merge, or compare image layers", |
| 3338 | "-level value adjust the level of image contrast", |
| 3339 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3340 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3341 | "-linear-stretch geometry", |
| 3342 | " improve contrast by `stretching with saturation'", |
| 3343 | "-liquid-rescale geometry", |
| 3344 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3345 | "-median geometry apply a median filter to the image", |
glennrp | 30d2dc6 | 2011-06-25 03:17:16 +0000 | [diff] [blame] | 3346 | "-mode geometry make each pixel the 'predominant color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3347 | "-modulate value vary the brightness, saturation, and hue", |
| 3348 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3349 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3350 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3351 | "-motion-blur geometry", |
| 3352 | " simulate motion blur", |
| 3353 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3354 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3355 | "-normalize transform image to span the full range of colors", |
| 3356 | "-opaque color change this color to the fill color", |
| 3357 | "-ordered-dither NxN", |
| 3358 | " add a noise pattern to the image with specific", |
| 3359 | " amplitudes", |
| 3360 | "-paint radius simulate an oil painting", |
| 3361 | "-polaroid angle simulate a Polaroid picture", |
| 3362 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3363 | "-profile filename add, delete, or apply an image profile", |
| 3364 | "-quantize colorspace reduce colors in this colorspace", |
| 3365 | "-radial-blur angle radial blur the image", |
| 3366 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3367 | "-random-threshold low,high", |
| 3368 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3369 | "-region geometry apply options to a portion of the image", |
| 3370 | "-render render vector graphics", |
| 3371 | "-repage geometry size and location of an image canvas", |
| 3372 | "-resample geometry change the resolution of an image", |
| 3373 | "-resize geometry resize the image", |
| 3374 | "-roll geometry roll an image vertically or horizontally", |
| 3375 | "-rotate degrees apply Paeth rotation to the image", |
| 3376 | "-sample geometry scale image with pixel sampling", |
| 3377 | "-scale geometry scale the image", |
| 3378 | "-segment values segment an image", |
| 3379 | "-selective-blur geometry", |
| 3380 | " selectively blur pixels within a contrast threshold", |
| 3381 | "-sepia-tone threshold", |
| 3382 | " simulate a sepia-toned photo", |
| 3383 | "-set property value set an image property", |
| 3384 | "-shade degrees shade the image using a distant light source", |
| 3385 | "-shadow geometry simulate an image shadow", |
| 3386 | "-sharpen geometry sharpen the image", |
| 3387 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3388 | "-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] | 3389 | "-sigmoidal-contrast geometry", |
| 3390 | " increase the contrast without saturating highlights or shadows", |
| 3391 | "-sketch geometry simulate a pencil sketch", |
| 3392 | "-solarize threshold negate all pixels above the threshold level", |
| 3393 | "-sparse-color method args", |
| 3394 | " fill in a image based on a few color points", |
| 3395 | "-splice geometry splice the background color into the image", |
| 3396 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3397 | "-statistic type radius", |
| 3398 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3399 | "-strip strip image of all profiles and comments", |
| 3400 | "-swirl degrees swirl image pixels about the center", |
| 3401 | "-threshold value threshold the image", |
| 3402 | "-thumbnail geometry create a thumbnail of the image", |
| 3403 | "-tile filename tile image when filling a graphic primitive", |
| 3404 | "-tint value tint the image with the fill color", |
| 3405 | "-transform affine transform image", |
| 3406 | "-transparent color make this color transparent within the image", |
| 3407 | "-transpose flip image vertically and rotate 90 degrees", |
| 3408 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3409 | "-trim trim image edges", |
| 3410 | "-type type image type", |
| 3411 | "-unique-colors discard all but one of any pixel color", |
| 3412 | "-unsharp geometry sharpen the image", |
| 3413 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3414 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3415 | "-white-threshold value", |
| 3416 | " force all pixels above the threshold into white", |
| 3417 | (char *) NULL |
| 3418 | }, |
| 3419 | *sequence_operators[]= |
| 3420 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3421 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3422 | "-clut apply a color lookup table to the image", |
| 3423 | "-coalesce merge a sequence of images", |
| 3424 | "-combine combine a sequence of images", |
| 3425 | "-composite composite image", |
| 3426 | "-crop geometry cut out a rectangular region of the image", |
| 3427 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3428 | "-evaluate-sequence operator", |
| 3429 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3430 | "-flatten flatten a sequence of images", |
| 3431 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3432 | "-hald-clut apply a Hald color lookup table to the image", |
| 3433 | "-morph value morph an image sequence", |
| 3434 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3435 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3436 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3437 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3438 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3439 | "-write filename write images to this file", |
| 3440 | (char *) NULL |
| 3441 | }, |
| 3442 | *settings[]= |
| 3443 | { |
| 3444 | "-adjoin join images into a single multi-image file", |
| 3445 | "-affine matrix affine transform matrix", |
| 3446 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3447 | "-antialias remove pixel-aliasing", |
| 3448 | "-authenticate password", |
| 3449 | " decipher image with this password", |
| 3450 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3451 | "-background color background color", |
| 3452 | "-bias value add bias when convolving an image", |
| 3453 | "-black-point-compensation", |
| 3454 | " use black point compensation", |
| 3455 | "-blue-primary point chromaticity blue primary point", |
| 3456 | "-bordercolor color border color", |
| 3457 | "-caption string assign a caption to an image", |
| 3458 | "-channel type apply option to select image channels", |
| 3459 | "-colors value preferred number of colors in the image", |
| 3460 | "-colorspace type alternate image colorspace", |
| 3461 | "-comment string annotate image with comment", |
| 3462 | "-compose operator set image composite operator", |
| 3463 | "-compress type type of pixel compression when writing the image", |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3464 | "-define format:option=value", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3465 | " define one or more image format options", |
| 3466 | "-delay value display the next image after pausing", |
| 3467 | "-density geometry horizontal and vertical density of the image", |
| 3468 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3469 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3470 | "-display server get image or font from this X server", |
| 3471 | "-dispose method layer disposal method", |
| 3472 | "-dither method apply error diffusion to image", |
| 3473 | "-encoding type text encoding type", |
| 3474 | "-endian type endianness (MSB or LSB) of the image", |
| 3475 | "-family name render text with this font family", |
| 3476 | "-fill color color to use when filling a graphic primitive", |
| 3477 | "-filter type use this filter when resizing an image", |
| 3478 | "-font name render text with this font", |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3479 | "-format \"string\" output formatted image characteristics", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3480 | "-fuzz distance colors within this distance are considered equal", |
| 3481 | "-gravity type horizontal and vertical text placement", |
| 3482 | "-green-primary point chromaticity green primary point", |
| 3483 | "-intent type type of rendering intent when managing the image color", |
| 3484 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3485 | "-interline-spacing value", |
| 3486 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3487 | "-interpolate method pixel color interpolation method", |
| 3488 | "-interword-spacing value", |
| 3489 | " set the space between two words", |
| 3490 | "-kerning value set the space between two letters", |
| 3491 | "-label string assign a label to an image", |
| 3492 | "-limit type value pixel cache resource limit", |
| 3493 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3494 | "-mask filename associate a mask with the image", |
| 3495 | "-mattecolor color frame color", |
| 3496 | "-monitor monitor progress", |
| 3497 | "-orient type image orientation", |
| 3498 | "-page geometry size and location of an image canvas (setting)", |
| 3499 | "-ping efficiently determine image attributes", |
| 3500 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3501 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3502 | "-preview type image preview type", |
| 3503 | "-quality value JPEG/MIFF/PNG compression level", |
| 3504 | "-quiet suppress all warning messages", |
| 3505 | "-red-primary point chromaticity red primary point", |
| 3506 | "-regard-warnings pay attention to warning messages", |
| 3507 | "-remap filename transform image colors to match this set of colors", |
| 3508 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3509 | "-sampling-factor geometry", |
| 3510 | " horizontal and vertical sampling factor", |
| 3511 | "-scene value image scene number", |
| 3512 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3513 | "-size geometry width and height of image", |
| 3514 | "-stretch type render text with this font stretch", |
| 3515 | "-stroke color graphic primitive stroke color", |
| 3516 | "-strokewidth value graphic primitive stroke width", |
| 3517 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3518 | "-synchronize synchronize image to storage device", |
| 3519 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3520 | "-texture filename name of texture to tile onto the image background", |
| 3521 | "-tile-offset geometry", |
| 3522 | " tile offset", |
| 3523 | "-treedepth value color tree depth", |
| 3524 | "-transparent-color color", |
| 3525 | " transparent color", |
| 3526 | "-undercolor color annotation bounding box color", |
| 3527 | "-units type the units of image resolution", |
| 3528 | "-verbose print detailed information about the image", |
| 3529 | "-view FlashPix viewing transforms", |
| 3530 | "-virtual-pixel method", |
| 3531 | " virtual pixel access method", |
| 3532 | "-weight type render text with this font weight", |
| 3533 | "-white-point point chromaticity white point", |
| 3534 | (char *) NULL |
| 3535 | }, |
| 3536 | *stack_operators[]= |
| 3537 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3538 | "-delete indexes delete the image from the image sequence", |
| 3539 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3540 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3541 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3542 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3543 | "-swap indexes swap two images in the image sequence", |
| 3544 | (char *) NULL |
| 3545 | }; |
| 3546 | |
| 3547 | const char |
| 3548 | **p; |
| 3549 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3550 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3551 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3552 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3553 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3554 | GetClientName()); |
| 3555 | (void) printf("\nImage Settings:\n"); |
| 3556 | for (p=settings; *p != (char *) NULL; p++) |
| 3557 | (void) printf(" %s\n",*p); |
| 3558 | (void) printf("\nImage Operators:\n"); |
| 3559 | for (p=operators; *p != (char *) NULL; p++) |
| 3560 | (void) printf(" %s\n",*p); |
| 3561 | (void) printf("\nImage Sequence Operators:\n"); |
| 3562 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3563 | (void) printf(" %s\n",*p); |
| 3564 | (void) printf("\nImage Stack Operators:\n"); |
| 3565 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3566 | (void) printf(" %s\n",*p); |
| 3567 | (void) printf("\nMiscellaneous Options:\n"); |
| 3568 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3569 | (void) printf(" %s\n",*p); |
| 3570 | (void) printf( |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3571 | "\nBy default, the image format of 'file' is determined by its magic\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3572 | (void) printf( |
| 3573 | "number. To specify a particular image format, precede the filename\n"); |
| 3574 | (void) printf( |
| 3575 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3576 | (void) printf( |
| 3577 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3578 | (void) printf("'-' for standard input or output.\n"); |
| 3579 | return(MagickFalse); |
| 3580 | } |
| 3581 | |
| 3582 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3583 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3584 | { |
| 3585 | #define DestroyMogrify() \ |
| 3586 | { \ |
| 3587 | if (format != (char *) NULL) \ |
| 3588 | format=DestroyString(format); \ |
| 3589 | if (path != (char *) NULL) \ |
| 3590 | path=DestroyString(path); \ |
| 3591 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3592 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3593 | argv[i]=DestroyString(argv[i]); \ |
| 3594 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3595 | } |
| 3596 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3597 | { \ |
| 3598 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3599 | option); \ |
| 3600 | DestroyMogrify(); \ |
| 3601 | return(MagickFalse); \ |
| 3602 | } |
| 3603 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3604 | { \ |
| 3605 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3606 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3607 | DestroyMogrify(); \ |
| 3608 | return(MagickFalse); \ |
| 3609 | } |
| 3610 | |
| 3611 | char |
| 3612 | *format, |
| 3613 | *option, |
| 3614 | *path; |
| 3615 | |
| 3616 | Image |
| 3617 | *image; |
| 3618 | |
| 3619 | ImageStack |
| 3620 | image_stack[MaxImageStackDepth+1]; |
| 3621 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3622 | MagickBooleanType |
| 3623 | global_colormap; |
| 3624 | |
| 3625 | MagickBooleanType |
| 3626 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3627 | pend, |
| 3628 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3629 | |
| 3630 | MagickStatusType |
| 3631 | status; |
| 3632 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3633 | register ssize_t |
| 3634 | i; |
| 3635 | |
| 3636 | ssize_t |
| 3637 | j, |
| 3638 | k; |
| 3639 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3640 | /* |
| 3641 | Set defaults. |
| 3642 | */ |
| 3643 | assert(image_info != (ImageInfo *) NULL); |
| 3644 | assert(image_info->signature == MagickSignature); |
| 3645 | if (image_info->debug != MagickFalse) |
| 3646 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3647 | assert(exception != (ExceptionInfo *) NULL); |
| 3648 | if (argc == 2) |
| 3649 | { |
| 3650 | option=argv[1]; |
| 3651 | if ((LocaleCompare("version",option+1) == 0) || |
| 3652 | (LocaleCompare("-version",option+1) == 0)) |
| 3653 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3654 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3655 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 3656 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 3657 | GetMagickCopyright()); |
| 3658 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 3659 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3660 | return(MagickFalse); |
| 3661 | } |
| 3662 | } |
| 3663 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3664 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3665 | format=(char *) NULL; |
| 3666 | path=(char *) NULL; |
| 3667 | global_colormap=MagickFalse; |
| 3668 | k=0; |
| 3669 | j=1; |
| 3670 | NewImageStack(); |
| 3671 | option=(char *) NULL; |
| 3672 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3673 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3674 | status=MagickTrue; |
| 3675 | /* |
| 3676 | Parse command line. |
| 3677 | */ |
| 3678 | ReadCommandlLine(argc,&argv); |
| 3679 | status=ExpandFilenames(&argc,&argv); |
| 3680 | if (status == MagickFalse) |
| 3681 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3682 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3683 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3684 | { |
| 3685 | option=argv[i]; |
| 3686 | if (LocaleCompare(option,"(") == 0) |
| 3687 | { |
| 3688 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3689 | if (k == MaxImageStackDepth) |
| 3690 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3691 | option); |
| 3692 | PushImageStack(); |
| 3693 | continue; |
| 3694 | } |
| 3695 | if (LocaleCompare(option,")") == 0) |
| 3696 | { |
| 3697 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3698 | if (k == 0) |
| 3699 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3700 | PopImageStack(); |
| 3701 | continue; |
| 3702 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3703 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3704 | { |
| 3705 | char |
| 3706 | backup_filename[MaxTextExtent], |
| 3707 | *filename; |
| 3708 | |
| 3709 | Image |
| 3710 | *images; |
| 3711 | |
| 3712 | /* |
| 3713 | Option is a file name: begin by reading image from specified file. |
| 3714 | */ |
| 3715 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3716 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3717 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3718 | filename=argv[++i]; |
| 3719 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 3720 | images=ReadImages(image_info,exception); |
| 3721 | status&=(images != (Image *) NULL) && |
| 3722 | (exception->severity < ErrorException); |
| 3723 | if (images == (Image *) NULL) |
| 3724 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3725 | if (format != (char *) NULL) |
| 3726 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3727 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3728 | if (path != (char *) NULL) |
| 3729 | { |
| 3730 | GetPathComponent(option,TailPath,filename); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3731 | (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3732 | path,*DirectorySeparator,filename); |
| 3733 | } |
| 3734 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3735 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3736 | AppendImageStack(images); |
| 3737 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3738 | if (global_colormap != MagickFalse) |
| 3739 | { |
| 3740 | QuantizeInfo |
| 3741 | *quantize_info; |
| 3742 | |
| 3743 | quantize_info=AcquireQuantizeInfo(image_info); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3744 | (void) RemapImages(quantize_info,images,(Image *) NULL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3745 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3746 | } |
| 3747 | *backup_filename='\0'; |
| 3748 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3749 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3750 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3751 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3752 | i; |
| 3753 | |
| 3754 | /* |
| 3755 | Rename image file as backup. |
| 3756 | */ |
| 3757 | (void) CopyMagickString(backup_filename,image->filename, |
| 3758 | MaxTextExtent); |
| 3759 | for (i=0; i < 6; i++) |
| 3760 | { |
| 3761 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3762 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3763 | break; |
| 3764 | } |
| 3765 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
cristy | 320684d | 2011-09-23 14:55:47 +0000 | [diff] [blame] | 3766 | (rename_utf8(image->filename,backup_filename) != 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3767 | *backup_filename='\0'; |
| 3768 | } |
| 3769 | /* |
| 3770 | Write transmogrified image to disk. |
| 3771 | */ |
| 3772 | image_info->synchronize=MagickTrue; |
| 3773 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3774 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 3775 | (void) remove_utf8(backup_filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3776 | RemoveAllImageStack(); |
| 3777 | continue; |
| 3778 | } |
| 3779 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3780 | switch (*(option+1)) |
| 3781 | { |
| 3782 | case 'a': |
| 3783 | { |
| 3784 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3785 | { |
| 3786 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3787 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3788 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3789 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3790 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3791 | break; |
| 3792 | } |
| 3793 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3794 | { |
| 3795 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3796 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3797 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3798 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3799 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3800 | break; |
| 3801 | } |
| 3802 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3803 | { |
| 3804 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3805 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3806 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3807 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3808 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3809 | break; |
| 3810 | } |
| 3811 | if (LocaleCompare("affine",option+1) == 0) |
| 3812 | { |
| 3813 | if (*option == '+') |
| 3814 | break; |
| 3815 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3816 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3817 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3818 | break; |
| 3819 | } |
| 3820 | if (LocaleCompare("alpha",option+1) == 0) |
| 3821 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3822 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3823 | type; |
| 3824 | |
| 3825 | if (*option == '+') |
| 3826 | break; |
| 3827 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3828 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3829 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3830 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3831 | if (type < 0) |
| 3832 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3833 | argv[i]); |
| 3834 | break; |
| 3835 | } |
| 3836 | if (LocaleCompare("annotate",option+1) == 0) |
| 3837 | { |
| 3838 | if (*option == '+') |
| 3839 | break; |
| 3840 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3841 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3842 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3843 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3844 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3845 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3846 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3847 | i++; |
| 3848 | break; |
| 3849 | } |
| 3850 | if (LocaleCompare("antialias",option+1) == 0) |
| 3851 | break; |
| 3852 | if (LocaleCompare("append",option+1) == 0) |
| 3853 | break; |
| 3854 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3855 | { |
| 3856 | if (*option == '+') |
| 3857 | break; |
| 3858 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3859 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3860 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3861 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3862 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3863 | break; |
| 3864 | } |
| 3865 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3866 | { |
| 3867 | if (*option == '+') |
| 3868 | break; |
| 3869 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3870 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3871 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3872 | break; |
| 3873 | } |
| 3874 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3875 | break; |
| 3876 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3877 | break; |
| 3878 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3879 | break; |
| 3880 | if (LocaleCompare("average",option+1) == 0) |
| 3881 | break; |
| 3882 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3883 | } |
| 3884 | case 'b': |
| 3885 | { |
| 3886 | if (LocaleCompare("background",option+1) == 0) |
| 3887 | { |
| 3888 | if (*option == '+') |
| 3889 | break; |
| 3890 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3891 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3892 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3893 | break; |
| 3894 | } |
| 3895 | if (LocaleCompare("bias",option+1) == 0) |
| 3896 | { |
| 3897 | if (*option == '+') |
| 3898 | break; |
| 3899 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3900 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3901 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3902 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3903 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3904 | break; |
| 3905 | } |
| 3906 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 3907 | break; |
| 3908 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 3909 | { |
| 3910 | if (*option == '+') |
| 3911 | break; |
| 3912 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3913 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3914 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3915 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3916 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3917 | break; |
| 3918 | } |
| 3919 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3920 | { |
| 3921 | if (*option == '+') |
| 3922 | break; |
| 3923 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3924 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3925 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3926 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3927 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3928 | break; |
| 3929 | } |
| 3930 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3931 | { |
| 3932 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3933 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3934 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3935 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3936 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3937 | break; |
| 3938 | } |
| 3939 | if (LocaleCompare("blur",option+1) == 0) |
| 3940 | { |
| 3941 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3942 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3943 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3944 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3945 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3946 | break; |
| 3947 | } |
| 3948 | if (LocaleCompare("border",option+1) == 0) |
| 3949 | { |
| 3950 | if (*option == '+') |
| 3951 | break; |
| 3952 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3953 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3954 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3955 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3956 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3957 | break; |
| 3958 | } |
| 3959 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3960 | { |
| 3961 | if (*option == '+') |
| 3962 | break; |
| 3963 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3964 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3965 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3966 | break; |
| 3967 | } |
| 3968 | if (LocaleCompare("box",option+1) == 0) |
| 3969 | { |
| 3970 | if (*option == '+') |
| 3971 | break; |
| 3972 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3973 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3974 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3975 | break; |
| 3976 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3977 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 3978 | { |
| 3979 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3980 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3981 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3982 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3983 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3984 | break; |
| 3985 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3986 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3987 | } |
| 3988 | case 'c': |
| 3989 | { |
| 3990 | if (LocaleCompare("cache",option+1) == 0) |
| 3991 | { |
| 3992 | if (*option == '+') |
| 3993 | break; |
| 3994 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3995 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3996 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3997 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3998 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3999 | break; |
| 4000 | } |
| 4001 | if (LocaleCompare("caption",option+1) == 0) |
| 4002 | { |
| 4003 | if (*option == '+') |
| 4004 | break; |
| 4005 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4006 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4007 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4008 | break; |
| 4009 | } |
| 4010 | if (LocaleCompare("channel",option+1) == 0) |
| 4011 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4012 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4013 | channel; |
| 4014 | |
| 4015 | if (*option == '+') |
| 4016 | break; |
| 4017 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4018 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4019 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4020 | channel=ParseChannelOption(argv[i]); |
| 4021 | if (channel < 0) |
| 4022 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 4023 | argv[i]); |
| 4024 | break; |
| 4025 | } |
| 4026 | if (LocaleCompare("cdl",option+1) == 0) |
| 4027 | { |
| 4028 | if (*option == '+') |
| 4029 | break; |
| 4030 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4031 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4032 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4033 | break; |
| 4034 | } |
| 4035 | if (LocaleCompare("charcoal",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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4043 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4044 | break; |
| 4045 | } |
| 4046 | if (LocaleCompare("chop",option+1) == 0) |
| 4047 | { |
| 4048 | if (*option == '+') |
| 4049 | break; |
| 4050 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4051 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4052 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4053 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4054 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4055 | break; |
| 4056 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4057 | if (LocaleCompare("clamp",option+1) == 0) |
| 4058 | break; |
| 4059 | if (LocaleCompare("clip",option+1) == 0) |
| 4060 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4061 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4062 | { |
| 4063 | if (*option == '+') |
| 4064 | break; |
| 4065 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4066 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4067 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4068 | break; |
| 4069 | } |
| 4070 | if (LocaleCompare("clut",option+1) == 0) |
| 4071 | break; |
| 4072 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4073 | break; |
| 4074 | if (LocaleCompare("colorize",option+1) == 0) |
| 4075 | { |
| 4076 | if (*option == '+') |
| 4077 | break; |
| 4078 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4079 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4080 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4081 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4082 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4083 | break; |
| 4084 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4085 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4086 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4087 | KernelInfo |
| 4088 | *kernel_info; |
| 4089 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4090 | if (*option == '+') |
| 4091 | break; |
| 4092 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4093 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4094 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4095 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4096 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4097 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4098 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4099 | break; |
| 4100 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4101 | if (LocaleCompare("colors",option+1) == 0) |
| 4102 | { |
| 4103 | if (*option == '+') |
| 4104 | break; |
| 4105 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4106 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4107 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4108 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4109 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4110 | break; |
| 4111 | } |
| 4112 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4113 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4114 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4115 | colorspace; |
| 4116 | |
| 4117 | if (*option == '+') |
| 4118 | break; |
| 4119 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4120 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4121 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4122 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4123 | argv[i]); |
| 4124 | if (colorspace < 0) |
| 4125 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4126 | argv[i]); |
| 4127 | break; |
| 4128 | } |
| 4129 | if (LocaleCompare("combine",option+1) == 0) |
| 4130 | break; |
| 4131 | if (LocaleCompare("comment",option+1) == 0) |
| 4132 | { |
| 4133 | if (*option == '+') |
| 4134 | break; |
| 4135 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4136 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4137 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4138 | break; |
| 4139 | } |
| 4140 | if (LocaleCompare("composite",option+1) == 0) |
| 4141 | break; |
| 4142 | if (LocaleCompare("compress",option+1) == 0) |
| 4143 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4144 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4145 | compress; |
| 4146 | |
| 4147 | if (*option == '+') |
| 4148 | break; |
| 4149 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4150 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4151 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4152 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4153 | argv[i]); |
| 4154 | if (compress < 0) |
| 4155 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4156 | argv[i]); |
| 4157 | break; |
| 4158 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4159 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4160 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4161 | if (LocaleCompare("contrast",option+1) == 0) |
| 4162 | break; |
| 4163 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4164 | { |
| 4165 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4166 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4167 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4168 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4169 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4170 | break; |
| 4171 | } |
| 4172 | if (LocaleCompare("convolve",option+1) == 0) |
| 4173 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4174 | KernelInfo |
| 4175 | *kernel_info; |
| 4176 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4177 | if (*option == '+') |
| 4178 | break; |
| 4179 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4180 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4181 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4182 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4183 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4184 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4185 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4186 | break; |
| 4187 | } |
| 4188 | if (LocaleCompare("crop",option+1) == 0) |
| 4189 | { |
| 4190 | if (*option == '+') |
| 4191 | break; |
| 4192 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4193 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4194 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4195 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4196 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4197 | break; |
| 4198 | } |
| 4199 | if (LocaleCompare("cycle",option+1) == 0) |
| 4200 | { |
| 4201 | if (*option == '+') |
| 4202 | break; |
| 4203 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4204 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4205 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4206 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4207 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4208 | break; |
| 4209 | } |
| 4210 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4211 | } |
| 4212 | case 'd': |
| 4213 | { |
| 4214 | if (LocaleCompare("decipher",option+1) == 0) |
| 4215 | { |
| 4216 | if (*option == '+') |
| 4217 | break; |
| 4218 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4219 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4220 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4221 | break; |
| 4222 | } |
| 4223 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4224 | break; |
| 4225 | if (LocaleCompare("debug",option+1) == 0) |
| 4226 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4227 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4228 | event; |
| 4229 | |
| 4230 | if (*option == '+') |
| 4231 | break; |
| 4232 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4233 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4234 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4235 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4236 | if (event < 0) |
| 4237 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4238 | argv[i]); |
| 4239 | (void) SetLogEventMask(argv[i]); |
| 4240 | break; |
| 4241 | } |
| 4242 | if (LocaleCompare("define",option+1) == 0) |
| 4243 | { |
| 4244 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4245 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4246 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4247 | if (*option == '+') |
| 4248 | { |
| 4249 | const char |
| 4250 | *define; |
| 4251 | |
| 4252 | define=GetImageOption(image_info,argv[i]); |
| 4253 | if (define == (const char *) NULL) |
| 4254 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4255 | break; |
| 4256 | } |
| 4257 | break; |
| 4258 | } |
| 4259 | if (LocaleCompare("delay",option+1) == 0) |
| 4260 | { |
| 4261 | if (*option == '+') |
| 4262 | break; |
| 4263 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4264 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4265 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4266 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4267 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4268 | break; |
| 4269 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4270 | if (LocaleCompare("delete",option+1) == 0) |
| 4271 | { |
| 4272 | if (*option == '+') |
| 4273 | break; |
| 4274 | i++; |
| 4275 | if (i == (ssize_t) (argc-1)) |
| 4276 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4277 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4278 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4279 | break; |
| 4280 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4281 | if (LocaleCompare("density",option+1) == 0) |
| 4282 | { |
| 4283 | if (*option == '+') |
| 4284 | break; |
| 4285 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4286 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4287 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4288 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4289 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4290 | break; |
| 4291 | } |
| 4292 | if (LocaleCompare("depth",option+1) == 0) |
| 4293 | { |
| 4294 | if (*option == '+') |
| 4295 | break; |
| 4296 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4297 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4298 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4299 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4300 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4301 | break; |
| 4302 | } |
| 4303 | if (LocaleCompare("deskew",option+1) == 0) |
| 4304 | { |
| 4305 | if (*option == '+') |
| 4306 | break; |
| 4307 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4308 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4309 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4310 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4311 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4312 | break; |
| 4313 | } |
| 4314 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4315 | break; |
| 4316 | if (LocaleCompare("dft",option+1) == 0) |
| 4317 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4318 | if (LocaleCompare("direction",option+1) == 0) |
| 4319 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4320 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4321 | direction; |
| 4322 | |
| 4323 | if (*option == '+') |
| 4324 | break; |
| 4325 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4326 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4327 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4328 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4329 | argv[i]); |
| 4330 | if (direction < 0) |
| 4331 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4332 | argv[i]); |
| 4333 | break; |
| 4334 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4335 | if (LocaleCompare("display",option+1) == 0) |
| 4336 | { |
| 4337 | if (*option == '+') |
| 4338 | break; |
| 4339 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4340 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4341 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4342 | break; |
| 4343 | } |
| 4344 | if (LocaleCompare("dispose",option+1) == 0) |
| 4345 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4346 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4347 | dispose; |
| 4348 | |
| 4349 | if (*option == '+') |
| 4350 | break; |
| 4351 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4352 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4353 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4354 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4355 | if (dispose < 0) |
| 4356 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4357 | argv[i]); |
| 4358 | break; |
| 4359 | } |
| 4360 | if (LocaleCompare("distort",option+1) == 0) |
| 4361 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4362 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4363 | op; |
| 4364 | |
| 4365 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4366 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4367 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4368 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4369 | if (op < 0) |
| 4370 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4371 | argv[i]); |
| 4372 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4373 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4374 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4375 | break; |
| 4376 | } |
| 4377 | if (LocaleCompare("dither",option+1) == 0) |
| 4378 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4379 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4380 | method; |
| 4381 | |
| 4382 | if (*option == '+') |
| 4383 | break; |
| 4384 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4385 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4386 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4387 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4388 | if (method < 0) |
| 4389 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4390 | argv[i]); |
| 4391 | break; |
| 4392 | } |
| 4393 | if (LocaleCompare("draw",option+1) == 0) |
| 4394 | { |
| 4395 | if (*option == '+') |
| 4396 | break; |
| 4397 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4398 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4399 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4400 | break; |
| 4401 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4402 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4403 | { |
| 4404 | if (*option == '+') |
| 4405 | break; |
| 4406 | i++; |
| 4407 | if (i == (ssize_t) (argc-1)) |
| 4408 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4409 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4410 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4411 | break; |
| 4412 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4413 | if (LocaleCompare("duration",option+1) == 0) |
| 4414 | { |
| 4415 | if (*option == '+') |
| 4416 | break; |
| 4417 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4418 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4419 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4420 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4421 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4422 | break; |
| 4423 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4424 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4425 | } |
| 4426 | case 'e': |
| 4427 | { |
| 4428 | if (LocaleCompare("edge",option+1) == 0) |
| 4429 | { |
| 4430 | if (*option == '+') |
| 4431 | break; |
| 4432 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4433 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4434 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4435 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4436 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4437 | break; |
| 4438 | } |
| 4439 | if (LocaleCompare("emboss",option+1) == 0) |
| 4440 | { |
| 4441 | if (*option == '+') |
| 4442 | break; |
| 4443 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4444 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4445 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4446 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4447 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4448 | break; |
| 4449 | } |
| 4450 | if (LocaleCompare("encipher",option+1) == 0) |
| 4451 | { |
| 4452 | if (*option == '+') |
| 4453 | break; |
| 4454 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4455 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4456 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4457 | break; |
| 4458 | } |
| 4459 | if (LocaleCompare("encoding",option+1) == 0) |
| 4460 | { |
| 4461 | if (*option == '+') |
| 4462 | break; |
| 4463 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4464 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4465 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4466 | break; |
| 4467 | } |
| 4468 | if (LocaleCompare("endian",option+1) == 0) |
| 4469 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4470 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4471 | endian; |
| 4472 | |
| 4473 | if (*option == '+') |
| 4474 | break; |
| 4475 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4476 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4477 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4478 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4479 | if (endian < 0) |
| 4480 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4481 | argv[i]); |
| 4482 | break; |
| 4483 | } |
| 4484 | if (LocaleCompare("enhance",option+1) == 0) |
| 4485 | break; |
| 4486 | if (LocaleCompare("equalize",option+1) == 0) |
| 4487 | break; |
| 4488 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4489 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4490 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4491 | op; |
| 4492 | |
| 4493 | if (*option == '+') |
| 4494 | break; |
| 4495 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4496 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4497 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4498 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4499 | if (op < 0) |
| 4500 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4501 | argv[i]); |
| 4502 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4503 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4504 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4505 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4506 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4507 | break; |
| 4508 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4509 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4510 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4511 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4512 | op; |
| 4513 | |
| 4514 | if (*option == '+') |
| 4515 | break; |
| 4516 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4517 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4518 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4519 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4520 | if (op < 0) |
| 4521 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4522 | argv[i]); |
| 4523 | break; |
| 4524 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4525 | if (LocaleCompare("extent",option+1) == 0) |
| 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); |
| 4532 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4533 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4534 | break; |
| 4535 | } |
| 4536 | if (LocaleCompare("extract",option+1) == 0) |
| 4537 | { |
| 4538 | if (*option == '+') |
| 4539 | break; |
| 4540 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4541 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4542 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4543 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4544 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4545 | break; |
| 4546 | } |
| 4547 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4548 | } |
| 4549 | case 'f': |
| 4550 | { |
| 4551 | if (LocaleCompare("family",option+1) == 0) |
| 4552 | { |
| 4553 | if (*option == '+') |
| 4554 | break; |
| 4555 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4556 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4557 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4558 | break; |
| 4559 | } |
| 4560 | if (LocaleCompare("fill",option+1) == 0) |
| 4561 | { |
| 4562 | if (*option == '+') |
| 4563 | break; |
| 4564 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4565 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4566 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4567 | break; |
| 4568 | } |
| 4569 | if (LocaleCompare("filter",option+1) == 0) |
| 4570 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4571 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4572 | filter; |
| 4573 | |
| 4574 | if (*option == '+') |
| 4575 | break; |
| 4576 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4577 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4578 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4579 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4580 | if (filter < 0) |
| 4581 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4582 | argv[i]); |
| 4583 | break; |
| 4584 | } |
| 4585 | if (LocaleCompare("flatten",option+1) == 0) |
| 4586 | break; |
| 4587 | if (LocaleCompare("flip",option+1) == 0) |
| 4588 | break; |
| 4589 | if (LocaleCompare("flop",option+1) == 0) |
| 4590 | break; |
| 4591 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4592 | { |
| 4593 | if (*option == '+') |
| 4594 | break; |
| 4595 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4596 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4597 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4598 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4599 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4600 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4601 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4602 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4603 | break; |
| 4604 | } |
| 4605 | if (LocaleCompare("font",option+1) == 0) |
| 4606 | { |
| 4607 | if (*option == '+') |
| 4608 | break; |
| 4609 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4610 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4611 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4612 | break; |
| 4613 | } |
| 4614 | if (LocaleCompare("format",option+1) == 0) |
| 4615 | { |
| 4616 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4617 | (void) CloneString(&format,(char *) NULL); |
| 4618 | if (*option == '+') |
| 4619 | break; |
| 4620 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4621 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4622 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4623 | (void) CloneString(&format,argv[i]); |
| 4624 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4625 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4626 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4627 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4628 | if (*image_info->magick == '\0') |
| 4629 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4630 | format); |
| 4631 | break; |
| 4632 | } |
| 4633 | if (LocaleCompare("frame",option+1) == 0) |
| 4634 | { |
| 4635 | if (*option == '+') |
| 4636 | break; |
| 4637 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4638 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4639 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4640 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4641 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4642 | break; |
| 4643 | } |
| 4644 | if (LocaleCompare("function",option+1) == 0) |
| 4645 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4646 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4647 | op; |
| 4648 | |
| 4649 | if (*option == '+') |
| 4650 | break; |
| 4651 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4652 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4653 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4654 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4655 | if (op < 0) |
| 4656 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4657 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4658 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4659 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4660 | break; |
| 4661 | } |
| 4662 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4663 | { |
| 4664 | if (*option == '+') |
| 4665 | break; |
| 4666 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4667 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4668 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4669 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4670 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4671 | break; |
| 4672 | } |
| 4673 | if (LocaleCompare("fx",option+1) == 0) |
| 4674 | { |
| 4675 | if (*option == '+') |
| 4676 | break; |
| 4677 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4678 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4679 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4680 | break; |
| 4681 | } |
| 4682 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4683 | } |
| 4684 | case 'g': |
| 4685 | { |
| 4686 | if (LocaleCompare("gamma",option+1) == 0) |
| 4687 | { |
| 4688 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4689 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4690 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4691 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4692 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4693 | break; |
| 4694 | } |
| 4695 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4696 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4697 | { |
| 4698 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4699 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4700 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4701 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4702 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4703 | break; |
| 4704 | } |
| 4705 | if (LocaleCompare("geometry",option+1) == 0) |
| 4706 | { |
| 4707 | if (*option == '+') |
| 4708 | break; |
| 4709 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4710 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4711 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4712 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4713 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4714 | break; |
| 4715 | } |
| 4716 | if (LocaleCompare("gravity",option+1) == 0) |
| 4717 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4718 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4719 | gravity; |
| 4720 | |
| 4721 | if (*option == '+') |
| 4722 | break; |
| 4723 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4724 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4725 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4726 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4727 | if (gravity < 0) |
| 4728 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4729 | argv[i]); |
| 4730 | break; |
| 4731 | } |
| 4732 | if (LocaleCompare("green-primary",option+1) == 0) |
| 4733 | { |
| 4734 | if (*option == '+') |
| 4735 | break; |
| 4736 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4737 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4738 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4739 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4740 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4741 | break; |
| 4742 | } |
| 4743 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4744 | } |
| 4745 | case 'h': |
| 4746 | { |
| 4747 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4748 | break; |
| 4749 | if ((LocaleCompare("help",option+1) == 0) || |
| 4750 | (LocaleCompare("-help",option+1) == 0)) |
| 4751 | return(MogrifyUsage()); |
| 4752 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4753 | } |
| 4754 | case 'i': |
| 4755 | { |
| 4756 | if (LocaleCompare("identify",option+1) == 0) |
| 4757 | break; |
| 4758 | if (LocaleCompare("idft",option+1) == 0) |
| 4759 | break; |
| 4760 | if (LocaleCompare("implode",option+1) == 0) |
| 4761 | { |
| 4762 | if (*option == '+') |
| 4763 | break; |
| 4764 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4765 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4766 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4767 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4768 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4769 | break; |
| 4770 | } |
| 4771 | if (LocaleCompare("intent",option+1) == 0) |
| 4772 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4773 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4774 | intent; |
| 4775 | |
| 4776 | if (*option == '+') |
| 4777 | break; |
| 4778 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4779 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4780 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4781 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4782 | if (intent < 0) |
| 4783 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4784 | argv[i]); |
| 4785 | break; |
| 4786 | } |
| 4787 | if (LocaleCompare("interlace",option+1) == 0) |
| 4788 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4789 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4790 | interlace; |
| 4791 | |
| 4792 | if (*option == '+') |
| 4793 | break; |
| 4794 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4795 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4796 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4797 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4798 | argv[i]); |
| 4799 | if (interlace < 0) |
| 4800 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4801 | argv[i]); |
| 4802 | break; |
| 4803 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4804 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4805 | { |
| 4806 | if (*option == '+') |
| 4807 | break; |
| 4808 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4809 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4810 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4811 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4812 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4813 | break; |
| 4814 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4815 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4816 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4817 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4818 | interpolate; |
| 4819 | |
| 4820 | if (*option == '+') |
| 4821 | break; |
| 4822 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4823 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4824 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4825 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4826 | argv[i]); |
| 4827 | if (interpolate < 0) |
| 4828 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4829 | argv[i]); |
| 4830 | break; |
| 4831 | } |
| 4832 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4833 | { |
| 4834 | if (*option == '+') |
| 4835 | break; |
| 4836 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4837 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4838 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4839 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4840 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4841 | break; |
| 4842 | } |
| 4843 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4844 | } |
| 4845 | case 'k': |
| 4846 | { |
| 4847 | if (LocaleCompare("kerning",option+1) == 0) |
| 4848 | { |
| 4849 | if (*option == '+') |
| 4850 | break; |
| 4851 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4852 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4853 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4854 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4855 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4856 | break; |
| 4857 | } |
| 4858 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4859 | } |
| 4860 | case 'l': |
| 4861 | { |
| 4862 | if (LocaleCompare("label",option+1) == 0) |
| 4863 | { |
| 4864 | if (*option == '+') |
| 4865 | break; |
| 4866 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4867 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4868 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4869 | break; |
| 4870 | } |
| 4871 | if (LocaleCompare("lat",option+1) == 0) |
| 4872 | { |
| 4873 | if (*option == '+') |
| 4874 | break; |
| 4875 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4876 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4877 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4878 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4879 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4880 | } |
| 4881 | if (LocaleCompare("layers",option+1) == 0) |
| 4882 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4883 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4884 | type; |
| 4885 | |
| 4886 | if (*option == '+') |
| 4887 | break; |
| 4888 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4889 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4890 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4891 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4892 | if (type < 0) |
| 4893 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4894 | argv[i]); |
| 4895 | break; |
| 4896 | } |
| 4897 | if (LocaleCompare("level",option+1) == 0) |
| 4898 | { |
| 4899 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4900 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4901 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4902 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4903 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4904 | break; |
| 4905 | } |
| 4906 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4907 | { |
| 4908 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4909 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4910 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4911 | break; |
| 4912 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4913 | if (LocaleCompare("limit",option+1) == 0) |
| 4914 | { |
| 4915 | char |
| 4916 | *p; |
| 4917 | |
| 4918 | double |
| 4919 | value; |
| 4920 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4921 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4922 | resource; |
| 4923 | |
| 4924 | if (*option == '+') |
| 4925 | break; |
| 4926 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4927 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4928 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4929 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4930 | argv[i]); |
| 4931 | if (resource < 0) |
| 4932 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4933 | argv[i]); |
| 4934 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4935 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4936 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 4937 | value=StringToDouble(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4938 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4939 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4940 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4941 | break; |
| 4942 | } |
| 4943 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4944 | { |
| 4945 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4946 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4947 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4948 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4949 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4950 | break; |
| 4951 | } |
| 4952 | if (LocaleCompare("list",option+1) == 0) |
| 4953 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4954 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4955 | list; |
| 4956 | |
| 4957 | if (*option == '+') |
| 4958 | break; |
| 4959 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4960 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4961 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4962 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4963 | if (list < 0) |
| 4964 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4965 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4966 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4967 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4968 | } |
| 4969 | if (LocaleCompare("log",option+1) == 0) |
| 4970 | { |
| 4971 | if (*option == '+') |
| 4972 | break; |
| 4973 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4974 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4975 | (strchr(argv[i],'%') == (char *) NULL)) |
| 4976 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4977 | break; |
| 4978 | } |
| 4979 | if (LocaleCompare("loop",option+1) == 0) |
| 4980 | { |
| 4981 | if (*option == '+') |
| 4982 | break; |
| 4983 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4984 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4985 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4986 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4987 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4988 | break; |
| 4989 | } |
| 4990 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4991 | } |
| 4992 | case 'm': |
| 4993 | { |
| 4994 | if (LocaleCompare("map",option+1) == 0) |
| 4995 | { |
| 4996 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 4997 | if (*option == '+') |
| 4998 | break; |
| 4999 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5000 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5001 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5002 | break; |
| 5003 | } |
| 5004 | if (LocaleCompare("mask",option+1) == 0) |
| 5005 | { |
| 5006 | if (*option == '+') |
| 5007 | break; |
| 5008 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5009 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5010 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5011 | break; |
| 5012 | } |
| 5013 | if (LocaleCompare("matte",option+1) == 0) |
| 5014 | break; |
| 5015 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 5016 | { |
| 5017 | if (*option == '+') |
| 5018 | break; |
| 5019 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5020 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5021 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5022 | break; |
| 5023 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5024 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5025 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5026 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5027 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5028 | if (LocaleCompare("modulate",option+1) == 0) |
| 5029 | { |
| 5030 | if (*option == '+') |
| 5031 | break; |
| 5032 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5033 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5034 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5035 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5036 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5037 | break; |
| 5038 | } |
| 5039 | if (LocaleCompare("median",option+1) == 0) |
| 5040 | { |
| 5041 | if (*option == '+') |
| 5042 | break; |
| 5043 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5044 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5045 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5046 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5047 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5048 | break; |
| 5049 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5050 | if (LocaleCompare("mode",option+1) == 0) |
| 5051 | { |
| 5052 | if (*option == '+') |
| 5053 | break; |
| 5054 | i++; |
| 5055 | if (i == (ssize_t) argc) |
| 5056 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5057 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5058 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5059 | break; |
| 5060 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5061 | if (LocaleCompare("monitor",option+1) == 0) |
| 5062 | break; |
| 5063 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5064 | break; |
| 5065 | if (LocaleCompare("morph",option+1) == 0) |
| 5066 | { |
| 5067 | if (*option == '+') |
| 5068 | break; |
| 5069 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5070 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5071 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5072 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5073 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5074 | break; |
| 5075 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5076 | if (LocaleCompare("morphology",option+1) == 0) |
| 5077 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5078 | char |
| 5079 | token[MaxTextExtent]; |
| 5080 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5081 | KernelInfo |
| 5082 | *kernel_info; |
| 5083 | |
| 5084 | ssize_t |
| 5085 | op; |
| 5086 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5087 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5088 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5089 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5090 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5091 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5092 | if (op < 0) |
| 5093 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5094 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5095 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5096 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5097 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5098 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5099 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5100 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5101 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5102 | break; |
| 5103 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5104 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5105 | break; |
| 5106 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5107 | { |
| 5108 | if (*option == '+') |
| 5109 | break; |
| 5110 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5111 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5112 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5113 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5114 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5115 | break; |
| 5116 | } |
| 5117 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5118 | } |
| 5119 | case 'n': |
| 5120 | { |
| 5121 | if (LocaleCompare("negate",option+1) == 0) |
| 5122 | break; |
| 5123 | if (LocaleCompare("noise",option+1) == 0) |
| 5124 | { |
| 5125 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5126 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5127 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5128 | if (*option == '+') |
| 5129 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5130 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5131 | noise; |
| 5132 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5133 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5134 | if (noise < 0) |
| 5135 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5136 | argv[i]); |
| 5137 | break; |
| 5138 | } |
| 5139 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5140 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5141 | break; |
| 5142 | } |
| 5143 | if (LocaleCompare("noop",option+1) == 0) |
| 5144 | break; |
| 5145 | if (LocaleCompare("normalize",option+1) == 0) |
| 5146 | break; |
| 5147 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5148 | } |
| 5149 | case 'o': |
| 5150 | { |
| 5151 | if (LocaleCompare("opaque",option+1) == 0) |
| 5152 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5153 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5154 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5155 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5156 | break; |
| 5157 | } |
| 5158 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5159 | { |
| 5160 | if (*option == '+') |
| 5161 | break; |
| 5162 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5163 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5164 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5165 | break; |
| 5166 | } |
| 5167 | if (LocaleCompare("orient",option+1) == 0) |
| 5168 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5169 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5170 | orientation; |
| 5171 | |
| 5172 | orientation=UndefinedOrientation; |
| 5173 | if (*option == '+') |
| 5174 | break; |
| 5175 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5176 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5177 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5178 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5179 | argv[i]); |
| 5180 | if (orientation < 0) |
| 5181 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5182 | argv[i]); |
| 5183 | break; |
| 5184 | } |
| 5185 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5186 | } |
| 5187 | case 'p': |
| 5188 | { |
| 5189 | if (LocaleCompare("page",option+1) == 0) |
| 5190 | { |
| 5191 | if (*option == '+') |
| 5192 | break; |
| 5193 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5194 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5195 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5196 | break; |
| 5197 | } |
| 5198 | if (LocaleCompare("paint",option+1) == 0) |
| 5199 | { |
| 5200 | if (*option == '+') |
| 5201 | break; |
| 5202 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5203 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5204 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5205 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5206 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5207 | break; |
| 5208 | } |
| 5209 | if (LocaleCompare("path",option+1) == 0) |
| 5210 | { |
| 5211 | (void) CloneString(&path,(char *) NULL); |
| 5212 | if (*option == '+') |
| 5213 | break; |
| 5214 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5215 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5216 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5217 | (void) CloneString(&path,argv[i]); |
| 5218 | break; |
| 5219 | } |
| 5220 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5221 | { |
| 5222 | if (*option == '+') |
| 5223 | break; |
| 5224 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5225 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5226 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5227 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5228 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5229 | break; |
| 5230 | } |
| 5231 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5232 | { |
| 5233 | if (*option == '+') |
| 5234 | break; |
| 5235 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5236 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5237 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5238 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5239 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5240 | break; |
| 5241 | } |
| 5242 | if (LocaleCompare("posterize",option+1) == 0) |
| 5243 | { |
| 5244 | if (*option == '+') |
| 5245 | break; |
| 5246 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5247 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5248 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5249 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5250 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5251 | break; |
| 5252 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5253 | if (LocaleCompare("precision",option+1) == 0) |
| 5254 | { |
| 5255 | if (*option == '+') |
| 5256 | break; |
| 5257 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5258 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5259 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5260 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5261 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5262 | break; |
| 5263 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5264 | if (LocaleCompare("print",option+1) == 0) |
| 5265 | { |
| 5266 | if (*option == '+') |
| 5267 | break; |
| 5268 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5269 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5270 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5271 | break; |
| 5272 | } |
| 5273 | if (LocaleCompare("process",option+1) == 0) |
| 5274 | { |
| 5275 | if (*option == '+') |
| 5276 | break; |
| 5277 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5278 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5279 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5280 | break; |
| 5281 | } |
| 5282 | if (LocaleCompare("profile",option+1) == 0) |
| 5283 | { |
| 5284 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5285 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5286 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5287 | break; |
| 5288 | } |
| 5289 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5290 | } |
| 5291 | case 'q': |
| 5292 | { |
| 5293 | if (LocaleCompare("quality",option+1) == 0) |
| 5294 | { |
| 5295 | if (*option == '+') |
| 5296 | break; |
| 5297 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5298 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5299 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5300 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5301 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5302 | break; |
| 5303 | } |
| 5304 | if (LocaleCompare("quantize",option+1) == 0) |
| 5305 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5306 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5307 | colorspace; |
| 5308 | |
| 5309 | if (*option == '+') |
| 5310 | break; |
| 5311 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5312 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5313 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5314 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5315 | argv[i]); |
| 5316 | if (colorspace < 0) |
| 5317 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5318 | argv[i]); |
| 5319 | break; |
| 5320 | } |
| 5321 | if (LocaleCompare("quiet",option+1) == 0) |
| 5322 | break; |
| 5323 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5324 | } |
| 5325 | case 'r': |
| 5326 | { |
| 5327 | if (LocaleCompare("radial-blur",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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5333 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5334 | break; |
| 5335 | } |
| 5336 | if (LocaleCompare("raise",option+1) == 0) |
| 5337 | { |
| 5338 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5339 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5340 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5341 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5342 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5343 | break; |
| 5344 | } |
| 5345 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5346 | { |
| 5347 | if (*option == '+') |
| 5348 | break; |
| 5349 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5350 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5351 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5352 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5353 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5354 | break; |
| 5355 | } |
| 5356 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5357 | { |
| 5358 | if (*option == '+') |
| 5359 | break; |
| 5360 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5361 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5362 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5363 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5364 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5365 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5366 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5367 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5368 | if (LocaleCompare("region",option+1) == 0) |
| 5369 | { |
| 5370 | if (*option == '+') |
| 5371 | break; |
| 5372 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5373 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5374 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5375 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5376 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5377 | break; |
| 5378 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5379 | if (LocaleCompare("remap",option+1) == 0) |
| 5380 | { |
| 5381 | if (*option == '+') |
| 5382 | break; |
| 5383 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5384 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5385 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5386 | break; |
| 5387 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5388 | if (LocaleCompare("render",option+1) == 0) |
| 5389 | break; |
| 5390 | if (LocaleCompare("repage",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 | } |
| 5401 | if (LocaleCompare("resample",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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5407 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5408 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5409 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5410 | break; |
| 5411 | } |
| 5412 | if (LocaleCompare("resize",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 | break; |
| 5422 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5423 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5424 | { |
| 5425 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5426 | break; |
| 5427 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5428 | if (LocaleCompare("reverse",option+1) == 0) |
| 5429 | break; |
| 5430 | if (LocaleCompare("roll",option+1) == 0) |
| 5431 | { |
| 5432 | if (*option == '+') |
| 5433 | break; |
| 5434 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5435 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5436 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5437 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5438 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5439 | break; |
| 5440 | } |
| 5441 | if (LocaleCompare("rotate",option+1) == 0) |
| 5442 | { |
| 5443 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5444 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5445 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5446 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5447 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5448 | break; |
| 5449 | } |
| 5450 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5451 | } |
| 5452 | case 's': |
| 5453 | { |
| 5454 | if (LocaleCompare("sample",option+1) == 0) |
| 5455 | { |
| 5456 | if (*option == '+') |
| 5457 | break; |
| 5458 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5459 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5460 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5461 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5462 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5463 | break; |
| 5464 | } |
| 5465 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5466 | { |
| 5467 | if (*option == '+') |
| 5468 | break; |
| 5469 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5470 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5471 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5472 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5473 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5474 | break; |
| 5475 | } |
| 5476 | if (LocaleCompare("scale",option+1) == 0) |
| 5477 | { |
| 5478 | if (*option == '+') |
| 5479 | break; |
| 5480 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5481 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5482 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5483 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5484 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5485 | break; |
| 5486 | } |
| 5487 | if (LocaleCompare("scene",option+1) == 0) |
| 5488 | { |
| 5489 | if (*option == '+') |
| 5490 | break; |
| 5491 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5492 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5493 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5494 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5495 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5496 | break; |
| 5497 | } |
| 5498 | if (LocaleCompare("seed",option+1) == 0) |
| 5499 | { |
| 5500 | if (*option == '+') |
| 5501 | break; |
| 5502 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5503 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5504 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5505 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5506 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5507 | break; |
| 5508 | } |
| 5509 | if (LocaleCompare("segment",option+1) == 0) |
| 5510 | { |
| 5511 | if (*option == '+') |
| 5512 | break; |
| 5513 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5514 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5515 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5516 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5517 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5518 | break; |
| 5519 | } |
| 5520 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5521 | { |
| 5522 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5523 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5524 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5525 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5526 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5527 | break; |
| 5528 | } |
| 5529 | if (LocaleCompare("separate",option+1) == 0) |
| 5530 | break; |
| 5531 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5532 | { |
| 5533 | if (*option == '+') |
| 5534 | break; |
| 5535 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5536 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5537 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5538 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5539 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5540 | break; |
| 5541 | } |
| 5542 | if (LocaleCompare("set",option+1) == 0) |
| 5543 | { |
| 5544 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5545 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5546 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5547 | if (*option == '+') |
| 5548 | break; |
| 5549 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5550 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5551 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5552 | break; |
| 5553 | } |
| 5554 | if (LocaleCompare("shade",option+1) == 0) |
| 5555 | { |
| 5556 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5557 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5558 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5559 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5560 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5561 | break; |
| 5562 | } |
| 5563 | if (LocaleCompare("shadow",option+1) == 0) |
| 5564 | { |
| 5565 | if (*option == '+') |
| 5566 | break; |
| 5567 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5568 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5569 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5570 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5571 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5572 | break; |
| 5573 | } |
| 5574 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5575 | { |
| 5576 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5577 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5578 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5579 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5580 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5581 | break; |
| 5582 | } |
| 5583 | if (LocaleCompare("shave",option+1) == 0) |
| 5584 | { |
| 5585 | if (*option == '+') |
| 5586 | break; |
| 5587 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5588 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5589 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5590 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5591 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5592 | break; |
| 5593 | } |
| 5594 | if (LocaleCompare("shear",option+1) == 0) |
| 5595 | { |
| 5596 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5597 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5598 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5599 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5600 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5601 | break; |
| 5602 | } |
| 5603 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5604 | { |
| 5605 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5606 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5607 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5608 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5609 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5610 | break; |
| 5611 | } |
| 5612 | if (LocaleCompare("size",option+1) == 0) |
| 5613 | { |
| 5614 | if (*option == '+') |
| 5615 | break; |
| 5616 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5617 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5618 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5619 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5620 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5621 | break; |
| 5622 | } |
| 5623 | if (LocaleCompare("sketch",option+1) == 0) |
| 5624 | { |
| 5625 | if (*option == '+') |
| 5626 | break; |
| 5627 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5628 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5629 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5630 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5631 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5632 | break; |
| 5633 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5634 | if (LocaleCompare("smush",option+1) == 0) |
| 5635 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5636 | i++; |
| 5637 | if (i == (ssize_t) argc) |
| 5638 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5639 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5640 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5641 | i++; |
| 5642 | break; |
| 5643 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5644 | if (LocaleCompare("solarize",option+1) == 0) |
| 5645 | { |
| 5646 | if (*option == '+') |
| 5647 | break; |
| 5648 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5649 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5650 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5651 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5652 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5653 | break; |
| 5654 | } |
| 5655 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5656 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5657 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5658 | op; |
| 5659 | |
| 5660 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5661 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5662 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5663 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5664 | if (op < 0) |
| 5665 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5666 | argv[i]); |
| 5667 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5668 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5669 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5670 | break; |
| 5671 | } |
| 5672 | if (LocaleCompare("spread",option+1) == 0) |
| 5673 | { |
| 5674 | if (*option == '+') |
| 5675 | break; |
| 5676 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5677 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5678 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5679 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5680 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5681 | break; |
| 5682 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5683 | if (LocaleCompare("statistic",option+1) == 0) |
| 5684 | { |
| 5685 | ssize_t |
| 5686 | op; |
| 5687 | |
| 5688 | if (*option == '+') |
| 5689 | break; |
| 5690 | i++; |
| 5691 | if (i == (ssize_t) argc) |
| 5692 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5693 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5694 | if (op < 0) |
| 5695 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5696 | argv[i]); |
| 5697 | i++; |
| 5698 | if (i == (ssize_t) (argc-1)) |
| 5699 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5700 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5701 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5702 | break; |
| 5703 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5704 | if (LocaleCompare("stretch",option+1) == 0) |
| 5705 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5706 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5707 | stretch; |
| 5708 | |
| 5709 | if (*option == '+') |
| 5710 | break; |
| 5711 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5712 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5713 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5714 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5715 | if (stretch < 0) |
| 5716 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5717 | argv[i]); |
| 5718 | break; |
| 5719 | } |
| 5720 | if (LocaleCompare("strip",option+1) == 0) |
| 5721 | break; |
| 5722 | if (LocaleCompare("stroke",option+1) == 0) |
| 5723 | { |
| 5724 | if (*option == '+') |
| 5725 | break; |
| 5726 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5727 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5728 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5729 | break; |
| 5730 | } |
| 5731 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5732 | { |
| 5733 | if (*option == '+') |
| 5734 | break; |
| 5735 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5736 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5737 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5738 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5739 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5740 | break; |
| 5741 | } |
| 5742 | if (LocaleCompare("style",option+1) == 0) |
| 5743 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5744 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5745 | style; |
| 5746 | |
| 5747 | if (*option == '+') |
| 5748 | break; |
| 5749 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5750 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5751 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5752 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5753 | if (style < 0) |
| 5754 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5755 | argv[i]); |
| 5756 | break; |
| 5757 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5758 | if (LocaleCompare("swap",option+1) == 0) |
| 5759 | { |
| 5760 | if (*option == '+') |
| 5761 | break; |
| 5762 | i++; |
| 5763 | if (i == (ssize_t) (argc-1)) |
| 5764 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5765 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5766 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5767 | break; |
| 5768 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5769 | if (LocaleCompare("swirl",option+1) == 0) |
| 5770 | { |
| 5771 | if (*option == '+') |
| 5772 | break; |
| 5773 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5774 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5775 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5776 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5777 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5778 | break; |
| 5779 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5780 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5781 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5782 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5783 | } |
| 5784 | case 't': |
| 5785 | { |
| 5786 | if (LocaleCompare("taint",option+1) == 0) |
| 5787 | break; |
| 5788 | if (LocaleCompare("texture",option+1) == 0) |
| 5789 | { |
| 5790 | if (*option == '+') |
| 5791 | break; |
| 5792 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5793 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5794 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5795 | break; |
| 5796 | } |
| 5797 | if (LocaleCompare("tile",option+1) == 0) |
| 5798 | { |
| 5799 | if (*option == '+') |
| 5800 | break; |
| 5801 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5802 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5803 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5804 | break; |
| 5805 | } |
| 5806 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5807 | { |
| 5808 | if (*option == '+') |
| 5809 | break; |
| 5810 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5811 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5812 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5813 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5814 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5815 | break; |
| 5816 | } |
| 5817 | if (LocaleCompare("tint",option+1) == 0) |
| 5818 | { |
| 5819 | if (*option == '+') |
| 5820 | break; |
| 5821 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5822 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5823 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5824 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5825 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5826 | break; |
| 5827 | } |
| 5828 | if (LocaleCompare("transform",option+1) == 0) |
| 5829 | break; |
| 5830 | if (LocaleCompare("transpose",option+1) == 0) |
| 5831 | break; |
| 5832 | if (LocaleCompare("transverse",option+1) == 0) |
| 5833 | break; |
| 5834 | if (LocaleCompare("threshold",option+1) == 0) |
| 5835 | { |
| 5836 | if (*option == '+') |
| 5837 | break; |
| 5838 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5839 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5840 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5841 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5842 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5843 | break; |
| 5844 | } |
| 5845 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5846 | { |
| 5847 | if (*option == '+') |
| 5848 | break; |
| 5849 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5850 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5851 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5852 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5853 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5854 | break; |
| 5855 | } |
| 5856 | if (LocaleCompare("transparent",option+1) == 0) |
| 5857 | { |
| 5858 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5859 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5860 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5861 | break; |
| 5862 | } |
| 5863 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 5864 | { |
| 5865 | if (*option == '+') |
| 5866 | break; |
| 5867 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5868 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5869 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5870 | break; |
| 5871 | } |
| 5872 | if (LocaleCompare("treedepth",option+1) == 0) |
| 5873 | { |
| 5874 | if (*option == '+') |
| 5875 | break; |
| 5876 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5877 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5878 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5879 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5880 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5881 | break; |
| 5882 | } |
| 5883 | if (LocaleCompare("trim",option+1) == 0) |
| 5884 | break; |
| 5885 | if (LocaleCompare("type",option+1) == 0) |
| 5886 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5887 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5888 | type; |
| 5889 | |
| 5890 | if (*option == '+') |
| 5891 | break; |
| 5892 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5893 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5894 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5895 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5896 | if (type < 0) |
| 5897 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5898 | argv[i]); |
| 5899 | break; |
| 5900 | } |
| 5901 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5902 | } |
| 5903 | case 'u': |
| 5904 | { |
| 5905 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5906 | { |
| 5907 | if (*option == '+') |
| 5908 | break; |
| 5909 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5910 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5911 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5912 | break; |
| 5913 | } |
| 5914 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5915 | break; |
| 5916 | if (LocaleCompare("units",option+1) == 0) |
| 5917 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5918 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5919 | units; |
| 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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5925 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5926 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5927 | argv[i]); |
| 5928 | if (units < 0) |
| 5929 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5930 | argv[i]); |
| 5931 | break; |
| 5932 | } |
| 5933 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5934 | { |
| 5935 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5936 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5937 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5938 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5939 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5940 | break; |
| 5941 | } |
| 5942 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5943 | } |
| 5944 | case 'v': |
| 5945 | { |
| 5946 | if (LocaleCompare("verbose",option+1) == 0) |
| 5947 | { |
| 5948 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 5949 | break; |
| 5950 | } |
| 5951 | if ((LocaleCompare("version",option+1) == 0) || |
| 5952 | (LocaleCompare("-version",option+1) == 0)) |
| 5953 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 5954 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5955 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 5956 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 5957 | GetMagickCopyright()); |
| 5958 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 5959 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5960 | break; |
| 5961 | } |
| 5962 | if (LocaleCompare("view",option+1) == 0) |
| 5963 | { |
| 5964 | if (*option == '+') |
| 5965 | break; |
| 5966 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5967 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5968 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5969 | break; |
| 5970 | } |
| 5971 | if (LocaleCompare("vignette",option+1) == 0) |
| 5972 | { |
| 5973 | if (*option == '+') |
| 5974 | break; |
| 5975 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5976 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5977 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5978 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5979 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5980 | break; |
| 5981 | } |
| 5982 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 5983 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5984 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5985 | method; |
| 5986 | |
| 5987 | if (*option == '+') |
| 5988 | break; |
| 5989 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5990 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5991 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5992 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5993 | argv[i]); |
| 5994 | if (method < 0) |
| 5995 | ThrowMogrifyException(OptionError, |
| 5996 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 5997 | break; |
| 5998 | } |
| 5999 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6000 | } |
| 6001 | case 'w': |
| 6002 | { |
| 6003 | if (LocaleCompare("wave",option+1) == 0) |
| 6004 | { |
| 6005 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6006 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6007 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6008 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6009 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6010 | break; |
| 6011 | } |
| 6012 | if (LocaleCompare("weight",option+1) == 0) |
| 6013 | { |
| 6014 | if (*option == '+') |
| 6015 | break; |
| 6016 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6017 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6018 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6019 | break; |
| 6020 | } |
| 6021 | if (LocaleCompare("white-point",option+1) == 0) |
| 6022 | { |
| 6023 | if (*option == '+') |
| 6024 | break; |
| 6025 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6026 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6027 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6028 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6029 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6030 | break; |
| 6031 | } |
| 6032 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6033 | { |
| 6034 | if (*option == '+') |
| 6035 | break; |
| 6036 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6037 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6038 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6039 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6040 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6041 | break; |
| 6042 | } |
| 6043 | if (LocaleCompare("write",option+1) == 0) |
| 6044 | { |
| 6045 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6046 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6047 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6048 | break; |
| 6049 | } |
| 6050 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6051 | } |
| 6052 | case '?': |
| 6053 | break; |
| 6054 | default: |
| 6055 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6056 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6057 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 6058 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6059 | if (fire != MagickFalse) |
| 6060 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6061 | } |
| 6062 | if (k != 0) |
| 6063 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6064 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6065 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6066 | DestroyMogrify(); |
| 6067 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6068 | } |
| 6069 | |
| 6070 | /* |
| 6071 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6072 | % % |
| 6073 | % % |
| 6074 | % % |
| 6075 | + M o g r i f y I m a g e I n f o % |
| 6076 | % % |
| 6077 | % % |
| 6078 | % % |
| 6079 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6080 | % |
| 6081 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6082 | % prescribed by command line options. |
| 6083 | % |
| 6084 | % The format of the MogrifyImageInfo method is: |
| 6085 | % |
| 6086 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6087 | % const char **argv,ExceptionInfo *exception) |
| 6088 | % |
| 6089 | % A description of each parameter follows: |
| 6090 | % |
| 6091 | % o image_info: the image info.. |
| 6092 | % |
| 6093 | % o argc: Specifies a pointer to an integer describing the number of |
| 6094 | % elements in the argument vector. |
| 6095 | % |
| 6096 | % o argv: Specifies a pointer to a text array containing the command line |
| 6097 | % arguments. |
| 6098 | % |
| 6099 | % o exception: return any errors or warnings in this structure. |
| 6100 | % |
| 6101 | */ |
| 6102 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6103 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6104 | { |
| 6105 | const char |
| 6106 | *option; |
| 6107 | |
| 6108 | GeometryInfo |
| 6109 | geometry_info; |
| 6110 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6111 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6112 | count; |
| 6113 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6114 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6115 | i; |
| 6116 | |
| 6117 | /* |
| 6118 | Initialize method variables. |
| 6119 | */ |
| 6120 | assert(image_info != (ImageInfo *) NULL); |
| 6121 | assert(image_info->signature == MagickSignature); |
| 6122 | if (image_info->debug != MagickFalse) |
| 6123 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6124 | image_info->filename); |
| 6125 | if (argc < 0) |
| 6126 | return(MagickTrue); |
| 6127 | /* |
| 6128 | Set the image settings. |
| 6129 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6130 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6131 | { |
| 6132 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6133 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6134 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6135 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6136 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6137 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6138 | break; |
| 6139 | switch (*(option+1)) |
| 6140 | { |
| 6141 | case 'a': |
| 6142 | { |
| 6143 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6144 | { |
| 6145 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6146 | break; |
| 6147 | } |
| 6148 | if (LocaleCompare("antialias",option+1) == 0) |
| 6149 | { |
| 6150 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6151 | break; |
| 6152 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6153 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6154 | { |
| 6155 | if (*option == '+') |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 6156 | (void) DeleteImageOption(image_info,option+1); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6157 | else |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 6158 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6159 | break; |
| 6160 | } |
| 6161 | break; |
| 6162 | } |
| 6163 | case 'b': |
| 6164 | { |
| 6165 | if (LocaleCompare("background",option+1) == 0) |
| 6166 | { |
| 6167 | if (*option == '+') |
| 6168 | { |
| 6169 | (void) DeleteImageOption(image_info,option+1); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6170 | (void) QueryColorCompliance(MogrifyBackgroundColor, |
| 6171 | AllCompliance,&image_info->background_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6172 | break; |
| 6173 | } |
| 6174 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6175 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6176 | &image_info->background_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6177 | break; |
| 6178 | } |
| 6179 | if (LocaleCompare("bias",option+1) == 0) |
| 6180 | { |
| 6181 | if (*option == '+') |
| 6182 | { |
| 6183 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6184 | break; |
| 6185 | } |
| 6186 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6187 | break; |
| 6188 | } |
| 6189 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6190 | { |
| 6191 | if (*option == '+') |
| 6192 | { |
| 6193 | (void) SetImageOption(image_info,option+1,"false"); |
| 6194 | break; |
| 6195 | } |
| 6196 | (void) SetImageOption(image_info,option+1,"true"); |
| 6197 | break; |
| 6198 | } |
| 6199 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6200 | { |
| 6201 | if (*option == '+') |
| 6202 | { |
| 6203 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6204 | break; |
| 6205 | } |
| 6206 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6207 | break; |
| 6208 | } |
| 6209 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6210 | { |
| 6211 | if (*option == '+') |
| 6212 | { |
| 6213 | (void) DeleteImageOption(image_info,option+1); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6214 | (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6215 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6216 | break; |
| 6217 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6218 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6219 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6220 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6221 | break; |
| 6222 | } |
| 6223 | if (LocaleCompare("box",option+1) == 0) |
| 6224 | { |
| 6225 | if (*option == '+') |
| 6226 | { |
| 6227 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6228 | break; |
| 6229 | } |
| 6230 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6231 | break; |
| 6232 | } |
| 6233 | break; |
| 6234 | } |
| 6235 | case 'c': |
| 6236 | { |
| 6237 | if (LocaleCompare("cache",option+1) == 0) |
| 6238 | { |
| 6239 | MagickSizeType |
| 6240 | limit; |
| 6241 | |
| 6242 | limit=MagickResourceInfinity; |
| 6243 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 6244 | limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1], |
| 6245 | 100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6246 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6247 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6248 | break; |
| 6249 | } |
| 6250 | if (LocaleCompare("caption",option+1) == 0) |
| 6251 | { |
| 6252 | if (*option == '+') |
| 6253 | { |
| 6254 | (void) DeleteImageOption(image_info,option+1); |
| 6255 | break; |
| 6256 | } |
| 6257 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6258 | break; |
| 6259 | } |
| 6260 | if (LocaleCompare("channel",option+1) == 0) |
| 6261 | { |
| 6262 | if (*option == '+') |
| 6263 | { |
| 6264 | image_info->channel=DefaultChannels; |
| 6265 | break; |
| 6266 | } |
| 6267 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6268 | break; |
| 6269 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6270 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6271 | { |
| 6272 | if (*option == '+') |
| 6273 | { |
| 6274 | image_info->colorspace=UndefinedColorspace; |
| 6275 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6276 | break; |
| 6277 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6278 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6279 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6280 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6281 | break; |
| 6282 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6283 | if (LocaleCompare("comment",option+1) == 0) |
| 6284 | { |
| 6285 | if (*option == '+') |
| 6286 | { |
| 6287 | (void) DeleteImageOption(image_info,option+1); |
| 6288 | break; |
| 6289 | } |
| 6290 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6291 | break; |
| 6292 | } |
| 6293 | if (LocaleCompare("compose",option+1) == 0) |
| 6294 | { |
| 6295 | if (*option == '+') |
| 6296 | { |
| 6297 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6298 | break; |
| 6299 | } |
| 6300 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6301 | break; |
| 6302 | } |
| 6303 | if (LocaleCompare("compress",option+1) == 0) |
| 6304 | { |
| 6305 | if (*option == '+') |
| 6306 | { |
| 6307 | image_info->compression=UndefinedCompression; |
| 6308 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6309 | break; |
| 6310 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6311 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6312 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6313 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6314 | break; |
| 6315 | } |
| 6316 | break; |
| 6317 | } |
| 6318 | case 'd': |
| 6319 | { |
| 6320 | if (LocaleCompare("debug",option+1) == 0) |
| 6321 | { |
| 6322 | if (*option == '+') |
| 6323 | (void) SetLogEventMask("none"); |
| 6324 | else |
| 6325 | (void) SetLogEventMask(argv[i+1]); |
| 6326 | image_info->debug=IsEventLogging(); |
| 6327 | break; |
| 6328 | } |
| 6329 | if (LocaleCompare("define",option+1) == 0) |
| 6330 | { |
| 6331 | if (*option == '+') |
| 6332 | { |
| 6333 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6334 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6335 | else |
| 6336 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6337 | break; |
| 6338 | } |
| 6339 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6340 | { |
| 6341 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6342 | exception); |
| 6343 | break; |
| 6344 | } |
| 6345 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6346 | break; |
| 6347 | } |
| 6348 | if (LocaleCompare("delay",option+1) == 0) |
| 6349 | { |
| 6350 | if (*option == '+') |
| 6351 | { |
| 6352 | (void) SetImageOption(image_info,option+1,"0"); |
| 6353 | break; |
| 6354 | } |
| 6355 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6356 | break; |
| 6357 | } |
| 6358 | if (LocaleCompare("density",option+1) == 0) |
| 6359 | { |
| 6360 | /* |
| 6361 | Set image density. |
| 6362 | */ |
| 6363 | if (*option == '+') |
| 6364 | { |
| 6365 | if (image_info->density != (char *) NULL) |
| 6366 | image_info->density=DestroyString(image_info->density); |
| 6367 | (void) SetImageOption(image_info,option+1,"72"); |
| 6368 | break; |
| 6369 | } |
| 6370 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6371 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6372 | break; |
| 6373 | } |
| 6374 | if (LocaleCompare("depth",option+1) == 0) |
| 6375 | { |
| 6376 | if (*option == '+') |
| 6377 | { |
| 6378 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6379 | break; |
| 6380 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6381 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6382 | break; |
| 6383 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6384 | if (LocaleCompare("direction",option+1) == 0) |
| 6385 | { |
| 6386 | if (*option == '+') |
| 6387 | { |
| 6388 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6389 | break; |
| 6390 | } |
| 6391 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6392 | break; |
| 6393 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6394 | if (LocaleCompare("display",option+1) == 0) |
| 6395 | { |
| 6396 | if (*option == '+') |
| 6397 | { |
| 6398 | if (image_info->server_name != (char *) NULL) |
| 6399 | image_info->server_name=DestroyString( |
| 6400 | image_info->server_name); |
| 6401 | break; |
| 6402 | } |
| 6403 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6404 | break; |
| 6405 | } |
| 6406 | if (LocaleCompare("dispose",option+1) == 0) |
| 6407 | { |
| 6408 | if (*option == '+') |
| 6409 | { |
| 6410 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6411 | break; |
| 6412 | } |
| 6413 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6414 | break; |
| 6415 | } |
| 6416 | if (LocaleCompare("dither",option+1) == 0) |
| 6417 | { |
| 6418 | if (*option == '+') |
| 6419 | { |
| 6420 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6421 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6422 | break; |
| 6423 | } |
| 6424 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6425 | image_info->dither=MagickTrue; |
| 6426 | break; |
| 6427 | } |
| 6428 | break; |
| 6429 | } |
| 6430 | case 'e': |
| 6431 | { |
| 6432 | if (LocaleCompare("encoding",option+1) == 0) |
| 6433 | { |
| 6434 | if (*option == '+') |
| 6435 | { |
| 6436 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6437 | break; |
| 6438 | } |
| 6439 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6440 | break; |
| 6441 | } |
| 6442 | if (LocaleCompare("endian",option+1) == 0) |
| 6443 | { |
| 6444 | if (*option == '+') |
| 6445 | { |
| 6446 | image_info->endian=UndefinedEndian; |
| 6447 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6448 | break; |
| 6449 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6450 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6451 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6452 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6453 | break; |
| 6454 | } |
| 6455 | if (LocaleCompare("extract",option+1) == 0) |
| 6456 | { |
| 6457 | /* |
| 6458 | Set image extract geometry. |
| 6459 | */ |
| 6460 | if (*option == '+') |
| 6461 | { |
| 6462 | if (image_info->extract != (char *) NULL) |
| 6463 | image_info->extract=DestroyString(image_info->extract); |
| 6464 | break; |
| 6465 | } |
| 6466 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6467 | break; |
| 6468 | } |
| 6469 | break; |
| 6470 | } |
| 6471 | case 'f': |
| 6472 | { |
| 6473 | if (LocaleCompare("fill",option+1) == 0) |
| 6474 | { |
| 6475 | if (*option == '+') |
| 6476 | { |
| 6477 | (void) SetImageOption(image_info,option+1,"none"); |
| 6478 | break; |
| 6479 | } |
| 6480 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6481 | break; |
| 6482 | } |
| 6483 | if (LocaleCompare("filter",option+1) == 0) |
| 6484 | { |
| 6485 | if (*option == '+') |
| 6486 | { |
| 6487 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6488 | break; |
| 6489 | } |
| 6490 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6491 | break; |
| 6492 | } |
| 6493 | if (LocaleCompare("font",option+1) == 0) |
| 6494 | { |
| 6495 | if (*option == '+') |
| 6496 | { |
| 6497 | if (image_info->font != (char *) NULL) |
| 6498 | image_info->font=DestroyString(image_info->font); |
| 6499 | break; |
| 6500 | } |
| 6501 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6502 | break; |
| 6503 | } |
| 6504 | if (LocaleCompare("format",option+1) == 0) |
| 6505 | { |
| 6506 | register const char |
| 6507 | *q; |
| 6508 | |
| 6509 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6510 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6511 | image_info->ping=MagickFalse; |
| 6512 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6513 | break; |
| 6514 | } |
| 6515 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6516 | { |
| 6517 | if (*option == '+') |
| 6518 | { |
| 6519 | image_info->fuzz=0.0; |
| 6520 | (void) SetImageOption(image_info,option+1,"0"); |
| 6521 | break; |
| 6522 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 6523 | image_info->fuzz=StringToDoubleInterval(argv[i+1],(double) |
| 6524 | QuantumRange+1.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6525 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6526 | break; |
| 6527 | } |
| 6528 | break; |
| 6529 | } |
| 6530 | case 'g': |
| 6531 | { |
| 6532 | if (LocaleCompare("gravity",option+1) == 0) |
| 6533 | { |
| 6534 | if (*option == '+') |
| 6535 | { |
| 6536 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6537 | break; |
| 6538 | } |
| 6539 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6540 | break; |
| 6541 | } |
| 6542 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6543 | { |
| 6544 | if (*option == '+') |
| 6545 | { |
| 6546 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6547 | break; |
| 6548 | } |
| 6549 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6550 | break; |
| 6551 | } |
| 6552 | break; |
| 6553 | } |
| 6554 | case 'i': |
| 6555 | { |
| 6556 | if (LocaleCompare("intent",option+1) == 0) |
| 6557 | { |
| 6558 | if (*option == '+') |
| 6559 | { |
| 6560 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6561 | break; |
| 6562 | } |
| 6563 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6564 | break; |
| 6565 | } |
| 6566 | if (LocaleCompare("interlace",option+1) == 0) |
| 6567 | { |
| 6568 | if (*option == '+') |
| 6569 | { |
| 6570 | image_info->interlace=UndefinedInterlace; |
| 6571 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6572 | break; |
| 6573 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6574 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6575 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6576 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6577 | break; |
| 6578 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6579 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6580 | { |
| 6581 | if (*option == '+') |
| 6582 | { |
| 6583 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6584 | break; |
| 6585 | } |
| 6586 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6587 | break; |
| 6588 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6589 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6590 | { |
| 6591 | if (*option == '+') |
| 6592 | { |
| 6593 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6594 | break; |
| 6595 | } |
| 6596 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6597 | break; |
| 6598 | } |
| 6599 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6600 | { |
| 6601 | if (*option == '+') |
| 6602 | { |
| 6603 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6604 | break; |
| 6605 | } |
| 6606 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6607 | break; |
| 6608 | } |
| 6609 | break; |
| 6610 | } |
| 6611 | case 'k': |
| 6612 | { |
| 6613 | if (LocaleCompare("kerning",option+1) == 0) |
| 6614 | { |
| 6615 | if (*option == '+') |
| 6616 | { |
| 6617 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6618 | break; |
| 6619 | } |
| 6620 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6621 | break; |
| 6622 | } |
| 6623 | break; |
| 6624 | } |
| 6625 | case 'l': |
| 6626 | { |
| 6627 | if (LocaleCompare("label",option+1) == 0) |
| 6628 | { |
| 6629 | if (*option == '+') |
| 6630 | { |
| 6631 | (void) DeleteImageOption(image_info,option+1); |
| 6632 | break; |
| 6633 | } |
| 6634 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6635 | break; |
| 6636 | } |
| 6637 | if (LocaleCompare("limit",option+1) == 0) |
| 6638 | { |
| 6639 | MagickSizeType |
| 6640 | limit; |
| 6641 | |
| 6642 | ResourceType |
| 6643 | type; |
| 6644 | |
| 6645 | if (*option == '+') |
| 6646 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6647 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6648 | MagickFalse,argv[i+1]); |
| 6649 | limit=MagickResourceInfinity; |
| 6650 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | c062734 | 2011-11-18 21:15:24 +0000 | [diff] [blame] | 6651 | limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6652 | (void) SetMagickResourceLimit(type,limit); |
| 6653 | break; |
| 6654 | } |
| 6655 | if (LocaleCompare("list",option+1) == 0) |
| 6656 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6657 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6658 | list; |
| 6659 | |
| 6660 | /* |
| 6661 | Display configuration list. |
| 6662 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6663 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6664 | switch (list) |
| 6665 | { |
| 6666 | case MagickCoderOptions: |
| 6667 | { |
| 6668 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6669 | break; |
| 6670 | } |
| 6671 | case MagickColorOptions: |
| 6672 | { |
| 6673 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6674 | break; |
| 6675 | } |
| 6676 | case MagickConfigureOptions: |
| 6677 | { |
| 6678 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6679 | break; |
| 6680 | } |
| 6681 | case MagickDelegateOptions: |
| 6682 | { |
| 6683 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6684 | break; |
| 6685 | } |
| 6686 | case MagickFontOptions: |
| 6687 | { |
| 6688 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6689 | break; |
| 6690 | } |
| 6691 | case MagickFormatOptions: |
| 6692 | { |
| 6693 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6694 | break; |
| 6695 | } |
| 6696 | case MagickLocaleOptions: |
| 6697 | { |
| 6698 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6699 | break; |
| 6700 | } |
| 6701 | case MagickLogOptions: |
| 6702 | { |
| 6703 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6704 | break; |
| 6705 | } |
| 6706 | case MagickMagicOptions: |
| 6707 | { |
| 6708 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6709 | break; |
| 6710 | } |
| 6711 | case MagickMimeOptions: |
| 6712 | { |
| 6713 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6714 | break; |
| 6715 | } |
| 6716 | case MagickModuleOptions: |
| 6717 | { |
| 6718 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6719 | break; |
| 6720 | } |
| 6721 | case MagickPolicyOptions: |
| 6722 | { |
| 6723 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6724 | break; |
| 6725 | } |
| 6726 | case MagickResourceOptions: |
| 6727 | { |
| 6728 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6729 | break; |
| 6730 | } |
| 6731 | case MagickThresholdOptions: |
| 6732 | { |
| 6733 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6734 | break; |
| 6735 | } |
| 6736 | default: |
| 6737 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6738 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6739 | exception); |
| 6740 | break; |
| 6741 | } |
| 6742 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6743 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6744 | } |
| 6745 | if (LocaleCompare("log",option+1) == 0) |
| 6746 | { |
| 6747 | if (*option == '+') |
| 6748 | break; |
| 6749 | (void) SetLogFormat(argv[i+1]); |
| 6750 | break; |
| 6751 | } |
| 6752 | if (LocaleCompare("loop",option+1) == 0) |
| 6753 | { |
| 6754 | if (*option == '+') |
| 6755 | { |
| 6756 | (void) SetImageOption(image_info,option+1,"0"); |
| 6757 | break; |
| 6758 | } |
| 6759 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6760 | break; |
| 6761 | } |
| 6762 | break; |
| 6763 | } |
| 6764 | case 'm': |
| 6765 | { |
| 6766 | if (LocaleCompare("matte",option+1) == 0) |
| 6767 | { |
| 6768 | if (*option == '+') |
| 6769 | { |
| 6770 | (void) SetImageOption(image_info,option+1,"false"); |
| 6771 | break; |
| 6772 | } |
| 6773 | (void) SetImageOption(image_info,option+1,"true"); |
| 6774 | break; |
| 6775 | } |
| 6776 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6777 | { |
| 6778 | if (*option == '+') |
| 6779 | { |
| 6780 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6781 | (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance, |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6782 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6783 | break; |
| 6784 | } |
| 6785 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6786 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6787 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6788 | break; |
| 6789 | } |
| 6790 | if (LocaleCompare("monitor",option+1) == 0) |
| 6791 | { |
| 6792 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6793 | (void *) NULL); |
| 6794 | break; |
| 6795 | } |
| 6796 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6797 | { |
| 6798 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6799 | break; |
| 6800 | } |
| 6801 | break; |
| 6802 | } |
| 6803 | case 'o': |
| 6804 | { |
| 6805 | if (LocaleCompare("orient",option+1) == 0) |
| 6806 | { |
| 6807 | if (*option == '+') |
| 6808 | { |
| 6809 | image_info->orientation=UndefinedOrientation; |
| 6810 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6811 | break; |
| 6812 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6813 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6814 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6815 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6816 | break; |
| 6817 | } |
| 6818 | } |
| 6819 | case 'p': |
| 6820 | { |
| 6821 | if (LocaleCompare("page",option+1) == 0) |
| 6822 | { |
| 6823 | char |
| 6824 | *canonical_page, |
| 6825 | page[MaxTextExtent]; |
| 6826 | |
| 6827 | const char |
| 6828 | *image_option; |
| 6829 | |
| 6830 | MagickStatusType |
| 6831 | flags; |
| 6832 | |
| 6833 | RectangleInfo |
| 6834 | geometry; |
| 6835 | |
| 6836 | if (*option == '+') |
| 6837 | { |
| 6838 | (void) DeleteImageOption(image_info,option+1); |
| 6839 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6840 | break; |
| 6841 | } |
| 6842 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6843 | image_option=GetImageOption(image_info,"page"); |
| 6844 | if (image_option != (const char *) NULL) |
| 6845 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6846 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6847 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6848 | canonical_page=DestroyString(canonical_page); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6849 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6850 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6851 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6852 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6853 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6854 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6855 | (void) SetImageOption(image_info,option+1,page); |
| 6856 | (void) CloneString(&image_info->page,page); |
| 6857 | break; |
| 6858 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6859 | if (LocaleCompare("ping",option+1) == 0) |
| 6860 | { |
| 6861 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6862 | break; |
| 6863 | } |
| 6864 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6865 | { |
| 6866 | if (*option == '+') |
| 6867 | geometry_info.rho=0.0; |
| 6868 | else |
| 6869 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6870 | image_info->pointsize=geometry_info.rho; |
| 6871 | break; |
| 6872 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6873 | if (LocaleCompare("precision",option+1) == 0) |
| 6874 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6875 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6876 | break; |
| 6877 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6878 | if (LocaleCompare("preview",option+1) == 0) |
| 6879 | { |
| 6880 | /* |
| 6881 | Preview image. |
| 6882 | */ |
| 6883 | if (*option == '+') |
| 6884 | { |
| 6885 | image_info->preview_type=UndefinedPreview; |
| 6886 | break; |
| 6887 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6888 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6889 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6890 | break; |
| 6891 | } |
| 6892 | break; |
| 6893 | } |
| 6894 | case 'q': |
| 6895 | { |
| 6896 | if (LocaleCompare("quality",option+1) == 0) |
| 6897 | { |
| 6898 | /* |
| 6899 | Set image compression quality. |
| 6900 | */ |
| 6901 | if (*option == '+') |
| 6902 | { |
| 6903 | image_info->quality=UndefinedCompressionQuality; |
| 6904 | (void) SetImageOption(image_info,option+1,"0"); |
| 6905 | break; |
| 6906 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6907 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6908 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6909 | break; |
| 6910 | } |
| 6911 | if (LocaleCompare("quiet",option+1) == 0) |
| 6912 | { |
| 6913 | static WarningHandler |
| 6914 | warning_handler = (WarningHandler) NULL; |
| 6915 | |
| 6916 | if (*option == '+') |
| 6917 | { |
| 6918 | /* |
| 6919 | Restore error or warning messages. |
| 6920 | */ |
| 6921 | warning_handler=SetWarningHandler(warning_handler); |
| 6922 | break; |
| 6923 | } |
| 6924 | /* |
| 6925 | Suppress error or warning messages. |
| 6926 | */ |
| 6927 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6928 | break; |
| 6929 | } |
| 6930 | break; |
| 6931 | } |
| 6932 | case 'r': |
| 6933 | { |
| 6934 | if (LocaleCompare("red-primary",option+1) == 0) |
| 6935 | { |
| 6936 | if (*option == '+') |
| 6937 | { |
| 6938 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6939 | break; |
| 6940 | } |
| 6941 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6942 | break; |
| 6943 | } |
| 6944 | break; |
| 6945 | } |
| 6946 | case 's': |
| 6947 | { |
| 6948 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 6949 | { |
| 6950 | /* |
| 6951 | Set image sampling factor. |
| 6952 | */ |
| 6953 | if (*option == '+') |
| 6954 | { |
| 6955 | if (image_info->sampling_factor != (char *) NULL) |
| 6956 | image_info->sampling_factor=DestroyString( |
| 6957 | image_info->sampling_factor); |
| 6958 | break; |
| 6959 | } |
| 6960 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 6961 | break; |
| 6962 | } |
| 6963 | if (LocaleCompare("scene",option+1) == 0) |
| 6964 | { |
| 6965 | /* |
| 6966 | Set image scene. |
| 6967 | */ |
| 6968 | if (*option == '+') |
| 6969 | { |
| 6970 | image_info->scene=0; |
| 6971 | (void) SetImageOption(image_info,option+1,"0"); |
| 6972 | break; |
| 6973 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6974 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6975 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6976 | break; |
| 6977 | } |
| 6978 | if (LocaleCompare("seed",option+1) == 0) |
| 6979 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6980 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6981 | seed; |
| 6982 | |
| 6983 | if (*option == '+') |
| 6984 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6985 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6986 | SeedPseudoRandomGenerator(seed); |
| 6987 | break; |
| 6988 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6989 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6990 | SeedPseudoRandomGenerator(seed); |
| 6991 | break; |
| 6992 | } |
| 6993 | if (LocaleCompare("size",option+1) == 0) |
| 6994 | { |
| 6995 | if (*option == '+') |
| 6996 | { |
| 6997 | if (image_info->size != (char *) NULL) |
| 6998 | image_info->size=DestroyString(image_info->size); |
| 6999 | break; |
| 7000 | } |
| 7001 | (void) CloneString(&image_info->size,argv[i+1]); |
| 7002 | break; |
| 7003 | } |
| 7004 | if (LocaleCompare("stroke",option+1) == 0) |
| 7005 | { |
| 7006 | if (*option == '+') |
| 7007 | { |
| 7008 | (void) SetImageOption(image_info,option+1,"none"); |
| 7009 | break; |
| 7010 | } |
| 7011 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7012 | break; |
| 7013 | } |
| 7014 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7015 | { |
| 7016 | if (*option == '+') |
| 7017 | { |
| 7018 | (void) SetImageOption(image_info,option+1,"0"); |
| 7019 | break; |
| 7020 | } |
| 7021 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7022 | break; |
| 7023 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7024 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7025 | { |
| 7026 | if (*option == '+') |
| 7027 | { |
| 7028 | image_info->synchronize=MagickFalse; |
| 7029 | break; |
| 7030 | } |
| 7031 | image_info->synchronize=MagickTrue; |
| 7032 | break; |
| 7033 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7034 | break; |
| 7035 | } |
| 7036 | case 't': |
| 7037 | { |
| 7038 | if (LocaleCompare("taint",option+1) == 0) |
| 7039 | { |
| 7040 | if (*option == '+') |
| 7041 | { |
| 7042 | (void) SetImageOption(image_info,option+1,"false"); |
| 7043 | break; |
| 7044 | } |
| 7045 | (void) SetImageOption(image_info,option+1,"true"); |
| 7046 | break; |
| 7047 | } |
| 7048 | if (LocaleCompare("texture",option+1) == 0) |
| 7049 | { |
| 7050 | if (*option == '+') |
| 7051 | { |
| 7052 | if (image_info->texture != (char *) NULL) |
| 7053 | image_info->texture=DestroyString(image_info->texture); |
| 7054 | break; |
| 7055 | } |
| 7056 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7057 | break; |
| 7058 | } |
| 7059 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7060 | { |
| 7061 | if (*option == '+') |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 7062 | (void) SetImageOption(image_info,option+1,"0"); |
| 7063 | else |
| 7064 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7065 | break; |
| 7066 | } |
| 7067 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7068 | { |
| 7069 | if (*option == '+') |
| 7070 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 7071 | (void) QueryColorCompliance("none",AllCompliance, |
| 7072 | &image_info->transparent_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7073 | (void) SetImageOption(image_info,option+1,"none"); |
| 7074 | break; |
| 7075 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 7076 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 7077 | &image_info->transparent_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7078 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7079 | break; |
| 7080 | } |
| 7081 | if (LocaleCompare("type",option+1) == 0) |
| 7082 | { |
| 7083 | if (*option == '+') |
| 7084 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7085 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7086 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7087 | break; |
| 7088 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7089 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7090 | MagickFalse,argv[i+1]); |
| 7091 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7092 | break; |
| 7093 | } |
| 7094 | break; |
| 7095 | } |
| 7096 | case 'u': |
| 7097 | { |
| 7098 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7099 | { |
| 7100 | if (*option == '+') |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 7101 | (void) DeleteImageOption(image_info,option+1); |
| 7102 | else |
| 7103 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7104 | break; |
| 7105 | } |
| 7106 | if (LocaleCompare("units",option+1) == 0) |
| 7107 | { |
| 7108 | if (*option == '+') |
| 7109 | { |
| 7110 | image_info->units=UndefinedResolution; |
| 7111 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7112 | break; |
| 7113 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7114 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7115 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7116 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7117 | break; |
| 7118 | } |
| 7119 | break; |
| 7120 | } |
| 7121 | case 'v': |
| 7122 | { |
| 7123 | if (LocaleCompare("verbose",option+1) == 0) |
| 7124 | { |
| 7125 | if (*option == '+') |
| 7126 | { |
| 7127 | image_info->verbose=MagickFalse; |
| 7128 | break; |
| 7129 | } |
| 7130 | image_info->verbose=MagickTrue; |
| 7131 | image_info->ping=MagickFalse; |
| 7132 | break; |
| 7133 | } |
| 7134 | if (LocaleCompare("view",option+1) == 0) |
| 7135 | { |
| 7136 | if (*option == '+') |
| 7137 | { |
| 7138 | if (image_info->view != (char *) NULL) |
| 7139 | image_info->view=DestroyString(image_info->view); |
| 7140 | break; |
| 7141 | } |
| 7142 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7143 | break; |
| 7144 | } |
| 7145 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7146 | { |
| 7147 | if (*option == '+') |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 7148 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7149 | else |
| 7150 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7151 | break; |
| 7152 | } |
| 7153 | break; |
| 7154 | } |
| 7155 | case 'w': |
| 7156 | { |
| 7157 | if (LocaleCompare("white-point",option+1) == 0) |
| 7158 | { |
| 7159 | if (*option == '+') |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 7160 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7161 | else |
| 7162 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7163 | break; |
| 7164 | } |
| 7165 | break; |
| 7166 | } |
| 7167 | default: |
| 7168 | break; |
| 7169 | } |
| 7170 | i+=count; |
| 7171 | } |
| 7172 | return(MagickTrue); |
| 7173 | } |
| 7174 | |
| 7175 | /* |
| 7176 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7177 | % % |
| 7178 | % % |
| 7179 | % % |
| 7180 | + M o g r i f y I m a g e L i s t % |
| 7181 | % % |
| 7182 | % % |
| 7183 | % % |
| 7184 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7185 | % |
| 7186 | % MogrifyImageList() applies any command line options that might affect the |
| 7187 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7188 | % |
| 7189 | % The format of the MogrifyImage method is: |
| 7190 | % |
| 7191 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7192 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7193 | % |
| 7194 | % A description of each parameter follows: |
| 7195 | % |
| 7196 | % o image_info: the image info.. |
| 7197 | % |
| 7198 | % o argc: Specifies a pointer to an integer describing the number of |
| 7199 | % elements in the argument vector. |
| 7200 | % |
| 7201 | % o argv: Specifies a pointer to a text array containing the command line |
| 7202 | % arguments. |
| 7203 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7204 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7205 | % |
| 7206 | % o exception: return any errors or warnings in this structure. |
| 7207 | % |
| 7208 | */ |
| 7209 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7210 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7211 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7212 | const char |
| 7213 | *option; |
| 7214 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7215 | ImageInfo |
| 7216 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7217 | |
| 7218 | MagickStatusType |
| 7219 | status; |
| 7220 | |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7221 | PixelInterpolateMethod |
| 7222 | interpolate_method; |
| 7223 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7224 | QuantizeInfo |
| 7225 | *quantize_info; |
| 7226 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7227 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7228 | i; |
| 7229 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7230 | ssize_t |
| 7231 | count, |
| 7232 | index; |
| 7233 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7234 | /* |
| 7235 | Apply options to the image list. |
| 7236 | */ |
| 7237 | assert(image_info != (ImageInfo *) NULL); |
| 7238 | assert(image_info->signature == MagickSignature); |
| 7239 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7240 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7241 | assert((*images)->signature == MagickSignature); |
| 7242 | if ((*images)->debug != MagickFalse) |
| 7243 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7244 | (*images)->filename); |
| 7245 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7246 | return(MagickTrue); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7247 | interpolate_method=UndefinedInterpolatePixel; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7248 | mogrify_info=CloneImageInfo(image_info); |
| 7249 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7250 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7251 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7252 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7253 | if (*images == (Image *) NULL) |
| 7254 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7255 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7256 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7257 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7258 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7259 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7260 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7261 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7262 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7263 | switch (*(option+1)) |
| 7264 | { |
| 7265 | case 'a': |
| 7266 | { |
| 7267 | if (LocaleCompare("affinity",option+1) == 0) |
| 7268 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7269 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7270 | if (*option == '+') |
| 7271 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7272 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7273 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7274 | break; |
| 7275 | } |
| 7276 | i++; |
| 7277 | break; |
| 7278 | } |
| 7279 | if (LocaleCompare("append",option+1) == 0) |
| 7280 | { |
| 7281 | Image |
| 7282 | *append_image; |
| 7283 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7284 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7285 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7286 | MagickFalse,exception); |
| 7287 | if (append_image == (Image *) NULL) |
| 7288 | { |
| 7289 | status=MagickFalse; |
| 7290 | break; |
| 7291 | } |
| 7292 | *images=DestroyImageList(*images); |
| 7293 | *images=append_image; |
| 7294 | break; |
| 7295 | } |
| 7296 | if (LocaleCompare("average",option+1) == 0) |
| 7297 | { |
| 7298 | Image |
| 7299 | *average_image; |
| 7300 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7301 | /* |
| 7302 | Average an image sequence (deprecated). |
| 7303 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7304 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7305 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7306 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7307 | if (average_image == (Image *) NULL) |
| 7308 | { |
| 7309 | status=MagickFalse; |
| 7310 | break; |
| 7311 | } |
| 7312 | *images=DestroyImageList(*images); |
| 7313 | *images=average_image; |
| 7314 | break; |
| 7315 | } |
| 7316 | break; |
| 7317 | } |
| 7318 | case 'c': |
| 7319 | { |
| 7320 | if (LocaleCompare("channel",option+1) == 0) |
| 7321 | { |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7322 | ChannelType |
| 7323 | channel; |
| 7324 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7325 | if (*option == '+') |
| 7326 | { |
| 7327 | channel=DefaultChannels; |
| 7328 | break; |
| 7329 | } |
| 7330 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | e2a912b | 2011-12-05 20:02:07 +0000 | [diff] [blame] | 7331 | SetPixelChannelMapMask(*images,channel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7332 | break; |
| 7333 | } |
| 7334 | if (LocaleCompare("clut",option+1) == 0) |
| 7335 | { |
| 7336 | Image |
| 7337 | *clut_image, |
| 7338 | *image; |
| 7339 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7340 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7341 | image=RemoveFirstImageFromList(images); |
| 7342 | clut_image=RemoveFirstImageFromList(images); |
| 7343 | if (clut_image == (Image *) NULL) |
| 7344 | { |
| 7345 | status=MagickFalse; |
| 7346 | break; |
| 7347 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7348 | (void) ClutImage(image,clut_image,interpolate_method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7349 | clut_image=DestroyImage(clut_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7350 | *images=DestroyImageList(*images); |
| 7351 | *images=image; |
| 7352 | break; |
| 7353 | } |
| 7354 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7355 | { |
| 7356 | Image |
| 7357 | *coalesce_image; |
| 7358 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7359 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7360 | coalesce_image=CoalesceImages(*images,exception); |
| 7361 | if (coalesce_image == (Image *) NULL) |
| 7362 | { |
| 7363 | status=MagickFalse; |
| 7364 | break; |
| 7365 | } |
| 7366 | *images=DestroyImageList(*images); |
| 7367 | *images=coalesce_image; |
| 7368 | break; |
| 7369 | } |
| 7370 | if (LocaleCompare("combine",option+1) == 0) |
| 7371 | { |
| 7372 | Image |
| 7373 | *combine_image; |
| 7374 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7375 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 7376 | combine_image=CombineImages(*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7377 | if (combine_image == (Image *) NULL) |
| 7378 | { |
| 7379 | status=MagickFalse; |
| 7380 | break; |
| 7381 | } |
| 7382 | *images=DestroyImageList(*images); |
| 7383 | *images=combine_image; |
| 7384 | break; |
| 7385 | } |
| 7386 | if (LocaleCompare("composite",option+1) == 0) |
| 7387 | { |
| 7388 | Image |
| 7389 | *mask_image, |
| 7390 | *composite_image, |
| 7391 | *image; |
| 7392 | |
| 7393 | RectangleInfo |
| 7394 | geometry; |
| 7395 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7396 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7397 | image=RemoveFirstImageFromList(images); |
| 7398 | composite_image=RemoveFirstImageFromList(images); |
| 7399 | if (composite_image == (Image *) NULL) |
| 7400 | { |
| 7401 | status=MagickFalse; |
| 7402 | break; |
| 7403 | } |
| 7404 | (void) TransformImage(&composite_image,(char *) NULL, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 7405 | composite_image->geometry,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7406 | SetGeometry(composite_image,&geometry); |
| 7407 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7408 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7409 | &geometry); |
| 7410 | mask_image=RemoveFirstImageFromList(images); |
| 7411 | if (mask_image != (Image *) NULL) |
| 7412 | { |
| 7413 | if ((image->compose == DisplaceCompositeOp) || |
| 7414 | (image->compose == DistortCompositeOp)) |
| 7415 | { |
| 7416 | /* |
| 7417 | Merge Y displacement into X displacement image. |
| 7418 | */ |
| 7419 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 7420 | mask_image,0,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7421 | mask_image=DestroyImage(mask_image); |
| 7422 | } |
| 7423 | else |
| 7424 | { |
| 7425 | /* |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 7426 | Set a blending mask for the composition. |
| 7427 | Possible problem, what if image->mask already set. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7428 | */ |
cristy | 10a6c61 | 2012-01-29 21:41:05 +0000 | [diff] [blame^] | 7429 | (void) NegateImage(mask_image,MagickFalse,exception); |
| 7430 | (void) SetImageMask(image,mask_image,exception); |
| 7431 | mask_image=DestroyImage(mask_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7432 | } |
| 7433 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7434 | (void) CompositeImage(image,image->compose,composite_image, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 7435 | geometry.x,geometry.y,exception); |
cristy | 10a6c61 | 2012-01-29 21:41:05 +0000 | [diff] [blame^] | 7436 | (void) SetImageMask(image,(Image *) NULL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7437 | composite_image=DestroyImage(composite_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7438 | *images=DestroyImageList(*images); |
| 7439 | *images=image; |
| 7440 | break; |
| 7441 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7442 | break; |
| 7443 | } |
| 7444 | case 'd': |
| 7445 | { |
| 7446 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7447 | { |
| 7448 | Image |
| 7449 | *deconstruct_image; |
| 7450 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7451 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7452 | deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer, |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 7453 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7454 | if (deconstruct_image == (Image *) NULL) |
| 7455 | { |
| 7456 | status=MagickFalse; |
| 7457 | break; |
| 7458 | } |
| 7459 | *images=DestroyImageList(*images); |
| 7460 | *images=deconstruct_image; |
| 7461 | break; |
| 7462 | } |
| 7463 | if (LocaleCompare("delete",option+1) == 0) |
| 7464 | { |
| 7465 | if (*option == '+') |
| 7466 | DeleteImages(images,"-1",exception); |
| 7467 | else |
| 7468 | DeleteImages(images,argv[i+1],exception); |
| 7469 | break; |
| 7470 | } |
| 7471 | if (LocaleCompare("dither",option+1) == 0) |
| 7472 | { |
| 7473 | if (*option == '+') |
| 7474 | { |
| 7475 | quantize_info->dither=MagickFalse; |
| 7476 | break; |
| 7477 | } |
| 7478 | quantize_info->dither=MagickTrue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7479 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7480 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7481 | break; |
| 7482 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7483 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7484 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7485 | Image |
| 7486 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7487 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7488 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7489 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7490 | else |
| 7491 | { |
| 7492 | const char |
| 7493 | *p; |
| 7494 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7495 | size_t |
| 7496 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7497 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7498 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7499 | p=strchr(argv[i+1],','); |
| 7500 | if (p == (const char *) NULL) |
| 7501 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7502 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7503 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7504 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7505 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7506 | } |
| 7507 | AppendImageToList(images, duplicate_images); |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7508 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7509 | break; |
| 7510 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7511 | break; |
| 7512 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7513 | case 'e': |
| 7514 | { |
| 7515 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7516 | { |
| 7517 | Image |
| 7518 | *evaluate_image; |
| 7519 | |
| 7520 | MagickEvaluateOperator |
| 7521 | op; |
| 7522 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7523 | (void) SyncImageSettings(mogrify_info,*images,exception); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7524 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 7525 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7526 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7527 | if (evaluate_image == (Image *) NULL) |
| 7528 | { |
| 7529 | status=MagickFalse; |
| 7530 | break; |
| 7531 | } |
| 7532 | *images=DestroyImageList(*images); |
| 7533 | *images=evaluate_image; |
| 7534 | break; |
| 7535 | } |
| 7536 | break; |
| 7537 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7538 | case 'f': |
| 7539 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7540 | if (LocaleCompare("fft",option+1) == 0) |
| 7541 | { |
| 7542 | Image |
| 7543 | *fourier_image; |
| 7544 | |
| 7545 | /* |
| 7546 | Implements the discrete Fourier transform (DFT). |
| 7547 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7548 | (void) SyncImageSettings(mogrify_info,*images,exception); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7549 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7550 | MagickTrue : MagickFalse,exception); |
| 7551 | if (fourier_image == (Image *) NULL) |
| 7552 | break; |
| 7553 | *images=DestroyImage(*images); |
| 7554 | *images=fourier_image; |
| 7555 | break; |
| 7556 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7557 | if (LocaleCompare("flatten",option+1) == 0) |
| 7558 | { |
| 7559 | Image |
| 7560 | *flatten_image; |
| 7561 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7562 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7563 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7564 | if (flatten_image == (Image *) NULL) |
| 7565 | break; |
| 7566 | *images=DestroyImageList(*images); |
| 7567 | *images=flatten_image; |
| 7568 | break; |
| 7569 | } |
| 7570 | if (LocaleCompare("fx",option+1) == 0) |
| 7571 | { |
| 7572 | Image |
| 7573 | *fx_image; |
| 7574 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7575 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 7576 | fx_image=FxImage(*images,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7577 | if (fx_image == (Image *) NULL) |
| 7578 | { |
| 7579 | status=MagickFalse; |
| 7580 | break; |
| 7581 | } |
| 7582 | *images=DestroyImageList(*images); |
| 7583 | *images=fx_image; |
| 7584 | break; |
| 7585 | } |
| 7586 | break; |
| 7587 | } |
| 7588 | case 'h': |
| 7589 | { |
| 7590 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7591 | { |
| 7592 | Image |
| 7593 | *hald_image, |
| 7594 | *image; |
| 7595 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7596 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7597 | image=RemoveFirstImageFromList(images); |
| 7598 | hald_image=RemoveFirstImageFromList(images); |
| 7599 | if (hald_image == (Image *) NULL) |
| 7600 | { |
| 7601 | status=MagickFalse; |
| 7602 | break; |
| 7603 | } |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 7604 | (void) HaldClutImage(image,hald_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7605 | hald_image=DestroyImage(hald_image); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7606 | if (*images != (Image *) NULL) |
| 7607 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7608 | *images=image; |
| 7609 | break; |
| 7610 | } |
| 7611 | break; |
| 7612 | } |
| 7613 | case 'i': |
| 7614 | { |
| 7615 | if (LocaleCompare("ift",option+1) == 0) |
| 7616 | { |
| 7617 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7618 | *fourier_image, |
| 7619 | *magnitude_image, |
| 7620 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7621 | |
| 7622 | /* |
| 7623 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7624 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7625 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7626 | magnitude_image=RemoveFirstImageFromList(images); |
| 7627 | phase_image=RemoveFirstImageFromList(images); |
| 7628 | if (phase_image == (Image *) NULL) |
| 7629 | { |
| 7630 | status=MagickFalse; |
| 7631 | break; |
| 7632 | } |
| 7633 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7634 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7635 | if (fourier_image == (Image *) NULL) |
| 7636 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7637 | if (*images != (Image *) NULL) |
| 7638 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7639 | *images=fourier_image; |
| 7640 | break; |
| 7641 | } |
| 7642 | if (LocaleCompare("insert",option+1) == 0) |
| 7643 | { |
| 7644 | Image |
| 7645 | *p, |
| 7646 | *q; |
| 7647 | |
| 7648 | index=0; |
| 7649 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7650 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7651 | p=RemoveLastImageFromList(images); |
| 7652 | if (p == (Image *) NULL) |
| 7653 | { |
| 7654 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7655 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7656 | status=MagickFalse; |
| 7657 | break; |
| 7658 | } |
| 7659 | q=p; |
| 7660 | if (index == 0) |
| 7661 | PrependImageToList(images,q); |
| 7662 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7663 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7664 | AppendImageToList(images,q); |
| 7665 | else |
| 7666 | { |
| 7667 | q=GetImageFromList(*images,index-1); |
| 7668 | if (q == (Image *) NULL) |
| 7669 | { |
| 7670 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7671 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7672 | status=MagickFalse; |
| 7673 | break; |
| 7674 | } |
| 7675 | InsertImageInList(&q,p); |
| 7676 | } |
| 7677 | *images=GetFirstImageInList(q); |
| 7678 | break; |
| 7679 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7680 | if (LocaleCompare("interpolate",option+1) == 0) |
| 7681 | { |
| 7682 | interpolate_method=(PixelInterpolateMethod) ParseCommandOption( |
| 7683 | MagickInterpolateOptions,MagickFalse,argv[i+1]); |
| 7684 | break; |
| 7685 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7686 | break; |
| 7687 | } |
| 7688 | case 'l': |
| 7689 | { |
| 7690 | if (LocaleCompare("layers",option+1) == 0) |
| 7691 | { |
| 7692 | Image |
| 7693 | *layers; |
| 7694 | |
| 7695 | ImageLayerMethod |
| 7696 | method; |
| 7697 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7698 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7699 | layers=(Image *) NULL; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7700 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7701 | MagickFalse,argv[i+1]); |
| 7702 | switch (method) |
| 7703 | { |
| 7704 | case CoalesceLayer: |
| 7705 | { |
| 7706 | layers=CoalesceImages(*images,exception); |
| 7707 | break; |
| 7708 | } |
| 7709 | case CompareAnyLayer: |
| 7710 | case CompareClearLayer: |
| 7711 | case CompareOverlayLayer: |
| 7712 | default: |
| 7713 | { |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7714 | layers=CompareImagesLayers(*images,method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7715 | break; |
| 7716 | } |
| 7717 | case MergeLayer: |
| 7718 | case FlattenLayer: |
| 7719 | case MosaicLayer: |
| 7720 | case TrimBoundsLayer: |
| 7721 | { |
| 7722 | layers=MergeImageLayers(*images,method,exception); |
| 7723 | break; |
| 7724 | } |
| 7725 | case DisposeLayer: |
| 7726 | { |
| 7727 | layers=DisposeImages(*images,exception); |
| 7728 | break; |
| 7729 | } |
| 7730 | case OptimizeImageLayer: |
| 7731 | { |
| 7732 | layers=OptimizeImageLayers(*images,exception); |
| 7733 | break; |
| 7734 | } |
| 7735 | case OptimizePlusLayer: |
| 7736 | { |
| 7737 | layers=OptimizePlusImageLayers(*images,exception); |
| 7738 | break; |
| 7739 | } |
| 7740 | case OptimizeTransLayer: |
| 7741 | { |
| 7742 | OptimizeImageTransparency(*images,exception); |
| 7743 | break; |
| 7744 | } |
| 7745 | case RemoveDupsLayer: |
| 7746 | { |
| 7747 | RemoveDuplicateLayers(images,exception); |
| 7748 | break; |
| 7749 | } |
| 7750 | case RemoveZeroLayer: |
| 7751 | { |
| 7752 | RemoveZeroDelayLayers(images,exception); |
| 7753 | break; |
| 7754 | } |
| 7755 | case OptimizeLayer: |
| 7756 | { |
| 7757 | /* |
| 7758 | General Purpose, GIF Animation Optimizer. |
| 7759 | */ |
| 7760 | layers=CoalesceImages(*images,exception); |
| 7761 | if (layers == (Image *) NULL) |
| 7762 | { |
| 7763 | status=MagickFalse; |
| 7764 | break; |
| 7765 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7766 | *images=DestroyImageList(*images); |
| 7767 | *images=layers; |
| 7768 | layers=OptimizeImageLayers(*images,exception); |
| 7769 | if (layers == (Image *) NULL) |
| 7770 | { |
| 7771 | status=MagickFalse; |
| 7772 | break; |
| 7773 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7774 | *images=DestroyImageList(*images); |
| 7775 | *images=layers; |
| 7776 | layers=(Image *) NULL; |
| 7777 | OptimizeImageTransparency(*images,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7778 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7779 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7780 | break; |
| 7781 | } |
| 7782 | case CompositeLayer: |
| 7783 | { |
| 7784 | CompositeOperator |
| 7785 | compose; |
| 7786 | |
| 7787 | Image |
| 7788 | *source; |
| 7789 | |
| 7790 | RectangleInfo |
| 7791 | geometry; |
| 7792 | |
| 7793 | /* |
| 7794 | Split image sequence at the first 'NULL:' image. |
| 7795 | */ |
| 7796 | source=(*images); |
| 7797 | while (source != (Image *) NULL) |
| 7798 | { |
| 7799 | source=GetNextImageInList(source); |
| 7800 | if ((source != (Image *) NULL) && |
| 7801 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7802 | break; |
| 7803 | } |
| 7804 | if (source != (Image *) NULL) |
| 7805 | { |
| 7806 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7807 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7808 | source=(Image *) NULL; |
| 7809 | else |
| 7810 | { |
| 7811 | /* |
| 7812 | Separate the two lists, junk the null: image. |
| 7813 | */ |
| 7814 | source=SplitImageList(source->previous); |
| 7815 | DeleteImageFromList(&source); |
| 7816 | } |
| 7817 | } |
| 7818 | if (source == (Image *) NULL) |
| 7819 | { |
| 7820 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7821 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7822 | status=MagickFalse; |
| 7823 | break; |
| 7824 | } |
| 7825 | /* |
| 7826 | Adjust offset with gravity and virtual canvas. |
| 7827 | */ |
| 7828 | SetGeometry(*images,&geometry); |
| 7829 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7830 | geometry.width=source->page.width != 0 ? |
| 7831 | source->page.width : source->columns; |
| 7832 | geometry.height=source->page.height != 0 ? |
| 7833 | source->page.height : source->rows; |
| 7834 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7835 | (*images)->page.width : (*images)->columns, |
| 7836 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7837 | (*images)->rows,(*images)->gravity,&geometry); |
| 7838 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7839 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7840 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7841 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7842 | MagickComposeOptions,MagickFalse,option); |
| 7843 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7844 | exception); |
| 7845 | source=DestroyImageList(source); |
| 7846 | break; |
| 7847 | } |
| 7848 | } |
| 7849 | if (layers == (Image *) NULL) |
| 7850 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7851 | *images=DestroyImageList(*images); |
| 7852 | *images=layers; |
| 7853 | break; |
| 7854 | } |
| 7855 | break; |
| 7856 | } |
| 7857 | case 'm': |
| 7858 | { |
| 7859 | if (LocaleCompare("map",option+1) == 0) |
| 7860 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7861 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7862 | if (*option == '+') |
| 7863 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7864 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7865 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7866 | break; |
| 7867 | } |
| 7868 | i++; |
| 7869 | break; |
| 7870 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7871 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7872 | { |
| 7873 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7874 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7875 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7876 | /* |
| 7877 | Maximum image sequence (deprecated). |
| 7878 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7879 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7880 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7881 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7882 | { |
| 7883 | status=MagickFalse; |
| 7884 | break; |
| 7885 | } |
| 7886 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7887 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7888 | break; |
| 7889 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7890 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7891 | { |
| 7892 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7893 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7894 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7895 | /* |
| 7896 | Minimum image sequence (deprecated). |
| 7897 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7898 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7899 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7900 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7901 | { |
| 7902 | status=MagickFalse; |
| 7903 | break; |
| 7904 | } |
| 7905 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7906 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7907 | break; |
| 7908 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7909 | if (LocaleCompare("morph",option+1) == 0) |
| 7910 | { |
| 7911 | Image |
| 7912 | *morph_image; |
| 7913 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7914 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7915 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7916 | exception); |
| 7917 | if (morph_image == (Image *) NULL) |
| 7918 | { |
| 7919 | status=MagickFalse; |
| 7920 | break; |
| 7921 | } |
| 7922 | *images=DestroyImageList(*images); |
| 7923 | *images=morph_image; |
| 7924 | break; |
| 7925 | } |
| 7926 | if (LocaleCompare("mosaic",option+1) == 0) |
| 7927 | { |
| 7928 | Image |
| 7929 | *mosaic_image; |
| 7930 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7931 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7932 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 7933 | if (mosaic_image == (Image *) NULL) |
| 7934 | { |
| 7935 | status=MagickFalse; |
| 7936 | break; |
| 7937 | } |
| 7938 | *images=DestroyImageList(*images); |
| 7939 | *images=mosaic_image; |
| 7940 | break; |
| 7941 | } |
| 7942 | break; |
| 7943 | } |
| 7944 | case 'p': |
| 7945 | { |
| 7946 | if (LocaleCompare("print",option+1) == 0) |
| 7947 | { |
| 7948 | char |
| 7949 | *string; |
| 7950 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7951 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7952 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1], |
| 7953 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7954 | if (string == (char *) NULL) |
| 7955 | break; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 7956 | (void) FormatLocaleFile(stdout,"%s",string); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7957 | string=DestroyString(string); |
| 7958 | } |
| 7959 | if (LocaleCompare("process",option+1) == 0) |
| 7960 | { |
| 7961 | char |
| 7962 | **arguments; |
| 7963 | |
| 7964 | int |
| 7965 | j, |
| 7966 | number_arguments; |
| 7967 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7968 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7969 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 7970 | if (arguments == (char **) NULL) |
| 7971 | break; |
| 7972 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 7973 | { |
| 7974 | char |
| 7975 | breaker, |
| 7976 | quote, |
| 7977 | *token; |
| 7978 | |
| 7979 | const char |
| 7980 | *arguments; |
| 7981 | |
| 7982 | int |
| 7983 | next, |
| 7984 | status; |
| 7985 | |
| 7986 | size_t |
| 7987 | length; |
| 7988 | |
| 7989 | TokenInfo |
| 7990 | *token_info; |
| 7991 | |
| 7992 | /* |
| 7993 | Support old style syntax, filter="-option arg". |
| 7994 | */ |
| 7995 | length=strlen(argv[i+1]); |
| 7996 | token=(char *) NULL; |
cristy | 37e0b38 | 2011-06-07 13:31:21 +0000 | [diff] [blame] | 7997 | if (~length >= (MaxTextExtent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7998 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 7999 | sizeof(*token)); |
| 8000 | if (token == (char *) NULL) |
| 8001 | break; |
| 8002 | next=0; |
| 8003 | arguments=argv[i+1]; |
| 8004 | token_info=AcquireTokenInfo(); |
| 8005 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8006 | "\"",'\0',&breaker,&next,"e); |
| 8007 | token_info=DestroyTokenInfo(token_info); |
| 8008 | if (status == 0) |
| 8009 | { |
| 8010 | const char |
| 8011 | *argv; |
| 8012 | |
| 8013 | argv=(&(arguments[next])); |
| 8014 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8015 | exception); |
| 8016 | } |
| 8017 | token=DestroyString(token); |
| 8018 | break; |
| 8019 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8020 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8021 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8022 | number_arguments-2,(const char **) arguments+2,exception); |
| 8023 | for (j=0; j < number_arguments; j++) |
| 8024 | arguments[j]=DestroyString(arguments[j]); |
| 8025 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8026 | break; |
| 8027 | } |
| 8028 | break; |
| 8029 | } |
| 8030 | case 'r': |
| 8031 | { |
| 8032 | if (LocaleCompare("reverse",option+1) == 0) |
| 8033 | { |
| 8034 | ReverseImageList(images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8035 | break; |
| 8036 | } |
| 8037 | break; |
| 8038 | } |
| 8039 | case 's': |
| 8040 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8041 | if (LocaleCompare("smush",option+1) == 0) |
| 8042 | { |
| 8043 | Image |
| 8044 | *smush_image; |
| 8045 | |
| 8046 | ssize_t |
| 8047 | offset; |
| 8048 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8049 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8050 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8051 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8052 | MagickFalse,offset,exception); |
| 8053 | if (smush_image == (Image *) NULL) |
| 8054 | { |
| 8055 | status=MagickFalse; |
| 8056 | break; |
| 8057 | } |
| 8058 | *images=DestroyImageList(*images); |
| 8059 | *images=smush_image; |
| 8060 | break; |
| 8061 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8062 | if (LocaleCompare("swap",option+1) == 0) |
| 8063 | { |
| 8064 | Image |
| 8065 | *p, |
| 8066 | *q, |
| 8067 | *swap; |
| 8068 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8069 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8070 | swap_index; |
| 8071 | |
| 8072 | index=(-1); |
| 8073 | swap_index=(-2); |
| 8074 | if (*option != '+') |
| 8075 | { |
| 8076 | GeometryInfo |
| 8077 | geometry_info; |
| 8078 | |
| 8079 | MagickStatusType |
| 8080 | flags; |
| 8081 | |
| 8082 | swap_index=(-1); |
| 8083 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8084 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8085 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8086 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8087 | } |
| 8088 | p=GetImageFromList(*images,index); |
| 8089 | q=GetImageFromList(*images,swap_index); |
| 8090 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8091 | { |
| 8092 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8093 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8094 | status=MagickFalse; |
| 8095 | break; |
| 8096 | } |
| 8097 | if (p == q) |
| 8098 | break; |
| 8099 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8100 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8101 | ReplaceImageInList(&q,swap); |
| 8102 | *images=GetFirstImageInList(q); |
| 8103 | break; |
| 8104 | } |
| 8105 | break; |
| 8106 | } |
| 8107 | case 'w': |
| 8108 | { |
| 8109 | if (LocaleCompare("write",option+1) == 0) |
| 8110 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8111 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8112 | key[MaxTextExtent]; |
| 8113 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8114 | Image |
| 8115 | *write_images; |
| 8116 | |
| 8117 | ImageInfo |
| 8118 | *write_info; |
| 8119 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8120 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8121 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8122 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8123 | write_images=(*images); |
| 8124 | if (*option == '+') |
| 8125 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8126 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8127 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8128 | write_info=DestroyImageInfo(write_info); |
| 8129 | if (*option == '+') |
| 8130 | write_images=DestroyImageList(write_images); |
| 8131 | break; |
| 8132 | } |
| 8133 | break; |
| 8134 | } |
| 8135 | default: |
| 8136 | break; |
| 8137 | } |
| 8138 | i+=count; |
| 8139 | } |
| 8140 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8141 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8142 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8143 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8144 | } |
| 8145 | |
| 8146 | /* |
| 8147 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8148 | % % |
| 8149 | % % |
| 8150 | % % |
| 8151 | + M o g r i f y I m a g e s % |
| 8152 | % % |
| 8153 | % % |
| 8154 | % % |
| 8155 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8156 | % |
| 8157 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8158 | % prescribed by command line options. |
| 8159 | % |
| 8160 | % The format of the MogrifyImage method is: |
| 8161 | % |
| 8162 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8163 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8164 | % Image **images,Exceptioninfo *exception) |
| 8165 | % |
| 8166 | % A description of each parameter follows: |
| 8167 | % |
| 8168 | % o image_info: the image info.. |
| 8169 | % |
| 8170 | % o post: If true, post process image list operators otherwise pre-process. |
| 8171 | % |
| 8172 | % o argc: Specifies a pointer to an integer describing the number of |
| 8173 | % elements in the argument vector. |
| 8174 | % |
| 8175 | % o argv: Specifies a pointer to a text array containing the command line |
| 8176 | % arguments. |
| 8177 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8178 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8179 | % |
| 8180 | % o exception: return any errors or warnings in this structure. |
| 8181 | % |
| 8182 | */ |
| 8183 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8184 | const MagickBooleanType post,const int argc,const char **argv, |
| 8185 | Image **images,ExceptionInfo *exception) |
| 8186 | { |
| 8187 | #define MogrifyImageTag "Mogrify/Image" |
| 8188 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8189 | MagickStatusType |
| 8190 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8191 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8192 | MagickBooleanType |
| 8193 | proceed; |
| 8194 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8195 | size_t |
| 8196 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8197 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8198 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8199 | i; |
| 8200 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8201 | assert(image_info != (ImageInfo *) NULL); |
| 8202 | assert(image_info->signature == MagickSignature); |
| 8203 | if (images == (Image **) NULL) |
| 8204 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8205 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8206 | assert((*images)->signature == MagickSignature); |
| 8207 | if ((*images)->debug != MagickFalse) |
| 8208 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8209 | (*images)->filename); |
| 8210 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8211 | return(MagickTrue); |
| 8212 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8213 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8214 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8215 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8216 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8217 | (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc, |
| 8218 | post?"post":"pre"); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8219 | #endif |
| 8220 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8221 | /* |
| 8222 | Pre-process multi-image sequence operators |
| 8223 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8224 | if (post == MagickFalse) |
| 8225 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8226 | /* |
| 8227 | For each image, process simple single image operators |
| 8228 | */ |
| 8229 | i=0; |
| 8230 | n=GetImageListLength(*images); |
cristy | 9f027d1 | 2011-09-21 01:17:17 +0000 | [diff] [blame] | 8231 | for ( ; ; ) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8232 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8233 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8234 | (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long) |
| 8235 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8236 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8237 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8238 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8239 | if (proceed == MagickFalse) |
| 8240 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8241 | if ( (*images)->next == (Image *) NULL ) |
| 8242 | break; |
| 8243 | *images=(*images)->next; |
| 8244 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8245 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8246 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8247 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8248 | (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long) |
| 8249 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8250 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8251 | |
| 8252 | /* |
| 8253 | Post-process, multi-image sequence operators |
| 8254 | */ |
| 8255 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8256 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8257 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8258 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8259 | } |