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, |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 132 | number_threads; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 133 | |
cristy | 118fc66 | 2012-02-11 00:02:25 +0000 | [diff] [blame] | 134 | ssize_t |
| 135 | n; |
| 136 | |
cristy | d0a94fa | 2010-03-12 14:18:11 +0000 | [diff] [blame] | 137 | (void) setlocale(LC_ALL,""); |
| 138 | (void) setlocale(LC_NUMERIC,"C"); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 139 | concurrent=MagickFalse; |
| 140 | duration=(-1.0); |
| 141 | iterations=1; |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 142 | status=MagickFalse; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 143 | regard_warnings=MagickFalse; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 144 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 145 | { |
| 146 | option=argv[i]; |
| 147 | if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) |
| 148 | continue; |
| 149 | if (LocaleCompare("bench",option+1) == 0) |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 150 | iterations=StringToUnsignedLong(argv[++i]); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 151 | if (LocaleCompare("concurrent",option+1) == 0) |
| 152 | concurrent=MagickTrue; |
| 153 | if (LocaleCompare("debug",option+1) == 0) |
| 154 | (void) SetLogEventMask(argv[++i]); |
| 155 | if (LocaleCompare("duration",option+1) == 0) |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 156 | duration=StringToDouble(argv[++i],(char **) NULL); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 157 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 158 | regard_warnings=MagickTrue; |
| 159 | } |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 160 | if (iterations == 1) |
| 161 | { |
| 162 | status=command(image_info,argc,argv,metadata,exception); |
| 163 | if (exception->severity != UndefinedException) |
| 164 | { |
| 165 | if ((exception->severity > ErrorException) || |
| 166 | (regard_warnings != MagickFalse)) |
| 167 | status=MagickTrue; |
| 168 | CatchException(exception); |
| 169 | } |
| 170 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 171 | { |
| 172 | (void) fputs(*metadata,stdout); |
| 173 | (void) fputc('\n',stdout); |
| 174 | *metadata=DestroyString(*metadata); |
| 175 | } |
| 176 | return(status); |
| 177 | } |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 178 | number_threads=GetOpenMPMaximumThreads(); |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 179 | serial=0.0; |
cristy | 118fc66 | 2012-02-11 00:02:25 +0000 | [diff] [blame] | 180 | for (n=1; n <= (ssize_t) number_threads; n++) |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 181 | { |
| 182 | double |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 183 | e, |
| 184 | parallel, |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 185 | user_time; |
| 186 | |
| 187 | TimerInfo |
| 188 | *timer; |
| 189 | |
cristy | 118fc66 | 2012-02-11 00:02:25 +0000 | [diff] [blame] | 190 | SetOpenMPMaximumThreads((int) n); |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 191 | timer=AcquireTimerInfo(); |
| 192 | if (concurrent == MagickFalse) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 193 | { |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 194 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 195 | { |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 196 | if (status != MagickFalse) |
| 197 | continue; |
| 198 | if (duration > 0) |
| 199 | { |
| 200 | if (GetElapsedTime(timer) > duration) |
| 201 | continue; |
| 202 | (void) ContinueTimer(timer); |
| 203 | } |
| 204 | status=command(image_info,argc,argv,metadata,exception); |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 205 | if (exception->severity != UndefinedException) |
| 206 | { |
| 207 | if ((exception->severity > ErrorException) || |
| 208 | (regard_warnings != MagickFalse)) |
| 209 | status=MagickTrue; |
| 210 | CatchException(exception); |
| 211 | } |
| 212 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 213 | { |
| 214 | (void) fputs(*metadata,stdout); |
| 215 | (void) fputc('\n',stdout); |
| 216 | *metadata=DestroyString(*metadata); |
| 217 | } |
| 218 | } |
| 219 | } |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 220 | else |
| 221 | { |
| 222 | SetOpenMPNested(1); |
| 223 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
| 224 | # pragma omp parallel for shared(status) |
| 225 | #endif |
| 226 | for (i=0; i < (ssize_t) iterations; i++) |
| 227 | { |
| 228 | if (status != MagickFalse) |
| 229 | continue; |
| 230 | if (duration > 0) |
| 231 | { |
| 232 | if (GetElapsedTime(timer) > duration) |
| 233 | continue; |
| 234 | (void) ContinueTimer(timer); |
| 235 | } |
| 236 | status=command(image_info,argc,argv,metadata,exception); |
| 237 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
| 238 | # pragma omp critical (MagickCore_CommandGenesis) |
| 239 | #endif |
| 240 | { |
| 241 | if (exception->severity != UndefinedException) |
| 242 | { |
| 243 | if ((exception->severity > ErrorException) || |
| 244 | (regard_warnings != MagickFalse)) |
| 245 | status=MagickTrue; |
| 246 | CatchException(exception); |
| 247 | } |
| 248 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 249 | { |
| 250 | (void) fputs(*metadata,stdout); |
| 251 | (void) fputc('\n',stdout); |
| 252 | *metadata=DestroyString(*metadata); |
| 253 | } |
| 254 | } |
| 255 | } |
| 256 | } |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 257 | user_time=GetUserTime(timer); |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 258 | parallel=GetElapsedTime(timer); |
| 259 | e=1.0; |
| 260 | if (n == 1) |
| 261 | serial=parallel; |
| 262 | else |
| 263 | e=((1.0/(1.0/((serial/(serial+parallel))+(1.0-(serial/(serial+parallel)))/ |
| 264 | (double) n)))-(1.0/(double) n))/(1.0-1.0/(double) n); |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 265 | (void) FormatLocaleFile(stderr, |
cristy | 91ce84d | 2011-12-09 23:02:25 +0000 | [diff] [blame] | 266 | "Performance[%.20g]: %.20gi %0.3fips %0.3fe %0.3fu %lu:%02lu.%03lu\n", |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 267 | (double) n,(double) iterations,(double) iterations/parallel,e, |
| 268 | user_time,(unsigned long) (parallel/60.0),(unsigned long) |
| 269 | floor(fmod(parallel,60.0)),(unsigned long) |
| 270 | (1000.0*(parallel-floor(parallel))+0.5)); |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 271 | timer=DestroyTimerInfo(timer); |
| 272 | } |
cristy | 1f9e1ed | 2009-11-18 04:09:38 +0000 | [diff] [blame] | 273 | return(status); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | /* |
| 277 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 278 | % % |
| 279 | % % |
| 280 | % % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 281 | + M o g r i f y I m a g e % |
| 282 | % % |
| 283 | % % |
| 284 | % % |
| 285 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 286 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 287 | % MogrifyImage() applies simple single image processing options to a single |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 288 | % image that may be part of a large list, but also handles any 'region' |
| 289 | % image handling. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 290 | % |
| 291 | % The image in the list may be modified in three different ways... |
| 292 | % |
| 293 | % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 294 | % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 295 | % * replace by a list of images (only the -separate option!) |
| 296 | % |
| 297 | % In each case the result is returned into the list, and a pointer to the |
| 298 | % modified image (last image added if replaced by a list of images) is |
| 299 | % returned. |
| 300 | % |
| 301 | % ASIDE: The -crop is present but restricted to non-tile single image crops |
| 302 | % |
| 303 | % This means if all the images are being processed (such as by |
| 304 | % MogrifyImages(), next image to be processed will be as per the pointer |
| 305 | % (*image)->next. Also the image list may grow as a result of some specific |
| 306 | % operations but as images are never merged or deleted, it will never shrink |
| 307 | % in length. Typically the list will remain the same length. |
| 308 | % |
| 309 | % WARNING: As the image pointed to may be replaced, the first image in the |
| 310 | % list may also change. GetFirstImageInList() should be used by caller if |
| 311 | % they wish return the Image pointer to the first image in list. |
| 312 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 313 | % |
| 314 | % The format of the MogrifyImage method is: |
| 315 | % |
| 316 | % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 317 | % const char **argv,Image **image) |
| 318 | % |
| 319 | % A description of each parameter follows: |
| 320 | % |
| 321 | % o image_info: the image info.. |
| 322 | % |
| 323 | % o argc: Specifies a pointer to an integer describing the number of |
| 324 | % elements in the argument vector. |
| 325 | % |
| 326 | % o argv: Specifies a pointer to a text array containing the command line |
| 327 | % arguments. |
| 328 | % |
| 329 | % o image: the image. |
| 330 | % |
| 331 | % o exception: return any errors or warnings in this structure. |
| 332 | % |
| 333 | */ |
| 334 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 335 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 336 | ExceptionInfo *exception) |
| 337 | { |
| 338 | char |
| 339 | key[MaxTextExtent]; |
| 340 | |
| 341 | ExceptionInfo |
| 342 | *sans_exception; |
| 343 | |
| 344 | Image |
| 345 | *image; |
| 346 | |
| 347 | ImageInfo |
| 348 | *read_info; |
| 349 | |
cristy | fcd785b | 2011-11-08 01:48:33 +0000 | [diff] [blame] | 350 | /* |
anthony | 32d85bf | 2012-02-15 14:54:59 +0000 | [diff] [blame] | 351 | Read an image into a image cache (for repeated usage) if not already in |
| 352 | cache. Then return the image that is in the cache. |
cristy | fcd785b | 2011-11-08 01:48:33 +0000 | [diff] [blame] | 353 | */ |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 354 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 355 | sans_exception=AcquireExceptionInfo(); |
| 356 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 357 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 358 | if (image != (Image *) NULL) |
| 359 | return(image); |
| 360 | read_info=CloneImageInfo(image_info); |
| 361 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 362 | image=ReadImage(read_info,exception); |
| 363 | read_info=DestroyImageInfo(read_info); |
| 364 | if (image != (Image *) NULL) |
| 365 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 366 | return(image); |
| 367 | } |
| 368 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 369 | static MagickBooleanType IsPathWritable(const char *path) |
| 370 | { |
| 371 | if (IsPathAccessible(path) == MagickFalse) |
| 372 | return(MagickFalse); |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 373 | if (access_utf8(path,W_OK) != 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 374 | return(MagickFalse); |
| 375 | return(MagickTrue); |
| 376 | } |
| 377 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 378 | static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 379 | { |
| 380 | if (x > y) |
| 381 | return(x); |
| 382 | return(y); |
| 383 | } |
| 384 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 385 | static MagickBooleanType MonitorProgress(const char *text, |
| 386 | const MagickOffsetType offset,const MagickSizeType extent, |
| 387 | void *wand_unused(client_data)) |
| 388 | { |
| 389 | char |
| 390 | message[MaxTextExtent], |
| 391 | tag[MaxTextExtent]; |
| 392 | |
| 393 | const char |
| 394 | *locale_message; |
| 395 | |
| 396 | register char |
| 397 | *p; |
| 398 | |
| 399 | if (extent < 2) |
| 400 | return(MagickTrue); |
| 401 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 402 | p=strrchr(tag,'/'); |
| 403 | if (p != (char *) NULL) |
| 404 | *p='\0'; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 405 | (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 406 | locale_message=GetLocaleMessage(message); |
| 407 | if (locale_message == message) |
| 408 | locale_message=tag; |
| 409 | if (p == (char *) NULL) |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 410 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", |
| 411 | locale_message,(long) offset,(unsigned long) extent,(long) |
| 412 | (100L*offset/(extent-1))); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 413 | else |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 414 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 415 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 416 | (100L*offset/(extent-1))); |
| 417 | if (offset == (MagickOffsetType) (extent-1)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 418 | (void) FormatLocaleFile(stderr,"\n"); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 419 | (void) fflush(stderr); |
| 420 | return(MagickTrue); |
| 421 | } |
| 422 | |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 423 | static Image *SparseColorOption(const Image *image, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 424 | const SparseColorMethod method,const char *arguments, |
| 425 | const MagickBooleanType color_from_image,ExceptionInfo *exception) |
| 426 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 427 | char |
| 428 | token[MaxTextExtent]; |
| 429 | |
| 430 | const char |
| 431 | *p; |
| 432 | |
| 433 | double |
| 434 | *sparse_arguments; |
| 435 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 436 | Image |
| 437 | *sparse_image; |
| 438 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 439 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 440 | color; |
| 441 | |
| 442 | MagickBooleanType |
| 443 | error; |
| 444 | |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 445 | register size_t |
| 446 | x; |
| 447 | |
| 448 | size_t |
| 449 | number_arguments, |
| 450 | number_colors; |
| 451 | |
cristy | f4425a7 | 2011-11-08 01:52:04 +0000 | [diff] [blame] | 452 | /* |
| 453 | SparseColorOption() parses the complex -sparse-color argument into an an |
| 454 | array of floating point values then calls SparseColorImage(). Argument is |
| 455 | a complex mix of floating-point pixel coodinates, and color specifications |
| 456 | (or direct floating point numbers). The number of floats needed to |
| 457 | represent a color varies depending on the current channel setting. |
| 458 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 459 | assert(image != (Image *) NULL); |
| 460 | assert(image->signature == MagickSignature); |
| 461 | if (image->debug != MagickFalse) |
| 462 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 463 | assert(exception != (ExceptionInfo *) NULL); |
| 464 | assert(exception->signature == MagickSignature); |
| 465 | /* |
| 466 | Limit channels according to image - and add up number of color channel. |
| 467 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 468 | number_colors=0; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 469 | if ((GetPixelRedTraits(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 ((GetPixelGreenTraits(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 ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 474 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 475 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 476 | (image->colorspace == CMYKColorspace)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 477 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 478 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 479 | (image->matte != MagickFalse)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 480 | number_colors++; |
| 481 | |
| 482 | /* |
| 483 | Read string, to determine number of arguments needed, |
| 484 | */ |
| 485 | p=arguments; |
| 486 | x=0; |
| 487 | while( *p != '\0' ) |
| 488 | { |
| 489 | GetMagickToken(p,&p,token); |
| 490 | if ( token[0] == ',' ) continue; |
| 491 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 492 | if ( color_from_image ) { |
| 493 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 494 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 495 | "Color arg given, when colors are coming from image"); |
| 496 | return( (Image *)NULL); |
| 497 | } |
| 498 | x += number_colors; /* color argument */ |
| 499 | } |
| 500 | else { |
| 501 | x++; /* floating point argument */ |
| 502 | } |
| 503 | } |
| 504 | error=MagickTrue; |
| 505 | if ( color_from_image ) { |
| 506 | /* just the control points are being given */ |
| 507 | error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; |
| 508 | number_arguments=(x/2)*(2+number_colors); |
| 509 | } |
| 510 | else { |
| 511 | /* control points and color values */ |
| 512 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; |
| 513 | number_arguments=x; |
| 514 | } |
| 515 | if ( error ) { |
| 516 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 517 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 518 | "Invalid number of Arguments"); |
| 519 | return( (Image *)NULL); |
| 520 | } |
| 521 | |
| 522 | /* Allocate and fill in the floating point arguments */ |
| 523 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 524 | sizeof(*sparse_arguments)); |
| 525 | if (sparse_arguments == (double *) NULL) { |
| 526 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 527 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 528 | return( (Image *)NULL); |
| 529 | } |
| 530 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 531 | sizeof(*sparse_arguments)); |
| 532 | p=arguments; |
| 533 | x=0; |
| 534 | while( *p != '\0' && x < number_arguments ) { |
| 535 | /* X coordinate */ |
| 536 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 537 | if ( token[0] == '\0' ) break; |
| 538 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 539 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 540 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 541 | "Color found, instead of X-coord"); |
| 542 | error = MagickTrue; |
| 543 | break; |
| 544 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 545 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 546 | /* Y coordinate */ |
| 547 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 548 | if ( token[0] == '\0' ) break; |
| 549 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 550 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 551 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 552 | "Color found, instead of Y-coord"); |
| 553 | error = MagickTrue; |
| 554 | break; |
| 555 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 556 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 557 | /* color values for this control point */ |
| 558 | #if 0 |
| 559 | if ( (color_from_image ) { |
| 560 | /* get color from image */ |
| 561 | /* HOW??? */ |
| 562 | } |
| 563 | else |
| 564 | #endif |
| 565 | { |
| 566 | /* color name or function given in string argument */ |
| 567 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 568 | if ( token[0] == '\0' ) break; |
| 569 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 570 | /* Color string given */ |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 571 | (void) QueryColorCompliance(token,AllCompliance,&color,exception); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 572 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 573 | sparse_arguments[x++] = QuantumScale*color.red; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 574 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 575 | sparse_arguments[x++] = QuantumScale*color.green; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 576 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 577 | sparse_arguments[x++] = QuantumScale*color.blue; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 578 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 579 | (image->colorspace == CMYKColorspace)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 580 | sparse_arguments[x++] = QuantumScale*color.black; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 581 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 582 | (image->matte != MagickFalse)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 583 | sparse_arguments[x++] = QuantumScale*color.alpha; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 584 | } |
| 585 | else { |
| 586 | /* Colors given as a set of floating point values - experimental */ |
| 587 | /* NB: token contains the first floating point value to use! */ |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 588 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 589 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 590 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 591 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 592 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 593 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 594 | token[0] = ','; /* used this token - get another */ |
| 595 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 596 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 597 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 598 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 599 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 600 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 601 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 602 | token[0] = ','; /* used this token - get another */ |
| 603 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 604 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 605 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 606 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 607 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 608 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 609 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 610 | token[0] = ','; /* used this token - get another */ |
| 611 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 612 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 613 | (image->colorspace == CMYKColorspace)) |
| 614 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 615 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 616 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 617 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 618 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 619 | token[0] = ','; /* used this token - get another */ |
| 620 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 621 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 622 | (image->matte != MagickFalse)) |
| 623 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 624 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 625 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 626 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 627 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 628 | token[0] = ','; /* used this token - get another */ |
| 629 | } |
| 630 | } |
| 631 | } |
| 632 | } |
| 633 | if ( number_arguments != x && !error ) { |
| 634 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
| 635 | "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error"); |
| 636 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 637 | return( (Image *)NULL); |
| 638 | } |
| 639 | if ( error ) |
| 640 | return( (Image *)NULL); |
| 641 | |
| 642 | /* Call the Interpolation function with the parsed arguments */ |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 643 | sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, |
| 644 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 645 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 646 | return( sparse_image ); |
| 647 | } |
| 648 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 649 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 650 | const char **argv,Image **image,ExceptionInfo *exception) |
| 651 | { |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 652 | CompositeOperator |
| 653 | compose; |
| 654 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 655 | const char |
| 656 | *format, |
| 657 | *option; |
| 658 | |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 659 | double |
| 660 | attenuate; |
| 661 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 662 | DrawInfo |
| 663 | *draw_info; |
| 664 | |
| 665 | GeometryInfo |
| 666 | geometry_info; |
| 667 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 668 | Image |
| 669 | *region_image; |
| 670 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 671 | ImageInfo |
| 672 | *mogrify_info; |
| 673 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 674 | MagickStatusType |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 675 | status; |
| 676 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 677 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 678 | fill; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 679 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 680 | MagickStatusType |
| 681 | flags; |
| 682 | |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 683 | PixelInterpolateMethod |
| 684 | interpolate_method; |
| 685 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 686 | QuantizeInfo |
| 687 | *quantize_info; |
| 688 | |
| 689 | RectangleInfo |
| 690 | geometry, |
| 691 | region_geometry; |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame] | 692 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 693 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 694 | i; |
| 695 | |
| 696 | /* |
| 697 | Initialize method variables. |
| 698 | */ |
| 699 | assert(image_info != (const ImageInfo *) NULL); |
| 700 | assert(image_info->signature == MagickSignature); |
| 701 | assert(image != (Image **) NULL); |
| 702 | assert((*image)->signature == MagickSignature); |
| 703 | if ((*image)->debug != MagickFalse) |
| 704 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); |
| 705 | if (argc < 0) |
| 706 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 707 | mogrify_info=CloneImageInfo(image_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 708 | draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL); |
| 709 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 710 | SetGeometryInfo(&geometry_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 711 | GetPixelInfo(*image,&fill); |
cristy | 9d8c8ce | 2011-10-25 16:13:52 +0000 | [diff] [blame] | 712 | fill=(*image)->background_color; |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 713 | attenuate=1.0; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 714 | compose=(*image)->compose; |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 715 | interpolate_method=UndefinedInterpolatePixel; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 716 | format=GetImageOption(mogrify_info,"format"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 717 | SetGeometry(*image,®ion_geometry); |
| 718 | region_image=NewImageList(); |
| 719 | /* |
| 720 | Transmogrify the image. |
| 721 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 722 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 723 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 724 | Image |
| 725 | *mogrify_image; |
| 726 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 727 | ssize_t |
| 728 | count; |
| 729 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 730 | option=argv[i]; |
| 731 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 732 | continue; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 733 | count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option), |
| 734 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 735 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 736 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 737 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 738 | mogrify_image=(Image *)NULL; |
| 739 | switch (*(option+1)) |
| 740 | { |
| 741 | case 'a': |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 742 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 743 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 744 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 745 | /* |
| 746 | Adaptive blur image. |
| 747 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 748 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 749 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 750 | if ((flags & SigmaValue) == 0) |
| 751 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 752 | if ((flags & XiValue) == 0) |
| 753 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 754 | mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho, |
cristy | 4c11c2b | 2011-09-05 20:17:07 +0000 | [diff] [blame] | 755 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 756 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 757 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 758 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 759 | { |
| 760 | /* |
| 761 | Adaptive resize image. |
| 762 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 763 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 764 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 765 | mogrify_image=AdaptiveResizeImage(*image,geometry.width, |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 766 | geometry.height,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 767 | break; |
| 768 | } |
| 769 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 770 | { |
| 771 | /* |
| 772 | Adaptive sharpen image. |
| 773 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 774 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 775 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 776 | if ((flags & SigmaValue) == 0) |
| 777 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 778 | if ((flags & XiValue) == 0) |
| 779 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 780 | mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho, |
cristy | 4c11c2b | 2011-09-05 20:17:07 +0000 | [diff] [blame] | 781 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 782 | break; |
| 783 | } |
| 784 | if (LocaleCompare("affine",option+1) == 0) |
| 785 | { |
| 786 | /* |
| 787 | Affine matrix. |
| 788 | */ |
| 789 | if (*option == '+') |
| 790 | { |
| 791 | GetAffineMatrix(&draw_info->affine); |
| 792 | break; |
| 793 | } |
| 794 | (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); |
| 795 | break; |
| 796 | } |
| 797 | if (LocaleCompare("alpha",option+1) == 0) |
| 798 | { |
| 799 | AlphaChannelType |
| 800 | alpha_type; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 801 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 802 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 803 | alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions, |
| 804 | MagickFalse,argv[i+1]); |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 805 | (void) SetImageAlphaChannel(*image,alpha_type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 806 | break; |
| 807 | } |
| 808 | if (LocaleCompare("annotate",option+1) == 0) |
| 809 | { |
| 810 | char |
| 811 | *text, |
| 812 | geometry[MaxTextExtent]; |
| 813 | |
| 814 | /* |
| 815 | Annotate image. |
| 816 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 817 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 818 | SetGeometryInfo(&geometry_info); |
| 819 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 820 | if ((flags & SigmaValue) == 0) |
| 821 | geometry_info.sigma=geometry_info.rho; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 822 | text=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 823 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 824 | if (text == (char *) NULL) |
| 825 | break; |
| 826 | (void) CloneString(&draw_info->text,text); |
| 827 | text=DestroyString(text); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 828 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 829 | geometry_info.xi,geometry_info.psi); |
| 830 | (void) CloneString(&draw_info->geometry,geometry); |
| 831 | draw_info->affine.sx=cos(DegreesToRadians( |
| 832 | fmod(geometry_info.rho,360.0))); |
| 833 | draw_info->affine.rx=sin(DegreesToRadians( |
| 834 | fmod(geometry_info.rho,360.0))); |
| 835 | draw_info->affine.ry=(-sin(DegreesToRadians( |
| 836 | fmod(geometry_info.sigma,360.0)))); |
| 837 | draw_info->affine.sy=cos(DegreesToRadians( |
| 838 | fmod(geometry_info.sigma,360.0))); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 839 | (void) AnnotateImage(*image,draw_info,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 840 | break; |
| 841 | } |
| 842 | if (LocaleCompare("antialias",option+1) == 0) |
| 843 | { |
| 844 | draw_info->stroke_antialias=(*option == '-') ? MagickTrue : |
| 845 | MagickFalse; |
| 846 | draw_info->text_antialias=(*option == '-') ? MagickTrue : |
| 847 | MagickFalse; |
| 848 | break; |
| 849 | } |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 850 | if (LocaleCompare("attenuate",option+1) == 0) |
| 851 | { |
| 852 | if (*option == '+') |
| 853 | { |
| 854 | attenuate=1.0; |
| 855 | break; |
| 856 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 857 | attenuate=StringToDouble(argv[i+1],(char **) NULL); |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 858 | break; |
| 859 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 860 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 861 | { |
| 862 | /* |
| 863 | Auto Adjust Gamma of image based on its mean |
| 864 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 865 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9511120 | 2011-08-09 19:41:42 +0000 | [diff] [blame] | 866 | (void) AutoGammaImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 867 | break; |
| 868 | } |
| 869 | if (LocaleCompare("auto-level",option+1) == 0) |
| 870 | { |
| 871 | /* |
| 872 | Perfectly Normalize (max/min stretch) the image |
| 873 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 874 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9511120 | 2011-08-09 19:41:42 +0000 | [diff] [blame] | 875 | (void) AutoLevelImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 876 | break; |
| 877 | } |
| 878 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 879 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 880 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 881 | switch ((*image)->orientation) |
| 882 | { |
| 883 | case TopRightOrientation: |
| 884 | { |
| 885 | mogrify_image=FlopImage(*image,exception); |
| 886 | break; |
| 887 | } |
| 888 | case BottomRightOrientation: |
| 889 | { |
| 890 | mogrify_image=RotateImage(*image,180.0,exception); |
| 891 | break; |
| 892 | } |
| 893 | case BottomLeftOrientation: |
| 894 | { |
| 895 | mogrify_image=FlipImage(*image,exception); |
| 896 | break; |
| 897 | } |
| 898 | case LeftTopOrientation: |
| 899 | { |
| 900 | mogrify_image=TransposeImage(*image,exception); |
| 901 | break; |
| 902 | } |
| 903 | case RightTopOrientation: |
| 904 | { |
| 905 | mogrify_image=RotateImage(*image,90.0,exception); |
| 906 | break; |
| 907 | } |
| 908 | case RightBottomOrientation: |
| 909 | { |
| 910 | mogrify_image=TransverseImage(*image,exception); |
| 911 | break; |
| 912 | } |
| 913 | case LeftBottomOrientation: |
| 914 | { |
| 915 | mogrify_image=RotateImage(*image,270.0,exception); |
| 916 | break; |
| 917 | } |
| 918 | default: |
| 919 | break; |
| 920 | } |
| 921 | if (mogrify_image != (Image *) NULL) |
| 922 | mogrify_image->orientation=TopLeftOrientation; |
| 923 | break; |
| 924 | } |
| 925 | break; |
| 926 | } |
| 927 | case 'b': |
| 928 | { |
| 929 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 930 | { |
| 931 | /* |
| 932 | Black threshold image. |
| 933 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 934 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 935 | (void) BlackThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 936 | break; |
| 937 | } |
| 938 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 939 | { |
| 940 | /* |
| 941 | Blue shift image. |
| 942 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 943 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 944 | geometry_info.rho=1.5; |
| 945 | if (*option == '-') |
| 946 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 947 | mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception); |
| 948 | break; |
| 949 | } |
| 950 | if (LocaleCompare("blur",option+1) == 0) |
| 951 | { |
| 952 | /* |
| 953 | Gaussian blur image. |
| 954 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 955 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 956 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 957 | if ((flags & SigmaValue) == 0) |
| 958 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 959 | if ((flags & XiValue) == 0) |
| 960 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 961 | mogrify_image=BlurImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 962 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 963 | break; |
| 964 | } |
| 965 | if (LocaleCompare("border",option+1) == 0) |
| 966 | { |
| 967 | /* |
| 968 | Surround image with a border of solid color. |
| 969 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 970 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 971 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 972 | if ((flags & SigmaValue) == 0) |
| 973 | geometry.height=geometry.width; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 974 | mogrify_image=BorderImage(*image,&geometry,compose,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 975 | break; |
| 976 | } |
| 977 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 978 | { |
| 979 | if (*option == '+') |
| 980 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 981 | (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 982 | &draw_info->border_color,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 983 | break; |
| 984 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 985 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 986 | &draw_info->border_color,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 987 | break; |
| 988 | } |
| 989 | if (LocaleCompare("box",option+1) == 0) |
| 990 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 991 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 992 | &draw_info->undercolor,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 993 | break; |
| 994 | } |
| 995 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 996 | { |
| 997 | double |
| 998 | brightness, |
| 999 | contrast; |
| 1000 | |
| 1001 | GeometryInfo |
| 1002 | geometry_info; |
| 1003 | |
| 1004 | MagickStatusType |
| 1005 | flags; |
| 1006 | |
| 1007 | /* |
| 1008 | Brightness / contrast image. |
| 1009 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1010 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1011 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1012 | brightness=geometry_info.rho; |
| 1013 | contrast=0.0; |
| 1014 | if ((flags & SigmaValue) != 0) |
| 1015 | contrast=geometry_info.sigma; |
cristy | 444eda6 | 2011-08-10 02:07:46 +0000 | [diff] [blame] | 1016 | (void) BrightnessContrastImage(*image,brightness,contrast, |
| 1017 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1018 | break; |
| 1019 | } |
| 1020 | break; |
| 1021 | } |
| 1022 | case 'c': |
| 1023 | { |
| 1024 | if (LocaleCompare("cdl",option+1) == 0) |
| 1025 | { |
| 1026 | char |
| 1027 | *color_correction_collection; |
| 1028 | |
| 1029 | /* |
| 1030 | Color correct with a color decision list. |
| 1031 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1032 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1033 | color_correction_collection=FileToString(argv[i+1],~0,exception); |
| 1034 | if (color_correction_collection == (char *) NULL) |
| 1035 | break; |
cristy | 1bfa9f0 | 2011-08-11 02:35:43 +0000 | [diff] [blame] | 1036 | (void) ColorDecisionListImage(*image,color_correction_collection, |
| 1037 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1038 | break; |
| 1039 | } |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 1040 | if (LocaleCompare("channel-extract",option+1) == 0) |
| 1041 | { |
| 1042 | puts("stand by..."); |
| 1043 | break; |
| 1044 | } |
| 1045 | if (LocaleCompare("channel-swap",option+1) == 0) |
| 1046 | { |
| 1047 | puts("stand by..."); |
| 1048 | break; |
| 1049 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1050 | if (LocaleCompare("charcoal",option+1) == 0) |
| 1051 | { |
| 1052 | /* |
| 1053 | Charcoal image. |
| 1054 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1055 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1056 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1057 | if ((flags & SigmaValue) == 0) |
| 1058 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1059 | if ((flags & XiValue) == 0) |
| 1060 | geometry_info.xi=1.0; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1061 | mogrify_image=CharcoalImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1062 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1063 | break; |
| 1064 | } |
| 1065 | if (LocaleCompare("chop",option+1) == 0) |
| 1066 | { |
| 1067 | /* |
| 1068 | Chop the image. |
| 1069 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1070 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1071 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1072 | mogrify_image=ChopImage(*image,&geometry,exception); |
| 1073 | break; |
| 1074 | } |
| 1075 | if (LocaleCompare("clamp",option+1) == 0) |
| 1076 | { |
| 1077 | /* |
| 1078 | Clamp image. |
| 1079 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1080 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 092d71c | 2011-10-14 18:01:29 +0000 | [diff] [blame] | 1081 | (void) ClampImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1082 | break; |
| 1083 | } |
| 1084 | if (LocaleCompare("clip",option+1) == 0) |
| 1085 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1086 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1087 | if (*option == '+') |
| 1088 | { |
cristy | 10a6c61 | 2012-01-29 21:41:05 +0000 | [diff] [blame] | 1089 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1090 | break; |
| 1091 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1092 | (void) ClipImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1093 | break; |
| 1094 | } |
| 1095 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1096 | { |
| 1097 | CacheView |
| 1098 | *mask_view; |
| 1099 | |
| 1100 | Image |
| 1101 | *mask_image; |
| 1102 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1103 | register Quantum |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1104 | *restrict q; |
| 1105 | |
| 1106 | register ssize_t |
| 1107 | x; |
| 1108 | |
| 1109 | ssize_t |
| 1110 | y; |
| 1111 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1112 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1113 | if (*option == '+') |
| 1114 | { |
| 1115 | /* |
| 1116 | Remove a mask. |
| 1117 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1118 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1119 | break; |
| 1120 | } |
| 1121 | /* |
| 1122 | Set the image mask. |
| 1123 | FUTURE: This Should Be a SetImageAlphaChannel() call, Or two. |
| 1124 | */ |
| 1125 | mask_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1126 | if (mask_image == (Image *) NULL) |
| 1127 | break; |
cristy | 574cc26 | 2011-08-05 01:23:58 +0000 | [diff] [blame] | 1128 | if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1129 | return(MagickFalse); |
| 1130 | mask_view=AcquireCacheView(mask_image); |
| 1131 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1132 | { |
| 1133 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1134 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 1135 | if (q == (Quantum *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1136 | break; |
| 1137 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1138 | { |
| 1139 | if (mask_image->matte == MagickFalse) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1140 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 1141 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1142 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1143 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1144 | q+=GetPixelChannels(mask_image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1145 | } |
| 1146 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
| 1147 | break; |
| 1148 | } |
| 1149 | mask_view=DestroyCacheView(mask_view); |
| 1150 | mask_image->matte=MagickTrue; |
cristy | 10a6c61 | 2012-01-29 21:41:05 +0000 | [diff] [blame] | 1151 | (void) SetImageMask(*image,mask_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1152 | break; |
| 1153 | } |
| 1154 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1155 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1156 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1157 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1158 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1159 | break; |
| 1160 | } |
| 1161 | if (LocaleCompare("colorize",option+1) == 0) |
| 1162 | { |
| 1163 | /* |
| 1164 | Colorize the image. |
| 1165 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1166 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | c7e6ff6 | 2011-10-03 13:46:11 +0000 | [diff] [blame] | 1167 | mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1168 | break; |
| 1169 | } |
| 1170 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1171 | { |
| 1172 | KernelInfo |
| 1173 | *kernel; |
| 1174 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1175 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1176 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1177 | if (kernel == (KernelInfo *) NULL) |
| 1178 | break; |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1179 | /* FUTURE: check on size of the matrix */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1180 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 1181 | kernel=DestroyKernelInfo(kernel); |
| 1182 | break; |
| 1183 | } |
| 1184 | if (LocaleCompare("colors",option+1) == 0) |
| 1185 | { |
| 1186 | /* |
| 1187 | Reduce the number of colors in the image. |
| 1188 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1189 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1190 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
| 1191 | if (quantize_info->number_colors == 0) |
| 1192 | break; |
| 1193 | if (((*image)->storage_class == DirectClass) || |
| 1194 | (*image)->colors > quantize_info->number_colors) |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1195 | (void) QuantizeImage(quantize_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1196 | else |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1197 | (void) CompressImageColormap(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1198 | break; |
| 1199 | } |
| 1200 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1201 | { |
| 1202 | ColorspaceType |
| 1203 | colorspace; |
| 1204 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1205 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1206 | if (*option == '+') |
| 1207 | { |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 1208 | (void) TransformImageColorspace(*image,RGBColorspace,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1209 | break; |
| 1210 | } |
| 1211 | colorspace=(ColorspaceType) ParseCommandOption( |
| 1212 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 1213 | (void) TransformImageColorspace(*image,colorspace,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1214 | break; |
| 1215 | } |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1216 | if (LocaleCompare("compose",option+1) == 0) |
| 1217 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1218 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1219 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 1220 | MagickFalse,argv[i+1]); |
| 1221 | break; |
| 1222 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1223 | if (LocaleCompare("contrast",option+1) == 0) |
| 1224 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1225 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1226 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1227 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1228 | break; |
| 1229 | } |
| 1230 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1231 | { |
| 1232 | double |
| 1233 | black_point, |
| 1234 | white_point; |
| 1235 | |
| 1236 | MagickStatusType |
| 1237 | flags; |
| 1238 | |
| 1239 | /* |
| 1240 | Contrast stretch image. |
| 1241 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1242 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1243 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1244 | black_point=geometry_info.rho; |
| 1245 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1246 | black_point; |
| 1247 | if ((flags & PercentValue) != 0) |
| 1248 | { |
| 1249 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1250 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1251 | } |
| 1252 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1253 | white_point; |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1254 | (void) ContrastStretchImage(*image,black_point,white_point, |
| 1255 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1256 | break; |
| 1257 | } |
| 1258 | if (LocaleCompare("convolve",option+1) == 0) |
| 1259 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1260 | KernelInfo |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1261 | *kernel_info; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1262 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1263 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1264 | kernel_info=AcquireKernelInfo(argv[i+1]); |
| 1265 | if (kernel_info == (KernelInfo *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1266 | break; |
cristy | 0a92238 | 2011-07-16 15:30:34 +0000 | [diff] [blame] | 1267 | kernel_info->bias=(*image)->bias; |
cristy | 5e6be1e | 2011-07-16 01:23:39 +0000 | [diff] [blame] | 1268 | mogrify_image=ConvolveImage(*image,kernel_info,exception); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1269 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1270 | break; |
| 1271 | } |
| 1272 | if (LocaleCompare("crop",option+1) == 0) |
| 1273 | { |
| 1274 | /* |
| 1275 | Crop a image to a smaller size |
| 1276 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1277 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1278 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1279 | break; |
| 1280 | } |
| 1281 | if (LocaleCompare("cycle",option+1) == 0) |
| 1282 | { |
| 1283 | /* |
| 1284 | Cycle an image colormap. |
| 1285 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1286 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1287 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]), |
| 1288 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1289 | break; |
| 1290 | } |
| 1291 | break; |
| 1292 | } |
| 1293 | case 'd': |
| 1294 | { |
| 1295 | if (LocaleCompare("decipher",option+1) == 0) |
| 1296 | { |
| 1297 | StringInfo |
| 1298 | *passkey; |
| 1299 | |
| 1300 | /* |
| 1301 | Decipher pixels. |
| 1302 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1303 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1304 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1305 | if (passkey != (StringInfo *) NULL) |
| 1306 | { |
| 1307 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1308 | passkey=DestroyStringInfo(passkey); |
| 1309 | } |
| 1310 | break; |
| 1311 | } |
| 1312 | if (LocaleCompare("density",option+1) == 0) |
| 1313 | { |
| 1314 | /* |
| 1315 | Set image density. |
| 1316 | */ |
| 1317 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1318 | break; |
| 1319 | } |
| 1320 | if (LocaleCompare("depth",option+1) == 0) |
| 1321 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1322 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1323 | if (*option == '+') |
| 1324 | { |
cristy | 8a11cb1 | 2011-10-19 23:53:34 +0000 | [diff] [blame] | 1325 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1326 | break; |
| 1327 | } |
cristy | 8a11cb1 | 2011-10-19 23:53:34 +0000 | [diff] [blame] | 1328 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]), |
| 1329 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1330 | break; |
| 1331 | } |
| 1332 | if (LocaleCompare("deskew",option+1) == 0) |
| 1333 | { |
| 1334 | double |
| 1335 | threshold; |
| 1336 | |
| 1337 | /* |
| 1338 | Straighten the image. |
| 1339 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1340 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1341 | if (*option == '+') |
| 1342 | threshold=40.0*QuantumRange/100.0; |
| 1343 | else |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 1344 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 1345 | 1.0); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1346 | mogrify_image=DeskewImage(*image,threshold,exception); |
| 1347 | break; |
| 1348 | } |
| 1349 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1350 | { |
| 1351 | /* |
| 1352 | Reduce the speckles within an image. |
| 1353 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1354 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1355 | mogrify_image=DespeckleImage(*image,exception); |
| 1356 | break; |
| 1357 | } |
| 1358 | if (LocaleCompare("display",option+1) == 0) |
| 1359 | { |
| 1360 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1361 | break; |
| 1362 | } |
| 1363 | if (LocaleCompare("distort",option+1) == 0) |
| 1364 | { |
| 1365 | char |
| 1366 | *args, |
| 1367 | token[MaxTextExtent]; |
| 1368 | |
| 1369 | const char |
| 1370 | *p; |
| 1371 | |
| 1372 | DistortImageMethod |
| 1373 | method; |
| 1374 | |
| 1375 | double |
| 1376 | *arguments; |
| 1377 | |
| 1378 | register ssize_t |
| 1379 | x; |
| 1380 | |
| 1381 | size_t |
| 1382 | number_arguments; |
| 1383 | |
| 1384 | /* |
| 1385 | Distort image. |
| 1386 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1387 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1388 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, |
| 1389 | MagickFalse,argv[i+1]); |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1390 | if (method == ResizeDistortion) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1391 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1392 | double |
| 1393 | resize_args[2]; |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1394 | |
| 1395 | /* |
| 1396 | Special Case - Argument is actually a resize geometry! |
| 1397 | Convert that to an appropriate distortion argument array. |
| 1398 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1399 | (void) ParseRegionGeometry(*image,argv[i+2],&geometry, |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1400 | exception); |
| 1401 | resize_args[0]=(double) geometry.width; |
| 1402 | resize_args[1]=(double) geometry.height; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1403 | mogrify_image=DistortImage(*image,method,(size_t)2, |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1404 | resize_args,MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1405 | break; |
| 1406 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1407 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1408 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1409 | if (args == (char *) NULL) |
| 1410 | break; |
| 1411 | p=(char *) args; |
| 1412 | for (x=0; *p != '\0'; x++) |
| 1413 | { |
| 1414 | GetMagickToken(p,&p,token); |
| 1415 | if (*token == ',') |
| 1416 | GetMagickToken(p,&p,token); |
| 1417 | } |
| 1418 | number_arguments=(size_t) x; |
| 1419 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1420 | sizeof(*arguments)); |
| 1421 | if (arguments == (double *) NULL) |
| 1422 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1423 | "MemoryAllocationFailed",(*image)->filename); |
| 1424 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1425 | sizeof(*arguments)); |
| 1426 | p=(char *) args; |
| 1427 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 1428 | { |
| 1429 | GetMagickToken(p,&p,token); |
| 1430 | if (*token == ',') |
| 1431 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1432 | arguments[x]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1433 | } |
| 1434 | args=DestroyString(args); |
| 1435 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
| 1436 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1437 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1438 | break; |
| 1439 | } |
| 1440 | if (LocaleCompare("dither",option+1) == 0) |
| 1441 | { |
| 1442 | if (*option == '+') |
| 1443 | { |
| 1444 | quantize_info->dither=MagickFalse; |
| 1445 | break; |
| 1446 | } |
| 1447 | quantize_info->dither=MagickTrue; |
| 1448 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
| 1449 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1450 | if (quantize_info->dither_method == NoDitherMethod) |
| 1451 | quantize_info->dither=MagickFalse; |
| 1452 | break; |
| 1453 | } |
| 1454 | if (LocaleCompare("draw",option+1) == 0) |
| 1455 | { |
| 1456 | /* |
| 1457 | Draw image. |
| 1458 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1459 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1460 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1461 | (void) DrawImage(*image,draw_info,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1462 | break; |
| 1463 | } |
| 1464 | break; |
| 1465 | } |
| 1466 | case 'e': |
| 1467 | { |
| 1468 | if (LocaleCompare("edge",option+1) == 0) |
| 1469 | { |
| 1470 | /* |
| 1471 | Enhance edges in the image. |
| 1472 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1473 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1474 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1475 | if ((flags & SigmaValue) == 0) |
| 1476 | geometry_info.sigma=1.0; |
cristy | 8ae632d | 2011-09-05 17:29:53 +0000 | [diff] [blame] | 1477 | mogrify_image=EdgeImage(*image,geometry_info.rho, |
| 1478 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1479 | break; |
| 1480 | } |
| 1481 | if (LocaleCompare("emboss",option+1) == 0) |
| 1482 | { |
| 1483 | /* |
cristy | d89705a | 2012-01-20 02:52:24 +0000 | [diff] [blame] | 1484 | Emboss image. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1485 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1486 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1487 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1488 | if ((flags & SigmaValue) == 0) |
| 1489 | geometry_info.sigma=1.0; |
| 1490 | mogrify_image=EmbossImage(*image,geometry_info.rho, |
| 1491 | geometry_info.sigma,exception); |
| 1492 | break; |
| 1493 | } |
| 1494 | if (LocaleCompare("encipher",option+1) == 0) |
| 1495 | { |
| 1496 | StringInfo |
| 1497 | *passkey; |
| 1498 | |
| 1499 | /* |
| 1500 | Encipher pixels. |
| 1501 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1502 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1503 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1504 | if (passkey != (StringInfo *) NULL) |
| 1505 | { |
| 1506 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1507 | passkey=DestroyStringInfo(passkey); |
| 1508 | } |
| 1509 | break; |
| 1510 | } |
| 1511 | if (LocaleCompare("encoding",option+1) == 0) |
| 1512 | { |
| 1513 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1514 | break; |
| 1515 | } |
| 1516 | if (LocaleCompare("enhance",option+1) == 0) |
| 1517 | { |
| 1518 | /* |
| 1519 | Enhance image. |
| 1520 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1521 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1522 | mogrify_image=EnhanceImage(*image,exception); |
| 1523 | break; |
| 1524 | } |
| 1525 | if (LocaleCompare("equalize",option+1) == 0) |
| 1526 | { |
| 1527 | /* |
| 1528 | Equalize image. |
| 1529 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1530 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 6d8c3d7 | 2011-08-22 01:20:01 +0000 | [diff] [blame] | 1531 | (void) EqualizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1532 | break; |
| 1533 | } |
| 1534 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1535 | { |
| 1536 | double |
| 1537 | constant; |
| 1538 | |
| 1539 | MagickEvaluateOperator |
| 1540 | op; |
| 1541 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1542 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1543 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 1544 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 1545 | constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+ |
| 1546 | 1.0); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1547 | (void) EvaluateImage(*image,op,constant,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1548 | break; |
| 1549 | } |
| 1550 | if (LocaleCompare("extent",option+1) == 0) |
| 1551 | { |
| 1552 | /* |
| 1553 | Set the image extent. |
| 1554 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1555 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1556 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1557 | if (geometry.width == 0) |
| 1558 | geometry.width=(*image)->columns; |
| 1559 | if (geometry.height == 0) |
| 1560 | geometry.height=(*image)->rows; |
| 1561 | mogrify_image=ExtentImage(*image,&geometry,exception); |
| 1562 | break; |
| 1563 | } |
| 1564 | break; |
| 1565 | } |
| 1566 | case 'f': |
| 1567 | { |
| 1568 | if (LocaleCompare("family",option+1) == 0) |
| 1569 | { |
| 1570 | if (*option == '+') |
| 1571 | { |
| 1572 | if (draw_info->family != (char *) NULL) |
| 1573 | draw_info->family=DestroyString(draw_info->family); |
| 1574 | break; |
| 1575 | } |
| 1576 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1577 | break; |
| 1578 | } |
| 1579 | if (LocaleCompare("features",option+1) == 0) |
| 1580 | { |
| 1581 | if (*option == '+') |
| 1582 | { |
| 1583 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1584 | break; |
| 1585 | } |
| 1586 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1587 | break; |
| 1588 | } |
| 1589 | if (LocaleCompare("fill",option+1) == 0) |
| 1590 | { |
| 1591 | ExceptionInfo |
| 1592 | *sans; |
| 1593 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1594 | PixelInfo |
| 1595 | color; |
| 1596 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1597 | GetPixelInfo(*image,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1598 | if (*option == '+') |
| 1599 | { |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1600 | (void) QueryColorCompliance("none",AllCompliance,&fill, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1601 | exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1602 | draw_info->fill=fill; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1603 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1604 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1605 | break; |
| 1606 | } |
| 1607 | sans=AcquireExceptionInfo(); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1608 | status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1609 | sans=DestroyExceptionInfo(sans); |
| 1610 | if (status == MagickFalse) |
| 1611 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 1612 | exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1613 | else |
| 1614 | draw_info->fill=fill=color; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1615 | break; |
| 1616 | } |
| 1617 | if (LocaleCompare("flip",option+1) == 0) |
| 1618 | { |
| 1619 | /* |
| 1620 | Flip image scanlines. |
| 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 | mogrify_image=FlipImage(*image,exception); |
| 1624 | break; |
| 1625 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1626 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1627 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1628 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1629 | target; |
| 1630 | |
| 1631 | /* |
| 1632 | Floodfill image. |
| 1633 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1634 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1635 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1636 | (void) QueryColorCompliance(argv[i+2],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1637 | exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1638 | (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x, |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 1639 | geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1640 | break; |
| 1641 | } |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1642 | if (LocaleCompare("flop",option+1) == 0) |
| 1643 | { |
| 1644 | /* |
| 1645 | Flop image scanlines. |
| 1646 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1647 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1648 | mogrify_image=FlopImage(*image,exception); |
| 1649 | break; |
| 1650 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1651 | if (LocaleCompare("font",option+1) == 0) |
| 1652 | { |
| 1653 | if (*option == '+') |
| 1654 | { |
| 1655 | if (draw_info->font != (char *) NULL) |
| 1656 | draw_info->font=DestroyString(draw_info->font); |
| 1657 | break; |
| 1658 | } |
| 1659 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1660 | break; |
| 1661 | } |
| 1662 | if (LocaleCompare("format",option+1) == 0) |
| 1663 | { |
| 1664 | format=argv[i+1]; |
| 1665 | break; |
| 1666 | } |
| 1667 | if (LocaleCompare("frame",option+1) == 0) |
| 1668 | { |
| 1669 | FrameInfo |
| 1670 | frame_info; |
| 1671 | |
| 1672 | /* |
| 1673 | Surround image with an ornamental border. |
| 1674 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1675 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1676 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1677 | frame_info.width=geometry.width; |
| 1678 | frame_info.height=geometry.height; |
| 1679 | if ((flags & HeightValue) == 0) |
| 1680 | frame_info.height=geometry.width; |
| 1681 | frame_info.outer_bevel=geometry.x; |
| 1682 | frame_info.inner_bevel=geometry.y; |
| 1683 | frame_info.x=(ssize_t) frame_info.width; |
| 1684 | frame_info.y=(ssize_t) frame_info.height; |
| 1685 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1686 | frame_info.height=(*image)->rows+2*frame_info.height; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1687 | mogrify_image=FrameImage(*image,&frame_info,compose,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1688 | break; |
| 1689 | } |
| 1690 | if (LocaleCompare("function",option+1) == 0) |
| 1691 | { |
| 1692 | char |
| 1693 | *arguments, |
| 1694 | token[MaxTextExtent]; |
| 1695 | |
| 1696 | const char |
| 1697 | *p; |
| 1698 | |
| 1699 | double |
| 1700 | *parameters; |
| 1701 | |
| 1702 | MagickFunction |
| 1703 | function; |
| 1704 | |
| 1705 | register ssize_t |
| 1706 | x; |
| 1707 | |
| 1708 | size_t |
| 1709 | number_parameters; |
| 1710 | |
| 1711 | /* |
| 1712 | Function Modify Image Values |
| 1713 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1714 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1715 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, |
| 1716 | MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1717 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1718 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1719 | if (arguments == (char *) NULL) |
| 1720 | break; |
| 1721 | p=(char *) arguments; |
| 1722 | for (x=0; *p != '\0'; x++) |
| 1723 | { |
| 1724 | GetMagickToken(p,&p,token); |
| 1725 | if (*token == ',') |
| 1726 | GetMagickToken(p,&p,token); |
| 1727 | } |
| 1728 | number_parameters=(size_t) x; |
| 1729 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1730 | sizeof(*parameters)); |
| 1731 | if (parameters == (double *) NULL) |
| 1732 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1733 | "MemoryAllocationFailed",(*image)->filename); |
| 1734 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1735 | sizeof(*parameters)); |
| 1736 | p=(char *) arguments; |
| 1737 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
| 1738 | { |
| 1739 | GetMagickToken(p,&p,token); |
| 1740 | if (*token == ',') |
| 1741 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1742 | parameters[x]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1743 | } |
| 1744 | arguments=DestroyString(arguments); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1745 | (void) FunctionImage(*image,function,number_parameters,parameters, |
| 1746 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1747 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1748 | break; |
| 1749 | } |
| 1750 | break; |
| 1751 | } |
| 1752 | case 'g': |
| 1753 | { |
| 1754 | if (LocaleCompare("gamma",option+1) == 0) |
| 1755 | { |
| 1756 | /* |
| 1757 | Gamma image. |
| 1758 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1759 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1760 | if (*option == '+') |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1761 | (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1762 | else |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1763 | (void) GammaImage(*image,StringToDouble(argv[i+1], |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 1764 | (char **) NULL),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1765 | break; |
| 1766 | } |
| 1767 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1768 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1769 | { |
| 1770 | /* |
| 1771 | Gaussian blur image. |
| 1772 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1773 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1774 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1775 | if ((flags & SigmaValue) == 0) |
| 1776 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1777 | mogrify_image=GaussianBlurImage(*image,geometry_info.rho, |
cristy | d89705a | 2012-01-20 02:52:24 +0000 | [diff] [blame] | 1778 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1779 | break; |
| 1780 | } |
| 1781 | if (LocaleCompare("geometry",option+1) == 0) |
| 1782 | { |
| 1783 | /* |
| 1784 | Record Image offset, Resize last image. |
| 1785 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1786 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1787 | if (*option == '+') |
| 1788 | { |
| 1789 | if ((*image)->geometry != (char *) NULL) |
| 1790 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1791 | break; |
| 1792 | } |
| 1793 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1794 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1795 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1796 | else |
| 1797 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 1798 | (*image)->filter,(*image)->blur,exception); |
| 1799 | break; |
| 1800 | } |
| 1801 | if (LocaleCompare("gravity",option+1) == 0) |
| 1802 | { |
| 1803 | if (*option == '+') |
| 1804 | { |
| 1805 | draw_info->gravity=UndefinedGravity; |
| 1806 | break; |
| 1807 | } |
| 1808 | draw_info->gravity=(GravityType) ParseCommandOption( |
| 1809 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1810 | break; |
| 1811 | } |
| 1812 | break; |
| 1813 | } |
| 1814 | case 'h': |
| 1815 | { |
| 1816 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1817 | { |
| 1818 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1819 | break; |
| 1820 | } |
| 1821 | break; |
| 1822 | } |
| 1823 | case 'i': |
| 1824 | { |
| 1825 | if (LocaleCompare("identify",option+1) == 0) |
| 1826 | { |
| 1827 | char |
| 1828 | *text; |
| 1829 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1830 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1831 | if (format == (char *) NULL) |
| 1832 | { |
cristy | a403727 | 2011-08-28 15:11:39 +0000 | [diff] [blame] | 1833 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose, |
| 1834 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1835 | break; |
| 1836 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1837 | text=InterpretImageProperties(mogrify_info,*image,format, |
| 1838 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1839 | if (text == (char *) NULL) |
| 1840 | break; |
| 1841 | (void) fputs(text,stdout); |
| 1842 | (void) fputc('\n',stdout); |
| 1843 | text=DestroyString(text); |
| 1844 | break; |
| 1845 | } |
| 1846 | if (LocaleCompare("implode",option+1) == 0) |
| 1847 | { |
| 1848 | /* |
| 1849 | Implode image. |
| 1850 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1851 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1852 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 76f512e | 2011-09-12 01:26:56 +0000 | [diff] [blame] | 1853 | mogrify_image=ImplodeImage(*image,geometry_info.rho, |
| 1854 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1855 | break; |
| 1856 | } |
| 1857 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1858 | { |
| 1859 | if (*option == '+') |
| 1860 | (void) ParseGeometry("0",&geometry_info); |
| 1861 | else |
| 1862 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1863 | draw_info->interline_spacing=geometry_info.rho; |
| 1864 | break; |
| 1865 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 1866 | if (LocaleCompare("interpolate",option+1) == 0) |
| 1867 | { |
| 1868 | interpolate_method=(PixelInterpolateMethod) ParseCommandOption( |
| 1869 | MagickInterpolateOptions,MagickFalse,argv[i+1]); |
| 1870 | break; |
| 1871 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1872 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1873 | { |
| 1874 | if (*option == '+') |
| 1875 | (void) ParseGeometry("0",&geometry_info); |
| 1876 | else |
| 1877 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1878 | draw_info->interword_spacing=geometry_info.rho; |
| 1879 | break; |
| 1880 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1881 | if (LocaleCompare("interpolative-resize",option+1) == 0) |
| 1882 | { |
| 1883 | /* |
| 1884 | Interpolative resize image. |
| 1885 | */ |
| 1886 | (void) SyncImageSettings(mogrify_info,*image,exception); |
| 1887 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1888 | mogrify_image=InterpolativeResizeImage(*image,geometry.width, |
| 1889 | geometry.height,interpolate_method,exception); |
| 1890 | break; |
| 1891 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1892 | break; |
| 1893 | } |
| 1894 | case 'k': |
| 1895 | { |
| 1896 | if (LocaleCompare("kerning",option+1) == 0) |
| 1897 | { |
| 1898 | if (*option == '+') |
| 1899 | (void) ParseGeometry("0",&geometry_info); |
| 1900 | else |
| 1901 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1902 | draw_info->kerning=geometry_info.rho; |
| 1903 | break; |
| 1904 | } |
| 1905 | break; |
| 1906 | } |
| 1907 | case 'l': |
| 1908 | { |
| 1909 | if (LocaleCompare("lat",option+1) == 0) |
| 1910 | { |
| 1911 | /* |
| 1912 | Local adaptive threshold image. |
| 1913 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1914 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1915 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1916 | if ((flags & PercentValue) != 0) |
| 1917 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 1918 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
cristy | de5cc63 | 2011-07-18 14:47:00 +0000 | [diff] [blame] | 1919 | geometry_info.rho,(size_t) geometry_info.sigma,(double) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1920 | geometry_info.xi,exception); |
| 1921 | break; |
| 1922 | } |
| 1923 | if (LocaleCompare("level",option+1) == 0) |
| 1924 | { |
| 1925 | MagickRealType |
| 1926 | black_point, |
| 1927 | gamma, |
| 1928 | white_point; |
| 1929 | |
| 1930 | MagickStatusType |
| 1931 | flags; |
| 1932 | |
| 1933 | /* |
| 1934 | Parse levels. |
| 1935 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1936 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1937 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1938 | black_point=geometry_info.rho; |
| 1939 | white_point=(MagickRealType) QuantumRange; |
| 1940 | if ((flags & SigmaValue) != 0) |
| 1941 | white_point=geometry_info.sigma; |
| 1942 | gamma=1.0; |
| 1943 | if ((flags & XiValue) != 0) |
| 1944 | gamma=geometry_info.xi; |
| 1945 | if ((flags & PercentValue) != 0) |
| 1946 | { |
| 1947 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 1948 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 1949 | } |
| 1950 | if ((flags & SigmaValue) == 0) |
| 1951 | white_point=(MagickRealType) QuantumRange-black_point; |
| 1952 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1953 | (void) LevelizeImage(*image,black_point,white_point,gamma, |
| 1954 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1955 | else |
cristy | 01e9afd | 2011-08-10 17:38:41 +0000 | [diff] [blame] | 1956 | (void) LevelImage(*image,black_point,white_point,gamma, |
| 1957 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1958 | break; |
| 1959 | } |
| 1960 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1961 | { |
| 1962 | char |
| 1963 | token[MaxTextExtent]; |
| 1964 | |
| 1965 | const char |
| 1966 | *p; |
| 1967 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1968 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1969 | black_point, |
| 1970 | white_point; |
| 1971 | |
| 1972 | p=(const char *) argv[i+1]; |
| 1973 | GetMagickToken(p,&p,token); /* get black point color */ |
| 1974 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1975 | (void) QueryColorCompliance(token,AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1976 | &black_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1977 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1978 | (void) QueryColorCompliance("#000000",AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1979 | &black_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1980 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1981 | GetMagickToken(p,&p,token); |
| 1982 | if (*token == '\0') |
| 1983 | white_point=black_point; /* set everything to that color */ |
| 1984 | else |
| 1985 | { |
| 1986 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 1987 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 1988 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1989 | (void) QueryColorCompliance(token,AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1990 | &white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1991 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1992 | (void) QueryColorCompliance("#ffffff",AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1993 | &white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1994 | } |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 1995 | (void) LevelImageColors(*image,&black_point,&white_point, |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1996 | *option == '+' ? MagickTrue : MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1997 | break; |
| 1998 | } |
| 1999 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 2000 | { |
| 2001 | double |
| 2002 | black_point, |
| 2003 | white_point; |
| 2004 | |
| 2005 | MagickStatusType |
| 2006 | flags; |
| 2007 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2008 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2009 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2010 | black_point=geometry_info.rho; |
| 2011 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 2012 | if ((flags & SigmaValue) != 0) |
| 2013 | white_point=geometry_info.sigma; |
| 2014 | if ((flags & PercentValue) != 0) |
| 2015 | { |
| 2016 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 2017 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 2018 | } |
| 2019 | if ((flags & SigmaValue) == 0) |
| 2020 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 2021 | black_point; |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2022 | (void) LinearStretchImage(*image,black_point,white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2023 | break; |
| 2024 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2025 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 2026 | { |
| 2027 | /* |
| 2028 | Liquid rescale image. |
| 2029 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2030 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2031 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2032 | if ((flags & XValue) == 0) |
| 2033 | geometry.x=1; |
| 2034 | if ((flags & YValue) == 0) |
| 2035 | geometry.y=0; |
| 2036 | mogrify_image=LiquidRescaleImage(*image,geometry.width, |
| 2037 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 2038 | break; |
| 2039 | } |
| 2040 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 2041 | { |
| 2042 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 2043 | break; |
| 2044 | } |
| 2045 | break; |
| 2046 | } |
| 2047 | case 'm': |
| 2048 | { |
| 2049 | if (LocaleCompare("map",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2050 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2051 | Image |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2052 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2053 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2054 | /* |
| 2055 | Transform image colors to match this set of colors. |
| 2056 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2057 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2058 | if (*option == '+') |
| 2059 | break; |
| 2060 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2061 | if (remap_image == (Image *) NULL) |
| 2062 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2063 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2064 | remap_image=DestroyImage(remap_image); |
| 2065 | break; |
| 2066 | } |
| 2067 | if (LocaleCompare("mask",option+1) == 0) |
| 2068 | { |
| 2069 | Image |
| 2070 | *mask; |
| 2071 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2072 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2073 | if (*option == '+') |
| 2074 | { |
| 2075 | /* |
| 2076 | Remove a mask. |
| 2077 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2078 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2079 | break; |
| 2080 | } |
| 2081 | /* |
| 2082 | Set the image mask. |
| 2083 | */ |
| 2084 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2085 | if (mask == (Image *) NULL) |
| 2086 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2087 | (void) SetImageMask(*image,mask,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2088 | mask=DestroyImage(mask); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2089 | break; |
| 2090 | } |
| 2091 | if (LocaleCompare("matte",option+1) == 0) |
| 2092 | { |
| 2093 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 2094 | SetAlphaChannel : DeactivateAlphaChannel,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2095 | break; |
| 2096 | } |
| 2097 | if (LocaleCompare("median",option+1) == 0) |
| 2098 | { |
| 2099 | /* |
| 2100 | Median filter image. |
| 2101 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2102 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2103 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2104 | if ((flags & SigmaValue) == 0) |
| 2105 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2106 | mogrify_image=StatisticImage(*image,MedianStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2107 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2108 | break; |
| 2109 | } |
| 2110 | if (LocaleCompare("mode",option+1) == 0) |
| 2111 | { |
| 2112 | /* |
| 2113 | Mode image. |
| 2114 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2115 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2116 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2117 | if ((flags & SigmaValue) == 0) |
| 2118 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2119 | mogrify_image=StatisticImage(*image,ModeStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2120 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2121 | break; |
| 2122 | } |
| 2123 | if (LocaleCompare("modulate",option+1) == 0) |
| 2124 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2125 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2126 | (void) ModulateImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2127 | break; |
| 2128 | } |
| 2129 | if (LocaleCompare("monitor",option+1) == 0) |
| 2130 | { |
| 2131 | if (*option == '+') |
| 2132 | { |
| 2133 | (void) SetImageProgressMonitor(*image, |
| 2134 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2135 | break; |
| 2136 | } |
| 2137 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2138 | (void *) NULL); |
| 2139 | break; |
| 2140 | } |
| 2141 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2142 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2143 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2144 | (void) SetImageType(*image,BilevelType,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2145 | break; |
| 2146 | } |
| 2147 | if (LocaleCompare("morphology",option+1) == 0) |
| 2148 | { |
| 2149 | char |
| 2150 | token[MaxTextExtent]; |
| 2151 | |
| 2152 | const char |
| 2153 | *p; |
| 2154 | |
| 2155 | KernelInfo |
| 2156 | *kernel; |
| 2157 | |
| 2158 | MorphologyMethod |
| 2159 | method; |
| 2160 | |
| 2161 | ssize_t |
| 2162 | iterations; |
| 2163 | |
| 2164 | /* |
| 2165 | Morphological Image Operation |
| 2166 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2167 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2168 | p=argv[i+1]; |
| 2169 | GetMagickToken(p,&p,token); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2170 | method=(MorphologyMethod) ParseCommandOption( |
| 2171 | MagickMorphologyOptions,MagickFalse,token); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2172 | iterations=1L; |
| 2173 | GetMagickToken(p,&p,token); |
| 2174 | if ((*p == ':') || (*p == ',')) |
| 2175 | GetMagickToken(p,&p,token); |
| 2176 | if ((*p != '\0')) |
| 2177 | iterations=(ssize_t) StringToLong(p); |
| 2178 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2179 | if (kernel == (KernelInfo *) NULL) |
| 2180 | { |
| 2181 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2182 | OptionError,"UnabletoParseKernel","morphology"); |
| 2183 | status=MagickFalse; |
| 2184 | break; |
| 2185 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2186 | mogrify_image=MorphologyImage(*image,method,iterations,kernel, |
| 2187 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2188 | kernel=DestroyKernelInfo(kernel); |
| 2189 | break; |
| 2190 | } |
| 2191 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2192 | { |
| 2193 | /* |
| 2194 | Motion blur image. |
| 2195 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2196 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2197 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2198 | if ((flags & SigmaValue) == 0) |
| 2199 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2200 | mogrify_image=MotionBlurImage(*image,geometry_info.rho, |
cristy | 7497f48 | 2011-12-08 01:57:31 +0000 | [diff] [blame] | 2201 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2202 | break; |
| 2203 | } |
| 2204 | break; |
| 2205 | } |
| 2206 | case 'n': |
| 2207 | { |
| 2208 | if (LocaleCompare("negate",option+1) == 0) |
| 2209 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2210 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2211 | (void) NegateImage(*image,*option == '+' ? MagickTrue : |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 2212 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2213 | break; |
| 2214 | } |
| 2215 | if (LocaleCompare("noise",option+1) == 0) |
| 2216 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2217 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2218 | if (*option == '-') |
| 2219 | { |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2220 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2221 | if ((flags & SigmaValue) == 0) |
| 2222 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2223 | mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2224 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2225 | } |
| 2226 | else |
| 2227 | { |
| 2228 | NoiseType |
| 2229 | noise; |
| 2230 | |
| 2231 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
| 2232 | MagickFalse,argv[i+1]); |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 2233 | mogrify_image=AddNoiseImage(*image,noise,attenuate,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2234 | } |
| 2235 | break; |
| 2236 | } |
| 2237 | if (LocaleCompare("normalize",option+1) == 0) |
| 2238 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2239 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 2240 | (void) NormalizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2241 | break; |
| 2242 | } |
| 2243 | break; |
| 2244 | } |
| 2245 | case 'o': |
| 2246 | { |
| 2247 | if (LocaleCompare("opaque",option+1) == 0) |
| 2248 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2249 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2250 | target; |
| 2251 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2252 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2253 | (void) QueryColorCompliance(argv[i+1],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2254 | exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 2255 | (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ? |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 2256 | MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2257 | break; |
| 2258 | } |
| 2259 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2260 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2261 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 1302067 | 2011-07-08 02:33:26 +0000 | [diff] [blame] | 2262 | (void) OrderedPosterizeImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2263 | break; |
| 2264 | } |
| 2265 | break; |
| 2266 | } |
| 2267 | case 'p': |
| 2268 | { |
| 2269 | if (LocaleCompare("paint",option+1) == 0) |
| 2270 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2271 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2272 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 14973ba | 2011-08-27 23:48:07 +0000 | [diff] [blame] | 2273 | mogrify_image=OilPaintImage(*image,geometry_info.rho, |
| 2274 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2275 | break; |
| 2276 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2277 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2278 | { |
| 2279 | if (*option == '+') |
| 2280 | (void) ParseGeometry("12",&geometry_info); |
| 2281 | else |
| 2282 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2283 | draw_info->pointsize=geometry_info.rho; |
| 2284 | break; |
| 2285 | } |
| 2286 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2287 | { |
cristy | e9e3d38 | 2011-12-14 01:50:13 +0000 | [diff] [blame] | 2288 | const char |
| 2289 | *caption; |
| 2290 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2291 | double |
| 2292 | angle; |
| 2293 | |
| 2294 | RandomInfo |
| 2295 | *random_info; |
| 2296 | |
| 2297 | /* |
| 2298 | Simulate a Polaroid picture. |
| 2299 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2300 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2301 | random_info=AcquireRandomInfo(); |
| 2302 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2303 | random_info=DestroyRandomInfo(random_info); |
| 2304 | if (*option == '-') |
| 2305 | { |
| 2306 | SetGeometryInfo(&geometry_info); |
| 2307 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2308 | angle=geometry_info.rho; |
| 2309 | } |
cristy | e9e3d38 | 2011-12-14 01:50:13 +0000 | [diff] [blame] | 2310 | caption=GetImageProperty(*image,"caption",exception); |
| 2311 | mogrify_image=PolaroidImage(*image,draw_info,caption,angle, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2312 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2313 | break; |
| 2314 | } |
| 2315 | if (LocaleCompare("posterize",option+1) == 0) |
| 2316 | { |
| 2317 | /* |
| 2318 | Posterize image. |
| 2319 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2320 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2321 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2322 | quantize_info->dither,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2323 | break; |
| 2324 | } |
| 2325 | if (LocaleCompare("preview",option+1) == 0) |
| 2326 | { |
| 2327 | PreviewType |
| 2328 | preview_type; |
| 2329 | |
| 2330 | /* |
| 2331 | Preview image. |
| 2332 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2333 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2334 | if (*option == '+') |
| 2335 | preview_type=UndefinedPreview; |
| 2336 | else |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2337 | preview_type=(PreviewType) ParseCommandOption( |
| 2338 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2339 | mogrify_image=PreviewImage(*image,preview_type,exception); |
| 2340 | break; |
| 2341 | } |
| 2342 | if (LocaleCompare("profile",option+1) == 0) |
| 2343 | { |
| 2344 | const char |
| 2345 | *name; |
| 2346 | |
| 2347 | const StringInfo |
| 2348 | *profile; |
| 2349 | |
| 2350 | Image |
| 2351 | *profile_image; |
| 2352 | |
| 2353 | ImageInfo |
| 2354 | *profile_info; |
| 2355 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2356 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2357 | if (*option == '+') |
| 2358 | { |
| 2359 | /* |
| 2360 | Remove a profile from the image. |
| 2361 | */ |
| 2362 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
cristy | 092d71c | 2011-10-14 18:01:29 +0000 | [diff] [blame] | 2363 | NULL,0,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2364 | break; |
| 2365 | } |
| 2366 | /* |
| 2367 | Associate a profile with the image. |
| 2368 | */ |
| 2369 | profile_info=CloneImageInfo(mogrify_info); |
| 2370 | profile=GetImageProfile(*image,"iptc"); |
| 2371 | if (profile != (StringInfo *) NULL) |
| 2372 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2373 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2374 | profile_info=DestroyImageInfo(profile_info); |
| 2375 | if (profile_image == (Image *) NULL) |
| 2376 | { |
| 2377 | StringInfo |
| 2378 | *profile; |
| 2379 | |
| 2380 | profile_info=CloneImageInfo(mogrify_info); |
| 2381 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2382 | MaxTextExtent); |
| 2383 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
| 2384 | if (profile != (StringInfo *) NULL) |
| 2385 | { |
| 2386 | (void) ProfileImage(*image,profile_info->magick, |
| 2387 | GetStringInfoDatum(profile),(size_t) |
cristy | 3fac9ec | 2011-11-17 18:04:39 +0000 | [diff] [blame] | 2388 | GetStringInfoLength(profile),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2389 | profile=DestroyStringInfo(profile); |
| 2390 | } |
| 2391 | profile_info=DestroyImageInfo(profile_info); |
| 2392 | break; |
| 2393 | } |
| 2394 | ResetImageProfileIterator(profile_image); |
| 2395 | name=GetNextImageProfile(profile_image); |
| 2396 | while (name != (const char *) NULL) |
| 2397 | { |
| 2398 | profile=GetImageProfile(profile_image,name); |
| 2399 | if (profile != (StringInfo *) NULL) |
| 2400 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
cristy | 3fac9ec | 2011-11-17 18:04:39 +0000 | [diff] [blame] | 2401 | (size_t) GetStringInfoLength(profile),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2402 | name=GetNextImageProfile(profile_image); |
| 2403 | } |
| 2404 | profile_image=DestroyImage(profile_image); |
| 2405 | break; |
| 2406 | } |
| 2407 | break; |
| 2408 | } |
| 2409 | case 'q': |
| 2410 | { |
| 2411 | if (LocaleCompare("quantize",option+1) == 0) |
| 2412 | { |
| 2413 | if (*option == '+') |
| 2414 | { |
| 2415 | quantize_info->colorspace=UndefinedColorspace; |
| 2416 | break; |
| 2417 | } |
| 2418 | quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
| 2419 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2420 | break; |
| 2421 | } |
| 2422 | break; |
| 2423 | } |
| 2424 | case 'r': |
| 2425 | { |
| 2426 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2427 | { |
| 2428 | /* |
| 2429 | Radial blur image. |
| 2430 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2431 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 6435bd9 | 2011-09-10 02:10:07 +0000 | [diff] [blame] | 2432 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2433 | mogrify_image=RadialBlurImage(*image,geometry_info.rho, |
| 2434 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2435 | break; |
| 2436 | } |
| 2437 | if (LocaleCompare("raise",option+1) == 0) |
| 2438 | { |
| 2439 | /* |
| 2440 | Surround image with a raise of solid color. |
| 2441 | */ |
| 2442 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2443 | if ((flags & SigmaValue) == 0) |
| 2444 | geometry.height=geometry.width; |
| 2445 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
cristy | 6170ac3 | 2011-08-28 14:15:37 +0000 | [diff] [blame] | 2446 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2447 | break; |
| 2448 | } |
| 2449 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2450 | { |
| 2451 | /* |
| 2452 | Threshold image. |
| 2453 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2454 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2455 | (void) RandomThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2456 | break; |
| 2457 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2458 | if (LocaleCompare("region",option+1) == 0) |
| 2459 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2460 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2461 | if (region_image != (Image *) NULL) |
| 2462 | { |
| 2463 | /* |
| 2464 | Composite region. |
| 2465 | */ |
| 2466 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2467 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 2468 | region_geometry.x,region_geometry.y,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2469 | *image=DestroyImage(*image); |
| 2470 | *image=region_image; |
| 2471 | region_image = (Image *) NULL; |
| 2472 | } |
| 2473 | if (*option == '+') |
| 2474 | break; |
| 2475 | /* |
| 2476 | Apply transformations to a selected region of the image. |
| 2477 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2478 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2479 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2480 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2481 | if (mogrify_image == (Image *) NULL) |
| 2482 | break; |
| 2483 | region_image=(*image); |
| 2484 | *image=mogrify_image; |
| 2485 | mogrify_image=(Image *) NULL; |
| 2486 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2487 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2488 | if (LocaleCompare("render",option+1) == 0) |
| 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 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2492 | break; |
| 2493 | } |
| 2494 | if (LocaleCompare("remap",option+1) == 0) |
| 2495 | { |
| 2496 | Image |
| 2497 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2498 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2499 | /* |
| 2500 | Transform image colors to match this set of colors. |
| 2501 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2502 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2503 | if (*option == '+') |
| 2504 | break; |
| 2505 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2506 | if (remap_image == (Image *) NULL) |
| 2507 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2508 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2509 | remap_image=DestroyImage(remap_image); |
| 2510 | break; |
| 2511 | } |
| 2512 | if (LocaleCompare("repage",option+1) == 0) |
| 2513 | { |
| 2514 | if (*option == '+') |
| 2515 | { |
| 2516 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2517 | break; |
| 2518 | } |
| 2519 | (void) ResetImagePage(*image,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2520 | break; |
| 2521 | } |
| 2522 | if (LocaleCompare("resample",option+1) == 0) |
| 2523 | { |
| 2524 | /* |
| 2525 | Resample image. |
| 2526 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2527 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2528 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2529 | if ((flags & SigmaValue) == 0) |
| 2530 | geometry_info.sigma=geometry_info.rho; |
| 2531 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
| 2532 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2533 | break; |
| 2534 | } |
| 2535 | if (LocaleCompare("resize",option+1) == 0) |
| 2536 | { |
| 2537 | /* |
| 2538 | Resize image. |
| 2539 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2540 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2541 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2542 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2543 | (*image)->filter,(*image)->blur,exception); |
| 2544 | break; |
| 2545 | } |
| 2546 | if (LocaleCompare("roll",option+1) == 0) |
| 2547 | { |
| 2548 | /* |
| 2549 | Roll image. |
| 2550 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2551 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2552 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2553 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2554 | break; |
| 2555 | } |
| 2556 | if (LocaleCompare("rotate",option+1) == 0) |
| 2557 | { |
| 2558 | char |
| 2559 | *geometry; |
| 2560 | |
| 2561 | /* |
| 2562 | Check for conditional image rotation. |
| 2563 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2564 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2565 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2566 | if ((*image)->columns <= (*image)->rows) |
| 2567 | break; |
| 2568 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2569 | if ((*image)->columns >= (*image)->rows) |
| 2570 | break; |
| 2571 | /* |
| 2572 | Rotate image. |
| 2573 | */ |
| 2574 | geometry=ConstantString(argv[i+1]); |
| 2575 | (void) SubstituteString(&geometry,">",""); |
| 2576 | (void) SubstituteString(&geometry,"<",""); |
| 2577 | (void) ParseGeometry(geometry,&geometry_info); |
| 2578 | geometry=DestroyString(geometry); |
| 2579 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
| 2580 | break; |
| 2581 | } |
| 2582 | break; |
| 2583 | } |
| 2584 | case 's': |
| 2585 | { |
| 2586 | if (LocaleCompare("sample",option+1) == 0) |
| 2587 | { |
| 2588 | /* |
| 2589 | Sample image with pixel replication. |
| 2590 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2591 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2592 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2593 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
| 2594 | exception); |
| 2595 | break; |
| 2596 | } |
| 2597 | if (LocaleCompare("scale",option+1) == 0) |
| 2598 | { |
| 2599 | /* |
| 2600 | Resize image. |
| 2601 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2602 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2603 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2604 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2605 | exception); |
| 2606 | break; |
| 2607 | } |
| 2608 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2609 | { |
| 2610 | /* |
| 2611 | Selectively blur pixels within a contrast threshold. |
| 2612 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2613 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2614 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2615 | if ((flags & PercentValue) != 0) |
| 2616 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2617 | mogrify_image=SelectiveBlurImage(*image,geometry_info.rho, |
cristy | 1e7aa31 | 2011-09-10 20:01:36 +0000 | [diff] [blame] | 2618 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2619 | break; |
| 2620 | } |
| 2621 | if (LocaleCompare("separate",option+1) == 0) |
| 2622 | { |
| 2623 | /* |
| 2624 | Break channels into separate images. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2625 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2626 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 2627 | mogrify_image=SeparateImages(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2628 | break; |
| 2629 | } |
| 2630 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2631 | { |
| 2632 | double |
| 2633 | threshold; |
| 2634 | |
| 2635 | /* |
| 2636 | Sepia-tone image. |
| 2637 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2638 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2639 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 2640 | 1.0); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2641 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
| 2642 | break; |
| 2643 | } |
| 2644 | if (LocaleCompare("segment",option+1) == 0) |
| 2645 | { |
| 2646 | /* |
| 2647 | Segment image. |
| 2648 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2649 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2650 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2651 | if ((flags & SigmaValue) == 0) |
| 2652 | geometry_info.sigma=1.0; |
| 2653 | (void) SegmentImage(*image,(*image)->colorspace, |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2654 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 2655 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2656 | break; |
| 2657 | } |
| 2658 | if (LocaleCompare("set",option+1) == 0) |
| 2659 | { |
| 2660 | char |
| 2661 | *value; |
| 2662 | |
| 2663 | /* |
| 2664 | Set image option. |
| 2665 | */ |
| 2666 | if (*option == '+') |
| 2667 | { |
| 2668 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2669 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2670 | else |
| 2671 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2672 | { |
| 2673 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
| 2674 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2675 | } |
| 2676 | else |
| 2677 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2678 | break; |
| 2679 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2680 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2681 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2682 | if (value == (char *) NULL) |
| 2683 | break; |
| 2684 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2685 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2686 | exception); |
| 2687 | else |
| 2688 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2689 | { |
| 2690 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
| 2691 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
| 2692 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2693 | } |
| 2694 | else |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 2695 | (void) SetImageProperty(*image,argv[i+1],value,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2696 | value=DestroyString(value); |
| 2697 | break; |
| 2698 | } |
| 2699 | if (LocaleCompare("shade",option+1) == 0) |
| 2700 | { |
| 2701 | /* |
| 2702 | Shade image. |
| 2703 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2704 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2705 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2706 | if ((flags & SigmaValue) == 0) |
| 2707 | geometry_info.sigma=1.0; |
| 2708 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2709 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2710 | break; |
| 2711 | } |
| 2712 | if (LocaleCompare("shadow",option+1) == 0) |
| 2713 | { |
| 2714 | /* |
| 2715 | Shadow image. |
| 2716 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2717 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2718 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2719 | if ((flags & SigmaValue) == 0) |
| 2720 | geometry_info.sigma=1.0; |
| 2721 | if ((flags & XiValue) == 0) |
| 2722 | geometry_info.xi=4.0; |
| 2723 | if ((flags & PsiValue) == 0) |
| 2724 | geometry_info.psi=4.0; |
| 2725 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
cristy | eb6e658 | 2011-12-09 09:14:23 +0000 | [diff] [blame] | 2726 | geometry_info.sigma,(*image)->bias,(ssize_t) |
| 2727 | ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5), |
| 2728 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2729 | break; |
| 2730 | } |
| 2731 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2732 | { |
| 2733 | /* |
| 2734 | Sharpen image. |
| 2735 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2736 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2737 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2738 | if ((flags & SigmaValue) == 0) |
| 2739 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2740 | if ((flags & XiValue) == 0) |
| 2741 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2742 | mogrify_image=SharpenImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2743 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2744 | break; |
| 2745 | } |
| 2746 | if (LocaleCompare("shave",option+1) == 0) |
| 2747 | { |
| 2748 | /* |
| 2749 | Shave the image edges. |
| 2750 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2751 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2752 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2753 | mogrify_image=ShaveImage(*image,&geometry,exception); |
| 2754 | break; |
| 2755 | } |
| 2756 | if (LocaleCompare("shear",option+1) == 0) |
| 2757 | { |
| 2758 | /* |
| 2759 | Shear image. |
| 2760 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2761 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2762 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2763 | if ((flags & SigmaValue) == 0) |
| 2764 | geometry_info.sigma=geometry_info.rho; |
| 2765 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2766 | geometry_info.sigma,exception); |
| 2767 | break; |
| 2768 | } |
| 2769 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2770 | { |
| 2771 | /* |
| 2772 | Sigmoidal non-linearity contrast control. |
| 2773 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2774 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2775 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2776 | if ((flags & SigmaValue) == 0) |
| 2777 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 2778 | if ((flags & PercentValue) != 0) |
| 2779 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2780 | 100.0; |
cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 2781 | (void) SigmoidalContrastImage(*image,(*option == '-') ? |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2782 | MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma, |
| 2783 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2784 | break; |
| 2785 | } |
| 2786 | if (LocaleCompare("sketch",option+1) == 0) |
| 2787 | { |
| 2788 | /* |
| 2789 | Sketch image. |
| 2790 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2791 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2792 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2793 | if ((flags & SigmaValue) == 0) |
| 2794 | geometry_info.sigma=1.0; |
| 2795 | mogrify_image=SketchImage(*image,geometry_info.rho, |
cristy | f7ef025 | 2011-09-09 14:50:06 +0000 | [diff] [blame] | 2796 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2797 | break; |
| 2798 | } |
| 2799 | if (LocaleCompare("solarize",option+1) == 0) |
| 2800 | { |
| 2801 | double |
| 2802 | threshold; |
| 2803 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2804 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2805 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 2806 | 1.0); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 2807 | (void) SolarizeImage(*image,threshold,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2808 | break; |
| 2809 | } |
| 2810 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2811 | { |
| 2812 | SparseColorMethod |
| 2813 | method; |
| 2814 | |
| 2815 | char |
| 2816 | *arguments; |
| 2817 | |
| 2818 | /* |
| 2819 | Sparse Color Interpolated Gradient |
| 2820 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2821 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2822 | method=(SparseColorMethod) ParseCommandOption( |
| 2823 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2824 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2825 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2826 | if (arguments == (char *) NULL) |
| 2827 | break; |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 2828 | mogrify_image=SparseColorOption(*image,method,arguments, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2829 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2830 | arguments=DestroyString(arguments); |
| 2831 | break; |
| 2832 | } |
| 2833 | if (LocaleCompare("splice",option+1) == 0) |
| 2834 | { |
| 2835 | /* |
| 2836 | Splice a solid color into the image. |
| 2837 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2838 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2839 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 2840 | mogrify_image=SpliceImage(*image,&geometry,exception); |
| 2841 | break; |
| 2842 | } |
| 2843 | if (LocaleCompare("spread",option+1) == 0) |
| 2844 | { |
| 2845 | /* |
| 2846 | Spread an image. |
| 2847 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2848 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2849 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame] | 2850 | mogrify_image=SpreadImage(*image,geometry_info.rho, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2851 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2852 | break; |
| 2853 | } |
| 2854 | if (LocaleCompare("statistic",option+1) == 0) |
| 2855 | { |
| 2856 | StatisticType |
| 2857 | type; |
| 2858 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2859 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2860 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
| 2861 | MagickFalse,argv[i+1]); |
| 2862 | (void) ParseGeometry(argv[i+2],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2863 | mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho, |
| 2864 | (size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2865 | break; |
| 2866 | } |
| 2867 | if (LocaleCompare("stretch",option+1) == 0) |
| 2868 | { |
| 2869 | if (*option == '+') |
| 2870 | { |
| 2871 | draw_info->stretch=UndefinedStretch; |
| 2872 | break; |
| 2873 | } |
| 2874 | draw_info->stretch=(StretchType) ParseCommandOption( |
| 2875 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2876 | break; |
| 2877 | } |
| 2878 | if (LocaleCompare("strip",option+1) == 0) |
| 2879 | { |
| 2880 | /* |
| 2881 | Strip image of profiles and comments. |
| 2882 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2883 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 2884 | (void) StripImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2885 | break; |
| 2886 | } |
| 2887 | if (LocaleCompare("stroke",option+1) == 0) |
| 2888 | { |
| 2889 | ExceptionInfo |
| 2890 | *sans; |
| 2891 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2892 | PixelInfo |
| 2893 | color; |
| 2894 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2895 | if (*option == '+') |
| 2896 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2897 | (void) QueryColorCompliance("none",AllCompliance, |
| 2898 | &draw_info->stroke,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2899 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2900 | draw_info->stroke_pattern=DestroyImage( |
| 2901 | draw_info->stroke_pattern); |
| 2902 | break; |
| 2903 | } |
| 2904 | sans=AcquireExceptionInfo(); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2905 | status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2906 | sans=DestroyExceptionInfo(sans); |
| 2907 | if (status == MagickFalse) |
| 2908 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2909 | exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2910 | else |
| 2911 | draw_info->stroke=color; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2912 | break; |
| 2913 | } |
| 2914 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2915 | { |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2916 | draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2917 | break; |
| 2918 | } |
| 2919 | if (LocaleCompare("style",option+1) == 0) |
| 2920 | { |
| 2921 | if (*option == '+') |
| 2922 | { |
| 2923 | draw_info->style=UndefinedStyle; |
| 2924 | break; |
| 2925 | } |
| 2926 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 2927 | MagickFalse,argv[i+1]); |
| 2928 | break; |
| 2929 | } |
| 2930 | if (LocaleCompare("swirl",option+1) == 0) |
| 2931 | { |
| 2932 | /* |
| 2933 | Swirl image. |
| 2934 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2935 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2936 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 76f512e | 2011-09-12 01:26:56 +0000 | [diff] [blame] | 2937 | mogrify_image=SwirlImage(*image,geometry_info.rho, |
| 2938 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2939 | break; |
| 2940 | } |
| 2941 | break; |
| 2942 | } |
| 2943 | case 't': |
| 2944 | { |
| 2945 | if (LocaleCompare("threshold",option+1) == 0) |
| 2946 | { |
| 2947 | double |
| 2948 | threshold; |
| 2949 | |
| 2950 | /* |
| 2951 | Threshold image. |
| 2952 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2953 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2954 | if (*option == '+') |
anthony | 247a86d | 2011-05-03 13:18:18 +0000 | [diff] [blame] | 2955 | threshold=(double) QuantumRange/2; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2956 | else |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2957 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 2958 | 1.0); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 2959 | (void) BilevelImage(*image,threshold,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2960 | break; |
| 2961 | } |
| 2962 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2963 | { |
| 2964 | /* |
| 2965 | Thumbnail image. |
| 2966 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2967 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2968 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2969 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2970 | exception); |
| 2971 | break; |
| 2972 | } |
| 2973 | if (LocaleCompare("tile",option+1) == 0) |
| 2974 | { |
| 2975 | if (*option == '+') |
| 2976 | { |
| 2977 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2978 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2979 | break; |
| 2980 | } |
| 2981 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2982 | exception); |
| 2983 | break; |
| 2984 | } |
| 2985 | if (LocaleCompare("tint",option+1) == 0) |
| 2986 | { |
| 2987 | /* |
| 2988 | Tint the image. |
| 2989 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2990 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2991 | mogrify_image=TintImage(*image,argv[i+1],&fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2992 | break; |
| 2993 | } |
| 2994 | if (LocaleCompare("transform",option+1) == 0) |
| 2995 | { |
| 2996 | /* |
| 2997 | Affine transform image. |
| 2998 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2999 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3000 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
| 3001 | exception); |
| 3002 | break; |
| 3003 | } |
| 3004 | if (LocaleCompare("transparent",option+1) == 0) |
| 3005 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 3006 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3007 | target; |
| 3008 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3009 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 3010 | (void) QueryColorCompliance(argv[i+1],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 3011 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3012 | (void) TransparentPaintImage(*image,&target,(Quantum) |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 3013 | TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue, |
cristy | 82d7af5 | 2011-10-16 16:26:41 +0000 | [diff] [blame] | 3014 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3015 | break; |
| 3016 | } |
| 3017 | if (LocaleCompare("transpose",option+1) == 0) |
| 3018 | { |
| 3019 | /* |
| 3020 | Transpose image scanlines. |
| 3021 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3022 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3023 | mogrify_image=TransposeImage(*image,exception); |
| 3024 | break; |
| 3025 | } |
| 3026 | if (LocaleCompare("transverse",option+1) == 0) |
| 3027 | { |
| 3028 | /* |
| 3029 | Transverse image scanlines. |
| 3030 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3031 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3032 | mogrify_image=TransverseImage(*image,exception); |
| 3033 | break; |
| 3034 | } |
| 3035 | if (LocaleCompare("treedepth",option+1) == 0) |
| 3036 | { |
| 3037 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
| 3038 | break; |
| 3039 | } |
| 3040 | if (LocaleCompare("trim",option+1) == 0) |
| 3041 | { |
| 3042 | /* |
| 3043 | Trim image. |
| 3044 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3045 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3046 | mogrify_image=TrimImage(*image,exception); |
| 3047 | break; |
| 3048 | } |
| 3049 | if (LocaleCompare("type",option+1) == 0) |
| 3050 | { |
| 3051 | ImageType |
| 3052 | type; |
| 3053 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3054 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3055 | if (*option == '+') |
| 3056 | type=UndefinedType; |
| 3057 | else |
| 3058 | type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 3059 | argv[i+1]); |
| 3060 | (*image)->type=UndefinedType; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3061 | (void) SetImageType(*image,type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3062 | break; |
| 3063 | } |
| 3064 | break; |
| 3065 | } |
| 3066 | case 'u': |
| 3067 | { |
| 3068 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3069 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 3070 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 3071 | &draw_info->undercolor,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3072 | break; |
| 3073 | } |
| 3074 | if (LocaleCompare("unique",option+1) == 0) |
| 3075 | { |
| 3076 | if (*option == '+') |
| 3077 | { |
| 3078 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
| 3079 | break; |
| 3080 | } |
| 3081 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
| 3082 | (void) SetImageArtifact(*image,"verbose","true"); |
| 3083 | break; |
| 3084 | } |
| 3085 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3086 | { |
| 3087 | /* |
| 3088 | Unique image colors. |
| 3089 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3090 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3091 | mogrify_image=UniqueImageColors(*image,exception); |
| 3092 | break; |
| 3093 | } |
| 3094 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3095 | { |
| 3096 | /* |
| 3097 | Unsharp mask image. |
| 3098 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3099 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3100 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3101 | if ((flags & SigmaValue) == 0) |
| 3102 | geometry_info.sigma=1.0; |
| 3103 | if ((flags & XiValue) == 0) |
| 3104 | geometry_info.xi=1.0; |
| 3105 | if ((flags & PsiValue) == 0) |
| 3106 | geometry_info.psi=0.05; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3107 | mogrify_image=UnsharpMaskImage(*image,geometry_info.rho, |
| 3108 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3109 | break; |
| 3110 | } |
| 3111 | break; |
| 3112 | } |
| 3113 | case 'v': |
| 3114 | { |
| 3115 | if (LocaleCompare("verbose",option+1) == 0) |
| 3116 | { |
| 3117 | (void) SetImageArtifact(*image,option+1, |
| 3118 | *option == '+' ? "false" : "true"); |
| 3119 | break; |
| 3120 | } |
| 3121 | if (LocaleCompare("vignette",option+1) == 0) |
| 3122 | { |
| 3123 | /* |
| 3124 | Vignette image. |
| 3125 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3126 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3127 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3128 | if ((flags & SigmaValue) == 0) |
| 3129 | geometry_info.sigma=1.0; |
| 3130 | if ((flags & XiValue) == 0) |
| 3131 | geometry_info.xi=0.1*(*image)->columns; |
| 3132 | if ((flags & PsiValue) == 0) |
| 3133 | geometry_info.psi=0.1*(*image)->rows; |
| 3134 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
cristy | eb6e658 | 2011-12-09 09:14:23 +0000 | [diff] [blame] | 3135 | geometry_info.sigma,(*image)->bias,(ssize_t) |
| 3136 | ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5), |
| 3137 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3138 | break; |
| 3139 | } |
| 3140 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3141 | { |
| 3142 | if (*option == '+') |
| 3143 | { |
| 3144 | (void) SetImageVirtualPixelMethod(*image, |
cristy | 387430f | 2012-02-07 13:09:46 +0000 | [diff] [blame] | 3145 | UndefinedVirtualPixelMethod,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3146 | break; |
| 3147 | } |
| 3148 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3149 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 387430f | 2012-02-07 13:09:46 +0000 | [diff] [blame] | 3150 | argv[i+1]),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3151 | break; |
| 3152 | } |
| 3153 | break; |
| 3154 | } |
| 3155 | case 'w': |
| 3156 | { |
| 3157 | if (LocaleCompare("wave",option+1) == 0) |
| 3158 | { |
| 3159 | /* |
| 3160 | Wave image. |
| 3161 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3162 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3163 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3164 | if ((flags & SigmaValue) == 0) |
| 3165 | geometry_info.sigma=1.0; |
| 3166 | mogrify_image=WaveImage(*image,geometry_info.rho, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 3167 | geometry_info.sigma,interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3168 | break; |
| 3169 | } |
| 3170 | if (LocaleCompare("weight",option+1) == 0) |
| 3171 | { |
| 3172 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
| 3173 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3174 | draw_info->weight=0; |
| 3175 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3176 | draw_info->weight=700; |
| 3177 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3178 | if (draw_info->weight <= 800) |
| 3179 | draw_info->weight+=100; |
| 3180 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3181 | if (draw_info->weight >= 100) |
| 3182 | draw_info->weight-=100; |
| 3183 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3184 | draw_info->weight=400; |
| 3185 | break; |
| 3186 | } |
| 3187 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3188 | { |
| 3189 | /* |
| 3190 | White threshold image. |
| 3191 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3192 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3193 | (void) WhiteThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3194 | break; |
| 3195 | } |
| 3196 | break; |
| 3197 | } |
| 3198 | default: |
| 3199 | break; |
| 3200 | } |
| 3201 | /* |
| 3202 | Replace current image with any image that was generated |
| 3203 | */ |
| 3204 | if (mogrify_image != (Image *) NULL) |
| 3205 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3206 | i+=count; |
| 3207 | } |
| 3208 | if (region_image != (Image *) NULL) |
| 3209 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3210 | /* |
| 3211 | Composite transformed region onto image. |
| 3212 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3213 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3214 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3215 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 3216 | region_geometry.x,region_geometry.y,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3217 | *image=DestroyImage(*image); |
| 3218 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3219 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3220 | } |
| 3221 | /* |
| 3222 | Free resources. |
| 3223 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3224 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3225 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3226 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 82d7af5 | 2011-10-16 16:26:41 +0000 | [diff] [blame] | 3227 | status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3228 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3229 | } |
| 3230 | |
| 3231 | /* |
| 3232 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3233 | % % |
| 3234 | % % |
| 3235 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3236 | + 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] | 3237 | % % |
| 3238 | % % |
| 3239 | % % |
| 3240 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3241 | % |
| 3242 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3243 | % transforms include image scaling, image rotation, color reduction, and |
| 3244 | % others. The transmogrified image overwrites the original image. |
| 3245 | % |
| 3246 | % The format of the MogrifyImageCommand method is: |
| 3247 | % |
| 3248 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3249 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3250 | % |
| 3251 | % A description of each parameter follows: |
| 3252 | % |
| 3253 | % o image_info: the image info. |
| 3254 | % |
| 3255 | % o argc: the number of elements in the argument vector. |
| 3256 | % |
| 3257 | % o argv: A text array containing the command line arguments. |
| 3258 | % |
| 3259 | % o metadata: any metadata is returned here. |
| 3260 | % |
| 3261 | % o exception: return any errors or warnings in this structure. |
| 3262 | % |
| 3263 | */ |
| 3264 | |
| 3265 | static MagickBooleanType MogrifyUsage(void) |
| 3266 | { |
| 3267 | static const char |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3268 | *channel_operators[]= |
| 3269 | { |
| 3270 | "-channel-extract channel-list", |
| 3271 | " extract the channels in order", |
| 3272 | "-channel-inject channel-list", |
| 3273 | " inject the channels in order", |
| 3274 | "-channel-swap channel,channel", |
| 3275 | " swap channels", |
| 3276 | (char *) NULL |
| 3277 | }, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3278 | *miscellaneous[]= |
| 3279 | { |
| 3280 | "-debug events display copious debugging information", |
| 3281 | "-help print program options", |
| 3282 | "-list type print a list of supported option arguments", |
| 3283 | "-log format format of debugging information", |
| 3284 | "-version print version information", |
| 3285 | (char *) NULL |
| 3286 | }, |
| 3287 | *operators[]= |
| 3288 | { |
| 3289 | "-adaptive-blur geometry", |
| 3290 | " adaptively blur pixels; decrease effect near edges", |
| 3291 | "-adaptive-resize geometry", |
| 3292 | " adaptively resize image using 'mesh' interpolation", |
| 3293 | "-adaptive-sharpen geometry", |
| 3294 | " adaptively sharpen pixels; increase effect near edges", |
| 3295 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3296 | " transparent, extract, background, or shape", |
| 3297 | "-annotate geometry text", |
| 3298 | " annotate the image with text", |
| 3299 | "-auto-gamma automagically adjust gamma level of image", |
| 3300 | "-auto-level automagically adjust color levels of image", |
| 3301 | "-auto-orient automagically orient (rotate) image", |
| 3302 | "-bench iterations measure performance", |
| 3303 | "-black-threshold value", |
| 3304 | " force all pixels below the threshold into black", |
| 3305 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3306 | "-blur geometry reduce image noise and reduce detail levels", |
| 3307 | "-border geometry surround image with a border of color", |
| 3308 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3309 | "-brightness-contrast geometry", |
| 3310 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3311 | "-cdl filename color correct with a color decision list", |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 3312 | "-charcoal geometry simulate a charcoal drawing", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3313 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3314 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3315 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3316 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3317 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3318 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3319 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3320 | "-contrast enhance or reduce the image contrast", |
| 3321 | "-contrast-stretch geometry", |
| 3322 | " improve contrast by `stretching' the intensity range", |
| 3323 | "-convolve coefficients", |
| 3324 | " apply a convolution kernel to the image", |
| 3325 | "-cycle amount cycle the image colormap", |
| 3326 | "-decipher filename convert cipher pixels to plain pixels", |
| 3327 | "-deskew threshold straighten an image", |
| 3328 | "-despeckle reduce the speckles within an image", |
| 3329 | "-distort method args", |
| 3330 | " distort images according to given method ad args", |
| 3331 | "-draw string annotate the image with a graphic primitive", |
| 3332 | "-edge radius apply a filter to detect edges in the image", |
| 3333 | "-encipher filename convert plain pixels to cipher pixels", |
| 3334 | "-emboss radius emboss an image", |
| 3335 | "-enhance apply a digital filter to enhance a noisy image", |
| 3336 | "-equalize perform histogram equalization to an image", |
| 3337 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3338 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3339 | "-extent geometry set the image size", |
| 3340 | "-extract geometry extract area from image", |
| 3341 | "-fft implements the discrete Fourier transform (DFT)", |
| 3342 | "-flip flip image vertically", |
| 3343 | "-floodfill geometry color", |
| 3344 | " floodfill the image with color", |
| 3345 | "-flop flop image horizontally", |
| 3346 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3347 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3348 | " apply function over image values", |
| 3349 | "-gamma value level of gamma correction", |
| 3350 | "-gaussian-blur geometry", |
| 3351 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3352 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3353 | "-identify identify the format and characteristics of the image", |
| 3354 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3355 | "-implode amount implode image pixels about the center", |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3356 | "-interpolative-resize geometry", |
| 3357 | " resize image using interpolation", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3358 | "-lat geometry local adaptive thresholding", |
| 3359 | "-layers method optimize, merge, or compare image layers", |
| 3360 | "-level value adjust the level of image contrast", |
| 3361 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3362 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3363 | "-linear-stretch geometry", |
| 3364 | " improve contrast by `stretching with saturation'", |
| 3365 | "-liquid-rescale geometry", |
| 3366 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3367 | "-median geometry apply a median filter to the image", |
glennrp | 30d2dc6 | 2011-06-25 03:17:16 +0000 | [diff] [blame] | 3368 | "-mode geometry make each pixel the 'predominant color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3369 | "-modulate value vary the brightness, saturation, and hue", |
| 3370 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3371 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3372 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3373 | "-motion-blur geometry", |
| 3374 | " simulate motion blur", |
| 3375 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3376 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3377 | "-normalize transform image to span the full range of colors", |
| 3378 | "-opaque color change this color to the fill color", |
| 3379 | "-ordered-dither NxN", |
| 3380 | " add a noise pattern to the image with specific", |
| 3381 | " amplitudes", |
| 3382 | "-paint radius simulate an oil painting", |
| 3383 | "-polaroid angle simulate a Polaroid picture", |
| 3384 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3385 | "-profile filename add, delete, or apply an image profile", |
| 3386 | "-quantize colorspace reduce colors in this colorspace", |
| 3387 | "-radial-blur angle radial blur the image", |
| 3388 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3389 | "-random-threshold low,high", |
| 3390 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3391 | "-region geometry apply options to a portion of the image", |
| 3392 | "-render render vector graphics", |
| 3393 | "-repage geometry size and location of an image canvas", |
| 3394 | "-resample geometry change the resolution of an image", |
| 3395 | "-resize geometry resize the image", |
| 3396 | "-roll geometry roll an image vertically or horizontally", |
| 3397 | "-rotate degrees apply Paeth rotation to the image", |
| 3398 | "-sample geometry scale image with pixel sampling", |
| 3399 | "-scale geometry scale the image", |
| 3400 | "-segment values segment an image", |
| 3401 | "-selective-blur geometry", |
| 3402 | " selectively blur pixels within a contrast threshold", |
| 3403 | "-sepia-tone threshold", |
| 3404 | " simulate a sepia-toned photo", |
| 3405 | "-set property value set an image property", |
| 3406 | "-shade degrees shade the image using a distant light source", |
| 3407 | "-shadow geometry simulate an image shadow", |
| 3408 | "-sharpen geometry sharpen the image", |
| 3409 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3410 | "-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] | 3411 | "-sigmoidal-contrast geometry", |
| 3412 | " increase the contrast without saturating highlights or shadows", |
| 3413 | "-sketch geometry simulate a pencil sketch", |
| 3414 | "-solarize threshold negate all pixels above the threshold level", |
| 3415 | "-sparse-color method args", |
| 3416 | " fill in a image based on a few color points", |
| 3417 | "-splice geometry splice the background color into the image", |
| 3418 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3419 | "-statistic type radius", |
| 3420 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3421 | "-strip strip image of all profiles and comments", |
| 3422 | "-swirl degrees swirl image pixels about the center", |
| 3423 | "-threshold value threshold the image", |
| 3424 | "-thumbnail geometry create a thumbnail of the image", |
| 3425 | "-tile filename tile image when filling a graphic primitive", |
| 3426 | "-tint value tint the image with the fill color", |
| 3427 | "-transform affine transform image", |
| 3428 | "-transparent color make this color transparent within the image", |
| 3429 | "-transpose flip image vertically and rotate 90 degrees", |
| 3430 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3431 | "-trim trim image edges", |
| 3432 | "-type type image type", |
| 3433 | "-unique-colors discard all but one of any pixel color", |
| 3434 | "-unsharp geometry sharpen the image", |
| 3435 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3436 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3437 | "-white-threshold value", |
| 3438 | " force all pixels above the threshold into white", |
| 3439 | (char *) NULL |
| 3440 | }, |
| 3441 | *sequence_operators[]= |
| 3442 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3443 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3444 | "-clut apply a color lookup table to the image", |
| 3445 | "-coalesce merge a sequence of images", |
| 3446 | "-combine combine a sequence of images", |
| 3447 | "-composite composite image", |
| 3448 | "-crop geometry cut out a rectangular region of the image", |
| 3449 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3450 | "-evaluate-sequence operator", |
| 3451 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3452 | "-flatten flatten a sequence of images", |
| 3453 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3454 | "-hald-clut apply a Hald color lookup table to the image", |
| 3455 | "-morph value morph an image sequence", |
| 3456 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3457 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3458 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3459 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3460 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3461 | "-write filename write images to this file", |
| 3462 | (char *) NULL |
| 3463 | }, |
| 3464 | *settings[]= |
| 3465 | { |
| 3466 | "-adjoin join images into a single multi-image file", |
| 3467 | "-affine matrix affine transform matrix", |
| 3468 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3469 | "-antialias remove pixel-aliasing", |
| 3470 | "-authenticate password", |
| 3471 | " decipher image with this password", |
| 3472 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3473 | "-background color background color", |
| 3474 | "-bias value add bias when convolving an image", |
| 3475 | "-black-point-compensation", |
| 3476 | " use black point compensation", |
| 3477 | "-blue-primary point chromaticity blue primary point", |
| 3478 | "-bordercolor color border color", |
| 3479 | "-caption string assign a caption to an image", |
| 3480 | "-channel type apply option to select image channels", |
| 3481 | "-colors value preferred number of colors in the image", |
| 3482 | "-colorspace type alternate image colorspace", |
| 3483 | "-comment string annotate image with comment", |
| 3484 | "-compose operator set image composite operator", |
| 3485 | "-compress type type of pixel compression when writing the image", |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3486 | "-define format:option=value", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3487 | " define one or more image format options", |
| 3488 | "-delay value display the next image after pausing", |
| 3489 | "-density geometry horizontal and vertical density of the image", |
| 3490 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3491 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3492 | "-display server get image or font from this X server", |
| 3493 | "-dispose method layer disposal method", |
| 3494 | "-dither method apply error diffusion to image", |
| 3495 | "-encoding type text encoding type", |
| 3496 | "-endian type endianness (MSB or LSB) of the image", |
| 3497 | "-family name render text with this font family", |
| 3498 | "-fill color color to use when filling a graphic primitive", |
| 3499 | "-filter type use this filter when resizing an image", |
| 3500 | "-font name render text with this font", |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3501 | "-format \"string\" output formatted image characteristics", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3502 | "-fuzz distance colors within this distance are considered equal", |
| 3503 | "-gravity type horizontal and vertical text placement", |
| 3504 | "-green-primary point chromaticity green primary point", |
| 3505 | "-intent type type of rendering intent when managing the image color", |
| 3506 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3507 | "-interline-spacing value", |
| 3508 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3509 | "-interpolate method pixel color interpolation method", |
| 3510 | "-interword-spacing value", |
| 3511 | " set the space between two words", |
| 3512 | "-kerning value set the space between two letters", |
| 3513 | "-label string assign a label to an image", |
| 3514 | "-limit type value pixel cache resource limit", |
| 3515 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3516 | "-mask filename associate a mask with the image", |
| 3517 | "-mattecolor color frame color", |
| 3518 | "-monitor monitor progress", |
| 3519 | "-orient type image orientation", |
| 3520 | "-page geometry size and location of an image canvas (setting)", |
| 3521 | "-ping efficiently determine image attributes", |
| 3522 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3523 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3524 | "-preview type image preview type", |
| 3525 | "-quality value JPEG/MIFF/PNG compression level", |
| 3526 | "-quiet suppress all warning messages", |
| 3527 | "-red-primary point chromaticity red primary point", |
| 3528 | "-regard-warnings pay attention to warning messages", |
| 3529 | "-remap filename transform image colors to match this set of colors", |
| 3530 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3531 | "-sampling-factor geometry", |
| 3532 | " horizontal and vertical sampling factor", |
| 3533 | "-scene value image scene number", |
| 3534 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3535 | "-size geometry width and height of image", |
| 3536 | "-stretch type render text with this font stretch", |
| 3537 | "-stroke color graphic primitive stroke color", |
| 3538 | "-strokewidth value graphic primitive stroke width", |
| 3539 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3540 | "-synchronize synchronize image to storage device", |
| 3541 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3542 | "-texture filename name of texture to tile onto the image background", |
| 3543 | "-tile-offset geometry", |
| 3544 | " tile offset", |
| 3545 | "-treedepth value color tree depth", |
| 3546 | "-transparent-color color", |
| 3547 | " transparent color", |
| 3548 | "-undercolor color annotation bounding box color", |
| 3549 | "-units type the units of image resolution", |
| 3550 | "-verbose print detailed information about the image", |
| 3551 | "-view FlashPix viewing transforms", |
| 3552 | "-virtual-pixel method", |
| 3553 | " virtual pixel access method", |
| 3554 | "-weight type render text with this font weight", |
| 3555 | "-white-point point chromaticity white point", |
| 3556 | (char *) NULL |
| 3557 | }, |
| 3558 | *stack_operators[]= |
| 3559 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3560 | "-delete indexes delete the image from the image sequence", |
| 3561 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3562 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3563 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3564 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3565 | "-swap indexes swap two images in the image sequence", |
| 3566 | (char *) NULL |
| 3567 | }; |
| 3568 | |
| 3569 | const char |
| 3570 | **p; |
| 3571 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3572 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3573 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3574 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3575 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3576 | GetClientName()); |
| 3577 | (void) printf("\nImage Settings:\n"); |
| 3578 | for (p=settings; *p != (char *) NULL; p++) |
| 3579 | (void) printf(" %s\n",*p); |
| 3580 | (void) printf("\nImage Operators:\n"); |
| 3581 | for (p=operators; *p != (char *) NULL; p++) |
| 3582 | (void) printf(" %s\n",*p); |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3583 | (void) printf("\nImage Channel Operators:\n"); |
| 3584 | for (p=channel_operators; *p != (char *) NULL; p++) |
| 3585 | (void) printf(" %s\n",*p); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3586 | (void) printf("\nImage Sequence Operators:\n"); |
| 3587 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3588 | (void) printf(" %s\n",*p); |
| 3589 | (void) printf("\nImage Stack Operators:\n"); |
| 3590 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3591 | (void) printf(" %s\n",*p); |
| 3592 | (void) printf("\nMiscellaneous Options:\n"); |
| 3593 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3594 | (void) printf(" %s\n",*p); |
| 3595 | (void) printf( |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3596 | "\nBy default, the image format of 'file' is determined by its magic\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3597 | (void) printf( |
| 3598 | "number. To specify a particular image format, precede the filename\n"); |
| 3599 | (void) printf( |
| 3600 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3601 | (void) printf( |
| 3602 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3603 | (void) printf("'-' for standard input or output.\n"); |
| 3604 | return(MagickFalse); |
| 3605 | } |
| 3606 | |
| 3607 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3608 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3609 | { |
| 3610 | #define DestroyMogrify() \ |
| 3611 | { \ |
| 3612 | if (format != (char *) NULL) \ |
| 3613 | format=DestroyString(format); \ |
| 3614 | if (path != (char *) NULL) \ |
| 3615 | path=DestroyString(path); \ |
| 3616 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3617 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3618 | argv[i]=DestroyString(argv[i]); \ |
| 3619 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3620 | } |
| 3621 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3622 | { \ |
| 3623 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3624 | option); \ |
| 3625 | DestroyMogrify(); \ |
| 3626 | return(MagickFalse); \ |
| 3627 | } |
| 3628 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3629 | { \ |
| 3630 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3631 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3632 | DestroyMogrify(); \ |
| 3633 | return(MagickFalse); \ |
| 3634 | } |
| 3635 | |
| 3636 | char |
| 3637 | *format, |
| 3638 | *option, |
| 3639 | *path; |
| 3640 | |
| 3641 | Image |
| 3642 | *image; |
| 3643 | |
| 3644 | ImageStack |
| 3645 | image_stack[MaxImageStackDepth+1]; |
| 3646 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3647 | MagickBooleanType |
| 3648 | global_colormap; |
| 3649 | |
| 3650 | MagickBooleanType |
| 3651 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3652 | pend, |
| 3653 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3654 | |
| 3655 | MagickStatusType |
| 3656 | status; |
| 3657 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3658 | register ssize_t |
| 3659 | i; |
| 3660 | |
| 3661 | ssize_t |
| 3662 | j, |
| 3663 | k; |
| 3664 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3665 | /* |
| 3666 | Set defaults. |
| 3667 | */ |
| 3668 | assert(image_info != (ImageInfo *) NULL); |
| 3669 | assert(image_info->signature == MagickSignature); |
| 3670 | if (image_info->debug != MagickFalse) |
| 3671 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3672 | assert(exception != (ExceptionInfo *) NULL); |
| 3673 | if (argc == 2) |
| 3674 | { |
| 3675 | option=argv[1]; |
| 3676 | if ((LocaleCompare("version",option+1) == 0) || |
| 3677 | (LocaleCompare("-version",option+1) == 0)) |
| 3678 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3679 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3680 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 3681 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 3682 | GetMagickCopyright()); |
| 3683 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 3684 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3685 | return(MagickFalse); |
| 3686 | } |
| 3687 | } |
| 3688 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3689 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3690 | format=(char *) NULL; |
| 3691 | path=(char *) NULL; |
| 3692 | global_colormap=MagickFalse; |
| 3693 | k=0; |
| 3694 | j=1; |
| 3695 | NewImageStack(); |
| 3696 | option=(char *) NULL; |
| 3697 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3698 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3699 | status=MagickTrue; |
| 3700 | /* |
| 3701 | Parse command line. |
| 3702 | */ |
| 3703 | ReadCommandlLine(argc,&argv); |
| 3704 | status=ExpandFilenames(&argc,&argv); |
| 3705 | if (status == MagickFalse) |
| 3706 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3707 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3708 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3709 | { |
| 3710 | option=argv[i]; |
| 3711 | if (LocaleCompare(option,"(") == 0) |
| 3712 | { |
| 3713 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3714 | if (k == MaxImageStackDepth) |
| 3715 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3716 | option); |
| 3717 | PushImageStack(); |
| 3718 | continue; |
| 3719 | } |
| 3720 | if (LocaleCompare(option,")") == 0) |
| 3721 | { |
| 3722 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3723 | if (k == 0) |
| 3724 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3725 | PopImageStack(); |
| 3726 | continue; |
| 3727 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3728 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3729 | { |
| 3730 | char |
| 3731 | backup_filename[MaxTextExtent], |
| 3732 | *filename; |
| 3733 | |
| 3734 | Image |
| 3735 | *images; |
| 3736 | |
| 3737 | /* |
| 3738 | Option is a file name: begin by reading image from specified file. |
| 3739 | */ |
| 3740 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3741 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3742 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3743 | filename=argv[++i]; |
cristy | 1b58f25 | 2012-03-01 01:41:41 +0000 | [diff] [blame] | 3744 | images=ReadImages(image_info,filename,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3745 | status&=(images != (Image *) NULL) && |
| 3746 | (exception->severity < ErrorException); |
| 3747 | if (images == (Image *) NULL) |
| 3748 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3749 | if (format != (char *) NULL) |
| 3750 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3751 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3752 | if (path != (char *) NULL) |
| 3753 | { |
| 3754 | GetPathComponent(option,TailPath,filename); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3755 | (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3756 | path,*DirectorySeparator,filename); |
| 3757 | } |
| 3758 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3759 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3760 | AppendImageStack(images); |
| 3761 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3762 | if (global_colormap != MagickFalse) |
| 3763 | { |
| 3764 | QuantizeInfo |
| 3765 | *quantize_info; |
| 3766 | |
| 3767 | quantize_info=AcquireQuantizeInfo(image_info); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3768 | (void) RemapImages(quantize_info,images,(Image *) NULL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3769 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3770 | } |
| 3771 | *backup_filename='\0'; |
| 3772 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3773 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3774 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3775 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3776 | i; |
| 3777 | |
| 3778 | /* |
| 3779 | Rename image file as backup. |
| 3780 | */ |
| 3781 | (void) CopyMagickString(backup_filename,image->filename, |
| 3782 | MaxTextExtent); |
| 3783 | for (i=0; i < 6; i++) |
| 3784 | { |
| 3785 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3786 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3787 | break; |
| 3788 | } |
| 3789 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
cristy | 320684d | 2011-09-23 14:55:47 +0000 | [diff] [blame] | 3790 | (rename_utf8(image->filename,backup_filename) != 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3791 | *backup_filename='\0'; |
| 3792 | } |
| 3793 | /* |
| 3794 | Write transmogrified image to disk. |
| 3795 | */ |
| 3796 | image_info->synchronize=MagickTrue; |
| 3797 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3798 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 3799 | (void) remove_utf8(backup_filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3800 | RemoveAllImageStack(); |
| 3801 | continue; |
| 3802 | } |
| 3803 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3804 | switch (*(option+1)) |
| 3805 | { |
| 3806 | case 'a': |
| 3807 | { |
| 3808 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3809 | { |
| 3810 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3811 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3812 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3813 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3814 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3815 | break; |
| 3816 | } |
| 3817 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3818 | { |
| 3819 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3820 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3821 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3822 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3823 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3824 | break; |
| 3825 | } |
| 3826 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3827 | { |
| 3828 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3829 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3830 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3831 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3832 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3833 | break; |
| 3834 | } |
| 3835 | if (LocaleCompare("affine",option+1) == 0) |
| 3836 | { |
| 3837 | if (*option == '+') |
| 3838 | break; |
| 3839 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3840 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3841 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3842 | break; |
| 3843 | } |
| 3844 | if (LocaleCompare("alpha",option+1) == 0) |
| 3845 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3846 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3847 | type; |
| 3848 | |
| 3849 | if (*option == '+') |
| 3850 | break; |
| 3851 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3852 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3853 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3854 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3855 | if (type < 0) |
| 3856 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3857 | argv[i]); |
| 3858 | break; |
| 3859 | } |
| 3860 | if (LocaleCompare("annotate",option+1) == 0) |
| 3861 | { |
| 3862 | if (*option == '+') |
| 3863 | break; |
| 3864 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3865 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3866 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3867 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3868 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3869 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3870 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3871 | i++; |
| 3872 | break; |
| 3873 | } |
| 3874 | if (LocaleCompare("antialias",option+1) == 0) |
| 3875 | break; |
| 3876 | if (LocaleCompare("append",option+1) == 0) |
| 3877 | break; |
| 3878 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3879 | { |
| 3880 | if (*option == '+') |
| 3881 | break; |
| 3882 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3883 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3884 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3885 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3886 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3887 | break; |
| 3888 | } |
| 3889 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3890 | { |
| 3891 | if (*option == '+') |
| 3892 | break; |
| 3893 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3894 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3895 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3896 | break; |
| 3897 | } |
| 3898 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3899 | break; |
| 3900 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3901 | break; |
| 3902 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3903 | break; |
| 3904 | if (LocaleCompare("average",option+1) == 0) |
| 3905 | break; |
| 3906 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3907 | } |
| 3908 | case 'b': |
| 3909 | { |
| 3910 | if (LocaleCompare("background",option+1) == 0) |
| 3911 | { |
| 3912 | if (*option == '+') |
| 3913 | break; |
| 3914 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3915 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3916 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3917 | break; |
| 3918 | } |
| 3919 | if (LocaleCompare("bias",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-1)) |
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("black-point-compensation",option+1) == 0) |
| 3931 | break; |
| 3932 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 3933 | { |
| 3934 | if (*option == '+') |
| 3935 | break; |
| 3936 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3937 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3938 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3939 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3940 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3941 | break; |
| 3942 | } |
| 3943 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3944 | { |
| 3945 | if (*option == '+') |
| 3946 | break; |
| 3947 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3948 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3949 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3950 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3951 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3952 | break; |
| 3953 | } |
| 3954 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3955 | { |
| 3956 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3957 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3958 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3959 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3960 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3961 | break; |
| 3962 | } |
| 3963 | if (LocaleCompare("blur",option+1) == 0) |
| 3964 | { |
| 3965 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3966 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3967 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3968 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3969 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3970 | break; |
| 3971 | } |
| 3972 | if (LocaleCompare("border",option+1) == 0) |
| 3973 | { |
| 3974 | if (*option == '+') |
| 3975 | break; |
| 3976 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3977 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3978 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3979 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3980 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3981 | break; |
| 3982 | } |
| 3983 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3984 | { |
| 3985 | if (*option == '+') |
| 3986 | break; |
| 3987 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3988 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3989 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3990 | break; |
| 3991 | } |
| 3992 | if (LocaleCompare("box",option+1) == 0) |
| 3993 | { |
| 3994 | if (*option == '+') |
| 3995 | break; |
| 3996 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3997 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3998 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3999 | break; |
| 4000 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 4001 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 4002 | { |
| 4003 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4004 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 4005 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4006 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4007 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4008 | break; |
| 4009 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4010 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4011 | } |
| 4012 | case 'c': |
| 4013 | { |
| 4014 | if (LocaleCompare("cache",option+1) == 0) |
| 4015 | { |
| 4016 | if (*option == '+') |
| 4017 | break; |
| 4018 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4019 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4020 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4021 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4022 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4023 | break; |
| 4024 | } |
| 4025 | if (LocaleCompare("caption",option+1) == 0) |
| 4026 | { |
| 4027 | if (*option == '+') |
| 4028 | break; |
| 4029 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4030 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4031 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4032 | break; |
| 4033 | } |
| 4034 | if (LocaleCompare("channel",option+1) == 0) |
| 4035 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4036 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4037 | channel; |
| 4038 | |
| 4039 | if (*option == '+') |
| 4040 | break; |
| 4041 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4042 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4043 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4044 | channel=ParseChannelOption(argv[i]); |
| 4045 | if (channel < 0) |
| 4046 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 4047 | argv[i]); |
| 4048 | break; |
| 4049 | } |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 4050 | if (LocaleCompare("channel-extract",option+1) == 0) |
| 4051 | { |
| 4052 | ssize_t |
| 4053 | channel; |
| 4054 | |
| 4055 | if (*option == '+') |
| 4056 | break; |
| 4057 | i++; |
| 4058 | if (i == (ssize_t) (argc-1)) |
| 4059 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 953c4bd | 2012-02-24 01:04:04 +0000 | [diff] [blame] | 4060 | channel=ParsePixelChannelOption(argv[i]); |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 4061 | if (channel < 0) |
| 4062 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 4063 | argv[i]); |
| 4064 | break; |
| 4065 | } |
| 4066 | if (LocaleCompare("channel-inject",option+1) == 0) |
| 4067 | { |
| 4068 | ssize_t |
| 4069 | channel; |
| 4070 | |
| 4071 | if (*option == '+') |
| 4072 | break; |
| 4073 | i++; |
| 4074 | if (i == (ssize_t) (argc-1)) |
| 4075 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 953c4bd | 2012-02-24 01:04:04 +0000 | [diff] [blame] | 4076 | channel=ParsePixelChannelOption(argv[i]); |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 4077 | if (channel < 0) |
| 4078 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 4079 | argv[i]); |
| 4080 | break; |
| 4081 | } |
| 4082 | if (LocaleCompare("channel-swap",option+1) == 0) |
| 4083 | { |
| 4084 | ssize_t |
| 4085 | channel; |
| 4086 | |
| 4087 | if (*option == '+') |
| 4088 | break; |
| 4089 | i++; |
| 4090 | if (i == (ssize_t) (argc-1)) |
| 4091 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 953c4bd | 2012-02-24 01:04:04 +0000 | [diff] [blame] | 4092 | channel=ParsePixelChannelOption(argv[i]); |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 4093 | if (channel < 0) |
| 4094 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 4095 | argv[i]); |
| 4096 | break; |
| 4097 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4098 | if (LocaleCompare("cdl",option+1) == 0) |
| 4099 | { |
| 4100 | if (*option == '+') |
| 4101 | break; |
| 4102 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4103 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4104 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4105 | break; |
| 4106 | } |
| 4107 | if (LocaleCompare("charcoal",option+1) == 0) |
| 4108 | { |
| 4109 | if (*option == '+') |
| 4110 | break; |
| 4111 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4112 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4113 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4114 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4115 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4116 | break; |
| 4117 | } |
| 4118 | if (LocaleCompare("chop",option+1) == 0) |
| 4119 | { |
| 4120 | if (*option == '+') |
| 4121 | break; |
| 4122 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4123 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4124 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4125 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4126 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4127 | break; |
| 4128 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4129 | if (LocaleCompare("clamp",option+1) == 0) |
| 4130 | break; |
| 4131 | if (LocaleCompare("clip",option+1) == 0) |
| 4132 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4133 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4134 | { |
| 4135 | if (*option == '+') |
| 4136 | break; |
| 4137 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4138 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4139 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4140 | break; |
| 4141 | } |
| 4142 | if (LocaleCompare("clut",option+1) == 0) |
| 4143 | break; |
| 4144 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4145 | break; |
| 4146 | if (LocaleCompare("colorize",option+1) == 0) |
| 4147 | { |
| 4148 | if (*option == '+') |
| 4149 | break; |
| 4150 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4151 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4152 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4153 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4154 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4155 | break; |
| 4156 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4157 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4158 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4159 | KernelInfo |
| 4160 | *kernel_info; |
| 4161 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4162 | if (*option == '+') |
| 4163 | break; |
| 4164 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4165 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4166 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4167 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4168 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4169 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4170 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4171 | break; |
| 4172 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4173 | if (LocaleCompare("colors",option+1) == 0) |
| 4174 | { |
| 4175 | if (*option == '+') |
| 4176 | break; |
| 4177 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4178 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4179 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4180 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4181 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4182 | break; |
| 4183 | } |
| 4184 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4185 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4186 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4187 | colorspace; |
| 4188 | |
| 4189 | if (*option == '+') |
| 4190 | break; |
| 4191 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4192 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4193 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4194 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4195 | argv[i]); |
| 4196 | if (colorspace < 0) |
| 4197 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4198 | argv[i]); |
| 4199 | break; |
| 4200 | } |
| 4201 | if (LocaleCompare("combine",option+1) == 0) |
| 4202 | break; |
| 4203 | if (LocaleCompare("comment",option+1) == 0) |
| 4204 | { |
| 4205 | if (*option == '+') |
| 4206 | break; |
| 4207 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4208 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4209 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4210 | break; |
| 4211 | } |
| 4212 | if (LocaleCompare("composite",option+1) == 0) |
| 4213 | break; |
| 4214 | if (LocaleCompare("compress",option+1) == 0) |
| 4215 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4216 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4217 | compress; |
| 4218 | |
| 4219 | if (*option == '+') |
| 4220 | break; |
| 4221 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4222 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4223 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4224 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4225 | argv[i]); |
| 4226 | if (compress < 0) |
| 4227 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4228 | argv[i]); |
| 4229 | break; |
| 4230 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4231 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4232 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4233 | if (LocaleCompare("contrast",option+1) == 0) |
| 4234 | break; |
| 4235 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4236 | { |
| 4237 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4238 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4239 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4240 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4241 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4242 | break; |
| 4243 | } |
| 4244 | if (LocaleCompare("convolve",option+1) == 0) |
| 4245 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4246 | KernelInfo |
| 4247 | *kernel_info; |
| 4248 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4249 | if (*option == '+') |
| 4250 | break; |
| 4251 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4252 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4253 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4254 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4255 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4256 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4257 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4258 | break; |
| 4259 | } |
| 4260 | if (LocaleCompare("crop",option+1) == 0) |
| 4261 | { |
| 4262 | if (*option == '+') |
| 4263 | break; |
| 4264 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4265 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4266 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4267 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4268 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4269 | break; |
| 4270 | } |
| 4271 | if (LocaleCompare("cycle",option+1) == 0) |
| 4272 | { |
| 4273 | if (*option == '+') |
| 4274 | break; |
| 4275 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4276 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4277 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4278 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4279 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4280 | break; |
| 4281 | } |
| 4282 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4283 | } |
| 4284 | case 'd': |
| 4285 | { |
| 4286 | if (LocaleCompare("decipher",option+1) == 0) |
| 4287 | { |
| 4288 | if (*option == '+') |
| 4289 | break; |
| 4290 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4291 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4292 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4293 | break; |
| 4294 | } |
| 4295 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4296 | break; |
| 4297 | if (LocaleCompare("debug",option+1) == 0) |
| 4298 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4299 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4300 | event; |
| 4301 | |
| 4302 | if (*option == '+') |
| 4303 | break; |
| 4304 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4305 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4306 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4307 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4308 | if (event < 0) |
| 4309 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4310 | argv[i]); |
| 4311 | (void) SetLogEventMask(argv[i]); |
| 4312 | break; |
| 4313 | } |
| 4314 | if (LocaleCompare("define",option+1) == 0) |
| 4315 | { |
| 4316 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4317 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4318 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4319 | if (*option == '+') |
| 4320 | { |
| 4321 | const char |
| 4322 | *define; |
| 4323 | |
| 4324 | define=GetImageOption(image_info,argv[i]); |
| 4325 | if (define == (const char *) NULL) |
| 4326 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4327 | break; |
| 4328 | } |
| 4329 | break; |
| 4330 | } |
| 4331 | if (LocaleCompare("delay",option+1) == 0) |
| 4332 | { |
| 4333 | if (*option == '+') |
| 4334 | break; |
| 4335 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4336 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4337 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4338 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4339 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4340 | break; |
| 4341 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4342 | if (LocaleCompare("delete",option+1) == 0) |
| 4343 | { |
| 4344 | if (*option == '+') |
| 4345 | break; |
| 4346 | i++; |
| 4347 | if (i == (ssize_t) (argc-1)) |
| 4348 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4349 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4350 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4351 | break; |
| 4352 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4353 | if (LocaleCompare("density",option+1) == 0) |
| 4354 | { |
| 4355 | if (*option == '+') |
| 4356 | break; |
| 4357 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4358 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4359 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4360 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4361 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4362 | break; |
| 4363 | } |
| 4364 | if (LocaleCompare("depth",option+1) == 0) |
| 4365 | { |
| 4366 | if (*option == '+') |
| 4367 | break; |
| 4368 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4369 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4370 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4371 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4372 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4373 | break; |
| 4374 | } |
| 4375 | if (LocaleCompare("deskew",option+1) == 0) |
| 4376 | { |
| 4377 | if (*option == '+') |
| 4378 | break; |
| 4379 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4380 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4381 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4382 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4383 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4384 | break; |
| 4385 | } |
| 4386 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4387 | break; |
| 4388 | if (LocaleCompare("dft",option+1) == 0) |
| 4389 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4390 | if (LocaleCompare("direction",option+1) == 0) |
| 4391 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4392 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4393 | direction; |
| 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 | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4399 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4400 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4401 | argv[i]); |
| 4402 | if (direction < 0) |
| 4403 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4404 | argv[i]); |
| 4405 | break; |
| 4406 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4407 | if (LocaleCompare("display",option+1) == 0) |
| 4408 | { |
| 4409 | if (*option == '+') |
| 4410 | break; |
| 4411 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4412 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4413 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4414 | break; |
| 4415 | } |
| 4416 | if (LocaleCompare("dispose",option+1) == 0) |
| 4417 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4418 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4419 | dispose; |
| 4420 | |
| 4421 | if (*option == '+') |
| 4422 | break; |
| 4423 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4424 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4425 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4426 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4427 | if (dispose < 0) |
| 4428 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4429 | argv[i]); |
| 4430 | break; |
| 4431 | } |
| 4432 | if (LocaleCompare("distort",option+1) == 0) |
| 4433 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4434 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4435 | op; |
| 4436 | |
| 4437 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4438 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4439 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4440 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4441 | if (op < 0) |
| 4442 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4443 | argv[i]); |
| 4444 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4445 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4446 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4447 | break; |
| 4448 | } |
| 4449 | if (LocaleCompare("dither",option+1) == 0) |
| 4450 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4451 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4452 | method; |
| 4453 | |
| 4454 | if (*option == '+') |
| 4455 | break; |
| 4456 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4457 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4458 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4459 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4460 | if (method < 0) |
| 4461 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4462 | argv[i]); |
| 4463 | break; |
| 4464 | } |
| 4465 | if (LocaleCompare("draw",option+1) == 0) |
| 4466 | { |
| 4467 | if (*option == '+') |
| 4468 | break; |
| 4469 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4470 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4471 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4472 | break; |
| 4473 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4474 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4475 | { |
| 4476 | if (*option == '+') |
| 4477 | break; |
| 4478 | i++; |
| 4479 | if (i == (ssize_t) (argc-1)) |
| 4480 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4481 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4482 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4483 | break; |
| 4484 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4485 | if (LocaleCompare("duration",option+1) == 0) |
| 4486 | { |
| 4487 | if (*option == '+') |
| 4488 | break; |
| 4489 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4490 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4491 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4492 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4493 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4494 | break; |
| 4495 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4496 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4497 | } |
| 4498 | case 'e': |
| 4499 | { |
| 4500 | if (LocaleCompare("edge",option+1) == 0) |
| 4501 | { |
| 4502 | if (*option == '+') |
| 4503 | break; |
| 4504 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4505 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4506 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4507 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4508 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4509 | break; |
| 4510 | } |
| 4511 | if (LocaleCompare("emboss",option+1) == 0) |
| 4512 | { |
| 4513 | if (*option == '+') |
| 4514 | break; |
| 4515 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4516 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4517 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4518 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4519 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4520 | break; |
| 4521 | } |
| 4522 | if (LocaleCompare("encipher",option+1) == 0) |
| 4523 | { |
| 4524 | if (*option == '+') |
| 4525 | break; |
| 4526 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4527 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4528 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4529 | break; |
| 4530 | } |
| 4531 | if (LocaleCompare("encoding",option+1) == 0) |
| 4532 | { |
| 4533 | if (*option == '+') |
| 4534 | break; |
| 4535 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4536 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4537 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4538 | break; |
| 4539 | } |
| 4540 | if (LocaleCompare("endian",option+1) == 0) |
| 4541 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4542 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4543 | endian; |
| 4544 | |
| 4545 | if (*option == '+') |
| 4546 | break; |
| 4547 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4548 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4549 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4550 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4551 | if (endian < 0) |
| 4552 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4553 | argv[i]); |
| 4554 | break; |
| 4555 | } |
| 4556 | if (LocaleCompare("enhance",option+1) == 0) |
| 4557 | break; |
| 4558 | if (LocaleCompare("equalize",option+1) == 0) |
| 4559 | break; |
| 4560 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4561 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4562 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4563 | op; |
| 4564 | |
| 4565 | if (*option == '+') |
| 4566 | break; |
| 4567 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4568 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4569 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4570 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4571 | if (op < 0) |
| 4572 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4573 | argv[i]); |
| 4574 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4575 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4576 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4577 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4578 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4579 | break; |
| 4580 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4581 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4582 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4583 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4584 | op; |
| 4585 | |
| 4586 | if (*option == '+') |
| 4587 | break; |
| 4588 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4589 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4590 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4591 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4592 | if (op < 0) |
| 4593 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4594 | argv[i]); |
| 4595 | break; |
| 4596 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4597 | if (LocaleCompare("extent",option+1) == 0) |
| 4598 | { |
| 4599 | if (*option == '+') |
| 4600 | break; |
| 4601 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4602 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4603 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4604 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4605 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4606 | break; |
| 4607 | } |
| 4608 | if (LocaleCompare("extract",option+1) == 0) |
| 4609 | { |
| 4610 | if (*option == '+') |
| 4611 | break; |
| 4612 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4613 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4614 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4615 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4616 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4617 | break; |
| 4618 | } |
| 4619 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4620 | } |
| 4621 | case 'f': |
| 4622 | { |
| 4623 | if (LocaleCompare("family",option+1) == 0) |
| 4624 | { |
| 4625 | if (*option == '+') |
| 4626 | break; |
| 4627 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4628 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4629 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4630 | break; |
| 4631 | } |
| 4632 | if (LocaleCompare("fill",option+1) == 0) |
| 4633 | { |
| 4634 | if (*option == '+') |
| 4635 | break; |
| 4636 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4637 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4638 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4639 | break; |
| 4640 | } |
| 4641 | if (LocaleCompare("filter",option+1) == 0) |
| 4642 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4643 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4644 | filter; |
| 4645 | |
| 4646 | if (*option == '+') |
| 4647 | break; |
| 4648 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4649 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4650 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4651 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4652 | if (filter < 0) |
| 4653 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4654 | argv[i]); |
| 4655 | break; |
| 4656 | } |
| 4657 | if (LocaleCompare("flatten",option+1) == 0) |
| 4658 | break; |
| 4659 | if (LocaleCompare("flip",option+1) == 0) |
| 4660 | break; |
| 4661 | if (LocaleCompare("flop",option+1) == 0) |
| 4662 | break; |
| 4663 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4664 | { |
| 4665 | if (*option == '+') |
| 4666 | break; |
| 4667 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4668 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4669 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4670 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4671 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4672 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4673 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4674 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4675 | break; |
| 4676 | } |
| 4677 | if (LocaleCompare("font",option+1) == 0) |
| 4678 | { |
| 4679 | if (*option == '+') |
| 4680 | break; |
| 4681 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4682 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4683 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4684 | break; |
| 4685 | } |
| 4686 | if (LocaleCompare("format",option+1) == 0) |
| 4687 | { |
| 4688 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4689 | (void) CloneString(&format,(char *) NULL); |
| 4690 | if (*option == '+') |
| 4691 | break; |
| 4692 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4693 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4694 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4695 | (void) CloneString(&format,argv[i]); |
| 4696 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4697 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4698 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4699 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4700 | if (*image_info->magick == '\0') |
| 4701 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4702 | format); |
| 4703 | break; |
| 4704 | } |
| 4705 | if (LocaleCompare("frame",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("function",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 | op; |
| 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 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4727 | if (op < 0) |
| 4728 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4729 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4730 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4731 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4732 | break; |
| 4733 | } |
| 4734 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4735 | { |
| 4736 | if (*option == '+') |
| 4737 | break; |
| 4738 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4739 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4740 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4741 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4742 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4743 | break; |
| 4744 | } |
| 4745 | if (LocaleCompare("fx",option+1) == 0) |
| 4746 | { |
| 4747 | if (*option == '+') |
| 4748 | break; |
| 4749 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4750 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4751 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4752 | break; |
| 4753 | } |
| 4754 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4755 | } |
| 4756 | case 'g': |
| 4757 | { |
| 4758 | if (LocaleCompare("gamma",option+1) == 0) |
| 4759 | { |
| 4760 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4761 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4762 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4763 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4764 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4765 | break; |
| 4766 | } |
| 4767 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4768 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4769 | { |
| 4770 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4771 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4772 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4773 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4774 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4775 | break; |
| 4776 | } |
| 4777 | if (LocaleCompare("geometry",option+1) == 0) |
| 4778 | { |
| 4779 | if (*option == '+') |
| 4780 | break; |
| 4781 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4782 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4783 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4784 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4785 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4786 | break; |
| 4787 | } |
| 4788 | if (LocaleCompare("gravity",option+1) == 0) |
| 4789 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4790 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4791 | gravity; |
| 4792 | |
| 4793 | if (*option == '+') |
| 4794 | break; |
| 4795 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4796 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4797 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4798 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4799 | if (gravity < 0) |
| 4800 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4801 | argv[i]); |
| 4802 | break; |
| 4803 | } |
| 4804 | if (LocaleCompare("green-primary",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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4810 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4811 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4812 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4813 | break; |
| 4814 | } |
| 4815 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4816 | } |
| 4817 | case 'h': |
| 4818 | { |
| 4819 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4820 | break; |
| 4821 | if ((LocaleCompare("help",option+1) == 0) || |
| 4822 | (LocaleCompare("-help",option+1) == 0)) |
| 4823 | return(MogrifyUsage()); |
| 4824 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4825 | } |
| 4826 | case 'i': |
| 4827 | { |
| 4828 | if (LocaleCompare("identify",option+1) == 0) |
| 4829 | break; |
| 4830 | if (LocaleCompare("idft",option+1) == 0) |
| 4831 | break; |
| 4832 | if (LocaleCompare("implode",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) |
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 | if (LocaleCompare("intent",option+1) == 0) |
| 4844 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4845 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4846 | intent; |
| 4847 | |
| 4848 | if (*option == '+') |
| 4849 | break; |
| 4850 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4851 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4852 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4853 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4854 | if (intent < 0) |
| 4855 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4856 | argv[i]); |
| 4857 | break; |
| 4858 | } |
| 4859 | if (LocaleCompare("interlace",option+1) == 0) |
| 4860 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4861 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4862 | interlace; |
| 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); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4869 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4870 | argv[i]); |
| 4871 | if (interlace < 0) |
| 4872 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4873 | argv[i]); |
| 4874 | break; |
| 4875 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4876 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4877 | { |
| 4878 | if (*option == '+') |
| 4879 | break; |
| 4880 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4881 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4882 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4883 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4884 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4885 | break; |
| 4886 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4887 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4888 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4889 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4890 | interpolate; |
| 4891 | |
| 4892 | if (*option == '+') |
| 4893 | break; |
| 4894 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4895 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4896 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4897 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4898 | argv[i]); |
| 4899 | if (interpolate < 0) |
| 4900 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4901 | argv[i]); |
| 4902 | break; |
| 4903 | } |
| 4904 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4905 | { |
| 4906 | if (*option == '+') |
| 4907 | break; |
| 4908 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4909 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4910 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4911 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4912 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4913 | break; |
| 4914 | } |
| 4915 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4916 | } |
| 4917 | case 'k': |
| 4918 | { |
| 4919 | if (LocaleCompare("kerning",option+1) == 0) |
| 4920 | { |
| 4921 | if (*option == '+') |
| 4922 | break; |
| 4923 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4924 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4925 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4926 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4927 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4928 | break; |
| 4929 | } |
| 4930 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4931 | } |
| 4932 | case 'l': |
| 4933 | { |
| 4934 | if (LocaleCompare("label",option+1) == 0) |
| 4935 | { |
| 4936 | if (*option == '+') |
| 4937 | break; |
| 4938 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4939 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4940 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4941 | break; |
| 4942 | } |
| 4943 | if (LocaleCompare("lat",option+1) == 0) |
| 4944 | { |
| 4945 | if (*option == '+') |
| 4946 | break; |
| 4947 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4948 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4949 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4950 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4951 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4952 | } |
| 4953 | if (LocaleCompare("layers",option+1) == 0) |
| 4954 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4955 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4956 | type; |
| 4957 | |
| 4958 | if (*option == '+') |
| 4959 | break; |
| 4960 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4961 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4962 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4963 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4964 | if (type < 0) |
| 4965 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4966 | argv[i]); |
| 4967 | break; |
| 4968 | } |
| 4969 | if (LocaleCompare("level",option+1) == 0) |
| 4970 | { |
| 4971 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4972 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4973 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4974 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4975 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4976 | break; |
| 4977 | } |
| 4978 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4979 | { |
| 4980 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4981 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4982 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4983 | break; |
| 4984 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4985 | if (LocaleCompare("limit",option+1) == 0) |
| 4986 | { |
| 4987 | char |
| 4988 | *p; |
| 4989 | |
| 4990 | double |
| 4991 | value; |
| 4992 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4993 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4994 | resource; |
| 4995 | |
| 4996 | if (*option == '+') |
| 4997 | break; |
| 4998 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4999 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5000 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5001 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5002 | argv[i]); |
| 5003 | if (resource < 0) |
| 5004 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 5005 | argv[i]); |
| 5006 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5007 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5008 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 5009 | value=StringToDouble(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 5010 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5011 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 5012 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5013 | break; |
| 5014 | } |
| 5015 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 5016 | { |
| 5017 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5018 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5019 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5020 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5021 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5022 | break; |
| 5023 | } |
| 5024 | if (LocaleCompare("list",option+1) == 0) |
| 5025 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5026 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5027 | list; |
| 5028 | |
| 5029 | if (*option == '+') |
| 5030 | break; |
| 5031 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5032 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5033 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5034 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5035 | if (list < 0) |
| 5036 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 5037 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5038 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 5039 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5040 | } |
| 5041 | if (LocaleCompare("log",option+1) == 0) |
| 5042 | { |
| 5043 | if (*option == '+') |
| 5044 | break; |
| 5045 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5046 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5047 | (strchr(argv[i],'%') == (char *) NULL)) |
| 5048 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5049 | break; |
| 5050 | } |
| 5051 | if (LocaleCompare("loop",option+1) == 0) |
| 5052 | { |
| 5053 | if (*option == '+') |
| 5054 | break; |
| 5055 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5056 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5057 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5058 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5059 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5060 | break; |
| 5061 | } |
| 5062 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5063 | } |
| 5064 | case 'm': |
| 5065 | { |
| 5066 | if (LocaleCompare("map",option+1) == 0) |
| 5067 | { |
| 5068 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 5069 | if (*option == '+') |
| 5070 | break; |
| 5071 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5072 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5073 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5074 | break; |
| 5075 | } |
| 5076 | if (LocaleCompare("mask",option+1) == 0) |
| 5077 | { |
| 5078 | if (*option == '+') |
| 5079 | break; |
| 5080 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5081 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5082 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5083 | break; |
| 5084 | } |
| 5085 | if (LocaleCompare("matte",option+1) == 0) |
| 5086 | break; |
| 5087 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 5088 | { |
| 5089 | if (*option == '+') |
| 5090 | break; |
| 5091 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5092 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5093 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5094 | break; |
| 5095 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5096 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5097 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5098 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5099 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5100 | if (LocaleCompare("modulate",option+1) == 0) |
| 5101 | { |
| 5102 | if (*option == '+') |
| 5103 | break; |
| 5104 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5105 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5106 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5107 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5108 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5109 | break; |
| 5110 | } |
| 5111 | if (LocaleCompare("median",option+1) == 0) |
| 5112 | { |
| 5113 | if (*option == '+') |
| 5114 | break; |
| 5115 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5116 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5117 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5118 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5119 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5120 | break; |
| 5121 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5122 | if (LocaleCompare("mode",option+1) == 0) |
| 5123 | { |
| 5124 | if (*option == '+') |
| 5125 | break; |
| 5126 | i++; |
| 5127 | if (i == (ssize_t) argc) |
| 5128 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5129 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5130 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5131 | break; |
| 5132 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5133 | if (LocaleCompare("monitor",option+1) == 0) |
| 5134 | break; |
| 5135 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5136 | break; |
| 5137 | if (LocaleCompare("morph",option+1) == 0) |
| 5138 | { |
| 5139 | if (*option == '+') |
| 5140 | break; |
| 5141 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5142 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5143 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5144 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5145 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5146 | break; |
| 5147 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5148 | if (LocaleCompare("morphology",option+1) == 0) |
| 5149 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5150 | char |
| 5151 | token[MaxTextExtent]; |
| 5152 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5153 | KernelInfo |
| 5154 | *kernel_info; |
| 5155 | |
| 5156 | ssize_t |
| 5157 | op; |
| 5158 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5159 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5160 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5161 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5162 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5163 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5164 | if (op < 0) |
| 5165 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5166 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5167 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5168 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5169 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5170 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5171 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5172 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5173 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5174 | break; |
| 5175 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5176 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5177 | break; |
| 5178 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5179 | { |
| 5180 | if (*option == '+') |
| 5181 | break; |
| 5182 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5183 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5184 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5185 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5186 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5187 | break; |
| 5188 | } |
| 5189 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5190 | } |
| 5191 | case 'n': |
| 5192 | { |
| 5193 | if (LocaleCompare("negate",option+1) == 0) |
| 5194 | break; |
| 5195 | if (LocaleCompare("noise",option+1) == 0) |
| 5196 | { |
| 5197 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5198 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5199 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5200 | if (*option == '+') |
| 5201 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5202 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5203 | noise; |
| 5204 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5205 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5206 | if (noise < 0) |
| 5207 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5208 | argv[i]); |
| 5209 | break; |
| 5210 | } |
| 5211 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5212 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5213 | break; |
| 5214 | } |
| 5215 | if (LocaleCompare("noop",option+1) == 0) |
| 5216 | break; |
| 5217 | if (LocaleCompare("normalize",option+1) == 0) |
| 5218 | break; |
| 5219 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5220 | } |
| 5221 | case 'o': |
| 5222 | { |
| 5223 | if (LocaleCompare("opaque",option+1) == 0) |
| 5224 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5225 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5226 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5227 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5228 | break; |
| 5229 | } |
| 5230 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5231 | { |
| 5232 | if (*option == '+') |
| 5233 | break; |
| 5234 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5235 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5236 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5237 | break; |
| 5238 | } |
| 5239 | if (LocaleCompare("orient",option+1) == 0) |
| 5240 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5241 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5242 | orientation; |
| 5243 | |
| 5244 | orientation=UndefinedOrientation; |
| 5245 | if (*option == '+') |
| 5246 | break; |
| 5247 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5248 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5249 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5250 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5251 | argv[i]); |
| 5252 | if (orientation < 0) |
| 5253 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5254 | argv[i]); |
| 5255 | break; |
| 5256 | } |
| 5257 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5258 | } |
| 5259 | case 'p': |
| 5260 | { |
| 5261 | if (LocaleCompare("page",option+1) == 0) |
| 5262 | { |
| 5263 | if (*option == '+') |
| 5264 | break; |
| 5265 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5266 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5267 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5268 | break; |
| 5269 | } |
| 5270 | if (LocaleCompare("paint",option+1) == 0) |
| 5271 | { |
| 5272 | if (*option == '+') |
| 5273 | break; |
| 5274 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5275 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5276 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5277 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5278 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5279 | break; |
| 5280 | } |
| 5281 | if (LocaleCompare("path",option+1) == 0) |
| 5282 | { |
| 5283 | (void) CloneString(&path,(char *) NULL); |
| 5284 | if (*option == '+') |
| 5285 | break; |
| 5286 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5287 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5288 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5289 | (void) CloneString(&path,argv[i]); |
| 5290 | break; |
| 5291 | } |
| 5292 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5293 | { |
| 5294 | if (*option == '+') |
| 5295 | break; |
| 5296 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5297 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5298 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5299 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5300 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5301 | break; |
| 5302 | } |
| 5303 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5304 | { |
| 5305 | if (*option == '+') |
| 5306 | break; |
| 5307 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5308 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5309 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5310 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5311 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5312 | break; |
| 5313 | } |
| 5314 | if (LocaleCompare("posterize",option+1) == 0) |
| 5315 | { |
| 5316 | if (*option == '+') |
| 5317 | break; |
| 5318 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5319 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5320 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5321 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5322 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5323 | break; |
| 5324 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5325 | if (LocaleCompare("precision",option+1) == 0) |
| 5326 | { |
| 5327 | if (*option == '+') |
| 5328 | break; |
| 5329 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5330 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5331 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5332 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5333 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5334 | break; |
| 5335 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5336 | if (LocaleCompare("print",option+1) == 0) |
| 5337 | { |
| 5338 | if (*option == '+') |
| 5339 | break; |
| 5340 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5341 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5342 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5343 | break; |
| 5344 | } |
| 5345 | if (LocaleCompare("process",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-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5351 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5352 | break; |
| 5353 | } |
| 5354 | if (LocaleCompare("profile",option+1) == 0) |
| 5355 | { |
| 5356 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5357 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5358 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5359 | break; |
| 5360 | } |
| 5361 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5362 | } |
| 5363 | case 'q': |
| 5364 | { |
| 5365 | if (LocaleCompare("quality",option+1) == 0) |
| 5366 | { |
| 5367 | if (*option == '+') |
| 5368 | break; |
| 5369 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5370 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5371 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5372 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5373 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5374 | break; |
| 5375 | } |
| 5376 | if (LocaleCompare("quantize",option+1) == 0) |
| 5377 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5378 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5379 | colorspace; |
| 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 | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5385 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5386 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5387 | argv[i]); |
| 5388 | if (colorspace < 0) |
| 5389 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5390 | argv[i]); |
| 5391 | break; |
| 5392 | } |
| 5393 | if (LocaleCompare("quiet",option+1) == 0) |
| 5394 | break; |
| 5395 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5396 | } |
| 5397 | case 'r': |
| 5398 | { |
| 5399 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5400 | { |
| 5401 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5402 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5403 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5404 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5405 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5406 | break; |
| 5407 | } |
| 5408 | if (LocaleCompare("raise",option+1) == 0) |
| 5409 | { |
| 5410 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5411 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5412 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5413 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5414 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5415 | break; |
| 5416 | } |
| 5417 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5418 | { |
| 5419 | if (*option == '+') |
| 5420 | break; |
| 5421 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5422 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5423 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5424 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5425 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5426 | break; |
| 5427 | } |
| 5428 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5429 | { |
| 5430 | if (*option == '+') |
| 5431 | break; |
| 5432 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5433 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5434 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5435 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5436 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5437 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5438 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5439 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5440 | if (LocaleCompare("region",option+1) == 0) |
| 5441 | { |
| 5442 | if (*option == '+') |
| 5443 | break; |
| 5444 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5445 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5446 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5447 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5448 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5449 | break; |
| 5450 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5451 | if (LocaleCompare("remap",option+1) == 0) |
| 5452 | { |
| 5453 | if (*option == '+') |
| 5454 | break; |
| 5455 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5456 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5457 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5458 | break; |
| 5459 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5460 | if (LocaleCompare("render",option+1) == 0) |
| 5461 | break; |
| 5462 | if (LocaleCompare("repage",option+1) == 0) |
| 5463 | { |
| 5464 | if (*option == '+') |
| 5465 | break; |
| 5466 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5467 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5468 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5469 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5470 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5471 | break; |
| 5472 | } |
| 5473 | if (LocaleCompare("resample",option+1) == 0) |
| 5474 | { |
| 5475 | if (*option == '+') |
| 5476 | break; |
| 5477 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5478 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5479 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5480 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5481 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5482 | break; |
| 5483 | } |
| 5484 | if (LocaleCompare("resize",option+1) == 0) |
| 5485 | { |
| 5486 | if (*option == '+') |
| 5487 | break; |
| 5488 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5489 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5490 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5491 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5492 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5493 | break; |
| 5494 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5495 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5496 | { |
| 5497 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5498 | break; |
| 5499 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5500 | if (LocaleCompare("reverse",option+1) == 0) |
| 5501 | break; |
| 5502 | if (LocaleCompare("roll",option+1) == 0) |
| 5503 | { |
| 5504 | if (*option == '+') |
| 5505 | break; |
| 5506 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5507 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5508 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5509 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5510 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5511 | break; |
| 5512 | } |
| 5513 | if (LocaleCompare("rotate",option+1) == 0) |
| 5514 | { |
| 5515 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5516 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5517 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5518 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5519 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5520 | break; |
| 5521 | } |
| 5522 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5523 | } |
| 5524 | case 's': |
| 5525 | { |
| 5526 | if (LocaleCompare("sample",option+1) == 0) |
| 5527 | { |
| 5528 | if (*option == '+') |
| 5529 | break; |
| 5530 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5531 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5532 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5533 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5534 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5535 | break; |
| 5536 | } |
| 5537 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5538 | { |
| 5539 | if (*option == '+') |
| 5540 | break; |
| 5541 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5542 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5543 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5544 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5545 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5546 | break; |
| 5547 | } |
| 5548 | if (LocaleCompare("scale",option+1) == 0) |
| 5549 | { |
| 5550 | if (*option == '+') |
| 5551 | break; |
| 5552 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5553 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5554 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5555 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5556 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5557 | break; |
| 5558 | } |
| 5559 | if (LocaleCompare("scene",option+1) == 0) |
| 5560 | { |
| 5561 | if (*option == '+') |
| 5562 | break; |
| 5563 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5564 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5565 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5566 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5567 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5568 | break; |
| 5569 | } |
| 5570 | if (LocaleCompare("seed",option+1) == 0) |
| 5571 | { |
| 5572 | if (*option == '+') |
| 5573 | break; |
| 5574 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5575 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5576 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5577 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5578 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5579 | break; |
| 5580 | } |
| 5581 | if (LocaleCompare("segment",option+1) == 0) |
| 5582 | { |
| 5583 | if (*option == '+') |
| 5584 | break; |
| 5585 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5586 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5587 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5588 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5589 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5590 | break; |
| 5591 | } |
| 5592 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5593 | { |
| 5594 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5595 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5596 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5597 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5598 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5599 | break; |
| 5600 | } |
| 5601 | if (LocaleCompare("separate",option+1) == 0) |
| 5602 | break; |
| 5603 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5604 | { |
| 5605 | if (*option == '+') |
| 5606 | break; |
| 5607 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5608 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5609 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5610 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5611 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5612 | break; |
| 5613 | } |
| 5614 | if (LocaleCompare("set",option+1) == 0) |
| 5615 | { |
| 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 (*option == '+') |
| 5620 | break; |
| 5621 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5622 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5623 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5624 | break; |
| 5625 | } |
| 5626 | if (LocaleCompare("shade",option+1) == 0) |
| 5627 | { |
| 5628 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5629 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5630 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5631 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5632 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5633 | break; |
| 5634 | } |
| 5635 | if (LocaleCompare("shadow",option+1) == 0) |
| 5636 | { |
| 5637 | if (*option == '+') |
| 5638 | break; |
| 5639 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5640 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5641 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5642 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5643 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5644 | break; |
| 5645 | } |
| 5646 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5647 | { |
| 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("shave",option+1) == 0) |
| 5656 | { |
| 5657 | if (*option == '+') |
| 5658 | break; |
| 5659 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5660 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5661 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5662 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5663 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5664 | break; |
| 5665 | } |
| 5666 | if (LocaleCompare("shear",option+1) == 0) |
| 5667 | { |
| 5668 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5669 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5670 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5671 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5672 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5673 | break; |
| 5674 | } |
| 5675 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5676 | { |
| 5677 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5678 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5679 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5680 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5681 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5682 | break; |
| 5683 | } |
| 5684 | if (LocaleCompare("size",option+1) == 0) |
| 5685 | { |
| 5686 | if (*option == '+') |
| 5687 | break; |
| 5688 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5689 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5690 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5691 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5692 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5693 | break; |
| 5694 | } |
| 5695 | if (LocaleCompare("sketch",option+1) == 0) |
| 5696 | { |
| 5697 | if (*option == '+') |
| 5698 | break; |
| 5699 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5700 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5701 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5702 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5703 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5704 | break; |
| 5705 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5706 | if (LocaleCompare("smush",option+1) == 0) |
| 5707 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5708 | i++; |
| 5709 | if (i == (ssize_t) argc) |
| 5710 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5711 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5712 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5713 | i++; |
| 5714 | break; |
| 5715 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5716 | if (LocaleCompare("solarize",option+1) == 0) |
| 5717 | { |
| 5718 | if (*option == '+') |
| 5719 | break; |
| 5720 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5721 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5722 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5723 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5724 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5725 | break; |
| 5726 | } |
| 5727 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5728 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5729 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5730 | op; |
| 5731 | |
| 5732 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5733 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5734 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5735 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5736 | if (op < 0) |
| 5737 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5738 | argv[i]); |
| 5739 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5740 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5741 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5742 | break; |
| 5743 | } |
| 5744 | if (LocaleCompare("spread",option+1) == 0) |
| 5745 | { |
| 5746 | if (*option == '+') |
| 5747 | break; |
| 5748 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5749 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5750 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5751 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5752 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5753 | break; |
| 5754 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5755 | if (LocaleCompare("statistic",option+1) == 0) |
| 5756 | { |
| 5757 | ssize_t |
| 5758 | op; |
| 5759 | |
| 5760 | if (*option == '+') |
| 5761 | break; |
| 5762 | i++; |
| 5763 | if (i == (ssize_t) argc) |
| 5764 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5765 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5766 | if (op < 0) |
| 5767 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5768 | argv[i]); |
| 5769 | i++; |
| 5770 | if (i == (ssize_t) (argc-1)) |
| 5771 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5772 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5773 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5774 | break; |
| 5775 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5776 | if (LocaleCompare("stretch",option+1) == 0) |
| 5777 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5778 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5779 | stretch; |
| 5780 | |
| 5781 | if (*option == '+') |
| 5782 | break; |
| 5783 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5784 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5785 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5786 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5787 | if (stretch < 0) |
| 5788 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5789 | argv[i]); |
| 5790 | break; |
| 5791 | } |
| 5792 | if (LocaleCompare("strip",option+1) == 0) |
| 5793 | break; |
| 5794 | if (LocaleCompare("stroke",option+1) == 0) |
| 5795 | { |
| 5796 | if (*option == '+') |
| 5797 | break; |
| 5798 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5799 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5800 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5801 | break; |
| 5802 | } |
| 5803 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5804 | { |
| 5805 | if (*option == '+') |
| 5806 | break; |
| 5807 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5808 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5809 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5810 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5811 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5812 | break; |
| 5813 | } |
| 5814 | if (LocaleCompare("style",option+1) == 0) |
| 5815 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5816 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5817 | style; |
| 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); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5824 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5825 | if (style < 0) |
| 5826 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5827 | argv[i]); |
| 5828 | break; |
| 5829 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5830 | if (LocaleCompare("swap",option+1) == 0) |
| 5831 | { |
| 5832 | if (*option == '+') |
| 5833 | break; |
| 5834 | i++; |
| 5835 | if (i == (ssize_t) (argc-1)) |
| 5836 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5837 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5838 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5839 | break; |
| 5840 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5841 | if (LocaleCompare("swirl",option+1) == 0) |
| 5842 | { |
| 5843 | if (*option == '+') |
| 5844 | break; |
| 5845 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5846 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5847 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5848 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5849 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5850 | break; |
| 5851 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5852 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5853 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5854 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5855 | } |
| 5856 | case 't': |
| 5857 | { |
| 5858 | if (LocaleCompare("taint",option+1) == 0) |
| 5859 | break; |
| 5860 | if (LocaleCompare("texture",option+1) == 0) |
| 5861 | { |
| 5862 | if (*option == '+') |
| 5863 | break; |
| 5864 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5865 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5866 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5867 | break; |
| 5868 | } |
| 5869 | if (LocaleCompare("tile",option+1) == 0) |
| 5870 | { |
| 5871 | if (*option == '+') |
| 5872 | break; |
| 5873 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5874 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5875 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5876 | break; |
| 5877 | } |
| 5878 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5879 | { |
| 5880 | if (*option == '+') |
| 5881 | break; |
| 5882 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5883 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5884 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5885 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5886 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5887 | break; |
| 5888 | } |
| 5889 | if (LocaleCompare("tint",option+1) == 0) |
| 5890 | { |
| 5891 | if (*option == '+') |
| 5892 | break; |
| 5893 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5894 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5895 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5896 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5897 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5898 | break; |
| 5899 | } |
| 5900 | if (LocaleCompare("transform",option+1) == 0) |
| 5901 | break; |
| 5902 | if (LocaleCompare("transpose",option+1) == 0) |
| 5903 | break; |
| 5904 | if (LocaleCompare("transverse",option+1) == 0) |
| 5905 | break; |
| 5906 | if (LocaleCompare("threshold",option+1) == 0) |
| 5907 | { |
| 5908 | if (*option == '+') |
| 5909 | break; |
| 5910 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5911 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5912 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5913 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5914 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5915 | break; |
| 5916 | } |
| 5917 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5918 | { |
| 5919 | if (*option == '+') |
| 5920 | break; |
| 5921 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5922 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5923 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5924 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5925 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5926 | break; |
| 5927 | } |
| 5928 | if (LocaleCompare("transparent",option+1) == 0) |
| 5929 | { |
| 5930 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5931 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5932 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5933 | break; |
| 5934 | } |
| 5935 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 5936 | { |
| 5937 | if (*option == '+') |
| 5938 | break; |
| 5939 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5940 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5941 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5942 | break; |
| 5943 | } |
| 5944 | if (LocaleCompare("treedepth",option+1) == 0) |
| 5945 | { |
| 5946 | if (*option == '+') |
| 5947 | break; |
| 5948 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5949 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5950 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5951 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5952 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5953 | break; |
| 5954 | } |
| 5955 | if (LocaleCompare("trim",option+1) == 0) |
| 5956 | break; |
| 5957 | if (LocaleCompare("type",option+1) == 0) |
| 5958 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5959 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5960 | type; |
| 5961 | |
| 5962 | if (*option == '+') |
| 5963 | break; |
| 5964 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5965 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5966 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5967 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5968 | if (type < 0) |
| 5969 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5970 | argv[i]); |
| 5971 | break; |
| 5972 | } |
| 5973 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5974 | } |
| 5975 | case 'u': |
| 5976 | { |
| 5977 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5978 | { |
| 5979 | if (*option == '+') |
| 5980 | break; |
| 5981 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5982 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5983 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5984 | break; |
| 5985 | } |
| 5986 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5987 | break; |
| 5988 | if (LocaleCompare("units",option+1) == 0) |
| 5989 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5990 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5991 | units; |
| 5992 | |
| 5993 | if (*option == '+') |
| 5994 | break; |
| 5995 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5996 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5997 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5998 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5999 | argv[i]); |
| 6000 | if (units < 0) |
| 6001 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 6002 | argv[i]); |
| 6003 | break; |
| 6004 | } |
| 6005 | if (LocaleCompare("unsharp",option+1) == 0) |
| 6006 | { |
| 6007 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6008 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6009 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6010 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6011 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6012 | break; |
| 6013 | } |
| 6014 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6015 | } |
| 6016 | case 'v': |
| 6017 | { |
| 6018 | if (LocaleCompare("verbose",option+1) == 0) |
| 6019 | { |
| 6020 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 6021 | break; |
| 6022 | } |
| 6023 | if ((LocaleCompare("version",option+1) == 0) || |
| 6024 | (LocaleCompare("-version",option+1) == 0)) |
| 6025 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6026 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6027 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 6028 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 6029 | GetMagickCopyright()); |
| 6030 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 6031 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6032 | break; |
| 6033 | } |
| 6034 | if (LocaleCompare("view",option+1) == 0) |
| 6035 | { |
| 6036 | if (*option == '+') |
| 6037 | break; |
| 6038 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6039 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6040 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6041 | break; |
| 6042 | } |
| 6043 | if (LocaleCompare("vignette",option+1) == 0) |
| 6044 | { |
| 6045 | if (*option == '+') |
| 6046 | break; |
| 6047 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6048 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6049 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6050 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6051 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6052 | break; |
| 6053 | } |
| 6054 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 6055 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6056 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6057 | method; |
| 6058 | |
| 6059 | if (*option == '+') |
| 6060 | break; |
| 6061 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6062 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6063 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6064 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6065 | argv[i]); |
| 6066 | if (method < 0) |
| 6067 | ThrowMogrifyException(OptionError, |
| 6068 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 6069 | break; |
| 6070 | } |
| 6071 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6072 | } |
| 6073 | case 'w': |
| 6074 | { |
| 6075 | if (LocaleCompare("wave",option+1) == 0) |
| 6076 | { |
| 6077 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6078 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6079 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6080 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6081 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6082 | break; |
| 6083 | } |
| 6084 | if (LocaleCompare("weight",option+1) == 0) |
| 6085 | { |
| 6086 | if (*option == '+') |
| 6087 | break; |
| 6088 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6089 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6090 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6091 | break; |
| 6092 | } |
| 6093 | if (LocaleCompare("white-point",option+1) == 0) |
| 6094 | { |
| 6095 | if (*option == '+') |
| 6096 | break; |
| 6097 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6098 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6099 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6100 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6101 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6102 | break; |
| 6103 | } |
| 6104 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6105 | { |
| 6106 | if (*option == '+') |
| 6107 | break; |
| 6108 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6109 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6110 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6111 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6112 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6113 | break; |
| 6114 | } |
| 6115 | if (LocaleCompare("write",option+1) == 0) |
| 6116 | { |
| 6117 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6118 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6119 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6120 | break; |
| 6121 | } |
| 6122 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6123 | } |
| 6124 | case '?': |
| 6125 | break; |
| 6126 | default: |
| 6127 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6128 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6129 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 6130 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6131 | if (fire != MagickFalse) |
| 6132 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6133 | } |
| 6134 | if (k != 0) |
| 6135 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6136 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6137 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6138 | DestroyMogrify(); |
| 6139 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6140 | } |
| 6141 | |
| 6142 | /* |
| 6143 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6144 | % % |
| 6145 | % % |
| 6146 | % % |
| 6147 | + M o g r i f y I m a g e I n f o % |
| 6148 | % % |
| 6149 | % % |
| 6150 | % % |
| 6151 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6152 | % |
| 6153 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6154 | % prescribed by command line options. |
| 6155 | % |
| 6156 | % The format of the MogrifyImageInfo method is: |
| 6157 | % |
| 6158 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6159 | % const char **argv,ExceptionInfo *exception) |
| 6160 | % |
| 6161 | % A description of each parameter follows: |
| 6162 | % |
| 6163 | % o image_info: the image info.. |
| 6164 | % |
| 6165 | % o argc: Specifies a pointer to an integer describing the number of |
| 6166 | % elements in the argument vector. |
| 6167 | % |
| 6168 | % o argv: Specifies a pointer to a text array containing the command line |
| 6169 | % arguments. |
| 6170 | % |
| 6171 | % o exception: return any errors or warnings in this structure. |
| 6172 | % |
| 6173 | */ |
| 6174 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6175 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6176 | { |
| 6177 | const char |
| 6178 | *option; |
| 6179 | |
| 6180 | GeometryInfo |
| 6181 | geometry_info; |
| 6182 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6183 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6184 | count; |
| 6185 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6186 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6187 | i; |
| 6188 | |
| 6189 | /* |
| 6190 | Initialize method variables. |
| 6191 | */ |
| 6192 | assert(image_info != (ImageInfo *) NULL); |
| 6193 | assert(image_info->signature == MagickSignature); |
| 6194 | if (image_info->debug != MagickFalse) |
| 6195 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6196 | image_info->filename); |
| 6197 | if (argc < 0) |
| 6198 | return(MagickTrue); |
| 6199 | /* |
| 6200 | Set the image settings. |
| 6201 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6202 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6203 | { |
| 6204 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6205 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6206 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6207 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6208 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6209 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6210 | break; |
| 6211 | switch (*(option+1)) |
| 6212 | { |
| 6213 | case 'a': |
| 6214 | { |
| 6215 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6216 | { |
| 6217 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6218 | break; |
| 6219 | } |
| 6220 | if (LocaleCompare("antialias",option+1) == 0) |
| 6221 | { |
| 6222 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6223 | break; |
| 6224 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6225 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6226 | { |
| 6227 | if (*option == '+') |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 6228 | (void) DeleteImageOption(image_info,option+1); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6229 | else |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 6230 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6231 | break; |
| 6232 | } |
| 6233 | break; |
| 6234 | } |
| 6235 | case 'b': |
| 6236 | { |
| 6237 | if (LocaleCompare("background",option+1) == 0) |
| 6238 | { |
| 6239 | if (*option == '+') |
| 6240 | { |
| 6241 | (void) DeleteImageOption(image_info,option+1); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6242 | (void) QueryColorCompliance(MogrifyBackgroundColor, |
| 6243 | AllCompliance,&image_info->background_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6244 | break; |
| 6245 | } |
| 6246 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6247 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6248 | &image_info->background_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6249 | break; |
| 6250 | } |
| 6251 | if (LocaleCompare("bias",option+1) == 0) |
| 6252 | { |
| 6253 | if (*option == '+') |
| 6254 | { |
| 6255 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6256 | break; |
| 6257 | } |
| 6258 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6259 | break; |
| 6260 | } |
| 6261 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6262 | { |
| 6263 | if (*option == '+') |
| 6264 | { |
| 6265 | (void) SetImageOption(image_info,option+1,"false"); |
| 6266 | break; |
| 6267 | } |
| 6268 | (void) SetImageOption(image_info,option+1,"true"); |
| 6269 | break; |
| 6270 | } |
| 6271 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6272 | { |
| 6273 | if (*option == '+') |
| 6274 | { |
| 6275 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6276 | break; |
| 6277 | } |
| 6278 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6279 | break; |
| 6280 | } |
| 6281 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6282 | { |
| 6283 | if (*option == '+') |
| 6284 | { |
| 6285 | (void) DeleteImageOption(image_info,option+1); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6286 | (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6287 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6288 | break; |
| 6289 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6290 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6291 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6292 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6293 | break; |
| 6294 | } |
| 6295 | if (LocaleCompare("box",option+1) == 0) |
| 6296 | { |
| 6297 | if (*option == '+') |
| 6298 | { |
| 6299 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6300 | break; |
| 6301 | } |
| 6302 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6303 | break; |
| 6304 | } |
| 6305 | break; |
| 6306 | } |
| 6307 | case 'c': |
| 6308 | { |
| 6309 | if (LocaleCompare("cache",option+1) == 0) |
| 6310 | { |
| 6311 | MagickSizeType |
| 6312 | limit; |
| 6313 | |
| 6314 | limit=MagickResourceInfinity; |
| 6315 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 6316 | limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1], |
| 6317 | 100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6318 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6319 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6320 | break; |
| 6321 | } |
| 6322 | if (LocaleCompare("caption",option+1) == 0) |
| 6323 | { |
| 6324 | if (*option == '+') |
| 6325 | { |
| 6326 | (void) DeleteImageOption(image_info,option+1); |
| 6327 | break; |
| 6328 | } |
| 6329 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6330 | break; |
| 6331 | } |
| 6332 | if (LocaleCompare("channel",option+1) == 0) |
| 6333 | { |
| 6334 | if (*option == '+') |
| 6335 | { |
| 6336 | image_info->channel=DefaultChannels; |
| 6337 | break; |
| 6338 | } |
| 6339 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6340 | break; |
| 6341 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6342 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6343 | { |
| 6344 | if (*option == '+') |
| 6345 | { |
| 6346 | image_info->colorspace=UndefinedColorspace; |
| 6347 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6348 | break; |
| 6349 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6350 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6351 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6352 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6353 | break; |
| 6354 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6355 | if (LocaleCompare("comment",option+1) == 0) |
| 6356 | { |
| 6357 | if (*option == '+') |
| 6358 | { |
| 6359 | (void) DeleteImageOption(image_info,option+1); |
| 6360 | break; |
| 6361 | } |
| 6362 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6363 | break; |
| 6364 | } |
| 6365 | if (LocaleCompare("compose",option+1) == 0) |
| 6366 | { |
| 6367 | if (*option == '+') |
| 6368 | { |
| 6369 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6370 | break; |
| 6371 | } |
| 6372 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6373 | break; |
| 6374 | } |
| 6375 | if (LocaleCompare("compress",option+1) == 0) |
| 6376 | { |
| 6377 | if (*option == '+') |
| 6378 | { |
| 6379 | image_info->compression=UndefinedCompression; |
| 6380 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6381 | break; |
| 6382 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6383 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6384 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6385 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6386 | break; |
| 6387 | } |
| 6388 | break; |
| 6389 | } |
| 6390 | case 'd': |
| 6391 | { |
| 6392 | if (LocaleCompare("debug",option+1) == 0) |
| 6393 | { |
| 6394 | if (*option == '+') |
| 6395 | (void) SetLogEventMask("none"); |
| 6396 | else |
| 6397 | (void) SetLogEventMask(argv[i+1]); |
| 6398 | image_info->debug=IsEventLogging(); |
| 6399 | break; |
| 6400 | } |
| 6401 | if (LocaleCompare("define",option+1) == 0) |
| 6402 | { |
| 6403 | if (*option == '+') |
| 6404 | { |
| 6405 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6406 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6407 | else |
| 6408 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6409 | break; |
| 6410 | } |
| 6411 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6412 | { |
| 6413 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6414 | exception); |
| 6415 | break; |
| 6416 | } |
| 6417 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6418 | break; |
| 6419 | } |
| 6420 | if (LocaleCompare("delay",option+1) == 0) |
| 6421 | { |
| 6422 | if (*option == '+') |
| 6423 | { |
| 6424 | (void) SetImageOption(image_info,option+1,"0"); |
| 6425 | break; |
| 6426 | } |
| 6427 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6428 | break; |
| 6429 | } |
| 6430 | if (LocaleCompare("density",option+1) == 0) |
| 6431 | { |
| 6432 | /* |
| 6433 | Set image density. |
| 6434 | */ |
| 6435 | if (*option == '+') |
| 6436 | { |
| 6437 | if (image_info->density != (char *) NULL) |
| 6438 | image_info->density=DestroyString(image_info->density); |
| 6439 | (void) SetImageOption(image_info,option+1,"72"); |
| 6440 | break; |
| 6441 | } |
| 6442 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6443 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6444 | break; |
| 6445 | } |
| 6446 | if (LocaleCompare("depth",option+1) == 0) |
| 6447 | { |
| 6448 | if (*option == '+') |
| 6449 | { |
| 6450 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6451 | break; |
| 6452 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6453 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6454 | break; |
| 6455 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6456 | if (LocaleCompare("direction",option+1) == 0) |
| 6457 | { |
| 6458 | if (*option == '+') |
| 6459 | { |
| 6460 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6461 | break; |
| 6462 | } |
| 6463 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6464 | break; |
| 6465 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6466 | if (LocaleCompare("display",option+1) == 0) |
| 6467 | { |
| 6468 | if (*option == '+') |
| 6469 | { |
| 6470 | if (image_info->server_name != (char *) NULL) |
| 6471 | image_info->server_name=DestroyString( |
| 6472 | image_info->server_name); |
| 6473 | break; |
| 6474 | } |
| 6475 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6476 | break; |
| 6477 | } |
| 6478 | if (LocaleCompare("dispose",option+1) == 0) |
| 6479 | { |
| 6480 | if (*option == '+') |
| 6481 | { |
| 6482 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6483 | break; |
| 6484 | } |
| 6485 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6486 | break; |
| 6487 | } |
| 6488 | if (LocaleCompare("dither",option+1) == 0) |
| 6489 | { |
| 6490 | if (*option == '+') |
| 6491 | { |
| 6492 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6493 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6494 | break; |
| 6495 | } |
| 6496 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6497 | image_info->dither=MagickTrue; |
| 6498 | break; |
| 6499 | } |
| 6500 | break; |
| 6501 | } |
| 6502 | case 'e': |
| 6503 | { |
| 6504 | if (LocaleCompare("encoding",option+1) == 0) |
| 6505 | { |
| 6506 | if (*option == '+') |
| 6507 | { |
| 6508 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6509 | break; |
| 6510 | } |
| 6511 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6512 | break; |
| 6513 | } |
| 6514 | if (LocaleCompare("endian",option+1) == 0) |
| 6515 | { |
| 6516 | if (*option == '+') |
| 6517 | { |
| 6518 | image_info->endian=UndefinedEndian; |
| 6519 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6520 | break; |
| 6521 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6522 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6523 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6524 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6525 | break; |
| 6526 | } |
| 6527 | if (LocaleCompare("extract",option+1) == 0) |
| 6528 | { |
| 6529 | /* |
| 6530 | Set image extract geometry. |
| 6531 | */ |
| 6532 | if (*option == '+') |
| 6533 | { |
| 6534 | if (image_info->extract != (char *) NULL) |
| 6535 | image_info->extract=DestroyString(image_info->extract); |
| 6536 | break; |
| 6537 | } |
| 6538 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6539 | break; |
| 6540 | } |
| 6541 | break; |
| 6542 | } |
| 6543 | case 'f': |
| 6544 | { |
| 6545 | if (LocaleCompare("fill",option+1) == 0) |
| 6546 | { |
| 6547 | if (*option == '+') |
| 6548 | { |
| 6549 | (void) SetImageOption(image_info,option+1,"none"); |
| 6550 | break; |
| 6551 | } |
| 6552 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6553 | break; |
| 6554 | } |
| 6555 | if (LocaleCompare("filter",option+1) == 0) |
| 6556 | { |
| 6557 | if (*option == '+') |
| 6558 | { |
| 6559 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6560 | break; |
| 6561 | } |
| 6562 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6563 | break; |
| 6564 | } |
| 6565 | if (LocaleCompare("font",option+1) == 0) |
| 6566 | { |
| 6567 | if (*option == '+') |
| 6568 | { |
| 6569 | if (image_info->font != (char *) NULL) |
| 6570 | image_info->font=DestroyString(image_info->font); |
| 6571 | break; |
| 6572 | } |
| 6573 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6574 | break; |
| 6575 | } |
| 6576 | if (LocaleCompare("format",option+1) == 0) |
| 6577 | { |
| 6578 | register const char |
| 6579 | *q; |
| 6580 | |
| 6581 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6582 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6583 | image_info->ping=MagickFalse; |
| 6584 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6585 | break; |
| 6586 | } |
| 6587 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6588 | { |
| 6589 | if (*option == '+') |
| 6590 | { |
| 6591 | image_info->fuzz=0.0; |
| 6592 | (void) SetImageOption(image_info,option+1,"0"); |
| 6593 | break; |
| 6594 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 6595 | image_info->fuzz=StringToDoubleInterval(argv[i+1],(double) |
| 6596 | QuantumRange+1.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6597 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6598 | break; |
| 6599 | } |
| 6600 | break; |
| 6601 | } |
| 6602 | case 'g': |
| 6603 | { |
| 6604 | if (LocaleCompare("gravity",option+1) == 0) |
| 6605 | { |
| 6606 | if (*option == '+') |
| 6607 | { |
| 6608 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6609 | break; |
| 6610 | } |
| 6611 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6612 | break; |
| 6613 | } |
| 6614 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6615 | { |
| 6616 | if (*option == '+') |
| 6617 | { |
| 6618 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6619 | break; |
| 6620 | } |
| 6621 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6622 | break; |
| 6623 | } |
| 6624 | break; |
| 6625 | } |
| 6626 | case 'i': |
| 6627 | { |
| 6628 | if (LocaleCompare("intent",option+1) == 0) |
| 6629 | { |
| 6630 | if (*option == '+') |
| 6631 | { |
| 6632 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6633 | break; |
| 6634 | } |
| 6635 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6636 | break; |
| 6637 | } |
| 6638 | if (LocaleCompare("interlace",option+1) == 0) |
| 6639 | { |
| 6640 | if (*option == '+') |
| 6641 | { |
| 6642 | image_info->interlace=UndefinedInterlace; |
| 6643 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6644 | break; |
| 6645 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6646 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6647 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6648 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6649 | break; |
| 6650 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6651 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6652 | { |
| 6653 | if (*option == '+') |
| 6654 | { |
| 6655 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6656 | break; |
| 6657 | } |
| 6658 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6659 | break; |
| 6660 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6661 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6662 | { |
| 6663 | if (*option == '+') |
| 6664 | { |
| 6665 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6666 | break; |
| 6667 | } |
| 6668 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6669 | break; |
| 6670 | } |
| 6671 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6672 | { |
| 6673 | if (*option == '+') |
| 6674 | { |
| 6675 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6676 | break; |
| 6677 | } |
| 6678 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6679 | break; |
| 6680 | } |
| 6681 | break; |
| 6682 | } |
| 6683 | case 'k': |
| 6684 | { |
| 6685 | if (LocaleCompare("kerning",option+1) == 0) |
| 6686 | { |
| 6687 | if (*option == '+') |
| 6688 | { |
| 6689 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6690 | break; |
| 6691 | } |
| 6692 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6693 | break; |
| 6694 | } |
| 6695 | break; |
| 6696 | } |
| 6697 | case 'l': |
| 6698 | { |
| 6699 | if (LocaleCompare("label",option+1) == 0) |
| 6700 | { |
| 6701 | if (*option == '+') |
| 6702 | { |
| 6703 | (void) DeleteImageOption(image_info,option+1); |
| 6704 | break; |
| 6705 | } |
| 6706 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6707 | break; |
| 6708 | } |
| 6709 | if (LocaleCompare("limit",option+1) == 0) |
| 6710 | { |
| 6711 | MagickSizeType |
| 6712 | limit; |
| 6713 | |
| 6714 | ResourceType |
| 6715 | type; |
| 6716 | |
| 6717 | if (*option == '+') |
| 6718 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6719 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6720 | MagickFalse,argv[i+1]); |
| 6721 | limit=MagickResourceInfinity; |
| 6722 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | c062734 | 2011-11-18 21:15:24 +0000 | [diff] [blame] | 6723 | limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6724 | (void) SetMagickResourceLimit(type,limit); |
| 6725 | break; |
| 6726 | } |
| 6727 | if (LocaleCompare("list",option+1) == 0) |
| 6728 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6729 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6730 | list; |
| 6731 | |
| 6732 | /* |
| 6733 | Display configuration list. |
| 6734 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6735 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6736 | switch (list) |
| 6737 | { |
| 6738 | case MagickCoderOptions: |
| 6739 | { |
| 6740 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6741 | break; |
| 6742 | } |
| 6743 | case MagickColorOptions: |
| 6744 | { |
| 6745 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6746 | break; |
| 6747 | } |
| 6748 | case MagickConfigureOptions: |
| 6749 | { |
| 6750 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6751 | break; |
| 6752 | } |
| 6753 | case MagickDelegateOptions: |
| 6754 | { |
| 6755 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6756 | break; |
| 6757 | } |
| 6758 | case MagickFontOptions: |
| 6759 | { |
| 6760 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6761 | break; |
| 6762 | } |
| 6763 | case MagickFormatOptions: |
| 6764 | { |
| 6765 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6766 | break; |
| 6767 | } |
| 6768 | case MagickLocaleOptions: |
| 6769 | { |
| 6770 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6771 | break; |
| 6772 | } |
| 6773 | case MagickLogOptions: |
| 6774 | { |
| 6775 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6776 | break; |
| 6777 | } |
| 6778 | case MagickMagicOptions: |
| 6779 | { |
| 6780 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6781 | break; |
| 6782 | } |
| 6783 | case MagickMimeOptions: |
| 6784 | { |
| 6785 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6786 | break; |
| 6787 | } |
| 6788 | case MagickModuleOptions: |
| 6789 | { |
| 6790 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6791 | break; |
| 6792 | } |
| 6793 | case MagickPolicyOptions: |
| 6794 | { |
| 6795 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6796 | break; |
| 6797 | } |
| 6798 | case MagickResourceOptions: |
| 6799 | { |
| 6800 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6801 | break; |
| 6802 | } |
| 6803 | case MagickThresholdOptions: |
| 6804 | { |
| 6805 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6806 | break; |
| 6807 | } |
| 6808 | default: |
| 6809 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6810 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6811 | exception); |
| 6812 | break; |
| 6813 | } |
| 6814 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6815 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6816 | } |
| 6817 | if (LocaleCompare("log",option+1) == 0) |
| 6818 | { |
| 6819 | if (*option == '+') |
| 6820 | break; |
| 6821 | (void) SetLogFormat(argv[i+1]); |
| 6822 | break; |
| 6823 | } |
| 6824 | if (LocaleCompare("loop",option+1) == 0) |
| 6825 | { |
| 6826 | if (*option == '+') |
| 6827 | { |
| 6828 | (void) SetImageOption(image_info,option+1,"0"); |
| 6829 | break; |
| 6830 | } |
| 6831 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6832 | break; |
| 6833 | } |
| 6834 | break; |
| 6835 | } |
| 6836 | case 'm': |
| 6837 | { |
| 6838 | if (LocaleCompare("matte",option+1) == 0) |
| 6839 | { |
| 6840 | if (*option == '+') |
| 6841 | { |
| 6842 | (void) SetImageOption(image_info,option+1,"false"); |
| 6843 | break; |
| 6844 | } |
| 6845 | (void) SetImageOption(image_info,option+1,"true"); |
| 6846 | break; |
| 6847 | } |
| 6848 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6849 | { |
| 6850 | if (*option == '+') |
| 6851 | { |
| 6852 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6853 | (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance, |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6854 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6855 | break; |
| 6856 | } |
| 6857 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6858 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6859 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6860 | break; |
| 6861 | } |
| 6862 | if (LocaleCompare("monitor",option+1) == 0) |
| 6863 | { |
| 6864 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6865 | (void *) NULL); |
| 6866 | break; |
| 6867 | } |
| 6868 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6869 | { |
| 6870 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6871 | break; |
| 6872 | } |
| 6873 | break; |
| 6874 | } |
| 6875 | case 'o': |
| 6876 | { |
| 6877 | if (LocaleCompare("orient",option+1) == 0) |
| 6878 | { |
| 6879 | if (*option == '+') |
| 6880 | { |
| 6881 | image_info->orientation=UndefinedOrientation; |
| 6882 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6883 | break; |
| 6884 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6885 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6886 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6887 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6888 | break; |
| 6889 | } |
| 6890 | } |
| 6891 | case 'p': |
| 6892 | { |
| 6893 | if (LocaleCompare("page",option+1) == 0) |
| 6894 | { |
| 6895 | char |
| 6896 | *canonical_page, |
| 6897 | page[MaxTextExtent]; |
| 6898 | |
| 6899 | const char |
| 6900 | *image_option; |
| 6901 | |
| 6902 | MagickStatusType |
| 6903 | flags; |
| 6904 | |
| 6905 | RectangleInfo |
| 6906 | geometry; |
| 6907 | |
| 6908 | if (*option == '+') |
| 6909 | { |
| 6910 | (void) DeleteImageOption(image_info,option+1); |
| 6911 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6912 | break; |
| 6913 | } |
| 6914 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6915 | image_option=GetImageOption(image_info,"page"); |
| 6916 | if (image_option != (const char *) NULL) |
| 6917 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6918 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6919 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6920 | canonical_page=DestroyString(canonical_page); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6921 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6922 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6923 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6924 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6925 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6926 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6927 | (void) SetImageOption(image_info,option+1,page); |
| 6928 | (void) CloneString(&image_info->page,page); |
| 6929 | break; |
| 6930 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6931 | if (LocaleCompare("ping",option+1) == 0) |
| 6932 | { |
| 6933 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6934 | break; |
| 6935 | } |
| 6936 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6937 | { |
| 6938 | if (*option == '+') |
| 6939 | geometry_info.rho=0.0; |
| 6940 | else |
| 6941 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6942 | image_info->pointsize=geometry_info.rho; |
| 6943 | break; |
| 6944 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6945 | if (LocaleCompare("precision",option+1) == 0) |
| 6946 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6947 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6948 | break; |
| 6949 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6950 | if (LocaleCompare("preview",option+1) == 0) |
| 6951 | { |
| 6952 | /* |
| 6953 | Preview image. |
| 6954 | */ |
| 6955 | if (*option == '+') |
| 6956 | { |
| 6957 | image_info->preview_type=UndefinedPreview; |
| 6958 | break; |
| 6959 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6960 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6961 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6962 | break; |
| 6963 | } |
| 6964 | break; |
| 6965 | } |
| 6966 | case 'q': |
| 6967 | { |
| 6968 | if (LocaleCompare("quality",option+1) == 0) |
| 6969 | { |
| 6970 | /* |
| 6971 | Set image compression quality. |
| 6972 | */ |
| 6973 | if (*option == '+') |
| 6974 | { |
| 6975 | image_info->quality=UndefinedCompressionQuality; |
| 6976 | (void) SetImageOption(image_info,option+1,"0"); |
| 6977 | break; |
| 6978 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6979 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6980 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6981 | break; |
| 6982 | } |
| 6983 | if (LocaleCompare("quiet",option+1) == 0) |
| 6984 | { |
| 6985 | static WarningHandler |
| 6986 | warning_handler = (WarningHandler) NULL; |
| 6987 | |
| 6988 | if (*option == '+') |
| 6989 | { |
| 6990 | /* |
| 6991 | Restore error or warning messages. |
| 6992 | */ |
| 6993 | warning_handler=SetWarningHandler(warning_handler); |
| 6994 | break; |
| 6995 | } |
| 6996 | /* |
| 6997 | Suppress error or warning messages. |
| 6998 | */ |
| 6999 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 7000 | break; |
| 7001 | } |
| 7002 | break; |
| 7003 | } |
| 7004 | case 'r': |
| 7005 | { |
| 7006 | if (LocaleCompare("red-primary",option+1) == 0) |
| 7007 | { |
| 7008 | if (*option == '+') |
| 7009 | { |
| 7010 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7011 | break; |
| 7012 | } |
| 7013 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7014 | break; |
| 7015 | } |
| 7016 | break; |
| 7017 | } |
| 7018 | case 's': |
| 7019 | { |
| 7020 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 7021 | { |
| 7022 | /* |
| 7023 | Set image sampling factor. |
| 7024 | */ |
| 7025 | if (*option == '+') |
| 7026 | { |
| 7027 | if (image_info->sampling_factor != (char *) NULL) |
| 7028 | image_info->sampling_factor=DestroyString( |
| 7029 | image_info->sampling_factor); |
| 7030 | break; |
| 7031 | } |
| 7032 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 7033 | break; |
| 7034 | } |
| 7035 | if (LocaleCompare("scene",option+1) == 0) |
| 7036 | { |
| 7037 | /* |
| 7038 | Set image scene. |
| 7039 | */ |
| 7040 | if (*option == '+') |
| 7041 | { |
| 7042 | image_info->scene=0; |
| 7043 | (void) SetImageOption(image_info,option+1,"0"); |
| 7044 | break; |
| 7045 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7046 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7047 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7048 | break; |
| 7049 | } |
| 7050 | if (LocaleCompare("seed",option+1) == 0) |
| 7051 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7052 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7053 | seed; |
| 7054 | |
| 7055 | if (*option == '+') |
| 7056 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7057 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7058 | SeedPseudoRandomGenerator(seed); |
| 7059 | break; |
| 7060 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7061 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7062 | SeedPseudoRandomGenerator(seed); |
| 7063 | break; |
| 7064 | } |
| 7065 | if (LocaleCompare("size",option+1) == 0) |
| 7066 | { |
| 7067 | if (*option == '+') |
| 7068 | { |
| 7069 | if (image_info->size != (char *) NULL) |
| 7070 | image_info->size=DestroyString(image_info->size); |
| 7071 | break; |
| 7072 | } |
| 7073 | (void) CloneString(&image_info->size,argv[i+1]); |
| 7074 | break; |
| 7075 | } |
| 7076 | if (LocaleCompare("stroke",option+1) == 0) |
| 7077 | { |
| 7078 | if (*option == '+') |
| 7079 | { |
| 7080 | (void) SetImageOption(image_info,option+1,"none"); |
| 7081 | break; |
| 7082 | } |
| 7083 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7084 | break; |
| 7085 | } |
| 7086 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7087 | { |
| 7088 | if (*option == '+') |
| 7089 | { |
| 7090 | (void) SetImageOption(image_info,option+1,"0"); |
| 7091 | break; |
| 7092 | } |
| 7093 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7094 | break; |
| 7095 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7096 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7097 | { |
| 7098 | if (*option == '+') |
| 7099 | { |
| 7100 | image_info->synchronize=MagickFalse; |
| 7101 | break; |
| 7102 | } |
| 7103 | image_info->synchronize=MagickTrue; |
| 7104 | break; |
| 7105 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7106 | break; |
| 7107 | } |
| 7108 | case 't': |
| 7109 | { |
| 7110 | if (LocaleCompare("taint",option+1) == 0) |
| 7111 | { |
| 7112 | if (*option == '+') |
| 7113 | { |
| 7114 | (void) SetImageOption(image_info,option+1,"false"); |
| 7115 | break; |
| 7116 | } |
| 7117 | (void) SetImageOption(image_info,option+1,"true"); |
| 7118 | break; |
| 7119 | } |
| 7120 | if (LocaleCompare("texture",option+1) == 0) |
| 7121 | { |
| 7122 | if (*option == '+') |
| 7123 | { |
| 7124 | if (image_info->texture != (char *) NULL) |
| 7125 | image_info->texture=DestroyString(image_info->texture); |
| 7126 | break; |
| 7127 | } |
| 7128 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7129 | break; |
| 7130 | } |
| 7131 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7132 | { |
| 7133 | if (*option == '+') |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 7134 | (void) SetImageOption(image_info,option+1,"0"); |
| 7135 | else |
| 7136 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7137 | break; |
| 7138 | } |
| 7139 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7140 | { |
| 7141 | if (*option == '+') |
| 7142 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 7143 | (void) QueryColorCompliance("none",AllCompliance, |
| 7144 | &image_info->transparent_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7145 | (void) SetImageOption(image_info,option+1,"none"); |
| 7146 | break; |
| 7147 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 7148 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 7149 | &image_info->transparent_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7150 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7151 | break; |
| 7152 | } |
| 7153 | if (LocaleCompare("type",option+1) == 0) |
| 7154 | { |
| 7155 | if (*option == '+') |
| 7156 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7157 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7158 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7159 | break; |
| 7160 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7161 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7162 | MagickFalse,argv[i+1]); |
| 7163 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7164 | break; |
| 7165 | } |
| 7166 | break; |
| 7167 | } |
| 7168 | case 'u': |
| 7169 | { |
| 7170 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7171 | { |
| 7172 | if (*option == '+') |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 7173 | (void) DeleteImageOption(image_info,option+1); |
| 7174 | else |
| 7175 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7176 | break; |
| 7177 | } |
| 7178 | if (LocaleCompare("units",option+1) == 0) |
| 7179 | { |
| 7180 | if (*option == '+') |
| 7181 | { |
| 7182 | image_info->units=UndefinedResolution; |
| 7183 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7184 | break; |
| 7185 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7186 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7187 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7188 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7189 | break; |
| 7190 | } |
| 7191 | break; |
| 7192 | } |
| 7193 | case 'v': |
| 7194 | { |
| 7195 | if (LocaleCompare("verbose",option+1) == 0) |
| 7196 | { |
| 7197 | if (*option == '+') |
| 7198 | { |
| 7199 | image_info->verbose=MagickFalse; |
| 7200 | break; |
| 7201 | } |
| 7202 | image_info->verbose=MagickTrue; |
| 7203 | image_info->ping=MagickFalse; |
| 7204 | break; |
| 7205 | } |
| 7206 | if (LocaleCompare("view",option+1) == 0) |
| 7207 | { |
| 7208 | if (*option == '+') |
| 7209 | { |
| 7210 | if (image_info->view != (char *) NULL) |
| 7211 | image_info->view=DestroyString(image_info->view); |
| 7212 | break; |
| 7213 | } |
| 7214 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7215 | break; |
| 7216 | } |
| 7217 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7218 | { |
| 7219 | if (*option == '+') |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 7220 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7221 | else |
| 7222 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7223 | break; |
| 7224 | } |
| 7225 | break; |
| 7226 | } |
| 7227 | case 'w': |
| 7228 | { |
| 7229 | if (LocaleCompare("white-point",option+1) == 0) |
| 7230 | { |
| 7231 | if (*option == '+') |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 7232 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7233 | else |
| 7234 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7235 | break; |
| 7236 | } |
| 7237 | break; |
| 7238 | } |
| 7239 | default: |
| 7240 | break; |
| 7241 | } |
| 7242 | i+=count; |
| 7243 | } |
| 7244 | return(MagickTrue); |
| 7245 | } |
| 7246 | |
| 7247 | /* |
| 7248 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7249 | % % |
| 7250 | % % |
| 7251 | % % |
| 7252 | + M o g r i f y I m a g e L i s t % |
| 7253 | % % |
| 7254 | % % |
| 7255 | % % |
| 7256 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7257 | % |
| 7258 | % MogrifyImageList() applies any command line options that might affect the |
| 7259 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7260 | % |
| 7261 | % The format of the MogrifyImage method is: |
| 7262 | % |
| 7263 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7264 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7265 | % |
| 7266 | % A description of each parameter follows: |
| 7267 | % |
| 7268 | % o image_info: the image info.. |
| 7269 | % |
| 7270 | % o argc: Specifies a pointer to an integer describing the number of |
| 7271 | % elements in the argument vector. |
| 7272 | % |
| 7273 | % o argv: Specifies a pointer to a text array containing the command line |
| 7274 | % arguments. |
| 7275 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7276 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7277 | % |
| 7278 | % o exception: return any errors or warnings in this structure. |
| 7279 | % |
| 7280 | */ |
| 7281 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7282 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7283 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7284 | const char |
| 7285 | *option; |
| 7286 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7287 | ImageInfo |
| 7288 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7289 | |
| 7290 | MagickStatusType |
| 7291 | status; |
| 7292 | |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7293 | PixelInterpolateMethod |
| 7294 | interpolate_method; |
| 7295 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7296 | QuantizeInfo |
| 7297 | *quantize_info; |
| 7298 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7299 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7300 | i; |
| 7301 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7302 | ssize_t |
| 7303 | count, |
| 7304 | index; |
| 7305 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7306 | /* |
| 7307 | Apply options to the image list. |
| 7308 | */ |
| 7309 | assert(image_info != (ImageInfo *) NULL); |
| 7310 | assert(image_info->signature == MagickSignature); |
| 7311 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7312 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7313 | assert((*images)->signature == MagickSignature); |
| 7314 | if ((*images)->debug != MagickFalse) |
| 7315 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7316 | (*images)->filename); |
| 7317 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7318 | return(MagickTrue); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7319 | interpolate_method=UndefinedInterpolatePixel; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7320 | mogrify_info=CloneImageInfo(image_info); |
| 7321 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7322 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7323 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7324 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7325 | if (*images == (Image *) NULL) |
| 7326 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7327 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7328 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7329 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7330 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7331 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7332 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7333 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7334 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7335 | switch (*(option+1)) |
| 7336 | { |
| 7337 | case 'a': |
| 7338 | { |
| 7339 | if (LocaleCompare("affinity",option+1) == 0) |
| 7340 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7341 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7342 | if (*option == '+') |
| 7343 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7344 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7345 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7346 | break; |
| 7347 | } |
| 7348 | i++; |
| 7349 | break; |
| 7350 | } |
| 7351 | if (LocaleCompare("append",option+1) == 0) |
| 7352 | { |
| 7353 | Image |
| 7354 | *append_image; |
| 7355 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7356 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7357 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7358 | MagickFalse,exception); |
| 7359 | if (append_image == (Image *) NULL) |
| 7360 | { |
| 7361 | status=MagickFalse; |
| 7362 | break; |
| 7363 | } |
| 7364 | *images=DestroyImageList(*images); |
| 7365 | *images=append_image; |
| 7366 | break; |
| 7367 | } |
| 7368 | if (LocaleCompare("average",option+1) == 0) |
| 7369 | { |
| 7370 | Image |
| 7371 | *average_image; |
| 7372 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7373 | /* |
| 7374 | Average an image sequence (deprecated). |
| 7375 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7376 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7377 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7378 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7379 | if (average_image == (Image *) NULL) |
| 7380 | { |
| 7381 | status=MagickFalse; |
| 7382 | break; |
| 7383 | } |
| 7384 | *images=DestroyImageList(*images); |
| 7385 | *images=average_image; |
| 7386 | break; |
| 7387 | } |
| 7388 | break; |
| 7389 | } |
| 7390 | case 'c': |
| 7391 | { |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 7392 | if (LocaleCompare("channel-inject",option+1) == 0) |
| 7393 | { |
| 7394 | puts("stand by..."); |
| 7395 | break; |
| 7396 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7397 | if (LocaleCompare("clut",option+1) == 0) |
| 7398 | { |
| 7399 | Image |
| 7400 | *clut_image, |
| 7401 | *image; |
| 7402 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7403 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7404 | image=RemoveFirstImageFromList(images); |
| 7405 | clut_image=RemoveFirstImageFromList(images); |
| 7406 | if (clut_image == (Image *) NULL) |
| 7407 | { |
| 7408 | status=MagickFalse; |
| 7409 | break; |
| 7410 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7411 | (void) ClutImage(image,clut_image,interpolate_method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7412 | clut_image=DestroyImage(clut_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7413 | *images=DestroyImageList(*images); |
| 7414 | *images=image; |
| 7415 | break; |
| 7416 | } |
| 7417 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7418 | { |
| 7419 | Image |
| 7420 | *coalesce_image; |
| 7421 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7422 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7423 | coalesce_image=CoalesceImages(*images,exception); |
| 7424 | if (coalesce_image == (Image *) NULL) |
| 7425 | { |
| 7426 | status=MagickFalse; |
| 7427 | break; |
| 7428 | } |
| 7429 | *images=DestroyImageList(*images); |
| 7430 | *images=coalesce_image; |
| 7431 | break; |
| 7432 | } |
| 7433 | if (LocaleCompare("combine",option+1) == 0) |
| 7434 | { |
| 7435 | Image |
| 7436 | *combine_image; |
| 7437 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7438 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 7439 | combine_image=CombineImages(*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7440 | if (combine_image == (Image *) NULL) |
| 7441 | { |
| 7442 | status=MagickFalse; |
| 7443 | break; |
| 7444 | } |
| 7445 | *images=DestroyImageList(*images); |
| 7446 | *images=combine_image; |
| 7447 | break; |
| 7448 | } |
| 7449 | if (LocaleCompare("composite",option+1) == 0) |
| 7450 | { |
| 7451 | Image |
| 7452 | *mask_image, |
| 7453 | *composite_image, |
| 7454 | *image; |
| 7455 | |
| 7456 | RectangleInfo |
| 7457 | geometry; |
| 7458 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7459 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7460 | image=RemoveFirstImageFromList(images); |
| 7461 | composite_image=RemoveFirstImageFromList(images); |
| 7462 | if (composite_image == (Image *) NULL) |
| 7463 | { |
| 7464 | status=MagickFalse; |
| 7465 | break; |
| 7466 | } |
| 7467 | (void) TransformImage(&composite_image,(char *) NULL, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 7468 | composite_image->geometry,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7469 | SetGeometry(composite_image,&geometry); |
| 7470 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7471 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7472 | &geometry); |
| 7473 | mask_image=RemoveFirstImageFromList(images); |
| 7474 | if (mask_image != (Image *) NULL) |
| 7475 | { |
| 7476 | if ((image->compose == DisplaceCompositeOp) || |
| 7477 | (image->compose == DistortCompositeOp)) |
| 7478 | { |
| 7479 | /* |
| 7480 | Merge Y displacement into X displacement image. |
| 7481 | */ |
| 7482 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 7483 | mask_image,0,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7484 | mask_image=DestroyImage(mask_image); |
| 7485 | } |
| 7486 | else |
| 7487 | { |
| 7488 | /* |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 7489 | Set a blending mask for the composition. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7490 | */ |
cristy | 10a6c61 | 2012-01-29 21:41:05 +0000 | [diff] [blame] | 7491 | (void) NegateImage(mask_image,MagickFalse,exception); |
| 7492 | (void) SetImageMask(image,mask_image,exception); |
| 7493 | mask_image=DestroyImage(mask_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7494 | } |
| 7495 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7496 | (void) CompositeImage(image,image->compose,composite_image, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 7497 | geometry.x,geometry.y,exception); |
cristy | 10a6c61 | 2012-01-29 21:41:05 +0000 | [diff] [blame] | 7498 | (void) SetImageMask(image,(Image *) NULL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7499 | composite_image=DestroyImage(composite_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7500 | *images=DestroyImageList(*images); |
| 7501 | *images=image; |
| 7502 | break; |
| 7503 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7504 | break; |
| 7505 | } |
| 7506 | case 'd': |
| 7507 | { |
| 7508 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7509 | { |
| 7510 | Image |
| 7511 | *deconstruct_image; |
| 7512 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7513 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7514 | deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer, |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 7515 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7516 | if (deconstruct_image == (Image *) NULL) |
| 7517 | { |
| 7518 | status=MagickFalse; |
| 7519 | break; |
| 7520 | } |
| 7521 | *images=DestroyImageList(*images); |
| 7522 | *images=deconstruct_image; |
| 7523 | break; |
| 7524 | } |
| 7525 | if (LocaleCompare("delete",option+1) == 0) |
| 7526 | { |
| 7527 | if (*option == '+') |
| 7528 | DeleteImages(images,"-1",exception); |
| 7529 | else |
| 7530 | DeleteImages(images,argv[i+1],exception); |
| 7531 | break; |
| 7532 | } |
| 7533 | if (LocaleCompare("dither",option+1) == 0) |
| 7534 | { |
| 7535 | if (*option == '+') |
| 7536 | { |
| 7537 | quantize_info->dither=MagickFalse; |
| 7538 | break; |
| 7539 | } |
| 7540 | quantize_info->dither=MagickTrue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7541 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7542 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7543 | break; |
| 7544 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7545 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7546 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7547 | Image |
| 7548 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7549 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7550 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7551 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7552 | else |
| 7553 | { |
| 7554 | const char |
| 7555 | *p; |
| 7556 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7557 | size_t |
| 7558 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7559 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7560 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7561 | p=strchr(argv[i+1],','); |
| 7562 | if (p == (const char *) NULL) |
| 7563 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7564 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7565 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7566 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7567 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7568 | } |
| 7569 | AppendImageToList(images, duplicate_images); |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7570 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7571 | break; |
| 7572 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7573 | break; |
| 7574 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7575 | case 'e': |
| 7576 | { |
| 7577 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7578 | { |
| 7579 | Image |
| 7580 | *evaluate_image; |
| 7581 | |
| 7582 | MagickEvaluateOperator |
| 7583 | op; |
| 7584 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7585 | (void) SyncImageSettings(mogrify_info,*images,exception); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7586 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 7587 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7588 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7589 | if (evaluate_image == (Image *) NULL) |
| 7590 | { |
| 7591 | status=MagickFalse; |
| 7592 | break; |
| 7593 | } |
| 7594 | *images=DestroyImageList(*images); |
| 7595 | *images=evaluate_image; |
| 7596 | break; |
| 7597 | } |
| 7598 | break; |
| 7599 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7600 | case 'f': |
| 7601 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7602 | if (LocaleCompare("fft",option+1) == 0) |
| 7603 | { |
| 7604 | Image |
| 7605 | *fourier_image; |
| 7606 | |
| 7607 | /* |
| 7608 | Implements the discrete Fourier transform (DFT). |
| 7609 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7610 | (void) SyncImageSettings(mogrify_info,*images,exception); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7611 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7612 | MagickTrue : MagickFalse,exception); |
| 7613 | if (fourier_image == (Image *) NULL) |
| 7614 | break; |
| 7615 | *images=DestroyImage(*images); |
| 7616 | *images=fourier_image; |
| 7617 | break; |
| 7618 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7619 | if (LocaleCompare("flatten",option+1) == 0) |
| 7620 | { |
| 7621 | Image |
| 7622 | *flatten_image; |
| 7623 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7624 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7625 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7626 | if (flatten_image == (Image *) NULL) |
| 7627 | break; |
| 7628 | *images=DestroyImageList(*images); |
| 7629 | *images=flatten_image; |
| 7630 | break; |
| 7631 | } |
| 7632 | if (LocaleCompare("fx",option+1) == 0) |
| 7633 | { |
| 7634 | Image |
| 7635 | *fx_image; |
| 7636 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7637 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 7638 | fx_image=FxImage(*images,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7639 | if (fx_image == (Image *) NULL) |
| 7640 | { |
| 7641 | status=MagickFalse; |
| 7642 | break; |
| 7643 | } |
| 7644 | *images=DestroyImageList(*images); |
| 7645 | *images=fx_image; |
| 7646 | break; |
| 7647 | } |
| 7648 | break; |
| 7649 | } |
| 7650 | case 'h': |
| 7651 | { |
| 7652 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7653 | { |
| 7654 | Image |
| 7655 | *hald_image, |
| 7656 | *image; |
| 7657 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7658 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7659 | image=RemoveFirstImageFromList(images); |
| 7660 | hald_image=RemoveFirstImageFromList(images); |
| 7661 | if (hald_image == (Image *) NULL) |
| 7662 | { |
| 7663 | status=MagickFalse; |
| 7664 | break; |
| 7665 | } |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 7666 | (void) HaldClutImage(image,hald_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7667 | hald_image=DestroyImage(hald_image); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7668 | if (*images != (Image *) NULL) |
| 7669 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7670 | *images=image; |
| 7671 | break; |
| 7672 | } |
| 7673 | break; |
| 7674 | } |
| 7675 | case 'i': |
| 7676 | { |
| 7677 | if (LocaleCompare("ift",option+1) == 0) |
| 7678 | { |
| 7679 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7680 | *fourier_image, |
| 7681 | *magnitude_image, |
| 7682 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7683 | |
| 7684 | /* |
| 7685 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7686 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7687 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7688 | magnitude_image=RemoveFirstImageFromList(images); |
| 7689 | phase_image=RemoveFirstImageFromList(images); |
| 7690 | if (phase_image == (Image *) NULL) |
| 7691 | { |
| 7692 | status=MagickFalse; |
| 7693 | break; |
| 7694 | } |
| 7695 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7696 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7697 | if (fourier_image == (Image *) NULL) |
| 7698 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7699 | if (*images != (Image *) NULL) |
| 7700 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7701 | *images=fourier_image; |
| 7702 | break; |
| 7703 | } |
| 7704 | if (LocaleCompare("insert",option+1) == 0) |
| 7705 | { |
| 7706 | Image |
| 7707 | *p, |
| 7708 | *q; |
| 7709 | |
| 7710 | index=0; |
| 7711 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7712 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7713 | p=RemoveLastImageFromList(images); |
| 7714 | if (p == (Image *) NULL) |
| 7715 | { |
| 7716 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7717 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7718 | status=MagickFalse; |
| 7719 | break; |
| 7720 | } |
| 7721 | q=p; |
| 7722 | if (index == 0) |
| 7723 | PrependImageToList(images,q); |
| 7724 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7725 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7726 | AppendImageToList(images,q); |
| 7727 | else |
| 7728 | { |
| 7729 | q=GetImageFromList(*images,index-1); |
| 7730 | if (q == (Image *) NULL) |
| 7731 | { |
| 7732 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7733 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7734 | status=MagickFalse; |
| 7735 | break; |
| 7736 | } |
| 7737 | InsertImageInList(&q,p); |
| 7738 | } |
| 7739 | *images=GetFirstImageInList(q); |
| 7740 | break; |
| 7741 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7742 | if (LocaleCompare("interpolate",option+1) == 0) |
| 7743 | { |
| 7744 | interpolate_method=(PixelInterpolateMethod) ParseCommandOption( |
| 7745 | MagickInterpolateOptions,MagickFalse,argv[i+1]); |
| 7746 | break; |
| 7747 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7748 | break; |
| 7749 | } |
| 7750 | case 'l': |
| 7751 | { |
| 7752 | if (LocaleCompare("layers",option+1) == 0) |
| 7753 | { |
| 7754 | Image |
| 7755 | *layers; |
| 7756 | |
| 7757 | ImageLayerMethod |
| 7758 | method; |
| 7759 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7760 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7761 | layers=(Image *) NULL; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7762 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7763 | MagickFalse,argv[i+1]); |
| 7764 | switch (method) |
| 7765 | { |
| 7766 | case CoalesceLayer: |
| 7767 | { |
| 7768 | layers=CoalesceImages(*images,exception); |
| 7769 | break; |
| 7770 | } |
| 7771 | case CompareAnyLayer: |
| 7772 | case CompareClearLayer: |
| 7773 | case CompareOverlayLayer: |
| 7774 | default: |
| 7775 | { |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7776 | layers=CompareImagesLayers(*images,method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7777 | break; |
| 7778 | } |
| 7779 | case MergeLayer: |
| 7780 | case FlattenLayer: |
| 7781 | case MosaicLayer: |
| 7782 | case TrimBoundsLayer: |
| 7783 | { |
| 7784 | layers=MergeImageLayers(*images,method,exception); |
| 7785 | break; |
| 7786 | } |
| 7787 | case DisposeLayer: |
| 7788 | { |
| 7789 | layers=DisposeImages(*images,exception); |
| 7790 | break; |
| 7791 | } |
| 7792 | case OptimizeImageLayer: |
| 7793 | { |
| 7794 | layers=OptimizeImageLayers(*images,exception); |
| 7795 | break; |
| 7796 | } |
| 7797 | case OptimizePlusLayer: |
| 7798 | { |
| 7799 | layers=OptimizePlusImageLayers(*images,exception); |
| 7800 | break; |
| 7801 | } |
| 7802 | case OptimizeTransLayer: |
| 7803 | { |
| 7804 | OptimizeImageTransparency(*images,exception); |
| 7805 | break; |
| 7806 | } |
| 7807 | case RemoveDupsLayer: |
| 7808 | { |
| 7809 | RemoveDuplicateLayers(images,exception); |
| 7810 | break; |
| 7811 | } |
| 7812 | case RemoveZeroLayer: |
| 7813 | { |
| 7814 | RemoveZeroDelayLayers(images,exception); |
| 7815 | break; |
| 7816 | } |
| 7817 | case OptimizeLayer: |
| 7818 | { |
| 7819 | /* |
| 7820 | General Purpose, GIF Animation Optimizer. |
| 7821 | */ |
| 7822 | layers=CoalesceImages(*images,exception); |
| 7823 | if (layers == (Image *) NULL) |
| 7824 | { |
| 7825 | status=MagickFalse; |
| 7826 | break; |
| 7827 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7828 | *images=DestroyImageList(*images); |
| 7829 | *images=layers; |
| 7830 | layers=OptimizeImageLayers(*images,exception); |
| 7831 | if (layers == (Image *) NULL) |
| 7832 | { |
| 7833 | status=MagickFalse; |
| 7834 | break; |
| 7835 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7836 | *images=DestroyImageList(*images); |
| 7837 | *images=layers; |
| 7838 | layers=(Image *) NULL; |
| 7839 | OptimizeImageTransparency(*images,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7840 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7841 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7842 | break; |
| 7843 | } |
| 7844 | case CompositeLayer: |
| 7845 | { |
| 7846 | CompositeOperator |
| 7847 | compose; |
| 7848 | |
| 7849 | Image |
| 7850 | *source; |
| 7851 | |
| 7852 | RectangleInfo |
| 7853 | geometry; |
| 7854 | |
| 7855 | /* |
| 7856 | Split image sequence at the first 'NULL:' image. |
| 7857 | */ |
| 7858 | source=(*images); |
| 7859 | while (source != (Image *) NULL) |
| 7860 | { |
| 7861 | source=GetNextImageInList(source); |
| 7862 | if ((source != (Image *) NULL) && |
| 7863 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7864 | break; |
| 7865 | } |
| 7866 | if (source != (Image *) NULL) |
| 7867 | { |
| 7868 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7869 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7870 | source=(Image *) NULL; |
| 7871 | else |
| 7872 | { |
| 7873 | /* |
| 7874 | Separate the two lists, junk the null: image. |
| 7875 | */ |
| 7876 | source=SplitImageList(source->previous); |
| 7877 | DeleteImageFromList(&source); |
| 7878 | } |
| 7879 | } |
| 7880 | if (source == (Image *) NULL) |
| 7881 | { |
| 7882 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7883 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7884 | status=MagickFalse; |
| 7885 | break; |
| 7886 | } |
| 7887 | /* |
| 7888 | Adjust offset with gravity and virtual canvas. |
| 7889 | */ |
| 7890 | SetGeometry(*images,&geometry); |
| 7891 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7892 | geometry.width=source->page.width != 0 ? |
| 7893 | source->page.width : source->columns; |
| 7894 | geometry.height=source->page.height != 0 ? |
| 7895 | source->page.height : source->rows; |
| 7896 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7897 | (*images)->page.width : (*images)->columns, |
| 7898 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7899 | (*images)->rows,(*images)->gravity,&geometry); |
| 7900 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7901 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7902 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7903 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7904 | MagickComposeOptions,MagickFalse,option); |
| 7905 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7906 | exception); |
| 7907 | source=DestroyImageList(source); |
| 7908 | break; |
| 7909 | } |
| 7910 | } |
| 7911 | if (layers == (Image *) NULL) |
| 7912 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7913 | *images=DestroyImageList(*images); |
| 7914 | *images=layers; |
| 7915 | break; |
| 7916 | } |
| 7917 | break; |
| 7918 | } |
| 7919 | case 'm': |
| 7920 | { |
| 7921 | if (LocaleCompare("map",option+1) == 0) |
| 7922 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7923 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7924 | if (*option == '+') |
| 7925 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7926 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7927 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7928 | break; |
| 7929 | } |
| 7930 | i++; |
| 7931 | break; |
| 7932 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7933 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7934 | { |
| 7935 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7936 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7937 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7938 | /* |
| 7939 | Maximum image sequence (deprecated). |
| 7940 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7941 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7942 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7943 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7944 | { |
| 7945 | status=MagickFalse; |
| 7946 | break; |
| 7947 | } |
| 7948 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7949 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7950 | break; |
| 7951 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7952 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7953 | { |
| 7954 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7955 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7956 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7957 | /* |
| 7958 | Minimum image sequence (deprecated). |
| 7959 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7960 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7961 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7962 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7963 | { |
| 7964 | status=MagickFalse; |
| 7965 | break; |
| 7966 | } |
| 7967 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7968 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7969 | break; |
| 7970 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7971 | if (LocaleCompare("morph",option+1) == 0) |
| 7972 | { |
| 7973 | Image |
| 7974 | *morph_image; |
| 7975 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7976 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7977 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7978 | exception); |
| 7979 | if (morph_image == (Image *) NULL) |
| 7980 | { |
| 7981 | status=MagickFalse; |
| 7982 | break; |
| 7983 | } |
| 7984 | *images=DestroyImageList(*images); |
| 7985 | *images=morph_image; |
| 7986 | break; |
| 7987 | } |
| 7988 | if (LocaleCompare("mosaic",option+1) == 0) |
| 7989 | { |
| 7990 | Image |
| 7991 | *mosaic_image; |
| 7992 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7993 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7994 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 7995 | if (mosaic_image == (Image *) NULL) |
| 7996 | { |
| 7997 | status=MagickFalse; |
| 7998 | break; |
| 7999 | } |
| 8000 | *images=DestroyImageList(*images); |
| 8001 | *images=mosaic_image; |
| 8002 | break; |
| 8003 | } |
| 8004 | break; |
| 8005 | } |
| 8006 | case 'p': |
| 8007 | { |
| 8008 | if (LocaleCompare("print",option+1) == 0) |
| 8009 | { |
| 8010 | char |
| 8011 | *string; |
| 8012 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8013 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 8014 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1], |
| 8015 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8016 | if (string == (char *) NULL) |
| 8017 | break; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8018 | (void) FormatLocaleFile(stdout,"%s",string); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8019 | string=DestroyString(string); |
| 8020 | } |
| 8021 | if (LocaleCompare("process",option+1) == 0) |
| 8022 | { |
| 8023 | char |
| 8024 | **arguments; |
| 8025 | |
| 8026 | int |
| 8027 | j, |
| 8028 | number_arguments; |
| 8029 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8030 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8031 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 8032 | if (arguments == (char **) NULL) |
| 8033 | break; |
| 8034 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 8035 | { |
| 8036 | char |
| 8037 | breaker, |
| 8038 | quote, |
| 8039 | *token; |
| 8040 | |
| 8041 | const char |
| 8042 | *arguments; |
| 8043 | |
| 8044 | int |
| 8045 | next, |
| 8046 | status; |
| 8047 | |
| 8048 | size_t |
| 8049 | length; |
| 8050 | |
| 8051 | TokenInfo |
| 8052 | *token_info; |
| 8053 | |
| 8054 | /* |
| 8055 | Support old style syntax, filter="-option arg". |
| 8056 | */ |
| 8057 | length=strlen(argv[i+1]); |
| 8058 | token=(char *) NULL; |
cristy | 37e0b38 | 2011-06-07 13:31:21 +0000 | [diff] [blame] | 8059 | if (~length >= (MaxTextExtent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8060 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8061 | sizeof(*token)); |
| 8062 | if (token == (char *) NULL) |
| 8063 | break; |
| 8064 | next=0; |
| 8065 | arguments=argv[i+1]; |
| 8066 | token_info=AcquireTokenInfo(); |
| 8067 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8068 | "\"",'\0',&breaker,&next,"e); |
| 8069 | token_info=DestroyTokenInfo(token_info); |
| 8070 | if (status == 0) |
| 8071 | { |
| 8072 | const char |
| 8073 | *argv; |
| 8074 | |
| 8075 | argv=(&(arguments[next])); |
| 8076 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8077 | exception); |
| 8078 | } |
| 8079 | token=DestroyString(token); |
| 8080 | break; |
| 8081 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8082 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8083 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8084 | number_arguments-2,(const char **) arguments+2,exception); |
| 8085 | for (j=0; j < number_arguments; j++) |
| 8086 | arguments[j]=DestroyString(arguments[j]); |
| 8087 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8088 | break; |
| 8089 | } |
| 8090 | break; |
| 8091 | } |
| 8092 | case 'r': |
| 8093 | { |
| 8094 | if (LocaleCompare("reverse",option+1) == 0) |
| 8095 | { |
| 8096 | ReverseImageList(images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8097 | break; |
| 8098 | } |
| 8099 | break; |
| 8100 | } |
| 8101 | case 's': |
| 8102 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8103 | if (LocaleCompare("smush",option+1) == 0) |
| 8104 | { |
| 8105 | Image |
| 8106 | *smush_image; |
| 8107 | |
| 8108 | ssize_t |
| 8109 | offset; |
| 8110 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8111 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8112 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8113 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8114 | MagickFalse,offset,exception); |
| 8115 | if (smush_image == (Image *) NULL) |
| 8116 | { |
| 8117 | status=MagickFalse; |
| 8118 | break; |
| 8119 | } |
| 8120 | *images=DestroyImageList(*images); |
| 8121 | *images=smush_image; |
| 8122 | break; |
| 8123 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8124 | if (LocaleCompare("swap",option+1) == 0) |
| 8125 | { |
| 8126 | Image |
| 8127 | *p, |
| 8128 | *q, |
| 8129 | *swap; |
| 8130 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8131 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8132 | swap_index; |
| 8133 | |
| 8134 | index=(-1); |
| 8135 | swap_index=(-2); |
| 8136 | if (*option != '+') |
| 8137 | { |
| 8138 | GeometryInfo |
| 8139 | geometry_info; |
| 8140 | |
| 8141 | MagickStatusType |
| 8142 | flags; |
| 8143 | |
| 8144 | swap_index=(-1); |
| 8145 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8146 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8147 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8148 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8149 | } |
| 8150 | p=GetImageFromList(*images,index); |
| 8151 | q=GetImageFromList(*images,swap_index); |
| 8152 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8153 | { |
| 8154 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8155 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8156 | status=MagickFalse; |
| 8157 | break; |
| 8158 | } |
| 8159 | if (p == q) |
| 8160 | break; |
| 8161 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8162 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8163 | ReplaceImageInList(&q,swap); |
| 8164 | *images=GetFirstImageInList(q); |
| 8165 | break; |
| 8166 | } |
| 8167 | break; |
| 8168 | } |
| 8169 | case 'w': |
| 8170 | { |
| 8171 | if (LocaleCompare("write",option+1) == 0) |
| 8172 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8173 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8174 | key[MaxTextExtent]; |
| 8175 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8176 | Image |
| 8177 | *write_images; |
| 8178 | |
| 8179 | ImageInfo |
| 8180 | *write_info; |
| 8181 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8182 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8183 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8184 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8185 | write_images=(*images); |
| 8186 | if (*option == '+') |
| 8187 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8188 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8189 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8190 | write_info=DestroyImageInfo(write_info); |
| 8191 | if (*option == '+') |
| 8192 | write_images=DestroyImageList(write_images); |
| 8193 | break; |
| 8194 | } |
| 8195 | break; |
| 8196 | } |
| 8197 | default: |
| 8198 | break; |
| 8199 | } |
| 8200 | i+=count; |
| 8201 | } |
| 8202 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8203 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8204 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8205 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8206 | } |
| 8207 | |
| 8208 | /* |
| 8209 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8210 | % % |
| 8211 | % % |
| 8212 | % % |
| 8213 | + M o g r i f y I m a g e s % |
| 8214 | % % |
| 8215 | % % |
| 8216 | % % |
| 8217 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8218 | % |
| 8219 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8220 | % prescribed by command line options. |
| 8221 | % |
| 8222 | % The format of the MogrifyImage method is: |
| 8223 | % |
| 8224 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8225 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8226 | % Image **images,Exceptioninfo *exception) |
| 8227 | % |
| 8228 | % A description of each parameter follows: |
| 8229 | % |
| 8230 | % o image_info: the image info.. |
| 8231 | % |
| 8232 | % o post: If true, post process image list operators otherwise pre-process. |
| 8233 | % |
| 8234 | % o argc: Specifies a pointer to an integer describing the number of |
| 8235 | % elements in the argument vector. |
| 8236 | % |
| 8237 | % o argv: Specifies a pointer to a text array containing the command line |
| 8238 | % arguments. |
| 8239 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8240 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8241 | % |
| 8242 | % o exception: return any errors or warnings in this structure. |
| 8243 | % |
| 8244 | */ |
| 8245 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8246 | const MagickBooleanType post,const int argc,const char **argv, |
| 8247 | Image **images,ExceptionInfo *exception) |
| 8248 | { |
| 8249 | #define MogrifyImageTag "Mogrify/Image" |
| 8250 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8251 | MagickStatusType |
| 8252 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8253 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8254 | MagickBooleanType |
| 8255 | proceed; |
| 8256 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8257 | size_t |
| 8258 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8259 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8260 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8261 | i; |
| 8262 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8263 | assert(image_info != (ImageInfo *) NULL); |
| 8264 | assert(image_info->signature == MagickSignature); |
| 8265 | if (images == (Image **) NULL) |
| 8266 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8267 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8268 | assert((*images)->signature == MagickSignature); |
| 8269 | if ((*images)->debug != MagickFalse) |
| 8270 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8271 | (*images)->filename); |
| 8272 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8273 | return(MagickTrue); |
| 8274 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8275 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8276 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8277 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8278 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8279 | (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc, |
| 8280 | post?"post":"pre"); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8281 | #endif |
| 8282 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8283 | /* |
| 8284 | Pre-process multi-image sequence operators |
| 8285 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8286 | if (post == MagickFalse) |
| 8287 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8288 | /* |
| 8289 | For each image, process simple single image operators |
| 8290 | */ |
| 8291 | i=0; |
| 8292 | n=GetImageListLength(*images); |
cristy | 9f027d1 | 2011-09-21 01:17:17 +0000 | [diff] [blame] | 8293 | for ( ; ; ) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8294 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8295 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8296 | (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long) |
| 8297 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8298 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8299 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8300 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8301 | if (proceed == MagickFalse) |
| 8302 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8303 | if ( (*images)->next == (Image *) NULL ) |
| 8304 | break; |
| 8305 | *images=(*images)->next; |
| 8306 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8307 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8308 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8309 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8310 | (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long) |
| 8311 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8312 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8313 | |
| 8314 | /* |
| 8315 | Post-process, multi-image sequence operators |
| 8316 | */ |
| 8317 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8318 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8319 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8320 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8321 | } |