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, |
| 2125 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2126 | break; |
| 2127 | } |
| 2128 | break; |
| 2129 | } |
| 2130 | case 'n': |
| 2131 | { |
| 2132 | if (LocaleCompare("negate",option+1) == 0) |
| 2133 | { |
| 2134 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2135 | (void) NegateImage(*image,*option == '+' ? MagickTrue : |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 2136 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2137 | break; |
| 2138 | } |
| 2139 | if (LocaleCompare("noise",option+1) == 0) |
| 2140 | { |
| 2141 | (void) SyncImageSettings(mogrify_info,*image); |
| 2142 | if (*option == '-') |
| 2143 | { |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame^] | 2144 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2145 | if ((flags & SigmaValue) == 0) |
| 2146 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2147 | mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame^] | 2148 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2149 | } |
| 2150 | else |
| 2151 | { |
| 2152 | NoiseType |
| 2153 | noise; |
| 2154 | |
| 2155 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
| 2156 | MagickFalse,argv[i+1]); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 2157 | mogrify_image=AddNoiseImage(*image,noise,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2158 | } |
| 2159 | break; |
| 2160 | } |
| 2161 | if (LocaleCompare("normalize",option+1) == 0) |
| 2162 | { |
| 2163 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 2164 | (void) NormalizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2165 | break; |
| 2166 | } |
| 2167 | break; |
| 2168 | } |
| 2169 | case 'o': |
| 2170 | { |
| 2171 | if (LocaleCompare("opaque",option+1) == 0) |
| 2172 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2173 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2174 | target; |
| 2175 | |
| 2176 | (void) SyncImageSettings(mogrify_info,*image); |
| 2177 | (void) QueryMagickColor(argv[i+1],&target,exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 2178 | (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ? |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 2179 | MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2180 | break; |
| 2181 | } |
| 2182 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2183 | { |
| 2184 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 1302067 | 2011-07-08 02:33:26 +0000 | [diff] [blame] | 2185 | (void) OrderedPosterizeImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2186 | break; |
| 2187 | } |
| 2188 | break; |
| 2189 | } |
| 2190 | case 'p': |
| 2191 | { |
| 2192 | if (LocaleCompare("paint",option+1) == 0) |
| 2193 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2194 | (void) SyncImageSettings(mogrify_info,*image); |
| 2195 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 14973ba | 2011-08-27 23:48:07 +0000 | [diff] [blame] | 2196 | mogrify_image=OilPaintImage(*image,geometry_info.rho, |
| 2197 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2198 | break; |
| 2199 | } |
| 2200 | if (LocaleCompare("pen",option+1) == 0) |
| 2201 | { |
| 2202 | if (*option == '+') |
| 2203 | { |
| 2204 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 2205 | break; |
| 2206 | } |
| 2207 | (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception); |
| 2208 | break; |
| 2209 | } |
| 2210 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2211 | { |
| 2212 | if (*option == '+') |
| 2213 | (void) ParseGeometry("12",&geometry_info); |
| 2214 | else |
| 2215 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2216 | draw_info->pointsize=geometry_info.rho; |
| 2217 | break; |
| 2218 | } |
| 2219 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2220 | { |
| 2221 | double |
| 2222 | angle; |
| 2223 | |
| 2224 | RandomInfo |
| 2225 | *random_info; |
| 2226 | |
| 2227 | /* |
| 2228 | Simulate a Polaroid picture. |
| 2229 | */ |
| 2230 | (void) SyncImageSettings(mogrify_info,*image); |
| 2231 | random_info=AcquireRandomInfo(); |
| 2232 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2233 | random_info=DestroyRandomInfo(random_info); |
| 2234 | if (*option == '-') |
| 2235 | { |
| 2236 | SetGeometryInfo(&geometry_info); |
| 2237 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2238 | angle=geometry_info.rho; |
| 2239 | } |
| 2240 | mogrify_image=PolaroidImage(*image,draw_info,angle,exception); |
| 2241 | break; |
| 2242 | } |
| 2243 | if (LocaleCompare("posterize",option+1) == 0) |
| 2244 | { |
| 2245 | /* |
| 2246 | Posterize image. |
| 2247 | */ |
| 2248 | (void) SyncImageSettings(mogrify_info,*image); |
| 2249 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2250 | quantize_info->dither,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2251 | break; |
| 2252 | } |
| 2253 | if (LocaleCompare("preview",option+1) == 0) |
| 2254 | { |
| 2255 | PreviewType |
| 2256 | preview_type; |
| 2257 | |
| 2258 | /* |
| 2259 | Preview image. |
| 2260 | */ |
| 2261 | (void) SyncImageSettings(mogrify_info,*image); |
| 2262 | if (*option == '+') |
| 2263 | preview_type=UndefinedPreview; |
| 2264 | else |
| 2265 | preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions, |
| 2266 | MagickFalse,argv[i+1]); |
| 2267 | mogrify_image=PreviewImage(*image,preview_type,exception); |
| 2268 | break; |
| 2269 | } |
| 2270 | if (LocaleCompare("profile",option+1) == 0) |
| 2271 | { |
| 2272 | const char |
| 2273 | *name; |
| 2274 | |
| 2275 | const StringInfo |
| 2276 | *profile; |
| 2277 | |
| 2278 | Image |
| 2279 | *profile_image; |
| 2280 | |
| 2281 | ImageInfo |
| 2282 | *profile_info; |
| 2283 | |
| 2284 | (void) SyncImageSettings(mogrify_info,*image); |
| 2285 | if (*option == '+') |
| 2286 | { |
| 2287 | /* |
| 2288 | Remove a profile from the image. |
| 2289 | */ |
| 2290 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
| 2291 | NULL,0,MagickTrue); |
| 2292 | InheritException(exception,&(*image)->exception); |
| 2293 | break; |
| 2294 | } |
| 2295 | /* |
| 2296 | Associate a profile with the image. |
| 2297 | */ |
| 2298 | profile_info=CloneImageInfo(mogrify_info); |
| 2299 | profile=GetImageProfile(*image,"iptc"); |
| 2300 | if (profile != (StringInfo *) NULL) |
| 2301 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2302 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2303 | profile_info=DestroyImageInfo(profile_info); |
| 2304 | if (profile_image == (Image *) NULL) |
| 2305 | { |
| 2306 | StringInfo |
| 2307 | *profile; |
| 2308 | |
| 2309 | profile_info=CloneImageInfo(mogrify_info); |
| 2310 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2311 | MaxTextExtent); |
| 2312 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
| 2313 | if (profile != (StringInfo *) NULL) |
| 2314 | { |
| 2315 | (void) ProfileImage(*image,profile_info->magick, |
| 2316 | GetStringInfoDatum(profile),(size_t) |
| 2317 | GetStringInfoLength(profile),MagickFalse); |
| 2318 | profile=DestroyStringInfo(profile); |
| 2319 | } |
| 2320 | profile_info=DestroyImageInfo(profile_info); |
| 2321 | break; |
| 2322 | } |
| 2323 | ResetImageProfileIterator(profile_image); |
| 2324 | name=GetNextImageProfile(profile_image); |
| 2325 | while (name != (const char *) NULL) |
| 2326 | { |
| 2327 | profile=GetImageProfile(profile_image,name); |
| 2328 | if (profile != (StringInfo *) NULL) |
| 2329 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
| 2330 | (size_t) GetStringInfoLength(profile),MagickFalse); |
| 2331 | name=GetNextImageProfile(profile_image); |
| 2332 | } |
| 2333 | profile_image=DestroyImage(profile_image); |
| 2334 | break; |
| 2335 | } |
| 2336 | break; |
| 2337 | } |
| 2338 | case 'q': |
| 2339 | { |
| 2340 | if (LocaleCompare("quantize",option+1) == 0) |
| 2341 | { |
| 2342 | if (*option == '+') |
| 2343 | { |
| 2344 | quantize_info->colorspace=UndefinedColorspace; |
| 2345 | break; |
| 2346 | } |
| 2347 | quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
| 2348 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2349 | break; |
| 2350 | } |
| 2351 | break; |
| 2352 | } |
| 2353 | case 'r': |
| 2354 | { |
| 2355 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2356 | { |
| 2357 | /* |
| 2358 | Radial blur image. |
| 2359 | */ |
| 2360 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2361 | mogrify_image=RadialBlurImage(*image,InterpretLocaleValue(argv[i+1], |
| 2362 | (char **) NULL),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2363 | break; |
| 2364 | } |
| 2365 | if (LocaleCompare("raise",option+1) == 0) |
| 2366 | { |
| 2367 | /* |
| 2368 | Surround image with a raise of solid color. |
| 2369 | */ |
| 2370 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2371 | if ((flags & SigmaValue) == 0) |
| 2372 | geometry.height=geometry.width; |
| 2373 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
cristy | 6170ac3 | 2011-08-28 14:15:37 +0000 | [diff] [blame] | 2374 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2375 | break; |
| 2376 | } |
| 2377 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2378 | { |
| 2379 | /* |
| 2380 | Threshold image. |
| 2381 | */ |
| 2382 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2383 | (void) RandomThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2384 | break; |
| 2385 | } |
| 2386 | if (LocaleCompare("recolor",option+1) == 0) |
| 2387 | { |
| 2388 | KernelInfo |
| 2389 | *kernel; |
| 2390 | |
| 2391 | (void) SyncImageSettings(mogrify_info,*image); |
| 2392 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2393 | if (kernel == (KernelInfo *) NULL) |
| 2394 | break; |
| 2395 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 2396 | kernel=DestroyKernelInfo(kernel); |
| 2397 | break; |
| 2398 | } |
| 2399 | if (LocaleCompare("region",option+1) == 0) |
| 2400 | { |
| 2401 | (void) SyncImageSettings(mogrify_info,*image); |
| 2402 | if (region_image != (Image *) NULL) |
| 2403 | { |
| 2404 | /* |
| 2405 | Composite region. |
| 2406 | */ |
| 2407 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2408 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 2409 | region_geometry.x,region_geometry.y); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2410 | InheritException(exception,®ion_image->exception); |
| 2411 | *image=DestroyImage(*image); |
| 2412 | *image=region_image; |
| 2413 | region_image = (Image *) NULL; |
| 2414 | } |
| 2415 | if (*option == '+') |
| 2416 | break; |
| 2417 | /* |
| 2418 | Apply transformations to a selected region of the image. |
| 2419 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2420 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2421 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2422 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2423 | if (mogrify_image == (Image *) NULL) |
| 2424 | break; |
| 2425 | region_image=(*image); |
| 2426 | *image=mogrify_image; |
| 2427 | mogrify_image=(Image *) NULL; |
| 2428 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2429 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2430 | if (LocaleCompare("render",option+1) == 0) |
| 2431 | { |
| 2432 | (void) SyncImageSettings(mogrify_info,*image); |
| 2433 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2434 | break; |
| 2435 | } |
| 2436 | if (LocaleCompare("remap",option+1) == 0) |
| 2437 | { |
| 2438 | Image |
| 2439 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2440 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2441 | /* |
| 2442 | Transform image colors to match this set of colors. |
| 2443 | */ |
| 2444 | (void) SyncImageSettings(mogrify_info,*image); |
| 2445 | if (*option == '+') |
| 2446 | break; |
| 2447 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2448 | if (remap_image == (Image *) NULL) |
| 2449 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2450 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2451 | remap_image=DestroyImage(remap_image); |
| 2452 | break; |
| 2453 | } |
| 2454 | if (LocaleCompare("repage",option+1) == 0) |
| 2455 | { |
| 2456 | if (*option == '+') |
| 2457 | { |
| 2458 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2459 | break; |
| 2460 | } |
| 2461 | (void) ResetImagePage(*image,argv[i+1]); |
| 2462 | InheritException(exception,&(*image)->exception); |
| 2463 | break; |
| 2464 | } |
| 2465 | if (LocaleCompare("resample",option+1) == 0) |
| 2466 | { |
| 2467 | /* |
| 2468 | Resample image. |
| 2469 | */ |
| 2470 | (void) SyncImageSettings(mogrify_info,*image); |
| 2471 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2472 | if ((flags & SigmaValue) == 0) |
| 2473 | geometry_info.sigma=geometry_info.rho; |
| 2474 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
| 2475 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2476 | break; |
| 2477 | } |
| 2478 | if (LocaleCompare("resize",option+1) == 0) |
| 2479 | { |
| 2480 | /* |
| 2481 | Resize image. |
| 2482 | */ |
| 2483 | (void) SyncImageSettings(mogrify_info,*image); |
| 2484 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2485 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2486 | (*image)->filter,(*image)->blur,exception); |
| 2487 | break; |
| 2488 | } |
| 2489 | if (LocaleCompare("roll",option+1) == 0) |
| 2490 | { |
| 2491 | /* |
| 2492 | Roll image. |
| 2493 | */ |
| 2494 | (void) SyncImageSettings(mogrify_info,*image); |
| 2495 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2496 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2497 | break; |
| 2498 | } |
| 2499 | if (LocaleCompare("rotate",option+1) == 0) |
| 2500 | { |
| 2501 | char |
| 2502 | *geometry; |
| 2503 | |
| 2504 | /* |
| 2505 | Check for conditional image rotation. |
| 2506 | */ |
| 2507 | (void) SyncImageSettings(mogrify_info,*image); |
| 2508 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2509 | if ((*image)->columns <= (*image)->rows) |
| 2510 | break; |
| 2511 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2512 | if ((*image)->columns >= (*image)->rows) |
| 2513 | break; |
| 2514 | /* |
| 2515 | Rotate image. |
| 2516 | */ |
| 2517 | geometry=ConstantString(argv[i+1]); |
| 2518 | (void) SubstituteString(&geometry,">",""); |
| 2519 | (void) SubstituteString(&geometry,"<",""); |
| 2520 | (void) ParseGeometry(geometry,&geometry_info); |
| 2521 | geometry=DestroyString(geometry); |
| 2522 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
| 2523 | break; |
| 2524 | } |
| 2525 | break; |
| 2526 | } |
| 2527 | case 's': |
| 2528 | { |
| 2529 | if (LocaleCompare("sample",option+1) == 0) |
| 2530 | { |
| 2531 | /* |
| 2532 | Sample image with pixel replication. |
| 2533 | */ |
| 2534 | (void) SyncImageSettings(mogrify_info,*image); |
| 2535 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2536 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
| 2537 | exception); |
| 2538 | break; |
| 2539 | } |
| 2540 | if (LocaleCompare("scale",option+1) == 0) |
| 2541 | { |
| 2542 | /* |
| 2543 | Resize image. |
| 2544 | */ |
| 2545 | (void) SyncImageSettings(mogrify_info,*image); |
| 2546 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2547 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2548 | exception); |
| 2549 | break; |
| 2550 | } |
| 2551 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2552 | { |
| 2553 | /* |
| 2554 | Selectively blur pixels within a contrast threshold. |
| 2555 | */ |
| 2556 | (void) SyncImageSettings(mogrify_info,*image); |
| 2557 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2558 | if ((flags & PercentValue) != 0) |
| 2559 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2560 | mogrify_image=SelectiveBlurImage(*image,geometry_info.rho, |
| 2561 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2562 | break; |
| 2563 | } |
| 2564 | if (LocaleCompare("separate",option+1) == 0) |
| 2565 | { |
| 2566 | /* |
| 2567 | Break channels into separate images. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2568 | */ |
| 2569 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 2570 | mogrify_image=SeparateImages(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2571 | break; |
| 2572 | } |
| 2573 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2574 | { |
| 2575 | double |
| 2576 | threshold; |
| 2577 | |
| 2578 | /* |
| 2579 | Sepia-tone image. |
| 2580 | */ |
| 2581 | (void) SyncImageSettings(mogrify_info,*image); |
| 2582 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2583 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
| 2584 | break; |
| 2585 | } |
| 2586 | if (LocaleCompare("segment",option+1) == 0) |
| 2587 | { |
| 2588 | /* |
| 2589 | Segment image. |
| 2590 | */ |
| 2591 | (void) SyncImageSettings(mogrify_info,*image); |
| 2592 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2593 | if ((flags & SigmaValue) == 0) |
| 2594 | geometry_info.sigma=1.0; |
| 2595 | (void) SegmentImage(*image,(*image)->colorspace, |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2596 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 2597 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2598 | break; |
| 2599 | } |
| 2600 | if (LocaleCompare("set",option+1) == 0) |
| 2601 | { |
| 2602 | char |
| 2603 | *value; |
| 2604 | |
| 2605 | /* |
| 2606 | Set image option. |
| 2607 | */ |
| 2608 | if (*option == '+') |
| 2609 | { |
| 2610 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2611 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2612 | else |
| 2613 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2614 | { |
| 2615 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
| 2616 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2617 | } |
| 2618 | else |
| 2619 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2620 | break; |
| 2621 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2622 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2623 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2624 | if (value == (char *) NULL) |
| 2625 | break; |
| 2626 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2627 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2628 | exception); |
| 2629 | else |
| 2630 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2631 | { |
| 2632 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
| 2633 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
| 2634 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2635 | } |
| 2636 | else |
| 2637 | (void) SetImageProperty(*image,argv[i+1],value); |
| 2638 | value=DestroyString(value); |
| 2639 | break; |
| 2640 | } |
| 2641 | if (LocaleCompare("shade",option+1) == 0) |
| 2642 | { |
| 2643 | /* |
| 2644 | Shade image. |
| 2645 | */ |
| 2646 | (void) SyncImageSettings(mogrify_info,*image); |
| 2647 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2648 | if ((flags & SigmaValue) == 0) |
| 2649 | geometry_info.sigma=1.0; |
| 2650 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2651 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2652 | break; |
| 2653 | } |
| 2654 | if (LocaleCompare("shadow",option+1) == 0) |
| 2655 | { |
| 2656 | /* |
| 2657 | Shadow image. |
| 2658 | */ |
| 2659 | (void) SyncImageSettings(mogrify_info,*image); |
| 2660 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2661 | if ((flags & SigmaValue) == 0) |
| 2662 | geometry_info.sigma=1.0; |
| 2663 | if ((flags & XiValue) == 0) |
| 2664 | geometry_info.xi=4.0; |
| 2665 | if ((flags & PsiValue) == 0) |
| 2666 | geometry_info.psi=4.0; |
| 2667 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
| 2668 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 2669 | ceil(geometry_info.psi-0.5),exception); |
| 2670 | break; |
| 2671 | } |
| 2672 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2673 | { |
| 2674 | /* |
| 2675 | Sharpen image. |
| 2676 | */ |
| 2677 | (void) SyncImageSettings(mogrify_info,*image); |
| 2678 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2679 | if ((flags & SigmaValue) == 0) |
| 2680 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2681 | if ((flags & XiValue) == 0) |
| 2682 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2683 | mogrify_image=SharpenImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2684 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2685 | break; |
| 2686 | } |
| 2687 | if (LocaleCompare("shave",option+1) == 0) |
| 2688 | { |
| 2689 | /* |
| 2690 | Shave the image edges. |
| 2691 | */ |
| 2692 | (void) SyncImageSettings(mogrify_info,*image); |
| 2693 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2694 | mogrify_image=ShaveImage(*image,&geometry,exception); |
| 2695 | break; |
| 2696 | } |
| 2697 | if (LocaleCompare("shear",option+1) == 0) |
| 2698 | { |
| 2699 | /* |
| 2700 | Shear image. |
| 2701 | */ |
| 2702 | (void) SyncImageSettings(mogrify_info,*image); |
| 2703 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2704 | if ((flags & SigmaValue) == 0) |
| 2705 | geometry_info.sigma=geometry_info.rho; |
| 2706 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2707 | geometry_info.sigma,exception); |
| 2708 | break; |
| 2709 | } |
| 2710 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2711 | { |
| 2712 | /* |
| 2713 | Sigmoidal non-linearity contrast control. |
| 2714 | */ |
| 2715 | (void) SyncImageSettings(mogrify_info,*image); |
| 2716 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2717 | if ((flags & SigmaValue) == 0) |
| 2718 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 2719 | if ((flags & PercentValue) != 0) |
| 2720 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2721 | 100.0; |
cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 2722 | (void) SigmoidalContrastImage(*image,(*option == '-') ? |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2723 | MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma, |
| 2724 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2725 | break; |
| 2726 | } |
| 2727 | if (LocaleCompare("sketch",option+1) == 0) |
| 2728 | { |
| 2729 | /* |
| 2730 | Sketch image. |
| 2731 | */ |
| 2732 | (void) SyncImageSettings(mogrify_info,*image); |
| 2733 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2734 | if ((flags & SigmaValue) == 0) |
| 2735 | geometry_info.sigma=1.0; |
| 2736 | mogrify_image=SketchImage(*image,geometry_info.rho, |
| 2737 | geometry_info.sigma,geometry_info.xi,exception); |
| 2738 | break; |
| 2739 | } |
| 2740 | if (LocaleCompare("solarize",option+1) == 0) |
| 2741 | { |
| 2742 | double |
| 2743 | threshold; |
| 2744 | |
| 2745 | (void) SyncImageSettings(mogrify_info,*image); |
| 2746 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 2747 | (void) SolarizeImage(*image,threshold,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2748 | break; |
| 2749 | } |
| 2750 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2751 | { |
| 2752 | SparseColorMethod |
| 2753 | method; |
| 2754 | |
| 2755 | char |
| 2756 | *arguments; |
| 2757 | |
| 2758 | /* |
| 2759 | Sparse Color Interpolated Gradient |
| 2760 | */ |
| 2761 | (void) SyncImageSettings(mogrify_info,*image); |
| 2762 | method=(SparseColorMethod) ParseCommandOption( |
| 2763 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2764 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2765 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2766 | if (arguments == (char *) NULL) |
| 2767 | break; |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 2768 | mogrify_image=SparseColorOption(*image,method,arguments, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2769 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2770 | arguments=DestroyString(arguments); |
| 2771 | break; |
| 2772 | } |
| 2773 | if (LocaleCompare("splice",option+1) == 0) |
| 2774 | { |
| 2775 | /* |
| 2776 | Splice a solid color into the image. |
| 2777 | */ |
| 2778 | (void) SyncImageSettings(mogrify_info,*image); |
| 2779 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 2780 | mogrify_image=SpliceImage(*image,&geometry,exception); |
| 2781 | break; |
| 2782 | } |
| 2783 | if (LocaleCompare("spread",option+1) == 0) |
| 2784 | { |
| 2785 | /* |
| 2786 | Spread an image. |
| 2787 | */ |
| 2788 | (void) SyncImageSettings(mogrify_info,*image); |
| 2789 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2790 | mogrify_image=SpreadImage(*image,geometry_info.rho,exception); |
| 2791 | break; |
| 2792 | } |
| 2793 | if (LocaleCompare("statistic",option+1) == 0) |
| 2794 | { |
| 2795 | StatisticType |
| 2796 | type; |
| 2797 | |
| 2798 | (void) SyncImageSettings(mogrify_info,*image); |
| 2799 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
| 2800 | MagickFalse,argv[i+1]); |
| 2801 | (void) ParseGeometry(argv[i+2],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2802 | mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho, |
| 2803 | (size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2804 | break; |
| 2805 | } |
| 2806 | if (LocaleCompare("stretch",option+1) == 0) |
| 2807 | { |
| 2808 | if (*option == '+') |
| 2809 | { |
| 2810 | draw_info->stretch=UndefinedStretch; |
| 2811 | break; |
| 2812 | } |
| 2813 | draw_info->stretch=(StretchType) ParseCommandOption( |
| 2814 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2815 | break; |
| 2816 | } |
| 2817 | if (LocaleCompare("strip",option+1) == 0) |
| 2818 | { |
| 2819 | /* |
| 2820 | Strip image of profiles and comments. |
| 2821 | */ |
| 2822 | (void) SyncImageSettings(mogrify_info,*image); |
| 2823 | (void) StripImage(*image); |
| 2824 | InheritException(exception,&(*image)->exception); |
| 2825 | break; |
| 2826 | } |
| 2827 | if (LocaleCompare("stroke",option+1) == 0) |
| 2828 | { |
| 2829 | ExceptionInfo |
| 2830 | *sans; |
| 2831 | |
| 2832 | if (*option == '+') |
| 2833 | { |
| 2834 | (void) QueryColorDatabase("none",&draw_info->stroke,exception); |
| 2835 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2836 | draw_info->stroke_pattern=DestroyImage( |
| 2837 | draw_info->stroke_pattern); |
| 2838 | break; |
| 2839 | } |
| 2840 | sans=AcquireExceptionInfo(); |
| 2841 | status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans); |
| 2842 | sans=DestroyExceptionInfo(sans); |
| 2843 | if (status == MagickFalse) |
| 2844 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2845 | exception); |
| 2846 | break; |
| 2847 | } |
| 2848 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2849 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 2850 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 2851 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2852 | break; |
| 2853 | } |
| 2854 | if (LocaleCompare("style",option+1) == 0) |
| 2855 | { |
| 2856 | if (*option == '+') |
| 2857 | { |
| 2858 | draw_info->style=UndefinedStyle; |
| 2859 | break; |
| 2860 | } |
| 2861 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 2862 | MagickFalse,argv[i+1]); |
| 2863 | break; |
| 2864 | } |
| 2865 | if (LocaleCompare("swirl",option+1) == 0) |
| 2866 | { |
| 2867 | /* |
| 2868 | Swirl image. |
| 2869 | */ |
| 2870 | (void) SyncImageSettings(mogrify_info,*image); |
| 2871 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2872 | mogrify_image=SwirlImage(*image,geometry_info.rho,exception); |
| 2873 | break; |
| 2874 | } |
| 2875 | break; |
| 2876 | } |
| 2877 | case 't': |
| 2878 | { |
| 2879 | if (LocaleCompare("threshold",option+1) == 0) |
| 2880 | { |
| 2881 | double |
| 2882 | threshold; |
| 2883 | |
| 2884 | /* |
| 2885 | Threshold image. |
| 2886 | */ |
| 2887 | (void) SyncImageSettings(mogrify_info,*image); |
| 2888 | if (*option == '+') |
anthony | 247a86d | 2011-05-03 13:18:18 +0000 | [diff] [blame] | 2889 | threshold=(double) QuantumRange/2; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2890 | else |
| 2891 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2892 | (void) BilevelImage(*image,threshold); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2893 | InheritException(exception,&(*image)->exception); |
| 2894 | break; |
| 2895 | } |
| 2896 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2897 | { |
| 2898 | /* |
| 2899 | Thumbnail image. |
| 2900 | */ |
| 2901 | (void) SyncImageSettings(mogrify_info,*image); |
| 2902 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2903 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2904 | exception); |
| 2905 | break; |
| 2906 | } |
| 2907 | if (LocaleCompare("tile",option+1) == 0) |
| 2908 | { |
| 2909 | if (*option == '+') |
| 2910 | { |
| 2911 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2912 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2913 | break; |
| 2914 | } |
| 2915 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2916 | exception); |
| 2917 | break; |
| 2918 | } |
| 2919 | if (LocaleCompare("tint",option+1) == 0) |
| 2920 | { |
| 2921 | /* |
| 2922 | Tint the image. |
| 2923 | */ |
| 2924 | (void) SyncImageSettings(mogrify_info,*image); |
| 2925 | mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception); |
| 2926 | break; |
| 2927 | } |
| 2928 | if (LocaleCompare("transform",option+1) == 0) |
| 2929 | { |
| 2930 | /* |
| 2931 | Affine transform image. |
| 2932 | */ |
| 2933 | (void) SyncImageSettings(mogrify_info,*image); |
| 2934 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
| 2935 | exception); |
| 2936 | break; |
| 2937 | } |
| 2938 | if (LocaleCompare("transparent",option+1) == 0) |
| 2939 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2940 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2941 | target; |
| 2942 | |
| 2943 | (void) SyncImageSettings(mogrify_info,*image); |
| 2944 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2945 | (void) TransparentPaintImage(*image,&target,(Quantum) |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 2946 | TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue, |
| 2947 | &(*image)->exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2948 | break; |
| 2949 | } |
| 2950 | if (LocaleCompare("transpose",option+1) == 0) |
| 2951 | { |
| 2952 | /* |
| 2953 | Transpose image scanlines. |
| 2954 | */ |
| 2955 | (void) SyncImageSettings(mogrify_info,*image); |
| 2956 | mogrify_image=TransposeImage(*image,exception); |
| 2957 | break; |
| 2958 | } |
| 2959 | if (LocaleCompare("transverse",option+1) == 0) |
| 2960 | { |
| 2961 | /* |
| 2962 | Transverse image scanlines. |
| 2963 | */ |
| 2964 | (void) SyncImageSettings(mogrify_info,*image); |
| 2965 | mogrify_image=TransverseImage(*image,exception); |
| 2966 | break; |
| 2967 | } |
| 2968 | if (LocaleCompare("treedepth",option+1) == 0) |
| 2969 | { |
| 2970 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
| 2971 | break; |
| 2972 | } |
| 2973 | if (LocaleCompare("trim",option+1) == 0) |
| 2974 | { |
| 2975 | /* |
| 2976 | Trim image. |
| 2977 | */ |
| 2978 | (void) SyncImageSettings(mogrify_info,*image); |
| 2979 | mogrify_image=TrimImage(*image,exception); |
| 2980 | break; |
| 2981 | } |
| 2982 | if (LocaleCompare("type",option+1) == 0) |
| 2983 | { |
| 2984 | ImageType |
| 2985 | type; |
| 2986 | |
| 2987 | (void) SyncImageSettings(mogrify_info,*image); |
| 2988 | if (*option == '+') |
| 2989 | type=UndefinedType; |
| 2990 | else |
| 2991 | type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 2992 | argv[i+1]); |
| 2993 | (*image)->type=UndefinedType; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2994 | (void) SetImageType(*image,type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2995 | break; |
| 2996 | } |
| 2997 | break; |
| 2998 | } |
| 2999 | case 'u': |
| 3000 | { |
| 3001 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3002 | { |
| 3003 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 3004 | exception); |
| 3005 | break; |
| 3006 | } |
| 3007 | if (LocaleCompare("unique",option+1) == 0) |
| 3008 | { |
| 3009 | if (*option == '+') |
| 3010 | { |
| 3011 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
| 3012 | break; |
| 3013 | } |
| 3014 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
| 3015 | (void) SetImageArtifact(*image,"verbose","true"); |
| 3016 | break; |
| 3017 | } |
| 3018 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3019 | { |
| 3020 | /* |
| 3021 | Unique image colors. |
| 3022 | */ |
| 3023 | (void) SyncImageSettings(mogrify_info,*image); |
| 3024 | mogrify_image=UniqueImageColors(*image,exception); |
| 3025 | break; |
| 3026 | } |
| 3027 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3028 | { |
| 3029 | /* |
| 3030 | Unsharp mask image. |
| 3031 | */ |
| 3032 | (void) SyncImageSettings(mogrify_info,*image); |
| 3033 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3034 | if ((flags & SigmaValue) == 0) |
| 3035 | geometry_info.sigma=1.0; |
| 3036 | if ((flags & XiValue) == 0) |
| 3037 | geometry_info.xi=1.0; |
| 3038 | if ((flags & PsiValue) == 0) |
| 3039 | geometry_info.psi=0.05; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3040 | mogrify_image=UnsharpMaskImage(*image,geometry_info.rho, |
| 3041 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3042 | break; |
| 3043 | } |
| 3044 | break; |
| 3045 | } |
| 3046 | case 'v': |
| 3047 | { |
| 3048 | if (LocaleCompare("verbose",option+1) == 0) |
| 3049 | { |
| 3050 | (void) SetImageArtifact(*image,option+1, |
| 3051 | *option == '+' ? "false" : "true"); |
| 3052 | break; |
| 3053 | } |
| 3054 | if (LocaleCompare("vignette",option+1) == 0) |
| 3055 | { |
| 3056 | /* |
| 3057 | Vignette image. |
| 3058 | */ |
| 3059 | (void) SyncImageSettings(mogrify_info,*image); |
| 3060 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3061 | if ((flags & SigmaValue) == 0) |
| 3062 | geometry_info.sigma=1.0; |
| 3063 | if ((flags & XiValue) == 0) |
| 3064 | geometry_info.xi=0.1*(*image)->columns; |
| 3065 | if ((flags & PsiValue) == 0) |
| 3066 | geometry_info.psi=0.1*(*image)->rows; |
| 3067 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
| 3068 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3069 | ceil(geometry_info.psi-0.5),exception); |
| 3070 | break; |
| 3071 | } |
| 3072 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3073 | { |
| 3074 | if (*option == '+') |
| 3075 | { |
| 3076 | (void) SetImageVirtualPixelMethod(*image, |
| 3077 | UndefinedVirtualPixelMethod); |
| 3078 | break; |
| 3079 | } |
| 3080 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3081 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 3082 | argv[i+1])); |
| 3083 | break; |
| 3084 | } |
| 3085 | break; |
| 3086 | } |
| 3087 | case 'w': |
| 3088 | { |
| 3089 | if (LocaleCompare("wave",option+1) == 0) |
| 3090 | { |
| 3091 | /* |
| 3092 | Wave image. |
| 3093 | */ |
| 3094 | (void) SyncImageSettings(mogrify_info,*image); |
| 3095 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3096 | if ((flags & SigmaValue) == 0) |
| 3097 | geometry_info.sigma=1.0; |
| 3098 | mogrify_image=WaveImage(*image,geometry_info.rho, |
| 3099 | geometry_info.sigma,exception); |
| 3100 | break; |
| 3101 | } |
| 3102 | if (LocaleCompare("weight",option+1) == 0) |
| 3103 | { |
| 3104 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
| 3105 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3106 | draw_info->weight=0; |
| 3107 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3108 | draw_info->weight=700; |
| 3109 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3110 | if (draw_info->weight <= 800) |
| 3111 | draw_info->weight+=100; |
| 3112 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3113 | if (draw_info->weight >= 100) |
| 3114 | draw_info->weight-=100; |
| 3115 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3116 | draw_info->weight=400; |
| 3117 | break; |
| 3118 | } |
| 3119 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3120 | { |
| 3121 | /* |
| 3122 | White threshold image. |
| 3123 | */ |
| 3124 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3125 | (void) WhiteThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3126 | InheritException(exception,&(*image)->exception); |
| 3127 | break; |
| 3128 | } |
| 3129 | break; |
| 3130 | } |
| 3131 | default: |
| 3132 | break; |
| 3133 | } |
| 3134 | /* |
| 3135 | Replace current image with any image that was generated |
| 3136 | */ |
| 3137 | if (mogrify_image != (Image *) NULL) |
| 3138 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3139 | i+=count; |
| 3140 | } |
| 3141 | if (region_image != (Image *) NULL) |
| 3142 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3143 | /* |
| 3144 | Composite transformed region onto image. |
| 3145 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3146 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3147 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3148 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 3149 | region_geometry.x,region_geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3150 | InheritException(exception,®ion_image->exception); |
| 3151 | *image=DestroyImage(*image); |
| 3152 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3153 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3154 | } |
| 3155 | /* |
| 3156 | Free resources. |
| 3157 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3158 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3159 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3160 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 3161 | status=(MagickStatusType) ((*image)->exception.severity == |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 3162 | UndefinedException ? 1 : 0); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3163 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3164 | } |
| 3165 | |
| 3166 | /* |
| 3167 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3168 | % % |
| 3169 | % % |
| 3170 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3171 | + 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] | 3172 | % % |
| 3173 | % % |
| 3174 | % % |
| 3175 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3176 | % |
| 3177 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3178 | % transforms include image scaling, image rotation, color reduction, and |
| 3179 | % others. The transmogrified image overwrites the original image. |
| 3180 | % |
| 3181 | % The format of the MogrifyImageCommand method is: |
| 3182 | % |
| 3183 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3184 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3185 | % |
| 3186 | % A description of each parameter follows: |
| 3187 | % |
| 3188 | % o image_info: the image info. |
| 3189 | % |
| 3190 | % o argc: the number of elements in the argument vector. |
| 3191 | % |
| 3192 | % o argv: A text array containing the command line arguments. |
| 3193 | % |
| 3194 | % o metadata: any metadata is returned here. |
| 3195 | % |
| 3196 | % o exception: return any errors or warnings in this structure. |
| 3197 | % |
| 3198 | */ |
| 3199 | |
| 3200 | static MagickBooleanType MogrifyUsage(void) |
| 3201 | { |
| 3202 | static const char |
| 3203 | *miscellaneous[]= |
| 3204 | { |
| 3205 | "-debug events display copious debugging information", |
| 3206 | "-help print program options", |
| 3207 | "-list type print a list of supported option arguments", |
| 3208 | "-log format format of debugging information", |
| 3209 | "-version print version information", |
| 3210 | (char *) NULL |
| 3211 | }, |
| 3212 | *operators[]= |
| 3213 | { |
| 3214 | "-adaptive-blur geometry", |
| 3215 | " adaptively blur pixels; decrease effect near edges", |
| 3216 | "-adaptive-resize geometry", |
| 3217 | " adaptively resize image using 'mesh' interpolation", |
| 3218 | "-adaptive-sharpen geometry", |
| 3219 | " adaptively sharpen pixels; increase effect near edges", |
| 3220 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3221 | " transparent, extract, background, or shape", |
| 3222 | "-annotate geometry text", |
| 3223 | " annotate the image with text", |
| 3224 | "-auto-gamma automagically adjust gamma level of image", |
| 3225 | "-auto-level automagically adjust color levels of image", |
| 3226 | "-auto-orient automagically orient (rotate) image", |
| 3227 | "-bench iterations measure performance", |
| 3228 | "-black-threshold value", |
| 3229 | " force all pixels below the threshold into black", |
| 3230 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3231 | "-blur geometry reduce image noise and reduce detail levels", |
| 3232 | "-border geometry surround image with a border of color", |
| 3233 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3234 | "-brightness-contrast geometry", |
| 3235 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3236 | "-cdl filename color correct with a color decision list", |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 3237 | "-charcoal geometry simulate a charcoal drawing", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3238 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3239 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3240 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3241 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3242 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3243 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3244 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3245 | "-contrast enhance or reduce the image contrast", |
| 3246 | "-contrast-stretch geometry", |
| 3247 | " improve contrast by `stretching' the intensity range", |
| 3248 | "-convolve coefficients", |
| 3249 | " apply a convolution kernel to the image", |
| 3250 | "-cycle amount cycle the image colormap", |
| 3251 | "-decipher filename convert cipher pixels to plain pixels", |
| 3252 | "-deskew threshold straighten an image", |
| 3253 | "-despeckle reduce the speckles within an image", |
| 3254 | "-distort method args", |
| 3255 | " distort images according to given method ad args", |
| 3256 | "-draw string annotate the image with a graphic primitive", |
| 3257 | "-edge radius apply a filter to detect edges in the image", |
| 3258 | "-encipher filename convert plain pixels to cipher pixels", |
| 3259 | "-emboss radius emboss an image", |
| 3260 | "-enhance apply a digital filter to enhance a noisy image", |
| 3261 | "-equalize perform histogram equalization to an image", |
| 3262 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3263 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3264 | "-extent geometry set the image size", |
| 3265 | "-extract geometry extract area from image", |
| 3266 | "-fft implements the discrete Fourier transform (DFT)", |
| 3267 | "-flip flip image vertically", |
| 3268 | "-floodfill geometry color", |
| 3269 | " floodfill the image with color", |
| 3270 | "-flop flop image horizontally", |
| 3271 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3272 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3273 | " apply function over image values", |
| 3274 | "-gamma value level of gamma correction", |
| 3275 | "-gaussian-blur geometry", |
| 3276 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3277 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3278 | "-identify identify the format and characteristics of the image", |
| 3279 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3280 | "-implode amount implode image pixels about the center", |
| 3281 | "-lat geometry local adaptive thresholding", |
| 3282 | "-layers method optimize, merge, or compare image layers", |
| 3283 | "-level value adjust the level of image contrast", |
| 3284 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3285 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3286 | "-linear-stretch geometry", |
| 3287 | " improve contrast by `stretching with saturation'", |
| 3288 | "-liquid-rescale geometry", |
| 3289 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3290 | "-median geometry apply a median filter to the image", |
glennrp | 30d2dc6 | 2011-06-25 03:17:16 +0000 | [diff] [blame] | 3291 | "-mode geometry make each pixel the 'predominant color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3292 | "-modulate value vary the brightness, saturation, and hue", |
| 3293 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3294 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3295 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3296 | "-motion-blur geometry", |
| 3297 | " simulate motion blur", |
| 3298 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3299 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3300 | "-normalize transform image to span the full range of colors", |
| 3301 | "-opaque color change this color to the fill color", |
| 3302 | "-ordered-dither NxN", |
| 3303 | " add a noise pattern to the image with specific", |
| 3304 | " amplitudes", |
| 3305 | "-paint radius simulate an oil painting", |
| 3306 | "-polaroid angle simulate a Polaroid picture", |
| 3307 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3308 | "-profile filename add, delete, or apply an image profile", |
| 3309 | "-quantize colorspace reduce colors in this colorspace", |
| 3310 | "-radial-blur angle radial blur the image", |
| 3311 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3312 | "-random-threshold low,high", |
| 3313 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3314 | "-region geometry apply options to a portion of the image", |
| 3315 | "-render render vector graphics", |
| 3316 | "-repage geometry size and location of an image canvas", |
| 3317 | "-resample geometry change the resolution of an image", |
| 3318 | "-resize geometry resize the image", |
| 3319 | "-roll geometry roll an image vertically or horizontally", |
| 3320 | "-rotate degrees apply Paeth rotation to the image", |
| 3321 | "-sample geometry scale image with pixel sampling", |
| 3322 | "-scale geometry scale the image", |
| 3323 | "-segment values segment an image", |
| 3324 | "-selective-blur geometry", |
| 3325 | " selectively blur pixels within a contrast threshold", |
| 3326 | "-sepia-tone threshold", |
| 3327 | " simulate a sepia-toned photo", |
| 3328 | "-set property value set an image property", |
| 3329 | "-shade degrees shade the image using a distant light source", |
| 3330 | "-shadow geometry simulate an image shadow", |
| 3331 | "-sharpen geometry sharpen the image", |
| 3332 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3333 | "-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] | 3334 | "-sigmoidal-contrast geometry", |
| 3335 | " increase the contrast without saturating highlights or shadows", |
| 3336 | "-sketch geometry simulate a pencil sketch", |
| 3337 | "-solarize threshold negate all pixels above the threshold level", |
| 3338 | "-sparse-color method args", |
| 3339 | " fill in a image based on a few color points", |
| 3340 | "-splice geometry splice the background color into the image", |
| 3341 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3342 | "-statistic type radius", |
| 3343 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3344 | "-strip strip image of all profiles and comments", |
| 3345 | "-swirl degrees swirl image pixels about the center", |
| 3346 | "-threshold value threshold the image", |
| 3347 | "-thumbnail geometry create a thumbnail of the image", |
| 3348 | "-tile filename tile image when filling a graphic primitive", |
| 3349 | "-tint value tint the image with the fill color", |
| 3350 | "-transform affine transform image", |
| 3351 | "-transparent color make this color transparent within the image", |
| 3352 | "-transpose flip image vertically and rotate 90 degrees", |
| 3353 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3354 | "-trim trim image edges", |
| 3355 | "-type type image type", |
| 3356 | "-unique-colors discard all but one of any pixel color", |
| 3357 | "-unsharp geometry sharpen the image", |
| 3358 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3359 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3360 | "-white-threshold value", |
| 3361 | " force all pixels above the threshold into white", |
| 3362 | (char *) NULL |
| 3363 | }, |
| 3364 | *sequence_operators[]= |
| 3365 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3366 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3367 | "-clut apply a color lookup table to the image", |
| 3368 | "-coalesce merge a sequence of images", |
| 3369 | "-combine combine a sequence of images", |
| 3370 | "-composite composite image", |
| 3371 | "-crop geometry cut out a rectangular region of the image", |
| 3372 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3373 | "-evaluate-sequence operator", |
| 3374 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3375 | "-flatten flatten a sequence of images", |
| 3376 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3377 | "-hald-clut apply a Hald color lookup table to the image", |
| 3378 | "-morph value morph an image sequence", |
| 3379 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3380 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3381 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3382 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3383 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3384 | "-write filename write images to this file", |
| 3385 | (char *) NULL |
| 3386 | }, |
| 3387 | *settings[]= |
| 3388 | { |
| 3389 | "-adjoin join images into a single multi-image file", |
| 3390 | "-affine matrix affine transform matrix", |
| 3391 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3392 | "-antialias remove pixel-aliasing", |
| 3393 | "-authenticate password", |
| 3394 | " decipher image with this password", |
| 3395 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3396 | "-background color background color", |
| 3397 | "-bias value add bias when convolving an image", |
| 3398 | "-black-point-compensation", |
| 3399 | " use black point compensation", |
| 3400 | "-blue-primary point chromaticity blue primary point", |
| 3401 | "-bordercolor color border color", |
| 3402 | "-caption string assign a caption to an image", |
| 3403 | "-channel type apply option to select image channels", |
| 3404 | "-colors value preferred number of colors in the image", |
| 3405 | "-colorspace type alternate image colorspace", |
| 3406 | "-comment string annotate image with comment", |
| 3407 | "-compose operator set image composite operator", |
| 3408 | "-compress type type of pixel compression when writing the image", |
| 3409 | "-define format:option", |
| 3410 | " define one or more image format options", |
| 3411 | "-delay value display the next image after pausing", |
| 3412 | "-density geometry horizontal and vertical density of the image", |
| 3413 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3414 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3415 | "-display server get image or font from this X server", |
| 3416 | "-dispose method layer disposal method", |
| 3417 | "-dither method apply error diffusion to image", |
| 3418 | "-encoding type text encoding type", |
| 3419 | "-endian type endianness (MSB or LSB) of the image", |
| 3420 | "-family name render text with this font family", |
| 3421 | "-fill color color to use when filling a graphic primitive", |
| 3422 | "-filter type use this filter when resizing an image", |
| 3423 | "-font name render text with this font", |
| 3424 | "-format \"string\" output formatted image characteristics", |
| 3425 | "-fuzz distance colors within this distance are considered equal", |
| 3426 | "-gravity type horizontal and vertical text placement", |
| 3427 | "-green-primary point chromaticity green primary point", |
| 3428 | "-intent type type of rendering intent when managing the image color", |
| 3429 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3430 | "-interline-spacing value", |
| 3431 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3432 | "-interpolate method pixel color interpolation method", |
| 3433 | "-interword-spacing value", |
| 3434 | " set the space between two words", |
| 3435 | "-kerning value set the space between two letters", |
| 3436 | "-label string assign a label to an image", |
| 3437 | "-limit type value pixel cache resource limit", |
| 3438 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3439 | "-mask filename associate a mask with the image", |
| 3440 | "-mattecolor color frame color", |
| 3441 | "-monitor monitor progress", |
| 3442 | "-orient type image orientation", |
| 3443 | "-page geometry size and location of an image canvas (setting)", |
| 3444 | "-ping efficiently determine image attributes", |
| 3445 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3446 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3447 | "-preview type image preview type", |
| 3448 | "-quality value JPEG/MIFF/PNG compression level", |
| 3449 | "-quiet suppress all warning messages", |
| 3450 | "-red-primary point chromaticity red primary point", |
| 3451 | "-regard-warnings pay attention to warning messages", |
| 3452 | "-remap filename transform image colors to match this set of colors", |
| 3453 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3454 | "-sampling-factor geometry", |
| 3455 | " horizontal and vertical sampling factor", |
| 3456 | "-scene value image scene number", |
| 3457 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3458 | "-size geometry width and height of image", |
| 3459 | "-stretch type render text with this font stretch", |
| 3460 | "-stroke color graphic primitive stroke color", |
| 3461 | "-strokewidth value graphic primitive stroke width", |
| 3462 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3463 | "-synchronize synchronize image to storage device", |
| 3464 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3465 | "-texture filename name of texture to tile onto the image background", |
| 3466 | "-tile-offset geometry", |
| 3467 | " tile offset", |
| 3468 | "-treedepth value color tree depth", |
| 3469 | "-transparent-color color", |
| 3470 | " transparent color", |
| 3471 | "-undercolor color annotation bounding box color", |
| 3472 | "-units type the units of image resolution", |
| 3473 | "-verbose print detailed information about the image", |
| 3474 | "-view FlashPix viewing transforms", |
| 3475 | "-virtual-pixel method", |
| 3476 | " virtual pixel access method", |
| 3477 | "-weight type render text with this font weight", |
| 3478 | "-white-point point chromaticity white point", |
| 3479 | (char *) NULL |
| 3480 | }, |
| 3481 | *stack_operators[]= |
| 3482 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3483 | "-delete indexes delete the image from the image sequence", |
| 3484 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3485 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3486 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3487 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3488 | "-swap indexes swap two images in the image sequence", |
| 3489 | (char *) NULL |
| 3490 | }; |
| 3491 | |
| 3492 | const char |
| 3493 | **p; |
| 3494 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3495 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3496 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3497 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3498 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3499 | GetClientName()); |
| 3500 | (void) printf("\nImage Settings:\n"); |
| 3501 | for (p=settings; *p != (char *) NULL; p++) |
| 3502 | (void) printf(" %s\n",*p); |
| 3503 | (void) printf("\nImage Operators:\n"); |
| 3504 | for (p=operators; *p != (char *) NULL; p++) |
| 3505 | (void) printf(" %s\n",*p); |
| 3506 | (void) printf("\nImage Sequence Operators:\n"); |
| 3507 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3508 | (void) printf(" %s\n",*p); |
| 3509 | (void) printf("\nImage Stack Operators:\n"); |
| 3510 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3511 | (void) printf(" %s\n",*p); |
| 3512 | (void) printf("\nMiscellaneous Options:\n"); |
| 3513 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3514 | (void) printf(" %s\n",*p); |
| 3515 | (void) printf( |
| 3516 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3517 | (void) printf( |
| 3518 | "number. To specify a particular image format, precede the filename\n"); |
| 3519 | (void) printf( |
| 3520 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3521 | (void) printf( |
| 3522 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3523 | (void) printf("'-' for standard input or output.\n"); |
| 3524 | return(MagickFalse); |
| 3525 | } |
| 3526 | |
| 3527 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3528 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3529 | { |
| 3530 | #define DestroyMogrify() \ |
| 3531 | { \ |
| 3532 | if (format != (char *) NULL) \ |
| 3533 | format=DestroyString(format); \ |
| 3534 | if (path != (char *) NULL) \ |
| 3535 | path=DestroyString(path); \ |
| 3536 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3537 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3538 | argv[i]=DestroyString(argv[i]); \ |
| 3539 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3540 | } |
| 3541 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3542 | { \ |
| 3543 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3544 | option); \ |
| 3545 | DestroyMogrify(); \ |
| 3546 | return(MagickFalse); \ |
| 3547 | } |
| 3548 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3549 | { \ |
| 3550 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3551 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3552 | DestroyMogrify(); \ |
| 3553 | return(MagickFalse); \ |
| 3554 | } |
| 3555 | |
| 3556 | char |
| 3557 | *format, |
| 3558 | *option, |
| 3559 | *path; |
| 3560 | |
| 3561 | Image |
| 3562 | *image; |
| 3563 | |
| 3564 | ImageStack |
| 3565 | image_stack[MaxImageStackDepth+1]; |
| 3566 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3567 | MagickBooleanType |
| 3568 | global_colormap; |
| 3569 | |
| 3570 | MagickBooleanType |
| 3571 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3572 | pend, |
| 3573 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3574 | |
| 3575 | MagickStatusType |
| 3576 | status; |
| 3577 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3578 | register ssize_t |
| 3579 | i; |
| 3580 | |
| 3581 | ssize_t |
| 3582 | j, |
| 3583 | k; |
| 3584 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3585 | /* |
| 3586 | Set defaults. |
| 3587 | */ |
| 3588 | assert(image_info != (ImageInfo *) NULL); |
| 3589 | assert(image_info->signature == MagickSignature); |
| 3590 | if (image_info->debug != MagickFalse) |
| 3591 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3592 | assert(exception != (ExceptionInfo *) NULL); |
| 3593 | if (argc == 2) |
| 3594 | { |
| 3595 | option=argv[1]; |
| 3596 | if ((LocaleCompare("version",option+1) == 0) || |
| 3597 | (LocaleCompare("-version",option+1) == 0)) |
| 3598 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3599 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3600 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 3601 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 3602 | GetMagickCopyright()); |
| 3603 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 3604 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3605 | return(MagickFalse); |
| 3606 | } |
| 3607 | } |
| 3608 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3609 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3610 | format=(char *) NULL; |
| 3611 | path=(char *) NULL; |
| 3612 | global_colormap=MagickFalse; |
| 3613 | k=0; |
| 3614 | j=1; |
| 3615 | NewImageStack(); |
| 3616 | option=(char *) NULL; |
| 3617 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3618 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3619 | status=MagickTrue; |
| 3620 | /* |
| 3621 | Parse command line. |
| 3622 | */ |
| 3623 | ReadCommandlLine(argc,&argv); |
| 3624 | status=ExpandFilenames(&argc,&argv); |
| 3625 | if (status == MagickFalse) |
| 3626 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3627 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3628 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3629 | { |
| 3630 | option=argv[i]; |
| 3631 | if (LocaleCompare(option,"(") == 0) |
| 3632 | { |
| 3633 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3634 | if (k == MaxImageStackDepth) |
| 3635 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3636 | option); |
| 3637 | PushImageStack(); |
| 3638 | continue; |
| 3639 | } |
| 3640 | if (LocaleCompare(option,")") == 0) |
| 3641 | { |
| 3642 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3643 | if (k == 0) |
| 3644 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3645 | PopImageStack(); |
| 3646 | continue; |
| 3647 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3648 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3649 | { |
| 3650 | char |
| 3651 | backup_filename[MaxTextExtent], |
| 3652 | *filename; |
| 3653 | |
| 3654 | Image |
| 3655 | *images; |
| 3656 | |
| 3657 | /* |
| 3658 | Option is a file name: begin by reading image from specified file. |
| 3659 | */ |
| 3660 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3661 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3662 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3663 | filename=argv[++i]; |
| 3664 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 3665 | images=ReadImages(image_info,exception); |
| 3666 | status&=(images != (Image *) NULL) && |
| 3667 | (exception->severity < ErrorException); |
| 3668 | if (images == (Image *) NULL) |
| 3669 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3670 | if (format != (char *) NULL) |
| 3671 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3672 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3673 | if (path != (char *) NULL) |
| 3674 | { |
| 3675 | GetPathComponent(option,TailPath,filename); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3676 | (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3677 | path,*DirectorySeparator,filename); |
| 3678 | } |
| 3679 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3680 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3681 | AppendImageStack(images); |
| 3682 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3683 | if (global_colormap != MagickFalse) |
| 3684 | { |
| 3685 | QuantizeInfo |
| 3686 | *quantize_info; |
| 3687 | |
| 3688 | quantize_info=AcquireQuantizeInfo(image_info); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3689 | (void) RemapImages(quantize_info,images,(Image *) NULL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3690 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3691 | } |
| 3692 | *backup_filename='\0'; |
| 3693 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3694 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3695 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3696 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3697 | i; |
| 3698 | |
| 3699 | /* |
| 3700 | Rename image file as backup. |
| 3701 | */ |
| 3702 | (void) CopyMagickString(backup_filename,image->filename, |
| 3703 | MaxTextExtent); |
| 3704 | for (i=0; i < 6; i++) |
| 3705 | { |
| 3706 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3707 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3708 | break; |
| 3709 | } |
| 3710 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
| 3711 | (rename(image->filename,backup_filename) != 0)) |
| 3712 | *backup_filename='\0'; |
| 3713 | } |
| 3714 | /* |
| 3715 | Write transmogrified image to disk. |
| 3716 | */ |
| 3717 | image_info->synchronize=MagickTrue; |
| 3718 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3719 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
| 3720 | (void) remove(backup_filename); |
| 3721 | RemoveAllImageStack(); |
| 3722 | continue; |
| 3723 | } |
| 3724 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3725 | switch (*(option+1)) |
| 3726 | { |
| 3727 | case 'a': |
| 3728 | { |
| 3729 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3730 | { |
| 3731 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3732 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3733 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3734 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3735 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3736 | break; |
| 3737 | } |
| 3738 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3739 | { |
| 3740 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3741 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3742 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3743 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3744 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3745 | break; |
| 3746 | } |
| 3747 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3748 | { |
| 3749 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3750 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3751 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3752 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3753 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3754 | break; |
| 3755 | } |
| 3756 | if (LocaleCompare("affine",option+1) == 0) |
| 3757 | { |
| 3758 | if (*option == '+') |
| 3759 | break; |
| 3760 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3761 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3762 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3763 | break; |
| 3764 | } |
| 3765 | if (LocaleCompare("alpha",option+1) == 0) |
| 3766 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3767 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3768 | type; |
| 3769 | |
| 3770 | if (*option == '+') |
| 3771 | break; |
| 3772 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3773 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3774 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3775 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3776 | if (type < 0) |
| 3777 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3778 | argv[i]); |
| 3779 | break; |
| 3780 | } |
| 3781 | if (LocaleCompare("annotate",option+1) == 0) |
| 3782 | { |
| 3783 | if (*option == '+') |
| 3784 | break; |
| 3785 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3786 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3787 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3788 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3789 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3790 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3791 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3792 | i++; |
| 3793 | break; |
| 3794 | } |
| 3795 | if (LocaleCompare("antialias",option+1) == 0) |
| 3796 | break; |
| 3797 | if (LocaleCompare("append",option+1) == 0) |
| 3798 | break; |
| 3799 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3800 | { |
| 3801 | if (*option == '+') |
| 3802 | break; |
| 3803 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3804 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3805 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3806 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3807 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3808 | break; |
| 3809 | } |
| 3810 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3811 | { |
| 3812 | if (*option == '+') |
| 3813 | break; |
| 3814 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3815 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3816 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3817 | break; |
| 3818 | } |
| 3819 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3820 | break; |
| 3821 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3822 | break; |
| 3823 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3824 | break; |
| 3825 | if (LocaleCompare("average",option+1) == 0) |
| 3826 | break; |
| 3827 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3828 | } |
| 3829 | case 'b': |
| 3830 | { |
| 3831 | if (LocaleCompare("background",option+1) == 0) |
| 3832 | { |
| 3833 | if (*option == '+') |
| 3834 | break; |
| 3835 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3836 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3837 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3838 | break; |
| 3839 | } |
| 3840 | if (LocaleCompare("bias",option+1) == 0) |
| 3841 | { |
| 3842 | if (*option == '+') |
| 3843 | break; |
| 3844 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3845 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3846 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3847 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3848 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3849 | break; |
| 3850 | } |
| 3851 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 3852 | break; |
| 3853 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 3854 | { |
| 3855 | if (*option == '+') |
| 3856 | break; |
| 3857 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3858 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3859 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3860 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3861 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3862 | break; |
| 3863 | } |
| 3864 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3865 | { |
| 3866 | if (*option == '+') |
| 3867 | break; |
| 3868 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3869 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3870 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3871 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3872 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3873 | break; |
| 3874 | } |
| 3875 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3876 | { |
| 3877 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3878 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3879 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3880 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3881 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3882 | break; |
| 3883 | } |
| 3884 | if (LocaleCompare("blur",option+1) == 0) |
| 3885 | { |
| 3886 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3887 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3888 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3889 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3890 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3891 | break; |
| 3892 | } |
| 3893 | if (LocaleCompare("border",option+1) == 0) |
| 3894 | { |
| 3895 | if (*option == '+') |
| 3896 | break; |
| 3897 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3898 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3899 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3900 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3901 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3902 | break; |
| 3903 | } |
| 3904 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3905 | { |
| 3906 | if (*option == '+') |
| 3907 | break; |
| 3908 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3909 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3910 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3911 | break; |
| 3912 | } |
| 3913 | if (LocaleCompare("box",option+1) == 0) |
| 3914 | { |
| 3915 | if (*option == '+') |
| 3916 | break; |
| 3917 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3918 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3919 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3920 | break; |
| 3921 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3922 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 3923 | { |
| 3924 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3925 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3926 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3927 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3928 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3929 | break; |
| 3930 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3931 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3932 | } |
| 3933 | case 'c': |
| 3934 | { |
| 3935 | if (LocaleCompare("cache",option+1) == 0) |
| 3936 | { |
| 3937 | if (*option == '+') |
| 3938 | break; |
| 3939 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3940 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3941 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3942 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3943 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3944 | break; |
| 3945 | } |
| 3946 | if (LocaleCompare("caption",option+1) == 0) |
| 3947 | { |
| 3948 | if (*option == '+') |
| 3949 | break; |
| 3950 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3951 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3952 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3953 | break; |
| 3954 | } |
| 3955 | if (LocaleCompare("channel",option+1) == 0) |
| 3956 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3957 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3958 | channel; |
| 3959 | |
| 3960 | if (*option == '+') |
| 3961 | break; |
| 3962 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3963 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3964 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3965 | channel=ParseChannelOption(argv[i]); |
| 3966 | if (channel < 0) |
| 3967 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 3968 | argv[i]); |
| 3969 | break; |
| 3970 | } |
| 3971 | if (LocaleCompare("cdl",option+1) == 0) |
| 3972 | { |
| 3973 | if (*option == '+') |
| 3974 | break; |
| 3975 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3976 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3977 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3978 | break; |
| 3979 | } |
| 3980 | if (LocaleCompare("charcoal",option+1) == 0) |
| 3981 | { |
| 3982 | if (*option == '+') |
| 3983 | break; |
| 3984 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3985 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3986 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3987 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3988 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3989 | break; |
| 3990 | } |
| 3991 | if (LocaleCompare("chop",option+1) == 0) |
| 3992 | { |
| 3993 | if (*option == '+') |
| 3994 | break; |
| 3995 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3996 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3997 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3998 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3999 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4000 | break; |
| 4001 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4002 | if (LocaleCompare("clamp",option+1) == 0) |
| 4003 | break; |
| 4004 | if (LocaleCompare("clip",option+1) == 0) |
| 4005 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4006 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4007 | { |
| 4008 | if (*option == '+') |
| 4009 | break; |
| 4010 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4011 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4012 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4013 | break; |
| 4014 | } |
| 4015 | if (LocaleCompare("clut",option+1) == 0) |
| 4016 | break; |
| 4017 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4018 | break; |
| 4019 | if (LocaleCompare("colorize",option+1) == 0) |
| 4020 | { |
| 4021 | if (*option == '+') |
| 4022 | break; |
| 4023 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4024 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4025 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4026 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4027 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4028 | break; |
| 4029 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4030 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4031 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4032 | KernelInfo |
| 4033 | *kernel_info; |
| 4034 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4035 | if (*option == '+') |
| 4036 | break; |
| 4037 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4038 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4039 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4040 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4041 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4042 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4043 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4044 | break; |
| 4045 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4046 | if (LocaleCompare("colors",option+1) == 0) |
| 4047 | { |
| 4048 | if (*option == '+') |
| 4049 | break; |
| 4050 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4051 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4052 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4053 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4054 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4055 | break; |
| 4056 | } |
| 4057 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4058 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4059 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4060 | colorspace; |
| 4061 | |
| 4062 | if (*option == '+') |
| 4063 | break; |
| 4064 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4065 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4066 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4067 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4068 | argv[i]); |
| 4069 | if (colorspace < 0) |
| 4070 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4071 | argv[i]); |
| 4072 | break; |
| 4073 | } |
| 4074 | if (LocaleCompare("combine",option+1) == 0) |
| 4075 | break; |
| 4076 | if (LocaleCompare("comment",option+1) == 0) |
| 4077 | { |
| 4078 | if (*option == '+') |
| 4079 | break; |
| 4080 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4081 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4082 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4083 | break; |
| 4084 | } |
| 4085 | if (LocaleCompare("composite",option+1) == 0) |
| 4086 | break; |
| 4087 | if (LocaleCompare("compress",option+1) == 0) |
| 4088 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4089 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4090 | compress; |
| 4091 | |
| 4092 | if (*option == '+') |
| 4093 | break; |
| 4094 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4095 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4096 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4097 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4098 | argv[i]); |
| 4099 | if (compress < 0) |
| 4100 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4101 | argv[i]); |
| 4102 | break; |
| 4103 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4104 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4105 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4106 | if (LocaleCompare("contrast",option+1) == 0) |
| 4107 | break; |
| 4108 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4109 | { |
| 4110 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4111 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4112 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4113 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4114 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4115 | break; |
| 4116 | } |
| 4117 | if (LocaleCompare("convolve",option+1) == 0) |
| 4118 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4119 | KernelInfo |
| 4120 | *kernel_info; |
| 4121 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4122 | if (*option == '+') |
| 4123 | break; |
| 4124 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4125 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4126 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4127 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4128 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4129 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4130 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4131 | break; |
| 4132 | } |
| 4133 | if (LocaleCompare("crop",option+1) == 0) |
| 4134 | { |
| 4135 | if (*option == '+') |
| 4136 | break; |
| 4137 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4138 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4139 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4140 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4141 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4142 | break; |
| 4143 | } |
| 4144 | if (LocaleCompare("cycle",option+1) == 0) |
| 4145 | { |
| 4146 | if (*option == '+') |
| 4147 | break; |
| 4148 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4149 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4150 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4151 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4152 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4153 | break; |
| 4154 | } |
| 4155 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4156 | } |
| 4157 | case 'd': |
| 4158 | { |
| 4159 | if (LocaleCompare("decipher",option+1) == 0) |
| 4160 | { |
| 4161 | if (*option == '+') |
| 4162 | break; |
| 4163 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4164 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4165 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4166 | break; |
| 4167 | } |
| 4168 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4169 | break; |
| 4170 | if (LocaleCompare("debug",option+1) == 0) |
| 4171 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4172 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4173 | event; |
| 4174 | |
| 4175 | if (*option == '+') |
| 4176 | break; |
| 4177 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4178 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4179 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4180 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4181 | if (event < 0) |
| 4182 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4183 | argv[i]); |
| 4184 | (void) SetLogEventMask(argv[i]); |
| 4185 | break; |
| 4186 | } |
| 4187 | if (LocaleCompare("define",option+1) == 0) |
| 4188 | { |
| 4189 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4190 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4191 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4192 | if (*option == '+') |
| 4193 | { |
| 4194 | const char |
| 4195 | *define; |
| 4196 | |
| 4197 | define=GetImageOption(image_info,argv[i]); |
| 4198 | if (define == (const char *) NULL) |
| 4199 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4200 | break; |
| 4201 | } |
| 4202 | break; |
| 4203 | } |
| 4204 | if (LocaleCompare("delay",option+1) == 0) |
| 4205 | { |
| 4206 | if (*option == '+') |
| 4207 | break; |
| 4208 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4209 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4210 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4211 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4212 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4213 | break; |
| 4214 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4215 | if (LocaleCompare("delete",option+1) == 0) |
| 4216 | { |
| 4217 | if (*option == '+') |
| 4218 | break; |
| 4219 | i++; |
| 4220 | if (i == (ssize_t) (argc-1)) |
| 4221 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4222 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4223 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4224 | break; |
| 4225 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4226 | if (LocaleCompare("density",option+1) == 0) |
| 4227 | { |
| 4228 | if (*option == '+') |
| 4229 | break; |
| 4230 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4231 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4232 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4233 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4234 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4235 | break; |
| 4236 | } |
| 4237 | if (LocaleCompare("depth",option+1) == 0) |
| 4238 | { |
| 4239 | if (*option == '+') |
| 4240 | break; |
| 4241 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4242 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4243 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4244 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4245 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4246 | break; |
| 4247 | } |
| 4248 | if (LocaleCompare("deskew",option+1) == 0) |
| 4249 | { |
| 4250 | if (*option == '+') |
| 4251 | break; |
| 4252 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4253 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4254 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4255 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4256 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4257 | break; |
| 4258 | } |
| 4259 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4260 | break; |
| 4261 | if (LocaleCompare("dft",option+1) == 0) |
| 4262 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4263 | if (LocaleCompare("direction",option+1) == 0) |
| 4264 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4265 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4266 | direction; |
| 4267 | |
| 4268 | if (*option == '+') |
| 4269 | break; |
| 4270 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4271 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4272 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4273 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4274 | argv[i]); |
| 4275 | if (direction < 0) |
| 4276 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4277 | argv[i]); |
| 4278 | break; |
| 4279 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4280 | if (LocaleCompare("display",option+1) == 0) |
| 4281 | { |
| 4282 | if (*option == '+') |
| 4283 | break; |
| 4284 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4285 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4286 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4287 | break; |
| 4288 | } |
| 4289 | if (LocaleCompare("dispose",option+1) == 0) |
| 4290 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4291 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4292 | dispose; |
| 4293 | |
| 4294 | if (*option == '+') |
| 4295 | break; |
| 4296 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4297 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4298 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4299 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4300 | if (dispose < 0) |
| 4301 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4302 | argv[i]); |
| 4303 | break; |
| 4304 | } |
| 4305 | if (LocaleCompare("distort",option+1) == 0) |
| 4306 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4307 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4308 | op; |
| 4309 | |
| 4310 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4311 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4312 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4313 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4314 | if (op < 0) |
| 4315 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4316 | argv[i]); |
| 4317 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4318 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4319 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4320 | break; |
| 4321 | } |
| 4322 | if (LocaleCompare("dither",option+1) == 0) |
| 4323 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4324 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4325 | method; |
| 4326 | |
| 4327 | if (*option == '+') |
| 4328 | break; |
| 4329 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4330 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4331 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4332 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4333 | if (method < 0) |
| 4334 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4335 | argv[i]); |
| 4336 | break; |
| 4337 | } |
| 4338 | if (LocaleCompare("draw",option+1) == 0) |
| 4339 | { |
| 4340 | if (*option == '+') |
| 4341 | break; |
| 4342 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4343 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4344 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4345 | break; |
| 4346 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4347 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4348 | { |
| 4349 | if (*option == '+') |
| 4350 | break; |
| 4351 | i++; |
| 4352 | if (i == (ssize_t) (argc-1)) |
| 4353 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4354 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4355 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4356 | break; |
| 4357 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4358 | if (LocaleCompare("duration",option+1) == 0) |
| 4359 | { |
| 4360 | if (*option == '+') |
| 4361 | break; |
| 4362 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4363 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4364 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4365 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4366 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4367 | break; |
| 4368 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4369 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4370 | } |
| 4371 | case 'e': |
| 4372 | { |
| 4373 | if (LocaleCompare("edge",option+1) == 0) |
| 4374 | { |
| 4375 | if (*option == '+') |
| 4376 | break; |
| 4377 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4378 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4379 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4380 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4381 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4382 | break; |
| 4383 | } |
| 4384 | if (LocaleCompare("emboss",option+1) == 0) |
| 4385 | { |
| 4386 | if (*option == '+') |
| 4387 | break; |
| 4388 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4389 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4390 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4391 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4392 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4393 | break; |
| 4394 | } |
| 4395 | if (LocaleCompare("encipher",option+1) == 0) |
| 4396 | { |
| 4397 | if (*option == '+') |
| 4398 | break; |
| 4399 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4400 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4401 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4402 | break; |
| 4403 | } |
| 4404 | if (LocaleCompare("encoding",option+1) == 0) |
| 4405 | { |
| 4406 | if (*option == '+') |
| 4407 | break; |
| 4408 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4409 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4410 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4411 | break; |
| 4412 | } |
| 4413 | if (LocaleCompare("endian",option+1) == 0) |
| 4414 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4415 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4416 | endian; |
| 4417 | |
| 4418 | if (*option == '+') |
| 4419 | break; |
| 4420 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4421 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4422 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4423 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4424 | if (endian < 0) |
| 4425 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4426 | argv[i]); |
| 4427 | break; |
| 4428 | } |
| 4429 | if (LocaleCompare("enhance",option+1) == 0) |
| 4430 | break; |
| 4431 | if (LocaleCompare("equalize",option+1) == 0) |
| 4432 | break; |
| 4433 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4434 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4435 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4436 | op; |
| 4437 | |
| 4438 | if (*option == '+') |
| 4439 | break; |
| 4440 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4441 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4442 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4443 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4444 | if (op < 0) |
| 4445 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4446 | argv[i]); |
| 4447 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4448 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4449 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4450 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4451 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4452 | break; |
| 4453 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4454 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4455 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4456 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4457 | op; |
| 4458 | |
| 4459 | if (*option == '+') |
| 4460 | break; |
| 4461 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4462 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4463 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4464 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4465 | if (op < 0) |
| 4466 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4467 | argv[i]); |
| 4468 | break; |
| 4469 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4470 | if (LocaleCompare("extent",option+1) == 0) |
| 4471 | { |
| 4472 | if (*option == '+') |
| 4473 | break; |
| 4474 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4475 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4476 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4477 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4478 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4479 | break; |
| 4480 | } |
| 4481 | if (LocaleCompare("extract",option+1) == 0) |
| 4482 | { |
| 4483 | if (*option == '+') |
| 4484 | break; |
| 4485 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4486 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4487 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4488 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4489 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4490 | break; |
| 4491 | } |
| 4492 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4493 | } |
| 4494 | case 'f': |
| 4495 | { |
| 4496 | if (LocaleCompare("family",option+1) == 0) |
| 4497 | { |
| 4498 | if (*option == '+') |
| 4499 | break; |
| 4500 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4501 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4502 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4503 | break; |
| 4504 | } |
| 4505 | if (LocaleCompare("fill",option+1) == 0) |
| 4506 | { |
| 4507 | if (*option == '+') |
| 4508 | break; |
| 4509 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4510 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4511 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4512 | break; |
| 4513 | } |
| 4514 | if (LocaleCompare("filter",option+1) == 0) |
| 4515 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4516 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4517 | filter; |
| 4518 | |
| 4519 | if (*option == '+') |
| 4520 | break; |
| 4521 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4522 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4523 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4524 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4525 | if (filter < 0) |
| 4526 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4527 | argv[i]); |
| 4528 | break; |
| 4529 | } |
| 4530 | if (LocaleCompare("flatten",option+1) == 0) |
| 4531 | break; |
| 4532 | if (LocaleCompare("flip",option+1) == 0) |
| 4533 | break; |
| 4534 | if (LocaleCompare("flop",option+1) == 0) |
| 4535 | break; |
| 4536 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4537 | { |
| 4538 | if (*option == '+') |
| 4539 | break; |
| 4540 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4541 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4542 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4543 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4544 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4545 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4546 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4547 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4548 | break; |
| 4549 | } |
| 4550 | if (LocaleCompare("font",option+1) == 0) |
| 4551 | { |
| 4552 | if (*option == '+') |
| 4553 | break; |
| 4554 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4555 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4556 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4557 | break; |
| 4558 | } |
| 4559 | if (LocaleCompare("format",option+1) == 0) |
| 4560 | { |
| 4561 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4562 | (void) CloneString(&format,(char *) NULL); |
| 4563 | if (*option == '+') |
| 4564 | break; |
| 4565 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4566 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4567 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4568 | (void) CloneString(&format,argv[i]); |
| 4569 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4570 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4571 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4572 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4573 | if (*image_info->magick == '\0') |
| 4574 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4575 | format); |
| 4576 | break; |
| 4577 | } |
| 4578 | if (LocaleCompare("frame",option+1) == 0) |
| 4579 | { |
| 4580 | if (*option == '+') |
| 4581 | break; |
| 4582 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4583 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4584 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4585 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4586 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4587 | break; |
| 4588 | } |
| 4589 | if (LocaleCompare("function",option+1) == 0) |
| 4590 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4591 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4592 | op; |
| 4593 | |
| 4594 | if (*option == '+') |
| 4595 | break; |
| 4596 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4597 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4598 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4599 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4600 | if (op < 0) |
| 4601 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4602 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4603 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4604 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4605 | break; |
| 4606 | } |
| 4607 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4608 | { |
| 4609 | if (*option == '+') |
| 4610 | break; |
| 4611 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4612 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4613 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4614 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4615 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4616 | break; |
| 4617 | } |
| 4618 | if (LocaleCompare("fx",option+1) == 0) |
| 4619 | { |
| 4620 | if (*option == '+') |
| 4621 | break; |
| 4622 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4623 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4624 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4625 | break; |
| 4626 | } |
| 4627 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4628 | } |
| 4629 | case 'g': |
| 4630 | { |
| 4631 | if (LocaleCompare("gamma",option+1) == 0) |
| 4632 | { |
| 4633 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4634 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4635 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4636 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4637 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4638 | break; |
| 4639 | } |
| 4640 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4641 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4642 | { |
| 4643 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4644 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4645 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4646 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4647 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4648 | break; |
| 4649 | } |
| 4650 | if (LocaleCompare("geometry",option+1) == 0) |
| 4651 | { |
| 4652 | if (*option == '+') |
| 4653 | break; |
| 4654 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4655 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4656 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4657 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4658 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4659 | break; |
| 4660 | } |
| 4661 | if (LocaleCompare("gravity",option+1) == 0) |
| 4662 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4663 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4664 | gravity; |
| 4665 | |
| 4666 | if (*option == '+') |
| 4667 | break; |
| 4668 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4669 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4670 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4671 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4672 | if (gravity < 0) |
| 4673 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4674 | argv[i]); |
| 4675 | break; |
| 4676 | } |
| 4677 | if (LocaleCompare("green-primary",option+1) == 0) |
| 4678 | { |
| 4679 | if (*option == '+') |
| 4680 | break; |
| 4681 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4682 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4683 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4684 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4685 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4686 | break; |
| 4687 | } |
| 4688 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4689 | } |
| 4690 | case 'h': |
| 4691 | { |
| 4692 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4693 | break; |
| 4694 | if ((LocaleCompare("help",option+1) == 0) || |
| 4695 | (LocaleCompare("-help",option+1) == 0)) |
| 4696 | return(MogrifyUsage()); |
| 4697 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4698 | } |
| 4699 | case 'i': |
| 4700 | { |
| 4701 | if (LocaleCompare("identify",option+1) == 0) |
| 4702 | break; |
| 4703 | if (LocaleCompare("idft",option+1) == 0) |
| 4704 | break; |
| 4705 | if (LocaleCompare("implode",option+1) == 0) |
| 4706 | { |
| 4707 | if (*option == '+') |
| 4708 | break; |
| 4709 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4710 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4711 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4712 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4713 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4714 | break; |
| 4715 | } |
| 4716 | if (LocaleCompare("intent",option+1) == 0) |
| 4717 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4718 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4719 | intent; |
| 4720 | |
| 4721 | if (*option == '+') |
| 4722 | break; |
| 4723 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4724 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4725 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4726 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4727 | if (intent < 0) |
| 4728 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4729 | argv[i]); |
| 4730 | break; |
| 4731 | } |
| 4732 | if (LocaleCompare("interlace",option+1) == 0) |
| 4733 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4734 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4735 | interlace; |
| 4736 | |
| 4737 | if (*option == '+') |
| 4738 | break; |
| 4739 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4740 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4741 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4742 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4743 | argv[i]); |
| 4744 | if (interlace < 0) |
| 4745 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4746 | argv[i]); |
| 4747 | break; |
| 4748 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4749 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4750 | { |
| 4751 | if (*option == '+') |
| 4752 | break; |
| 4753 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4754 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4755 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4756 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4757 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4758 | break; |
| 4759 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4760 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4761 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4762 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4763 | interpolate; |
| 4764 | |
| 4765 | if (*option == '+') |
| 4766 | break; |
| 4767 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4768 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4769 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4770 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4771 | argv[i]); |
| 4772 | if (interpolate < 0) |
| 4773 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4774 | argv[i]); |
| 4775 | break; |
| 4776 | } |
| 4777 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4778 | { |
| 4779 | if (*option == '+') |
| 4780 | break; |
| 4781 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4782 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4783 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4784 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4785 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4786 | break; |
| 4787 | } |
| 4788 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4789 | } |
| 4790 | case 'k': |
| 4791 | { |
| 4792 | if (LocaleCompare("kerning",option+1) == 0) |
| 4793 | { |
| 4794 | if (*option == '+') |
| 4795 | break; |
| 4796 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4797 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4798 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4799 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4800 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4801 | break; |
| 4802 | } |
| 4803 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4804 | } |
| 4805 | case 'l': |
| 4806 | { |
| 4807 | if (LocaleCompare("label",option+1) == 0) |
| 4808 | { |
| 4809 | if (*option == '+') |
| 4810 | break; |
| 4811 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4812 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4813 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4814 | break; |
| 4815 | } |
| 4816 | if (LocaleCompare("lat",option+1) == 0) |
| 4817 | { |
| 4818 | if (*option == '+') |
| 4819 | break; |
| 4820 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4821 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4822 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4823 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4824 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4825 | } |
| 4826 | if (LocaleCompare("layers",option+1) == 0) |
| 4827 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4828 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4829 | type; |
| 4830 | |
| 4831 | if (*option == '+') |
| 4832 | break; |
| 4833 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4834 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4835 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4836 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4837 | if (type < 0) |
| 4838 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4839 | argv[i]); |
| 4840 | break; |
| 4841 | } |
| 4842 | if (LocaleCompare("level",option+1) == 0) |
| 4843 | { |
| 4844 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4845 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4846 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4847 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4848 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4849 | break; |
| 4850 | } |
| 4851 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4852 | { |
| 4853 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4854 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4855 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4856 | break; |
| 4857 | } |
| 4858 | if (LocaleCompare("linewidth",option+1) == 0) |
| 4859 | { |
| 4860 | if (*option == '+') |
| 4861 | break; |
| 4862 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4863 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4864 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4865 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4866 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4867 | break; |
| 4868 | } |
| 4869 | if (LocaleCompare("limit",option+1) == 0) |
| 4870 | { |
| 4871 | char |
| 4872 | *p; |
| 4873 | |
| 4874 | double |
| 4875 | value; |
| 4876 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4877 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4878 | resource; |
| 4879 | |
| 4880 | if (*option == '+') |
| 4881 | break; |
| 4882 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4883 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4884 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4885 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4886 | argv[i]); |
| 4887 | if (resource < 0) |
| 4888 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4889 | argv[i]); |
| 4890 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4891 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4892 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 4893 | value=InterpretLocaleValue(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4894 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4895 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4896 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4897 | break; |
| 4898 | } |
| 4899 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4900 | { |
| 4901 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4902 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4903 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4904 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4905 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4906 | break; |
| 4907 | } |
| 4908 | if (LocaleCompare("list",option+1) == 0) |
| 4909 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4910 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4911 | list; |
| 4912 | |
| 4913 | if (*option == '+') |
| 4914 | break; |
| 4915 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4916 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4917 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4918 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4919 | if (list < 0) |
| 4920 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4921 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4922 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4923 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4924 | } |
| 4925 | if (LocaleCompare("log",option+1) == 0) |
| 4926 | { |
| 4927 | if (*option == '+') |
| 4928 | break; |
| 4929 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4930 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4931 | (strchr(argv[i],'%') == (char *) NULL)) |
| 4932 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4933 | break; |
| 4934 | } |
| 4935 | if (LocaleCompare("loop",option+1) == 0) |
| 4936 | { |
| 4937 | if (*option == '+') |
| 4938 | break; |
| 4939 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4940 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4941 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4942 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4943 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4944 | break; |
| 4945 | } |
| 4946 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4947 | } |
| 4948 | case 'm': |
| 4949 | { |
| 4950 | if (LocaleCompare("map",option+1) == 0) |
| 4951 | { |
| 4952 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 4953 | if (*option == '+') |
| 4954 | break; |
| 4955 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4956 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4957 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4958 | break; |
| 4959 | } |
| 4960 | if (LocaleCompare("mask",option+1) == 0) |
| 4961 | { |
| 4962 | if (*option == '+') |
| 4963 | break; |
| 4964 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4965 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4966 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4967 | break; |
| 4968 | } |
| 4969 | if (LocaleCompare("matte",option+1) == 0) |
| 4970 | break; |
| 4971 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 4972 | { |
| 4973 | if (*option == '+') |
| 4974 | break; |
| 4975 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4976 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4977 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4978 | break; |
| 4979 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 4980 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 4981 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 4982 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 4983 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4984 | if (LocaleCompare("modulate",option+1) == 0) |
| 4985 | { |
| 4986 | if (*option == '+') |
| 4987 | break; |
| 4988 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4989 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4990 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4991 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4992 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4993 | break; |
| 4994 | } |
| 4995 | if (LocaleCompare("median",option+1) == 0) |
| 4996 | { |
| 4997 | if (*option == '+') |
| 4998 | break; |
| 4999 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5000 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5001 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5002 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5003 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5004 | break; |
| 5005 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5006 | if (LocaleCompare("mode",option+1) == 0) |
| 5007 | { |
| 5008 | if (*option == '+') |
| 5009 | break; |
| 5010 | i++; |
| 5011 | if (i == (ssize_t) argc) |
| 5012 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5013 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5014 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5015 | break; |
| 5016 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5017 | if (LocaleCompare("monitor",option+1) == 0) |
| 5018 | break; |
| 5019 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5020 | break; |
| 5021 | if (LocaleCompare("morph",option+1) == 0) |
| 5022 | { |
| 5023 | if (*option == '+') |
| 5024 | break; |
| 5025 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5026 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5027 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5028 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5029 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5030 | break; |
| 5031 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5032 | if (LocaleCompare("morphology",option+1) == 0) |
| 5033 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5034 | char |
| 5035 | token[MaxTextExtent]; |
| 5036 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5037 | KernelInfo |
| 5038 | *kernel_info; |
| 5039 | |
| 5040 | ssize_t |
| 5041 | op; |
| 5042 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5043 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5044 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5045 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5046 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5047 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5048 | if (op < 0) |
| 5049 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5050 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5051 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5052 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5053 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5054 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5055 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5056 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5057 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5058 | break; |
| 5059 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5060 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5061 | break; |
| 5062 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5063 | { |
| 5064 | if (*option == '+') |
| 5065 | break; |
| 5066 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5067 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5068 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5069 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5070 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5071 | break; |
| 5072 | } |
| 5073 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5074 | } |
| 5075 | case 'n': |
| 5076 | { |
| 5077 | if (LocaleCompare("negate",option+1) == 0) |
| 5078 | break; |
| 5079 | if (LocaleCompare("noise",option+1) == 0) |
| 5080 | { |
| 5081 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5082 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5083 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5084 | if (*option == '+') |
| 5085 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5086 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5087 | noise; |
| 5088 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5089 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5090 | if (noise < 0) |
| 5091 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5092 | argv[i]); |
| 5093 | break; |
| 5094 | } |
| 5095 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5096 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5097 | break; |
| 5098 | } |
| 5099 | if (LocaleCompare("noop",option+1) == 0) |
| 5100 | break; |
| 5101 | if (LocaleCompare("normalize",option+1) == 0) |
| 5102 | break; |
| 5103 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5104 | } |
| 5105 | case 'o': |
| 5106 | { |
| 5107 | if (LocaleCompare("opaque",option+1) == 0) |
| 5108 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5109 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5110 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5111 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5112 | break; |
| 5113 | } |
| 5114 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5115 | { |
| 5116 | if (*option == '+') |
| 5117 | break; |
| 5118 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5119 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5120 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5121 | break; |
| 5122 | } |
| 5123 | if (LocaleCompare("orient",option+1) == 0) |
| 5124 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5125 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5126 | orientation; |
| 5127 | |
| 5128 | orientation=UndefinedOrientation; |
| 5129 | if (*option == '+') |
| 5130 | break; |
| 5131 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5132 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5133 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5134 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5135 | argv[i]); |
| 5136 | if (orientation < 0) |
| 5137 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5138 | argv[i]); |
| 5139 | break; |
| 5140 | } |
| 5141 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5142 | } |
| 5143 | case 'p': |
| 5144 | { |
| 5145 | if (LocaleCompare("page",option+1) == 0) |
| 5146 | { |
| 5147 | if (*option == '+') |
| 5148 | break; |
| 5149 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5150 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5151 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5152 | break; |
| 5153 | } |
| 5154 | if (LocaleCompare("paint",option+1) == 0) |
| 5155 | { |
| 5156 | if (*option == '+') |
| 5157 | break; |
| 5158 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5159 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5160 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5161 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5162 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5163 | break; |
| 5164 | } |
| 5165 | if (LocaleCompare("path",option+1) == 0) |
| 5166 | { |
| 5167 | (void) CloneString(&path,(char *) NULL); |
| 5168 | if (*option == '+') |
| 5169 | break; |
| 5170 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5171 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5172 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5173 | (void) CloneString(&path,argv[i]); |
| 5174 | break; |
| 5175 | } |
| 5176 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5177 | { |
| 5178 | if (*option == '+') |
| 5179 | break; |
| 5180 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5181 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5182 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5183 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5184 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5185 | break; |
| 5186 | } |
| 5187 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5188 | { |
| 5189 | if (*option == '+') |
| 5190 | break; |
| 5191 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5192 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5193 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5194 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5195 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5196 | break; |
| 5197 | } |
| 5198 | if (LocaleCompare("posterize",option+1) == 0) |
| 5199 | { |
| 5200 | if (*option == '+') |
| 5201 | break; |
| 5202 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5203 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5204 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5205 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5206 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5207 | break; |
| 5208 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5209 | if (LocaleCompare("precision",option+1) == 0) |
| 5210 | { |
| 5211 | if (*option == '+') |
| 5212 | break; |
| 5213 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5214 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5215 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5216 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5217 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5218 | break; |
| 5219 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5220 | if (LocaleCompare("print",option+1) == 0) |
| 5221 | { |
| 5222 | if (*option == '+') |
| 5223 | break; |
| 5224 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5225 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5226 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5227 | break; |
| 5228 | } |
| 5229 | if (LocaleCompare("process",option+1) == 0) |
| 5230 | { |
| 5231 | if (*option == '+') |
| 5232 | break; |
| 5233 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5234 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5235 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5236 | break; |
| 5237 | } |
| 5238 | if (LocaleCompare("profile",option+1) == 0) |
| 5239 | { |
| 5240 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5241 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5242 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5243 | break; |
| 5244 | } |
| 5245 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5246 | } |
| 5247 | case 'q': |
| 5248 | { |
| 5249 | if (LocaleCompare("quality",option+1) == 0) |
| 5250 | { |
| 5251 | if (*option == '+') |
| 5252 | break; |
| 5253 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5254 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5255 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5256 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5257 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5258 | break; |
| 5259 | } |
| 5260 | if (LocaleCompare("quantize",option+1) == 0) |
| 5261 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5262 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5263 | colorspace; |
| 5264 | |
| 5265 | if (*option == '+') |
| 5266 | break; |
| 5267 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5268 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5269 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5270 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5271 | argv[i]); |
| 5272 | if (colorspace < 0) |
| 5273 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5274 | argv[i]); |
| 5275 | break; |
| 5276 | } |
| 5277 | if (LocaleCompare("quiet",option+1) == 0) |
| 5278 | break; |
| 5279 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5280 | } |
| 5281 | case 'r': |
| 5282 | { |
| 5283 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5284 | { |
| 5285 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5286 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5287 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5288 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5289 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5290 | break; |
| 5291 | } |
| 5292 | if (LocaleCompare("raise",option+1) == 0) |
| 5293 | { |
| 5294 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5295 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5296 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5297 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5298 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5299 | break; |
| 5300 | } |
| 5301 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5302 | { |
| 5303 | if (*option == '+') |
| 5304 | break; |
| 5305 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5306 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5307 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5308 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5309 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5310 | break; |
| 5311 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5312 | if (LocaleCompare("recolor",option+1) == 0) |
| 5313 | { |
| 5314 | if (*option == '+') |
| 5315 | break; |
| 5316 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5317 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5318 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5319 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5320 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5321 | break; |
| 5322 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5323 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5324 | { |
| 5325 | if (*option == '+') |
| 5326 | break; |
| 5327 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5328 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5329 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5330 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5331 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5332 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5333 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5334 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5335 | if (LocaleCompare("region",option+1) == 0) |
| 5336 | { |
| 5337 | if (*option == '+') |
| 5338 | break; |
| 5339 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5340 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5341 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5342 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5343 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5344 | break; |
| 5345 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5346 | if (LocaleCompare("remap",option+1) == 0) |
| 5347 | { |
| 5348 | if (*option == '+') |
| 5349 | break; |
| 5350 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5351 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5352 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5353 | break; |
| 5354 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5355 | if (LocaleCompare("render",option+1) == 0) |
| 5356 | break; |
| 5357 | if (LocaleCompare("repage",option+1) == 0) |
| 5358 | { |
| 5359 | if (*option == '+') |
| 5360 | break; |
| 5361 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5362 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5363 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5364 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5365 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5366 | break; |
| 5367 | } |
| 5368 | if (LocaleCompare("resample",option+1) == 0) |
| 5369 | { |
| 5370 | if (*option == '+') |
| 5371 | break; |
| 5372 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5373 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5374 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5375 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5376 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5377 | break; |
| 5378 | } |
| 5379 | if (LocaleCompare("resize",option+1) == 0) |
| 5380 | { |
| 5381 | if (*option == '+') |
| 5382 | break; |
| 5383 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5384 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5385 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5386 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5387 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5388 | break; |
| 5389 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5390 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5391 | { |
| 5392 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5393 | break; |
| 5394 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5395 | if (LocaleCompare("reverse",option+1) == 0) |
| 5396 | break; |
| 5397 | if (LocaleCompare("roll",option+1) == 0) |
| 5398 | { |
| 5399 | if (*option == '+') |
| 5400 | break; |
| 5401 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5402 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5403 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5404 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5405 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5406 | break; |
| 5407 | } |
| 5408 | if (LocaleCompare("rotate",option+1) == 0) |
| 5409 | { |
| 5410 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5411 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5412 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5413 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5414 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5415 | break; |
| 5416 | } |
| 5417 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5418 | } |
| 5419 | case 's': |
| 5420 | { |
| 5421 | if (LocaleCompare("sample",option+1) == 0) |
| 5422 | { |
| 5423 | if (*option == '+') |
| 5424 | break; |
| 5425 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5426 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5427 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5428 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5429 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5430 | break; |
| 5431 | } |
| 5432 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5433 | { |
| 5434 | if (*option == '+') |
| 5435 | break; |
| 5436 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5437 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5438 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5439 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5440 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5441 | break; |
| 5442 | } |
| 5443 | if (LocaleCompare("scale",option+1) == 0) |
| 5444 | { |
| 5445 | if (*option == '+') |
| 5446 | break; |
| 5447 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5448 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5449 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5450 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5451 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5452 | break; |
| 5453 | } |
| 5454 | if (LocaleCompare("scene",option+1) == 0) |
| 5455 | { |
| 5456 | if (*option == '+') |
| 5457 | break; |
| 5458 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5459 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5460 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5461 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5462 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5463 | break; |
| 5464 | } |
| 5465 | if (LocaleCompare("seed",option+1) == 0) |
| 5466 | { |
| 5467 | if (*option == '+') |
| 5468 | break; |
| 5469 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5470 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5471 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5472 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5473 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5474 | break; |
| 5475 | } |
| 5476 | if (LocaleCompare("segment",option+1) == 0) |
| 5477 | { |
| 5478 | if (*option == '+') |
| 5479 | break; |
| 5480 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5481 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5482 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5483 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5484 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5485 | break; |
| 5486 | } |
| 5487 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5488 | { |
| 5489 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5490 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5491 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5492 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5493 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5494 | break; |
| 5495 | } |
| 5496 | if (LocaleCompare("separate",option+1) == 0) |
| 5497 | break; |
| 5498 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5499 | { |
| 5500 | if (*option == '+') |
| 5501 | break; |
| 5502 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5503 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5504 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5505 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5506 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5507 | break; |
| 5508 | } |
| 5509 | if (LocaleCompare("set",option+1) == 0) |
| 5510 | { |
| 5511 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5512 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5513 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5514 | if (*option == '+') |
| 5515 | break; |
| 5516 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5517 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5518 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5519 | break; |
| 5520 | } |
| 5521 | if (LocaleCompare("shade",option+1) == 0) |
| 5522 | { |
| 5523 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5524 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5525 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5526 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5527 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5528 | break; |
| 5529 | } |
| 5530 | if (LocaleCompare("shadow",option+1) == 0) |
| 5531 | { |
| 5532 | if (*option == '+') |
| 5533 | break; |
| 5534 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5535 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5536 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5537 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5538 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5539 | break; |
| 5540 | } |
| 5541 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5542 | { |
| 5543 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5544 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5545 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5546 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5547 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5548 | break; |
| 5549 | } |
| 5550 | if (LocaleCompare("shave",option+1) == 0) |
| 5551 | { |
| 5552 | if (*option == '+') |
| 5553 | break; |
| 5554 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5555 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5556 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5557 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5558 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5559 | break; |
| 5560 | } |
| 5561 | if (LocaleCompare("shear",option+1) == 0) |
| 5562 | { |
| 5563 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5564 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5565 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5566 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5567 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5568 | break; |
| 5569 | } |
| 5570 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5571 | { |
| 5572 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5573 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5574 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5575 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5576 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5577 | break; |
| 5578 | } |
| 5579 | if (LocaleCompare("size",option+1) == 0) |
| 5580 | { |
| 5581 | if (*option == '+') |
| 5582 | break; |
| 5583 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5584 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5585 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5586 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5587 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5588 | break; |
| 5589 | } |
| 5590 | if (LocaleCompare("sketch",option+1) == 0) |
| 5591 | { |
| 5592 | if (*option == '+') |
| 5593 | break; |
| 5594 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5595 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5596 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5597 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5598 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5599 | break; |
| 5600 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5601 | if (LocaleCompare("smush",option+1) == 0) |
| 5602 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5603 | i++; |
| 5604 | if (i == (ssize_t) argc) |
| 5605 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5606 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5607 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5608 | i++; |
| 5609 | break; |
| 5610 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5611 | if (LocaleCompare("solarize",option+1) == 0) |
| 5612 | { |
| 5613 | if (*option == '+') |
| 5614 | break; |
| 5615 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5616 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5617 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5618 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5619 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5620 | break; |
| 5621 | } |
| 5622 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5623 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5624 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5625 | op; |
| 5626 | |
| 5627 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5628 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5629 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5630 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5631 | if (op < 0) |
| 5632 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5633 | argv[i]); |
| 5634 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5635 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5636 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5637 | break; |
| 5638 | } |
| 5639 | if (LocaleCompare("spread",option+1) == 0) |
| 5640 | { |
| 5641 | if (*option == '+') |
| 5642 | break; |
| 5643 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5644 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5645 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5646 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5647 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5648 | break; |
| 5649 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5650 | if (LocaleCompare("statistic",option+1) == 0) |
| 5651 | { |
| 5652 | ssize_t |
| 5653 | op; |
| 5654 | |
| 5655 | if (*option == '+') |
| 5656 | break; |
| 5657 | i++; |
| 5658 | if (i == (ssize_t) argc) |
| 5659 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5660 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5661 | if (op < 0) |
| 5662 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5663 | argv[i]); |
| 5664 | i++; |
| 5665 | if (i == (ssize_t) (argc-1)) |
| 5666 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5667 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5668 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5669 | break; |
| 5670 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5671 | if (LocaleCompare("stretch",option+1) == 0) |
| 5672 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5673 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5674 | stretch; |
| 5675 | |
| 5676 | if (*option == '+') |
| 5677 | break; |
| 5678 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5679 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5680 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5681 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5682 | if (stretch < 0) |
| 5683 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5684 | argv[i]); |
| 5685 | break; |
| 5686 | } |
| 5687 | if (LocaleCompare("strip",option+1) == 0) |
| 5688 | break; |
| 5689 | if (LocaleCompare("stroke",option+1) == 0) |
| 5690 | { |
| 5691 | if (*option == '+') |
| 5692 | break; |
| 5693 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5694 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5695 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5696 | break; |
| 5697 | } |
| 5698 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5699 | { |
| 5700 | if (*option == '+') |
| 5701 | break; |
| 5702 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5703 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5704 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5705 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5706 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5707 | break; |
| 5708 | } |
| 5709 | if (LocaleCompare("style",option+1) == 0) |
| 5710 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5711 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5712 | style; |
| 5713 | |
| 5714 | if (*option == '+') |
| 5715 | break; |
| 5716 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5717 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5718 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5719 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5720 | if (style < 0) |
| 5721 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5722 | argv[i]); |
| 5723 | break; |
| 5724 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5725 | if (LocaleCompare("swap",option+1) == 0) |
| 5726 | { |
| 5727 | if (*option == '+') |
| 5728 | break; |
| 5729 | i++; |
| 5730 | if (i == (ssize_t) (argc-1)) |
| 5731 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5732 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5733 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5734 | break; |
| 5735 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5736 | if (LocaleCompare("swirl",option+1) == 0) |
| 5737 | { |
| 5738 | if (*option == '+') |
| 5739 | break; |
| 5740 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5741 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5742 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5743 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5744 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5745 | break; |
| 5746 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5747 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5748 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5749 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5750 | } |
| 5751 | case 't': |
| 5752 | { |
| 5753 | if (LocaleCompare("taint",option+1) == 0) |
| 5754 | break; |
| 5755 | if (LocaleCompare("texture",option+1) == 0) |
| 5756 | { |
| 5757 | if (*option == '+') |
| 5758 | break; |
| 5759 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5760 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5761 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5762 | break; |
| 5763 | } |
| 5764 | if (LocaleCompare("tile",option+1) == 0) |
| 5765 | { |
| 5766 | if (*option == '+') |
| 5767 | break; |
| 5768 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5769 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5770 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5771 | break; |
| 5772 | } |
| 5773 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5774 | { |
| 5775 | if (*option == '+') |
| 5776 | break; |
| 5777 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5778 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5779 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5780 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5781 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5782 | break; |
| 5783 | } |
| 5784 | if (LocaleCompare("tint",option+1) == 0) |
| 5785 | { |
| 5786 | if (*option == '+') |
| 5787 | break; |
| 5788 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5789 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5790 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5791 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5792 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5793 | break; |
| 5794 | } |
| 5795 | if (LocaleCompare("transform",option+1) == 0) |
| 5796 | break; |
| 5797 | if (LocaleCompare("transpose",option+1) == 0) |
| 5798 | break; |
| 5799 | if (LocaleCompare("transverse",option+1) == 0) |
| 5800 | break; |
| 5801 | if (LocaleCompare("threshold",option+1) == 0) |
| 5802 | { |
| 5803 | if (*option == '+') |
| 5804 | break; |
| 5805 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5806 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5807 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5808 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5809 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5810 | break; |
| 5811 | } |
| 5812 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5813 | { |
| 5814 | if (*option == '+') |
| 5815 | break; |
| 5816 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5817 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5818 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5819 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5820 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5821 | break; |
| 5822 | } |
| 5823 | if (LocaleCompare("transparent",option+1) == 0) |
| 5824 | { |
| 5825 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5826 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5827 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5828 | break; |
| 5829 | } |
| 5830 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 5831 | { |
| 5832 | if (*option == '+') |
| 5833 | break; |
| 5834 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5835 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5836 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5837 | break; |
| 5838 | } |
| 5839 | if (LocaleCompare("treedepth",option+1) == 0) |
| 5840 | { |
| 5841 | if (*option == '+') |
| 5842 | break; |
| 5843 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5844 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5845 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5846 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5847 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5848 | break; |
| 5849 | } |
| 5850 | if (LocaleCompare("trim",option+1) == 0) |
| 5851 | break; |
| 5852 | if (LocaleCompare("type",option+1) == 0) |
| 5853 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5854 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5855 | type; |
| 5856 | |
| 5857 | if (*option == '+') |
| 5858 | break; |
| 5859 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5860 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5861 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5862 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5863 | if (type < 0) |
| 5864 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5865 | argv[i]); |
| 5866 | break; |
| 5867 | } |
| 5868 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5869 | } |
| 5870 | case 'u': |
| 5871 | { |
| 5872 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5873 | { |
| 5874 | if (*option == '+') |
| 5875 | break; |
| 5876 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5877 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5878 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5879 | break; |
| 5880 | } |
| 5881 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5882 | break; |
| 5883 | if (LocaleCompare("units",option+1) == 0) |
| 5884 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5885 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5886 | units; |
| 5887 | |
| 5888 | if (*option == '+') |
| 5889 | break; |
| 5890 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5891 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5892 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5893 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5894 | argv[i]); |
| 5895 | if (units < 0) |
| 5896 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5897 | argv[i]); |
| 5898 | break; |
| 5899 | } |
| 5900 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5901 | { |
| 5902 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5903 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5904 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5905 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5906 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5907 | break; |
| 5908 | } |
| 5909 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5910 | } |
| 5911 | case 'v': |
| 5912 | { |
| 5913 | if (LocaleCompare("verbose",option+1) == 0) |
| 5914 | { |
| 5915 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 5916 | break; |
| 5917 | } |
| 5918 | if ((LocaleCompare("version",option+1) == 0) || |
| 5919 | (LocaleCompare("-version",option+1) == 0)) |
| 5920 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 5921 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5922 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 5923 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 5924 | GetMagickCopyright()); |
| 5925 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 5926 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5927 | break; |
| 5928 | } |
| 5929 | if (LocaleCompare("view",option+1) == 0) |
| 5930 | { |
| 5931 | if (*option == '+') |
| 5932 | break; |
| 5933 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5934 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5935 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5936 | break; |
| 5937 | } |
| 5938 | if (LocaleCompare("vignette",option+1) == 0) |
| 5939 | { |
| 5940 | if (*option == '+') |
| 5941 | break; |
| 5942 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5943 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5944 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5945 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5946 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5947 | break; |
| 5948 | } |
| 5949 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 5950 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5951 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5952 | method; |
| 5953 | |
| 5954 | if (*option == '+') |
| 5955 | break; |
| 5956 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5957 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5958 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5959 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5960 | argv[i]); |
| 5961 | if (method < 0) |
| 5962 | ThrowMogrifyException(OptionError, |
| 5963 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 5964 | break; |
| 5965 | } |
| 5966 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5967 | } |
| 5968 | case 'w': |
| 5969 | { |
| 5970 | if (LocaleCompare("wave",option+1) == 0) |
| 5971 | { |
| 5972 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5973 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5974 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5975 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5976 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5977 | break; |
| 5978 | } |
| 5979 | if (LocaleCompare("weight",option+1) == 0) |
| 5980 | { |
| 5981 | if (*option == '+') |
| 5982 | break; |
| 5983 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5984 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5985 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5986 | break; |
| 5987 | } |
| 5988 | if (LocaleCompare("white-point",option+1) == 0) |
| 5989 | { |
| 5990 | if (*option == '+') |
| 5991 | break; |
| 5992 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5993 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5994 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5995 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5996 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5997 | break; |
| 5998 | } |
| 5999 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6000 | { |
| 6001 | if (*option == '+') |
| 6002 | break; |
| 6003 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6004 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6005 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6006 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6007 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6008 | break; |
| 6009 | } |
| 6010 | if (LocaleCompare("write",option+1) == 0) |
| 6011 | { |
| 6012 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6013 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6014 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6015 | break; |
| 6016 | } |
| 6017 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6018 | } |
| 6019 | case '?': |
| 6020 | break; |
| 6021 | default: |
| 6022 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6023 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6024 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 6025 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6026 | if (fire != MagickFalse) |
| 6027 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6028 | } |
| 6029 | if (k != 0) |
| 6030 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6031 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6032 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6033 | DestroyMogrify(); |
| 6034 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6035 | } |
| 6036 | |
| 6037 | /* |
| 6038 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6039 | % % |
| 6040 | % % |
| 6041 | % % |
| 6042 | + M o g r i f y I m a g e I n f o % |
| 6043 | % % |
| 6044 | % % |
| 6045 | % % |
| 6046 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6047 | % |
| 6048 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6049 | % prescribed by command line options. |
| 6050 | % |
| 6051 | % The format of the MogrifyImageInfo method is: |
| 6052 | % |
| 6053 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6054 | % const char **argv,ExceptionInfo *exception) |
| 6055 | % |
| 6056 | % A description of each parameter follows: |
| 6057 | % |
| 6058 | % o image_info: the image info.. |
| 6059 | % |
| 6060 | % o argc: Specifies a pointer to an integer describing the number of |
| 6061 | % elements in the argument vector. |
| 6062 | % |
| 6063 | % o argv: Specifies a pointer to a text array containing the command line |
| 6064 | % arguments. |
| 6065 | % |
| 6066 | % o exception: return any errors or warnings in this structure. |
| 6067 | % |
| 6068 | */ |
| 6069 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6070 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6071 | { |
| 6072 | const char |
| 6073 | *option; |
| 6074 | |
| 6075 | GeometryInfo |
| 6076 | geometry_info; |
| 6077 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6078 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6079 | count; |
| 6080 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6081 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6082 | i; |
| 6083 | |
| 6084 | /* |
| 6085 | Initialize method variables. |
| 6086 | */ |
| 6087 | assert(image_info != (ImageInfo *) NULL); |
| 6088 | assert(image_info->signature == MagickSignature); |
| 6089 | if (image_info->debug != MagickFalse) |
| 6090 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6091 | image_info->filename); |
| 6092 | if (argc < 0) |
| 6093 | return(MagickTrue); |
| 6094 | /* |
| 6095 | Set the image settings. |
| 6096 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6097 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6098 | { |
| 6099 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6100 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6101 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6102 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6103 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6104 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6105 | break; |
| 6106 | switch (*(option+1)) |
| 6107 | { |
| 6108 | case 'a': |
| 6109 | { |
| 6110 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6111 | { |
| 6112 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6113 | break; |
| 6114 | } |
| 6115 | if (LocaleCompare("antialias",option+1) == 0) |
| 6116 | { |
| 6117 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6118 | break; |
| 6119 | } |
| 6120 | if (LocaleCompare("attenuate",option+1) == 0) |
| 6121 | { |
| 6122 | if (*option == '+') |
| 6123 | { |
| 6124 | (void) DeleteImageOption(image_info,option+1); |
| 6125 | break; |
| 6126 | } |
| 6127 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6128 | break; |
| 6129 | } |
| 6130 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6131 | { |
| 6132 | if (*option == '+') |
| 6133 | (void) CloneString(&image_info->authenticate,(char *) NULL); |
| 6134 | else |
| 6135 | (void) CloneString(&image_info->authenticate,argv[i+1]); |
| 6136 | break; |
| 6137 | } |
| 6138 | break; |
| 6139 | } |
| 6140 | case 'b': |
| 6141 | { |
| 6142 | if (LocaleCompare("background",option+1) == 0) |
| 6143 | { |
| 6144 | if (*option == '+') |
| 6145 | { |
| 6146 | (void) DeleteImageOption(image_info,option+1); |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6147 | (void) QueryColorDatabase(MogrifyBackgroundColor, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6148 | &image_info->background_color,exception); |
| 6149 | break; |
| 6150 | } |
| 6151 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6152 | (void) QueryColorDatabase(argv[i+1],&image_info->background_color, |
| 6153 | exception); |
| 6154 | break; |
| 6155 | } |
| 6156 | if (LocaleCompare("bias",option+1) == 0) |
| 6157 | { |
| 6158 | if (*option == '+') |
| 6159 | { |
| 6160 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6161 | break; |
| 6162 | } |
| 6163 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6164 | break; |
| 6165 | } |
| 6166 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6167 | { |
| 6168 | if (*option == '+') |
| 6169 | { |
| 6170 | (void) SetImageOption(image_info,option+1,"false"); |
| 6171 | break; |
| 6172 | } |
| 6173 | (void) SetImageOption(image_info,option+1,"true"); |
| 6174 | break; |
| 6175 | } |
| 6176 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6177 | { |
| 6178 | if (*option == '+') |
| 6179 | { |
| 6180 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6181 | break; |
| 6182 | } |
| 6183 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6184 | break; |
| 6185 | } |
| 6186 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6187 | { |
| 6188 | if (*option == '+') |
| 6189 | { |
| 6190 | (void) DeleteImageOption(image_info,option+1); |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6191 | (void) QueryColorDatabase(MogrifyBorderColor, |
| 6192 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6193 | break; |
| 6194 | } |
| 6195 | (void) QueryColorDatabase(argv[i+1],&image_info->border_color, |
| 6196 | exception); |
| 6197 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6198 | break; |
| 6199 | } |
| 6200 | if (LocaleCompare("box",option+1) == 0) |
| 6201 | { |
| 6202 | if (*option == '+') |
| 6203 | { |
| 6204 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6205 | break; |
| 6206 | } |
| 6207 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6208 | break; |
| 6209 | } |
| 6210 | break; |
| 6211 | } |
| 6212 | case 'c': |
| 6213 | { |
| 6214 | if (LocaleCompare("cache",option+1) == 0) |
| 6215 | { |
| 6216 | MagickSizeType |
| 6217 | limit; |
| 6218 | |
| 6219 | limit=MagickResourceInfinity; |
| 6220 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6221 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6222 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6223 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6224 | break; |
| 6225 | } |
| 6226 | if (LocaleCompare("caption",option+1) == 0) |
| 6227 | { |
| 6228 | if (*option == '+') |
| 6229 | { |
| 6230 | (void) DeleteImageOption(image_info,option+1); |
| 6231 | break; |
| 6232 | } |
| 6233 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6234 | break; |
| 6235 | } |
| 6236 | if (LocaleCompare("channel",option+1) == 0) |
| 6237 | { |
| 6238 | if (*option == '+') |
| 6239 | { |
| 6240 | image_info->channel=DefaultChannels; |
| 6241 | break; |
| 6242 | } |
| 6243 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6244 | break; |
| 6245 | } |
| 6246 | if (LocaleCompare("colors",option+1) == 0) |
| 6247 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6248 | image_info->colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6249 | break; |
| 6250 | } |
| 6251 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6252 | { |
| 6253 | if (*option == '+') |
| 6254 | { |
| 6255 | image_info->colorspace=UndefinedColorspace; |
| 6256 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6257 | break; |
| 6258 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6259 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6260 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6261 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6262 | break; |
| 6263 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6264 | if (LocaleCompare("comment",option+1) == 0) |
| 6265 | { |
| 6266 | if (*option == '+') |
| 6267 | { |
| 6268 | (void) DeleteImageOption(image_info,option+1); |
| 6269 | break; |
| 6270 | } |
| 6271 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6272 | break; |
| 6273 | } |
| 6274 | if (LocaleCompare("compose",option+1) == 0) |
| 6275 | { |
| 6276 | if (*option == '+') |
| 6277 | { |
| 6278 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6279 | break; |
| 6280 | } |
| 6281 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6282 | break; |
| 6283 | } |
| 6284 | if (LocaleCompare("compress",option+1) == 0) |
| 6285 | { |
| 6286 | if (*option == '+') |
| 6287 | { |
| 6288 | image_info->compression=UndefinedCompression; |
| 6289 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6290 | break; |
| 6291 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6292 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6293 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6294 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6295 | break; |
| 6296 | } |
| 6297 | break; |
| 6298 | } |
| 6299 | case 'd': |
| 6300 | { |
| 6301 | if (LocaleCompare("debug",option+1) == 0) |
| 6302 | { |
| 6303 | if (*option == '+') |
| 6304 | (void) SetLogEventMask("none"); |
| 6305 | else |
| 6306 | (void) SetLogEventMask(argv[i+1]); |
| 6307 | image_info->debug=IsEventLogging(); |
| 6308 | break; |
| 6309 | } |
| 6310 | if (LocaleCompare("define",option+1) == 0) |
| 6311 | { |
| 6312 | if (*option == '+') |
| 6313 | { |
| 6314 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6315 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6316 | else |
| 6317 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6318 | break; |
| 6319 | } |
| 6320 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6321 | { |
| 6322 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6323 | exception); |
| 6324 | break; |
| 6325 | } |
| 6326 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6327 | break; |
| 6328 | } |
| 6329 | if (LocaleCompare("delay",option+1) == 0) |
| 6330 | { |
| 6331 | if (*option == '+') |
| 6332 | { |
| 6333 | (void) SetImageOption(image_info,option+1,"0"); |
| 6334 | break; |
| 6335 | } |
| 6336 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6337 | break; |
| 6338 | } |
| 6339 | if (LocaleCompare("density",option+1) == 0) |
| 6340 | { |
| 6341 | /* |
| 6342 | Set image density. |
| 6343 | */ |
| 6344 | if (*option == '+') |
| 6345 | { |
| 6346 | if (image_info->density != (char *) NULL) |
| 6347 | image_info->density=DestroyString(image_info->density); |
| 6348 | (void) SetImageOption(image_info,option+1,"72"); |
| 6349 | break; |
| 6350 | } |
| 6351 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6352 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6353 | break; |
| 6354 | } |
| 6355 | if (LocaleCompare("depth",option+1) == 0) |
| 6356 | { |
| 6357 | if (*option == '+') |
| 6358 | { |
| 6359 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6360 | break; |
| 6361 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6362 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6363 | break; |
| 6364 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6365 | if (LocaleCompare("direction",option+1) == 0) |
| 6366 | { |
| 6367 | if (*option == '+') |
| 6368 | { |
| 6369 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6370 | break; |
| 6371 | } |
| 6372 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6373 | break; |
| 6374 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6375 | if (LocaleCompare("display",option+1) == 0) |
| 6376 | { |
| 6377 | if (*option == '+') |
| 6378 | { |
| 6379 | if (image_info->server_name != (char *) NULL) |
| 6380 | image_info->server_name=DestroyString( |
| 6381 | image_info->server_name); |
| 6382 | break; |
| 6383 | } |
| 6384 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6385 | break; |
| 6386 | } |
| 6387 | if (LocaleCompare("dispose",option+1) == 0) |
| 6388 | { |
| 6389 | if (*option == '+') |
| 6390 | { |
| 6391 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6392 | break; |
| 6393 | } |
| 6394 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6395 | break; |
| 6396 | } |
| 6397 | if (LocaleCompare("dither",option+1) == 0) |
| 6398 | { |
| 6399 | if (*option == '+') |
| 6400 | { |
| 6401 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6402 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6403 | break; |
| 6404 | } |
| 6405 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6406 | image_info->dither=MagickTrue; |
| 6407 | break; |
| 6408 | } |
| 6409 | break; |
| 6410 | } |
| 6411 | case 'e': |
| 6412 | { |
| 6413 | if (LocaleCompare("encoding",option+1) == 0) |
| 6414 | { |
| 6415 | if (*option == '+') |
| 6416 | { |
| 6417 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6418 | break; |
| 6419 | } |
| 6420 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6421 | break; |
| 6422 | } |
| 6423 | if (LocaleCompare("endian",option+1) == 0) |
| 6424 | { |
| 6425 | if (*option == '+') |
| 6426 | { |
| 6427 | image_info->endian=UndefinedEndian; |
| 6428 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6429 | break; |
| 6430 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6431 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6432 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6433 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6434 | break; |
| 6435 | } |
| 6436 | if (LocaleCompare("extract",option+1) == 0) |
| 6437 | { |
| 6438 | /* |
| 6439 | Set image extract geometry. |
| 6440 | */ |
| 6441 | if (*option == '+') |
| 6442 | { |
| 6443 | if (image_info->extract != (char *) NULL) |
| 6444 | image_info->extract=DestroyString(image_info->extract); |
| 6445 | break; |
| 6446 | } |
| 6447 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6448 | break; |
| 6449 | } |
| 6450 | break; |
| 6451 | } |
| 6452 | case 'f': |
| 6453 | { |
| 6454 | if (LocaleCompare("fill",option+1) == 0) |
| 6455 | { |
| 6456 | if (*option == '+') |
| 6457 | { |
| 6458 | (void) SetImageOption(image_info,option+1,"none"); |
| 6459 | break; |
| 6460 | } |
| 6461 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6462 | break; |
| 6463 | } |
| 6464 | if (LocaleCompare("filter",option+1) == 0) |
| 6465 | { |
| 6466 | if (*option == '+') |
| 6467 | { |
| 6468 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6469 | break; |
| 6470 | } |
| 6471 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6472 | break; |
| 6473 | } |
| 6474 | if (LocaleCompare("font",option+1) == 0) |
| 6475 | { |
| 6476 | if (*option == '+') |
| 6477 | { |
| 6478 | if (image_info->font != (char *) NULL) |
| 6479 | image_info->font=DestroyString(image_info->font); |
| 6480 | break; |
| 6481 | } |
| 6482 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6483 | break; |
| 6484 | } |
| 6485 | if (LocaleCompare("format",option+1) == 0) |
| 6486 | { |
| 6487 | register const char |
| 6488 | *q; |
| 6489 | |
| 6490 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6491 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6492 | image_info->ping=MagickFalse; |
| 6493 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6494 | break; |
| 6495 | } |
| 6496 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6497 | { |
| 6498 | if (*option == '+') |
| 6499 | { |
| 6500 | image_info->fuzz=0.0; |
| 6501 | (void) SetImageOption(image_info,option+1,"0"); |
| 6502 | break; |
| 6503 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6504 | image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6505 | 1.0); |
| 6506 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6507 | break; |
| 6508 | } |
| 6509 | break; |
| 6510 | } |
| 6511 | case 'g': |
| 6512 | { |
| 6513 | if (LocaleCompare("gravity",option+1) == 0) |
| 6514 | { |
| 6515 | if (*option == '+') |
| 6516 | { |
| 6517 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6518 | break; |
| 6519 | } |
| 6520 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6521 | break; |
| 6522 | } |
| 6523 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6524 | { |
| 6525 | if (*option == '+') |
| 6526 | { |
| 6527 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6528 | break; |
| 6529 | } |
| 6530 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6531 | break; |
| 6532 | } |
| 6533 | break; |
| 6534 | } |
| 6535 | case 'i': |
| 6536 | { |
| 6537 | if (LocaleCompare("intent",option+1) == 0) |
| 6538 | { |
| 6539 | if (*option == '+') |
| 6540 | { |
| 6541 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6542 | break; |
| 6543 | } |
| 6544 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6545 | break; |
| 6546 | } |
| 6547 | if (LocaleCompare("interlace",option+1) == 0) |
| 6548 | { |
| 6549 | if (*option == '+') |
| 6550 | { |
| 6551 | image_info->interlace=UndefinedInterlace; |
| 6552 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6553 | break; |
| 6554 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6555 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6556 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6557 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6558 | break; |
| 6559 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6560 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6561 | { |
| 6562 | if (*option == '+') |
| 6563 | { |
| 6564 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6565 | break; |
| 6566 | } |
| 6567 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6568 | break; |
| 6569 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6570 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6571 | { |
| 6572 | if (*option == '+') |
| 6573 | { |
| 6574 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6575 | break; |
| 6576 | } |
| 6577 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6578 | break; |
| 6579 | } |
| 6580 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6581 | { |
| 6582 | if (*option == '+') |
| 6583 | { |
| 6584 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6585 | break; |
| 6586 | } |
| 6587 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6588 | break; |
| 6589 | } |
| 6590 | break; |
| 6591 | } |
| 6592 | case 'k': |
| 6593 | { |
| 6594 | if (LocaleCompare("kerning",option+1) == 0) |
| 6595 | { |
| 6596 | if (*option == '+') |
| 6597 | { |
| 6598 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6599 | break; |
| 6600 | } |
| 6601 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6602 | break; |
| 6603 | } |
| 6604 | break; |
| 6605 | } |
| 6606 | case 'l': |
| 6607 | { |
| 6608 | if (LocaleCompare("label",option+1) == 0) |
| 6609 | { |
| 6610 | if (*option == '+') |
| 6611 | { |
| 6612 | (void) DeleteImageOption(image_info,option+1); |
| 6613 | break; |
| 6614 | } |
| 6615 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6616 | break; |
| 6617 | } |
| 6618 | if (LocaleCompare("limit",option+1) == 0) |
| 6619 | { |
| 6620 | MagickSizeType |
| 6621 | limit; |
| 6622 | |
| 6623 | ResourceType |
| 6624 | type; |
| 6625 | |
| 6626 | if (*option == '+') |
| 6627 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6628 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6629 | MagickFalse,argv[i+1]); |
| 6630 | limit=MagickResourceInfinity; |
| 6631 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6632 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6633 | (void) SetMagickResourceLimit(type,limit); |
| 6634 | break; |
| 6635 | } |
| 6636 | if (LocaleCompare("list",option+1) == 0) |
| 6637 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6638 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6639 | list; |
| 6640 | |
| 6641 | /* |
| 6642 | Display configuration list. |
| 6643 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6644 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6645 | switch (list) |
| 6646 | { |
| 6647 | case MagickCoderOptions: |
| 6648 | { |
| 6649 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6650 | break; |
| 6651 | } |
| 6652 | case MagickColorOptions: |
| 6653 | { |
| 6654 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6655 | break; |
| 6656 | } |
| 6657 | case MagickConfigureOptions: |
| 6658 | { |
| 6659 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6660 | break; |
| 6661 | } |
| 6662 | case MagickDelegateOptions: |
| 6663 | { |
| 6664 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6665 | break; |
| 6666 | } |
| 6667 | case MagickFontOptions: |
| 6668 | { |
| 6669 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6670 | break; |
| 6671 | } |
| 6672 | case MagickFormatOptions: |
| 6673 | { |
| 6674 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6675 | break; |
| 6676 | } |
| 6677 | case MagickLocaleOptions: |
| 6678 | { |
| 6679 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6680 | break; |
| 6681 | } |
| 6682 | case MagickLogOptions: |
| 6683 | { |
| 6684 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6685 | break; |
| 6686 | } |
| 6687 | case MagickMagicOptions: |
| 6688 | { |
| 6689 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6690 | break; |
| 6691 | } |
| 6692 | case MagickMimeOptions: |
| 6693 | { |
| 6694 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6695 | break; |
| 6696 | } |
| 6697 | case MagickModuleOptions: |
| 6698 | { |
| 6699 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6700 | break; |
| 6701 | } |
| 6702 | case MagickPolicyOptions: |
| 6703 | { |
| 6704 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6705 | break; |
| 6706 | } |
| 6707 | case MagickResourceOptions: |
| 6708 | { |
| 6709 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6710 | break; |
| 6711 | } |
| 6712 | case MagickThresholdOptions: |
| 6713 | { |
| 6714 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6715 | break; |
| 6716 | } |
| 6717 | default: |
| 6718 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6719 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6720 | exception); |
| 6721 | break; |
| 6722 | } |
| 6723 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6724 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6725 | } |
| 6726 | if (LocaleCompare("log",option+1) == 0) |
| 6727 | { |
| 6728 | if (*option == '+') |
| 6729 | break; |
| 6730 | (void) SetLogFormat(argv[i+1]); |
| 6731 | break; |
| 6732 | } |
| 6733 | if (LocaleCompare("loop",option+1) == 0) |
| 6734 | { |
| 6735 | if (*option == '+') |
| 6736 | { |
| 6737 | (void) SetImageOption(image_info,option+1,"0"); |
| 6738 | break; |
| 6739 | } |
| 6740 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6741 | break; |
| 6742 | } |
| 6743 | break; |
| 6744 | } |
| 6745 | case 'm': |
| 6746 | { |
| 6747 | if (LocaleCompare("matte",option+1) == 0) |
| 6748 | { |
| 6749 | if (*option == '+') |
| 6750 | { |
| 6751 | (void) SetImageOption(image_info,option+1,"false"); |
| 6752 | break; |
| 6753 | } |
| 6754 | (void) SetImageOption(image_info,option+1,"true"); |
| 6755 | break; |
| 6756 | } |
| 6757 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6758 | { |
| 6759 | if (*option == '+') |
| 6760 | { |
| 6761 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6762 | (void) QueryColorDatabase(MogrifyMatteColor, |
| 6763 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6764 | break; |
| 6765 | } |
| 6766 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6767 | (void) QueryColorDatabase(argv[i+1],&image_info->matte_color, |
| 6768 | exception); |
| 6769 | break; |
| 6770 | } |
| 6771 | if (LocaleCompare("monitor",option+1) == 0) |
| 6772 | { |
| 6773 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6774 | (void *) NULL); |
| 6775 | break; |
| 6776 | } |
| 6777 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6778 | { |
| 6779 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6780 | break; |
| 6781 | } |
| 6782 | break; |
| 6783 | } |
| 6784 | case 'o': |
| 6785 | { |
| 6786 | if (LocaleCompare("orient",option+1) == 0) |
| 6787 | { |
| 6788 | if (*option == '+') |
| 6789 | { |
| 6790 | image_info->orientation=UndefinedOrientation; |
| 6791 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6792 | break; |
| 6793 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6794 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6795 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6796 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6797 | break; |
| 6798 | } |
| 6799 | } |
| 6800 | case 'p': |
| 6801 | { |
| 6802 | if (LocaleCompare("page",option+1) == 0) |
| 6803 | { |
| 6804 | char |
| 6805 | *canonical_page, |
| 6806 | page[MaxTextExtent]; |
| 6807 | |
| 6808 | const char |
| 6809 | *image_option; |
| 6810 | |
| 6811 | MagickStatusType |
| 6812 | flags; |
| 6813 | |
| 6814 | RectangleInfo |
| 6815 | geometry; |
| 6816 | |
| 6817 | if (*option == '+') |
| 6818 | { |
| 6819 | (void) DeleteImageOption(image_info,option+1); |
| 6820 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6821 | break; |
| 6822 | } |
| 6823 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6824 | image_option=GetImageOption(image_info,"page"); |
| 6825 | if (image_option != (const char *) NULL) |
| 6826 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6827 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6828 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6829 | canonical_page=DestroyString(canonical_page); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6830 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6831 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6832 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6833 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6834 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6835 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6836 | (void) SetImageOption(image_info,option+1,page); |
| 6837 | (void) CloneString(&image_info->page,page); |
| 6838 | break; |
| 6839 | } |
| 6840 | if (LocaleCompare("pen",option+1) == 0) |
| 6841 | { |
| 6842 | if (*option == '+') |
| 6843 | { |
| 6844 | (void) SetImageOption(image_info,option+1,"none"); |
| 6845 | break; |
| 6846 | } |
| 6847 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6848 | break; |
| 6849 | } |
| 6850 | if (LocaleCompare("ping",option+1) == 0) |
| 6851 | { |
| 6852 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6853 | break; |
| 6854 | } |
| 6855 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6856 | { |
| 6857 | if (*option == '+') |
| 6858 | geometry_info.rho=0.0; |
| 6859 | else |
| 6860 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6861 | image_info->pointsize=geometry_info.rho; |
| 6862 | break; |
| 6863 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6864 | if (LocaleCompare("precision",option+1) == 0) |
| 6865 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6866 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6867 | break; |
| 6868 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6869 | if (LocaleCompare("preview",option+1) == 0) |
| 6870 | { |
| 6871 | /* |
| 6872 | Preview image. |
| 6873 | */ |
| 6874 | if (*option == '+') |
| 6875 | { |
| 6876 | image_info->preview_type=UndefinedPreview; |
| 6877 | break; |
| 6878 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6879 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6880 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6881 | break; |
| 6882 | } |
| 6883 | break; |
| 6884 | } |
| 6885 | case 'q': |
| 6886 | { |
| 6887 | if (LocaleCompare("quality",option+1) == 0) |
| 6888 | { |
| 6889 | /* |
| 6890 | Set image compression quality. |
| 6891 | */ |
| 6892 | if (*option == '+') |
| 6893 | { |
| 6894 | image_info->quality=UndefinedCompressionQuality; |
| 6895 | (void) SetImageOption(image_info,option+1,"0"); |
| 6896 | break; |
| 6897 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6898 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6899 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6900 | break; |
| 6901 | } |
| 6902 | if (LocaleCompare("quiet",option+1) == 0) |
| 6903 | { |
| 6904 | static WarningHandler |
| 6905 | warning_handler = (WarningHandler) NULL; |
| 6906 | |
| 6907 | if (*option == '+') |
| 6908 | { |
| 6909 | /* |
| 6910 | Restore error or warning messages. |
| 6911 | */ |
| 6912 | warning_handler=SetWarningHandler(warning_handler); |
| 6913 | break; |
| 6914 | } |
| 6915 | /* |
| 6916 | Suppress error or warning messages. |
| 6917 | */ |
| 6918 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6919 | break; |
| 6920 | } |
| 6921 | break; |
| 6922 | } |
| 6923 | case 'r': |
| 6924 | { |
| 6925 | if (LocaleCompare("red-primary",option+1) == 0) |
| 6926 | { |
| 6927 | if (*option == '+') |
| 6928 | { |
| 6929 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6930 | break; |
| 6931 | } |
| 6932 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6933 | break; |
| 6934 | } |
| 6935 | break; |
| 6936 | } |
| 6937 | case 's': |
| 6938 | { |
| 6939 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 6940 | { |
| 6941 | /* |
| 6942 | Set image sampling factor. |
| 6943 | */ |
| 6944 | if (*option == '+') |
| 6945 | { |
| 6946 | if (image_info->sampling_factor != (char *) NULL) |
| 6947 | image_info->sampling_factor=DestroyString( |
| 6948 | image_info->sampling_factor); |
| 6949 | break; |
| 6950 | } |
| 6951 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 6952 | break; |
| 6953 | } |
| 6954 | if (LocaleCompare("scene",option+1) == 0) |
| 6955 | { |
| 6956 | /* |
| 6957 | Set image scene. |
| 6958 | */ |
| 6959 | if (*option == '+') |
| 6960 | { |
| 6961 | image_info->scene=0; |
| 6962 | (void) SetImageOption(image_info,option+1,"0"); |
| 6963 | break; |
| 6964 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6965 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6966 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6967 | break; |
| 6968 | } |
| 6969 | if (LocaleCompare("seed",option+1) == 0) |
| 6970 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6971 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6972 | seed; |
| 6973 | |
| 6974 | if (*option == '+') |
| 6975 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6976 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6977 | SeedPseudoRandomGenerator(seed); |
| 6978 | break; |
| 6979 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6980 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6981 | SeedPseudoRandomGenerator(seed); |
| 6982 | break; |
| 6983 | } |
| 6984 | if (LocaleCompare("size",option+1) == 0) |
| 6985 | { |
| 6986 | if (*option == '+') |
| 6987 | { |
| 6988 | if (image_info->size != (char *) NULL) |
| 6989 | image_info->size=DestroyString(image_info->size); |
| 6990 | break; |
| 6991 | } |
| 6992 | (void) CloneString(&image_info->size,argv[i+1]); |
| 6993 | break; |
| 6994 | } |
| 6995 | if (LocaleCompare("stroke",option+1) == 0) |
| 6996 | { |
| 6997 | if (*option == '+') |
| 6998 | { |
| 6999 | (void) SetImageOption(image_info,option+1,"none"); |
| 7000 | break; |
| 7001 | } |
| 7002 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7003 | break; |
| 7004 | } |
| 7005 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7006 | { |
| 7007 | if (*option == '+') |
| 7008 | { |
| 7009 | (void) SetImageOption(image_info,option+1,"0"); |
| 7010 | break; |
| 7011 | } |
| 7012 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7013 | break; |
| 7014 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7015 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7016 | { |
| 7017 | if (*option == '+') |
| 7018 | { |
| 7019 | image_info->synchronize=MagickFalse; |
| 7020 | break; |
| 7021 | } |
| 7022 | image_info->synchronize=MagickTrue; |
| 7023 | break; |
| 7024 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7025 | break; |
| 7026 | } |
| 7027 | case 't': |
| 7028 | { |
| 7029 | if (LocaleCompare("taint",option+1) == 0) |
| 7030 | { |
| 7031 | if (*option == '+') |
| 7032 | { |
| 7033 | (void) SetImageOption(image_info,option+1,"false"); |
| 7034 | break; |
| 7035 | } |
| 7036 | (void) SetImageOption(image_info,option+1,"true"); |
| 7037 | break; |
| 7038 | } |
| 7039 | if (LocaleCompare("texture",option+1) == 0) |
| 7040 | { |
| 7041 | if (*option == '+') |
| 7042 | { |
| 7043 | if (image_info->texture != (char *) NULL) |
| 7044 | image_info->texture=DestroyString(image_info->texture); |
| 7045 | break; |
| 7046 | } |
| 7047 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7048 | break; |
| 7049 | } |
| 7050 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7051 | { |
| 7052 | if (*option == '+') |
| 7053 | { |
| 7054 | (void) SetImageOption(image_info,option+1,"0"); |
| 7055 | break; |
| 7056 | } |
| 7057 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7058 | break; |
| 7059 | } |
| 7060 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7061 | { |
| 7062 | if (*option == '+') |
| 7063 | { |
| 7064 | (void) QueryColorDatabase("none",&image_info->transparent_color, exception); |
| 7065 | (void) SetImageOption(image_info,option+1,"none"); |
| 7066 | break; |
| 7067 | } |
| 7068 | (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color, |
| 7069 | exception); |
| 7070 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7071 | break; |
| 7072 | } |
| 7073 | if (LocaleCompare("type",option+1) == 0) |
| 7074 | { |
| 7075 | if (*option == '+') |
| 7076 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7077 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7078 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7079 | break; |
| 7080 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7081 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7082 | MagickFalse,argv[i+1]); |
| 7083 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7084 | break; |
| 7085 | } |
| 7086 | break; |
| 7087 | } |
| 7088 | case 'u': |
| 7089 | { |
| 7090 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7091 | { |
| 7092 | if (*option == '+') |
| 7093 | { |
| 7094 | (void) DeleteImageOption(image_info,option+1); |
| 7095 | break; |
| 7096 | } |
| 7097 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7098 | break; |
| 7099 | } |
| 7100 | if (LocaleCompare("units",option+1) == 0) |
| 7101 | { |
| 7102 | if (*option == '+') |
| 7103 | { |
| 7104 | image_info->units=UndefinedResolution; |
| 7105 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7106 | break; |
| 7107 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7108 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7109 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7110 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7111 | break; |
| 7112 | } |
| 7113 | break; |
| 7114 | } |
| 7115 | case 'v': |
| 7116 | { |
| 7117 | if (LocaleCompare("verbose",option+1) == 0) |
| 7118 | { |
| 7119 | if (*option == '+') |
| 7120 | { |
| 7121 | image_info->verbose=MagickFalse; |
| 7122 | break; |
| 7123 | } |
| 7124 | image_info->verbose=MagickTrue; |
| 7125 | image_info->ping=MagickFalse; |
| 7126 | break; |
| 7127 | } |
| 7128 | if (LocaleCompare("view",option+1) == 0) |
| 7129 | { |
| 7130 | if (*option == '+') |
| 7131 | { |
| 7132 | if (image_info->view != (char *) NULL) |
| 7133 | image_info->view=DestroyString(image_info->view); |
| 7134 | break; |
| 7135 | } |
| 7136 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7137 | break; |
| 7138 | } |
| 7139 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7140 | { |
| 7141 | if (*option == '+') |
| 7142 | { |
| 7143 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7144 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7145 | break; |
| 7146 | } |
| 7147 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7148 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7149 | argv[i+1]); |
| 7150 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7151 | break; |
| 7152 | } |
| 7153 | break; |
| 7154 | } |
| 7155 | case 'w': |
| 7156 | { |
| 7157 | if (LocaleCompare("white-point",option+1) == 0) |
| 7158 | { |
| 7159 | if (*option == '+') |
| 7160 | { |
| 7161 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7162 | break; |
| 7163 | } |
| 7164 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7165 | break; |
| 7166 | } |
| 7167 | break; |
| 7168 | } |
| 7169 | default: |
| 7170 | break; |
| 7171 | } |
| 7172 | i+=count; |
| 7173 | } |
| 7174 | return(MagickTrue); |
| 7175 | } |
| 7176 | |
| 7177 | /* |
| 7178 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7179 | % % |
| 7180 | % % |
| 7181 | % % |
| 7182 | + M o g r i f y I m a g e L i s t % |
| 7183 | % % |
| 7184 | % % |
| 7185 | % % |
| 7186 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7187 | % |
| 7188 | % MogrifyImageList() applies any command line options that might affect the |
| 7189 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7190 | % |
| 7191 | % The format of the MogrifyImage method is: |
| 7192 | % |
| 7193 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7194 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7195 | % |
| 7196 | % A description of each parameter follows: |
| 7197 | % |
| 7198 | % o image_info: the image info.. |
| 7199 | % |
| 7200 | % o argc: Specifies a pointer to an integer describing the number of |
| 7201 | % elements in the argument vector. |
| 7202 | % |
| 7203 | % o argv: Specifies a pointer to a text array containing the command line |
| 7204 | % arguments. |
| 7205 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7206 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7207 | % |
| 7208 | % o exception: return any errors or warnings in this structure. |
| 7209 | % |
| 7210 | */ |
| 7211 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7212 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7213 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7214 | const char |
| 7215 | *option; |
| 7216 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7217 | ImageInfo |
| 7218 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7219 | |
| 7220 | MagickStatusType |
| 7221 | status; |
| 7222 | |
| 7223 | QuantizeInfo |
| 7224 | *quantize_info; |
| 7225 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7226 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7227 | i; |
| 7228 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7229 | ssize_t |
| 7230 | count, |
| 7231 | index; |
| 7232 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7233 | /* |
| 7234 | Apply options to the image list. |
| 7235 | */ |
| 7236 | assert(image_info != (ImageInfo *) NULL); |
| 7237 | assert(image_info->signature == MagickSignature); |
| 7238 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7239 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7240 | assert((*images)->signature == MagickSignature); |
| 7241 | if ((*images)->debug != MagickFalse) |
| 7242 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7243 | (*images)->filename); |
| 7244 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7245 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7246 | mogrify_info=CloneImageInfo(image_info); |
| 7247 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7248 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7249 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7250 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7251 | if (*images == (Image *) NULL) |
| 7252 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7253 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7254 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7255 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7256 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7257 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7258 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7259 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7260 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7261 | switch (*(option+1)) |
| 7262 | { |
| 7263 | case 'a': |
| 7264 | { |
| 7265 | if (LocaleCompare("affinity",option+1) == 0) |
| 7266 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7267 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7268 | if (*option == '+') |
| 7269 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7270 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7271 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7272 | break; |
| 7273 | } |
| 7274 | i++; |
| 7275 | break; |
| 7276 | } |
| 7277 | if (LocaleCompare("append",option+1) == 0) |
| 7278 | { |
| 7279 | Image |
| 7280 | *append_image; |
| 7281 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7282 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7283 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7284 | MagickFalse,exception); |
| 7285 | if (append_image == (Image *) NULL) |
| 7286 | { |
| 7287 | status=MagickFalse; |
| 7288 | break; |
| 7289 | } |
| 7290 | *images=DestroyImageList(*images); |
| 7291 | *images=append_image; |
| 7292 | break; |
| 7293 | } |
| 7294 | if (LocaleCompare("average",option+1) == 0) |
| 7295 | { |
| 7296 | Image |
| 7297 | *average_image; |
| 7298 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7299 | /* |
| 7300 | Average an image sequence (deprecated). |
| 7301 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7302 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7303 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7304 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7305 | if (average_image == (Image *) NULL) |
| 7306 | { |
| 7307 | status=MagickFalse; |
| 7308 | break; |
| 7309 | } |
| 7310 | *images=DestroyImageList(*images); |
| 7311 | *images=average_image; |
| 7312 | break; |
| 7313 | } |
| 7314 | break; |
| 7315 | } |
| 7316 | case 'c': |
| 7317 | { |
| 7318 | if (LocaleCompare("channel",option+1) == 0) |
| 7319 | { |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7320 | ChannelType |
| 7321 | channel; |
| 7322 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7323 | if (*option == '+') |
| 7324 | { |
| 7325 | channel=DefaultChannels; |
| 7326 | break; |
| 7327 | } |
| 7328 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 7329 | SetPixelChannelMap(*images,channel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7330 | break; |
| 7331 | } |
| 7332 | if (LocaleCompare("clut",option+1) == 0) |
| 7333 | { |
| 7334 | Image |
| 7335 | *clut_image, |
| 7336 | *image; |
| 7337 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7338 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7339 | image=RemoveFirstImageFromList(images); |
| 7340 | clut_image=RemoveFirstImageFromList(images); |
| 7341 | if (clut_image == (Image *) NULL) |
| 7342 | { |
| 7343 | status=MagickFalse; |
| 7344 | break; |
| 7345 | } |
cristy | 444eda6 | 2011-08-10 02:07:46 +0000 | [diff] [blame] | 7346 | (void) ClutImage(image,clut_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7347 | clut_image=DestroyImage(clut_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7348 | *images=DestroyImageList(*images); |
| 7349 | *images=image; |
| 7350 | break; |
| 7351 | } |
| 7352 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7353 | { |
| 7354 | Image |
| 7355 | *coalesce_image; |
| 7356 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7357 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7358 | coalesce_image=CoalesceImages(*images,exception); |
| 7359 | if (coalesce_image == (Image *) NULL) |
| 7360 | { |
| 7361 | status=MagickFalse; |
| 7362 | break; |
| 7363 | } |
| 7364 | *images=DestroyImageList(*images); |
| 7365 | *images=coalesce_image; |
| 7366 | break; |
| 7367 | } |
| 7368 | if (LocaleCompare("combine",option+1) == 0) |
| 7369 | { |
| 7370 | Image |
| 7371 | *combine_image; |
| 7372 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7373 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 7374 | combine_image=CombineImages(*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7375 | if (combine_image == (Image *) NULL) |
| 7376 | { |
| 7377 | status=MagickFalse; |
| 7378 | break; |
| 7379 | } |
| 7380 | *images=DestroyImageList(*images); |
| 7381 | *images=combine_image; |
| 7382 | break; |
| 7383 | } |
| 7384 | if (LocaleCompare("composite",option+1) == 0) |
| 7385 | { |
| 7386 | Image |
| 7387 | *mask_image, |
| 7388 | *composite_image, |
| 7389 | *image; |
| 7390 | |
| 7391 | RectangleInfo |
| 7392 | geometry; |
| 7393 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7394 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7395 | image=RemoveFirstImageFromList(images); |
| 7396 | composite_image=RemoveFirstImageFromList(images); |
| 7397 | if (composite_image == (Image *) NULL) |
| 7398 | { |
| 7399 | status=MagickFalse; |
| 7400 | break; |
| 7401 | } |
| 7402 | (void) TransformImage(&composite_image,(char *) NULL, |
| 7403 | composite_image->geometry); |
| 7404 | SetGeometry(composite_image,&geometry); |
| 7405 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7406 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7407 | &geometry); |
| 7408 | mask_image=RemoveFirstImageFromList(images); |
| 7409 | if (mask_image != (Image *) NULL) |
| 7410 | { |
| 7411 | if ((image->compose == DisplaceCompositeOp) || |
| 7412 | (image->compose == DistortCompositeOp)) |
| 7413 | { |
| 7414 | /* |
| 7415 | Merge Y displacement into X displacement image. |
| 7416 | */ |
| 7417 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
| 7418 | mask_image,0,0); |
| 7419 | mask_image=DestroyImage(mask_image); |
| 7420 | } |
| 7421 | else |
| 7422 | { |
| 7423 | /* |
| 7424 | Set a blending mask for the composition. |
| 7425 | */ |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7426 | /* POSIBLE ERROR; what if image->mask already set */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7427 | image->mask=mask_image; |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 7428 | (void) NegateImage(image->mask,MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7429 | } |
| 7430 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7431 | (void) CompositeImage(image,image->compose,composite_image, |
| 7432 | geometry.x,geometry.y); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7433 | if (mask_image != (Image *) NULL) |
| 7434 | mask_image=image->mask=DestroyImage(image->mask); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7435 | composite_image=DestroyImage(composite_image); |
| 7436 | InheritException(exception,&image->exception); |
| 7437 | *images=DestroyImageList(*images); |
| 7438 | *images=image; |
| 7439 | break; |
| 7440 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7441 | #if 0 |
| 7442 | This has been merged completely into MogrifyImage() |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7443 | if (LocaleCompare("crop",option+1) == 0) |
| 7444 | { |
| 7445 | MagickStatusType |
| 7446 | flags; |
| 7447 | |
| 7448 | RectangleInfo |
| 7449 | geometry; |
| 7450 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7451 | /* |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7452 | Crop Image. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7453 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7454 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7455 | flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception); |
| 7456 | if (((geometry.width == 0) && (geometry.height == 0)) || |
| 7457 | ((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 7458 | break; |
| 7459 | (void) TransformImages(images,argv[i+1],(char *) NULL); |
| 7460 | InheritException(exception,&(*images)->exception); |
| 7461 | break; |
| 7462 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7463 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7464 | break; |
| 7465 | } |
| 7466 | case 'd': |
| 7467 | { |
| 7468 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7469 | { |
| 7470 | Image |
| 7471 | *deconstruct_image; |
| 7472 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7473 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7474 | deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer, |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 7475 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7476 | if (deconstruct_image == (Image *) NULL) |
| 7477 | { |
| 7478 | status=MagickFalse; |
| 7479 | break; |
| 7480 | } |
| 7481 | *images=DestroyImageList(*images); |
| 7482 | *images=deconstruct_image; |
| 7483 | break; |
| 7484 | } |
| 7485 | if (LocaleCompare("delete",option+1) == 0) |
| 7486 | { |
| 7487 | if (*option == '+') |
| 7488 | DeleteImages(images,"-1",exception); |
| 7489 | else |
| 7490 | DeleteImages(images,argv[i+1],exception); |
| 7491 | break; |
| 7492 | } |
| 7493 | if (LocaleCompare("dither",option+1) == 0) |
| 7494 | { |
| 7495 | if (*option == '+') |
| 7496 | { |
| 7497 | quantize_info->dither=MagickFalse; |
| 7498 | break; |
| 7499 | } |
| 7500 | quantize_info->dither=MagickTrue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7501 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7502 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7503 | break; |
| 7504 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7505 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7506 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7507 | Image |
| 7508 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7509 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7510 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7511 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7512 | else |
| 7513 | { |
| 7514 | const char |
| 7515 | *p; |
| 7516 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7517 | size_t |
| 7518 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7519 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7520 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7521 | p=strchr(argv[i+1],','); |
| 7522 | if (p == (const char *) NULL) |
| 7523 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7524 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7525 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7526 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7527 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7528 | } |
| 7529 | AppendImageToList(images, duplicate_images); |
| 7530 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7531 | break; |
| 7532 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7533 | break; |
| 7534 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7535 | case 'e': |
| 7536 | { |
| 7537 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7538 | { |
| 7539 | Image |
| 7540 | *evaluate_image; |
| 7541 | |
| 7542 | MagickEvaluateOperator |
| 7543 | op; |
| 7544 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7545 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7546 | op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions, |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7547 | MagickFalse,argv[i+1]); |
| 7548 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7549 | if (evaluate_image == (Image *) NULL) |
| 7550 | { |
| 7551 | status=MagickFalse; |
| 7552 | break; |
| 7553 | } |
| 7554 | *images=DestroyImageList(*images); |
| 7555 | *images=evaluate_image; |
| 7556 | break; |
| 7557 | } |
| 7558 | break; |
| 7559 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7560 | case 'f': |
| 7561 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7562 | if (LocaleCompare("fft",option+1) == 0) |
| 7563 | { |
| 7564 | Image |
| 7565 | *fourier_image; |
| 7566 | |
| 7567 | /* |
| 7568 | Implements the discrete Fourier transform (DFT). |
| 7569 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7570 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7571 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7572 | MagickTrue : MagickFalse,exception); |
| 7573 | if (fourier_image == (Image *) NULL) |
| 7574 | break; |
| 7575 | *images=DestroyImage(*images); |
| 7576 | *images=fourier_image; |
| 7577 | break; |
| 7578 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7579 | if (LocaleCompare("flatten",option+1) == 0) |
| 7580 | { |
| 7581 | Image |
| 7582 | *flatten_image; |
| 7583 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7584 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7585 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7586 | if (flatten_image == (Image *) NULL) |
| 7587 | break; |
| 7588 | *images=DestroyImageList(*images); |
| 7589 | *images=flatten_image; |
| 7590 | break; |
| 7591 | } |
| 7592 | if (LocaleCompare("fx",option+1) == 0) |
| 7593 | { |
| 7594 | Image |
| 7595 | *fx_image; |
| 7596 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7597 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 7598 | fx_image=FxImage(*images,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7599 | if (fx_image == (Image *) NULL) |
| 7600 | { |
| 7601 | status=MagickFalse; |
| 7602 | break; |
| 7603 | } |
| 7604 | *images=DestroyImageList(*images); |
| 7605 | *images=fx_image; |
| 7606 | break; |
| 7607 | } |
| 7608 | break; |
| 7609 | } |
| 7610 | case 'h': |
| 7611 | { |
| 7612 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7613 | { |
| 7614 | Image |
| 7615 | *hald_image, |
| 7616 | *image; |
| 7617 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7618 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7619 | image=RemoveFirstImageFromList(images); |
| 7620 | hald_image=RemoveFirstImageFromList(images); |
| 7621 | if (hald_image == (Image *) NULL) |
| 7622 | { |
| 7623 | status=MagickFalse; |
| 7624 | break; |
| 7625 | } |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 7626 | (void) HaldClutImage(image,hald_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7627 | hald_image=DestroyImage(hald_image); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7628 | if (*images != (Image *) NULL) |
| 7629 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7630 | *images=image; |
| 7631 | break; |
| 7632 | } |
| 7633 | break; |
| 7634 | } |
| 7635 | case 'i': |
| 7636 | { |
| 7637 | if (LocaleCompare("ift",option+1) == 0) |
| 7638 | { |
| 7639 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7640 | *fourier_image, |
| 7641 | *magnitude_image, |
| 7642 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7643 | |
| 7644 | /* |
| 7645 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7646 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7647 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7648 | magnitude_image=RemoveFirstImageFromList(images); |
| 7649 | phase_image=RemoveFirstImageFromList(images); |
| 7650 | if (phase_image == (Image *) NULL) |
| 7651 | { |
| 7652 | status=MagickFalse; |
| 7653 | break; |
| 7654 | } |
| 7655 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7656 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7657 | if (fourier_image == (Image *) NULL) |
| 7658 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7659 | if (*images != (Image *) NULL) |
| 7660 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7661 | *images=fourier_image; |
| 7662 | break; |
| 7663 | } |
| 7664 | if (LocaleCompare("insert",option+1) == 0) |
| 7665 | { |
| 7666 | Image |
| 7667 | *p, |
| 7668 | *q; |
| 7669 | |
| 7670 | index=0; |
| 7671 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7672 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7673 | p=RemoveLastImageFromList(images); |
| 7674 | if (p == (Image *) NULL) |
| 7675 | { |
| 7676 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7677 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7678 | status=MagickFalse; |
| 7679 | break; |
| 7680 | } |
| 7681 | q=p; |
| 7682 | if (index == 0) |
| 7683 | PrependImageToList(images,q); |
| 7684 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7685 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7686 | AppendImageToList(images,q); |
| 7687 | else |
| 7688 | { |
| 7689 | q=GetImageFromList(*images,index-1); |
| 7690 | if (q == (Image *) NULL) |
| 7691 | { |
| 7692 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7693 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7694 | status=MagickFalse; |
| 7695 | break; |
| 7696 | } |
| 7697 | InsertImageInList(&q,p); |
| 7698 | } |
| 7699 | *images=GetFirstImageInList(q); |
| 7700 | break; |
| 7701 | } |
| 7702 | break; |
| 7703 | } |
| 7704 | case 'l': |
| 7705 | { |
| 7706 | if (LocaleCompare("layers",option+1) == 0) |
| 7707 | { |
| 7708 | Image |
| 7709 | *layers; |
| 7710 | |
| 7711 | ImageLayerMethod |
| 7712 | method; |
| 7713 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7714 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7715 | layers=(Image *) NULL; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7716 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7717 | MagickFalse,argv[i+1]); |
| 7718 | switch (method) |
| 7719 | { |
| 7720 | case CoalesceLayer: |
| 7721 | { |
| 7722 | layers=CoalesceImages(*images,exception); |
| 7723 | break; |
| 7724 | } |
| 7725 | case CompareAnyLayer: |
| 7726 | case CompareClearLayer: |
| 7727 | case CompareOverlayLayer: |
| 7728 | default: |
| 7729 | { |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7730 | layers=CompareImagesLayers(*images,method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7731 | break; |
| 7732 | } |
| 7733 | case MergeLayer: |
| 7734 | case FlattenLayer: |
| 7735 | case MosaicLayer: |
| 7736 | case TrimBoundsLayer: |
| 7737 | { |
| 7738 | layers=MergeImageLayers(*images,method,exception); |
| 7739 | break; |
| 7740 | } |
| 7741 | case DisposeLayer: |
| 7742 | { |
| 7743 | layers=DisposeImages(*images,exception); |
| 7744 | break; |
| 7745 | } |
| 7746 | case OptimizeImageLayer: |
| 7747 | { |
| 7748 | layers=OptimizeImageLayers(*images,exception); |
| 7749 | break; |
| 7750 | } |
| 7751 | case OptimizePlusLayer: |
| 7752 | { |
| 7753 | layers=OptimizePlusImageLayers(*images,exception); |
| 7754 | break; |
| 7755 | } |
| 7756 | case OptimizeTransLayer: |
| 7757 | { |
| 7758 | OptimizeImageTransparency(*images,exception); |
| 7759 | break; |
| 7760 | } |
| 7761 | case RemoveDupsLayer: |
| 7762 | { |
| 7763 | RemoveDuplicateLayers(images,exception); |
| 7764 | break; |
| 7765 | } |
| 7766 | case RemoveZeroLayer: |
| 7767 | { |
| 7768 | RemoveZeroDelayLayers(images,exception); |
| 7769 | break; |
| 7770 | } |
| 7771 | case OptimizeLayer: |
| 7772 | { |
| 7773 | /* |
| 7774 | General Purpose, GIF Animation Optimizer. |
| 7775 | */ |
| 7776 | layers=CoalesceImages(*images,exception); |
| 7777 | if (layers == (Image *) NULL) |
| 7778 | { |
| 7779 | status=MagickFalse; |
| 7780 | break; |
| 7781 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7782 | *images=DestroyImageList(*images); |
| 7783 | *images=layers; |
| 7784 | layers=OptimizeImageLayers(*images,exception); |
| 7785 | if (layers == (Image *) NULL) |
| 7786 | { |
| 7787 | status=MagickFalse; |
| 7788 | break; |
| 7789 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7790 | *images=DestroyImageList(*images); |
| 7791 | *images=layers; |
| 7792 | layers=(Image *) NULL; |
| 7793 | OptimizeImageTransparency(*images,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7794 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7795 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7796 | break; |
| 7797 | } |
| 7798 | case CompositeLayer: |
| 7799 | { |
| 7800 | CompositeOperator |
| 7801 | compose; |
| 7802 | |
| 7803 | Image |
| 7804 | *source; |
| 7805 | |
| 7806 | RectangleInfo |
| 7807 | geometry; |
| 7808 | |
| 7809 | /* |
| 7810 | Split image sequence at the first 'NULL:' image. |
| 7811 | */ |
| 7812 | source=(*images); |
| 7813 | while (source != (Image *) NULL) |
| 7814 | { |
| 7815 | source=GetNextImageInList(source); |
| 7816 | if ((source != (Image *) NULL) && |
| 7817 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7818 | break; |
| 7819 | } |
| 7820 | if (source != (Image *) NULL) |
| 7821 | { |
| 7822 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7823 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7824 | source=(Image *) NULL; |
| 7825 | else |
| 7826 | { |
| 7827 | /* |
| 7828 | Separate the two lists, junk the null: image. |
| 7829 | */ |
| 7830 | source=SplitImageList(source->previous); |
| 7831 | DeleteImageFromList(&source); |
| 7832 | } |
| 7833 | } |
| 7834 | if (source == (Image *) NULL) |
| 7835 | { |
| 7836 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7837 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7838 | status=MagickFalse; |
| 7839 | break; |
| 7840 | } |
| 7841 | /* |
| 7842 | Adjust offset with gravity and virtual canvas. |
| 7843 | */ |
| 7844 | SetGeometry(*images,&geometry); |
| 7845 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7846 | geometry.width=source->page.width != 0 ? |
| 7847 | source->page.width : source->columns; |
| 7848 | geometry.height=source->page.height != 0 ? |
| 7849 | source->page.height : source->rows; |
| 7850 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7851 | (*images)->page.width : (*images)->columns, |
| 7852 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7853 | (*images)->rows,(*images)->gravity,&geometry); |
| 7854 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7855 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7856 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7857 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7858 | MagickComposeOptions,MagickFalse,option); |
| 7859 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7860 | exception); |
| 7861 | source=DestroyImageList(source); |
| 7862 | break; |
| 7863 | } |
| 7864 | } |
| 7865 | if (layers == (Image *) NULL) |
| 7866 | break; |
| 7867 | InheritException(exception,&layers->exception); |
| 7868 | *images=DestroyImageList(*images); |
| 7869 | *images=layers; |
| 7870 | break; |
| 7871 | } |
| 7872 | break; |
| 7873 | } |
| 7874 | case 'm': |
| 7875 | { |
| 7876 | if (LocaleCompare("map",option+1) == 0) |
| 7877 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7878 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7879 | if (*option == '+') |
| 7880 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7881 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7882 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7883 | break; |
| 7884 | } |
| 7885 | i++; |
| 7886 | break; |
| 7887 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7888 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7889 | { |
| 7890 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7891 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7892 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7893 | /* |
| 7894 | Maximum image sequence (deprecated). |
| 7895 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7896 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7897 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7898 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7899 | { |
| 7900 | status=MagickFalse; |
| 7901 | break; |
| 7902 | } |
| 7903 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7904 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7905 | break; |
| 7906 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7907 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7908 | { |
| 7909 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7910 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7911 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7912 | /* |
| 7913 | Minimum image sequence (deprecated). |
| 7914 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7915 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7916 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7917 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7918 | { |
| 7919 | status=MagickFalse; |
| 7920 | break; |
| 7921 | } |
| 7922 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7923 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7924 | break; |
| 7925 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7926 | if (LocaleCompare("morph",option+1) == 0) |
| 7927 | { |
| 7928 | Image |
| 7929 | *morph_image; |
| 7930 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7931 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7932 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7933 | exception); |
| 7934 | if (morph_image == (Image *) NULL) |
| 7935 | { |
| 7936 | status=MagickFalse; |
| 7937 | break; |
| 7938 | } |
| 7939 | *images=DestroyImageList(*images); |
| 7940 | *images=morph_image; |
| 7941 | break; |
| 7942 | } |
| 7943 | if (LocaleCompare("mosaic",option+1) == 0) |
| 7944 | { |
| 7945 | Image |
| 7946 | *mosaic_image; |
| 7947 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7948 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7949 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 7950 | if (mosaic_image == (Image *) NULL) |
| 7951 | { |
| 7952 | status=MagickFalse; |
| 7953 | break; |
| 7954 | } |
| 7955 | *images=DestroyImageList(*images); |
| 7956 | *images=mosaic_image; |
| 7957 | break; |
| 7958 | } |
| 7959 | break; |
| 7960 | } |
| 7961 | case 'p': |
| 7962 | { |
| 7963 | if (LocaleCompare("print",option+1) == 0) |
| 7964 | { |
| 7965 | char |
| 7966 | *string; |
| 7967 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7968 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7969 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1], |
| 7970 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7971 | if (string == (char *) NULL) |
| 7972 | break; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 7973 | (void) FormatLocaleFile(stdout,"%s",string); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7974 | string=DestroyString(string); |
| 7975 | } |
| 7976 | if (LocaleCompare("process",option+1) == 0) |
| 7977 | { |
| 7978 | char |
| 7979 | **arguments; |
| 7980 | |
| 7981 | int |
| 7982 | j, |
| 7983 | number_arguments; |
| 7984 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7985 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7986 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 7987 | if (arguments == (char **) NULL) |
| 7988 | break; |
| 7989 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 7990 | { |
| 7991 | char |
| 7992 | breaker, |
| 7993 | quote, |
| 7994 | *token; |
| 7995 | |
| 7996 | const char |
| 7997 | *arguments; |
| 7998 | |
| 7999 | int |
| 8000 | next, |
| 8001 | status; |
| 8002 | |
| 8003 | size_t |
| 8004 | length; |
| 8005 | |
| 8006 | TokenInfo |
| 8007 | *token_info; |
| 8008 | |
| 8009 | /* |
| 8010 | Support old style syntax, filter="-option arg". |
| 8011 | */ |
| 8012 | length=strlen(argv[i+1]); |
| 8013 | token=(char *) NULL; |
cristy | 37e0b38 | 2011-06-07 13:31:21 +0000 | [diff] [blame] | 8014 | if (~length >= (MaxTextExtent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8015 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8016 | sizeof(*token)); |
| 8017 | if (token == (char *) NULL) |
| 8018 | break; |
| 8019 | next=0; |
| 8020 | arguments=argv[i+1]; |
| 8021 | token_info=AcquireTokenInfo(); |
| 8022 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8023 | "\"",'\0',&breaker,&next,"e); |
| 8024 | token_info=DestroyTokenInfo(token_info); |
| 8025 | if (status == 0) |
| 8026 | { |
| 8027 | const char |
| 8028 | *argv; |
| 8029 | |
| 8030 | argv=(&(arguments[next])); |
| 8031 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8032 | exception); |
| 8033 | } |
| 8034 | token=DestroyString(token); |
| 8035 | break; |
| 8036 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8037 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8038 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8039 | number_arguments-2,(const char **) arguments+2,exception); |
| 8040 | for (j=0; j < number_arguments; j++) |
| 8041 | arguments[j]=DestroyString(arguments[j]); |
| 8042 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8043 | break; |
| 8044 | } |
| 8045 | break; |
| 8046 | } |
| 8047 | case 'r': |
| 8048 | { |
| 8049 | if (LocaleCompare("reverse",option+1) == 0) |
| 8050 | { |
| 8051 | ReverseImageList(images); |
| 8052 | InheritException(exception,&(*images)->exception); |
| 8053 | break; |
| 8054 | } |
| 8055 | break; |
| 8056 | } |
| 8057 | case 's': |
| 8058 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8059 | if (LocaleCompare("smush",option+1) == 0) |
| 8060 | { |
| 8061 | Image |
| 8062 | *smush_image; |
| 8063 | |
| 8064 | ssize_t |
| 8065 | offset; |
| 8066 | |
| 8067 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8068 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8069 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8070 | MagickFalse,offset,exception); |
| 8071 | if (smush_image == (Image *) NULL) |
| 8072 | { |
| 8073 | status=MagickFalse; |
| 8074 | break; |
| 8075 | } |
| 8076 | *images=DestroyImageList(*images); |
| 8077 | *images=smush_image; |
| 8078 | break; |
| 8079 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8080 | if (LocaleCompare("swap",option+1) == 0) |
| 8081 | { |
| 8082 | Image |
| 8083 | *p, |
| 8084 | *q, |
| 8085 | *swap; |
| 8086 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8087 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8088 | swap_index; |
| 8089 | |
| 8090 | index=(-1); |
| 8091 | swap_index=(-2); |
| 8092 | if (*option != '+') |
| 8093 | { |
| 8094 | GeometryInfo |
| 8095 | geometry_info; |
| 8096 | |
| 8097 | MagickStatusType |
| 8098 | flags; |
| 8099 | |
| 8100 | swap_index=(-1); |
| 8101 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8102 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8103 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8104 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8105 | } |
| 8106 | p=GetImageFromList(*images,index); |
| 8107 | q=GetImageFromList(*images,swap_index); |
| 8108 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8109 | { |
| 8110 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8111 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8112 | status=MagickFalse; |
| 8113 | break; |
| 8114 | } |
| 8115 | if (p == q) |
| 8116 | break; |
| 8117 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8118 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8119 | ReplaceImageInList(&q,swap); |
| 8120 | *images=GetFirstImageInList(q); |
| 8121 | break; |
| 8122 | } |
| 8123 | break; |
| 8124 | } |
| 8125 | case 'w': |
| 8126 | { |
| 8127 | if (LocaleCompare("write",option+1) == 0) |
| 8128 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8129 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8130 | key[MaxTextExtent]; |
| 8131 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8132 | Image |
| 8133 | *write_images; |
| 8134 | |
| 8135 | ImageInfo |
| 8136 | *write_info; |
| 8137 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8138 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8139 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8140 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8141 | write_images=(*images); |
| 8142 | if (*option == '+') |
| 8143 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8144 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8145 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8146 | write_info=DestroyImageInfo(write_info); |
| 8147 | if (*option == '+') |
| 8148 | write_images=DestroyImageList(write_images); |
| 8149 | break; |
| 8150 | } |
| 8151 | break; |
| 8152 | } |
| 8153 | default: |
| 8154 | break; |
| 8155 | } |
| 8156 | i+=count; |
| 8157 | } |
| 8158 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8159 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8160 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8161 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8162 | } |
| 8163 | |
| 8164 | /* |
| 8165 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8166 | % % |
| 8167 | % % |
| 8168 | % % |
| 8169 | + M o g r i f y I m a g e s % |
| 8170 | % % |
| 8171 | % % |
| 8172 | % % |
| 8173 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8174 | % |
| 8175 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8176 | % prescribed by command line options. |
| 8177 | % |
| 8178 | % The format of the MogrifyImage method is: |
| 8179 | % |
| 8180 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8181 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8182 | % Image **images,Exceptioninfo *exception) |
| 8183 | % |
| 8184 | % A description of each parameter follows: |
| 8185 | % |
| 8186 | % o image_info: the image info.. |
| 8187 | % |
| 8188 | % o post: If true, post process image list operators otherwise pre-process. |
| 8189 | % |
| 8190 | % o argc: Specifies a pointer to an integer describing the number of |
| 8191 | % elements in the argument vector. |
| 8192 | % |
| 8193 | % o argv: Specifies a pointer to a text array containing the command line |
| 8194 | % arguments. |
| 8195 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8196 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8197 | % |
| 8198 | % o exception: return any errors or warnings in this structure. |
| 8199 | % |
| 8200 | */ |
| 8201 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8202 | const MagickBooleanType post,const int argc,const char **argv, |
| 8203 | Image **images,ExceptionInfo *exception) |
| 8204 | { |
| 8205 | #define MogrifyImageTag "Mogrify/Image" |
| 8206 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8207 | MagickStatusType |
| 8208 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8209 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8210 | MagickBooleanType |
| 8211 | proceed; |
| 8212 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8213 | size_t |
| 8214 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8215 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8216 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8217 | i; |
| 8218 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8219 | assert(image_info != (ImageInfo *) NULL); |
| 8220 | assert(image_info->signature == MagickSignature); |
| 8221 | if (images == (Image **) NULL) |
| 8222 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8223 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8224 | assert((*images)->signature == MagickSignature); |
| 8225 | if ((*images)->debug != MagickFalse) |
| 8226 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8227 | (*images)->filename); |
| 8228 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8229 | return(MagickTrue); |
| 8230 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8231 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8232 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8233 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8234 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8235 | (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc, |
| 8236 | post?"post":"pre"); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8237 | #endif |
| 8238 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8239 | /* |
| 8240 | Pre-process multi-image sequence operators |
| 8241 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8242 | if (post == MagickFalse) |
| 8243 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8244 | /* |
| 8245 | For each image, process simple single image operators |
| 8246 | */ |
| 8247 | i=0; |
| 8248 | n=GetImageListLength(*images); |
| 8249 | for (;;) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8250 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8251 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8252 | (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long) |
| 8253 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8254 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8255 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8256 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8257 | if (proceed == MagickFalse) |
| 8258 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8259 | if ( (*images)->next == (Image *) NULL ) |
| 8260 | break; |
| 8261 | *images=(*images)->next; |
| 8262 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8263 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8264 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8265 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8266 | (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long) |
| 8267 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8268 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8269 | |
| 8270 | /* |
| 8271 | Post-process, multi-image sequence operators |
| 8272 | */ |
| 8273 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8274 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8275 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8276 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8277 | } |