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 | 7e41fe8 | 2010-12-04 23:12:08 +0000 | [diff] [blame] | 20 | % Copyright 1999-2011 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" |
| 54 | #include "MagickCore/thread-private.h" |
| 55 | #include "MagickCore/string-private.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 56 | |
| 57 | /* |
cristy | 154fa9d | 2011-08-05 14:25:15 +0000 | [diff] [blame] | 58 | Constant declaration. |
| 59 | */ |
cristy | 3a557c0 | 2011-08-06 19:48:02 +0000 | [diff] [blame] | 60 | static const char |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 61 | MogrifyBackgroundColor[] = "#ffffff", /* white */ |
| 62 | MogrifyBorderColor[] = "#dfdfdf", /* gray */ |
| 63 | MogrifyMatteColor[] = "#bdbdbd"; /* gray */ |
cristy | 154fa9d | 2011-08-05 14:25:15 +0000 | [diff] [blame] | 64 | |
| 65 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 66 | Define declarations. |
| 67 | */ |
| 68 | #define UndefinedCompressionQuality 0UL |
| 69 | |
| 70 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 71 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 72 | % % |
| 73 | % % |
| 74 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 75 | % 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] | 76 | % % |
| 77 | % % |
| 78 | % % |
| 79 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 80 | % |
| 81 | % MagickCommandGenesis() applies image processing options to an image as |
| 82 | % prescribed by command line options. |
| 83 | % |
| 84 | % The format of the MagickCommandGenesis method is: |
| 85 | % |
| 86 | % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 87 | % MagickCommand command,int argc,char **argv,char **metadata, |
| 88 | % ExceptionInfo *exception) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 89 | % |
| 90 | % A description of each parameter follows: |
| 91 | % |
| 92 | % o image_info: the image info. |
| 93 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 94 | % o command: Choose from ConvertImageCommand, IdentifyImageCommand, |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 95 | % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 96 | % ConjureImageCommand, StreamImageCommand, ImportImageCommand, |
| 97 | % DisplayImageCommand, or AnimateImageCommand. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 98 | % |
| 99 | % o argc: Specifies a pointer to an integer describing the number of |
| 100 | % elements in the argument vector. |
| 101 | % |
| 102 | % o argv: Specifies a pointer to a text array containing the command line |
| 103 | % arguments. |
| 104 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 105 | % o metadata: any metadata is returned here. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 106 | % |
| 107 | % o exception: return any errors or warnings in this structure. |
| 108 | % |
| 109 | */ |
| 110 | WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
| 111 | MagickCommand command,int argc,char **argv,char **metadata, |
| 112 | ExceptionInfo *exception) |
| 113 | { |
| 114 | char |
| 115 | *option; |
| 116 | |
| 117 | double |
| 118 | duration, |
| 119 | elapsed_time, |
| 120 | user_time; |
| 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 | |
| 130 | TimerInfo |
| 131 | *timer; |
| 132 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 133 | size_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 134 | iterations; |
| 135 | |
cristy | d0a94fa | 2010-03-12 14:18:11 +0000 | [diff] [blame] | 136 | (void) setlocale(LC_ALL,""); |
| 137 | (void) setlocale(LC_NUMERIC,"C"); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 138 | concurrent=MagickFalse; |
| 139 | duration=(-1.0); |
| 140 | iterations=1; |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 141 | status=MagickFalse; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 142 | regard_warnings=MagickFalse; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 143 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 144 | { |
| 145 | option=argv[i]; |
| 146 | if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) |
| 147 | continue; |
| 148 | if (LocaleCompare("bench",option+1) == 0) |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 149 | iterations=StringToUnsignedLong(argv[++i]); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 150 | if (LocaleCompare("concurrent",option+1) == 0) |
| 151 | concurrent=MagickTrue; |
| 152 | if (LocaleCompare("debug",option+1) == 0) |
| 153 | (void) SetLogEventMask(argv[++i]); |
| 154 | if (LocaleCompare("duration",option+1) == 0) |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 155 | duration=InterpretLocaleValue(argv[++i],(char **) NULL); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 156 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 157 | regard_warnings=MagickTrue; |
| 158 | } |
| 159 | timer=AcquireTimerInfo(); |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 160 | if (concurrent == MagickFalse) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 161 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 162 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 163 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 164 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 165 | continue; |
| 166 | if (duration > 0) |
| 167 | { |
| 168 | if (GetElapsedTime(timer) > duration) |
| 169 | continue; |
| 170 | (void) ContinueTimer(timer); |
| 171 | } |
| 172 | status=command(image_info,argc,argv,metadata,exception); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 173 | if (exception->severity != UndefinedException) |
| 174 | { |
| 175 | if ((exception->severity > ErrorException) || |
| 176 | (regard_warnings != MagickFalse)) |
| 177 | status=MagickTrue; |
| 178 | CatchException(exception); |
| 179 | } |
cristy | 3d1a551 | 2009-10-25 21:23:27 +0000 | [diff] [blame] | 180 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 181 | { |
| 182 | (void) fputs(*metadata,stdout); |
| 183 | (void) fputc('\n',stdout); |
| 184 | *metadata=DestroyString(*metadata); |
| 185 | } |
| 186 | } |
| 187 | } |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 188 | else |
| 189 | { |
| 190 | SetOpenMPNested(1); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 191 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 192 | # pragma omp parallel for shared(status) |
| 193 | #endif |
cristy | bb50337 | 2010-05-27 20:51:26 +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 | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 196 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 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 | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 205 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 206 | # pragma omp critical (MagickCore_CommandGenesis) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 207 | #endif |
| 208 | { |
| 209 | if (exception->severity != UndefinedException) |
| 210 | { |
| 211 | if ((exception->severity > ErrorException) || |
| 212 | (regard_warnings != MagickFalse)) |
| 213 | status=MagickTrue; |
| 214 | CatchException(exception); |
| 215 | } |
| 216 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 217 | { |
| 218 | (void) fputs(*metadata,stdout); |
| 219 | (void) fputc('\n',stdout); |
| 220 | *metadata=DestroyString(*metadata); |
| 221 | } |
| 222 | } |
| 223 | } |
| 224 | } |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 225 | if (iterations > 1) |
| 226 | { |
| 227 | elapsed_time=GetElapsedTime(timer); |
| 228 | user_time=GetUserTime(timer); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 229 | (void) FormatLocaleFile(stderr, |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 230 | "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double) |
| 231 | iterations,1.0*iterations/elapsed_time,user_time,(double) |
| 232 | (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double) |
| 233 | (1000.0*(elapsed_time-floor(elapsed_time)))); |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 234 | (void) fflush(stderr); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 235 | } |
| 236 | timer=DestroyTimerInfo(timer); |
cristy | 1f9e1ed | 2009-11-18 04:09:38 +0000 | [diff] [blame] | 237 | return(status); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | /* |
| 241 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 242 | % % |
| 243 | % % |
| 244 | % % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 245 | + M o g r i f y I m a g e % |
| 246 | % % |
| 247 | % % |
| 248 | % % |
| 249 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 250 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 251 | % MogrifyImage() applies simple single image processing options to a single |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 252 | % image that may be part of a large list, but also handles any 'region' |
| 253 | % image handling. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 254 | % |
| 255 | % The image in the list may be modified in three different ways... |
| 256 | % |
| 257 | % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 258 | % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 259 | % * replace by a list of images (only the -separate option!) |
| 260 | % |
| 261 | % In each case the result is returned into the list, and a pointer to the |
| 262 | % modified image (last image added if replaced by a list of images) is |
| 263 | % returned. |
| 264 | % |
| 265 | % ASIDE: The -crop is present but restricted to non-tile single image crops |
| 266 | % |
| 267 | % This means if all the images are being processed (such as by |
| 268 | % MogrifyImages(), next image to be processed will be as per the pointer |
| 269 | % (*image)->next. Also the image list may grow as a result of some specific |
| 270 | % operations but as images are never merged or deleted, it will never shrink |
| 271 | % in length. Typically the list will remain the same length. |
| 272 | % |
| 273 | % WARNING: As the image pointed to may be replaced, the first image in the |
| 274 | % list may also change. GetFirstImageInList() should be used by caller if |
| 275 | % they wish return the Image pointer to the first image in list. |
| 276 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 277 | % |
| 278 | % The format of the MogrifyImage method is: |
| 279 | % |
| 280 | % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 281 | % const char **argv,Image **image) |
| 282 | % |
| 283 | % A description of each parameter follows: |
| 284 | % |
| 285 | % o image_info: the image info.. |
| 286 | % |
| 287 | % o argc: Specifies a pointer to an integer describing the number of |
| 288 | % elements in the argument vector. |
| 289 | % |
| 290 | % o argv: Specifies a pointer to a text array containing the command line |
| 291 | % arguments. |
| 292 | % |
| 293 | % o image: the image. |
| 294 | % |
| 295 | % o exception: return any errors or warnings in this structure. |
| 296 | % |
| 297 | */ |
| 298 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 299 | /* |
| 300 | ** GetImageCache() will read an image into a image cache if not already |
| 301 | ** present then return the image that is in the cache under that filename. |
| 302 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 303 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 304 | ExceptionInfo *exception) |
| 305 | { |
| 306 | char |
| 307 | key[MaxTextExtent]; |
| 308 | |
| 309 | ExceptionInfo |
| 310 | *sans_exception; |
| 311 | |
| 312 | Image |
| 313 | *image; |
| 314 | |
| 315 | ImageInfo |
| 316 | *read_info; |
| 317 | |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 318 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 319 | sans_exception=AcquireExceptionInfo(); |
| 320 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 321 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 322 | if (image != (Image *) NULL) |
| 323 | return(image); |
| 324 | read_info=CloneImageInfo(image_info); |
| 325 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 326 | image=ReadImage(read_info,exception); |
| 327 | read_info=DestroyImageInfo(read_info); |
| 328 | if (image != (Image *) NULL) |
| 329 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 330 | return(image); |
| 331 | } |
| 332 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 333 | static MagickBooleanType IsPathWritable(const char *path) |
| 334 | { |
| 335 | if (IsPathAccessible(path) == MagickFalse) |
| 336 | return(MagickFalse); |
| 337 | if (access(path,W_OK) != 0) |
| 338 | return(MagickFalse); |
| 339 | return(MagickTrue); |
| 340 | } |
| 341 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 342 | static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 343 | { |
| 344 | if (x > y) |
| 345 | return(x); |
| 346 | return(y); |
| 347 | } |
| 348 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 349 | static MagickBooleanType MonitorProgress(const char *text, |
| 350 | const MagickOffsetType offset,const MagickSizeType extent, |
| 351 | void *wand_unused(client_data)) |
| 352 | { |
| 353 | char |
| 354 | message[MaxTextExtent], |
| 355 | tag[MaxTextExtent]; |
| 356 | |
| 357 | const char |
| 358 | *locale_message; |
| 359 | |
| 360 | register char |
| 361 | *p; |
| 362 | |
| 363 | if (extent < 2) |
| 364 | return(MagickTrue); |
| 365 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 366 | p=strrchr(tag,'/'); |
| 367 | if (p != (char *) NULL) |
| 368 | *p='\0'; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 369 | (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 370 | locale_message=GetLocaleMessage(message); |
| 371 | if (locale_message == message) |
| 372 | locale_message=tag; |
| 373 | if (p == (char *) NULL) |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 374 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", |
| 375 | locale_message,(long) offset,(unsigned long) extent,(long) |
| 376 | (100L*offset/(extent-1))); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 377 | else |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 378 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 379 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 380 | (100L*offset/(extent-1))); |
| 381 | if (offset == (MagickOffsetType) (extent-1)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 382 | (void) FormatLocaleFile(stderr,"\n"); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 383 | (void) fflush(stderr); |
| 384 | return(MagickTrue); |
| 385 | } |
| 386 | |
| 387 | /* |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 388 | ** SparseColorOption() parses the complex -sparse-color argument into an |
| 389 | ** an array of floating point values then calls SparseColorImage(). |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 390 | ** Argument is a complex mix of floating-point pixel coodinates, and color |
| 391 | ** specifications (or direct floating point numbers). The number of floats |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 392 | ** needed to represent a color varies depending on the current channel |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 393 | ** setting. |
| 394 | */ |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 395 | static Image *SparseColorOption(const Image *image, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 396 | const SparseColorMethod method,const char *arguments, |
| 397 | const MagickBooleanType color_from_image,ExceptionInfo *exception) |
| 398 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 399 | char |
| 400 | token[MaxTextExtent]; |
| 401 | |
| 402 | const char |
| 403 | *p; |
| 404 | |
| 405 | double |
| 406 | *sparse_arguments; |
| 407 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 408 | Image |
| 409 | *sparse_image; |
| 410 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 411 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 412 | color; |
| 413 | |
| 414 | MagickBooleanType |
| 415 | error; |
| 416 | |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 417 | register size_t |
| 418 | x; |
| 419 | |
| 420 | size_t |
| 421 | number_arguments, |
| 422 | number_colors; |
| 423 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 424 | assert(image != (Image *) NULL); |
| 425 | assert(image->signature == MagickSignature); |
| 426 | if (image->debug != MagickFalse) |
| 427 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 428 | assert(exception != (ExceptionInfo *) NULL); |
| 429 | assert(exception->signature == MagickSignature); |
| 430 | /* |
| 431 | Limit channels according to image - and add up number of color channel. |
| 432 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 433 | number_colors=0; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 434 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 435 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 436 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 437 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 438 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 439 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 440 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 441 | (image->colorspace == CMYKColorspace)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 442 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 443 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 444 | (image->matte != MagickFalse)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 445 | number_colors++; |
| 446 | |
| 447 | /* |
| 448 | Read string, to determine number of arguments needed, |
| 449 | */ |
| 450 | p=arguments; |
| 451 | x=0; |
| 452 | while( *p != '\0' ) |
| 453 | { |
| 454 | GetMagickToken(p,&p,token); |
| 455 | if ( token[0] == ',' ) continue; |
| 456 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 457 | if ( color_from_image ) { |
| 458 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 459 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 460 | "Color arg given, when colors are coming from image"); |
| 461 | return( (Image *)NULL); |
| 462 | } |
| 463 | x += number_colors; /* color argument */ |
| 464 | } |
| 465 | else { |
| 466 | x++; /* floating point argument */ |
| 467 | } |
| 468 | } |
| 469 | error=MagickTrue; |
| 470 | if ( color_from_image ) { |
| 471 | /* just the control points are being given */ |
| 472 | error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; |
| 473 | number_arguments=(x/2)*(2+number_colors); |
| 474 | } |
| 475 | else { |
| 476 | /* control points and color values */ |
| 477 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; |
| 478 | number_arguments=x; |
| 479 | } |
| 480 | if ( error ) { |
| 481 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 482 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 483 | "Invalid number of Arguments"); |
| 484 | return( (Image *)NULL); |
| 485 | } |
| 486 | |
| 487 | /* Allocate and fill in the floating point arguments */ |
| 488 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 489 | sizeof(*sparse_arguments)); |
| 490 | if (sparse_arguments == (double *) NULL) { |
| 491 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 492 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 493 | return( (Image *)NULL); |
| 494 | } |
| 495 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 496 | sizeof(*sparse_arguments)); |
| 497 | p=arguments; |
| 498 | x=0; |
| 499 | while( *p != '\0' && x < number_arguments ) { |
| 500 | /* X coordinate */ |
| 501 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 502 | if ( token[0] == '\0' ) break; |
| 503 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 504 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 505 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 506 | "Color found, instead of X-coord"); |
| 507 | error = MagickTrue; |
| 508 | break; |
| 509 | } |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 510 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 511 | /* Y coordinate */ |
| 512 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 513 | if ( token[0] == '\0' ) break; |
| 514 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 515 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 516 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 517 | "Color found, instead of Y-coord"); |
| 518 | error = MagickTrue; |
| 519 | break; |
| 520 | } |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 521 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 522 | /* color values for this control point */ |
| 523 | #if 0 |
| 524 | if ( (color_from_image ) { |
| 525 | /* get color from image */ |
| 526 | /* HOW??? */ |
| 527 | } |
| 528 | else |
| 529 | #endif |
| 530 | { |
| 531 | /* color name or function given in string argument */ |
| 532 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 533 | if ( token[0] == '\0' ) break; |
| 534 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 535 | /* Color string given */ |
| 536 | (void) QueryMagickColor(token,&color,exception); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 537 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 538 | sparse_arguments[x++] = QuantumScale*color.red; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 539 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 540 | sparse_arguments[x++] = QuantumScale*color.green; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 541 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 542 | sparse_arguments[x++] = QuantumScale*color.blue; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 543 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 544 | (image->colorspace == CMYKColorspace)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 545 | sparse_arguments[x++] = QuantumScale*color.black; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 546 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 547 | (image->matte != MagickFalse)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 548 | sparse_arguments[x++] = QuantumScale*color.alpha; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 549 | } |
| 550 | else { |
| 551 | /* Colors given as a set of floating point values - experimental */ |
| 552 | /* NB: token contains the first floating point value to use! */ |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 553 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 554 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 555 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 556 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 557 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 558 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 559 | token[0] = ','; /* used this token - get another */ |
| 560 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 561 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 562 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 563 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 564 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 565 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 566 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 567 | token[0] = ','; /* used this token - get another */ |
| 568 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 569 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 570 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 571 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 572 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 573 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 574 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 575 | token[0] = ','; /* used this token - get another */ |
| 576 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 577 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 578 | (image->colorspace == CMYKColorspace)) |
| 579 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 580 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 581 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 582 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 583 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 584 | token[0] = ','; /* used this token - get another */ |
| 585 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 586 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 587 | (image->matte != MagickFalse)) |
| 588 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 589 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 590 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 591 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 592 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 593 | token[0] = ','; /* used this token - get another */ |
| 594 | } |
| 595 | } |
| 596 | } |
| 597 | } |
| 598 | if ( number_arguments != x && !error ) { |
| 599 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
| 600 | "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error"); |
| 601 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 602 | return( (Image *)NULL); |
| 603 | } |
| 604 | if ( error ) |
| 605 | return( (Image *)NULL); |
| 606 | |
| 607 | /* Call the Interpolation function with the parsed arguments */ |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 608 | sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, |
| 609 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 610 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 611 | return( sparse_image ); |
| 612 | } |
| 613 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 614 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 615 | const char **argv,Image **image,ExceptionInfo *exception) |
| 616 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 617 | ChannelType |
| 618 | channel; |
| 619 | |
| 620 | const char |
| 621 | *format, |
| 622 | *option; |
| 623 | |
| 624 | DrawInfo |
| 625 | *draw_info; |
| 626 | |
| 627 | GeometryInfo |
| 628 | geometry_info; |
| 629 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 630 | Image |
| 631 | *region_image; |
| 632 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 633 | ImageInfo |
| 634 | *mogrify_info; |
| 635 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 636 | MagickStatusType |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 637 | status; |
| 638 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 639 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 640 | fill; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 641 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 642 | MagickStatusType |
| 643 | flags; |
| 644 | |
| 645 | QuantizeInfo |
| 646 | *quantize_info; |
| 647 | |
| 648 | RectangleInfo |
| 649 | geometry, |
| 650 | region_geometry; |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame] | 651 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 652 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 653 | i; |
| 654 | |
| 655 | /* |
| 656 | Initialize method variables. |
| 657 | */ |
| 658 | assert(image_info != (const ImageInfo *) NULL); |
| 659 | assert(image_info->signature == MagickSignature); |
| 660 | assert(image != (Image **) NULL); |
| 661 | assert((*image)->signature == MagickSignature); |
| 662 | if ((*image)->debug != MagickFalse) |
| 663 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); |
| 664 | if (argc < 0) |
| 665 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 666 | mogrify_info=CloneImageInfo(image_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 667 | draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL); |
| 668 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 669 | SetGeometryInfo(&geometry_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 670 | GetPixelInfo(*image,&fill); |
| 671 | SetPixelInfoPacket(*image,&(*image)->background_color,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 672 | channel=mogrify_info->channel; |
| 673 | format=GetImageOption(mogrify_info,"format"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 674 | SetGeometry(*image,®ion_geometry); |
| 675 | region_image=NewImageList(); |
| 676 | /* |
| 677 | Transmogrify the image. |
| 678 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 679 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 680 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 681 | Image |
| 682 | *mogrify_image; |
| 683 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 684 | ssize_t |
| 685 | count; |
| 686 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 687 | option=argv[i]; |
| 688 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 689 | continue; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 690 | count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option), |
| 691 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 692 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 693 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 694 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 695 | mogrify_image=(Image *)NULL; |
| 696 | switch (*(option+1)) |
| 697 | { |
| 698 | case 'a': |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 699 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 700 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 701 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 702 | /* |
| 703 | Adaptive blur image. |
| 704 | */ |
| 705 | (void) SyncImageSettings(mogrify_info,*image); |
| 706 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 707 | if ((flags & SigmaValue) == 0) |
| 708 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 709 | if ((flags & XiValue) == 0) |
| 710 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 711 | mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho, |
cristy | 4c11c2b | 2011-09-05 20:17:07 +0000 | [diff] [blame] | 712 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 713 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 714 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 715 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 716 | { |
| 717 | /* |
| 718 | Adaptive resize image. |
| 719 | */ |
| 720 | (void) SyncImageSettings(mogrify_info,*image); |
| 721 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 722 | mogrify_image=AdaptiveResizeImage(*image,geometry.width, |
| 723 | geometry.height,exception); |
| 724 | break; |
| 725 | } |
| 726 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 727 | { |
| 728 | /* |
| 729 | Adaptive sharpen image. |
| 730 | */ |
| 731 | (void) SyncImageSettings(mogrify_info,*image); |
| 732 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 733 | if ((flags & SigmaValue) == 0) |
| 734 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 735 | if ((flags & XiValue) == 0) |
| 736 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 737 | mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho, |
cristy | 4c11c2b | 2011-09-05 20:17:07 +0000 | [diff] [blame] | 738 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 739 | break; |
| 740 | } |
| 741 | if (LocaleCompare("affine",option+1) == 0) |
| 742 | { |
| 743 | /* |
| 744 | Affine matrix. |
| 745 | */ |
| 746 | if (*option == '+') |
| 747 | { |
| 748 | GetAffineMatrix(&draw_info->affine); |
| 749 | break; |
| 750 | } |
| 751 | (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); |
| 752 | break; |
| 753 | } |
| 754 | if (LocaleCompare("alpha",option+1) == 0) |
| 755 | { |
| 756 | AlphaChannelType |
| 757 | alpha_type; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 758 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 759 | (void) SyncImageSettings(mogrify_info,*image); |
| 760 | alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions, |
| 761 | MagickFalse,argv[i+1]); |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 762 | (void) SetImageAlphaChannel(*image,alpha_type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 763 | break; |
| 764 | } |
| 765 | if (LocaleCompare("annotate",option+1) == 0) |
| 766 | { |
| 767 | char |
| 768 | *text, |
| 769 | geometry[MaxTextExtent]; |
| 770 | |
| 771 | /* |
| 772 | Annotate image. |
| 773 | */ |
| 774 | (void) SyncImageSettings(mogrify_info,*image); |
| 775 | SetGeometryInfo(&geometry_info); |
| 776 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 777 | if ((flags & SigmaValue) == 0) |
| 778 | geometry_info.sigma=geometry_info.rho; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 779 | text=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 780 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 781 | if (text == (char *) NULL) |
| 782 | break; |
| 783 | (void) CloneString(&draw_info->text,text); |
| 784 | text=DestroyString(text); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 785 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 786 | geometry_info.xi,geometry_info.psi); |
| 787 | (void) CloneString(&draw_info->geometry,geometry); |
| 788 | draw_info->affine.sx=cos(DegreesToRadians( |
| 789 | fmod(geometry_info.rho,360.0))); |
| 790 | draw_info->affine.rx=sin(DegreesToRadians( |
| 791 | fmod(geometry_info.rho,360.0))); |
| 792 | draw_info->affine.ry=(-sin(DegreesToRadians( |
| 793 | fmod(geometry_info.sigma,360.0)))); |
| 794 | draw_info->affine.sy=cos(DegreesToRadians( |
| 795 | fmod(geometry_info.sigma,360.0))); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 796 | (void) AnnotateImage(*image,draw_info,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 797 | break; |
| 798 | } |
| 799 | if (LocaleCompare("antialias",option+1) == 0) |
| 800 | { |
| 801 | draw_info->stroke_antialias=(*option == '-') ? MagickTrue : |
| 802 | MagickFalse; |
| 803 | draw_info->text_antialias=(*option == '-') ? MagickTrue : |
| 804 | MagickFalse; |
| 805 | break; |
| 806 | } |
| 807 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 808 | { |
| 809 | /* |
| 810 | Auto Adjust Gamma of image based on its mean |
| 811 | */ |
| 812 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 9511120 | 2011-08-09 19:41:42 +0000 | [diff] [blame] | 813 | (void) AutoGammaImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 814 | break; |
| 815 | } |
| 816 | if (LocaleCompare("auto-level",option+1) == 0) |
| 817 | { |
| 818 | /* |
| 819 | Perfectly Normalize (max/min stretch) the image |
| 820 | */ |
| 821 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 9511120 | 2011-08-09 19:41:42 +0000 | [diff] [blame] | 822 | (void) AutoLevelImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 823 | break; |
| 824 | } |
| 825 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 826 | { |
| 827 | (void) SyncImageSettings(mogrify_info,*image); |
| 828 | switch ((*image)->orientation) |
| 829 | { |
| 830 | case TopRightOrientation: |
| 831 | { |
| 832 | mogrify_image=FlopImage(*image,exception); |
| 833 | break; |
| 834 | } |
| 835 | case BottomRightOrientation: |
| 836 | { |
| 837 | mogrify_image=RotateImage(*image,180.0,exception); |
| 838 | break; |
| 839 | } |
| 840 | case BottomLeftOrientation: |
| 841 | { |
| 842 | mogrify_image=FlipImage(*image,exception); |
| 843 | break; |
| 844 | } |
| 845 | case LeftTopOrientation: |
| 846 | { |
| 847 | mogrify_image=TransposeImage(*image,exception); |
| 848 | break; |
| 849 | } |
| 850 | case RightTopOrientation: |
| 851 | { |
| 852 | mogrify_image=RotateImage(*image,90.0,exception); |
| 853 | break; |
| 854 | } |
| 855 | case RightBottomOrientation: |
| 856 | { |
| 857 | mogrify_image=TransverseImage(*image,exception); |
| 858 | break; |
| 859 | } |
| 860 | case LeftBottomOrientation: |
| 861 | { |
| 862 | mogrify_image=RotateImage(*image,270.0,exception); |
| 863 | break; |
| 864 | } |
| 865 | default: |
| 866 | break; |
| 867 | } |
| 868 | if (mogrify_image != (Image *) NULL) |
| 869 | mogrify_image->orientation=TopLeftOrientation; |
| 870 | break; |
| 871 | } |
| 872 | break; |
| 873 | } |
| 874 | case 'b': |
| 875 | { |
| 876 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 877 | { |
| 878 | /* |
| 879 | Black threshold image. |
| 880 | */ |
| 881 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 882 | (void) BlackThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 883 | InheritException(exception,&(*image)->exception); |
| 884 | break; |
| 885 | } |
| 886 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 887 | { |
| 888 | /* |
| 889 | Blue shift image. |
| 890 | */ |
| 891 | (void) SyncImageSettings(mogrify_info,*image); |
| 892 | geometry_info.rho=1.5; |
| 893 | if (*option == '-') |
| 894 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 895 | mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception); |
| 896 | break; |
| 897 | } |
| 898 | if (LocaleCompare("blur",option+1) == 0) |
| 899 | { |
| 900 | /* |
| 901 | Gaussian blur image. |
| 902 | */ |
| 903 | (void) SyncImageSettings(mogrify_info,*image); |
| 904 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 905 | if ((flags & SigmaValue) == 0) |
| 906 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 907 | if ((flags & XiValue) == 0) |
| 908 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 909 | mogrify_image=BlurImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 910 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 911 | break; |
| 912 | } |
| 913 | if (LocaleCompare("border",option+1) == 0) |
| 914 | { |
| 915 | /* |
| 916 | Surround image with a border of solid color. |
| 917 | */ |
| 918 | (void) SyncImageSettings(mogrify_info,*image); |
| 919 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 920 | if ((flags & SigmaValue) == 0) |
| 921 | geometry.height=geometry.width; |
| 922 | mogrify_image=BorderImage(*image,&geometry,exception); |
| 923 | break; |
| 924 | } |
| 925 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 926 | { |
| 927 | if (*option == '+') |
| 928 | { |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 929 | (void) QueryColorDatabase(MogrifyBorderColor, |
| 930 | &draw_info->border_color,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 931 | break; |
| 932 | } |
| 933 | (void) QueryColorDatabase(argv[i+1],&draw_info->border_color, |
| 934 | exception); |
| 935 | break; |
| 936 | } |
| 937 | if (LocaleCompare("box",option+1) == 0) |
| 938 | { |
| 939 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 940 | exception); |
| 941 | break; |
| 942 | } |
| 943 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 944 | { |
| 945 | double |
| 946 | brightness, |
| 947 | contrast; |
| 948 | |
| 949 | GeometryInfo |
| 950 | geometry_info; |
| 951 | |
| 952 | MagickStatusType |
| 953 | flags; |
| 954 | |
| 955 | /* |
| 956 | Brightness / contrast image. |
| 957 | */ |
| 958 | (void) SyncImageSettings(mogrify_info,*image); |
| 959 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 960 | brightness=geometry_info.rho; |
| 961 | contrast=0.0; |
| 962 | if ((flags & SigmaValue) != 0) |
| 963 | contrast=geometry_info.sigma; |
cristy | 444eda6 | 2011-08-10 02:07:46 +0000 | [diff] [blame] | 964 | (void) BrightnessContrastImage(*image,brightness,contrast, |
| 965 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 966 | InheritException(exception,&(*image)->exception); |
| 967 | break; |
| 968 | } |
| 969 | break; |
| 970 | } |
| 971 | case 'c': |
| 972 | { |
| 973 | if (LocaleCompare("cdl",option+1) == 0) |
| 974 | { |
| 975 | char |
| 976 | *color_correction_collection; |
| 977 | |
| 978 | /* |
| 979 | Color correct with a color decision list. |
| 980 | */ |
| 981 | (void) SyncImageSettings(mogrify_info,*image); |
| 982 | color_correction_collection=FileToString(argv[i+1],~0,exception); |
| 983 | if (color_correction_collection == (char *) NULL) |
| 984 | break; |
cristy | 1bfa9f0 | 2011-08-11 02:35:43 +0000 | [diff] [blame] | 985 | (void) ColorDecisionListImage(*image,color_correction_collection, |
| 986 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 987 | InheritException(exception,&(*image)->exception); |
| 988 | break; |
| 989 | } |
| 990 | if (LocaleCompare("channel",option+1) == 0) |
| 991 | { |
| 992 | if (*option == '+') |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 993 | channel=DefaultChannels; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 994 | else |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 995 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 996 | SetPixelChannelMap(*image,channel); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 997 | break; |
| 998 | } |
| 999 | if (LocaleCompare("charcoal",option+1) == 0) |
| 1000 | { |
| 1001 | /* |
| 1002 | Charcoal image. |
| 1003 | */ |
| 1004 | (void) SyncImageSettings(mogrify_info,*image); |
| 1005 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1006 | if ((flags & SigmaValue) == 0) |
| 1007 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1008 | if ((flags & XiValue) == 0) |
| 1009 | geometry_info.xi=1.0; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1010 | mogrify_image=CharcoalImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1011 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1012 | break; |
| 1013 | } |
| 1014 | if (LocaleCompare("chop",option+1) == 0) |
| 1015 | { |
| 1016 | /* |
| 1017 | Chop the image. |
| 1018 | */ |
| 1019 | (void) SyncImageSettings(mogrify_info,*image); |
| 1020 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1021 | mogrify_image=ChopImage(*image,&geometry,exception); |
| 1022 | break; |
| 1023 | } |
| 1024 | if (LocaleCompare("clamp",option+1) == 0) |
| 1025 | { |
| 1026 | /* |
| 1027 | Clamp image. |
| 1028 | */ |
| 1029 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1030 | (void) ClampImage(*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1031 | InheritException(exception,&(*image)->exception); |
| 1032 | break; |
| 1033 | } |
| 1034 | if (LocaleCompare("clip",option+1) == 0) |
| 1035 | { |
| 1036 | (void) SyncImageSettings(mogrify_info,*image); |
| 1037 | if (*option == '+') |
| 1038 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1039 | (void) SetImageClipMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1040 | break; |
| 1041 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1042 | (void) ClipImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1043 | break; |
| 1044 | } |
| 1045 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1046 | { |
| 1047 | CacheView |
| 1048 | *mask_view; |
| 1049 | |
| 1050 | Image |
| 1051 | *mask_image; |
| 1052 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1053 | register Quantum |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1054 | *restrict q; |
| 1055 | |
| 1056 | register ssize_t |
| 1057 | x; |
| 1058 | |
| 1059 | ssize_t |
| 1060 | y; |
| 1061 | |
| 1062 | (void) SyncImageSettings(mogrify_info,*image); |
| 1063 | if (*option == '+') |
| 1064 | { |
| 1065 | /* |
| 1066 | Remove a mask. |
| 1067 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1068 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1069 | break; |
| 1070 | } |
| 1071 | /* |
| 1072 | Set the image mask. |
| 1073 | FUTURE: This Should Be a SetImageAlphaChannel() call, Or two. |
| 1074 | */ |
| 1075 | mask_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1076 | if (mask_image == (Image *) NULL) |
| 1077 | break; |
cristy | 574cc26 | 2011-08-05 01:23:58 +0000 | [diff] [blame] | 1078 | if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1079 | return(MagickFalse); |
| 1080 | mask_view=AcquireCacheView(mask_image); |
| 1081 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1082 | { |
| 1083 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1084 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 1085 | if (q == (Quantum *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1086 | break; |
| 1087 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1088 | { |
| 1089 | if (mask_image->matte == MagickFalse) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1090 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 1091 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1092 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1093 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1094 | q+=GetPixelChannels(mask_image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1095 | } |
| 1096 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
| 1097 | break; |
| 1098 | } |
| 1099 | mask_view=DestroyCacheView(mask_view); |
| 1100 | mask_image->matte=MagickTrue; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1101 | (void) SetImageClipMask(*image,mask_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1102 | InheritException(exception,&(*image)->exception); |
| 1103 | break; |
| 1104 | } |
| 1105 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1106 | { |
| 1107 | (void) SyncImageSettings(mogrify_info,*image); |
| 1108 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1109 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1110 | break; |
| 1111 | } |
| 1112 | if (LocaleCompare("colorize",option+1) == 0) |
| 1113 | { |
| 1114 | /* |
| 1115 | Colorize the image. |
| 1116 | */ |
| 1117 | (void) SyncImageSettings(mogrify_info,*image); |
| 1118 | mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill, |
| 1119 | exception); |
| 1120 | break; |
| 1121 | } |
| 1122 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1123 | { |
| 1124 | KernelInfo |
| 1125 | *kernel; |
| 1126 | |
| 1127 | (void) SyncImageSettings(mogrify_info,*image); |
| 1128 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1129 | if (kernel == (KernelInfo *) NULL) |
| 1130 | break; |
| 1131 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 1132 | kernel=DestroyKernelInfo(kernel); |
| 1133 | break; |
| 1134 | } |
| 1135 | if (LocaleCompare("colors",option+1) == 0) |
| 1136 | { |
| 1137 | /* |
| 1138 | Reduce the number of colors in the image. |
| 1139 | */ |
| 1140 | (void) SyncImageSettings(mogrify_info,*image); |
| 1141 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
| 1142 | if (quantize_info->number_colors == 0) |
| 1143 | break; |
| 1144 | if (((*image)->storage_class == DirectClass) || |
| 1145 | (*image)->colors > quantize_info->number_colors) |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1146 | (void) QuantizeImage(quantize_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1147 | else |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1148 | (void) CompressImageColormap(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1149 | break; |
| 1150 | } |
| 1151 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1152 | { |
| 1153 | ColorspaceType |
| 1154 | colorspace; |
| 1155 | |
| 1156 | (void) SyncImageSettings(mogrify_info,*image); |
| 1157 | if (*option == '+') |
| 1158 | { |
| 1159 | (void) TransformImageColorspace(*image,RGBColorspace); |
| 1160 | InheritException(exception,&(*image)->exception); |
| 1161 | break; |
| 1162 | } |
| 1163 | colorspace=(ColorspaceType) ParseCommandOption( |
| 1164 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 1165 | (void) TransformImageColorspace(*image,colorspace); |
| 1166 | InheritException(exception,&(*image)->exception); |
| 1167 | break; |
| 1168 | } |
| 1169 | if (LocaleCompare("contrast",option+1) == 0) |
| 1170 | { |
| 1171 | (void) SyncImageSettings(mogrify_info,*image); |
| 1172 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1173 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1174 | break; |
| 1175 | } |
| 1176 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1177 | { |
| 1178 | double |
| 1179 | black_point, |
| 1180 | white_point; |
| 1181 | |
| 1182 | MagickStatusType |
| 1183 | flags; |
| 1184 | |
| 1185 | /* |
| 1186 | Contrast stretch image. |
| 1187 | */ |
| 1188 | (void) SyncImageSettings(mogrify_info,*image); |
| 1189 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1190 | black_point=geometry_info.rho; |
| 1191 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1192 | black_point; |
| 1193 | if ((flags & PercentValue) != 0) |
| 1194 | { |
| 1195 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1196 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1197 | } |
| 1198 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1199 | white_point; |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1200 | (void) ContrastStretchImage(*image,black_point,white_point, |
| 1201 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1202 | InheritException(exception,&(*image)->exception); |
| 1203 | break; |
| 1204 | } |
| 1205 | if (LocaleCompare("convolve",option+1) == 0) |
| 1206 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1207 | KernelInfo |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1208 | *kernel_info; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1209 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1210 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1211 | kernel_info=AcquireKernelInfo(argv[i+1]); |
| 1212 | if (kernel_info == (KernelInfo *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1213 | break; |
cristy | 0a92238 | 2011-07-16 15:30:34 +0000 | [diff] [blame] | 1214 | kernel_info->bias=(*image)->bias; |
cristy | 5e6be1e | 2011-07-16 01:23:39 +0000 | [diff] [blame] | 1215 | mogrify_image=ConvolveImage(*image,kernel_info,exception); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1216 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1217 | break; |
| 1218 | } |
| 1219 | if (LocaleCompare("crop",option+1) == 0) |
| 1220 | { |
| 1221 | /* |
| 1222 | Crop a image to a smaller size |
| 1223 | */ |
| 1224 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1225 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1226 | break; |
| 1227 | } |
| 1228 | if (LocaleCompare("cycle",option+1) == 0) |
| 1229 | { |
| 1230 | /* |
| 1231 | Cycle an image colormap. |
| 1232 | */ |
| 1233 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1234 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]), |
| 1235 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1236 | break; |
| 1237 | } |
| 1238 | break; |
| 1239 | } |
| 1240 | case 'd': |
| 1241 | { |
| 1242 | if (LocaleCompare("decipher",option+1) == 0) |
| 1243 | { |
| 1244 | StringInfo |
| 1245 | *passkey; |
| 1246 | |
| 1247 | /* |
| 1248 | Decipher pixels. |
| 1249 | */ |
| 1250 | (void) SyncImageSettings(mogrify_info,*image); |
| 1251 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1252 | if (passkey != (StringInfo *) NULL) |
| 1253 | { |
| 1254 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1255 | passkey=DestroyStringInfo(passkey); |
| 1256 | } |
| 1257 | break; |
| 1258 | } |
| 1259 | if (LocaleCompare("density",option+1) == 0) |
| 1260 | { |
| 1261 | /* |
| 1262 | Set image density. |
| 1263 | */ |
| 1264 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1265 | break; |
| 1266 | } |
| 1267 | if (LocaleCompare("depth",option+1) == 0) |
| 1268 | { |
| 1269 | (void) SyncImageSettings(mogrify_info,*image); |
| 1270 | if (*option == '+') |
| 1271 | { |
| 1272 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH); |
| 1273 | break; |
| 1274 | } |
| 1275 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1])); |
| 1276 | break; |
| 1277 | } |
| 1278 | if (LocaleCompare("deskew",option+1) == 0) |
| 1279 | { |
| 1280 | double |
| 1281 | threshold; |
| 1282 | |
| 1283 | /* |
| 1284 | Straighten the image. |
| 1285 | */ |
| 1286 | (void) SyncImageSettings(mogrify_info,*image); |
| 1287 | if (*option == '+') |
| 1288 | threshold=40.0*QuantumRange/100.0; |
| 1289 | else |
| 1290 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 1291 | mogrify_image=DeskewImage(*image,threshold,exception); |
| 1292 | break; |
| 1293 | } |
| 1294 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1295 | { |
| 1296 | /* |
| 1297 | Reduce the speckles within an image. |
| 1298 | */ |
| 1299 | (void) SyncImageSettings(mogrify_info,*image); |
| 1300 | mogrify_image=DespeckleImage(*image,exception); |
| 1301 | break; |
| 1302 | } |
| 1303 | if (LocaleCompare("display",option+1) == 0) |
| 1304 | { |
| 1305 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1306 | break; |
| 1307 | } |
| 1308 | if (LocaleCompare("distort",option+1) == 0) |
| 1309 | { |
| 1310 | char |
| 1311 | *args, |
| 1312 | token[MaxTextExtent]; |
| 1313 | |
| 1314 | const char |
| 1315 | *p; |
| 1316 | |
| 1317 | DistortImageMethod |
| 1318 | method; |
| 1319 | |
| 1320 | double |
| 1321 | *arguments; |
| 1322 | |
| 1323 | register ssize_t |
| 1324 | x; |
| 1325 | |
| 1326 | size_t |
| 1327 | number_arguments; |
| 1328 | |
| 1329 | /* |
| 1330 | Distort image. |
| 1331 | */ |
| 1332 | (void) SyncImageSettings(mogrify_info,*image); |
| 1333 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, |
| 1334 | MagickFalse,argv[i+1]); |
| 1335 | if ( method == ResizeDistortion ) |
| 1336 | { |
| 1337 | /* Special Case - Argument is actually a resize geometry! |
| 1338 | ** Convert that to an appropriate distortion argument array. |
| 1339 | */ |
| 1340 | double |
| 1341 | resize_args[2]; |
| 1342 | (void) ParseRegionGeometry(*image,argv[i+2],&geometry, |
| 1343 | exception); |
| 1344 | resize_args[0]=(double)geometry.width; |
| 1345 | resize_args[1]=(double)geometry.height; |
| 1346 | mogrify_image=DistortImage(*image,method,(size_t)2, |
| 1347 | resize_args,MagickTrue,exception); |
| 1348 | break; |
| 1349 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1350 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1351 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1352 | if (args == (char *) NULL) |
| 1353 | break; |
| 1354 | p=(char *) args; |
| 1355 | for (x=0; *p != '\0'; x++) |
| 1356 | { |
| 1357 | GetMagickToken(p,&p,token); |
| 1358 | if (*token == ',') |
| 1359 | GetMagickToken(p,&p,token); |
| 1360 | } |
| 1361 | number_arguments=(size_t) x; |
| 1362 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1363 | sizeof(*arguments)); |
| 1364 | if (arguments == (double *) NULL) |
| 1365 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1366 | "MemoryAllocationFailed",(*image)->filename); |
| 1367 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1368 | sizeof(*arguments)); |
| 1369 | p=(char *) args; |
| 1370 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 1371 | { |
| 1372 | GetMagickToken(p,&p,token); |
| 1373 | if (*token == ',') |
| 1374 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1375 | arguments[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1376 | } |
| 1377 | args=DestroyString(args); |
| 1378 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
| 1379 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1380 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1381 | break; |
| 1382 | } |
| 1383 | if (LocaleCompare("dither",option+1) == 0) |
| 1384 | { |
| 1385 | if (*option == '+') |
| 1386 | { |
| 1387 | quantize_info->dither=MagickFalse; |
| 1388 | break; |
| 1389 | } |
| 1390 | quantize_info->dither=MagickTrue; |
| 1391 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
| 1392 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1393 | if (quantize_info->dither_method == NoDitherMethod) |
| 1394 | quantize_info->dither=MagickFalse; |
| 1395 | break; |
| 1396 | } |
| 1397 | if (LocaleCompare("draw",option+1) == 0) |
| 1398 | { |
| 1399 | /* |
| 1400 | Draw image. |
| 1401 | */ |
| 1402 | (void) SyncImageSettings(mogrify_info,*image); |
| 1403 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1404 | (void) DrawImage(*image,draw_info,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1405 | break; |
| 1406 | } |
| 1407 | break; |
| 1408 | } |
| 1409 | case 'e': |
| 1410 | { |
| 1411 | if (LocaleCompare("edge",option+1) == 0) |
| 1412 | { |
| 1413 | /* |
| 1414 | Enhance edges in the image. |
| 1415 | */ |
| 1416 | (void) SyncImageSettings(mogrify_info,*image); |
| 1417 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1418 | if ((flags & SigmaValue) == 0) |
| 1419 | geometry_info.sigma=1.0; |
cristy | 8ae632d | 2011-09-05 17:29:53 +0000 | [diff] [blame] | 1420 | mogrify_image=EdgeImage(*image,geometry_info.rho, |
| 1421 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1422 | break; |
| 1423 | } |
| 1424 | if (LocaleCompare("emboss",option+1) == 0) |
| 1425 | { |
| 1426 | /* |
| 1427 | Gaussian embossen image. |
| 1428 | */ |
| 1429 | (void) SyncImageSettings(mogrify_info,*image); |
| 1430 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1431 | if ((flags & SigmaValue) == 0) |
| 1432 | geometry_info.sigma=1.0; |
| 1433 | mogrify_image=EmbossImage(*image,geometry_info.rho, |
| 1434 | geometry_info.sigma,exception); |
| 1435 | break; |
| 1436 | } |
| 1437 | if (LocaleCompare("encipher",option+1) == 0) |
| 1438 | { |
| 1439 | StringInfo |
| 1440 | *passkey; |
| 1441 | |
| 1442 | /* |
| 1443 | Encipher pixels. |
| 1444 | */ |
| 1445 | (void) SyncImageSettings(mogrify_info,*image); |
| 1446 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1447 | if (passkey != (StringInfo *) NULL) |
| 1448 | { |
| 1449 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1450 | passkey=DestroyStringInfo(passkey); |
| 1451 | } |
| 1452 | break; |
| 1453 | } |
| 1454 | if (LocaleCompare("encoding",option+1) == 0) |
| 1455 | { |
| 1456 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1457 | break; |
| 1458 | } |
| 1459 | if (LocaleCompare("enhance",option+1) == 0) |
| 1460 | { |
| 1461 | /* |
| 1462 | Enhance image. |
| 1463 | */ |
| 1464 | (void) SyncImageSettings(mogrify_info,*image); |
| 1465 | mogrify_image=EnhanceImage(*image,exception); |
| 1466 | break; |
| 1467 | } |
| 1468 | if (LocaleCompare("equalize",option+1) == 0) |
| 1469 | { |
| 1470 | /* |
| 1471 | Equalize image. |
| 1472 | */ |
| 1473 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 6d8c3d7 | 2011-08-22 01:20:01 +0000 | [diff] [blame] | 1474 | (void) EqualizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1475 | break; |
| 1476 | } |
| 1477 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1478 | { |
| 1479 | double |
| 1480 | constant; |
| 1481 | |
| 1482 | MagickEvaluateOperator |
| 1483 | op; |
| 1484 | |
| 1485 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1486 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 1487 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1488 | constant=SiPrefixToDouble(argv[i+2],QuantumRange); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1489 | (void) EvaluateImage(*image,op,constant,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1490 | break; |
| 1491 | } |
| 1492 | if (LocaleCompare("extent",option+1) == 0) |
| 1493 | { |
| 1494 | /* |
| 1495 | Set the image extent. |
| 1496 | */ |
| 1497 | (void) SyncImageSettings(mogrify_info,*image); |
| 1498 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1499 | if (geometry.width == 0) |
| 1500 | geometry.width=(*image)->columns; |
| 1501 | if (geometry.height == 0) |
| 1502 | geometry.height=(*image)->rows; |
| 1503 | mogrify_image=ExtentImage(*image,&geometry,exception); |
| 1504 | break; |
| 1505 | } |
| 1506 | break; |
| 1507 | } |
| 1508 | case 'f': |
| 1509 | { |
| 1510 | if (LocaleCompare("family",option+1) == 0) |
| 1511 | { |
| 1512 | if (*option == '+') |
| 1513 | { |
| 1514 | if (draw_info->family != (char *) NULL) |
| 1515 | draw_info->family=DestroyString(draw_info->family); |
| 1516 | break; |
| 1517 | } |
| 1518 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1519 | break; |
| 1520 | } |
| 1521 | if (LocaleCompare("features",option+1) == 0) |
| 1522 | { |
| 1523 | if (*option == '+') |
| 1524 | { |
| 1525 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1526 | break; |
| 1527 | } |
| 1528 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1529 | break; |
| 1530 | } |
| 1531 | if (LocaleCompare("fill",option+1) == 0) |
| 1532 | { |
| 1533 | ExceptionInfo |
| 1534 | *sans; |
| 1535 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1536 | GetPixelInfo(*image,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1537 | if (*option == '+') |
| 1538 | { |
| 1539 | (void) QueryMagickColor("none",&fill,exception); |
| 1540 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 1541 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1542 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1543 | break; |
| 1544 | } |
| 1545 | sans=AcquireExceptionInfo(); |
| 1546 | (void) QueryMagickColor(argv[i+1],&fill,sans); |
| 1547 | status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans); |
| 1548 | sans=DestroyExceptionInfo(sans); |
| 1549 | if (status == MagickFalse) |
| 1550 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 1551 | exception); |
| 1552 | break; |
| 1553 | } |
| 1554 | if (LocaleCompare("flip",option+1) == 0) |
| 1555 | { |
| 1556 | /* |
| 1557 | Flip image scanlines. |
| 1558 | */ |
| 1559 | (void) SyncImageSettings(mogrify_info,*image); |
| 1560 | mogrify_image=FlipImage(*image,exception); |
| 1561 | break; |
| 1562 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1563 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1564 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1565 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1566 | target; |
| 1567 | |
| 1568 | /* |
| 1569 | Floodfill image. |
| 1570 | */ |
| 1571 | (void) SyncImageSettings(mogrify_info,*image); |
| 1572 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1573 | (void) QueryMagickColor(argv[i+2],&target,exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1574 | (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x, |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 1575 | geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1576 | break; |
| 1577 | } |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1578 | if (LocaleCompare("flop",option+1) == 0) |
| 1579 | { |
| 1580 | /* |
| 1581 | Flop image scanlines. |
| 1582 | */ |
| 1583 | (void) SyncImageSettings(mogrify_info,*image); |
| 1584 | mogrify_image=FlopImage(*image,exception); |
| 1585 | break; |
| 1586 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1587 | if (LocaleCompare("font",option+1) == 0) |
| 1588 | { |
| 1589 | if (*option == '+') |
| 1590 | { |
| 1591 | if (draw_info->font != (char *) NULL) |
| 1592 | draw_info->font=DestroyString(draw_info->font); |
| 1593 | break; |
| 1594 | } |
| 1595 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1596 | break; |
| 1597 | } |
| 1598 | if (LocaleCompare("format",option+1) == 0) |
| 1599 | { |
| 1600 | format=argv[i+1]; |
| 1601 | break; |
| 1602 | } |
| 1603 | if (LocaleCompare("frame",option+1) == 0) |
| 1604 | { |
| 1605 | FrameInfo |
| 1606 | frame_info; |
| 1607 | |
| 1608 | /* |
| 1609 | Surround image with an ornamental border. |
| 1610 | */ |
| 1611 | (void) SyncImageSettings(mogrify_info,*image); |
| 1612 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1613 | frame_info.width=geometry.width; |
| 1614 | frame_info.height=geometry.height; |
| 1615 | if ((flags & HeightValue) == 0) |
| 1616 | frame_info.height=geometry.width; |
| 1617 | frame_info.outer_bevel=geometry.x; |
| 1618 | frame_info.inner_bevel=geometry.y; |
| 1619 | frame_info.x=(ssize_t) frame_info.width; |
| 1620 | frame_info.y=(ssize_t) frame_info.height; |
| 1621 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1622 | frame_info.height=(*image)->rows+2*frame_info.height; |
| 1623 | mogrify_image=FrameImage(*image,&frame_info,exception); |
| 1624 | break; |
| 1625 | } |
| 1626 | if (LocaleCompare("function",option+1) == 0) |
| 1627 | { |
| 1628 | char |
| 1629 | *arguments, |
| 1630 | token[MaxTextExtent]; |
| 1631 | |
| 1632 | const char |
| 1633 | *p; |
| 1634 | |
| 1635 | double |
| 1636 | *parameters; |
| 1637 | |
| 1638 | MagickFunction |
| 1639 | function; |
| 1640 | |
| 1641 | register ssize_t |
| 1642 | x; |
| 1643 | |
| 1644 | size_t |
| 1645 | number_parameters; |
| 1646 | |
| 1647 | /* |
| 1648 | Function Modify Image Values |
| 1649 | */ |
| 1650 | (void) SyncImageSettings(mogrify_info,*image); |
| 1651 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, |
| 1652 | MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1653 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1654 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1655 | if (arguments == (char *) NULL) |
| 1656 | break; |
| 1657 | p=(char *) arguments; |
| 1658 | for (x=0; *p != '\0'; x++) |
| 1659 | { |
| 1660 | GetMagickToken(p,&p,token); |
| 1661 | if (*token == ',') |
| 1662 | GetMagickToken(p,&p,token); |
| 1663 | } |
| 1664 | number_parameters=(size_t) x; |
| 1665 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1666 | sizeof(*parameters)); |
| 1667 | if (parameters == (double *) NULL) |
| 1668 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1669 | "MemoryAllocationFailed",(*image)->filename); |
| 1670 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1671 | sizeof(*parameters)); |
| 1672 | p=(char *) arguments; |
| 1673 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
| 1674 | { |
| 1675 | GetMagickToken(p,&p,token); |
| 1676 | if (*token == ',') |
| 1677 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1678 | parameters[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1679 | } |
| 1680 | arguments=DestroyString(arguments); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1681 | (void) FunctionImage(*image,function,number_parameters,parameters, |
| 1682 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1683 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1684 | break; |
| 1685 | } |
| 1686 | break; |
| 1687 | } |
| 1688 | case 'g': |
| 1689 | { |
| 1690 | if (LocaleCompare("gamma",option+1) == 0) |
| 1691 | { |
| 1692 | /* |
| 1693 | Gamma image. |
| 1694 | */ |
| 1695 | (void) SyncImageSettings(mogrify_info,*image); |
| 1696 | if (*option == '+') |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1697 | (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1698 | else |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 1699 | (void) GammaImage(*image,InterpretLocaleValue(argv[i+1], |
| 1700 | (char **) NULL),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1701 | break; |
| 1702 | } |
| 1703 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1704 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1705 | { |
| 1706 | /* |
| 1707 | Gaussian blur image. |
| 1708 | */ |
| 1709 | (void) SyncImageSettings(mogrify_info,*image); |
| 1710 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1711 | if ((flags & SigmaValue) == 0) |
| 1712 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1713 | if ((flags & XiValue) == 0) |
| 1714 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1715 | mogrify_image=GaussianBlurImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1716 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1717 | break; |
| 1718 | } |
| 1719 | if (LocaleCompare("geometry",option+1) == 0) |
| 1720 | { |
| 1721 | /* |
| 1722 | Record Image offset, Resize last image. |
| 1723 | */ |
| 1724 | (void) SyncImageSettings(mogrify_info,*image); |
| 1725 | if (*option == '+') |
| 1726 | { |
| 1727 | if ((*image)->geometry != (char *) NULL) |
| 1728 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1729 | break; |
| 1730 | } |
| 1731 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1732 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1733 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1734 | else |
| 1735 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 1736 | (*image)->filter,(*image)->blur,exception); |
| 1737 | break; |
| 1738 | } |
| 1739 | if (LocaleCompare("gravity",option+1) == 0) |
| 1740 | { |
| 1741 | if (*option == '+') |
| 1742 | { |
| 1743 | draw_info->gravity=UndefinedGravity; |
| 1744 | break; |
| 1745 | } |
| 1746 | draw_info->gravity=(GravityType) ParseCommandOption( |
| 1747 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1748 | break; |
| 1749 | } |
| 1750 | break; |
| 1751 | } |
| 1752 | case 'h': |
| 1753 | { |
| 1754 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1755 | { |
| 1756 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1757 | break; |
| 1758 | } |
| 1759 | break; |
| 1760 | } |
| 1761 | case 'i': |
| 1762 | { |
| 1763 | if (LocaleCompare("identify",option+1) == 0) |
| 1764 | { |
| 1765 | char |
| 1766 | *text; |
| 1767 | |
| 1768 | (void) SyncImageSettings(mogrify_info,*image); |
| 1769 | if (format == (char *) NULL) |
| 1770 | { |
cristy | a403727 | 2011-08-28 15:11:39 +0000 | [diff] [blame] | 1771 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose, |
| 1772 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1773 | break; |
| 1774 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1775 | text=InterpretImageProperties(mogrify_info,*image,format, |
| 1776 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1777 | if (text == (char *) NULL) |
| 1778 | break; |
| 1779 | (void) fputs(text,stdout); |
| 1780 | (void) fputc('\n',stdout); |
| 1781 | text=DestroyString(text); |
| 1782 | break; |
| 1783 | } |
| 1784 | if (LocaleCompare("implode",option+1) == 0) |
| 1785 | { |
| 1786 | /* |
| 1787 | Implode image. |
| 1788 | */ |
| 1789 | (void) SyncImageSettings(mogrify_info,*image); |
| 1790 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1791 | mogrify_image=ImplodeImage(*image,geometry_info.rho,exception); |
| 1792 | break; |
| 1793 | } |
| 1794 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1795 | { |
| 1796 | if (*option == '+') |
| 1797 | (void) ParseGeometry("0",&geometry_info); |
| 1798 | else |
| 1799 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1800 | draw_info->interline_spacing=geometry_info.rho; |
| 1801 | break; |
| 1802 | } |
| 1803 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1804 | { |
| 1805 | if (*option == '+') |
| 1806 | (void) ParseGeometry("0",&geometry_info); |
| 1807 | else |
| 1808 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1809 | draw_info->interword_spacing=geometry_info.rho; |
| 1810 | break; |
| 1811 | } |
| 1812 | break; |
| 1813 | } |
| 1814 | case 'k': |
| 1815 | { |
| 1816 | if (LocaleCompare("kerning",option+1) == 0) |
| 1817 | { |
| 1818 | if (*option == '+') |
| 1819 | (void) ParseGeometry("0",&geometry_info); |
| 1820 | else |
| 1821 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1822 | draw_info->kerning=geometry_info.rho; |
| 1823 | break; |
| 1824 | } |
| 1825 | break; |
| 1826 | } |
| 1827 | case 'l': |
| 1828 | { |
| 1829 | if (LocaleCompare("lat",option+1) == 0) |
| 1830 | { |
| 1831 | /* |
| 1832 | Local adaptive threshold image. |
| 1833 | */ |
| 1834 | (void) SyncImageSettings(mogrify_info,*image); |
| 1835 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1836 | if ((flags & PercentValue) != 0) |
| 1837 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 1838 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
cristy | de5cc63 | 2011-07-18 14:47:00 +0000 | [diff] [blame] | 1839 | geometry_info.rho,(size_t) geometry_info.sigma,(double) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1840 | geometry_info.xi,exception); |
| 1841 | break; |
| 1842 | } |
| 1843 | if (LocaleCompare("level",option+1) == 0) |
| 1844 | { |
| 1845 | MagickRealType |
| 1846 | black_point, |
| 1847 | gamma, |
| 1848 | white_point; |
| 1849 | |
| 1850 | MagickStatusType |
| 1851 | flags; |
| 1852 | |
| 1853 | /* |
| 1854 | Parse levels. |
| 1855 | */ |
| 1856 | (void) SyncImageSettings(mogrify_info,*image); |
| 1857 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1858 | black_point=geometry_info.rho; |
| 1859 | white_point=(MagickRealType) QuantumRange; |
| 1860 | if ((flags & SigmaValue) != 0) |
| 1861 | white_point=geometry_info.sigma; |
| 1862 | gamma=1.0; |
| 1863 | if ((flags & XiValue) != 0) |
| 1864 | gamma=geometry_info.xi; |
| 1865 | if ((flags & PercentValue) != 0) |
| 1866 | { |
| 1867 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 1868 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 1869 | } |
| 1870 | if ((flags & SigmaValue) == 0) |
| 1871 | white_point=(MagickRealType) QuantumRange-black_point; |
| 1872 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1873 | (void) LevelizeImage(*image,black_point,white_point,gamma, |
| 1874 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1875 | else |
cristy | 01e9afd | 2011-08-10 17:38:41 +0000 | [diff] [blame] | 1876 | (void) LevelImage(*image,black_point,white_point,gamma, |
| 1877 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1878 | InheritException(exception,&(*image)->exception); |
| 1879 | break; |
| 1880 | } |
| 1881 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1882 | { |
| 1883 | char |
| 1884 | token[MaxTextExtent]; |
| 1885 | |
| 1886 | const char |
| 1887 | *p; |
| 1888 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1889 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1890 | black_point, |
| 1891 | white_point; |
| 1892 | |
| 1893 | p=(const char *) argv[i+1]; |
| 1894 | GetMagickToken(p,&p,token); /* get black point color */ |
| 1895 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1896 | (void) QueryMagickColor(token,&black_point,exception); |
| 1897 | else |
| 1898 | (void) QueryMagickColor("#000000",&black_point,exception); |
| 1899 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1900 | GetMagickToken(p,&p,token); |
| 1901 | if (*token == '\0') |
| 1902 | white_point=black_point; /* set everything to that color */ |
| 1903 | else |
| 1904 | { |
| 1905 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 1906 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 1907 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1908 | (void) QueryMagickColor(token,&white_point,exception); |
| 1909 | else |
| 1910 | (void) QueryMagickColor("#ffffff",&white_point,exception); |
| 1911 | } |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 1912 | (void) LevelImageColors(*image,&black_point,&white_point, |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1913 | *option == '+' ? MagickTrue : MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1914 | break; |
| 1915 | } |
| 1916 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 1917 | { |
| 1918 | double |
| 1919 | black_point, |
| 1920 | white_point; |
| 1921 | |
| 1922 | MagickStatusType |
| 1923 | flags; |
| 1924 | |
| 1925 | (void) SyncImageSettings(mogrify_info,*image); |
| 1926 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1927 | black_point=geometry_info.rho; |
| 1928 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 1929 | if ((flags & SigmaValue) != 0) |
| 1930 | white_point=geometry_info.sigma; |
| 1931 | if ((flags & PercentValue) != 0) |
| 1932 | { |
| 1933 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1934 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1935 | } |
| 1936 | if ((flags & SigmaValue) == 0) |
| 1937 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1938 | black_point; |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 1939 | (void) LinearStretchImage(*image,black_point,white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1940 | InheritException(exception,&(*image)->exception); |
| 1941 | break; |
| 1942 | } |
| 1943 | if (LocaleCompare("linewidth",option+1) == 0) |
| 1944 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1945 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 1946 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1947 | break; |
| 1948 | } |
| 1949 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 1950 | { |
| 1951 | /* |
| 1952 | Liquid rescale image. |
| 1953 | */ |
| 1954 | (void) SyncImageSettings(mogrify_info,*image); |
| 1955 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1956 | if ((flags & XValue) == 0) |
| 1957 | geometry.x=1; |
| 1958 | if ((flags & YValue) == 0) |
| 1959 | geometry.y=0; |
| 1960 | mogrify_image=LiquidRescaleImage(*image,geometry.width, |
| 1961 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 1962 | break; |
| 1963 | } |
| 1964 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 1965 | { |
| 1966 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1967 | break; |
| 1968 | } |
| 1969 | break; |
| 1970 | } |
| 1971 | case 'm': |
| 1972 | { |
| 1973 | if (LocaleCompare("map",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1974 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1975 | Image |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1976 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1977 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1978 | /* |
| 1979 | Transform image colors to match this set of colors. |
| 1980 | */ |
| 1981 | (void) SyncImageSettings(mogrify_info,*image); |
| 1982 | if (*option == '+') |
| 1983 | break; |
| 1984 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1985 | if (remap_image == (Image *) NULL) |
| 1986 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1987 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1988 | remap_image=DestroyImage(remap_image); |
| 1989 | break; |
| 1990 | } |
| 1991 | if (LocaleCompare("mask",option+1) == 0) |
| 1992 | { |
| 1993 | Image |
| 1994 | *mask; |
| 1995 | |
| 1996 | (void) SyncImageSettings(mogrify_info,*image); |
| 1997 | if (*option == '+') |
| 1998 | { |
| 1999 | /* |
| 2000 | Remove a mask. |
| 2001 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2002 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2003 | break; |
| 2004 | } |
| 2005 | /* |
| 2006 | Set the image mask. |
| 2007 | */ |
| 2008 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2009 | if (mask == (Image *) NULL) |
| 2010 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2011 | (void) SetImageMask(*image,mask,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2012 | mask=DestroyImage(mask); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2013 | break; |
| 2014 | } |
| 2015 | if (LocaleCompare("matte",option+1) == 0) |
| 2016 | { |
| 2017 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 2018 | SetAlphaChannel : DeactivateAlphaChannel,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2019 | break; |
| 2020 | } |
| 2021 | if (LocaleCompare("median",option+1) == 0) |
| 2022 | { |
| 2023 | /* |
| 2024 | Median filter image. |
| 2025 | */ |
| 2026 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2027 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2028 | if ((flags & SigmaValue) == 0) |
| 2029 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2030 | mogrify_image=StatisticImage(*image,MedianStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2031 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2032 | break; |
| 2033 | } |
| 2034 | if (LocaleCompare("mode",option+1) == 0) |
| 2035 | { |
| 2036 | /* |
| 2037 | Mode image. |
| 2038 | */ |
| 2039 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2040 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2041 | if ((flags & SigmaValue) == 0) |
| 2042 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2043 | mogrify_image=StatisticImage(*image,ModeStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2044 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2045 | break; |
| 2046 | } |
| 2047 | if (LocaleCompare("modulate",option+1) == 0) |
| 2048 | { |
| 2049 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2050 | (void) ModulateImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2051 | break; |
| 2052 | } |
| 2053 | if (LocaleCompare("monitor",option+1) == 0) |
| 2054 | { |
| 2055 | if (*option == '+') |
| 2056 | { |
| 2057 | (void) SetImageProgressMonitor(*image, |
| 2058 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2059 | break; |
| 2060 | } |
| 2061 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2062 | (void *) NULL); |
| 2063 | break; |
| 2064 | } |
| 2065 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2066 | { |
| 2067 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2068 | (void) SetImageType(*image,BilevelType,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2069 | break; |
| 2070 | } |
| 2071 | if (LocaleCompare("morphology",option+1) == 0) |
| 2072 | { |
| 2073 | char |
| 2074 | token[MaxTextExtent]; |
| 2075 | |
| 2076 | const char |
| 2077 | *p; |
| 2078 | |
| 2079 | KernelInfo |
| 2080 | *kernel; |
| 2081 | |
| 2082 | MorphologyMethod |
| 2083 | method; |
| 2084 | |
| 2085 | ssize_t |
| 2086 | iterations; |
| 2087 | |
| 2088 | /* |
| 2089 | Morphological Image Operation |
| 2090 | */ |
| 2091 | (void) SyncImageSettings(mogrify_info,*image); |
| 2092 | p=argv[i+1]; |
| 2093 | GetMagickToken(p,&p,token); |
| 2094 | method=(MorphologyMethod) ParseCommandOption(MagickMorphologyOptions, |
| 2095 | MagickFalse,token); |
| 2096 | iterations=1L; |
| 2097 | GetMagickToken(p,&p,token); |
| 2098 | if ((*p == ':') || (*p == ',')) |
| 2099 | GetMagickToken(p,&p,token); |
| 2100 | if ((*p != '\0')) |
| 2101 | iterations=(ssize_t) StringToLong(p); |
| 2102 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2103 | if (kernel == (KernelInfo *) NULL) |
| 2104 | { |
| 2105 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2106 | OptionError,"UnabletoParseKernel","morphology"); |
| 2107 | status=MagickFalse; |
| 2108 | break; |
| 2109 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2110 | mogrify_image=MorphologyImage(*image,method,iterations,kernel, |
| 2111 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2112 | kernel=DestroyKernelInfo(kernel); |
| 2113 | break; |
| 2114 | } |
| 2115 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2116 | { |
| 2117 | /* |
| 2118 | Motion blur image. |
| 2119 | */ |
| 2120 | (void) SyncImageSettings(mogrify_info,*image); |
| 2121 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2122 | if ((flags & SigmaValue) == 0) |
| 2123 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2124 | mogrify_image=MotionBlurImage(*image,geometry_info.rho, |
cristy | f7ef025 | 2011-09-09 14:50:06 +0000 | [diff] [blame] | 2125 | geometry_info.sigma,geometry_info.xi,geometry_info.psi, |
| 2126 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2127 | break; |
| 2128 | } |
| 2129 | break; |
| 2130 | } |
| 2131 | case 'n': |
| 2132 | { |
| 2133 | if (LocaleCompare("negate",option+1) == 0) |
| 2134 | { |
| 2135 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2136 | (void) NegateImage(*image,*option == '+' ? MagickTrue : |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 2137 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2138 | break; |
| 2139 | } |
| 2140 | if (LocaleCompare("noise",option+1) == 0) |
| 2141 | { |
| 2142 | (void) SyncImageSettings(mogrify_info,*image); |
| 2143 | if (*option == '-') |
| 2144 | { |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2145 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2146 | if ((flags & SigmaValue) == 0) |
| 2147 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2148 | mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2149 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2150 | } |
| 2151 | else |
| 2152 | { |
| 2153 | NoiseType |
| 2154 | noise; |
| 2155 | |
| 2156 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
| 2157 | MagickFalse,argv[i+1]); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 2158 | mogrify_image=AddNoiseImage(*image,noise,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2159 | } |
| 2160 | break; |
| 2161 | } |
| 2162 | if (LocaleCompare("normalize",option+1) == 0) |
| 2163 | { |
| 2164 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 2165 | (void) NormalizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2166 | break; |
| 2167 | } |
| 2168 | break; |
| 2169 | } |
| 2170 | case 'o': |
| 2171 | { |
| 2172 | if (LocaleCompare("opaque",option+1) == 0) |
| 2173 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2174 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2175 | target; |
| 2176 | |
| 2177 | (void) SyncImageSettings(mogrify_info,*image); |
| 2178 | (void) QueryMagickColor(argv[i+1],&target,exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 2179 | (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ? |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 2180 | MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2181 | break; |
| 2182 | } |
| 2183 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2184 | { |
| 2185 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 1302067 | 2011-07-08 02:33:26 +0000 | [diff] [blame] | 2186 | (void) OrderedPosterizeImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2187 | break; |
| 2188 | } |
| 2189 | break; |
| 2190 | } |
| 2191 | case 'p': |
| 2192 | { |
| 2193 | if (LocaleCompare("paint",option+1) == 0) |
| 2194 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2195 | (void) SyncImageSettings(mogrify_info,*image); |
| 2196 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 14973ba | 2011-08-27 23:48:07 +0000 | [diff] [blame] | 2197 | mogrify_image=OilPaintImage(*image,geometry_info.rho, |
| 2198 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2199 | break; |
| 2200 | } |
| 2201 | if (LocaleCompare("pen",option+1) == 0) |
| 2202 | { |
| 2203 | if (*option == '+') |
| 2204 | { |
| 2205 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 2206 | break; |
| 2207 | } |
| 2208 | (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception); |
| 2209 | break; |
| 2210 | } |
| 2211 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2212 | { |
| 2213 | if (*option == '+') |
| 2214 | (void) ParseGeometry("12",&geometry_info); |
| 2215 | else |
| 2216 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2217 | draw_info->pointsize=geometry_info.rho; |
| 2218 | break; |
| 2219 | } |
| 2220 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2221 | { |
| 2222 | double |
| 2223 | angle; |
| 2224 | |
| 2225 | RandomInfo |
| 2226 | *random_info; |
| 2227 | |
| 2228 | /* |
| 2229 | Simulate a Polaroid picture. |
| 2230 | */ |
| 2231 | (void) SyncImageSettings(mogrify_info,*image); |
| 2232 | random_info=AcquireRandomInfo(); |
| 2233 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2234 | random_info=DestroyRandomInfo(random_info); |
| 2235 | if (*option == '-') |
| 2236 | { |
| 2237 | SetGeometryInfo(&geometry_info); |
| 2238 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2239 | angle=geometry_info.rho; |
| 2240 | } |
| 2241 | mogrify_image=PolaroidImage(*image,draw_info,angle,exception); |
| 2242 | break; |
| 2243 | } |
| 2244 | if (LocaleCompare("posterize",option+1) == 0) |
| 2245 | { |
| 2246 | /* |
| 2247 | Posterize image. |
| 2248 | */ |
| 2249 | (void) SyncImageSettings(mogrify_info,*image); |
| 2250 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2251 | quantize_info->dither,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2252 | break; |
| 2253 | } |
| 2254 | if (LocaleCompare("preview",option+1) == 0) |
| 2255 | { |
| 2256 | PreviewType |
| 2257 | preview_type; |
| 2258 | |
| 2259 | /* |
| 2260 | Preview image. |
| 2261 | */ |
| 2262 | (void) SyncImageSettings(mogrify_info,*image); |
| 2263 | if (*option == '+') |
| 2264 | preview_type=UndefinedPreview; |
| 2265 | else |
| 2266 | preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions, |
| 2267 | MagickFalse,argv[i+1]); |
| 2268 | mogrify_image=PreviewImage(*image,preview_type,exception); |
| 2269 | break; |
| 2270 | } |
| 2271 | if (LocaleCompare("profile",option+1) == 0) |
| 2272 | { |
| 2273 | const char |
| 2274 | *name; |
| 2275 | |
| 2276 | const StringInfo |
| 2277 | *profile; |
| 2278 | |
| 2279 | Image |
| 2280 | *profile_image; |
| 2281 | |
| 2282 | ImageInfo |
| 2283 | *profile_info; |
| 2284 | |
| 2285 | (void) SyncImageSettings(mogrify_info,*image); |
| 2286 | if (*option == '+') |
| 2287 | { |
| 2288 | /* |
| 2289 | Remove a profile from the image. |
| 2290 | */ |
| 2291 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
| 2292 | NULL,0,MagickTrue); |
| 2293 | InheritException(exception,&(*image)->exception); |
| 2294 | break; |
| 2295 | } |
| 2296 | /* |
| 2297 | Associate a profile with the image. |
| 2298 | */ |
| 2299 | profile_info=CloneImageInfo(mogrify_info); |
| 2300 | profile=GetImageProfile(*image,"iptc"); |
| 2301 | if (profile != (StringInfo *) NULL) |
| 2302 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2303 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2304 | profile_info=DestroyImageInfo(profile_info); |
| 2305 | if (profile_image == (Image *) NULL) |
| 2306 | { |
| 2307 | StringInfo |
| 2308 | *profile; |
| 2309 | |
| 2310 | profile_info=CloneImageInfo(mogrify_info); |
| 2311 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2312 | MaxTextExtent); |
| 2313 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
| 2314 | if (profile != (StringInfo *) NULL) |
| 2315 | { |
| 2316 | (void) ProfileImage(*image,profile_info->magick, |
| 2317 | GetStringInfoDatum(profile),(size_t) |
| 2318 | GetStringInfoLength(profile),MagickFalse); |
| 2319 | profile=DestroyStringInfo(profile); |
| 2320 | } |
| 2321 | profile_info=DestroyImageInfo(profile_info); |
| 2322 | break; |
| 2323 | } |
| 2324 | ResetImageProfileIterator(profile_image); |
| 2325 | name=GetNextImageProfile(profile_image); |
| 2326 | while (name != (const char *) NULL) |
| 2327 | { |
| 2328 | profile=GetImageProfile(profile_image,name); |
| 2329 | if (profile != (StringInfo *) NULL) |
| 2330 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
| 2331 | (size_t) GetStringInfoLength(profile),MagickFalse); |
| 2332 | name=GetNextImageProfile(profile_image); |
| 2333 | } |
| 2334 | profile_image=DestroyImage(profile_image); |
| 2335 | break; |
| 2336 | } |
| 2337 | break; |
| 2338 | } |
| 2339 | case 'q': |
| 2340 | { |
| 2341 | if (LocaleCompare("quantize",option+1) == 0) |
| 2342 | { |
| 2343 | if (*option == '+') |
| 2344 | { |
| 2345 | quantize_info->colorspace=UndefinedColorspace; |
| 2346 | break; |
| 2347 | } |
| 2348 | quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
| 2349 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2350 | break; |
| 2351 | } |
| 2352 | break; |
| 2353 | } |
| 2354 | case 'r': |
| 2355 | { |
| 2356 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2357 | { |
| 2358 | /* |
| 2359 | Radial blur image. |
| 2360 | */ |
| 2361 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 6435bd9 | 2011-09-10 02:10:07 +0000 | [diff] [blame] | 2362 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2363 | mogrify_image=RadialBlurImage(*image,geometry_info.rho, |
| 2364 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2365 | break; |
| 2366 | } |
| 2367 | if (LocaleCompare("raise",option+1) == 0) |
| 2368 | { |
| 2369 | /* |
| 2370 | Surround image with a raise of solid color. |
| 2371 | */ |
| 2372 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2373 | if ((flags & SigmaValue) == 0) |
| 2374 | geometry.height=geometry.width; |
| 2375 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
cristy | 6170ac3 | 2011-08-28 14:15:37 +0000 | [diff] [blame] | 2376 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2377 | break; |
| 2378 | } |
| 2379 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2380 | { |
| 2381 | /* |
| 2382 | Threshold image. |
| 2383 | */ |
| 2384 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2385 | (void) RandomThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2386 | break; |
| 2387 | } |
| 2388 | if (LocaleCompare("recolor",option+1) == 0) |
| 2389 | { |
| 2390 | KernelInfo |
| 2391 | *kernel; |
| 2392 | |
| 2393 | (void) SyncImageSettings(mogrify_info,*image); |
| 2394 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2395 | if (kernel == (KernelInfo *) NULL) |
| 2396 | break; |
| 2397 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 2398 | kernel=DestroyKernelInfo(kernel); |
| 2399 | break; |
| 2400 | } |
| 2401 | if (LocaleCompare("region",option+1) == 0) |
| 2402 | { |
| 2403 | (void) SyncImageSettings(mogrify_info,*image); |
| 2404 | if (region_image != (Image *) NULL) |
| 2405 | { |
| 2406 | /* |
| 2407 | Composite region. |
| 2408 | */ |
| 2409 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2410 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 2411 | region_geometry.x,region_geometry.y); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2412 | InheritException(exception,®ion_image->exception); |
| 2413 | *image=DestroyImage(*image); |
| 2414 | *image=region_image; |
| 2415 | region_image = (Image *) NULL; |
| 2416 | } |
| 2417 | if (*option == '+') |
| 2418 | break; |
| 2419 | /* |
| 2420 | Apply transformations to a selected region of the image. |
| 2421 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2422 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2423 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2424 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2425 | if (mogrify_image == (Image *) NULL) |
| 2426 | break; |
| 2427 | region_image=(*image); |
| 2428 | *image=mogrify_image; |
| 2429 | mogrify_image=(Image *) NULL; |
| 2430 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2431 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2432 | if (LocaleCompare("render",option+1) == 0) |
| 2433 | { |
| 2434 | (void) SyncImageSettings(mogrify_info,*image); |
| 2435 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2436 | break; |
| 2437 | } |
| 2438 | if (LocaleCompare("remap",option+1) == 0) |
| 2439 | { |
| 2440 | Image |
| 2441 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2442 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2443 | /* |
| 2444 | Transform image colors to match this set of colors. |
| 2445 | */ |
| 2446 | (void) SyncImageSettings(mogrify_info,*image); |
| 2447 | if (*option == '+') |
| 2448 | break; |
| 2449 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2450 | if (remap_image == (Image *) NULL) |
| 2451 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2452 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2453 | remap_image=DestroyImage(remap_image); |
| 2454 | break; |
| 2455 | } |
| 2456 | if (LocaleCompare("repage",option+1) == 0) |
| 2457 | { |
| 2458 | if (*option == '+') |
| 2459 | { |
| 2460 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2461 | break; |
| 2462 | } |
| 2463 | (void) ResetImagePage(*image,argv[i+1]); |
| 2464 | InheritException(exception,&(*image)->exception); |
| 2465 | break; |
| 2466 | } |
| 2467 | if (LocaleCompare("resample",option+1) == 0) |
| 2468 | { |
| 2469 | /* |
| 2470 | Resample image. |
| 2471 | */ |
| 2472 | (void) SyncImageSettings(mogrify_info,*image); |
| 2473 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2474 | if ((flags & SigmaValue) == 0) |
| 2475 | geometry_info.sigma=geometry_info.rho; |
| 2476 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
| 2477 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2478 | break; |
| 2479 | } |
| 2480 | if (LocaleCompare("resize",option+1) == 0) |
| 2481 | { |
| 2482 | /* |
| 2483 | Resize image. |
| 2484 | */ |
| 2485 | (void) SyncImageSettings(mogrify_info,*image); |
| 2486 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2487 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2488 | (*image)->filter,(*image)->blur,exception); |
| 2489 | break; |
| 2490 | } |
| 2491 | if (LocaleCompare("roll",option+1) == 0) |
| 2492 | { |
| 2493 | /* |
| 2494 | Roll image. |
| 2495 | */ |
| 2496 | (void) SyncImageSettings(mogrify_info,*image); |
| 2497 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2498 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2499 | break; |
| 2500 | } |
| 2501 | if (LocaleCompare("rotate",option+1) == 0) |
| 2502 | { |
| 2503 | char |
| 2504 | *geometry; |
| 2505 | |
| 2506 | /* |
| 2507 | Check for conditional image rotation. |
| 2508 | */ |
| 2509 | (void) SyncImageSettings(mogrify_info,*image); |
| 2510 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2511 | if ((*image)->columns <= (*image)->rows) |
| 2512 | break; |
| 2513 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2514 | if ((*image)->columns >= (*image)->rows) |
| 2515 | break; |
| 2516 | /* |
| 2517 | Rotate image. |
| 2518 | */ |
| 2519 | geometry=ConstantString(argv[i+1]); |
| 2520 | (void) SubstituteString(&geometry,">",""); |
| 2521 | (void) SubstituteString(&geometry,"<",""); |
| 2522 | (void) ParseGeometry(geometry,&geometry_info); |
| 2523 | geometry=DestroyString(geometry); |
| 2524 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
| 2525 | break; |
| 2526 | } |
| 2527 | break; |
| 2528 | } |
| 2529 | case 's': |
| 2530 | { |
| 2531 | if (LocaleCompare("sample",option+1) == 0) |
| 2532 | { |
| 2533 | /* |
| 2534 | Sample image with pixel replication. |
| 2535 | */ |
| 2536 | (void) SyncImageSettings(mogrify_info,*image); |
| 2537 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2538 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
| 2539 | exception); |
| 2540 | break; |
| 2541 | } |
| 2542 | if (LocaleCompare("scale",option+1) == 0) |
| 2543 | { |
| 2544 | /* |
| 2545 | Resize image. |
| 2546 | */ |
| 2547 | (void) SyncImageSettings(mogrify_info,*image); |
| 2548 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2549 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2550 | exception); |
| 2551 | break; |
| 2552 | } |
| 2553 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2554 | { |
| 2555 | /* |
| 2556 | Selectively blur pixels within a contrast threshold. |
| 2557 | */ |
| 2558 | (void) SyncImageSettings(mogrify_info,*image); |
| 2559 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2560 | if ((flags & PercentValue) != 0) |
| 2561 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2562 | mogrify_image=SelectiveBlurImage(*image,geometry_info.rho, |
cristy | 1e7aa31 | 2011-09-10 20:01:36 +0000 | [diff] [blame^] | 2563 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2564 | break; |
| 2565 | } |
| 2566 | if (LocaleCompare("separate",option+1) == 0) |
| 2567 | { |
| 2568 | /* |
| 2569 | Break channels into separate images. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2570 | */ |
| 2571 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 2572 | mogrify_image=SeparateImages(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2573 | break; |
| 2574 | } |
| 2575 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2576 | { |
| 2577 | double |
| 2578 | threshold; |
| 2579 | |
| 2580 | /* |
| 2581 | Sepia-tone image. |
| 2582 | */ |
| 2583 | (void) SyncImageSettings(mogrify_info,*image); |
| 2584 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2585 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
| 2586 | break; |
| 2587 | } |
| 2588 | if (LocaleCompare("segment",option+1) == 0) |
| 2589 | { |
| 2590 | /* |
| 2591 | Segment image. |
| 2592 | */ |
| 2593 | (void) SyncImageSettings(mogrify_info,*image); |
| 2594 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2595 | if ((flags & SigmaValue) == 0) |
| 2596 | geometry_info.sigma=1.0; |
| 2597 | (void) SegmentImage(*image,(*image)->colorspace, |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2598 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 2599 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2600 | break; |
| 2601 | } |
| 2602 | if (LocaleCompare("set",option+1) == 0) |
| 2603 | { |
| 2604 | char |
| 2605 | *value; |
| 2606 | |
| 2607 | /* |
| 2608 | Set image option. |
| 2609 | */ |
| 2610 | if (*option == '+') |
| 2611 | { |
| 2612 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2613 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2614 | else |
| 2615 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2616 | { |
| 2617 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
| 2618 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2619 | } |
| 2620 | else |
| 2621 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2622 | break; |
| 2623 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2624 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2625 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2626 | if (value == (char *) NULL) |
| 2627 | break; |
| 2628 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2629 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2630 | exception); |
| 2631 | else |
| 2632 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2633 | { |
| 2634 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
| 2635 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
| 2636 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2637 | } |
| 2638 | else |
| 2639 | (void) SetImageProperty(*image,argv[i+1],value); |
| 2640 | value=DestroyString(value); |
| 2641 | break; |
| 2642 | } |
| 2643 | if (LocaleCompare("shade",option+1) == 0) |
| 2644 | { |
| 2645 | /* |
| 2646 | Shade image. |
| 2647 | */ |
| 2648 | (void) SyncImageSettings(mogrify_info,*image); |
| 2649 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2650 | if ((flags & SigmaValue) == 0) |
| 2651 | geometry_info.sigma=1.0; |
| 2652 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2653 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2654 | break; |
| 2655 | } |
| 2656 | if (LocaleCompare("shadow",option+1) == 0) |
| 2657 | { |
| 2658 | /* |
| 2659 | Shadow image. |
| 2660 | */ |
| 2661 | (void) SyncImageSettings(mogrify_info,*image); |
| 2662 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2663 | if ((flags & SigmaValue) == 0) |
| 2664 | geometry_info.sigma=1.0; |
| 2665 | if ((flags & XiValue) == 0) |
| 2666 | geometry_info.xi=4.0; |
| 2667 | if ((flags & PsiValue) == 0) |
| 2668 | geometry_info.psi=4.0; |
| 2669 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
| 2670 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 2671 | ceil(geometry_info.psi-0.5),exception); |
| 2672 | break; |
| 2673 | } |
| 2674 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2675 | { |
| 2676 | /* |
| 2677 | Sharpen image. |
| 2678 | */ |
| 2679 | (void) SyncImageSettings(mogrify_info,*image); |
| 2680 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2681 | if ((flags & SigmaValue) == 0) |
| 2682 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2683 | if ((flags & XiValue) == 0) |
| 2684 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2685 | mogrify_image=SharpenImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2686 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2687 | break; |
| 2688 | } |
| 2689 | if (LocaleCompare("shave",option+1) == 0) |
| 2690 | { |
| 2691 | /* |
| 2692 | Shave the image edges. |
| 2693 | */ |
| 2694 | (void) SyncImageSettings(mogrify_info,*image); |
| 2695 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2696 | mogrify_image=ShaveImage(*image,&geometry,exception); |
| 2697 | break; |
| 2698 | } |
| 2699 | if (LocaleCompare("shear",option+1) == 0) |
| 2700 | { |
| 2701 | /* |
| 2702 | Shear image. |
| 2703 | */ |
| 2704 | (void) SyncImageSettings(mogrify_info,*image); |
| 2705 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2706 | if ((flags & SigmaValue) == 0) |
| 2707 | geometry_info.sigma=geometry_info.rho; |
| 2708 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2709 | geometry_info.sigma,exception); |
| 2710 | break; |
| 2711 | } |
| 2712 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2713 | { |
| 2714 | /* |
| 2715 | Sigmoidal non-linearity contrast control. |
| 2716 | */ |
| 2717 | (void) SyncImageSettings(mogrify_info,*image); |
| 2718 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2719 | if ((flags & SigmaValue) == 0) |
| 2720 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 2721 | if ((flags & PercentValue) != 0) |
| 2722 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2723 | 100.0; |
cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 2724 | (void) SigmoidalContrastImage(*image,(*option == '-') ? |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2725 | MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma, |
| 2726 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2727 | break; |
| 2728 | } |
| 2729 | if (LocaleCompare("sketch",option+1) == 0) |
| 2730 | { |
| 2731 | /* |
| 2732 | Sketch image. |
| 2733 | */ |
| 2734 | (void) SyncImageSettings(mogrify_info,*image); |
| 2735 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2736 | if ((flags & SigmaValue) == 0) |
| 2737 | geometry_info.sigma=1.0; |
| 2738 | mogrify_image=SketchImage(*image,geometry_info.rho, |
cristy | f7ef025 | 2011-09-09 14:50:06 +0000 | [diff] [blame] | 2739 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2740 | break; |
| 2741 | } |
| 2742 | if (LocaleCompare("solarize",option+1) == 0) |
| 2743 | { |
| 2744 | double |
| 2745 | threshold; |
| 2746 | |
| 2747 | (void) SyncImageSettings(mogrify_info,*image); |
| 2748 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 2749 | (void) SolarizeImage(*image,threshold,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2750 | break; |
| 2751 | } |
| 2752 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2753 | { |
| 2754 | SparseColorMethod |
| 2755 | method; |
| 2756 | |
| 2757 | char |
| 2758 | *arguments; |
| 2759 | |
| 2760 | /* |
| 2761 | Sparse Color Interpolated Gradient |
| 2762 | */ |
| 2763 | (void) SyncImageSettings(mogrify_info,*image); |
| 2764 | method=(SparseColorMethod) ParseCommandOption( |
| 2765 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2766 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2767 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2768 | if (arguments == (char *) NULL) |
| 2769 | break; |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 2770 | mogrify_image=SparseColorOption(*image,method,arguments, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2771 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2772 | arguments=DestroyString(arguments); |
| 2773 | break; |
| 2774 | } |
| 2775 | if (LocaleCompare("splice",option+1) == 0) |
| 2776 | { |
| 2777 | /* |
| 2778 | Splice a solid color into the image. |
| 2779 | */ |
| 2780 | (void) SyncImageSettings(mogrify_info,*image); |
| 2781 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 2782 | mogrify_image=SpliceImage(*image,&geometry,exception); |
| 2783 | break; |
| 2784 | } |
| 2785 | if (LocaleCompare("spread",option+1) == 0) |
| 2786 | { |
| 2787 | /* |
| 2788 | Spread an image. |
| 2789 | */ |
| 2790 | (void) SyncImageSettings(mogrify_info,*image); |
| 2791 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2792 | mogrify_image=SpreadImage(*image,geometry_info.rho,exception); |
| 2793 | break; |
| 2794 | } |
| 2795 | if (LocaleCompare("statistic",option+1) == 0) |
| 2796 | { |
| 2797 | StatisticType |
| 2798 | type; |
| 2799 | |
| 2800 | (void) SyncImageSettings(mogrify_info,*image); |
| 2801 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
| 2802 | MagickFalse,argv[i+1]); |
| 2803 | (void) ParseGeometry(argv[i+2],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2804 | mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho, |
| 2805 | (size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2806 | break; |
| 2807 | } |
| 2808 | if (LocaleCompare("stretch",option+1) == 0) |
| 2809 | { |
| 2810 | if (*option == '+') |
| 2811 | { |
| 2812 | draw_info->stretch=UndefinedStretch; |
| 2813 | break; |
| 2814 | } |
| 2815 | draw_info->stretch=(StretchType) ParseCommandOption( |
| 2816 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2817 | break; |
| 2818 | } |
| 2819 | if (LocaleCompare("strip",option+1) == 0) |
| 2820 | { |
| 2821 | /* |
| 2822 | Strip image of profiles and comments. |
| 2823 | */ |
| 2824 | (void) SyncImageSettings(mogrify_info,*image); |
| 2825 | (void) StripImage(*image); |
| 2826 | InheritException(exception,&(*image)->exception); |
| 2827 | break; |
| 2828 | } |
| 2829 | if (LocaleCompare("stroke",option+1) == 0) |
| 2830 | { |
| 2831 | ExceptionInfo |
| 2832 | *sans; |
| 2833 | |
| 2834 | if (*option == '+') |
| 2835 | { |
| 2836 | (void) QueryColorDatabase("none",&draw_info->stroke,exception); |
| 2837 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2838 | draw_info->stroke_pattern=DestroyImage( |
| 2839 | draw_info->stroke_pattern); |
| 2840 | break; |
| 2841 | } |
| 2842 | sans=AcquireExceptionInfo(); |
| 2843 | status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans); |
| 2844 | sans=DestroyExceptionInfo(sans); |
| 2845 | if (status == MagickFalse) |
| 2846 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2847 | exception); |
| 2848 | break; |
| 2849 | } |
| 2850 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2851 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 2852 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 2853 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2854 | break; |
| 2855 | } |
| 2856 | if (LocaleCompare("style",option+1) == 0) |
| 2857 | { |
| 2858 | if (*option == '+') |
| 2859 | { |
| 2860 | draw_info->style=UndefinedStyle; |
| 2861 | break; |
| 2862 | } |
| 2863 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 2864 | MagickFalse,argv[i+1]); |
| 2865 | break; |
| 2866 | } |
| 2867 | if (LocaleCompare("swirl",option+1) == 0) |
| 2868 | { |
| 2869 | /* |
| 2870 | Swirl image. |
| 2871 | */ |
| 2872 | (void) SyncImageSettings(mogrify_info,*image); |
| 2873 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2874 | mogrify_image=SwirlImage(*image,geometry_info.rho,exception); |
| 2875 | break; |
| 2876 | } |
| 2877 | break; |
| 2878 | } |
| 2879 | case 't': |
| 2880 | { |
| 2881 | if (LocaleCompare("threshold",option+1) == 0) |
| 2882 | { |
| 2883 | double |
| 2884 | threshold; |
| 2885 | |
| 2886 | /* |
| 2887 | Threshold image. |
| 2888 | */ |
| 2889 | (void) SyncImageSettings(mogrify_info,*image); |
| 2890 | if (*option == '+') |
anthony | 247a86d | 2011-05-03 13:18:18 +0000 | [diff] [blame] | 2891 | threshold=(double) QuantumRange/2; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2892 | else |
| 2893 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2894 | (void) BilevelImage(*image,threshold); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2895 | InheritException(exception,&(*image)->exception); |
| 2896 | break; |
| 2897 | } |
| 2898 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2899 | { |
| 2900 | /* |
| 2901 | Thumbnail image. |
| 2902 | */ |
| 2903 | (void) SyncImageSettings(mogrify_info,*image); |
| 2904 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2905 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2906 | exception); |
| 2907 | break; |
| 2908 | } |
| 2909 | if (LocaleCompare("tile",option+1) == 0) |
| 2910 | { |
| 2911 | if (*option == '+') |
| 2912 | { |
| 2913 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2914 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2915 | break; |
| 2916 | } |
| 2917 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2918 | exception); |
| 2919 | break; |
| 2920 | } |
| 2921 | if (LocaleCompare("tint",option+1) == 0) |
| 2922 | { |
| 2923 | /* |
| 2924 | Tint the image. |
| 2925 | */ |
| 2926 | (void) SyncImageSettings(mogrify_info,*image); |
| 2927 | mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception); |
| 2928 | break; |
| 2929 | } |
| 2930 | if (LocaleCompare("transform",option+1) == 0) |
| 2931 | { |
| 2932 | /* |
| 2933 | Affine transform image. |
| 2934 | */ |
| 2935 | (void) SyncImageSettings(mogrify_info,*image); |
| 2936 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
| 2937 | exception); |
| 2938 | break; |
| 2939 | } |
| 2940 | if (LocaleCompare("transparent",option+1) == 0) |
| 2941 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2942 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2943 | target; |
| 2944 | |
| 2945 | (void) SyncImageSettings(mogrify_info,*image); |
| 2946 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2947 | (void) TransparentPaintImage(*image,&target,(Quantum) |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 2948 | TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue, |
| 2949 | &(*image)->exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2950 | break; |
| 2951 | } |
| 2952 | if (LocaleCompare("transpose",option+1) == 0) |
| 2953 | { |
| 2954 | /* |
| 2955 | Transpose image scanlines. |
| 2956 | */ |
| 2957 | (void) SyncImageSettings(mogrify_info,*image); |
| 2958 | mogrify_image=TransposeImage(*image,exception); |
| 2959 | break; |
| 2960 | } |
| 2961 | if (LocaleCompare("transverse",option+1) == 0) |
| 2962 | { |
| 2963 | /* |
| 2964 | Transverse image scanlines. |
| 2965 | */ |
| 2966 | (void) SyncImageSettings(mogrify_info,*image); |
| 2967 | mogrify_image=TransverseImage(*image,exception); |
| 2968 | break; |
| 2969 | } |
| 2970 | if (LocaleCompare("treedepth",option+1) == 0) |
| 2971 | { |
| 2972 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
| 2973 | break; |
| 2974 | } |
| 2975 | if (LocaleCompare("trim",option+1) == 0) |
| 2976 | { |
| 2977 | /* |
| 2978 | Trim image. |
| 2979 | */ |
| 2980 | (void) SyncImageSettings(mogrify_info,*image); |
| 2981 | mogrify_image=TrimImage(*image,exception); |
| 2982 | break; |
| 2983 | } |
| 2984 | if (LocaleCompare("type",option+1) == 0) |
| 2985 | { |
| 2986 | ImageType |
| 2987 | type; |
| 2988 | |
| 2989 | (void) SyncImageSettings(mogrify_info,*image); |
| 2990 | if (*option == '+') |
| 2991 | type=UndefinedType; |
| 2992 | else |
| 2993 | type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 2994 | argv[i+1]); |
| 2995 | (*image)->type=UndefinedType; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2996 | (void) SetImageType(*image,type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2997 | break; |
| 2998 | } |
| 2999 | break; |
| 3000 | } |
| 3001 | case 'u': |
| 3002 | { |
| 3003 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3004 | { |
| 3005 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 3006 | exception); |
| 3007 | break; |
| 3008 | } |
| 3009 | if (LocaleCompare("unique",option+1) == 0) |
| 3010 | { |
| 3011 | if (*option == '+') |
| 3012 | { |
| 3013 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
| 3014 | break; |
| 3015 | } |
| 3016 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
| 3017 | (void) SetImageArtifact(*image,"verbose","true"); |
| 3018 | break; |
| 3019 | } |
| 3020 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3021 | { |
| 3022 | /* |
| 3023 | Unique image colors. |
| 3024 | */ |
| 3025 | (void) SyncImageSettings(mogrify_info,*image); |
| 3026 | mogrify_image=UniqueImageColors(*image,exception); |
| 3027 | break; |
| 3028 | } |
| 3029 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3030 | { |
| 3031 | /* |
| 3032 | Unsharp mask image. |
| 3033 | */ |
| 3034 | (void) SyncImageSettings(mogrify_info,*image); |
| 3035 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3036 | if ((flags & SigmaValue) == 0) |
| 3037 | geometry_info.sigma=1.0; |
| 3038 | if ((flags & XiValue) == 0) |
| 3039 | geometry_info.xi=1.0; |
| 3040 | if ((flags & PsiValue) == 0) |
| 3041 | geometry_info.psi=0.05; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3042 | mogrify_image=UnsharpMaskImage(*image,geometry_info.rho, |
| 3043 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3044 | break; |
| 3045 | } |
| 3046 | break; |
| 3047 | } |
| 3048 | case 'v': |
| 3049 | { |
| 3050 | if (LocaleCompare("verbose",option+1) == 0) |
| 3051 | { |
| 3052 | (void) SetImageArtifact(*image,option+1, |
| 3053 | *option == '+' ? "false" : "true"); |
| 3054 | break; |
| 3055 | } |
| 3056 | if (LocaleCompare("vignette",option+1) == 0) |
| 3057 | { |
| 3058 | /* |
| 3059 | Vignette image. |
| 3060 | */ |
| 3061 | (void) SyncImageSettings(mogrify_info,*image); |
| 3062 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3063 | if ((flags & SigmaValue) == 0) |
| 3064 | geometry_info.sigma=1.0; |
| 3065 | if ((flags & XiValue) == 0) |
| 3066 | geometry_info.xi=0.1*(*image)->columns; |
| 3067 | if ((flags & PsiValue) == 0) |
| 3068 | geometry_info.psi=0.1*(*image)->rows; |
| 3069 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
| 3070 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3071 | ceil(geometry_info.psi-0.5),exception); |
| 3072 | break; |
| 3073 | } |
| 3074 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3075 | { |
| 3076 | if (*option == '+') |
| 3077 | { |
| 3078 | (void) SetImageVirtualPixelMethod(*image, |
| 3079 | UndefinedVirtualPixelMethod); |
| 3080 | break; |
| 3081 | } |
| 3082 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3083 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 3084 | argv[i+1])); |
| 3085 | break; |
| 3086 | } |
| 3087 | break; |
| 3088 | } |
| 3089 | case 'w': |
| 3090 | { |
| 3091 | if (LocaleCompare("wave",option+1) == 0) |
| 3092 | { |
| 3093 | /* |
| 3094 | Wave image. |
| 3095 | */ |
| 3096 | (void) SyncImageSettings(mogrify_info,*image); |
| 3097 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3098 | if ((flags & SigmaValue) == 0) |
| 3099 | geometry_info.sigma=1.0; |
| 3100 | mogrify_image=WaveImage(*image,geometry_info.rho, |
| 3101 | geometry_info.sigma,exception); |
| 3102 | break; |
| 3103 | } |
| 3104 | if (LocaleCompare("weight",option+1) == 0) |
| 3105 | { |
| 3106 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
| 3107 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3108 | draw_info->weight=0; |
| 3109 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3110 | draw_info->weight=700; |
| 3111 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3112 | if (draw_info->weight <= 800) |
| 3113 | draw_info->weight+=100; |
| 3114 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3115 | if (draw_info->weight >= 100) |
| 3116 | draw_info->weight-=100; |
| 3117 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3118 | draw_info->weight=400; |
| 3119 | break; |
| 3120 | } |
| 3121 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3122 | { |
| 3123 | /* |
| 3124 | White threshold image. |
| 3125 | */ |
| 3126 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3127 | (void) WhiteThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3128 | InheritException(exception,&(*image)->exception); |
| 3129 | break; |
| 3130 | } |
| 3131 | break; |
| 3132 | } |
| 3133 | default: |
| 3134 | break; |
| 3135 | } |
| 3136 | /* |
| 3137 | Replace current image with any image that was generated |
| 3138 | */ |
| 3139 | if (mogrify_image != (Image *) NULL) |
| 3140 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3141 | i+=count; |
| 3142 | } |
| 3143 | if (region_image != (Image *) NULL) |
| 3144 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3145 | /* |
| 3146 | Composite transformed region onto image. |
| 3147 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3148 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3149 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3150 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 3151 | region_geometry.x,region_geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3152 | InheritException(exception,®ion_image->exception); |
| 3153 | *image=DestroyImage(*image); |
| 3154 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3155 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3156 | } |
| 3157 | /* |
| 3158 | Free resources. |
| 3159 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3160 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3161 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3162 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 3163 | status=(MagickStatusType) ((*image)->exception.severity == |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 3164 | UndefinedException ? 1 : 0); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3165 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3166 | } |
| 3167 | |
| 3168 | /* |
| 3169 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3170 | % % |
| 3171 | % % |
| 3172 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3173 | + 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] | 3174 | % % |
| 3175 | % % |
| 3176 | % % |
| 3177 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3178 | % |
| 3179 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3180 | % transforms include image scaling, image rotation, color reduction, and |
| 3181 | % others. The transmogrified image overwrites the original image. |
| 3182 | % |
| 3183 | % The format of the MogrifyImageCommand method is: |
| 3184 | % |
| 3185 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3186 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3187 | % |
| 3188 | % A description of each parameter follows: |
| 3189 | % |
| 3190 | % o image_info: the image info. |
| 3191 | % |
| 3192 | % o argc: the number of elements in the argument vector. |
| 3193 | % |
| 3194 | % o argv: A text array containing the command line arguments. |
| 3195 | % |
| 3196 | % o metadata: any metadata is returned here. |
| 3197 | % |
| 3198 | % o exception: return any errors or warnings in this structure. |
| 3199 | % |
| 3200 | */ |
| 3201 | |
| 3202 | static MagickBooleanType MogrifyUsage(void) |
| 3203 | { |
| 3204 | static const char |
| 3205 | *miscellaneous[]= |
| 3206 | { |
| 3207 | "-debug events display copious debugging information", |
| 3208 | "-help print program options", |
| 3209 | "-list type print a list of supported option arguments", |
| 3210 | "-log format format of debugging information", |
| 3211 | "-version print version information", |
| 3212 | (char *) NULL |
| 3213 | }, |
| 3214 | *operators[]= |
| 3215 | { |
| 3216 | "-adaptive-blur geometry", |
| 3217 | " adaptively blur pixels; decrease effect near edges", |
| 3218 | "-adaptive-resize geometry", |
| 3219 | " adaptively resize image using 'mesh' interpolation", |
| 3220 | "-adaptive-sharpen geometry", |
| 3221 | " adaptively sharpen pixels; increase effect near edges", |
| 3222 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3223 | " transparent, extract, background, or shape", |
| 3224 | "-annotate geometry text", |
| 3225 | " annotate the image with text", |
| 3226 | "-auto-gamma automagically adjust gamma level of image", |
| 3227 | "-auto-level automagically adjust color levels of image", |
| 3228 | "-auto-orient automagically orient (rotate) image", |
| 3229 | "-bench iterations measure performance", |
| 3230 | "-black-threshold value", |
| 3231 | " force all pixels below the threshold into black", |
| 3232 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3233 | "-blur geometry reduce image noise and reduce detail levels", |
| 3234 | "-border geometry surround image with a border of color", |
| 3235 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3236 | "-brightness-contrast geometry", |
| 3237 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3238 | "-cdl filename color correct with a color decision list", |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 3239 | "-charcoal geometry simulate a charcoal drawing", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3240 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3241 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3242 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3243 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3244 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3245 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3246 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3247 | "-contrast enhance or reduce the image contrast", |
| 3248 | "-contrast-stretch geometry", |
| 3249 | " improve contrast by `stretching' the intensity range", |
| 3250 | "-convolve coefficients", |
| 3251 | " apply a convolution kernel to the image", |
| 3252 | "-cycle amount cycle the image colormap", |
| 3253 | "-decipher filename convert cipher pixels to plain pixels", |
| 3254 | "-deskew threshold straighten an image", |
| 3255 | "-despeckle reduce the speckles within an image", |
| 3256 | "-distort method args", |
| 3257 | " distort images according to given method ad args", |
| 3258 | "-draw string annotate the image with a graphic primitive", |
| 3259 | "-edge radius apply a filter to detect edges in the image", |
| 3260 | "-encipher filename convert plain pixels to cipher pixels", |
| 3261 | "-emboss radius emboss an image", |
| 3262 | "-enhance apply a digital filter to enhance a noisy image", |
| 3263 | "-equalize perform histogram equalization to an image", |
| 3264 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3265 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3266 | "-extent geometry set the image size", |
| 3267 | "-extract geometry extract area from image", |
| 3268 | "-fft implements the discrete Fourier transform (DFT)", |
| 3269 | "-flip flip image vertically", |
| 3270 | "-floodfill geometry color", |
| 3271 | " floodfill the image with color", |
| 3272 | "-flop flop image horizontally", |
| 3273 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3274 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3275 | " apply function over image values", |
| 3276 | "-gamma value level of gamma correction", |
| 3277 | "-gaussian-blur geometry", |
| 3278 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3279 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3280 | "-identify identify the format and characteristics of the image", |
| 3281 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3282 | "-implode amount implode image pixels about the center", |
| 3283 | "-lat geometry local adaptive thresholding", |
| 3284 | "-layers method optimize, merge, or compare image layers", |
| 3285 | "-level value adjust the level of image contrast", |
| 3286 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3287 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3288 | "-linear-stretch geometry", |
| 3289 | " improve contrast by `stretching with saturation'", |
| 3290 | "-liquid-rescale geometry", |
| 3291 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3292 | "-median geometry apply a median filter to the image", |
glennrp | 30d2dc6 | 2011-06-25 03:17:16 +0000 | [diff] [blame] | 3293 | "-mode geometry make each pixel the 'predominant color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3294 | "-modulate value vary the brightness, saturation, and hue", |
| 3295 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3296 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3297 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3298 | "-motion-blur geometry", |
| 3299 | " simulate motion blur", |
| 3300 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3301 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3302 | "-normalize transform image to span the full range of colors", |
| 3303 | "-opaque color change this color to the fill color", |
| 3304 | "-ordered-dither NxN", |
| 3305 | " add a noise pattern to the image with specific", |
| 3306 | " amplitudes", |
| 3307 | "-paint radius simulate an oil painting", |
| 3308 | "-polaroid angle simulate a Polaroid picture", |
| 3309 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3310 | "-profile filename add, delete, or apply an image profile", |
| 3311 | "-quantize colorspace reduce colors in this colorspace", |
| 3312 | "-radial-blur angle radial blur the image", |
| 3313 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3314 | "-random-threshold low,high", |
| 3315 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3316 | "-region geometry apply options to a portion of the image", |
| 3317 | "-render render vector graphics", |
| 3318 | "-repage geometry size and location of an image canvas", |
| 3319 | "-resample geometry change the resolution of an image", |
| 3320 | "-resize geometry resize the image", |
| 3321 | "-roll geometry roll an image vertically or horizontally", |
| 3322 | "-rotate degrees apply Paeth rotation to the image", |
| 3323 | "-sample geometry scale image with pixel sampling", |
| 3324 | "-scale geometry scale the image", |
| 3325 | "-segment values segment an image", |
| 3326 | "-selective-blur geometry", |
| 3327 | " selectively blur pixels within a contrast threshold", |
| 3328 | "-sepia-tone threshold", |
| 3329 | " simulate a sepia-toned photo", |
| 3330 | "-set property value set an image property", |
| 3331 | "-shade degrees shade the image using a distant light source", |
| 3332 | "-shadow geometry simulate an image shadow", |
| 3333 | "-sharpen geometry sharpen the image", |
| 3334 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3335 | "-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] | 3336 | "-sigmoidal-contrast geometry", |
| 3337 | " increase the contrast without saturating highlights or shadows", |
| 3338 | "-sketch geometry simulate a pencil sketch", |
| 3339 | "-solarize threshold negate all pixels above the threshold level", |
| 3340 | "-sparse-color method args", |
| 3341 | " fill in a image based on a few color points", |
| 3342 | "-splice geometry splice the background color into the image", |
| 3343 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3344 | "-statistic type radius", |
| 3345 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3346 | "-strip strip image of all profiles and comments", |
| 3347 | "-swirl degrees swirl image pixels about the center", |
| 3348 | "-threshold value threshold the image", |
| 3349 | "-thumbnail geometry create a thumbnail of the image", |
| 3350 | "-tile filename tile image when filling a graphic primitive", |
| 3351 | "-tint value tint the image with the fill color", |
| 3352 | "-transform affine transform image", |
| 3353 | "-transparent color make this color transparent within the image", |
| 3354 | "-transpose flip image vertically and rotate 90 degrees", |
| 3355 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3356 | "-trim trim image edges", |
| 3357 | "-type type image type", |
| 3358 | "-unique-colors discard all but one of any pixel color", |
| 3359 | "-unsharp geometry sharpen the image", |
| 3360 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3361 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3362 | "-white-threshold value", |
| 3363 | " force all pixels above the threshold into white", |
| 3364 | (char *) NULL |
| 3365 | }, |
| 3366 | *sequence_operators[]= |
| 3367 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3368 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3369 | "-clut apply a color lookup table to the image", |
| 3370 | "-coalesce merge a sequence of images", |
| 3371 | "-combine combine a sequence of images", |
| 3372 | "-composite composite image", |
| 3373 | "-crop geometry cut out a rectangular region of the image", |
| 3374 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3375 | "-evaluate-sequence operator", |
| 3376 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3377 | "-flatten flatten a sequence of images", |
| 3378 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3379 | "-hald-clut apply a Hald color lookup table to the image", |
| 3380 | "-morph value morph an image sequence", |
| 3381 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3382 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3383 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3384 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3385 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3386 | "-write filename write images to this file", |
| 3387 | (char *) NULL |
| 3388 | }, |
| 3389 | *settings[]= |
| 3390 | { |
| 3391 | "-adjoin join images into a single multi-image file", |
| 3392 | "-affine matrix affine transform matrix", |
| 3393 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3394 | "-antialias remove pixel-aliasing", |
| 3395 | "-authenticate password", |
| 3396 | " decipher image with this password", |
| 3397 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3398 | "-background color background color", |
| 3399 | "-bias value add bias when convolving an image", |
| 3400 | "-black-point-compensation", |
| 3401 | " use black point compensation", |
| 3402 | "-blue-primary point chromaticity blue primary point", |
| 3403 | "-bordercolor color border color", |
| 3404 | "-caption string assign a caption to an image", |
| 3405 | "-channel type apply option to select image channels", |
| 3406 | "-colors value preferred number of colors in the image", |
| 3407 | "-colorspace type alternate image colorspace", |
| 3408 | "-comment string annotate image with comment", |
| 3409 | "-compose operator set image composite operator", |
| 3410 | "-compress type type of pixel compression when writing the image", |
| 3411 | "-define format:option", |
| 3412 | " define one or more image format options", |
| 3413 | "-delay value display the next image after pausing", |
| 3414 | "-density geometry horizontal and vertical density of the image", |
| 3415 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3416 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3417 | "-display server get image or font from this X server", |
| 3418 | "-dispose method layer disposal method", |
| 3419 | "-dither method apply error diffusion to image", |
| 3420 | "-encoding type text encoding type", |
| 3421 | "-endian type endianness (MSB or LSB) of the image", |
| 3422 | "-family name render text with this font family", |
| 3423 | "-fill color color to use when filling a graphic primitive", |
| 3424 | "-filter type use this filter when resizing an image", |
| 3425 | "-font name render text with this font", |
| 3426 | "-format \"string\" output formatted image characteristics", |
| 3427 | "-fuzz distance colors within this distance are considered equal", |
| 3428 | "-gravity type horizontal and vertical text placement", |
| 3429 | "-green-primary point chromaticity green primary point", |
| 3430 | "-intent type type of rendering intent when managing the image color", |
| 3431 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3432 | "-interline-spacing value", |
| 3433 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3434 | "-interpolate method pixel color interpolation method", |
| 3435 | "-interword-spacing value", |
| 3436 | " set the space between two words", |
| 3437 | "-kerning value set the space between two letters", |
| 3438 | "-label string assign a label to an image", |
| 3439 | "-limit type value pixel cache resource limit", |
| 3440 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3441 | "-mask filename associate a mask with the image", |
| 3442 | "-mattecolor color frame color", |
| 3443 | "-monitor monitor progress", |
| 3444 | "-orient type image orientation", |
| 3445 | "-page geometry size and location of an image canvas (setting)", |
| 3446 | "-ping efficiently determine image attributes", |
| 3447 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3448 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3449 | "-preview type image preview type", |
| 3450 | "-quality value JPEG/MIFF/PNG compression level", |
| 3451 | "-quiet suppress all warning messages", |
| 3452 | "-red-primary point chromaticity red primary point", |
| 3453 | "-regard-warnings pay attention to warning messages", |
| 3454 | "-remap filename transform image colors to match this set of colors", |
| 3455 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3456 | "-sampling-factor geometry", |
| 3457 | " horizontal and vertical sampling factor", |
| 3458 | "-scene value image scene number", |
| 3459 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3460 | "-size geometry width and height of image", |
| 3461 | "-stretch type render text with this font stretch", |
| 3462 | "-stroke color graphic primitive stroke color", |
| 3463 | "-strokewidth value graphic primitive stroke width", |
| 3464 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3465 | "-synchronize synchronize image to storage device", |
| 3466 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3467 | "-texture filename name of texture to tile onto the image background", |
| 3468 | "-tile-offset geometry", |
| 3469 | " tile offset", |
| 3470 | "-treedepth value color tree depth", |
| 3471 | "-transparent-color color", |
| 3472 | " transparent color", |
| 3473 | "-undercolor color annotation bounding box color", |
| 3474 | "-units type the units of image resolution", |
| 3475 | "-verbose print detailed information about the image", |
| 3476 | "-view FlashPix viewing transforms", |
| 3477 | "-virtual-pixel method", |
| 3478 | " virtual pixel access method", |
| 3479 | "-weight type render text with this font weight", |
| 3480 | "-white-point point chromaticity white point", |
| 3481 | (char *) NULL |
| 3482 | }, |
| 3483 | *stack_operators[]= |
| 3484 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3485 | "-delete indexes delete the image from the image sequence", |
| 3486 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3487 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3488 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3489 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3490 | "-swap indexes swap two images in the image sequence", |
| 3491 | (char *) NULL |
| 3492 | }; |
| 3493 | |
| 3494 | const char |
| 3495 | **p; |
| 3496 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3497 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3498 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3499 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3500 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3501 | GetClientName()); |
| 3502 | (void) printf("\nImage Settings:\n"); |
| 3503 | for (p=settings; *p != (char *) NULL; p++) |
| 3504 | (void) printf(" %s\n",*p); |
| 3505 | (void) printf("\nImage Operators:\n"); |
| 3506 | for (p=operators; *p != (char *) NULL; p++) |
| 3507 | (void) printf(" %s\n",*p); |
| 3508 | (void) printf("\nImage Sequence Operators:\n"); |
| 3509 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3510 | (void) printf(" %s\n",*p); |
| 3511 | (void) printf("\nImage Stack Operators:\n"); |
| 3512 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3513 | (void) printf(" %s\n",*p); |
| 3514 | (void) printf("\nMiscellaneous Options:\n"); |
| 3515 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3516 | (void) printf(" %s\n",*p); |
| 3517 | (void) printf( |
| 3518 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3519 | (void) printf( |
| 3520 | "number. To specify a particular image format, precede the filename\n"); |
| 3521 | (void) printf( |
| 3522 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3523 | (void) printf( |
| 3524 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3525 | (void) printf("'-' for standard input or output.\n"); |
| 3526 | return(MagickFalse); |
| 3527 | } |
| 3528 | |
| 3529 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3530 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3531 | { |
| 3532 | #define DestroyMogrify() \ |
| 3533 | { \ |
| 3534 | if (format != (char *) NULL) \ |
| 3535 | format=DestroyString(format); \ |
| 3536 | if (path != (char *) NULL) \ |
| 3537 | path=DestroyString(path); \ |
| 3538 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3539 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3540 | argv[i]=DestroyString(argv[i]); \ |
| 3541 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3542 | } |
| 3543 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3544 | { \ |
| 3545 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3546 | option); \ |
| 3547 | DestroyMogrify(); \ |
| 3548 | return(MagickFalse); \ |
| 3549 | } |
| 3550 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3551 | { \ |
| 3552 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3553 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3554 | DestroyMogrify(); \ |
| 3555 | return(MagickFalse); \ |
| 3556 | } |
| 3557 | |
| 3558 | char |
| 3559 | *format, |
| 3560 | *option, |
| 3561 | *path; |
| 3562 | |
| 3563 | Image |
| 3564 | *image; |
| 3565 | |
| 3566 | ImageStack |
| 3567 | image_stack[MaxImageStackDepth+1]; |
| 3568 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3569 | MagickBooleanType |
| 3570 | global_colormap; |
| 3571 | |
| 3572 | MagickBooleanType |
| 3573 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3574 | pend, |
| 3575 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3576 | |
| 3577 | MagickStatusType |
| 3578 | status; |
| 3579 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3580 | register ssize_t |
| 3581 | i; |
| 3582 | |
| 3583 | ssize_t |
| 3584 | j, |
| 3585 | k; |
| 3586 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3587 | /* |
| 3588 | Set defaults. |
| 3589 | */ |
| 3590 | assert(image_info != (ImageInfo *) NULL); |
| 3591 | assert(image_info->signature == MagickSignature); |
| 3592 | if (image_info->debug != MagickFalse) |
| 3593 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3594 | assert(exception != (ExceptionInfo *) NULL); |
| 3595 | if (argc == 2) |
| 3596 | { |
| 3597 | option=argv[1]; |
| 3598 | if ((LocaleCompare("version",option+1) == 0) || |
| 3599 | (LocaleCompare("-version",option+1) == 0)) |
| 3600 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3601 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3602 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 3603 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 3604 | GetMagickCopyright()); |
| 3605 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 3606 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3607 | return(MagickFalse); |
| 3608 | } |
| 3609 | } |
| 3610 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3611 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3612 | format=(char *) NULL; |
| 3613 | path=(char *) NULL; |
| 3614 | global_colormap=MagickFalse; |
| 3615 | k=0; |
| 3616 | j=1; |
| 3617 | NewImageStack(); |
| 3618 | option=(char *) NULL; |
| 3619 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3620 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3621 | status=MagickTrue; |
| 3622 | /* |
| 3623 | Parse command line. |
| 3624 | */ |
| 3625 | ReadCommandlLine(argc,&argv); |
| 3626 | status=ExpandFilenames(&argc,&argv); |
| 3627 | if (status == MagickFalse) |
| 3628 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3629 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3630 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3631 | { |
| 3632 | option=argv[i]; |
| 3633 | if (LocaleCompare(option,"(") == 0) |
| 3634 | { |
| 3635 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3636 | if (k == MaxImageStackDepth) |
| 3637 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3638 | option); |
| 3639 | PushImageStack(); |
| 3640 | continue; |
| 3641 | } |
| 3642 | if (LocaleCompare(option,")") == 0) |
| 3643 | { |
| 3644 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3645 | if (k == 0) |
| 3646 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3647 | PopImageStack(); |
| 3648 | continue; |
| 3649 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3650 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3651 | { |
| 3652 | char |
| 3653 | backup_filename[MaxTextExtent], |
| 3654 | *filename; |
| 3655 | |
| 3656 | Image |
| 3657 | *images; |
| 3658 | |
| 3659 | /* |
| 3660 | Option is a file name: begin by reading image from specified file. |
| 3661 | */ |
| 3662 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3663 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3664 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3665 | filename=argv[++i]; |
| 3666 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 3667 | images=ReadImages(image_info,exception); |
| 3668 | status&=(images != (Image *) NULL) && |
| 3669 | (exception->severity < ErrorException); |
| 3670 | if (images == (Image *) NULL) |
| 3671 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3672 | if (format != (char *) NULL) |
| 3673 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3674 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3675 | if (path != (char *) NULL) |
| 3676 | { |
| 3677 | GetPathComponent(option,TailPath,filename); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3678 | (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3679 | path,*DirectorySeparator,filename); |
| 3680 | } |
| 3681 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3682 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3683 | AppendImageStack(images); |
| 3684 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3685 | if (global_colormap != MagickFalse) |
| 3686 | { |
| 3687 | QuantizeInfo |
| 3688 | *quantize_info; |
| 3689 | |
| 3690 | quantize_info=AcquireQuantizeInfo(image_info); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3691 | (void) RemapImages(quantize_info,images,(Image *) NULL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3692 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3693 | } |
| 3694 | *backup_filename='\0'; |
| 3695 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3696 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3697 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3698 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3699 | i; |
| 3700 | |
| 3701 | /* |
| 3702 | Rename image file as backup. |
| 3703 | */ |
| 3704 | (void) CopyMagickString(backup_filename,image->filename, |
| 3705 | MaxTextExtent); |
| 3706 | for (i=0; i < 6; i++) |
| 3707 | { |
| 3708 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3709 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3710 | break; |
| 3711 | } |
| 3712 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
| 3713 | (rename(image->filename,backup_filename) != 0)) |
| 3714 | *backup_filename='\0'; |
| 3715 | } |
| 3716 | /* |
| 3717 | Write transmogrified image to disk. |
| 3718 | */ |
| 3719 | image_info->synchronize=MagickTrue; |
| 3720 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3721 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
| 3722 | (void) remove(backup_filename); |
| 3723 | RemoveAllImageStack(); |
| 3724 | continue; |
| 3725 | } |
| 3726 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3727 | switch (*(option+1)) |
| 3728 | { |
| 3729 | case 'a': |
| 3730 | { |
| 3731 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3732 | { |
| 3733 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3734 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3735 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3736 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3737 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3738 | break; |
| 3739 | } |
| 3740 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3741 | { |
| 3742 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3743 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3744 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3745 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3746 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3747 | break; |
| 3748 | } |
| 3749 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3750 | { |
| 3751 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3752 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3753 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3754 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3755 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3756 | break; |
| 3757 | } |
| 3758 | if (LocaleCompare("affine",option+1) == 0) |
| 3759 | { |
| 3760 | if (*option == '+') |
| 3761 | break; |
| 3762 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3763 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3764 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3765 | break; |
| 3766 | } |
| 3767 | if (LocaleCompare("alpha",option+1) == 0) |
| 3768 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3769 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3770 | type; |
| 3771 | |
| 3772 | if (*option == '+') |
| 3773 | break; |
| 3774 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3775 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3776 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3777 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3778 | if (type < 0) |
| 3779 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3780 | argv[i]); |
| 3781 | break; |
| 3782 | } |
| 3783 | if (LocaleCompare("annotate",option+1) == 0) |
| 3784 | { |
| 3785 | if (*option == '+') |
| 3786 | break; |
| 3787 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3788 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3789 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3790 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3791 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3792 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3793 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3794 | i++; |
| 3795 | break; |
| 3796 | } |
| 3797 | if (LocaleCompare("antialias",option+1) == 0) |
| 3798 | break; |
| 3799 | if (LocaleCompare("append",option+1) == 0) |
| 3800 | break; |
| 3801 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3802 | { |
| 3803 | if (*option == '+') |
| 3804 | break; |
| 3805 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3806 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3807 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3808 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3809 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3810 | break; |
| 3811 | } |
| 3812 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3813 | { |
| 3814 | if (*option == '+') |
| 3815 | break; |
| 3816 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3817 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3818 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3819 | break; |
| 3820 | } |
| 3821 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3822 | break; |
| 3823 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3824 | break; |
| 3825 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3826 | break; |
| 3827 | if (LocaleCompare("average",option+1) == 0) |
| 3828 | break; |
| 3829 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3830 | } |
| 3831 | case 'b': |
| 3832 | { |
| 3833 | if (LocaleCompare("background",option+1) == 0) |
| 3834 | { |
| 3835 | if (*option == '+') |
| 3836 | break; |
| 3837 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3838 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3839 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3840 | break; |
| 3841 | } |
| 3842 | if (LocaleCompare("bias",option+1) == 0) |
| 3843 | { |
| 3844 | if (*option == '+') |
| 3845 | break; |
| 3846 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3847 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3848 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3849 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3850 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3851 | break; |
| 3852 | } |
| 3853 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 3854 | break; |
| 3855 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 3856 | { |
| 3857 | if (*option == '+') |
| 3858 | break; |
| 3859 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3860 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3861 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3862 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3863 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3864 | break; |
| 3865 | } |
| 3866 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3867 | { |
| 3868 | if (*option == '+') |
| 3869 | break; |
| 3870 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3871 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3872 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3873 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3874 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3875 | break; |
| 3876 | } |
| 3877 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3878 | { |
| 3879 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3880 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3881 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3882 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3883 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3884 | break; |
| 3885 | } |
| 3886 | if (LocaleCompare("blur",option+1) == 0) |
| 3887 | { |
| 3888 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3889 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3890 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3891 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3892 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3893 | break; |
| 3894 | } |
| 3895 | if (LocaleCompare("border",option+1) == 0) |
| 3896 | { |
| 3897 | if (*option == '+') |
| 3898 | break; |
| 3899 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3900 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3901 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3902 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3903 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3904 | break; |
| 3905 | } |
| 3906 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3907 | { |
| 3908 | if (*option == '+') |
| 3909 | break; |
| 3910 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3911 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3912 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3913 | break; |
| 3914 | } |
| 3915 | if (LocaleCompare("box",option+1) == 0) |
| 3916 | { |
| 3917 | if (*option == '+') |
| 3918 | break; |
| 3919 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3920 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3921 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3922 | break; |
| 3923 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3924 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 3925 | { |
| 3926 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3927 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3928 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3929 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3930 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3931 | break; |
| 3932 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3933 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3934 | } |
| 3935 | case 'c': |
| 3936 | { |
| 3937 | if (LocaleCompare("cache",option+1) == 0) |
| 3938 | { |
| 3939 | if (*option == '+') |
| 3940 | break; |
| 3941 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3942 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3943 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3944 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3945 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3946 | break; |
| 3947 | } |
| 3948 | if (LocaleCompare("caption",option+1) == 0) |
| 3949 | { |
| 3950 | if (*option == '+') |
| 3951 | break; |
| 3952 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3953 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3954 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3955 | break; |
| 3956 | } |
| 3957 | if (LocaleCompare("channel",option+1) == 0) |
| 3958 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3959 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3960 | channel; |
| 3961 | |
| 3962 | if (*option == '+') |
| 3963 | break; |
| 3964 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3965 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3966 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3967 | channel=ParseChannelOption(argv[i]); |
| 3968 | if (channel < 0) |
| 3969 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 3970 | argv[i]); |
| 3971 | break; |
| 3972 | } |
| 3973 | if (LocaleCompare("cdl",option+1) == 0) |
| 3974 | { |
| 3975 | if (*option == '+') |
| 3976 | break; |
| 3977 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3978 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3979 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3980 | break; |
| 3981 | } |
| 3982 | if (LocaleCompare("charcoal",option+1) == 0) |
| 3983 | { |
| 3984 | if (*option == '+') |
| 3985 | break; |
| 3986 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3987 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3988 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3989 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3990 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3991 | break; |
| 3992 | } |
| 3993 | if (LocaleCompare("chop",option+1) == 0) |
| 3994 | { |
| 3995 | if (*option == '+') |
| 3996 | break; |
| 3997 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3998 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3999 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4000 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4001 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4002 | break; |
| 4003 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4004 | if (LocaleCompare("clamp",option+1) == 0) |
| 4005 | break; |
| 4006 | if (LocaleCompare("clip",option+1) == 0) |
| 4007 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4008 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4009 | { |
| 4010 | if (*option == '+') |
| 4011 | break; |
| 4012 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4013 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4014 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4015 | break; |
| 4016 | } |
| 4017 | if (LocaleCompare("clut",option+1) == 0) |
| 4018 | break; |
| 4019 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4020 | break; |
| 4021 | if (LocaleCompare("colorize",option+1) == 0) |
| 4022 | { |
| 4023 | if (*option == '+') |
| 4024 | break; |
| 4025 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4026 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4027 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4028 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4029 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4030 | break; |
| 4031 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4032 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4033 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4034 | KernelInfo |
| 4035 | *kernel_info; |
| 4036 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4037 | if (*option == '+') |
| 4038 | break; |
| 4039 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4040 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4041 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4042 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4043 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4044 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4045 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4046 | break; |
| 4047 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4048 | if (LocaleCompare("colors",option+1) == 0) |
| 4049 | { |
| 4050 | if (*option == '+') |
| 4051 | break; |
| 4052 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4053 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4054 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4055 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4056 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4057 | break; |
| 4058 | } |
| 4059 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4060 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4061 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4062 | colorspace; |
| 4063 | |
| 4064 | if (*option == '+') |
| 4065 | break; |
| 4066 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4067 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4068 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4069 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4070 | argv[i]); |
| 4071 | if (colorspace < 0) |
| 4072 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4073 | argv[i]); |
| 4074 | break; |
| 4075 | } |
| 4076 | if (LocaleCompare("combine",option+1) == 0) |
| 4077 | break; |
| 4078 | if (LocaleCompare("comment",option+1) == 0) |
| 4079 | { |
| 4080 | if (*option == '+') |
| 4081 | break; |
| 4082 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4083 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4084 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4085 | break; |
| 4086 | } |
| 4087 | if (LocaleCompare("composite",option+1) == 0) |
| 4088 | break; |
| 4089 | if (LocaleCompare("compress",option+1) == 0) |
| 4090 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4091 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4092 | compress; |
| 4093 | |
| 4094 | if (*option == '+') |
| 4095 | break; |
| 4096 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4097 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4098 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4099 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4100 | argv[i]); |
| 4101 | if (compress < 0) |
| 4102 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4103 | argv[i]); |
| 4104 | break; |
| 4105 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4106 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4107 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4108 | if (LocaleCompare("contrast",option+1) == 0) |
| 4109 | break; |
| 4110 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4111 | { |
| 4112 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4113 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4114 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4115 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4116 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4117 | break; |
| 4118 | } |
| 4119 | if (LocaleCompare("convolve",option+1) == 0) |
| 4120 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4121 | KernelInfo |
| 4122 | *kernel_info; |
| 4123 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4124 | if (*option == '+') |
| 4125 | break; |
| 4126 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4127 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4128 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4129 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4130 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4131 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4132 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4133 | break; |
| 4134 | } |
| 4135 | if (LocaleCompare("crop",option+1) == 0) |
| 4136 | { |
| 4137 | if (*option == '+') |
| 4138 | break; |
| 4139 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4140 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4141 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4142 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4143 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4144 | break; |
| 4145 | } |
| 4146 | if (LocaleCompare("cycle",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 | } |
| 4157 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4158 | } |
| 4159 | case 'd': |
| 4160 | { |
| 4161 | if (LocaleCompare("decipher",option+1) == 0) |
| 4162 | { |
| 4163 | if (*option == '+') |
| 4164 | break; |
| 4165 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4166 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4167 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4168 | break; |
| 4169 | } |
| 4170 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4171 | break; |
| 4172 | if (LocaleCompare("debug",option+1) == 0) |
| 4173 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4174 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4175 | event; |
| 4176 | |
| 4177 | if (*option == '+') |
| 4178 | break; |
| 4179 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4180 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4181 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4182 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4183 | if (event < 0) |
| 4184 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4185 | argv[i]); |
| 4186 | (void) SetLogEventMask(argv[i]); |
| 4187 | break; |
| 4188 | } |
| 4189 | if (LocaleCompare("define",option+1) == 0) |
| 4190 | { |
| 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); |
| 4194 | if (*option == '+') |
| 4195 | { |
| 4196 | const char |
| 4197 | *define; |
| 4198 | |
| 4199 | define=GetImageOption(image_info,argv[i]); |
| 4200 | if (define == (const char *) NULL) |
| 4201 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4202 | break; |
| 4203 | } |
| 4204 | break; |
| 4205 | } |
| 4206 | if (LocaleCompare("delay",option+1) == 0) |
| 4207 | { |
| 4208 | if (*option == '+') |
| 4209 | break; |
| 4210 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4211 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4212 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4213 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4214 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4215 | break; |
| 4216 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4217 | if (LocaleCompare("delete",option+1) == 0) |
| 4218 | { |
| 4219 | if (*option == '+') |
| 4220 | break; |
| 4221 | i++; |
| 4222 | if (i == (ssize_t) (argc-1)) |
| 4223 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4224 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4225 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4226 | break; |
| 4227 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4228 | if (LocaleCompare("density",option+1) == 0) |
| 4229 | { |
| 4230 | if (*option == '+') |
| 4231 | break; |
| 4232 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4233 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4234 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4235 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4236 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4237 | break; |
| 4238 | } |
| 4239 | if (LocaleCompare("depth",option+1) == 0) |
| 4240 | { |
| 4241 | if (*option == '+') |
| 4242 | break; |
| 4243 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4244 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4245 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4246 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4247 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4248 | break; |
| 4249 | } |
| 4250 | if (LocaleCompare("deskew",option+1) == 0) |
| 4251 | { |
| 4252 | if (*option == '+') |
| 4253 | break; |
| 4254 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4255 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4256 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4257 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4258 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4259 | break; |
| 4260 | } |
| 4261 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4262 | break; |
| 4263 | if (LocaleCompare("dft",option+1) == 0) |
| 4264 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4265 | if (LocaleCompare("direction",option+1) == 0) |
| 4266 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4267 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4268 | direction; |
| 4269 | |
| 4270 | if (*option == '+') |
| 4271 | break; |
| 4272 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4273 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4274 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4275 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4276 | argv[i]); |
| 4277 | if (direction < 0) |
| 4278 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4279 | argv[i]); |
| 4280 | break; |
| 4281 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4282 | if (LocaleCompare("display",option+1) == 0) |
| 4283 | { |
| 4284 | if (*option == '+') |
| 4285 | break; |
| 4286 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4287 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4288 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4289 | break; |
| 4290 | } |
| 4291 | if (LocaleCompare("dispose",option+1) == 0) |
| 4292 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4293 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4294 | dispose; |
| 4295 | |
| 4296 | if (*option == '+') |
| 4297 | break; |
| 4298 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4299 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4300 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4301 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4302 | if (dispose < 0) |
| 4303 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4304 | argv[i]); |
| 4305 | break; |
| 4306 | } |
| 4307 | if (LocaleCompare("distort",option+1) == 0) |
| 4308 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4309 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4310 | op; |
| 4311 | |
| 4312 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4313 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4314 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4315 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4316 | if (op < 0) |
| 4317 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4318 | argv[i]); |
| 4319 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4320 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4321 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4322 | break; |
| 4323 | } |
| 4324 | if (LocaleCompare("dither",option+1) == 0) |
| 4325 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4326 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4327 | method; |
| 4328 | |
| 4329 | if (*option == '+') |
| 4330 | break; |
| 4331 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4332 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4333 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4334 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4335 | if (method < 0) |
| 4336 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4337 | argv[i]); |
| 4338 | break; |
| 4339 | } |
| 4340 | if (LocaleCompare("draw",option+1) == 0) |
| 4341 | { |
| 4342 | if (*option == '+') |
| 4343 | break; |
| 4344 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4345 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4346 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4347 | break; |
| 4348 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4349 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4350 | { |
| 4351 | if (*option == '+') |
| 4352 | break; |
| 4353 | i++; |
| 4354 | if (i == (ssize_t) (argc-1)) |
| 4355 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4356 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4357 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4358 | break; |
| 4359 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4360 | if (LocaleCompare("duration",option+1) == 0) |
| 4361 | { |
| 4362 | if (*option == '+') |
| 4363 | break; |
| 4364 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4365 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4366 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4367 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4368 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4369 | break; |
| 4370 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4371 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4372 | } |
| 4373 | case 'e': |
| 4374 | { |
| 4375 | if (LocaleCompare("edge",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("emboss",option+1) == 0) |
| 4387 | { |
| 4388 | if (*option == '+') |
| 4389 | break; |
| 4390 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4391 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4392 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4393 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4394 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4395 | break; |
| 4396 | } |
| 4397 | if (LocaleCompare("encipher",option+1) == 0) |
| 4398 | { |
| 4399 | if (*option == '+') |
| 4400 | break; |
| 4401 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4402 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4403 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4404 | break; |
| 4405 | } |
| 4406 | if (LocaleCompare("encoding",option+1) == 0) |
| 4407 | { |
| 4408 | if (*option == '+') |
| 4409 | break; |
| 4410 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4411 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4412 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4413 | break; |
| 4414 | } |
| 4415 | if (LocaleCompare("endian",option+1) == 0) |
| 4416 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4417 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4418 | endian; |
| 4419 | |
| 4420 | if (*option == '+') |
| 4421 | break; |
| 4422 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4423 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4424 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4425 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4426 | if (endian < 0) |
| 4427 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4428 | argv[i]); |
| 4429 | break; |
| 4430 | } |
| 4431 | if (LocaleCompare("enhance",option+1) == 0) |
| 4432 | break; |
| 4433 | if (LocaleCompare("equalize",option+1) == 0) |
| 4434 | break; |
| 4435 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4436 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4437 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4438 | op; |
| 4439 | |
| 4440 | if (*option == '+') |
| 4441 | break; |
| 4442 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4443 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4444 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4445 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4446 | if (op < 0) |
| 4447 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4448 | argv[i]); |
| 4449 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4450 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4451 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4452 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4453 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4454 | break; |
| 4455 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4456 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4457 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4458 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4459 | op; |
| 4460 | |
| 4461 | if (*option == '+') |
| 4462 | break; |
| 4463 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4464 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4465 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4466 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4467 | if (op < 0) |
| 4468 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4469 | argv[i]); |
| 4470 | break; |
| 4471 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4472 | if (LocaleCompare("extent",option+1) == 0) |
| 4473 | { |
| 4474 | if (*option == '+') |
| 4475 | break; |
| 4476 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4477 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4478 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4479 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4480 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4481 | break; |
| 4482 | } |
| 4483 | if (LocaleCompare("extract",option+1) == 0) |
| 4484 | { |
| 4485 | if (*option == '+') |
| 4486 | break; |
| 4487 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4488 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4489 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4490 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4491 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4492 | break; |
| 4493 | } |
| 4494 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4495 | } |
| 4496 | case 'f': |
| 4497 | { |
| 4498 | if (LocaleCompare("family",option+1) == 0) |
| 4499 | { |
| 4500 | if (*option == '+') |
| 4501 | break; |
| 4502 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4503 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4504 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4505 | break; |
| 4506 | } |
| 4507 | if (LocaleCompare("fill",option+1) == 0) |
| 4508 | { |
| 4509 | if (*option == '+') |
| 4510 | break; |
| 4511 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4512 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4513 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4514 | break; |
| 4515 | } |
| 4516 | if (LocaleCompare("filter",option+1) == 0) |
| 4517 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4518 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4519 | filter; |
| 4520 | |
| 4521 | if (*option == '+') |
| 4522 | break; |
| 4523 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4524 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4525 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4526 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4527 | if (filter < 0) |
| 4528 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4529 | argv[i]); |
| 4530 | break; |
| 4531 | } |
| 4532 | if (LocaleCompare("flatten",option+1) == 0) |
| 4533 | break; |
| 4534 | if (LocaleCompare("flip",option+1) == 0) |
| 4535 | break; |
| 4536 | if (LocaleCompare("flop",option+1) == 0) |
| 4537 | break; |
| 4538 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4539 | { |
| 4540 | if (*option == '+') |
| 4541 | break; |
| 4542 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4543 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4544 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4545 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4546 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 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); |
| 4550 | break; |
| 4551 | } |
| 4552 | if (LocaleCompare("font",option+1) == 0) |
| 4553 | { |
| 4554 | if (*option == '+') |
| 4555 | break; |
| 4556 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4557 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4558 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4559 | break; |
| 4560 | } |
| 4561 | if (LocaleCompare("format",option+1) == 0) |
| 4562 | { |
| 4563 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4564 | (void) CloneString(&format,(char *) NULL); |
| 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); |
| 4570 | (void) CloneString(&format,argv[i]); |
| 4571 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4572 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4573 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4574 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4575 | if (*image_info->magick == '\0') |
| 4576 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4577 | format); |
| 4578 | break; |
| 4579 | } |
| 4580 | if (LocaleCompare("frame",option+1) == 0) |
| 4581 | { |
| 4582 | if (*option == '+') |
| 4583 | break; |
| 4584 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4585 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4586 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4587 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4588 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4589 | break; |
| 4590 | } |
| 4591 | if (LocaleCompare("function",option+1) == 0) |
| 4592 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4593 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4594 | op; |
| 4595 | |
| 4596 | if (*option == '+') |
| 4597 | break; |
| 4598 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4599 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4600 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4601 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4602 | if (op < 0) |
| 4603 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4604 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4605 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4606 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4607 | break; |
| 4608 | } |
| 4609 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4610 | { |
| 4611 | if (*option == '+') |
| 4612 | break; |
| 4613 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4614 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4615 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4616 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4617 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4618 | break; |
| 4619 | } |
| 4620 | if (LocaleCompare("fx",option+1) == 0) |
| 4621 | { |
| 4622 | if (*option == '+') |
| 4623 | break; |
| 4624 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4625 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4626 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4627 | break; |
| 4628 | } |
| 4629 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4630 | } |
| 4631 | case 'g': |
| 4632 | { |
| 4633 | if (LocaleCompare("gamma",option+1) == 0) |
| 4634 | { |
| 4635 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4636 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4637 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4638 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4639 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4640 | break; |
| 4641 | } |
| 4642 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4643 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4644 | { |
| 4645 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4646 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4647 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4648 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4649 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4650 | break; |
| 4651 | } |
| 4652 | if (LocaleCompare("geometry",option+1) == 0) |
| 4653 | { |
| 4654 | if (*option == '+') |
| 4655 | break; |
| 4656 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4657 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4658 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4659 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4660 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4661 | break; |
| 4662 | } |
| 4663 | if (LocaleCompare("gravity",option+1) == 0) |
| 4664 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4665 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4666 | gravity; |
| 4667 | |
| 4668 | if (*option == '+') |
| 4669 | break; |
| 4670 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4671 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4672 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4673 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4674 | if (gravity < 0) |
| 4675 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4676 | argv[i]); |
| 4677 | break; |
| 4678 | } |
| 4679 | if (LocaleCompare("green-primary",option+1) == 0) |
| 4680 | { |
| 4681 | if (*option == '+') |
| 4682 | break; |
| 4683 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4684 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4685 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4686 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4687 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4688 | break; |
| 4689 | } |
| 4690 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4691 | } |
| 4692 | case 'h': |
| 4693 | { |
| 4694 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4695 | break; |
| 4696 | if ((LocaleCompare("help",option+1) == 0) || |
| 4697 | (LocaleCompare("-help",option+1) == 0)) |
| 4698 | return(MogrifyUsage()); |
| 4699 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4700 | } |
| 4701 | case 'i': |
| 4702 | { |
| 4703 | if (LocaleCompare("identify",option+1) == 0) |
| 4704 | break; |
| 4705 | if (LocaleCompare("idft",option+1) == 0) |
| 4706 | break; |
| 4707 | if (LocaleCompare("implode",option+1) == 0) |
| 4708 | { |
| 4709 | if (*option == '+') |
| 4710 | break; |
| 4711 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4712 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4713 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4714 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4715 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4716 | break; |
| 4717 | } |
| 4718 | if (LocaleCompare("intent",option+1) == 0) |
| 4719 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4720 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4721 | intent; |
| 4722 | |
| 4723 | if (*option == '+') |
| 4724 | break; |
| 4725 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4726 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4727 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4728 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4729 | if (intent < 0) |
| 4730 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4731 | argv[i]); |
| 4732 | break; |
| 4733 | } |
| 4734 | if (LocaleCompare("interlace",option+1) == 0) |
| 4735 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4736 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4737 | interlace; |
| 4738 | |
| 4739 | if (*option == '+') |
| 4740 | break; |
| 4741 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4742 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4743 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4744 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4745 | argv[i]); |
| 4746 | if (interlace < 0) |
| 4747 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4748 | argv[i]); |
| 4749 | break; |
| 4750 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4751 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4752 | { |
| 4753 | if (*option == '+') |
| 4754 | break; |
| 4755 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4756 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4757 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4758 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4759 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4760 | break; |
| 4761 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4762 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4763 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4764 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4765 | interpolate; |
| 4766 | |
| 4767 | if (*option == '+') |
| 4768 | break; |
| 4769 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4770 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4771 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4772 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4773 | argv[i]); |
| 4774 | if (interpolate < 0) |
| 4775 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4776 | argv[i]); |
| 4777 | break; |
| 4778 | } |
| 4779 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4780 | { |
| 4781 | if (*option == '+') |
| 4782 | break; |
| 4783 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4784 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4785 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4786 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4787 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4788 | break; |
| 4789 | } |
| 4790 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4791 | } |
| 4792 | case 'k': |
| 4793 | { |
| 4794 | if (LocaleCompare("kerning",option+1) == 0) |
| 4795 | { |
| 4796 | if (*option == '+') |
| 4797 | break; |
| 4798 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4799 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4800 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4801 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4802 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4803 | break; |
| 4804 | } |
| 4805 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4806 | } |
| 4807 | case 'l': |
| 4808 | { |
| 4809 | if (LocaleCompare("label",option+1) == 0) |
| 4810 | { |
| 4811 | if (*option == '+') |
| 4812 | break; |
| 4813 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4814 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4815 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4816 | break; |
| 4817 | } |
| 4818 | if (LocaleCompare("lat",option+1) == 0) |
| 4819 | { |
| 4820 | if (*option == '+') |
| 4821 | break; |
| 4822 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4823 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4824 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4825 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4826 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4827 | } |
| 4828 | if (LocaleCompare("layers",option+1) == 0) |
| 4829 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4830 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4831 | type; |
| 4832 | |
| 4833 | if (*option == '+') |
| 4834 | break; |
| 4835 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4836 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4837 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4838 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4839 | if (type < 0) |
| 4840 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4841 | argv[i]); |
| 4842 | break; |
| 4843 | } |
| 4844 | if (LocaleCompare("level",option+1) == 0) |
| 4845 | { |
| 4846 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4847 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4848 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4849 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4850 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4851 | break; |
| 4852 | } |
| 4853 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4854 | { |
| 4855 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4856 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4857 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4858 | break; |
| 4859 | } |
| 4860 | if (LocaleCompare("linewidth",option+1) == 0) |
| 4861 | { |
| 4862 | if (*option == '+') |
| 4863 | break; |
| 4864 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4865 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4866 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4867 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4868 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4869 | break; |
| 4870 | } |
| 4871 | if (LocaleCompare("limit",option+1) == 0) |
| 4872 | { |
| 4873 | char |
| 4874 | *p; |
| 4875 | |
| 4876 | double |
| 4877 | value; |
| 4878 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4879 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4880 | resource; |
| 4881 | |
| 4882 | if (*option == '+') |
| 4883 | break; |
| 4884 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4885 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4886 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4887 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4888 | argv[i]); |
| 4889 | if (resource < 0) |
| 4890 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4891 | argv[i]); |
| 4892 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4893 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4894 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 4895 | value=InterpretLocaleValue(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4896 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4897 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4898 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4899 | break; |
| 4900 | } |
| 4901 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4902 | { |
| 4903 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4904 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4905 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4906 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4907 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4908 | break; |
| 4909 | } |
| 4910 | if (LocaleCompare("list",option+1) == 0) |
| 4911 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4912 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4913 | list; |
| 4914 | |
| 4915 | if (*option == '+') |
| 4916 | break; |
| 4917 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4918 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4919 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4920 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4921 | if (list < 0) |
| 4922 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4923 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4924 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4925 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4926 | } |
| 4927 | if (LocaleCompare("log",option+1) == 0) |
| 4928 | { |
| 4929 | if (*option == '+') |
| 4930 | break; |
| 4931 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4932 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4933 | (strchr(argv[i],'%') == (char *) NULL)) |
| 4934 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4935 | break; |
| 4936 | } |
| 4937 | if (LocaleCompare("loop",option+1) == 0) |
| 4938 | { |
| 4939 | if (*option == '+') |
| 4940 | break; |
| 4941 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4942 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4943 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4944 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4945 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4946 | break; |
| 4947 | } |
| 4948 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4949 | } |
| 4950 | case 'm': |
| 4951 | { |
| 4952 | if (LocaleCompare("map",option+1) == 0) |
| 4953 | { |
| 4954 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 4955 | if (*option == '+') |
| 4956 | break; |
| 4957 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4958 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4959 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4960 | break; |
| 4961 | } |
| 4962 | if (LocaleCompare("mask",option+1) == 0) |
| 4963 | { |
| 4964 | if (*option == '+') |
| 4965 | break; |
| 4966 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4967 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4968 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4969 | break; |
| 4970 | } |
| 4971 | if (LocaleCompare("matte",option+1) == 0) |
| 4972 | break; |
| 4973 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 4974 | { |
| 4975 | if (*option == '+') |
| 4976 | break; |
| 4977 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4978 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4979 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4980 | break; |
| 4981 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 4982 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 4983 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 4984 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 4985 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4986 | if (LocaleCompare("modulate",option+1) == 0) |
| 4987 | { |
| 4988 | if (*option == '+') |
| 4989 | break; |
| 4990 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4991 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4992 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4993 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4994 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4995 | break; |
| 4996 | } |
| 4997 | if (LocaleCompare("median",option+1) == 0) |
| 4998 | { |
| 4999 | if (*option == '+') |
| 5000 | break; |
| 5001 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5002 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5003 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5004 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5005 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5006 | break; |
| 5007 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5008 | if (LocaleCompare("mode",option+1) == 0) |
| 5009 | { |
| 5010 | if (*option == '+') |
| 5011 | break; |
| 5012 | i++; |
| 5013 | if (i == (ssize_t) argc) |
| 5014 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5015 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5016 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5017 | break; |
| 5018 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5019 | if (LocaleCompare("monitor",option+1) == 0) |
| 5020 | break; |
| 5021 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5022 | break; |
| 5023 | if (LocaleCompare("morph",option+1) == 0) |
| 5024 | { |
| 5025 | if (*option == '+') |
| 5026 | break; |
| 5027 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5028 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5029 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5030 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5031 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5032 | break; |
| 5033 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5034 | if (LocaleCompare("morphology",option+1) == 0) |
| 5035 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5036 | char |
| 5037 | token[MaxTextExtent]; |
| 5038 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5039 | KernelInfo |
| 5040 | *kernel_info; |
| 5041 | |
| 5042 | ssize_t |
| 5043 | op; |
| 5044 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5045 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5046 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5047 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5048 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5049 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5050 | if (op < 0) |
| 5051 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5052 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5053 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5054 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5055 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5056 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5057 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5058 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5059 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5060 | break; |
| 5061 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5062 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5063 | break; |
| 5064 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5065 | { |
| 5066 | if (*option == '+') |
| 5067 | break; |
| 5068 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5069 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5070 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5071 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5072 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5073 | break; |
| 5074 | } |
| 5075 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5076 | } |
| 5077 | case 'n': |
| 5078 | { |
| 5079 | if (LocaleCompare("negate",option+1) == 0) |
| 5080 | break; |
| 5081 | if (LocaleCompare("noise",option+1) == 0) |
| 5082 | { |
| 5083 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5084 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5085 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5086 | if (*option == '+') |
| 5087 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5088 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5089 | noise; |
| 5090 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5091 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5092 | if (noise < 0) |
| 5093 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5094 | argv[i]); |
| 5095 | break; |
| 5096 | } |
| 5097 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5098 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5099 | break; |
| 5100 | } |
| 5101 | if (LocaleCompare("noop",option+1) == 0) |
| 5102 | break; |
| 5103 | if (LocaleCompare("normalize",option+1) == 0) |
| 5104 | break; |
| 5105 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5106 | } |
| 5107 | case 'o': |
| 5108 | { |
| 5109 | if (LocaleCompare("opaque",option+1) == 0) |
| 5110 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5111 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5112 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5113 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5114 | break; |
| 5115 | } |
| 5116 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5117 | { |
| 5118 | if (*option == '+') |
| 5119 | break; |
| 5120 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5121 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5122 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5123 | break; |
| 5124 | } |
| 5125 | if (LocaleCompare("orient",option+1) == 0) |
| 5126 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5127 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5128 | orientation; |
| 5129 | |
| 5130 | orientation=UndefinedOrientation; |
| 5131 | if (*option == '+') |
| 5132 | break; |
| 5133 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5134 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5135 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5136 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5137 | argv[i]); |
| 5138 | if (orientation < 0) |
| 5139 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5140 | argv[i]); |
| 5141 | break; |
| 5142 | } |
| 5143 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5144 | } |
| 5145 | case 'p': |
| 5146 | { |
| 5147 | if (LocaleCompare("page",option+1) == 0) |
| 5148 | { |
| 5149 | if (*option == '+') |
| 5150 | break; |
| 5151 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5152 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5153 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5154 | break; |
| 5155 | } |
| 5156 | if (LocaleCompare("paint",option+1) == 0) |
| 5157 | { |
| 5158 | if (*option == '+') |
| 5159 | break; |
| 5160 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5161 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5162 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5163 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5164 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5165 | break; |
| 5166 | } |
| 5167 | if (LocaleCompare("path",option+1) == 0) |
| 5168 | { |
| 5169 | (void) CloneString(&path,(char *) NULL); |
| 5170 | if (*option == '+') |
| 5171 | break; |
| 5172 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5173 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5174 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5175 | (void) CloneString(&path,argv[i]); |
| 5176 | break; |
| 5177 | } |
| 5178 | if (LocaleCompare("pointsize",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 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5190 | { |
| 5191 | if (*option == '+') |
| 5192 | break; |
| 5193 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5194 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5195 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5196 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5197 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5198 | break; |
| 5199 | } |
| 5200 | if (LocaleCompare("posterize",option+1) == 0) |
| 5201 | { |
| 5202 | if (*option == '+') |
| 5203 | break; |
| 5204 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5205 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5206 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5207 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5208 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5209 | break; |
| 5210 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5211 | if (LocaleCompare("precision",option+1) == 0) |
| 5212 | { |
| 5213 | if (*option == '+') |
| 5214 | break; |
| 5215 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5216 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5217 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5218 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5219 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5220 | break; |
| 5221 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5222 | if (LocaleCompare("print",option+1) == 0) |
| 5223 | { |
| 5224 | if (*option == '+') |
| 5225 | break; |
| 5226 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5227 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5228 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5229 | break; |
| 5230 | } |
| 5231 | if (LocaleCompare("process",option+1) == 0) |
| 5232 | { |
| 5233 | if (*option == '+') |
| 5234 | break; |
| 5235 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5236 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5237 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5238 | break; |
| 5239 | } |
| 5240 | if (LocaleCompare("profile",option+1) == 0) |
| 5241 | { |
| 5242 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5243 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5244 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5245 | break; |
| 5246 | } |
| 5247 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5248 | } |
| 5249 | case 'q': |
| 5250 | { |
| 5251 | if (LocaleCompare("quality",option+1) == 0) |
| 5252 | { |
| 5253 | if (*option == '+') |
| 5254 | break; |
| 5255 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5256 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5257 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5258 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5259 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5260 | break; |
| 5261 | } |
| 5262 | if (LocaleCompare("quantize",option+1) == 0) |
| 5263 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5264 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5265 | colorspace; |
| 5266 | |
| 5267 | if (*option == '+') |
| 5268 | break; |
| 5269 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5270 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5271 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5272 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5273 | argv[i]); |
| 5274 | if (colorspace < 0) |
| 5275 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5276 | argv[i]); |
| 5277 | break; |
| 5278 | } |
| 5279 | if (LocaleCompare("quiet",option+1) == 0) |
| 5280 | break; |
| 5281 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5282 | } |
| 5283 | case 'r': |
| 5284 | { |
| 5285 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5286 | { |
| 5287 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5288 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5289 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5290 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5291 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5292 | break; |
| 5293 | } |
| 5294 | if (LocaleCompare("raise",option+1) == 0) |
| 5295 | { |
| 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("random-threshold",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 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5314 | if (LocaleCompare("recolor",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-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5320 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5321 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5322 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5323 | break; |
| 5324 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5325 | if (LocaleCompare("red-primary",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 | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5331 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5332 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5333 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5334 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5335 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5336 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5337 | if (LocaleCompare("region",option+1) == 0) |
| 5338 | { |
| 5339 | if (*option == '+') |
| 5340 | break; |
| 5341 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5342 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5343 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5344 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5345 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5346 | break; |
| 5347 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5348 | if (LocaleCompare("remap",option+1) == 0) |
| 5349 | { |
| 5350 | if (*option == '+') |
| 5351 | break; |
| 5352 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5353 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5354 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5355 | break; |
| 5356 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5357 | if (LocaleCompare("render",option+1) == 0) |
| 5358 | break; |
| 5359 | if (LocaleCompare("repage",option+1) == 0) |
| 5360 | { |
| 5361 | if (*option == '+') |
| 5362 | break; |
| 5363 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5364 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5365 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5366 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5367 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5368 | break; |
| 5369 | } |
| 5370 | if (LocaleCompare("resample",option+1) == 0) |
| 5371 | { |
| 5372 | if (*option == '+') |
| 5373 | break; |
| 5374 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5375 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5376 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5377 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5378 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5379 | break; |
| 5380 | } |
| 5381 | if (LocaleCompare("resize",option+1) == 0) |
| 5382 | { |
| 5383 | if (*option == '+') |
| 5384 | break; |
| 5385 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5386 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5387 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5388 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5389 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5390 | break; |
| 5391 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5392 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5393 | { |
| 5394 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5395 | break; |
| 5396 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5397 | if (LocaleCompare("reverse",option+1) == 0) |
| 5398 | break; |
| 5399 | if (LocaleCompare("roll",option+1) == 0) |
| 5400 | { |
| 5401 | if (*option == '+') |
| 5402 | break; |
| 5403 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5404 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5405 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5406 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5407 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5408 | break; |
| 5409 | } |
| 5410 | if (LocaleCompare("rotate",option+1) == 0) |
| 5411 | { |
| 5412 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5413 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5414 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5415 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5416 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5417 | break; |
| 5418 | } |
| 5419 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5420 | } |
| 5421 | case 's': |
| 5422 | { |
| 5423 | if (LocaleCompare("sample",option+1) == 0) |
| 5424 | { |
| 5425 | if (*option == '+') |
| 5426 | break; |
| 5427 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5428 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5429 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5430 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5431 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5432 | break; |
| 5433 | } |
| 5434 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5435 | { |
| 5436 | if (*option == '+') |
| 5437 | break; |
| 5438 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5439 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5440 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5441 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5442 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5443 | break; |
| 5444 | } |
| 5445 | if (LocaleCompare("scale",option+1) == 0) |
| 5446 | { |
| 5447 | if (*option == '+') |
| 5448 | break; |
| 5449 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5450 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5451 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5452 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5453 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5454 | break; |
| 5455 | } |
| 5456 | if (LocaleCompare("scene",option+1) == 0) |
| 5457 | { |
| 5458 | if (*option == '+') |
| 5459 | break; |
| 5460 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5461 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5462 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5463 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5464 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5465 | break; |
| 5466 | } |
| 5467 | if (LocaleCompare("seed",option+1) == 0) |
| 5468 | { |
| 5469 | if (*option == '+') |
| 5470 | break; |
| 5471 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5472 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5473 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5474 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5475 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5476 | break; |
| 5477 | } |
| 5478 | if (LocaleCompare("segment",option+1) == 0) |
| 5479 | { |
| 5480 | if (*option == '+') |
| 5481 | break; |
| 5482 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5483 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5484 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5485 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5486 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5487 | break; |
| 5488 | } |
| 5489 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5490 | { |
| 5491 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5492 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5493 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5494 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5495 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5496 | break; |
| 5497 | } |
| 5498 | if (LocaleCompare("separate",option+1) == 0) |
| 5499 | break; |
| 5500 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5501 | { |
| 5502 | if (*option == '+') |
| 5503 | break; |
| 5504 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5505 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5506 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5507 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5508 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5509 | break; |
| 5510 | } |
| 5511 | if (LocaleCompare("set",option+1) == 0) |
| 5512 | { |
| 5513 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5514 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5515 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5516 | if (*option == '+') |
| 5517 | break; |
| 5518 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5519 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5520 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5521 | break; |
| 5522 | } |
| 5523 | if (LocaleCompare("shade",option+1) == 0) |
| 5524 | { |
| 5525 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5526 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5527 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5528 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5529 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5530 | break; |
| 5531 | } |
| 5532 | if (LocaleCompare("shadow",option+1) == 0) |
| 5533 | { |
| 5534 | if (*option == '+') |
| 5535 | break; |
| 5536 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5537 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5538 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5539 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5540 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5541 | break; |
| 5542 | } |
| 5543 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5544 | { |
| 5545 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5546 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5547 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5548 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5549 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5550 | break; |
| 5551 | } |
| 5552 | if (LocaleCompare("shave",option+1) == 0) |
| 5553 | { |
| 5554 | if (*option == '+') |
| 5555 | break; |
| 5556 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5557 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5558 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5559 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5560 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5561 | break; |
| 5562 | } |
| 5563 | if (LocaleCompare("shear",option+1) == 0) |
| 5564 | { |
| 5565 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5566 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5567 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5568 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5569 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5570 | break; |
| 5571 | } |
| 5572 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5573 | { |
| 5574 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5575 | if (i == (ssize_t) (argc-1)) |
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("size",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("sketch",option+1) == 0) |
| 5593 | { |
| 5594 | if (*option == '+') |
| 5595 | break; |
| 5596 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5597 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5598 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5599 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5600 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5601 | break; |
| 5602 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5603 | if (LocaleCompare("smush",option+1) == 0) |
| 5604 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5605 | i++; |
| 5606 | if (i == (ssize_t) argc) |
| 5607 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5608 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5609 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5610 | i++; |
| 5611 | break; |
| 5612 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5613 | if (LocaleCompare("solarize",option+1) == 0) |
| 5614 | { |
| 5615 | if (*option == '+') |
| 5616 | break; |
| 5617 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5618 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5619 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5620 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5621 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5622 | break; |
| 5623 | } |
| 5624 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5625 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5626 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5627 | op; |
| 5628 | |
| 5629 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5630 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5631 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5632 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5633 | if (op < 0) |
| 5634 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5635 | argv[i]); |
| 5636 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5637 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5638 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5639 | break; |
| 5640 | } |
| 5641 | if (LocaleCompare("spread",option+1) == 0) |
| 5642 | { |
| 5643 | if (*option == '+') |
| 5644 | break; |
| 5645 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5646 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5647 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5648 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5649 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5650 | break; |
| 5651 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5652 | if (LocaleCompare("statistic",option+1) == 0) |
| 5653 | { |
| 5654 | ssize_t |
| 5655 | op; |
| 5656 | |
| 5657 | if (*option == '+') |
| 5658 | break; |
| 5659 | i++; |
| 5660 | if (i == (ssize_t) argc) |
| 5661 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5662 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5663 | if (op < 0) |
| 5664 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5665 | argv[i]); |
| 5666 | i++; |
| 5667 | if (i == (ssize_t) (argc-1)) |
| 5668 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5669 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5670 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5671 | break; |
| 5672 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5673 | if (LocaleCompare("stretch",option+1) == 0) |
| 5674 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5675 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5676 | stretch; |
| 5677 | |
| 5678 | if (*option == '+') |
| 5679 | break; |
| 5680 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5681 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5682 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5683 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5684 | if (stretch < 0) |
| 5685 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5686 | argv[i]); |
| 5687 | break; |
| 5688 | } |
| 5689 | if (LocaleCompare("strip",option+1) == 0) |
| 5690 | break; |
| 5691 | if (LocaleCompare("stroke",option+1) == 0) |
| 5692 | { |
| 5693 | if (*option == '+') |
| 5694 | break; |
| 5695 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5696 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5697 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5698 | break; |
| 5699 | } |
| 5700 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5701 | { |
| 5702 | if (*option == '+') |
| 5703 | break; |
| 5704 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5705 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5706 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5707 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5708 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5709 | break; |
| 5710 | } |
| 5711 | if (LocaleCompare("style",option+1) == 0) |
| 5712 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5713 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5714 | style; |
| 5715 | |
| 5716 | if (*option == '+') |
| 5717 | break; |
| 5718 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5719 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5720 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5721 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5722 | if (style < 0) |
| 5723 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5724 | argv[i]); |
| 5725 | break; |
| 5726 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5727 | if (LocaleCompare("swap",option+1) == 0) |
| 5728 | { |
| 5729 | if (*option == '+') |
| 5730 | break; |
| 5731 | i++; |
| 5732 | if (i == (ssize_t) (argc-1)) |
| 5733 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5734 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5735 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5736 | break; |
| 5737 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5738 | if (LocaleCompare("swirl",option+1) == 0) |
| 5739 | { |
| 5740 | if (*option == '+') |
| 5741 | break; |
| 5742 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5743 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5744 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5745 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5746 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5747 | break; |
| 5748 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5749 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5750 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5751 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5752 | } |
| 5753 | case 't': |
| 5754 | { |
| 5755 | if (LocaleCompare("taint",option+1) == 0) |
| 5756 | break; |
| 5757 | if (LocaleCompare("texture",option+1) == 0) |
| 5758 | { |
| 5759 | if (*option == '+') |
| 5760 | break; |
| 5761 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5762 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5763 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5764 | break; |
| 5765 | } |
| 5766 | if (LocaleCompare("tile",option+1) == 0) |
| 5767 | { |
| 5768 | if (*option == '+') |
| 5769 | break; |
| 5770 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5771 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5772 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5773 | break; |
| 5774 | } |
| 5775 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5776 | { |
| 5777 | if (*option == '+') |
| 5778 | break; |
| 5779 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5780 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5781 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5782 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5783 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5784 | break; |
| 5785 | } |
| 5786 | if (LocaleCompare("tint",option+1) == 0) |
| 5787 | { |
| 5788 | if (*option == '+') |
| 5789 | break; |
| 5790 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5791 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5792 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5793 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5794 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5795 | break; |
| 5796 | } |
| 5797 | if (LocaleCompare("transform",option+1) == 0) |
| 5798 | break; |
| 5799 | if (LocaleCompare("transpose",option+1) == 0) |
| 5800 | break; |
| 5801 | if (LocaleCompare("transverse",option+1) == 0) |
| 5802 | break; |
| 5803 | if (LocaleCompare("threshold",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("thumbnail",option+1) == 0) |
| 5815 | { |
| 5816 | if (*option == '+') |
| 5817 | break; |
| 5818 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5819 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5820 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5821 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5822 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5823 | break; |
| 5824 | } |
| 5825 | if (LocaleCompare("transparent",option+1) == 0) |
| 5826 | { |
| 5827 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5828 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5829 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5830 | break; |
| 5831 | } |
| 5832 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 5833 | { |
| 5834 | if (*option == '+') |
| 5835 | break; |
| 5836 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5837 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5838 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5839 | break; |
| 5840 | } |
| 5841 | if (LocaleCompare("treedepth",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 | } |
| 5852 | if (LocaleCompare("trim",option+1) == 0) |
| 5853 | break; |
| 5854 | if (LocaleCompare("type",option+1) == 0) |
| 5855 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5856 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5857 | type; |
| 5858 | |
| 5859 | if (*option == '+') |
| 5860 | break; |
| 5861 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5862 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5863 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5864 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5865 | if (type < 0) |
| 5866 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5867 | argv[i]); |
| 5868 | break; |
| 5869 | } |
| 5870 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5871 | } |
| 5872 | case 'u': |
| 5873 | { |
| 5874 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5875 | { |
| 5876 | if (*option == '+') |
| 5877 | break; |
| 5878 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5879 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5880 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5881 | break; |
| 5882 | } |
| 5883 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5884 | break; |
| 5885 | if (LocaleCompare("units",option+1) == 0) |
| 5886 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5887 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5888 | units; |
| 5889 | |
| 5890 | if (*option == '+') |
| 5891 | break; |
| 5892 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5893 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5894 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5895 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5896 | argv[i]); |
| 5897 | if (units < 0) |
| 5898 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5899 | argv[i]); |
| 5900 | break; |
| 5901 | } |
| 5902 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5903 | { |
| 5904 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5905 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5906 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5907 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5908 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5909 | break; |
| 5910 | } |
| 5911 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5912 | } |
| 5913 | case 'v': |
| 5914 | { |
| 5915 | if (LocaleCompare("verbose",option+1) == 0) |
| 5916 | { |
| 5917 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 5918 | break; |
| 5919 | } |
| 5920 | if ((LocaleCompare("version",option+1) == 0) || |
| 5921 | (LocaleCompare("-version",option+1) == 0)) |
| 5922 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 5923 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5924 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 5925 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 5926 | GetMagickCopyright()); |
| 5927 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 5928 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5929 | break; |
| 5930 | } |
| 5931 | if (LocaleCompare("view",option+1) == 0) |
| 5932 | { |
| 5933 | if (*option == '+') |
| 5934 | break; |
| 5935 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5936 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5937 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5938 | break; |
| 5939 | } |
| 5940 | if (LocaleCompare("vignette",option+1) == 0) |
| 5941 | { |
| 5942 | if (*option == '+') |
| 5943 | break; |
| 5944 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5945 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5946 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5947 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5948 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5949 | break; |
| 5950 | } |
| 5951 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 5952 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5953 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5954 | method; |
| 5955 | |
| 5956 | if (*option == '+') |
| 5957 | break; |
| 5958 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5959 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5960 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5961 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5962 | argv[i]); |
| 5963 | if (method < 0) |
| 5964 | ThrowMogrifyException(OptionError, |
| 5965 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 5966 | break; |
| 5967 | } |
| 5968 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5969 | } |
| 5970 | case 'w': |
| 5971 | { |
| 5972 | if (LocaleCompare("wave",option+1) == 0) |
| 5973 | { |
| 5974 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5975 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5976 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5977 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5978 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5979 | break; |
| 5980 | } |
| 5981 | if (LocaleCompare("weight",option+1) == 0) |
| 5982 | { |
| 5983 | if (*option == '+') |
| 5984 | break; |
| 5985 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5986 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5987 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5988 | break; |
| 5989 | } |
| 5990 | if (LocaleCompare("white-point",option+1) == 0) |
| 5991 | { |
| 5992 | if (*option == '+') |
| 5993 | break; |
| 5994 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5995 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5996 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5997 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5998 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5999 | break; |
| 6000 | } |
| 6001 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6002 | { |
| 6003 | if (*option == '+') |
| 6004 | break; |
| 6005 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6006 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6007 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6008 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6009 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6010 | break; |
| 6011 | } |
| 6012 | if (LocaleCompare("write",option+1) == 0) |
| 6013 | { |
| 6014 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6015 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6016 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6017 | break; |
| 6018 | } |
| 6019 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6020 | } |
| 6021 | case '?': |
| 6022 | break; |
| 6023 | default: |
| 6024 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6025 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6026 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 6027 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6028 | if (fire != MagickFalse) |
| 6029 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6030 | } |
| 6031 | if (k != 0) |
| 6032 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6033 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6034 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6035 | DestroyMogrify(); |
| 6036 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6037 | } |
| 6038 | |
| 6039 | /* |
| 6040 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6041 | % % |
| 6042 | % % |
| 6043 | % % |
| 6044 | + M o g r i f y I m a g e I n f o % |
| 6045 | % % |
| 6046 | % % |
| 6047 | % % |
| 6048 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6049 | % |
| 6050 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6051 | % prescribed by command line options. |
| 6052 | % |
| 6053 | % The format of the MogrifyImageInfo method is: |
| 6054 | % |
| 6055 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6056 | % const char **argv,ExceptionInfo *exception) |
| 6057 | % |
| 6058 | % A description of each parameter follows: |
| 6059 | % |
| 6060 | % o image_info: the image info.. |
| 6061 | % |
| 6062 | % o argc: Specifies a pointer to an integer describing the number of |
| 6063 | % elements in the argument vector. |
| 6064 | % |
| 6065 | % o argv: Specifies a pointer to a text array containing the command line |
| 6066 | % arguments. |
| 6067 | % |
| 6068 | % o exception: return any errors or warnings in this structure. |
| 6069 | % |
| 6070 | */ |
| 6071 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6072 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6073 | { |
| 6074 | const char |
| 6075 | *option; |
| 6076 | |
| 6077 | GeometryInfo |
| 6078 | geometry_info; |
| 6079 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6080 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6081 | count; |
| 6082 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6083 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6084 | i; |
| 6085 | |
| 6086 | /* |
| 6087 | Initialize method variables. |
| 6088 | */ |
| 6089 | assert(image_info != (ImageInfo *) NULL); |
| 6090 | assert(image_info->signature == MagickSignature); |
| 6091 | if (image_info->debug != MagickFalse) |
| 6092 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6093 | image_info->filename); |
| 6094 | if (argc < 0) |
| 6095 | return(MagickTrue); |
| 6096 | /* |
| 6097 | Set the image settings. |
| 6098 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6099 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6100 | { |
| 6101 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6102 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6103 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6104 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6105 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6106 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6107 | break; |
| 6108 | switch (*(option+1)) |
| 6109 | { |
| 6110 | case 'a': |
| 6111 | { |
| 6112 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6113 | { |
| 6114 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6115 | break; |
| 6116 | } |
| 6117 | if (LocaleCompare("antialias",option+1) == 0) |
| 6118 | { |
| 6119 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6120 | break; |
| 6121 | } |
| 6122 | if (LocaleCompare("attenuate",option+1) == 0) |
| 6123 | { |
| 6124 | if (*option == '+') |
| 6125 | { |
| 6126 | (void) DeleteImageOption(image_info,option+1); |
| 6127 | break; |
| 6128 | } |
| 6129 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6130 | break; |
| 6131 | } |
| 6132 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6133 | { |
| 6134 | if (*option == '+') |
| 6135 | (void) CloneString(&image_info->authenticate,(char *) NULL); |
| 6136 | else |
| 6137 | (void) CloneString(&image_info->authenticate,argv[i+1]); |
| 6138 | break; |
| 6139 | } |
| 6140 | break; |
| 6141 | } |
| 6142 | case 'b': |
| 6143 | { |
| 6144 | if (LocaleCompare("background",option+1) == 0) |
| 6145 | { |
| 6146 | if (*option == '+') |
| 6147 | { |
| 6148 | (void) DeleteImageOption(image_info,option+1); |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6149 | (void) QueryColorDatabase(MogrifyBackgroundColor, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6150 | &image_info->background_color,exception); |
| 6151 | break; |
| 6152 | } |
| 6153 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6154 | (void) QueryColorDatabase(argv[i+1],&image_info->background_color, |
| 6155 | exception); |
| 6156 | break; |
| 6157 | } |
| 6158 | if (LocaleCompare("bias",option+1) == 0) |
| 6159 | { |
| 6160 | if (*option == '+') |
| 6161 | { |
| 6162 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6163 | break; |
| 6164 | } |
| 6165 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6166 | break; |
| 6167 | } |
| 6168 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6169 | { |
| 6170 | if (*option == '+') |
| 6171 | { |
| 6172 | (void) SetImageOption(image_info,option+1,"false"); |
| 6173 | break; |
| 6174 | } |
| 6175 | (void) SetImageOption(image_info,option+1,"true"); |
| 6176 | break; |
| 6177 | } |
| 6178 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6179 | { |
| 6180 | if (*option == '+') |
| 6181 | { |
| 6182 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6183 | break; |
| 6184 | } |
| 6185 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6186 | break; |
| 6187 | } |
| 6188 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6189 | { |
| 6190 | if (*option == '+') |
| 6191 | { |
| 6192 | (void) DeleteImageOption(image_info,option+1); |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6193 | (void) QueryColorDatabase(MogrifyBorderColor, |
| 6194 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6195 | break; |
| 6196 | } |
| 6197 | (void) QueryColorDatabase(argv[i+1],&image_info->border_color, |
| 6198 | exception); |
| 6199 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6200 | break; |
| 6201 | } |
| 6202 | if (LocaleCompare("box",option+1) == 0) |
| 6203 | { |
| 6204 | if (*option == '+') |
| 6205 | { |
| 6206 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6207 | break; |
| 6208 | } |
| 6209 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6210 | break; |
| 6211 | } |
| 6212 | break; |
| 6213 | } |
| 6214 | case 'c': |
| 6215 | { |
| 6216 | if (LocaleCompare("cache",option+1) == 0) |
| 6217 | { |
| 6218 | MagickSizeType |
| 6219 | limit; |
| 6220 | |
| 6221 | limit=MagickResourceInfinity; |
| 6222 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6223 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6224 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6225 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6226 | break; |
| 6227 | } |
| 6228 | if (LocaleCompare("caption",option+1) == 0) |
| 6229 | { |
| 6230 | if (*option == '+') |
| 6231 | { |
| 6232 | (void) DeleteImageOption(image_info,option+1); |
| 6233 | break; |
| 6234 | } |
| 6235 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6236 | break; |
| 6237 | } |
| 6238 | if (LocaleCompare("channel",option+1) == 0) |
| 6239 | { |
| 6240 | if (*option == '+') |
| 6241 | { |
| 6242 | image_info->channel=DefaultChannels; |
| 6243 | break; |
| 6244 | } |
| 6245 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6246 | break; |
| 6247 | } |
| 6248 | if (LocaleCompare("colors",option+1) == 0) |
| 6249 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6250 | image_info->colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6251 | break; |
| 6252 | } |
| 6253 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6254 | { |
| 6255 | if (*option == '+') |
| 6256 | { |
| 6257 | image_info->colorspace=UndefinedColorspace; |
| 6258 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6259 | break; |
| 6260 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6261 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6262 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6263 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6264 | break; |
| 6265 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6266 | if (LocaleCompare("comment",option+1) == 0) |
| 6267 | { |
| 6268 | if (*option == '+') |
| 6269 | { |
| 6270 | (void) DeleteImageOption(image_info,option+1); |
| 6271 | break; |
| 6272 | } |
| 6273 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6274 | break; |
| 6275 | } |
| 6276 | if (LocaleCompare("compose",option+1) == 0) |
| 6277 | { |
| 6278 | if (*option == '+') |
| 6279 | { |
| 6280 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6281 | break; |
| 6282 | } |
| 6283 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6284 | break; |
| 6285 | } |
| 6286 | if (LocaleCompare("compress",option+1) == 0) |
| 6287 | { |
| 6288 | if (*option == '+') |
| 6289 | { |
| 6290 | image_info->compression=UndefinedCompression; |
| 6291 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6292 | break; |
| 6293 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6294 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6295 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6296 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6297 | break; |
| 6298 | } |
| 6299 | break; |
| 6300 | } |
| 6301 | case 'd': |
| 6302 | { |
| 6303 | if (LocaleCompare("debug",option+1) == 0) |
| 6304 | { |
| 6305 | if (*option == '+') |
| 6306 | (void) SetLogEventMask("none"); |
| 6307 | else |
| 6308 | (void) SetLogEventMask(argv[i+1]); |
| 6309 | image_info->debug=IsEventLogging(); |
| 6310 | break; |
| 6311 | } |
| 6312 | if (LocaleCompare("define",option+1) == 0) |
| 6313 | { |
| 6314 | if (*option == '+') |
| 6315 | { |
| 6316 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6317 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6318 | else |
| 6319 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6320 | break; |
| 6321 | } |
| 6322 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6323 | { |
| 6324 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6325 | exception); |
| 6326 | break; |
| 6327 | } |
| 6328 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6329 | break; |
| 6330 | } |
| 6331 | if (LocaleCompare("delay",option+1) == 0) |
| 6332 | { |
| 6333 | if (*option == '+') |
| 6334 | { |
| 6335 | (void) SetImageOption(image_info,option+1,"0"); |
| 6336 | break; |
| 6337 | } |
| 6338 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6339 | break; |
| 6340 | } |
| 6341 | if (LocaleCompare("density",option+1) == 0) |
| 6342 | { |
| 6343 | /* |
| 6344 | Set image density. |
| 6345 | */ |
| 6346 | if (*option == '+') |
| 6347 | { |
| 6348 | if (image_info->density != (char *) NULL) |
| 6349 | image_info->density=DestroyString(image_info->density); |
| 6350 | (void) SetImageOption(image_info,option+1,"72"); |
| 6351 | break; |
| 6352 | } |
| 6353 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6354 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6355 | break; |
| 6356 | } |
| 6357 | if (LocaleCompare("depth",option+1) == 0) |
| 6358 | { |
| 6359 | if (*option == '+') |
| 6360 | { |
| 6361 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6362 | break; |
| 6363 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6364 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6365 | break; |
| 6366 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6367 | if (LocaleCompare("direction",option+1) == 0) |
| 6368 | { |
| 6369 | if (*option == '+') |
| 6370 | { |
| 6371 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6372 | break; |
| 6373 | } |
| 6374 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6375 | break; |
| 6376 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6377 | if (LocaleCompare("display",option+1) == 0) |
| 6378 | { |
| 6379 | if (*option == '+') |
| 6380 | { |
| 6381 | if (image_info->server_name != (char *) NULL) |
| 6382 | image_info->server_name=DestroyString( |
| 6383 | image_info->server_name); |
| 6384 | break; |
| 6385 | } |
| 6386 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6387 | break; |
| 6388 | } |
| 6389 | if (LocaleCompare("dispose",option+1) == 0) |
| 6390 | { |
| 6391 | if (*option == '+') |
| 6392 | { |
| 6393 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6394 | break; |
| 6395 | } |
| 6396 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6397 | break; |
| 6398 | } |
| 6399 | if (LocaleCompare("dither",option+1) == 0) |
| 6400 | { |
| 6401 | if (*option == '+') |
| 6402 | { |
| 6403 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6404 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6405 | break; |
| 6406 | } |
| 6407 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6408 | image_info->dither=MagickTrue; |
| 6409 | break; |
| 6410 | } |
| 6411 | break; |
| 6412 | } |
| 6413 | case 'e': |
| 6414 | { |
| 6415 | if (LocaleCompare("encoding",option+1) == 0) |
| 6416 | { |
| 6417 | if (*option == '+') |
| 6418 | { |
| 6419 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6420 | break; |
| 6421 | } |
| 6422 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6423 | break; |
| 6424 | } |
| 6425 | if (LocaleCompare("endian",option+1) == 0) |
| 6426 | { |
| 6427 | if (*option == '+') |
| 6428 | { |
| 6429 | image_info->endian=UndefinedEndian; |
| 6430 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6431 | break; |
| 6432 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6433 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6434 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6435 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6436 | break; |
| 6437 | } |
| 6438 | if (LocaleCompare("extract",option+1) == 0) |
| 6439 | { |
| 6440 | /* |
| 6441 | Set image extract geometry. |
| 6442 | */ |
| 6443 | if (*option == '+') |
| 6444 | { |
| 6445 | if (image_info->extract != (char *) NULL) |
| 6446 | image_info->extract=DestroyString(image_info->extract); |
| 6447 | break; |
| 6448 | } |
| 6449 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6450 | break; |
| 6451 | } |
| 6452 | break; |
| 6453 | } |
| 6454 | case 'f': |
| 6455 | { |
| 6456 | if (LocaleCompare("fill",option+1) == 0) |
| 6457 | { |
| 6458 | if (*option == '+') |
| 6459 | { |
| 6460 | (void) SetImageOption(image_info,option+1,"none"); |
| 6461 | break; |
| 6462 | } |
| 6463 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6464 | break; |
| 6465 | } |
| 6466 | if (LocaleCompare("filter",option+1) == 0) |
| 6467 | { |
| 6468 | if (*option == '+') |
| 6469 | { |
| 6470 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6471 | break; |
| 6472 | } |
| 6473 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6474 | break; |
| 6475 | } |
| 6476 | if (LocaleCompare("font",option+1) == 0) |
| 6477 | { |
| 6478 | if (*option == '+') |
| 6479 | { |
| 6480 | if (image_info->font != (char *) NULL) |
| 6481 | image_info->font=DestroyString(image_info->font); |
| 6482 | break; |
| 6483 | } |
| 6484 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6485 | break; |
| 6486 | } |
| 6487 | if (LocaleCompare("format",option+1) == 0) |
| 6488 | { |
| 6489 | register const char |
| 6490 | *q; |
| 6491 | |
| 6492 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6493 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6494 | image_info->ping=MagickFalse; |
| 6495 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6496 | break; |
| 6497 | } |
| 6498 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6499 | { |
| 6500 | if (*option == '+') |
| 6501 | { |
| 6502 | image_info->fuzz=0.0; |
| 6503 | (void) SetImageOption(image_info,option+1,"0"); |
| 6504 | break; |
| 6505 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6506 | image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6507 | 1.0); |
| 6508 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6509 | break; |
| 6510 | } |
| 6511 | break; |
| 6512 | } |
| 6513 | case 'g': |
| 6514 | { |
| 6515 | if (LocaleCompare("gravity",option+1) == 0) |
| 6516 | { |
| 6517 | if (*option == '+') |
| 6518 | { |
| 6519 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6520 | break; |
| 6521 | } |
| 6522 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6523 | break; |
| 6524 | } |
| 6525 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6526 | { |
| 6527 | if (*option == '+') |
| 6528 | { |
| 6529 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6530 | break; |
| 6531 | } |
| 6532 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6533 | break; |
| 6534 | } |
| 6535 | break; |
| 6536 | } |
| 6537 | case 'i': |
| 6538 | { |
| 6539 | if (LocaleCompare("intent",option+1) == 0) |
| 6540 | { |
| 6541 | if (*option == '+') |
| 6542 | { |
| 6543 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6544 | break; |
| 6545 | } |
| 6546 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6547 | break; |
| 6548 | } |
| 6549 | if (LocaleCompare("interlace",option+1) == 0) |
| 6550 | { |
| 6551 | if (*option == '+') |
| 6552 | { |
| 6553 | image_info->interlace=UndefinedInterlace; |
| 6554 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6555 | break; |
| 6556 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6557 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6558 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6559 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6560 | break; |
| 6561 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6562 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6563 | { |
| 6564 | if (*option == '+') |
| 6565 | { |
| 6566 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6567 | break; |
| 6568 | } |
| 6569 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6570 | break; |
| 6571 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6572 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6573 | { |
| 6574 | if (*option == '+') |
| 6575 | { |
| 6576 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6577 | break; |
| 6578 | } |
| 6579 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6580 | break; |
| 6581 | } |
| 6582 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6583 | { |
| 6584 | if (*option == '+') |
| 6585 | { |
| 6586 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6587 | break; |
| 6588 | } |
| 6589 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6590 | break; |
| 6591 | } |
| 6592 | break; |
| 6593 | } |
| 6594 | case 'k': |
| 6595 | { |
| 6596 | if (LocaleCompare("kerning",option+1) == 0) |
| 6597 | { |
| 6598 | if (*option == '+') |
| 6599 | { |
| 6600 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6601 | break; |
| 6602 | } |
| 6603 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6604 | break; |
| 6605 | } |
| 6606 | break; |
| 6607 | } |
| 6608 | case 'l': |
| 6609 | { |
| 6610 | if (LocaleCompare("label",option+1) == 0) |
| 6611 | { |
| 6612 | if (*option == '+') |
| 6613 | { |
| 6614 | (void) DeleteImageOption(image_info,option+1); |
| 6615 | break; |
| 6616 | } |
| 6617 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6618 | break; |
| 6619 | } |
| 6620 | if (LocaleCompare("limit",option+1) == 0) |
| 6621 | { |
| 6622 | MagickSizeType |
| 6623 | limit; |
| 6624 | |
| 6625 | ResourceType |
| 6626 | type; |
| 6627 | |
| 6628 | if (*option == '+') |
| 6629 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6630 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6631 | MagickFalse,argv[i+1]); |
| 6632 | limit=MagickResourceInfinity; |
| 6633 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6634 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6635 | (void) SetMagickResourceLimit(type,limit); |
| 6636 | break; |
| 6637 | } |
| 6638 | if (LocaleCompare("list",option+1) == 0) |
| 6639 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6640 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6641 | list; |
| 6642 | |
| 6643 | /* |
| 6644 | Display configuration list. |
| 6645 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6646 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6647 | switch (list) |
| 6648 | { |
| 6649 | case MagickCoderOptions: |
| 6650 | { |
| 6651 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6652 | break; |
| 6653 | } |
| 6654 | case MagickColorOptions: |
| 6655 | { |
| 6656 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6657 | break; |
| 6658 | } |
| 6659 | case MagickConfigureOptions: |
| 6660 | { |
| 6661 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6662 | break; |
| 6663 | } |
| 6664 | case MagickDelegateOptions: |
| 6665 | { |
| 6666 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6667 | break; |
| 6668 | } |
| 6669 | case MagickFontOptions: |
| 6670 | { |
| 6671 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6672 | break; |
| 6673 | } |
| 6674 | case MagickFormatOptions: |
| 6675 | { |
| 6676 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6677 | break; |
| 6678 | } |
| 6679 | case MagickLocaleOptions: |
| 6680 | { |
| 6681 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6682 | break; |
| 6683 | } |
| 6684 | case MagickLogOptions: |
| 6685 | { |
| 6686 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6687 | break; |
| 6688 | } |
| 6689 | case MagickMagicOptions: |
| 6690 | { |
| 6691 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6692 | break; |
| 6693 | } |
| 6694 | case MagickMimeOptions: |
| 6695 | { |
| 6696 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6697 | break; |
| 6698 | } |
| 6699 | case MagickModuleOptions: |
| 6700 | { |
| 6701 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6702 | break; |
| 6703 | } |
| 6704 | case MagickPolicyOptions: |
| 6705 | { |
| 6706 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6707 | break; |
| 6708 | } |
| 6709 | case MagickResourceOptions: |
| 6710 | { |
| 6711 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6712 | break; |
| 6713 | } |
| 6714 | case MagickThresholdOptions: |
| 6715 | { |
| 6716 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6717 | break; |
| 6718 | } |
| 6719 | default: |
| 6720 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6721 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6722 | exception); |
| 6723 | break; |
| 6724 | } |
| 6725 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6726 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6727 | } |
| 6728 | if (LocaleCompare("log",option+1) == 0) |
| 6729 | { |
| 6730 | if (*option == '+') |
| 6731 | break; |
| 6732 | (void) SetLogFormat(argv[i+1]); |
| 6733 | break; |
| 6734 | } |
| 6735 | if (LocaleCompare("loop",option+1) == 0) |
| 6736 | { |
| 6737 | if (*option == '+') |
| 6738 | { |
| 6739 | (void) SetImageOption(image_info,option+1,"0"); |
| 6740 | break; |
| 6741 | } |
| 6742 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6743 | break; |
| 6744 | } |
| 6745 | break; |
| 6746 | } |
| 6747 | case 'm': |
| 6748 | { |
| 6749 | if (LocaleCompare("matte",option+1) == 0) |
| 6750 | { |
| 6751 | if (*option == '+') |
| 6752 | { |
| 6753 | (void) SetImageOption(image_info,option+1,"false"); |
| 6754 | break; |
| 6755 | } |
| 6756 | (void) SetImageOption(image_info,option+1,"true"); |
| 6757 | break; |
| 6758 | } |
| 6759 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6760 | { |
| 6761 | if (*option == '+') |
| 6762 | { |
| 6763 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6764 | (void) QueryColorDatabase(MogrifyMatteColor, |
| 6765 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6766 | break; |
| 6767 | } |
| 6768 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6769 | (void) QueryColorDatabase(argv[i+1],&image_info->matte_color, |
| 6770 | exception); |
| 6771 | break; |
| 6772 | } |
| 6773 | if (LocaleCompare("monitor",option+1) == 0) |
| 6774 | { |
| 6775 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6776 | (void *) NULL); |
| 6777 | break; |
| 6778 | } |
| 6779 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6780 | { |
| 6781 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6782 | break; |
| 6783 | } |
| 6784 | break; |
| 6785 | } |
| 6786 | case 'o': |
| 6787 | { |
| 6788 | if (LocaleCompare("orient",option+1) == 0) |
| 6789 | { |
| 6790 | if (*option == '+') |
| 6791 | { |
| 6792 | image_info->orientation=UndefinedOrientation; |
| 6793 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6794 | break; |
| 6795 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6796 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6797 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6798 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6799 | break; |
| 6800 | } |
| 6801 | } |
| 6802 | case 'p': |
| 6803 | { |
| 6804 | if (LocaleCompare("page",option+1) == 0) |
| 6805 | { |
| 6806 | char |
| 6807 | *canonical_page, |
| 6808 | page[MaxTextExtent]; |
| 6809 | |
| 6810 | const char |
| 6811 | *image_option; |
| 6812 | |
| 6813 | MagickStatusType |
| 6814 | flags; |
| 6815 | |
| 6816 | RectangleInfo |
| 6817 | geometry; |
| 6818 | |
| 6819 | if (*option == '+') |
| 6820 | { |
| 6821 | (void) DeleteImageOption(image_info,option+1); |
| 6822 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6823 | break; |
| 6824 | } |
| 6825 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6826 | image_option=GetImageOption(image_info,"page"); |
| 6827 | if (image_option != (const char *) NULL) |
| 6828 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6829 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6830 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6831 | canonical_page=DestroyString(canonical_page); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6832 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6833 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6834 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6835 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6836 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6837 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6838 | (void) SetImageOption(image_info,option+1,page); |
| 6839 | (void) CloneString(&image_info->page,page); |
| 6840 | break; |
| 6841 | } |
| 6842 | if (LocaleCompare("pen",option+1) == 0) |
| 6843 | { |
| 6844 | if (*option == '+') |
| 6845 | { |
| 6846 | (void) SetImageOption(image_info,option+1,"none"); |
| 6847 | break; |
| 6848 | } |
| 6849 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6850 | break; |
| 6851 | } |
| 6852 | if (LocaleCompare("ping",option+1) == 0) |
| 6853 | { |
| 6854 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6855 | break; |
| 6856 | } |
| 6857 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6858 | { |
| 6859 | if (*option == '+') |
| 6860 | geometry_info.rho=0.0; |
| 6861 | else |
| 6862 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6863 | image_info->pointsize=geometry_info.rho; |
| 6864 | break; |
| 6865 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6866 | if (LocaleCompare("precision",option+1) == 0) |
| 6867 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6868 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6869 | break; |
| 6870 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6871 | if (LocaleCompare("preview",option+1) == 0) |
| 6872 | { |
| 6873 | /* |
| 6874 | Preview image. |
| 6875 | */ |
| 6876 | if (*option == '+') |
| 6877 | { |
| 6878 | image_info->preview_type=UndefinedPreview; |
| 6879 | break; |
| 6880 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6881 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6882 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6883 | break; |
| 6884 | } |
| 6885 | break; |
| 6886 | } |
| 6887 | case 'q': |
| 6888 | { |
| 6889 | if (LocaleCompare("quality",option+1) == 0) |
| 6890 | { |
| 6891 | /* |
| 6892 | Set image compression quality. |
| 6893 | */ |
| 6894 | if (*option == '+') |
| 6895 | { |
| 6896 | image_info->quality=UndefinedCompressionQuality; |
| 6897 | (void) SetImageOption(image_info,option+1,"0"); |
| 6898 | break; |
| 6899 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6900 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6901 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6902 | break; |
| 6903 | } |
| 6904 | if (LocaleCompare("quiet",option+1) == 0) |
| 6905 | { |
| 6906 | static WarningHandler |
| 6907 | warning_handler = (WarningHandler) NULL; |
| 6908 | |
| 6909 | if (*option == '+') |
| 6910 | { |
| 6911 | /* |
| 6912 | Restore error or warning messages. |
| 6913 | */ |
| 6914 | warning_handler=SetWarningHandler(warning_handler); |
| 6915 | break; |
| 6916 | } |
| 6917 | /* |
| 6918 | Suppress error or warning messages. |
| 6919 | */ |
| 6920 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6921 | break; |
| 6922 | } |
| 6923 | break; |
| 6924 | } |
| 6925 | case 'r': |
| 6926 | { |
| 6927 | if (LocaleCompare("red-primary",option+1) == 0) |
| 6928 | { |
| 6929 | if (*option == '+') |
| 6930 | { |
| 6931 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6932 | break; |
| 6933 | } |
| 6934 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6935 | break; |
| 6936 | } |
| 6937 | break; |
| 6938 | } |
| 6939 | case 's': |
| 6940 | { |
| 6941 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 6942 | { |
| 6943 | /* |
| 6944 | Set image sampling factor. |
| 6945 | */ |
| 6946 | if (*option == '+') |
| 6947 | { |
| 6948 | if (image_info->sampling_factor != (char *) NULL) |
| 6949 | image_info->sampling_factor=DestroyString( |
| 6950 | image_info->sampling_factor); |
| 6951 | break; |
| 6952 | } |
| 6953 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 6954 | break; |
| 6955 | } |
| 6956 | if (LocaleCompare("scene",option+1) == 0) |
| 6957 | { |
| 6958 | /* |
| 6959 | Set image scene. |
| 6960 | */ |
| 6961 | if (*option == '+') |
| 6962 | { |
| 6963 | image_info->scene=0; |
| 6964 | (void) SetImageOption(image_info,option+1,"0"); |
| 6965 | break; |
| 6966 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6967 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6968 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6969 | break; |
| 6970 | } |
| 6971 | if (LocaleCompare("seed",option+1) == 0) |
| 6972 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6973 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6974 | seed; |
| 6975 | |
| 6976 | if (*option == '+') |
| 6977 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6978 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6979 | SeedPseudoRandomGenerator(seed); |
| 6980 | break; |
| 6981 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6982 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6983 | SeedPseudoRandomGenerator(seed); |
| 6984 | break; |
| 6985 | } |
| 6986 | if (LocaleCompare("size",option+1) == 0) |
| 6987 | { |
| 6988 | if (*option == '+') |
| 6989 | { |
| 6990 | if (image_info->size != (char *) NULL) |
| 6991 | image_info->size=DestroyString(image_info->size); |
| 6992 | break; |
| 6993 | } |
| 6994 | (void) CloneString(&image_info->size,argv[i+1]); |
| 6995 | break; |
| 6996 | } |
| 6997 | if (LocaleCompare("stroke",option+1) == 0) |
| 6998 | { |
| 6999 | if (*option == '+') |
| 7000 | { |
| 7001 | (void) SetImageOption(image_info,option+1,"none"); |
| 7002 | break; |
| 7003 | } |
| 7004 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7005 | break; |
| 7006 | } |
| 7007 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7008 | { |
| 7009 | if (*option == '+') |
| 7010 | { |
| 7011 | (void) SetImageOption(image_info,option+1,"0"); |
| 7012 | break; |
| 7013 | } |
| 7014 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7015 | break; |
| 7016 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7017 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7018 | { |
| 7019 | if (*option == '+') |
| 7020 | { |
| 7021 | image_info->synchronize=MagickFalse; |
| 7022 | break; |
| 7023 | } |
| 7024 | image_info->synchronize=MagickTrue; |
| 7025 | break; |
| 7026 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7027 | break; |
| 7028 | } |
| 7029 | case 't': |
| 7030 | { |
| 7031 | if (LocaleCompare("taint",option+1) == 0) |
| 7032 | { |
| 7033 | if (*option == '+') |
| 7034 | { |
| 7035 | (void) SetImageOption(image_info,option+1,"false"); |
| 7036 | break; |
| 7037 | } |
| 7038 | (void) SetImageOption(image_info,option+1,"true"); |
| 7039 | break; |
| 7040 | } |
| 7041 | if (LocaleCompare("texture",option+1) == 0) |
| 7042 | { |
| 7043 | if (*option == '+') |
| 7044 | { |
| 7045 | if (image_info->texture != (char *) NULL) |
| 7046 | image_info->texture=DestroyString(image_info->texture); |
| 7047 | break; |
| 7048 | } |
| 7049 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7050 | break; |
| 7051 | } |
| 7052 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7053 | { |
| 7054 | if (*option == '+') |
| 7055 | { |
| 7056 | (void) SetImageOption(image_info,option+1,"0"); |
| 7057 | break; |
| 7058 | } |
| 7059 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7060 | break; |
| 7061 | } |
| 7062 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7063 | { |
| 7064 | if (*option == '+') |
| 7065 | { |
| 7066 | (void) QueryColorDatabase("none",&image_info->transparent_color, exception); |
| 7067 | (void) SetImageOption(image_info,option+1,"none"); |
| 7068 | break; |
| 7069 | } |
| 7070 | (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color, |
| 7071 | exception); |
| 7072 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7073 | break; |
| 7074 | } |
| 7075 | if (LocaleCompare("type",option+1) == 0) |
| 7076 | { |
| 7077 | if (*option == '+') |
| 7078 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7079 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7080 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7081 | break; |
| 7082 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7083 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7084 | MagickFalse,argv[i+1]); |
| 7085 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7086 | break; |
| 7087 | } |
| 7088 | break; |
| 7089 | } |
| 7090 | case 'u': |
| 7091 | { |
| 7092 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7093 | { |
| 7094 | if (*option == '+') |
| 7095 | { |
| 7096 | (void) DeleteImageOption(image_info,option+1); |
| 7097 | break; |
| 7098 | } |
| 7099 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7100 | break; |
| 7101 | } |
| 7102 | if (LocaleCompare("units",option+1) == 0) |
| 7103 | { |
| 7104 | if (*option == '+') |
| 7105 | { |
| 7106 | image_info->units=UndefinedResolution; |
| 7107 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7108 | break; |
| 7109 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7110 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7111 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7112 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7113 | break; |
| 7114 | } |
| 7115 | break; |
| 7116 | } |
| 7117 | case 'v': |
| 7118 | { |
| 7119 | if (LocaleCompare("verbose",option+1) == 0) |
| 7120 | { |
| 7121 | if (*option == '+') |
| 7122 | { |
| 7123 | image_info->verbose=MagickFalse; |
| 7124 | break; |
| 7125 | } |
| 7126 | image_info->verbose=MagickTrue; |
| 7127 | image_info->ping=MagickFalse; |
| 7128 | break; |
| 7129 | } |
| 7130 | if (LocaleCompare("view",option+1) == 0) |
| 7131 | { |
| 7132 | if (*option == '+') |
| 7133 | { |
| 7134 | if (image_info->view != (char *) NULL) |
| 7135 | image_info->view=DestroyString(image_info->view); |
| 7136 | break; |
| 7137 | } |
| 7138 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7139 | break; |
| 7140 | } |
| 7141 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7142 | { |
| 7143 | if (*option == '+') |
| 7144 | { |
| 7145 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7146 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7147 | break; |
| 7148 | } |
| 7149 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7150 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7151 | argv[i+1]); |
| 7152 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7153 | break; |
| 7154 | } |
| 7155 | break; |
| 7156 | } |
| 7157 | case 'w': |
| 7158 | { |
| 7159 | if (LocaleCompare("white-point",option+1) == 0) |
| 7160 | { |
| 7161 | if (*option == '+') |
| 7162 | { |
| 7163 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7164 | break; |
| 7165 | } |
| 7166 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7167 | break; |
| 7168 | } |
| 7169 | break; |
| 7170 | } |
| 7171 | default: |
| 7172 | break; |
| 7173 | } |
| 7174 | i+=count; |
| 7175 | } |
| 7176 | return(MagickTrue); |
| 7177 | } |
| 7178 | |
| 7179 | /* |
| 7180 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7181 | % % |
| 7182 | % % |
| 7183 | % % |
| 7184 | + M o g r i f y I m a g e L i s t % |
| 7185 | % % |
| 7186 | % % |
| 7187 | % % |
| 7188 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7189 | % |
| 7190 | % MogrifyImageList() applies any command line options that might affect the |
| 7191 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7192 | % |
| 7193 | % The format of the MogrifyImage method is: |
| 7194 | % |
| 7195 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7196 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7197 | % |
| 7198 | % A description of each parameter follows: |
| 7199 | % |
| 7200 | % o image_info: the image info.. |
| 7201 | % |
| 7202 | % o argc: Specifies a pointer to an integer describing the number of |
| 7203 | % elements in the argument vector. |
| 7204 | % |
| 7205 | % o argv: Specifies a pointer to a text array containing the command line |
| 7206 | % arguments. |
| 7207 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7208 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7209 | % |
| 7210 | % o exception: return any errors or warnings in this structure. |
| 7211 | % |
| 7212 | */ |
| 7213 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7214 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7215 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7216 | const char |
| 7217 | *option; |
| 7218 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7219 | ImageInfo |
| 7220 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7221 | |
| 7222 | MagickStatusType |
| 7223 | status; |
| 7224 | |
| 7225 | QuantizeInfo |
| 7226 | *quantize_info; |
| 7227 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7228 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7229 | i; |
| 7230 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7231 | ssize_t |
| 7232 | count, |
| 7233 | index; |
| 7234 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7235 | /* |
| 7236 | Apply options to the image list. |
| 7237 | */ |
| 7238 | assert(image_info != (ImageInfo *) NULL); |
| 7239 | assert(image_info->signature == MagickSignature); |
| 7240 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7241 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7242 | assert((*images)->signature == MagickSignature); |
| 7243 | if ((*images)->debug != MagickFalse) |
| 7244 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7245 | (*images)->filename); |
| 7246 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7247 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7248 | mogrify_info=CloneImageInfo(image_info); |
| 7249 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7250 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7251 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7252 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7253 | if (*images == (Image *) NULL) |
| 7254 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7255 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7256 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7257 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7258 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7259 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7260 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7261 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7262 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7263 | switch (*(option+1)) |
| 7264 | { |
| 7265 | case 'a': |
| 7266 | { |
| 7267 | if (LocaleCompare("affinity",option+1) == 0) |
| 7268 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7269 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7270 | if (*option == '+') |
| 7271 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7272 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7273 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7274 | break; |
| 7275 | } |
| 7276 | i++; |
| 7277 | break; |
| 7278 | } |
| 7279 | if (LocaleCompare("append",option+1) == 0) |
| 7280 | { |
| 7281 | Image |
| 7282 | *append_image; |
| 7283 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7284 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7285 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7286 | MagickFalse,exception); |
| 7287 | if (append_image == (Image *) NULL) |
| 7288 | { |
| 7289 | status=MagickFalse; |
| 7290 | break; |
| 7291 | } |
| 7292 | *images=DestroyImageList(*images); |
| 7293 | *images=append_image; |
| 7294 | break; |
| 7295 | } |
| 7296 | if (LocaleCompare("average",option+1) == 0) |
| 7297 | { |
| 7298 | Image |
| 7299 | *average_image; |
| 7300 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7301 | /* |
| 7302 | Average an image sequence (deprecated). |
| 7303 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7304 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7305 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7306 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7307 | if (average_image == (Image *) NULL) |
| 7308 | { |
| 7309 | status=MagickFalse; |
| 7310 | break; |
| 7311 | } |
| 7312 | *images=DestroyImageList(*images); |
| 7313 | *images=average_image; |
| 7314 | break; |
| 7315 | } |
| 7316 | break; |
| 7317 | } |
| 7318 | case 'c': |
| 7319 | { |
| 7320 | if (LocaleCompare("channel",option+1) == 0) |
| 7321 | { |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7322 | ChannelType |
| 7323 | channel; |
| 7324 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7325 | if (*option == '+') |
| 7326 | { |
| 7327 | channel=DefaultChannels; |
| 7328 | break; |
| 7329 | } |
| 7330 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 7331 | SetPixelChannelMap(*images,channel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7332 | break; |
| 7333 | } |
| 7334 | if (LocaleCompare("clut",option+1) == 0) |
| 7335 | { |
| 7336 | Image |
| 7337 | *clut_image, |
| 7338 | *image; |
| 7339 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7340 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7341 | image=RemoveFirstImageFromList(images); |
| 7342 | clut_image=RemoveFirstImageFromList(images); |
| 7343 | if (clut_image == (Image *) NULL) |
| 7344 | { |
| 7345 | status=MagickFalse; |
| 7346 | break; |
| 7347 | } |
cristy | 444eda6 | 2011-08-10 02:07:46 +0000 | [diff] [blame] | 7348 | (void) ClutImage(image,clut_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7349 | clut_image=DestroyImage(clut_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7350 | *images=DestroyImageList(*images); |
| 7351 | *images=image; |
| 7352 | break; |
| 7353 | } |
| 7354 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7355 | { |
| 7356 | Image |
| 7357 | *coalesce_image; |
| 7358 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7359 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7360 | coalesce_image=CoalesceImages(*images,exception); |
| 7361 | if (coalesce_image == (Image *) NULL) |
| 7362 | { |
| 7363 | status=MagickFalse; |
| 7364 | break; |
| 7365 | } |
| 7366 | *images=DestroyImageList(*images); |
| 7367 | *images=coalesce_image; |
| 7368 | break; |
| 7369 | } |
| 7370 | if (LocaleCompare("combine",option+1) == 0) |
| 7371 | { |
| 7372 | Image |
| 7373 | *combine_image; |
| 7374 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7375 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 7376 | combine_image=CombineImages(*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7377 | if (combine_image == (Image *) NULL) |
| 7378 | { |
| 7379 | status=MagickFalse; |
| 7380 | break; |
| 7381 | } |
| 7382 | *images=DestroyImageList(*images); |
| 7383 | *images=combine_image; |
| 7384 | break; |
| 7385 | } |
| 7386 | if (LocaleCompare("composite",option+1) == 0) |
| 7387 | { |
| 7388 | Image |
| 7389 | *mask_image, |
| 7390 | *composite_image, |
| 7391 | *image; |
| 7392 | |
| 7393 | RectangleInfo |
| 7394 | geometry; |
| 7395 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7396 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7397 | image=RemoveFirstImageFromList(images); |
| 7398 | composite_image=RemoveFirstImageFromList(images); |
| 7399 | if (composite_image == (Image *) NULL) |
| 7400 | { |
| 7401 | status=MagickFalse; |
| 7402 | break; |
| 7403 | } |
| 7404 | (void) TransformImage(&composite_image,(char *) NULL, |
| 7405 | composite_image->geometry); |
| 7406 | SetGeometry(composite_image,&geometry); |
| 7407 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7408 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7409 | &geometry); |
| 7410 | mask_image=RemoveFirstImageFromList(images); |
| 7411 | if (mask_image != (Image *) NULL) |
| 7412 | { |
| 7413 | if ((image->compose == DisplaceCompositeOp) || |
| 7414 | (image->compose == DistortCompositeOp)) |
| 7415 | { |
| 7416 | /* |
| 7417 | Merge Y displacement into X displacement image. |
| 7418 | */ |
| 7419 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
| 7420 | mask_image,0,0); |
| 7421 | mask_image=DestroyImage(mask_image); |
| 7422 | } |
| 7423 | else |
| 7424 | { |
| 7425 | /* |
| 7426 | Set a blending mask for the composition. |
| 7427 | */ |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7428 | /* POSIBLE ERROR; what if image->mask already set */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7429 | image->mask=mask_image; |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 7430 | (void) NegateImage(image->mask,MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7431 | } |
| 7432 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7433 | (void) CompositeImage(image,image->compose,composite_image, |
| 7434 | geometry.x,geometry.y); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7435 | if (mask_image != (Image *) NULL) |
| 7436 | mask_image=image->mask=DestroyImage(image->mask); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7437 | composite_image=DestroyImage(composite_image); |
| 7438 | InheritException(exception,&image->exception); |
| 7439 | *images=DestroyImageList(*images); |
| 7440 | *images=image; |
| 7441 | break; |
| 7442 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7443 | #if 0 |
| 7444 | This has been merged completely into MogrifyImage() |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7445 | if (LocaleCompare("crop",option+1) == 0) |
| 7446 | { |
| 7447 | MagickStatusType |
| 7448 | flags; |
| 7449 | |
| 7450 | RectangleInfo |
| 7451 | geometry; |
| 7452 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7453 | /* |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7454 | Crop Image. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7455 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7456 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7457 | flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception); |
| 7458 | if (((geometry.width == 0) && (geometry.height == 0)) || |
| 7459 | ((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 7460 | break; |
| 7461 | (void) TransformImages(images,argv[i+1],(char *) NULL); |
| 7462 | InheritException(exception,&(*images)->exception); |
| 7463 | break; |
| 7464 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7465 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7466 | break; |
| 7467 | } |
| 7468 | case 'd': |
| 7469 | { |
| 7470 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7471 | { |
| 7472 | Image |
| 7473 | *deconstruct_image; |
| 7474 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7475 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7476 | deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer, |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 7477 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7478 | if (deconstruct_image == (Image *) NULL) |
| 7479 | { |
| 7480 | status=MagickFalse; |
| 7481 | break; |
| 7482 | } |
| 7483 | *images=DestroyImageList(*images); |
| 7484 | *images=deconstruct_image; |
| 7485 | break; |
| 7486 | } |
| 7487 | if (LocaleCompare("delete",option+1) == 0) |
| 7488 | { |
| 7489 | if (*option == '+') |
| 7490 | DeleteImages(images,"-1",exception); |
| 7491 | else |
| 7492 | DeleteImages(images,argv[i+1],exception); |
| 7493 | break; |
| 7494 | } |
| 7495 | if (LocaleCompare("dither",option+1) == 0) |
| 7496 | { |
| 7497 | if (*option == '+') |
| 7498 | { |
| 7499 | quantize_info->dither=MagickFalse; |
| 7500 | break; |
| 7501 | } |
| 7502 | quantize_info->dither=MagickTrue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7503 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7504 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7505 | break; |
| 7506 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7507 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7508 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7509 | Image |
| 7510 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7511 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7512 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7513 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7514 | else |
| 7515 | { |
| 7516 | const char |
| 7517 | *p; |
| 7518 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7519 | size_t |
| 7520 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7521 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7522 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7523 | p=strchr(argv[i+1],','); |
| 7524 | if (p == (const char *) NULL) |
| 7525 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7526 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7527 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7528 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7529 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7530 | } |
| 7531 | AppendImageToList(images, duplicate_images); |
| 7532 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7533 | break; |
| 7534 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7535 | break; |
| 7536 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7537 | case 'e': |
| 7538 | { |
| 7539 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7540 | { |
| 7541 | Image |
| 7542 | *evaluate_image; |
| 7543 | |
| 7544 | MagickEvaluateOperator |
| 7545 | op; |
| 7546 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7547 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7548 | op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions, |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7549 | MagickFalse,argv[i+1]); |
| 7550 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7551 | if (evaluate_image == (Image *) NULL) |
| 7552 | { |
| 7553 | status=MagickFalse; |
| 7554 | break; |
| 7555 | } |
| 7556 | *images=DestroyImageList(*images); |
| 7557 | *images=evaluate_image; |
| 7558 | break; |
| 7559 | } |
| 7560 | break; |
| 7561 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7562 | case 'f': |
| 7563 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7564 | if (LocaleCompare("fft",option+1) == 0) |
| 7565 | { |
| 7566 | Image |
| 7567 | *fourier_image; |
| 7568 | |
| 7569 | /* |
| 7570 | Implements the discrete Fourier transform (DFT). |
| 7571 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7572 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7573 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7574 | MagickTrue : MagickFalse,exception); |
| 7575 | if (fourier_image == (Image *) NULL) |
| 7576 | break; |
| 7577 | *images=DestroyImage(*images); |
| 7578 | *images=fourier_image; |
| 7579 | break; |
| 7580 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7581 | if (LocaleCompare("flatten",option+1) == 0) |
| 7582 | { |
| 7583 | Image |
| 7584 | *flatten_image; |
| 7585 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7586 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7587 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7588 | if (flatten_image == (Image *) NULL) |
| 7589 | break; |
| 7590 | *images=DestroyImageList(*images); |
| 7591 | *images=flatten_image; |
| 7592 | break; |
| 7593 | } |
| 7594 | if (LocaleCompare("fx",option+1) == 0) |
| 7595 | { |
| 7596 | Image |
| 7597 | *fx_image; |
| 7598 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7599 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 7600 | fx_image=FxImage(*images,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7601 | if (fx_image == (Image *) NULL) |
| 7602 | { |
| 7603 | status=MagickFalse; |
| 7604 | break; |
| 7605 | } |
| 7606 | *images=DestroyImageList(*images); |
| 7607 | *images=fx_image; |
| 7608 | break; |
| 7609 | } |
| 7610 | break; |
| 7611 | } |
| 7612 | case 'h': |
| 7613 | { |
| 7614 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7615 | { |
| 7616 | Image |
| 7617 | *hald_image, |
| 7618 | *image; |
| 7619 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7620 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7621 | image=RemoveFirstImageFromList(images); |
| 7622 | hald_image=RemoveFirstImageFromList(images); |
| 7623 | if (hald_image == (Image *) NULL) |
| 7624 | { |
| 7625 | status=MagickFalse; |
| 7626 | break; |
| 7627 | } |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 7628 | (void) HaldClutImage(image,hald_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7629 | hald_image=DestroyImage(hald_image); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7630 | if (*images != (Image *) NULL) |
| 7631 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7632 | *images=image; |
| 7633 | break; |
| 7634 | } |
| 7635 | break; |
| 7636 | } |
| 7637 | case 'i': |
| 7638 | { |
| 7639 | if (LocaleCompare("ift",option+1) == 0) |
| 7640 | { |
| 7641 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7642 | *fourier_image, |
| 7643 | *magnitude_image, |
| 7644 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7645 | |
| 7646 | /* |
| 7647 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7648 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7649 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7650 | magnitude_image=RemoveFirstImageFromList(images); |
| 7651 | phase_image=RemoveFirstImageFromList(images); |
| 7652 | if (phase_image == (Image *) NULL) |
| 7653 | { |
| 7654 | status=MagickFalse; |
| 7655 | break; |
| 7656 | } |
| 7657 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7658 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7659 | if (fourier_image == (Image *) NULL) |
| 7660 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7661 | if (*images != (Image *) NULL) |
| 7662 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7663 | *images=fourier_image; |
| 7664 | break; |
| 7665 | } |
| 7666 | if (LocaleCompare("insert",option+1) == 0) |
| 7667 | { |
| 7668 | Image |
| 7669 | *p, |
| 7670 | *q; |
| 7671 | |
| 7672 | index=0; |
| 7673 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7674 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7675 | p=RemoveLastImageFromList(images); |
| 7676 | if (p == (Image *) NULL) |
| 7677 | { |
| 7678 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7679 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7680 | status=MagickFalse; |
| 7681 | break; |
| 7682 | } |
| 7683 | q=p; |
| 7684 | if (index == 0) |
| 7685 | PrependImageToList(images,q); |
| 7686 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7687 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7688 | AppendImageToList(images,q); |
| 7689 | else |
| 7690 | { |
| 7691 | q=GetImageFromList(*images,index-1); |
| 7692 | if (q == (Image *) NULL) |
| 7693 | { |
| 7694 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7695 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7696 | status=MagickFalse; |
| 7697 | break; |
| 7698 | } |
| 7699 | InsertImageInList(&q,p); |
| 7700 | } |
| 7701 | *images=GetFirstImageInList(q); |
| 7702 | break; |
| 7703 | } |
| 7704 | break; |
| 7705 | } |
| 7706 | case 'l': |
| 7707 | { |
| 7708 | if (LocaleCompare("layers",option+1) == 0) |
| 7709 | { |
| 7710 | Image |
| 7711 | *layers; |
| 7712 | |
| 7713 | ImageLayerMethod |
| 7714 | method; |
| 7715 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7716 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7717 | layers=(Image *) NULL; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7718 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7719 | MagickFalse,argv[i+1]); |
| 7720 | switch (method) |
| 7721 | { |
| 7722 | case CoalesceLayer: |
| 7723 | { |
| 7724 | layers=CoalesceImages(*images,exception); |
| 7725 | break; |
| 7726 | } |
| 7727 | case CompareAnyLayer: |
| 7728 | case CompareClearLayer: |
| 7729 | case CompareOverlayLayer: |
| 7730 | default: |
| 7731 | { |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7732 | layers=CompareImagesLayers(*images,method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7733 | break; |
| 7734 | } |
| 7735 | case MergeLayer: |
| 7736 | case FlattenLayer: |
| 7737 | case MosaicLayer: |
| 7738 | case TrimBoundsLayer: |
| 7739 | { |
| 7740 | layers=MergeImageLayers(*images,method,exception); |
| 7741 | break; |
| 7742 | } |
| 7743 | case DisposeLayer: |
| 7744 | { |
| 7745 | layers=DisposeImages(*images,exception); |
| 7746 | break; |
| 7747 | } |
| 7748 | case OptimizeImageLayer: |
| 7749 | { |
| 7750 | layers=OptimizeImageLayers(*images,exception); |
| 7751 | break; |
| 7752 | } |
| 7753 | case OptimizePlusLayer: |
| 7754 | { |
| 7755 | layers=OptimizePlusImageLayers(*images,exception); |
| 7756 | break; |
| 7757 | } |
| 7758 | case OptimizeTransLayer: |
| 7759 | { |
| 7760 | OptimizeImageTransparency(*images,exception); |
| 7761 | break; |
| 7762 | } |
| 7763 | case RemoveDupsLayer: |
| 7764 | { |
| 7765 | RemoveDuplicateLayers(images,exception); |
| 7766 | break; |
| 7767 | } |
| 7768 | case RemoveZeroLayer: |
| 7769 | { |
| 7770 | RemoveZeroDelayLayers(images,exception); |
| 7771 | break; |
| 7772 | } |
| 7773 | case OptimizeLayer: |
| 7774 | { |
| 7775 | /* |
| 7776 | General Purpose, GIF Animation Optimizer. |
| 7777 | */ |
| 7778 | layers=CoalesceImages(*images,exception); |
| 7779 | if (layers == (Image *) NULL) |
| 7780 | { |
| 7781 | status=MagickFalse; |
| 7782 | break; |
| 7783 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7784 | *images=DestroyImageList(*images); |
| 7785 | *images=layers; |
| 7786 | layers=OptimizeImageLayers(*images,exception); |
| 7787 | if (layers == (Image *) NULL) |
| 7788 | { |
| 7789 | status=MagickFalse; |
| 7790 | break; |
| 7791 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7792 | *images=DestroyImageList(*images); |
| 7793 | *images=layers; |
| 7794 | layers=(Image *) NULL; |
| 7795 | OptimizeImageTransparency(*images,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7796 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7797 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7798 | break; |
| 7799 | } |
| 7800 | case CompositeLayer: |
| 7801 | { |
| 7802 | CompositeOperator |
| 7803 | compose; |
| 7804 | |
| 7805 | Image |
| 7806 | *source; |
| 7807 | |
| 7808 | RectangleInfo |
| 7809 | geometry; |
| 7810 | |
| 7811 | /* |
| 7812 | Split image sequence at the first 'NULL:' image. |
| 7813 | */ |
| 7814 | source=(*images); |
| 7815 | while (source != (Image *) NULL) |
| 7816 | { |
| 7817 | source=GetNextImageInList(source); |
| 7818 | if ((source != (Image *) NULL) && |
| 7819 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7820 | break; |
| 7821 | } |
| 7822 | if (source != (Image *) NULL) |
| 7823 | { |
| 7824 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7825 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7826 | source=(Image *) NULL; |
| 7827 | else |
| 7828 | { |
| 7829 | /* |
| 7830 | Separate the two lists, junk the null: image. |
| 7831 | */ |
| 7832 | source=SplitImageList(source->previous); |
| 7833 | DeleteImageFromList(&source); |
| 7834 | } |
| 7835 | } |
| 7836 | if (source == (Image *) NULL) |
| 7837 | { |
| 7838 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7839 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7840 | status=MagickFalse; |
| 7841 | break; |
| 7842 | } |
| 7843 | /* |
| 7844 | Adjust offset with gravity and virtual canvas. |
| 7845 | */ |
| 7846 | SetGeometry(*images,&geometry); |
| 7847 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7848 | geometry.width=source->page.width != 0 ? |
| 7849 | source->page.width : source->columns; |
| 7850 | geometry.height=source->page.height != 0 ? |
| 7851 | source->page.height : source->rows; |
| 7852 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7853 | (*images)->page.width : (*images)->columns, |
| 7854 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7855 | (*images)->rows,(*images)->gravity,&geometry); |
| 7856 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7857 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7858 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7859 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7860 | MagickComposeOptions,MagickFalse,option); |
| 7861 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7862 | exception); |
| 7863 | source=DestroyImageList(source); |
| 7864 | break; |
| 7865 | } |
| 7866 | } |
| 7867 | if (layers == (Image *) NULL) |
| 7868 | break; |
| 7869 | InheritException(exception,&layers->exception); |
| 7870 | *images=DestroyImageList(*images); |
| 7871 | *images=layers; |
| 7872 | break; |
| 7873 | } |
| 7874 | break; |
| 7875 | } |
| 7876 | case 'm': |
| 7877 | { |
| 7878 | if (LocaleCompare("map",option+1) == 0) |
| 7879 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7880 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7881 | if (*option == '+') |
| 7882 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7883 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7884 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7885 | break; |
| 7886 | } |
| 7887 | i++; |
| 7888 | break; |
| 7889 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7890 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7891 | { |
| 7892 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7893 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7894 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7895 | /* |
| 7896 | Maximum image sequence (deprecated). |
| 7897 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7898 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7899 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7900 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7901 | { |
| 7902 | status=MagickFalse; |
| 7903 | break; |
| 7904 | } |
| 7905 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7906 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7907 | break; |
| 7908 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7909 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7910 | { |
| 7911 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7912 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7913 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7914 | /* |
| 7915 | Minimum image sequence (deprecated). |
| 7916 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7917 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7918 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7919 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7920 | { |
| 7921 | status=MagickFalse; |
| 7922 | break; |
| 7923 | } |
| 7924 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7925 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7926 | break; |
| 7927 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7928 | if (LocaleCompare("morph",option+1) == 0) |
| 7929 | { |
| 7930 | Image |
| 7931 | *morph_image; |
| 7932 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7933 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7934 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7935 | exception); |
| 7936 | if (morph_image == (Image *) NULL) |
| 7937 | { |
| 7938 | status=MagickFalse; |
| 7939 | break; |
| 7940 | } |
| 7941 | *images=DestroyImageList(*images); |
| 7942 | *images=morph_image; |
| 7943 | break; |
| 7944 | } |
| 7945 | if (LocaleCompare("mosaic",option+1) == 0) |
| 7946 | { |
| 7947 | Image |
| 7948 | *mosaic_image; |
| 7949 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7950 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7951 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 7952 | if (mosaic_image == (Image *) NULL) |
| 7953 | { |
| 7954 | status=MagickFalse; |
| 7955 | break; |
| 7956 | } |
| 7957 | *images=DestroyImageList(*images); |
| 7958 | *images=mosaic_image; |
| 7959 | break; |
| 7960 | } |
| 7961 | break; |
| 7962 | } |
| 7963 | case 'p': |
| 7964 | { |
| 7965 | if (LocaleCompare("print",option+1) == 0) |
| 7966 | { |
| 7967 | char |
| 7968 | *string; |
| 7969 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7970 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7971 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1], |
| 7972 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7973 | if (string == (char *) NULL) |
| 7974 | break; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 7975 | (void) FormatLocaleFile(stdout,"%s",string); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7976 | string=DestroyString(string); |
| 7977 | } |
| 7978 | if (LocaleCompare("process",option+1) == 0) |
| 7979 | { |
| 7980 | char |
| 7981 | **arguments; |
| 7982 | |
| 7983 | int |
| 7984 | j, |
| 7985 | number_arguments; |
| 7986 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7987 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7988 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 7989 | if (arguments == (char **) NULL) |
| 7990 | break; |
| 7991 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 7992 | { |
| 7993 | char |
| 7994 | breaker, |
| 7995 | quote, |
| 7996 | *token; |
| 7997 | |
| 7998 | const char |
| 7999 | *arguments; |
| 8000 | |
| 8001 | int |
| 8002 | next, |
| 8003 | status; |
| 8004 | |
| 8005 | size_t |
| 8006 | length; |
| 8007 | |
| 8008 | TokenInfo |
| 8009 | *token_info; |
| 8010 | |
| 8011 | /* |
| 8012 | Support old style syntax, filter="-option arg". |
| 8013 | */ |
| 8014 | length=strlen(argv[i+1]); |
| 8015 | token=(char *) NULL; |
cristy | 37e0b38 | 2011-06-07 13:31:21 +0000 | [diff] [blame] | 8016 | if (~length >= (MaxTextExtent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8017 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8018 | sizeof(*token)); |
| 8019 | if (token == (char *) NULL) |
| 8020 | break; |
| 8021 | next=0; |
| 8022 | arguments=argv[i+1]; |
| 8023 | token_info=AcquireTokenInfo(); |
| 8024 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8025 | "\"",'\0',&breaker,&next,"e); |
| 8026 | token_info=DestroyTokenInfo(token_info); |
| 8027 | if (status == 0) |
| 8028 | { |
| 8029 | const char |
| 8030 | *argv; |
| 8031 | |
| 8032 | argv=(&(arguments[next])); |
| 8033 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8034 | exception); |
| 8035 | } |
| 8036 | token=DestroyString(token); |
| 8037 | break; |
| 8038 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8039 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8040 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8041 | number_arguments-2,(const char **) arguments+2,exception); |
| 8042 | for (j=0; j < number_arguments; j++) |
| 8043 | arguments[j]=DestroyString(arguments[j]); |
| 8044 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8045 | break; |
| 8046 | } |
| 8047 | break; |
| 8048 | } |
| 8049 | case 'r': |
| 8050 | { |
| 8051 | if (LocaleCompare("reverse",option+1) == 0) |
| 8052 | { |
| 8053 | ReverseImageList(images); |
| 8054 | InheritException(exception,&(*images)->exception); |
| 8055 | break; |
| 8056 | } |
| 8057 | break; |
| 8058 | } |
| 8059 | case 's': |
| 8060 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8061 | if (LocaleCompare("smush",option+1) == 0) |
| 8062 | { |
| 8063 | Image |
| 8064 | *smush_image; |
| 8065 | |
| 8066 | ssize_t |
| 8067 | offset; |
| 8068 | |
| 8069 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8070 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8071 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8072 | MagickFalse,offset,exception); |
| 8073 | if (smush_image == (Image *) NULL) |
| 8074 | { |
| 8075 | status=MagickFalse; |
| 8076 | break; |
| 8077 | } |
| 8078 | *images=DestroyImageList(*images); |
| 8079 | *images=smush_image; |
| 8080 | break; |
| 8081 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8082 | if (LocaleCompare("swap",option+1) == 0) |
| 8083 | { |
| 8084 | Image |
| 8085 | *p, |
| 8086 | *q, |
| 8087 | *swap; |
| 8088 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8089 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8090 | swap_index; |
| 8091 | |
| 8092 | index=(-1); |
| 8093 | swap_index=(-2); |
| 8094 | if (*option != '+') |
| 8095 | { |
| 8096 | GeometryInfo |
| 8097 | geometry_info; |
| 8098 | |
| 8099 | MagickStatusType |
| 8100 | flags; |
| 8101 | |
| 8102 | swap_index=(-1); |
| 8103 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8104 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8105 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8106 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8107 | } |
| 8108 | p=GetImageFromList(*images,index); |
| 8109 | q=GetImageFromList(*images,swap_index); |
| 8110 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8111 | { |
| 8112 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8113 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8114 | status=MagickFalse; |
| 8115 | break; |
| 8116 | } |
| 8117 | if (p == q) |
| 8118 | break; |
| 8119 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8120 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8121 | ReplaceImageInList(&q,swap); |
| 8122 | *images=GetFirstImageInList(q); |
| 8123 | break; |
| 8124 | } |
| 8125 | break; |
| 8126 | } |
| 8127 | case 'w': |
| 8128 | { |
| 8129 | if (LocaleCompare("write",option+1) == 0) |
| 8130 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8131 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8132 | key[MaxTextExtent]; |
| 8133 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8134 | Image |
| 8135 | *write_images; |
| 8136 | |
| 8137 | ImageInfo |
| 8138 | *write_info; |
| 8139 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8140 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8141 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8142 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8143 | write_images=(*images); |
| 8144 | if (*option == '+') |
| 8145 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8146 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8147 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8148 | write_info=DestroyImageInfo(write_info); |
| 8149 | if (*option == '+') |
| 8150 | write_images=DestroyImageList(write_images); |
| 8151 | break; |
| 8152 | } |
| 8153 | break; |
| 8154 | } |
| 8155 | default: |
| 8156 | break; |
| 8157 | } |
| 8158 | i+=count; |
| 8159 | } |
| 8160 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8161 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8162 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8163 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8164 | } |
| 8165 | |
| 8166 | /* |
| 8167 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8168 | % % |
| 8169 | % % |
| 8170 | % % |
| 8171 | + M o g r i f y I m a g e s % |
| 8172 | % % |
| 8173 | % % |
| 8174 | % % |
| 8175 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8176 | % |
| 8177 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8178 | % prescribed by command line options. |
| 8179 | % |
| 8180 | % The format of the MogrifyImage method is: |
| 8181 | % |
| 8182 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8183 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8184 | % Image **images,Exceptioninfo *exception) |
| 8185 | % |
| 8186 | % A description of each parameter follows: |
| 8187 | % |
| 8188 | % o image_info: the image info.. |
| 8189 | % |
| 8190 | % o post: If true, post process image list operators otherwise pre-process. |
| 8191 | % |
| 8192 | % o argc: Specifies a pointer to an integer describing the number of |
| 8193 | % elements in the argument vector. |
| 8194 | % |
| 8195 | % o argv: Specifies a pointer to a text array containing the command line |
| 8196 | % arguments. |
| 8197 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8198 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8199 | % |
| 8200 | % o exception: return any errors or warnings in this structure. |
| 8201 | % |
| 8202 | */ |
| 8203 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8204 | const MagickBooleanType post,const int argc,const char **argv, |
| 8205 | Image **images,ExceptionInfo *exception) |
| 8206 | { |
| 8207 | #define MogrifyImageTag "Mogrify/Image" |
| 8208 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8209 | MagickStatusType |
| 8210 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8211 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8212 | MagickBooleanType |
| 8213 | proceed; |
| 8214 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8215 | size_t |
| 8216 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8217 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8218 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8219 | i; |
| 8220 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8221 | assert(image_info != (ImageInfo *) NULL); |
| 8222 | assert(image_info->signature == MagickSignature); |
| 8223 | if (images == (Image **) NULL) |
| 8224 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8225 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8226 | assert((*images)->signature == MagickSignature); |
| 8227 | if ((*images)->debug != MagickFalse) |
| 8228 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8229 | (*images)->filename); |
| 8230 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8231 | return(MagickTrue); |
| 8232 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8233 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8234 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8235 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8236 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8237 | (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc, |
| 8238 | post?"post":"pre"); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8239 | #endif |
| 8240 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8241 | /* |
| 8242 | Pre-process multi-image sequence operators |
| 8243 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8244 | if (post == MagickFalse) |
| 8245 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8246 | /* |
| 8247 | For each image, process simple single image operators |
| 8248 | */ |
| 8249 | i=0; |
| 8250 | n=GetImageListLength(*images); |
| 8251 | for (;;) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8252 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8253 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8254 | (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long) |
| 8255 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8256 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8257 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8258 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8259 | if (proceed == MagickFalse) |
| 8260 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8261 | if ( (*images)->next == (Image *) NULL ) |
| 8262 | break; |
| 8263 | *images=(*images)->next; |
| 8264 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8265 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8266 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8267 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8268 | (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long) |
| 8269 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8270 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8271 | |
| 8272 | /* |
| 8273 | Post-process, multi-image sequence operators |
| 8274 | */ |
| 8275 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8276 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8277 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8278 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8279 | } |