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 | /* |
| 58 | Define declarations. |
| 59 | */ |
| 60 | #define UndefinedCompressionQuality 0UL |
| 61 | |
| 62 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 63 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 64 | % % |
| 65 | % % |
| 66 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 67 | % 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] | 68 | % % |
| 69 | % % |
| 70 | % % |
| 71 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 72 | % |
| 73 | % MagickCommandGenesis() applies image processing options to an image as |
| 74 | % prescribed by command line options. |
| 75 | % |
| 76 | % The format of the MagickCommandGenesis method is: |
| 77 | % |
| 78 | % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 79 | % MagickCommand command,int argc,char **argv,char **metadata, |
| 80 | % ExceptionInfo *exception) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 81 | % |
| 82 | % A description of each parameter follows: |
| 83 | % |
| 84 | % o image_info: the image info. |
| 85 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 86 | % o command: Choose from ConvertImageCommand, IdentifyImageCommand, |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 87 | % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 88 | % ConjureImageCommand, StreamImageCommand, ImportImageCommand, |
| 89 | % DisplayImageCommand, or AnimateImageCommand. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 90 | % |
| 91 | % o argc: Specifies a pointer to an integer describing the number of |
| 92 | % elements in the argument vector. |
| 93 | % |
| 94 | % o argv: Specifies a pointer to a text array containing the command line |
| 95 | % arguments. |
| 96 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 97 | % o metadata: any metadata is returned here. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 98 | % |
| 99 | % o exception: return any errors or warnings in this structure. |
| 100 | % |
| 101 | */ |
| 102 | WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
| 103 | MagickCommand command,int argc,char **argv,char **metadata, |
| 104 | ExceptionInfo *exception) |
| 105 | { |
| 106 | char |
| 107 | *option; |
| 108 | |
| 109 | double |
| 110 | duration, |
| 111 | elapsed_time, |
| 112 | user_time; |
| 113 | |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 114 | MagickBooleanType |
| 115 | concurrent, |
| 116 | regard_warnings, |
| 117 | status; |
| 118 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 119 | register ssize_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 120 | i; |
| 121 | |
| 122 | TimerInfo |
| 123 | *timer; |
| 124 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 125 | size_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 126 | iterations; |
| 127 | |
cristy | d0a94fa | 2010-03-12 14:18:11 +0000 | [diff] [blame] | 128 | (void) setlocale(LC_ALL,""); |
| 129 | (void) setlocale(LC_NUMERIC,"C"); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 130 | concurrent=MagickFalse; |
| 131 | duration=(-1.0); |
| 132 | iterations=1; |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 133 | status=MagickFalse; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 134 | regard_warnings=MagickFalse; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 135 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 136 | { |
| 137 | option=argv[i]; |
| 138 | if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) |
| 139 | continue; |
| 140 | if (LocaleCompare("bench",option+1) == 0) |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 141 | iterations=StringToUnsignedLong(argv[++i]); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 142 | if (LocaleCompare("concurrent",option+1) == 0) |
| 143 | concurrent=MagickTrue; |
| 144 | if (LocaleCompare("debug",option+1) == 0) |
| 145 | (void) SetLogEventMask(argv[++i]); |
| 146 | if (LocaleCompare("duration",option+1) == 0) |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 147 | duration=InterpretLocaleValue(argv[++i],(char **) NULL); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 148 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 149 | regard_warnings=MagickTrue; |
| 150 | } |
| 151 | timer=AcquireTimerInfo(); |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 152 | if (concurrent == MagickFalse) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 153 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 154 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 155 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 156 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 157 | continue; |
| 158 | if (duration > 0) |
| 159 | { |
| 160 | if (GetElapsedTime(timer) > duration) |
| 161 | continue; |
| 162 | (void) ContinueTimer(timer); |
| 163 | } |
| 164 | status=command(image_info,argc,argv,metadata,exception); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 165 | if (exception->severity != UndefinedException) |
| 166 | { |
| 167 | if ((exception->severity > ErrorException) || |
| 168 | (regard_warnings != MagickFalse)) |
| 169 | status=MagickTrue; |
| 170 | CatchException(exception); |
| 171 | } |
cristy | 3d1a551 | 2009-10-25 21:23:27 +0000 | [diff] [blame] | 172 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 173 | { |
| 174 | (void) fputs(*metadata,stdout); |
| 175 | (void) fputc('\n',stdout); |
| 176 | *metadata=DestroyString(*metadata); |
| 177 | } |
| 178 | } |
| 179 | } |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 180 | else |
| 181 | { |
| 182 | SetOpenMPNested(1); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 183 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 184 | # pragma omp parallel for shared(status) |
| 185 | #endif |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 186 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 187 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 188 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 189 | continue; |
| 190 | if (duration > 0) |
| 191 | { |
| 192 | if (GetElapsedTime(timer) > duration) |
| 193 | continue; |
| 194 | (void) ContinueTimer(timer); |
| 195 | } |
| 196 | status=command(image_info,argc,argv,metadata,exception); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 197 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 198 | # pragma omp critical (MagickCore_CommandGenesis) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 199 | #endif |
| 200 | { |
| 201 | if (exception->severity != UndefinedException) |
| 202 | { |
| 203 | if ((exception->severity > ErrorException) || |
| 204 | (regard_warnings != MagickFalse)) |
| 205 | status=MagickTrue; |
| 206 | CatchException(exception); |
| 207 | } |
| 208 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 209 | { |
| 210 | (void) fputs(*metadata,stdout); |
| 211 | (void) fputc('\n',stdout); |
| 212 | *metadata=DestroyString(*metadata); |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | } |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 217 | if (iterations > 1) |
| 218 | { |
| 219 | elapsed_time=GetElapsedTime(timer); |
| 220 | user_time=GetUserTime(timer); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 221 | (void) FormatLocaleFile(stderr, |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 222 | "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double) |
| 223 | iterations,1.0*iterations/elapsed_time,user_time,(double) |
| 224 | (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double) |
| 225 | (1000.0*(elapsed_time-floor(elapsed_time)))); |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 226 | (void) fflush(stderr); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 227 | } |
| 228 | timer=DestroyTimerInfo(timer); |
cristy | 1f9e1ed | 2009-11-18 04:09:38 +0000 | [diff] [blame] | 229 | return(status); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | /* |
| 233 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 234 | % % |
| 235 | % % |
| 236 | % % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 237 | + M o g r i f y I m a g e % |
| 238 | % % |
| 239 | % % |
| 240 | % % |
| 241 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 242 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 243 | % MogrifyImage() applies simple single image processing options to a single |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 244 | % image that may be part of a large list, but also handles any 'region' |
| 245 | % image handling. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 246 | % |
| 247 | % The image in the list may be modified in three different ways... |
| 248 | % |
| 249 | % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 250 | % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 251 | % * replace by a list of images (only the -separate option!) |
| 252 | % |
| 253 | % In each case the result is returned into the list, and a pointer to the |
| 254 | % modified image (last image added if replaced by a list of images) is |
| 255 | % returned. |
| 256 | % |
| 257 | % ASIDE: The -crop is present but restricted to non-tile single image crops |
| 258 | % |
| 259 | % This means if all the images are being processed (such as by |
| 260 | % MogrifyImages(), next image to be processed will be as per the pointer |
| 261 | % (*image)->next. Also the image list may grow as a result of some specific |
| 262 | % operations but as images are never merged or deleted, it will never shrink |
| 263 | % in length. Typically the list will remain the same length. |
| 264 | % |
| 265 | % WARNING: As the image pointed to may be replaced, the first image in the |
| 266 | % list may also change. GetFirstImageInList() should be used by caller if |
| 267 | % they wish return the Image pointer to the first image in list. |
| 268 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 269 | % |
| 270 | % The format of the MogrifyImage method is: |
| 271 | % |
| 272 | % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 273 | % const char **argv,Image **image) |
| 274 | % |
| 275 | % A description of each parameter follows: |
| 276 | % |
| 277 | % o image_info: the image info.. |
| 278 | % |
| 279 | % o argc: Specifies a pointer to an integer describing the number of |
| 280 | % elements in the argument vector. |
| 281 | % |
| 282 | % o argv: Specifies a pointer to a text array containing the command line |
| 283 | % arguments. |
| 284 | % |
| 285 | % o image: the image. |
| 286 | % |
| 287 | % o exception: return any errors or warnings in this structure. |
| 288 | % |
| 289 | */ |
| 290 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 291 | /* |
| 292 | ** GetImageCache() will read an image into a image cache if not already |
| 293 | ** present then return the image that is in the cache under that filename. |
| 294 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 295 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 296 | ExceptionInfo *exception) |
| 297 | { |
| 298 | char |
| 299 | key[MaxTextExtent]; |
| 300 | |
| 301 | ExceptionInfo |
| 302 | *sans_exception; |
| 303 | |
| 304 | Image |
| 305 | *image; |
| 306 | |
| 307 | ImageInfo |
| 308 | *read_info; |
| 309 | |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 310 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 311 | sans_exception=AcquireExceptionInfo(); |
| 312 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 313 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 314 | if (image != (Image *) NULL) |
| 315 | return(image); |
| 316 | read_info=CloneImageInfo(image_info); |
| 317 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 318 | image=ReadImage(read_info,exception); |
| 319 | read_info=DestroyImageInfo(read_info); |
| 320 | if (image != (Image *) NULL) |
| 321 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 322 | return(image); |
| 323 | } |
| 324 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 325 | static MagickBooleanType IsPathWritable(const char *path) |
| 326 | { |
| 327 | if (IsPathAccessible(path) == MagickFalse) |
| 328 | return(MagickFalse); |
| 329 | if (access(path,W_OK) != 0) |
| 330 | return(MagickFalse); |
| 331 | return(MagickTrue); |
| 332 | } |
| 333 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 334 | static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 335 | { |
| 336 | if (x > y) |
| 337 | return(x); |
| 338 | return(y); |
| 339 | } |
| 340 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 341 | static MagickBooleanType MonitorProgress(const char *text, |
| 342 | const MagickOffsetType offset,const MagickSizeType extent, |
| 343 | void *wand_unused(client_data)) |
| 344 | { |
| 345 | char |
| 346 | message[MaxTextExtent], |
| 347 | tag[MaxTextExtent]; |
| 348 | |
| 349 | const char |
| 350 | *locale_message; |
| 351 | |
| 352 | register char |
| 353 | *p; |
| 354 | |
| 355 | if (extent < 2) |
| 356 | return(MagickTrue); |
| 357 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 358 | p=strrchr(tag,'/'); |
| 359 | if (p != (char *) NULL) |
| 360 | *p='\0'; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 361 | (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 362 | locale_message=GetLocaleMessage(message); |
| 363 | if (locale_message == message) |
| 364 | locale_message=tag; |
| 365 | if (p == (char *) NULL) |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 366 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", |
| 367 | locale_message,(long) offset,(unsigned long) extent,(long) |
| 368 | (100L*offset/(extent-1))); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 369 | else |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 370 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 371 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 372 | (100L*offset/(extent-1))); |
| 373 | if (offset == (MagickOffsetType) (extent-1)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 374 | (void) FormatLocaleFile(stderr,"\n"); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 375 | (void) fflush(stderr); |
| 376 | return(MagickTrue); |
| 377 | } |
| 378 | |
| 379 | /* |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 380 | ** SparseColorOption() parses the complex -sparse-color argument into an |
| 381 | ** an array of floating point values then calls SparseColorImage(). |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 382 | ** Argument is a complex mix of floating-point pixel coodinates, and color |
| 383 | ** specifications (or direct floating point numbers). The number of floats |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 384 | ** needed to represent a color varies depending on the current channel |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 385 | ** setting. |
| 386 | */ |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 387 | static Image *SparseColorOption(const Image *image, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 388 | const SparseColorMethod method,const char *arguments, |
| 389 | const MagickBooleanType color_from_image,ExceptionInfo *exception) |
| 390 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 391 | char |
| 392 | token[MaxTextExtent]; |
| 393 | |
| 394 | const char |
| 395 | *p; |
| 396 | |
| 397 | double |
| 398 | *sparse_arguments; |
| 399 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 400 | Image |
| 401 | *sparse_image; |
| 402 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 403 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 404 | color; |
| 405 | |
| 406 | MagickBooleanType |
| 407 | error; |
| 408 | |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 409 | register size_t |
| 410 | x; |
| 411 | |
| 412 | size_t |
| 413 | number_arguments, |
| 414 | number_colors; |
| 415 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 416 | assert(image != (Image *) NULL); |
| 417 | assert(image->signature == MagickSignature); |
| 418 | if (image->debug != MagickFalse) |
| 419 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 420 | assert(exception != (ExceptionInfo *) NULL); |
| 421 | assert(exception->signature == MagickSignature); |
| 422 | /* |
| 423 | Limit channels according to image - and add up number of color channel. |
| 424 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 425 | number_colors=0; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 426 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 427 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 428 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 429 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 430 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 431 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 432 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 433 | (image->colorspace == CMYKColorspace)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 434 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 435 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 436 | (image->matte != MagickFalse)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 437 | number_colors++; |
| 438 | |
| 439 | /* |
| 440 | Read string, to determine number of arguments needed, |
| 441 | */ |
| 442 | p=arguments; |
| 443 | x=0; |
| 444 | while( *p != '\0' ) |
| 445 | { |
| 446 | GetMagickToken(p,&p,token); |
| 447 | if ( token[0] == ',' ) continue; |
| 448 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 449 | if ( color_from_image ) { |
| 450 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 451 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 452 | "Color arg given, when colors are coming from image"); |
| 453 | return( (Image *)NULL); |
| 454 | } |
| 455 | x += number_colors; /* color argument */ |
| 456 | } |
| 457 | else { |
| 458 | x++; /* floating point argument */ |
| 459 | } |
| 460 | } |
| 461 | error=MagickTrue; |
| 462 | if ( color_from_image ) { |
| 463 | /* just the control points are being given */ |
| 464 | error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; |
| 465 | number_arguments=(x/2)*(2+number_colors); |
| 466 | } |
| 467 | else { |
| 468 | /* control points and color values */ |
| 469 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; |
| 470 | number_arguments=x; |
| 471 | } |
| 472 | if ( error ) { |
| 473 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 474 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 475 | "Invalid number of Arguments"); |
| 476 | return( (Image *)NULL); |
| 477 | } |
| 478 | |
| 479 | /* Allocate and fill in the floating point arguments */ |
| 480 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 481 | sizeof(*sparse_arguments)); |
| 482 | if (sparse_arguments == (double *) NULL) { |
| 483 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 484 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 485 | return( (Image *)NULL); |
| 486 | } |
| 487 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 488 | sizeof(*sparse_arguments)); |
| 489 | p=arguments; |
| 490 | x=0; |
| 491 | while( *p != '\0' && x < number_arguments ) { |
| 492 | /* X coordinate */ |
| 493 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 494 | if ( token[0] == '\0' ) break; |
| 495 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 496 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 497 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 498 | "Color found, instead of X-coord"); |
| 499 | error = MagickTrue; |
| 500 | break; |
| 501 | } |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 502 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 503 | /* Y coordinate */ |
| 504 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 505 | if ( token[0] == '\0' ) break; |
| 506 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 507 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 508 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 509 | "Color found, instead of Y-coord"); |
| 510 | error = MagickTrue; |
| 511 | break; |
| 512 | } |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 513 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 514 | /* color values for this control point */ |
| 515 | #if 0 |
| 516 | if ( (color_from_image ) { |
| 517 | /* get color from image */ |
| 518 | /* HOW??? */ |
| 519 | } |
| 520 | else |
| 521 | #endif |
| 522 | { |
| 523 | /* color name or function given in string argument */ |
| 524 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 525 | if ( token[0] == '\0' ) break; |
| 526 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 527 | /* Color string given */ |
| 528 | (void) QueryMagickColor(token,&color,exception); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 529 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 530 | sparse_arguments[x++] = QuantumScale*color.red; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 531 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 532 | sparse_arguments[x++] = QuantumScale*color.green; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 533 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 534 | sparse_arguments[x++] = QuantumScale*color.blue; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 535 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 536 | (image->colorspace == CMYKColorspace)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 537 | sparse_arguments[x++] = QuantumScale*color.black; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 538 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 539 | (image->matte != MagickFalse)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 540 | sparse_arguments[x++] = QuantumScale*color.alpha; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 541 | } |
| 542 | else { |
| 543 | /* Colors given as a set of floating point values - experimental */ |
| 544 | /* NB: token contains the first floating point value to use! */ |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 545 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 546 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 547 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 548 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 549 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 550 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 551 | token[0] = ','; /* used this token - get another */ |
| 552 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 553 | if ((GetPixelGreenTraits(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 ((GetPixelBlueTraits(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 (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 570 | (image->colorspace == CMYKColorspace)) |
| 571 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 572 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 573 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 574 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 575 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 576 | token[0] = ','; /* used this token - get another */ |
| 577 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 578 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 579 | (image->matte != MagickFalse)) |
| 580 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 581 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 582 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 583 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 584 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 585 | token[0] = ','; /* used this token - get another */ |
| 586 | } |
| 587 | } |
| 588 | } |
| 589 | } |
| 590 | if ( number_arguments != x && !error ) { |
| 591 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
| 592 | "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error"); |
| 593 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 594 | return( (Image *)NULL); |
| 595 | } |
| 596 | if ( error ) |
| 597 | return( (Image *)NULL); |
| 598 | |
| 599 | /* Call the Interpolation function with the parsed arguments */ |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 600 | sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, |
| 601 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 602 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 603 | return( sparse_image ); |
| 604 | } |
| 605 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 606 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 607 | const char **argv,Image **image,ExceptionInfo *exception) |
| 608 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 609 | ChannelType |
| 610 | channel; |
| 611 | |
| 612 | const char |
| 613 | *format, |
| 614 | *option; |
| 615 | |
| 616 | DrawInfo |
| 617 | *draw_info; |
| 618 | |
| 619 | GeometryInfo |
| 620 | geometry_info; |
| 621 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 622 | Image |
| 623 | *region_image; |
| 624 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 625 | ImageInfo |
| 626 | *mogrify_info; |
| 627 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 628 | MagickStatusType |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 629 | status; |
| 630 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 631 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 632 | fill; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 633 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 634 | MagickStatusType |
| 635 | flags; |
| 636 | |
| 637 | QuantizeInfo |
| 638 | *quantize_info; |
| 639 | |
| 640 | RectangleInfo |
| 641 | geometry, |
| 642 | region_geometry; |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame] | 643 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 644 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 645 | i; |
| 646 | |
| 647 | /* |
| 648 | Initialize method variables. |
| 649 | */ |
| 650 | assert(image_info != (const ImageInfo *) NULL); |
| 651 | assert(image_info->signature == MagickSignature); |
| 652 | assert(image != (Image **) NULL); |
| 653 | assert((*image)->signature == MagickSignature); |
| 654 | if ((*image)->debug != MagickFalse) |
| 655 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); |
| 656 | if (argc < 0) |
| 657 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 658 | mogrify_info=CloneImageInfo(image_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 659 | draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL); |
| 660 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 661 | SetGeometryInfo(&geometry_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 662 | GetPixelInfo(*image,&fill); |
| 663 | SetPixelInfoPacket(*image,&(*image)->background_color,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 664 | channel=mogrify_info->channel; |
| 665 | format=GetImageOption(mogrify_info,"format"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 666 | SetGeometry(*image,®ion_geometry); |
| 667 | region_image=NewImageList(); |
| 668 | /* |
| 669 | Transmogrify the image. |
| 670 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 671 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 672 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 673 | Image |
| 674 | *mogrify_image; |
| 675 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 676 | ssize_t |
| 677 | count; |
| 678 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 679 | option=argv[i]; |
| 680 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 681 | continue; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 682 | count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option), |
| 683 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 684 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 685 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 686 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 687 | mogrify_image=(Image *)NULL; |
| 688 | switch (*(option+1)) |
| 689 | { |
| 690 | case 'a': |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 691 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 692 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 693 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 694 | /* |
| 695 | Adaptive blur image. |
| 696 | */ |
| 697 | (void) SyncImageSettings(mogrify_info,*image); |
| 698 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 699 | if ((flags & SigmaValue) == 0) |
| 700 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 701 | mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho, |
| 702 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 703 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 704 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 705 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 706 | { |
| 707 | /* |
| 708 | Adaptive resize image. |
| 709 | */ |
| 710 | (void) SyncImageSettings(mogrify_info,*image); |
| 711 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 712 | mogrify_image=AdaptiveResizeImage(*image,geometry.width, |
| 713 | geometry.height,exception); |
| 714 | break; |
| 715 | } |
| 716 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 717 | { |
| 718 | /* |
| 719 | Adaptive sharpen image. |
| 720 | */ |
| 721 | (void) SyncImageSettings(mogrify_info,*image); |
| 722 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 723 | if ((flags & SigmaValue) == 0) |
| 724 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 725 | mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho, |
| 726 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 727 | break; |
| 728 | } |
| 729 | if (LocaleCompare("affine",option+1) == 0) |
| 730 | { |
| 731 | /* |
| 732 | Affine matrix. |
| 733 | */ |
| 734 | if (*option == '+') |
| 735 | { |
| 736 | GetAffineMatrix(&draw_info->affine); |
| 737 | break; |
| 738 | } |
| 739 | (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); |
| 740 | break; |
| 741 | } |
| 742 | if (LocaleCompare("alpha",option+1) == 0) |
| 743 | { |
| 744 | AlphaChannelType |
| 745 | alpha_type; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 746 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 747 | (void) SyncImageSettings(mogrify_info,*image); |
| 748 | alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions, |
| 749 | MagickFalse,argv[i+1]); |
| 750 | (void) SetImageAlphaChannel(*image,alpha_type); |
| 751 | InheritException(exception,&(*image)->exception); |
| 752 | break; |
| 753 | } |
| 754 | if (LocaleCompare("annotate",option+1) == 0) |
| 755 | { |
| 756 | char |
| 757 | *text, |
| 758 | geometry[MaxTextExtent]; |
| 759 | |
| 760 | /* |
| 761 | Annotate image. |
| 762 | */ |
| 763 | (void) SyncImageSettings(mogrify_info,*image); |
| 764 | SetGeometryInfo(&geometry_info); |
| 765 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 766 | if ((flags & SigmaValue) == 0) |
| 767 | geometry_info.sigma=geometry_info.rho; |
| 768 | text=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 769 | InheritException(exception,&(*image)->exception); |
| 770 | if (text == (char *) NULL) |
| 771 | break; |
| 772 | (void) CloneString(&draw_info->text,text); |
| 773 | text=DestroyString(text); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 774 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 775 | geometry_info.xi,geometry_info.psi); |
| 776 | (void) CloneString(&draw_info->geometry,geometry); |
| 777 | draw_info->affine.sx=cos(DegreesToRadians( |
| 778 | fmod(geometry_info.rho,360.0))); |
| 779 | draw_info->affine.rx=sin(DegreesToRadians( |
| 780 | fmod(geometry_info.rho,360.0))); |
| 781 | draw_info->affine.ry=(-sin(DegreesToRadians( |
| 782 | fmod(geometry_info.sigma,360.0)))); |
| 783 | draw_info->affine.sy=cos(DegreesToRadians( |
| 784 | fmod(geometry_info.sigma,360.0))); |
| 785 | (void) AnnotateImage(*image,draw_info); |
| 786 | InheritException(exception,&(*image)->exception); |
| 787 | break; |
| 788 | } |
| 789 | if (LocaleCompare("antialias",option+1) == 0) |
| 790 | { |
| 791 | draw_info->stroke_antialias=(*option == '-') ? MagickTrue : |
| 792 | MagickFalse; |
| 793 | draw_info->text_antialias=(*option == '-') ? MagickTrue : |
| 794 | MagickFalse; |
| 795 | break; |
| 796 | } |
| 797 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 798 | { |
| 799 | /* |
| 800 | Auto Adjust Gamma of image based on its mean |
| 801 | */ |
| 802 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | ab01585 | 2011-07-06 01:03:32 +0000 | [diff] [blame] | 803 | (void) AutoGammaImage(*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 804 | break; |
| 805 | } |
| 806 | if (LocaleCompare("auto-level",option+1) == 0) |
| 807 | { |
| 808 | /* |
| 809 | Perfectly Normalize (max/min stretch) the image |
| 810 | */ |
| 811 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | ab01585 | 2011-07-06 01:03:32 +0000 | [diff] [blame] | 812 | (void) AutoLevelImage(*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 813 | break; |
| 814 | } |
| 815 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 816 | { |
| 817 | (void) SyncImageSettings(mogrify_info,*image); |
| 818 | switch ((*image)->orientation) |
| 819 | { |
| 820 | case TopRightOrientation: |
| 821 | { |
| 822 | mogrify_image=FlopImage(*image,exception); |
| 823 | break; |
| 824 | } |
| 825 | case BottomRightOrientation: |
| 826 | { |
| 827 | mogrify_image=RotateImage(*image,180.0,exception); |
| 828 | break; |
| 829 | } |
| 830 | case BottomLeftOrientation: |
| 831 | { |
| 832 | mogrify_image=FlipImage(*image,exception); |
| 833 | break; |
| 834 | } |
| 835 | case LeftTopOrientation: |
| 836 | { |
| 837 | mogrify_image=TransposeImage(*image,exception); |
| 838 | break; |
| 839 | } |
| 840 | case RightTopOrientation: |
| 841 | { |
| 842 | mogrify_image=RotateImage(*image,90.0,exception); |
| 843 | break; |
| 844 | } |
| 845 | case RightBottomOrientation: |
| 846 | { |
| 847 | mogrify_image=TransverseImage(*image,exception); |
| 848 | break; |
| 849 | } |
| 850 | case LeftBottomOrientation: |
| 851 | { |
| 852 | mogrify_image=RotateImage(*image,270.0,exception); |
| 853 | break; |
| 854 | } |
| 855 | default: |
| 856 | break; |
| 857 | } |
| 858 | if (mogrify_image != (Image *) NULL) |
| 859 | mogrify_image->orientation=TopLeftOrientation; |
| 860 | break; |
| 861 | } |
| 862 | break; |
| 863 | } |
| 864 | case 'b': |
| 865 | { |
| 866 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 867 | { |
| 868 | /* |
| 869 | Black threshold image. |
| 870 | */ |
| 871 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 872 | (void) BlackThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 873 | InheritException(exception,&(*image)->exception); |
| 874 | break; |
| 875 | } |
| 876 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 877 | { |
| 878 | /* |
| 879 | Blue shift image. |
| 880 | */ |
| 881 | (void) SyncImageSettings(mogrify_info,*image); |
| 882 | geometry_info.rho=1.5; |
| 883 | if (*option == '-') |
| 884 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 885 | mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception); |
| 886 | break; |
| 887 | } |
| 888 | if (LocaleCompare("blur",option+1) == 0) |
| 889 | { |
| 890 | /* |
| 891 | Gaussian blur image. |
| 892 | */ |
| 893 | (void) SyncImageSettings(mogrify_info,*image); |
| 894 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 895 | if ((flags & SigmaValue) == 0) |
| 896 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 897 | mogrify_image=BlurImage(*image,geometry_info.rho, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 898 | geometry_info.sigma,exception); |
| 899 | break; |
| 900 | } |
| 901 | if (LocaleCompare("border",option+1) == 0) |
| 902 | { |
| 903 | /* |
| 904 | Surround image with a border of solid color. |
| 905 | */ |
| 906 | (void) SyncImageSettings(mogrify_info,*image); |
| 907 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 908 | if ((flags & SigmaValue) == 0) |
| 909 | geometry.height=geometry.width; |
| 910 | mogrify_image=BorderImage(*image,&geometry,exception); |
| 911 | break; |
| 912 | } |
| 913 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 914 | { |
| 915 | if (*option == '+') |
| 916 | { |
| 917 | (void) QueryColorDatabase(BorderColor,&draw_info->border_color, |
| 918 | exception); |
| 919 | break; |
| 920 | } |
| 921 | (void) QueryColorDatabase(argv[i+1],&draw_info->border_color, |
| 922 | exception); |
| 923 | break; |
| 924 | } |
| 925 | if (LocaleCompare("box",option+1) == 0) |
| 926 | { |
| 927 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 928 | exception); |
| 929 | break; |
| 930 | } |
| 931 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 932 | { |
| 933 | double |
| 934 | brightness, |
| 935 | contrast; |
| 936 | |
| 937 | GeometryInfo |
| 938 | geometry_info; |
| 939 | |
| 940 | MagickStatusType |
| 941 | flags; |
| 942 | |
| 943 | /* |
| 944 | Brightness / contrast image. |
| 945 | */ |
| 946 | (void) SyncImageSettings(mogrify_info,*image); |
| 947 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 948 | brightness=geometry_info.rho; |
| 949 | contrast=0.0; |
| 950 | if ((flags & SigmaValue) != 0) |
| 951 | contrast=geometry_info.sigma; |
cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 952 | (void) BrightnessContrastImage(*image,brightness,contrast); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 953 | InheritException(exception,&(*image)->exception); |
| 954 | break; |
| 955 | } |
| 956 | break; |
| 957 | } |
| 958 | case 'c': |
| 959 | { |
| 960 | if (LocaleCompare("cdl",option+1) == 0) |
| 961 | { |
| 962 | char |
| 963 | *color_correction_collection; |
| 964 | |
| 965 | /* |
| 966 | Color correct with a color decision list. |
| 967 | */ |
| 968 | (void) SyncImageSettings(mogrify_info,*image); |
| 969 | color_correction_collection=FileToString(argv[i+1],~0,exception); |
| 970 | if (color_correction_collection == (char *) NULL) |
| 971 | break; |
| 972 | (void) ColorDecisionListImage(*image,color_correction_collection); |
| 973 | InheritException(exception,&(*image)->exception); |
| 974 | break; |
| 975 | } |
| 976 | if (LocaleCompare("channel",option+1) == 0) |
| 977 | { |
| 978 | if (*option == '+') |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 979 | channel=DefaultChannels; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 980 | else |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 981 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 982 | SetPixelChannelMap(*image,channel); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 983 | break; |
| 984 | } |
| 985 | if (LocaleCompare("charcoal",option+1) == 0) |
| 986 | { |
| 987 | /* |
| 988 | Charcoal image. |
| 989 | */ |
| 990 | (void) SyncImageSettings(mogrify_info,*image); |
| 991 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 992 | if ((flags & SigmaValue) == 0) |
| 993 | geometry_info.sigma=1.0; |
| 994 | mogrify_image=CharcoalImage(*image,geometry_info.rho, |
| 995 | geometry_info.sigma,exception); |
| 996 | break; |
| 997 | } |
| 998 | if (LocaleCompare("chop",option+1) == 0) |
| 999 | { |
| 1000 | /* |
| 1001 | Chop the image. |
| 1002 | */ |
| 1003 | (void) SyncImageSettings(mogrify_info,*image); |
| 1004 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1005 | mogrify_image=ChopImage(*image,&geometry,exception); |
| 1006 | break; |
| 1007 | } |
| 1008 | if (LocaleCompare("clamp",option+1) == 0) |
| 1009 | { |
| 1010 | /* |
| 1011 | Clamp image. |
| 1012 | */ |
| 1013 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1014 | (void) ClampImage(*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1015 | InheritException(exception,&(*image)->exception); |
| 1016 | break; |
| 1017 | } |
| 1018 | if (LocaleCompare("clip",option+1) == 0) |
| 1019 | { |
| 1020 | (void) SyncImageSettings(mogrify_info,*image); |
| 1021 | if (*option == '+') |
| 1022 | { |
| 1023 | (void) SetImageClipMask(*image,(Image *) NULL); |
| 1024 | InheritException(exception,&(*image)->exception); |
| 1025 | break; |
| 1026 | } |
| 1027 | (void) ClipImage(*image); |
| 1028 | InheritException(exception,&(*image)->exception); |
| 1029 | break; |
| 1030 | } |
| 1031 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1032 | { |
| 1033 | CacheView |
| 1034 | *mask_view; |
| 1035 | |
| 1036 | Image |
| 1037 | *mask_image; |
| 1038 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1039 | register Quantum |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1040 | *restrict q; |
| 1041 | |
| 1042 | register ssize_t |
| 1043 | x; |
| 1044 | |
| 1045 | ssize_t |
| 1046 | y; |
| 1047 | |
| 1048 | (void) SyncImageSettings(mogrify_info,*image); |
| 1049 | if (*option == '+') |
| 1050 | { |
| 1051 | /* |
| 1052 | Remove a mask. |
| 1053 | */ |
| 1054 | (void) SetImageMask(*image,(Image *) NULL); |
| 1055 | InheritException(exception,&(*image)->exception); |
| 1056 | break; |
| 1057 | } |
| 1058 | /* |
| 1059 | Set the image mask. |
| 1060 | FUTURE: This Should Be a SetImageAlphaChannel() call, Or two. |
| 1061 | */ |
| 1062 | mask_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1063 | if (mask_image == (Image *) NULL) |
| 1064 | break; |
| 1065 | if (SetImageStorageClass(mask_image,DirectClass) == MagickFalse) |
| 1066 | return(MagickFalse); |
| 1067 | mask_view=AcquireCacheView(mask_image); |
| 1068 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1069 | { |
| 1070 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1071 | exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1072 | if (q == (const Quantum *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1073 | break; |
| 1074 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1075 | { |
| 1076 | if (mask_image->matte == MagickFalse) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1077 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 1078 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1079 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1080 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1081 | q+=GetPixelChannels(mask_image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1082 | } |
| 1083 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
| 1084 | break; |
| 1085 | } |
| 1086 | mask_view=DestroyCacheView(mask_view); |
| 1087 | mask_image->matte=MagickTrue; |
| 1088 | (void) SetImageClipMask(*image,mask_image); |
| 1089 | mask_image=DestroyImage(mask_image); |
| 1090 | InheritException(exception,&(*image)->exception); |
| 1091 | break; |
| 1092 | } |
| 1093 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1094 | { |
| 1095 | (void) SyncImageSettings(mogrify_info,*image); |
| 1096 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
| 1097 | MagickFalse); |
| 1098 | InheritException(exception,&(*image)->exception); |
| 1099 | break; |
| 1100 | } |
| 1101 | if (LocaleCompare("colorize",option+1) == 0) |
| 1102 | { |
| 1103 | /* |
| 1104 | Colorize the image. |
| 1105 | */ |
| 1106 | (void) SyncImageSettings(mogrify_info,*image); |
| 1107 | mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill, |
| 1108 | exception); |
| 1109 | break; |
| 1110 | } |
| 1111 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1112 | { |
| 1113 | KernelInfo |
| 1114 | *kernel; |
| 1115 | |
| 1116 | (void) SyncImageSettings(mogrify_info,*image); |
| 1117 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1118 | if (kernel == (KernelInfo *) NULL) |
| 1119 | break; |
| 1120 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 1121 | kernel=DestroyKernelInfo(kernel); |
| 1122 | break; |
| 1123 | } |
| 1124 | if (LocaleCompare("colors",option+1) == 0) |
| 1125 | { |
| 1126 | /* |
| 1127 | Reduce the number of colors in the image. |
| 1128 | */ |
| 1129 | (void) SyncImageSettings(mogrify_info,*image); |
| 1130 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
| 1131 | if (quantize_info->number_colors == 0) |
| 1132 | break; |
| 1133 | if (((*image)->storage_class == DirectClass) || |
| 1134 | (*image)->colors > quantize_info->number_colors) |
| 1135 | (void) QuantizeImage(quantize_info,*image); |
| 1136 | else |
| 1137 | (void) CompressImageColormap(*image); |
| 1138 | InheritException(exception,&(*image)->exception); |
| 1139 | break; |
| 1140 | } |
| 1141 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1142 | { |
| 1143 | ColorspaceType |
| 1144 | colorspace; |
| 1145 | |
| 1146 | (void) SyncImageSettings(mogrify_info,*image); |
| 1147 | if (*option == '+') |
| 1148 | { |
| 1149 | (void) TransformImageColorspace(*image,RGBColorspace); |
| 1150 | InheritException(exception,&(*image)->exception); |
| 1151 | break; |
| 1152 | } |
| 1153 | colorspace=(ColorspaceType) ParseCommandOption( |
| 1154 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 1155 | (void) TransformImageColorspace(*image,colorspace); |
| 1156 | InheritException(exception,&(*image)->exception); |
| 1157 | break; |
| 1158 | } |
| 1159 | if (LocaleCompare("contrast",option+1) == 0) |
| 1160 | { |
| 1161 | (void) SyncImageSettings(mogrify_info,*image); |
| 1162 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
| 1163 | MagickFalse); |
| 1164 | InheritException(exception,&(*image)->exception); |
| 1165 | break; |
| 1166 | } |
| 1167 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1168 | { |
| 1169 | double |
| 1170 | black_point, |
| 1171 | white_point; |
| 1172 | |
| 1173 | MagickStatusType |
| 1174 | flags; |
| 1175 | |
| 1176 | /* |
| 1177 | Contrast stretch image. |
| 1178 | */ |
| 1179 | (void) SyncImageSettings(mogrify_info,*image); |
| 1180 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1181 | black_point=geometry_info.rho; |
| 1182 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1183 | black_point; |
| 1184 | if ((flags & PercentValue) != 0) |
| 1185 | { |
| 1186 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1187 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1188 | } |
| 1189 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1190 | white_point; |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1191 | (void) ContrastStretchImage(*image,black_point,white_point); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1192 | InheritException(exception,&(*image)->exception); |
| 1193 | break; |
| 1194 | } |
| 1195 | if (LocaleCompare("convolve",option+1) == 0) |
| 1196 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1197 | KernelInfo |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame^] | 1198 | *kernel_info; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1199 | |
| 1200 | register ssize_t |
| 1201 | j; |
| 1202 | |
| 1203 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame^] | 1204 | kernel_info=AcquireKernelInfo(argv[i+1]); |
| 1205 | if (kernel_info == (KernelInfo *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1206 | break; |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame^] | 1207 | mogrify_image=FilterImage(*image,kernel_info,exception); |
| 1208 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1209 | break; |
| 1210 | } |
| 1211 | if (LocaleCompare("crop",option+1) == 0) |
| 1212 | { |
| 1213 | /* |
| 1214 | Crop a image to a smaller size |
| 1215 | */ |
| 1216 | (void) SyncImageSettings(mogrify_info,*image); |
| 1217 | #if 0 |
| 1218 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1219 | if (((geometry.width != 0) || (geometry.height != 0)) && |
| 1220 | ((flags & XValue) == 0) && ((flags & YValue) == 0)) |
| 1221 | break; |
| 1222 | #endif |
| 1223 | #if 0 |
| 1224 | mogrify_image=CloneImage(*image,0,0,MagickTrue,&(*image)->exception); |
| 1225 | mogrify_image->next = mogrify_image->previous = (Image *)NULL; |
| 1226 | (void) TransformImage(&mogrify_image,argv[i+1],(char *) NULL); |
| 1227 | InheritException(exception,&mogrify_image->exception); |
| 1228 | #else |
| 1229 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
| 1230 | #endif |
| 1231 | break; |
| 1232 | } |
| 1233 | if (LocaleCompare("cycle",option+1) == 0) |
| 1234 | { |
| 1235 | /* |
| 1236 | Cycle an image colormap. |
| 1237 | */ |
| 1238 | (void) SyncImageSettings(mogrify_info,*image); |
| 1239 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1])); |
| 1240 | InheritException(exception,&(*image)->exception); |
| 1241 | break; |
| 1242 | } |
| 1243 | break; |
| 1244 | } |
| 1245 | case 'd': |
| 1246 | { |
| 1247 | if (LocaleCompare("decipher",option+1) == 0) |
| 1248 | { |
| 1249 | StringInfo |
| 1250 | *passkey; |
| 1251 | |
| 1252 | /* |
| 1253 | Decipher pixels. |
| 1254 | */ |
| 1255 | (void) SyncImageSettings(mogrify_info,*image); |
| 1256 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1257 | if (passkey != (StringInfo *) NULL) |
| 1258 | { |
| 1259 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1260 | passkey=DestroyStringInfo(passkey); |
| 1261 | } |
| 1262 | break; |
| 1263 | } |
| 1264 | if (LocaleCompare("density",option+1) == 0) |
| 1265 | { |
| 1266 | /* |
| 1267 | Set image density. |
| 1268 | */ |
| 1269 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1270 | break; |
| 1271 | } |
| 1272 | if (LocaleCompare("depth",option+1) == 0) |
| 1273 | { |
| 1274 | (void) SyncImageSettings(mogrify_info,*image); |
| 1275 | if (*option == '+') |
| 1276 | { |
| 1277 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH); |
| 1278 | break; |
| 1279 | } |
| 1280 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1])); |
| 1281 | break; |
| 1282 | } |
| 1283 | if (LocaleCompare("deskew",option+1) == 0) |
| 1284 | { |
| 1285 | double |
| 1286 | threshold; |
| 1287 | |
| 1288 | /* |
| 1289 | Straighten the image. |
| 1290 | */ |
| 1291 | (void) SyncImageSettings(mogrify_info,*image); |
| 1292 | if (*option == '+') |
| 1293 | threshold=40.0*QuantumRange/100.0; |
| 1294 | else |
| 1295 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 1296 | mogrify_image=DeskewImage(*image,threshold,exception); |
| 1297 | break; |
| 1298 | } |
| 1299 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1300 | { |
| 1301 | /* |
| 1302 | Reduce the speckles within an image. |
| 1303 | */ |
| 1304 | (void) SyncImageSettings(mogrify_info,*image); |
| 1305 | mogrify_image=DespeckleImage(*image,exception); |
| 1306 | break; |
| 1307 | } |
| 1308 | if (LocaleCompare("display",option+1) == 0) |
| 1309 | { |
| 1310 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1311 | break; |
| 1312 | } |
| 1313 | if (LocaleCompare("distort",option+1) == 0) |
| 1314 | { |
| 1315 | char |
| 1316 | *args, |
| 1317 | token[MaxTextExtent]; |
| 1318 | |
| 1319 | const char |
| 1320 | *p; |
| 1321 | |
| 1322 | DistortImageMethod |
| 1323 | method; |
| 1324 | |
| 1325 | double |
| 1326 | *arguments; |
| 1327 | |
| 1328 | register ssize_t |
| 1329 | x; |
| 1330 | |
| 1331 | size_t |
| 1332 | number_arguments; |
| 1333 | |
| 1334 | /* |
| 1335 | Distort image. |
| 1336 | */ |
| 1337 | (void) SyncImageSettings(mogrify_info,*image); |
| 1338 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, |
| 1339 | MagickFalse,argv[i+1]); |
| 1340 | if ( method == ResizeDistortion ) |
| 1341 | { |
| 1342 | /* Special Case - Argument is actually a resize geometry! |
| 1343 | ** Convert that to an appropriate distortion argument array. |
| 1344 | */ |
| 1345 | double |
| 1346 | resize_args[2]; |
| 1347 | (void) ParseRegionGeometry(*image,argv[i+2],&geometry, |
| 1348 | exception); |
| 1349 | resize_args[0]=(double)geometry.width; |
| 1350 | resize_args[1]=(double)geometry.height; |
| 1351 | mogrify_image=DistortImage(*image,method,(size_t)2, |
| 1352 | resize_args,MagickTrue,exception); |
| 1353 | break; |
| 1354 | } |
| 1355 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 1356 | InheritException(exception,&(*image)->exception); |
| 1357 | if (args == (char *) NULL) |
| 1358 | break; |
| 1359 | p=(char *) args; |
| 1360 | for (x=0; *p != '\0'; x++) |
| 1361 | { |
| 1362 | GetMagickToken(p,&p,token); |
| 1363 | if (*token == ',') |
| 1364 | GetMagickToken(p,&p,token); |
| 1365 | } |
| 1366 | number_arguments=(size_t) x; |
| 1367 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1368 | sizeof(*arguments)); |
| 1369 | if (arguments == (double *) NULL) |
| 1370 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1371 | "MemoryAllocationFailed",(*image)->filename); |
| 1372 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1373 | sizeof(*arguments)); |
| 1374 | p=(char *) args; |
| 1375 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 1376 | { |
| 1377 | GetMagickToken(p,&p,token); |
| 1378 | if (*token == ',') |
| 1379 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1380 | arguments[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1381 | } |
| 1382 | args=DestroyString(args); |
| 1383 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
| 1384 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1385 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1386 | break; |
| 1387 | } |
| 1388 | if (LocaleCompare("dither",option+1) == 0) |
| 1389 | { |
| 1390 | if (*option == '+') |
| 1391 | { |
| 1392 | quantize_info->dither=MagickFalse; |
| 1393 | break; |
| 1394 | } |
| 1395 | quantize_info->dither=MagickTrue; |
| 1396 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
| 1397 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1398 | if (quantize_info->dither_method == NoDitherMethod) |
| 1399 | quantize_info->dither=MagickFalse; |
| 1400 | break; |
| 1401 | } |
| 1402 | if (LocaleCompare("draw",option+1) == 0) |
| 1403 | { |
| 1404 | /* |
| 1405 | Draw image. |
| 1406 | */ |
| 1407 | (void) SyncImageSettings(mogrify_info,*image); |
| 1408 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
| 1409 | (void) DrawImage(*image,draw_info); |
| 1410 | InheritException(exception,&(*image)->exception); |
| 1411 | break; |
| 1412 | } |
| 1413 | break; |
| 1414 | } |
| 1415 | case 'e': |
| 1416 | { |
| 1417 | if (LocaleCompare("edge",option+1) == 0) |
| 1418 | { |
| 1419 | /* |
| 1420 | Enhance edges in the image. |
| 1421 | */ |
| 1422 | (void) SyncImageSettings(mogrify_info,*image); |
| 1423 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1424 | if ((flags & SigmaValue) == 0) |
| 1425 | geometry_info.sigma=1.0; |
| 1426 | mogrify_image=EdgeImage(*image,geometry_info.rho,exception); |
| 1427 | break; |
| 1428 | } |
| 1429 | if (LocaleCompare("emboss",option+1) == 0) |
| 1430 | { |
| 1431 | /* |
| 1432 | Gaussian embossen image. |
| 1433 | */ |
| 1434 | (void) SyncImageSettings(mogrify_info,*image); |
| 1435 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1436 | if ((flags & SigmaValue) == 0) |
| 1437 | geometry_info.sigma=1.0; |
| 1438 | mogrify_image=EmbossImage(*image,geometry_info.rho, |
| 1439 | geometry_info.sigma,exception); |
| 1440 | break; |
| 1441 | } |
| 1442 | if (LocaleCompare("encipher",option+1) == 0) |
| 1443 | { |
| 1444 | StringInfo |
| 1445 | *passkey; |
| 1446 | |
| 1447 | /* |
| 1448 | Encipher pixels. |
| 1449 | */ |
| 1450 | (void) SyncImageSettings(mogrify_info,*image); |
| 1451 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1452 | if (passkey != (StringInfo *) NULL) |
| 1453 | { |
| 1454 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1455 | passkey=DestroyStringInfo(passkey); |
| 1456 | } |
| 1457 | break; |
| 1458 | } |
| 1459 | if (LocaleCompare("encoding",option+1) == 0) |
| 1460 | { |
| 1461 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1462 | break; |
| 1463 | } |
| 1464 | if (LocaleCompare("enhance",option+1) == 0) |
| 1465 | { |
| 1466 | /* |
| 1467 | Enhance image. |
| 1468 | */ |
| 1469 | (void) SyncImageSettings(mogrify_info,*image); |
| 1470 | mogrify_image=EnhanceImage(*image,exception); |
| 1471 | break; |
| 1472 | } |
| 1473 | if (LocaleCompare("equalize",option+1) == 0) |
| 1474 | { |
| 1475 | /* |
| 1476 | Equalize image. |
| 1477 | */ |
| 1478 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1479 | (void) EqualizeImage(*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1480 | InheritException(exception,&(*image)->exception); |
| 1481 | break; |
| 1482 | } |
| 1483 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1484 | { |
| 1485 | double |
| 1486 | constant; |
| 1487 | |
| 1488 | MagickEvaluateOperator |
| 1489 | op; |
| 1490 | |
| 1491 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1492 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 1493 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1494 | constant=SiPrefixToDouble(argv[i+2],QuantumRange); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1495 | (void) EvaluateImage(*image,op,constant,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1496 | break; |
| 1497 | } |
| 1498 | if (LocaleCompare("extent",option+1) == 0) |
| 1499 | { |
| 1500 | /* |
| 1501 | Set the image extent. |
| 1502 | */ |
| 1503 | (void) SyncImageSettings(mogrify_info,*image); |
| 1504 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1505 | if (geometry.width == 0) |
| 1506 | geometry.width=(*image)->columns; |
| 1507 | if (geometry.height == 0) |
| 1508 | geometry.height=(*image)->rows; |
| 1509 | mogrify_image=ExtentImage(*image,&geometry,exception); |
| 1510 | break; |
| 1511 | } |
| 1512 | break; |
| 1513 | } |
| 1514 | case 'f': |
| 1515 | { |
| 1516 | if (LocaleCompare("family",option+1) == 0) |
| 1517 | { |
| 1518 | if (*option == '+') |
| 1519 | { |
| 1520 | if (draw_info->family != (char *) NULL) |
| 1521 | draw_info->family=DestroyString(draw_info->family); |
| 1522 | break; |
| 1523 | } |
| 1524 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1525 | break; |
| 1526 | } |
| 1527 | if (LocaleCompare("features",option+1) == 0) |
| 1528 | { |
| 1529 | if (*option == '+') |
| 1530 | { |
| 1531 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1532 | break; |
| 1533 | } |
| 1534 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1535 | break; |
| 1536 | } |
| 1537 | if (LocaleCompare("fill",option+1) == 0) |
| 1538 | { |
| 1539 | ExceptionInfo |
| 1540 | *sans; |
| 1541 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1542 | GetPixelInfo(*image,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1543 | if (*option == '+') |
| 1544 | { |
| 1545 | (void) QueryMagickColor("none",&fill,exception); |
| 1546 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 1547 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1548 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1549 | break; |
| 1550 | } |
| 1551 | sans=AcquireExceptionInfo(); |
| 1552 | (void) QueryMagickColor(argv[i+1],&fill,sans); |
| 1553 | status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans); |
| 1554 | sans=DestroyExceptionInfo(sans); |
| 1555 | if (status == MagickFalse) |
| 1556 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 1557 | exception); |
| 1558 | break; |
| 1559 | } |
| 1560 | if (LocaleCompare("flip",option+1) == 0) |
| 1561 | { |
| 1562 | /* |
| 1563 | Flip image scanlines. |
| 1564 | */ |
| 1565 | (void) SyncImageSettings(mogrify_info,*image); |
| 1566 | mogrify_image=FlipImage(*image,exception); |
| 1567 | break; |
| 1568 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1569 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1570 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1571 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1572 | target; |
| 1573 | |
| 1574 | /* |
| 1575 | Floodfill image. |
| 1576 | */ |
| 1577 | (void) SyncImageSettings(mogrify_info,*image); |
| 1578 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1579 | (void) QueryMagickColor(argv[i+2],&target,exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1580 | (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x, |
| 1581 | geometry.y,*option == '-' ? MagickFalse : MagickTrue); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1582 | InheritException(exception,&(*image)->exception); |
| 1583 | break; |
| 1584 | } |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1585 | if (LocaleCompare("flop",option+1) == 0) |
| 1586 | { |
| 1587 | /* |
| 1588 | Flop image scanlines. |
| 1589 | */ |
| 1590 | (void) SyncImageSettings(mogrify_info,*image); |
| 1591 | mogrify_image=FlopImage(*image,exception); |
| 1592 | break; |
| 1593 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1594 | if (LocaleCompare("font",option+1) == 0) |
| 1595 | { |
| 1596 | if (*option == '+') |
| 1597 | { |
| 1598 | if (draw_info->font != (char *) NULL) |
| 1599 | draw_info->font=DestroyString(draw_info->font); |
| 1600 | break; |
| 1601 | } |
| 1602 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1603 | break; |
| 1604 | } |
| 1605 | if (LocaleCompare("format",option+1) == 0) |
| 1606 | { |
| 1607 | format=argv[i+1]; |
| 1608 | break; |
| 1609 | } |
| 1610 | if (LocaleCompare("frame",option+1) == 0) |
| 1611 | { |
| 1612 | FrameInfo |
| 1613 | frame_info; |
| 1614 | |
| 1615 | /* |
| 1616 | Surround image with an ornamental border. |
| 1617 | */ |
| 1618 | (void) SyncImageSettings(mogrify_info,*image); |
| 1619 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1620 | frame_info.width=geometry.width; |
| 1621 | frame_info.height=geometry.height; |
| 1622 | if ((flags & HeightValue) == 0) |
| 1623 | frame_info.height=geometry.width; |
| 1624 | frame_info.outer_bevel=geometry.x; |
| 1625 | frame_info.inner_bevel=geometry.y; |
| 1626 | frame_info.x=(ssize_t) frame_info.width; |
| 1627 | frame_info.y=(ssize_t) frame_info.height; |
| 1628 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1629 | frame_info.height=(*image)->rows+2*frame_info.height; |
| 1630 | mogrify_image=FrameImage(*image,&frame_info,exception); |
| 1631 | break; |
| 1632 | } |
| 1633 | if (LocaleCompare("function",option+1) == 0) |
| 1634 | { |
| 1635 | char |
| 1636 | *arguments, |
| 1637 | token[MaxTextExtent]; |
| 1638 | |
| 1639 | const char |
| 1640 | *p; |
| 1641 | |
| 1642 | double |
| 1643 | *parameters; |
| 1644 | |
| 1645 | MagickFunction |
| 1646 | function; |
| 1647 | |
| 1648 | register ssize_t |
| 1649 | x; |
| 1650 | |
| 1651 | size_t |
| 1652 | number_parameters; |
| 1653 | |
| 1654 | /* |
| 1655 | Function Modify Image Values |
| 1656 | */ |
| 1657 | (void) SyncImageSettings(mogrify_info,*image); |
| 1658 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, |
| 1659 | MagickFalse,argv[i+1]); |
| 1660 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 1661 | InheritException(exception,&(*image)->exception); |
| 1662 | if (arguments == (char *) NULL) |
| 1663 | break; |
| 1664 | p=(char *) arguments; |
| 1665 | for (x=0; *p != '\0'; x++) |
| 1666 | { |
| 1667 | GetMagickToken(p,&p,token); |
| 1668 | if (*token == ',') |
| 1669 | GetMagickToken(p,&p,token); |
| 1670 | } |
| 1671 | number_parameters=(size_t) x; |
| 1672 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1673 | sizeof(*parameters)); |
| 1674 | if (parameters == (double *) NULL) |
| 1675 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1676 | "MemoryAllocationFailed",(*image)->filename); |
| 1677 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1678 | sizeof(*parameters)); |
| 1679 | p=(char *) arguments; |
| 1680 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
| 1681 | { |
| 1682 | GetMagickToken(p,&p,token); |
| 1683 | if (*token == ',') |
| 1684 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1685 | parameters[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1686 | } |
| 1687 | arguments=DestroyString(arguments); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1688 | (void) FunctionImage(*image,function,number_parameters,parameters, |
| 1689 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1690 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1691 | break; |
| 1692 | } |
| 1693 | break; |
| 1694 | } |
| 1695 | case 'g': |
| 1696 | { |
| 1697 | if (LocaleCompare("gamma",option+1) == 0) |
| 1698 | { |
| 1699 | /* |
| 1700 | Gamma image. |
| 1701 | */ |
| 1702 | (void) SyncImageSettings(mogrify_info,*image); |
| 1703 | if (*option == '+') |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1704 | (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1705 | else |
| 1706 | { |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1707 | (void) GammaImage(*image,InterpretLocaleValue(argv[i+1], |
| 1708 | (char **) NULL)); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1709 | InheritException(exception,&(*image)->exception); |
| 1710 | } |
| 1711 | break; |
| 1712 | } |
| 1713 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1714 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1715 | { |
| 1716 | /* |
| 1717 | Gaussian blur image. |
| 1718 | */ |
| 1719 | (void) SyncImageSettings(mogrify_info,*image); |
| 1720 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1721 | if ((flags & SigmaValue) == 0) |
| 1722 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1723 | mogrify_image=GaussianBlurImage(*image,geometry_info.rho, |
| 1724 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1725 | break; |
| 1726 | } |
| 1727 | if (LocaleCompare("geometry",option+1) == 0) |
| 1728 | { |
| 1729 | /* |
| 1730 | Record Image offset, Resize last image. |
| 1731 | */ |
| 1732 | (void) SyncImageSettings(mogrify_info,*image); |
| 1733 | if (*option == '+') |
| 1734 | { |
| 1735 | if ((*image)->geometry != (char *) NULL) |
| 1736 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1737 | break; |
| 1738 | } |
| 1739 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1740 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1741 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1742 | else |
| 1743 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 1744 | (*image)->filter,(*image)->blur,exception); |
| 1745 | break; |
| 1746 | } |
| 1747 | if (LocaleCompare("gravity",option+1) == 0) |
| 1748 | { |
| 1749 | if (*option == '+') |
| 1750 | { |
| 1751 | draw_info->gravity=UndefinedGravity; |
| 1752 | break; |
| 1753 | } |
| 1754 | draw_info->gravity=(GravityType) ParseCommandOption( |
| 1755 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1756 | break; |
| 1757 | } |
| 1758 | break; |
| 1759 | } |
| 1760 | case 'h': |
| 1761 | { |
| 1762 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1763 | { |
| 1764 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1765 | break; |
| 1766 | } |
| 1767 | break; |
| 1768 | } |
| 1769 | case 'i': |
| 1770 | { |
| 1771 | if (LocaleCompare("identify",option+1) == 0) |
| 1772 | { |
| 1773 | char |
| 1774 | *text; |
| 1775 | |
| 1776 | (void) SyncImageSettings(mogrify_info,*image); |
| 1777 | if (format == (char *) NULL) |
| 1778 | { |
| 1779 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose); |
| 1780 | InheritException(exception,&(*image)->exception); |
| 1781 | break; |
| 1782 | } |
| 1783 | text=InterpretImageProperties(mogrify_info,*image,format); |
| 1784 | InheritException(exception,&(*image)->exception); |
| 1785 | if (text == (char *) NULL) |
| 1786 | break; |
| 1787 | (void) fputs(text,stdout); |
| 1788 | (void) fputc('\n',stdout); |
| 1789 | text=DestroyString(text); |
| 1790 | break; |
| 1791 | } |
| 1792 | if (LocaleCompare("implode",option+1) == 0) |
| 1793 | { |
| 1794 | /* |
| 1795 | Implode image. |
| 1796 | */ |
| 1797 | (void) SyncImageSettings(mogrify_info,*image); |
| 1798 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1799 | mogrify_image=ImplodeImage(*image,geometry_info.rho,exception); |
| 1800 | break; |
| 1801 | } |
| 1802 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1803 | { |
| 1804 | if (*option == '+') |
| 1805 | (void) ParseGeometry("0",&geometry_info); |
| 1806 | else |
| 1807 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1808 | draw_info->interline_spacing=geometry_info.rho; |
| 1809 | break; |
| 1810 | } |
| 1811 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1812 | { |
| 1813 | if (*option == '+') |
| 1814 | (void) ParseGeometry("0",&geometry_info); |
| 1815 | else |
| 1816 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1817 | draw_info->interword_spacing=geometry_info.rho; |
| 1818 | break; |
| 1819 | } |
| 1820 | break; |
| 1821 | } |
| 1822 | case 'k': |
| 1823 | { |
| 1824 | if (LocaleCompare("kerning",option+1) == 0) |
| 1825 | { |
| 1826 | if (*option == '+') |
| 1827 | (void) ParseGeometry("0",&geometry_info); |
| 1828 | else |
| 1829 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1830 | draw_info->kerning=geometry_info.rho; |
| 1831 | break; |
| 1832 | } |
| 1833 | break; |
| 1834 | } |
| 1835 | case 'l': |
| 1836 | { |
| 1837 | if (LocaleCompare("lat",option+1) == 0) |
| 1838 | { |
| 1839 | /* |
| 1840 | Local adaptive threshold image. |
| 1841 | */ |
| 1842 | (void) SyncImageSettings(mogrify_info,*image); |
| 1843 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1844 | if ((flags & PercentValue) != 0) |
| 1845 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 1846 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
| 1847 | geometry_info.rho,(size_t) geometry_info.sigma,(ssize_t) |
| 1848 | geometry_info.xi,exception); |
| 1849 | break; |
| 1850 | } |
| 1851 | if (LocaleCompare("level",option+1) == 0) |
| 1852 | { |
| 1853 | MagickRealType |
| 1854 | black_point, |
| 1855 | gamma, |
| 1856 | white_point; |
| 1857 | |
| 1858 | MagickStatusType |
| 1859 | flags; |
| 1860 | |
| 1861 | /* |
| 1862 | Parse levels. |
| 1863 | */ |
| 1864 | (void) SyncImageSettings(mogrify_info,*image); |
| 1865 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1866 | black_point=geometry_info.rho; |
| 1867 | white_point=(MagickRealType) QuantumRange; |
| 1868 | if ((flags & SigmaValue) != 0) |
| 1869 | white_point=geometry_info.sigma; |
| 1870 | gamma=1.0; |
| 1871 | if ((flags & XiValue) != 0) |
| 1872 | gamma=geometry_info.xi; |
| 1873 | if ((flags & PercentValue) != 0) |
| 1874 | { |
| 1875 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 1876 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 1877 | } |
| 1878 | if ((flags & SigmaValue) == 0) |
| 1879 | white_point=(MagickRealType) QuantumRange-black_point; |
| 1880 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1881 | (void) LevelizeImage(*image,black_point,white_point,gamma); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1882 | else |
cristy | f89cb1d | 2011-07-07 01:24:37 +0000 | [diff] [blame] | 1883 | (void) LevelImage(*image,black_point,white_point,gamma); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1884 | InheritException(exception,&(*image)->exception); |
| 1885 | break; |
| 1886 | } |
| 1887 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1888 | { |
| 1889 | char |
| 1890 | token[MaxTextExtent]; |
| 1891 | |
| 1892 | const char |
| 1893 | *p; |
| 1894 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1895 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1896 | black_point, |
| 1897 | white_point; |
| 1898 | |
| 1899 | p=(const char *) argv[i+1]; |
| 1900 | GetMagickToken(p,&p,token); /* get black point color */ |
| 1901 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1902 | (void) QueryMagickColor(token,&black_point,exception); |
| 1903 | else |
| 1904 | (void) QueryMagickColor("#000000",&black_point,exception); |
| 1905 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1906 | GetMagickToken(p,&p,token); |
| 1907 | if (*token == '\0') |
| 1908 | white_point=black_point; /* set everything to that color */ |
| 1909 | else |
| 1910 | { |
| 1911 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 1912 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 1913 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1914 | (void) QueryMagickColor(token,&white_point,exception); |
| 1915 | else |
| 1916 | (void) QueryMagickColor("#ffffff",&white_point,exception); |
| 1917 | } |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 1918 | (void) LevelImageColors(*image,&black_point,&white_point, |
| 1919 | *option == '+' ? MagickTrue : MagickFalse); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1920 | break; |
| 1921 | } |
| 1922 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 1923 | { |
| 1924 | double |
| 1925 | black_point, |
| 1926 | white_point; |
| 1927 | |
| 1928 | MagickStatusType |
| 1929 | flags; |
| 1930 | |
| 1931 | (void) SyncImageSettings(mogrify_info,*image); |
| 1932 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1933 | black_point=geometry_info.rho; |
| 1934 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 1935 | if ((flags & SigmaValue) != 0) |
| 1936 | white_point=geometry_info.sigma; |
| 1937 | if ((flags & PercentValue) != 0) |
| 1938 | { |
| 1939 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1940 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1941 | } |
| 1942 | if ((flags & SigmaValue) == 0) |
| 1943 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1944 | black_point; |
| 1945 | (void) LinearStretchImage(*image,black_point,white_point); |
| 1946 | InheritException(exception,&(*image)->exception); |
| 1947 | break; |
| 1948 | } |
| 1949 | if (LocaleCompare("linewidth",option+1) == 0) |
| 1950 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1951 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 1952 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1953 | break; |
| 1954 | } |
| 1955 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 1956 | { |
| 1957 | /* |
| 1958 | Liquid rescale image. |
| 1959 | */ |
| 1960 | (void) SyncImageSettings(mogrify_info,*image); |
| 1961 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1962 | if ((flags & XValue) == 0) |
| 1963 | geometry.x=1; |
| 1964 | if ((flags & YValue) == 0) |
| 1965 | geometry.y=0; |
| 1966 | mogrify_image=LiquidRescaleImage(*image,geometry.width, |
| 1967 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 1968 | break; |
| 1969 | } |
| 1970 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 1971 | { |
| 1972 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1973 | break; |
| 1974 | } |
| 1975 | break; |
| 1976 | } |
| 1977 | case 'm': |
| 1978 | { |
| 1979 | if (LocaleCompare("map",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1980 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1981 | Image |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1982 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1983 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1984 | /* |
| 1985 | Transform image colors to match this set of colors. |
| 1986 | */ |
| 1987 | (void) SyncImageSettings(mogrify_info,*image); |
| 1988 | if (*option == '+') |
| 1989 | break; |
| 1990 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1991 | if (remap_image == (Image *) NULL) |
| 1992 | break; |
| 1993 | (void) RemapImage(quantize_info,*image,remap_image); |
| 1994 | InheritException(exception,&(*image)->exception); |
| 1995 | remap_image=DestroyImage(remap_image); |
| 1996 | break; |
| 1997 | } |
| 1998 | if (LocaleCompare("mask",option+1) == 0) |
| 1999 | { |
| 2000 | Image |
| 2001 | *mask; |
| 2002 | |
| 2003 | (void) SyncImageSettings(mogrify_info,*image); |
| 2004 | if (*option == '+') |
| 2005 | { |
| 2006 | /* |
| 2007 | Remove a mask. |
| 2008 | */ |
| 2009 | (void) SetImageMask(*image,(Image *) NULL); |
| 2010 | InheritException(exception,&(*image)->exception); |
| 2011 | break; |
| 2012 | } |
| 2013 | /* |
| 2014 | Set the image mask. |
| 2015 | */ |
| 2016 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2017 | if (mask == (Image *) NULL) |
| 2018 | break; |
| 2019 | (void) SetImageMask(*image,mask); |
| 2020 | mask=DestroyImage(mask); |
| 2021 | InheritException(exception,&(*image)->exception); |
| 2022 | break; |
| 2023 | } |
| 2024 | if (LocaleCompare("matte",option+1) == 0) |
| 2025 | { |
| 2026 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
| 2027 | SetAlphaChannel : DeactivateAlphaChannel ); |
| 2028 | InheritException(exception,&(*image)->exception); |
| 2029 | break; |
| 2030 | } |
| 2031 | if (LocaleCompare("median",option+1) == 0) |
| 2032 | { |
| 2033 | /* |
| 2034 | Median filter image. |
| 2035 | */ |
| 2036 | (void) SyncImageSettings(mogrify_info,*image); |
| 2037 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2038 | mogrify_image=StatisticImage(*image,MedianStatistic,(size_t) |
| 2039 | geometry_info.rho,(size_t) geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2040 | break; |
| 2041 | } |
| 2042 | if (LocaleCompare("mode",option+1) == 0) |
| 2043 | { |
| 2044 | /* |
| 2045 | Mode image. |
| 2046 | */ |
| 2047 | (void) SyncImageSettings(mogrify_info,*image); |
| 2048 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2049 | mogrify_image=StatisticImage(*image,ModeStatistic,(size_t) |
| 2050 | geometry_info.rho,(size_t) geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2051 | break; |
| 2052 | } |
| 2053 | if (LocaleCompare("modulate",option+1) == 0) |
| 2054 | { |
| 2055 | (void) SyncImageSettings(mogrify_info,*image); |
| 2056 | (void) ModulateImage(*image,argv[i+1]); |
| 2057 | InheritException(exception,&(*image)->exception); |
| 2058 | break; |
| 2059 | } |
| 2060 | if (LocaleCompare("monitor",option+1) == 0) |
| 2061 | { |
| 2062 | if (*option == '+') |
| 2063 | { |
| 2064 | (void) SetImageProgressMonitor(*image, |
| 2065 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2066 | break; |
| 2067 | } |
| 2068 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2069 | (void *) NULL); |
| 2070 | break; |
| 2071 | } |
| 2072 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2073 | { |
| 2074 | (void) SyncImageSettings(mogrify_info,*image); |
| 2075 | (void) SetImageType(*image,BilevelType); |
| 2076 | InheritException(exception,&(*image)->exception); |
| 2077 | break; |
| 2078 | } |
| 2079 | if (LocaleCompare("morphology",option+1) == 0) |
| 2080 | { |
| 2081 | char |
| 2082 | token[MaxTextExtent]; |
| 2083 | |
| 2084 | const char |
| 2085 | *p; |
| 2086 | |
| 2087 | KernelInfo |
| 2088 | *kernel; |
| 2089 | |
| 2090 | MorphologyMethod |
| 2091 | method; |
| 2092 | |
| 2093 | ssize_t |
| 2094 | iterations; |
| 2095 | |
| 2096 | /* |
| 2097 | Morphological Image Operation |
| 2098 | */ |
| 2099 | (void) SyncImageSettings(mogrify_info,*image); |
| 2100 | p=argv[i+1]; |
| 2101 | GetMagickToken(p,&p,token); |
| 2102 | method=(MorphologyMethod) ParseCommandOption(MagickMorphologyOptions, |
| 2103 | MagickFalse,token); |
| 2104 | iterations=1L; |
| 2105 | GetMagickToken(p,&p,token); |
| 2106 | if ((*p == ':') || (*p == ',')) |
| 2107 | GetMagickToken(p,&p,token); |
| 2108 | if ((*p != '\0')) |
| 2109 | iterations=(ssize_t) StringToLong(p); |
| 2110 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2111 | if (kernel == (KernelInfo *) NULL) |
| 2112 | { |
| 2113 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2114 | OptionError,"UnabletoParseKernel","morphology"); |
| 2115 | status=MagickFalse; |
| 2116 | break; |
| 2117 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2118 | mogrify_image=MorphologyImage(*image,method,iterations,kernel, |
| 2119 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2120 | kernel=DestroyKernelInfo(kernel); |
| 2121 | break; |
| 2122 | } |
| 2123 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2124 | { |
| 2125 | /* |
| 2126 | Motion blur image. |
| 2127 | */ |
| 2128 | (void) SyncImageSettings(mogrify_info,*image); |
| 2129 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2130 | if ((flags & SigmaValue) == 0) |
| 2131 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2132 | mogrify_image=MotionBlurImage(*image,geometry_info.rho, |
| 2133 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2134 | break; |
| 2135 | } |
| 2136 | break; |
| 2137 | } |
| 2138 | case 'n': |
| 2139 | { |
| 2140 | if (LocaleCompare("negate",option+1) == 0) |
| 2141 | { |
| 2142 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2143 | (void) NegateImage(*image,*option == '+' ? MagickTrue : |
| 2144 | MagickFalse); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2145 | InheritException(exception,&(*image)->exception); |
| 2146 | break; |
| 2147 | } |
| 2148 | if (LocaleCompare("noise",option+1) == 0) |
| 2149 | { |
| 2150 | (void) SyncImageSettings(mogrify_info,*image); |
| 2151 | if (*option == '-') |
| 2152 | { |
| 2153 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2154 | mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t) |
| 2155 | geometry_info.rho,(size_t) geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2156 | } |
| 2157 | else |
| 2158 | { |
| 2159 | NoiseType |
| 2160 | noise; |
| 2161 | |
| 2162 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
| 2163 | MagickFalse,argv[i+1]); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 2164 | mogrify_image=AddNoiseImage(*image,noise,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2165 | } |
| 2166 | break; |
| 2167 | } |
| 2168 | if (LocaleCompare("normalize",option+1) == 0) |
| 2169 | { |
| 2170 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2171 | (void) NormalizeImage(*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2172 | InheritException(exception,&(*image)->exception); |
| 2173 | break; |
| 2174 | } |
| 2175 | break; |
| 2176 | } |
| 2177 | case 'o': |
| 2178 | { |
| 2179 | if (LocaleCompare("opaque",option+1) == 0) |
| 2180 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2181 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2182 | target; |
| 2183 | |
| 2184 | (void) SyncImageSettings(mogrify_info,*image); |
| 2185 | (void) QueryMagickColor(argv[i+1],&target,exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 2186 | (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ? |
| 2187 | MagickFalse : MagickTrue); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2188 | break; |
| 2189 | } |
| 2190 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2191 | { |
| 2192 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 1302067 | 2011-07-08 02:33:26 +0000 | [diff] [blame] | 2193 | (void) OrderedPosterizeImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2194 | break; |
| 2195 | } |
| 2196 | break; |
| 2197 | } |
| 2198 | case 'p': |
| 2199 | { |
| 2200 | if (LocaleCompare("paint",option+1) == 0) |
| 2201 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2202 | (void) SyncImageSettings(mogrify_info,*image); |
| 2203 | (void) ParseGeometry(argv[i+1],&geometry_info); |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 2204 | mogrify_image=OilPaintImage(*image,geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2205 | break; |
| 2206 | } |
| 2207 | if (LocaleCompare("pen",option+1) == 0) |
| 2208 | { |
| 2209 | if (*option == '+') |
| 2210 | { |
| 2211 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 2212 | break; |
| 2213 | } |
| 2214 | (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception); |
| 2215 | break; |
| 2216 | } |
| 2217 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2218 | { |
| 2219 | if (*option == '+') |
| 2220 | (void) ParseGeometry("12",&geometry_info); |
| 2221 | else |
| 2222 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2223 | draw_info->pointsize=geometry_info.rho; |
| 2224 | break; |
| 2225 | } |
| 2226 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2227 | { |
| 2228 | double |
| 2229 | angle; |
| 2230 | |
| 2231 | RandomInfo |
| 2232 | *random_info; |
| 2233 | |
| 2234 | /* |
| 2235 | Simulate a Polaroid picture. |
| 2236 | */ |
| 2237 | (void) SyncImageSettings(mogrify_info,*image); |
| 2238 | random_info=AcquireRandomInfo(); |
| 2239 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2240 | random_info=DestroyRandomInfo(random_info); |
| 2241 | if (*option == '-') |
| 2242 | { |
| 2243 | SetGeometryInfo(&geometry_info); |
| 2244 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2245 | angle=geometry_info.rho; |
| 2246 | } |
| 2247 | mogrify_image=PolaroidImage(*image,draw_info,angle,exception); |
| 2248 | break; |
| 2249 | } |
| 2250 | if (LocaleCompare("posterize",option+1) == 0) |
| 2251 | { |
| 2252 | /* |
| 2253 | Posterize image. |
| 2254 | */ |
| 2255 | (void) SyncImageSettings(mogrify_info,*image); |
| 2256 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
| 2257 | quantize_info->dither); |
| 2258 | InheritException(exception,&(*image)->exception); |
| 2259 | break; |
| 2260 | } |
| 2261 | if (LocaleCompare("preview",option+1) == 0) |
| 2262 | { |
| 2263 | PreviewType |
| 2264 | preview_type; |
| 2265 | |
| 2266 | /* |
| 2267 | Preview image. |
| 2268 | */ |
| 2269 | (void) SyncImageSettings(mogrify_info,*image); |
| 2270 | if (*option == '+') |
| 2271 | preview_type=UndefinedPreview; |
| 2272 | else |
| 2273 | preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions, |
| 2274 | MagickFalse,argv[i+1]); |
| 2275 | mogrify_image=PreviewImage(*image,preview_type,exception); |
| 2276 | break; |
| 2277 | } |
| 2278 | if (LocaleCompare("profile",option+1) == 0) |
| 2279 | { |
| 2280 | const char |
| 2281 | *name; |
| 2282 | |
| 2283 | const StringInfo |
| 2284 | *profile; |
| 2285 | |
| 2286 | Image |
| 2287 | *profile_image; |
| 2288 | |
| 2289 | ImageInfo |
| 2290 | *profile_info; |
| 2291 | |
| 2292 | (void) SyncImageSettings(mogrify_info,*image); |
| 2293 | if (*option == '+') |
| 2294 | { |
| 2295 | /* |
| 2296 | Remove a profile from the image. |
| 2297 | */ |
| 2298 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
| 2299 | NULL,0,MagickTrue); |
| 2300 | InheritException(exception,&(*image)->exception); |
| 2301 | break; |
| 2302 | } |
| 2303 | /* |
| 2304 | Associate a profile with the image. |
| 2305 | */ |
| 2306 | profile_info=CloneImageInfo(mogrify_info); |
| 2307 | profile=GetImageProfile(*image,"iptc"); |
| 2308 | if (profile != (StringInfo *) NULL) |
| 2309 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2310 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2311 | profile_info=DestroyImageInfo(profile_info); |
| 2312 | if (profile_image == (Image *) NULL) |
| 2313 | { |
| 2314 | StringInfo |
| 2315 | *profile; |
| 2316 | |
| 2317 | profile_info=CloneImageInfo(mogrify_info); |
| 2318 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2319 | MaxTextExtent); |
| 2320 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
| 2321 | if (profile != (StringInfo *) NULL) |
| 2322 | { |
| 2323 | (void) ProfileImage(*image,profile_info->magick, |
| 2324 | GetStringInfoDatum(profile),(size_t) |
| 2325 | GetStringInfoLength(profile),MagickFalse); |
| 2326 | profile=DestroyStringInfo(profile); |
| 2327 | } |
| 2328 | profile_info=DestroyImageInfo(profile_info); |
| 2329 | break; |
| 2330 | } |
| 2331 | ResetImageProfileIterator(profile_image); |
| 2332 | name=GetNextImageProfile(profile_image); |
| 2333 | while (name != (const char *) NULL) |
| 2334 | { |
| 2335 | profile=GetImageProfile(profile_image,name); |
| 2336 | if (profile != (StringInfo *) NULL) |
| 2337 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
| 2338 | (size_t) GetStringInfoLength(profile),MagickFalse); |
| 2339 | name=GetNextImageProfile(profile_image); |
| 2340 | } |
| 2341 | profile_image=DestroyImage(profile_image); |
| 2342 | break; |
| 2343 | } |
| 2344 | break; |
| 2345 | } |
| 2346 | case 'q': |
| 2347 | { |
| 2348 | if (LocaleCompare("quantize",option+1) == 0) |
| 2349 | { |
| 2350 | if (*option == '+') |
| 2351 | { |
| 2352 | quantize_info->colorspace=UndefinedColorspace; |
| 2353 | break; |
| 2354 | } |
| 2355 | quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
| 2356 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2357 | break; |
| 2358 | } |
| 2359 | break; |
| 2360 | } |
| 2361 | case 'r': |
| 2362 | { |
| 2363 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2364 | { |
| 2365 | /* |
| 2366 | Radial blur image. |
| 2367 | */ |
| 2368 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2369 | mogrify_image=RadialBlurImage(*image,InterpretLocaleValue(argv[i+1], |
| 2370 | (char **) NULL),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2371 | break; |
| 2372 | } |
| 2373 | if (LocaleCompare("raise",option+1) == 0) |
| 2374 | { |
| 2375 | /* |
| 2376 | Surround image with a raise of solid color. |
| 2377 | */ |
| 2378 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2379 | if ((flags & SigmaValue) == 0) |
| 2380 | geometry.height=geometry.width; |
| 2381 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
| 2382 | MagickFalse); |
| 2383 | InheritException(exception,&(*image)->exception); |
| 2384 | break; |
| 2385 | } |
| 2386 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2387 | { |
| 2388 | /* |
| 2389 | Threshold image. |
| 2390 | */ |
| 2391 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2392 | (void) RandomThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2393 | break; |
| 2394 | } |
| 2395 | if (LocaleCompare("recolor",option+1) == 0) |
| 2396 | { |
| 2397 | KernelInfo |
| 2398 | *kernel; |
| 2399 | |
| 2400 | (void) SyncImageSettings(mogrify_info,*image); |
| 2401 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2402 | if (kernel == (KernelInfo *) NULL) |
| 2403 | break; |
| 2404 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 2405 | kernel=DestroyKernelInfo(kernel); |
| 2406 | break; |
| 2407 | } |
| 2408 | if (LocaleCompare("region",option+1) == 0) |
| 2409 | { |
| 2410 | (void) SyncImageSettings(mogrify_info,*image); |
| 2411 | if (region_image != (Image *) NULL) |
| 2412 | { |
| 2413 | /* |
| 2414 | Composite region. |
| 2415 | */ |
| 2416 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2417 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 2418 | region_geometry.x,region_geometry.y); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2419 | InheritException(exception,®ion_image->exception); |
| 2420 | *image=DestroyImage(*image); |
| 2421 | *image=region_image; |
| 2422 | region_image = (Image *) NULL; |
| 2423 | } |
| 2424 | if (*option == '+') |
| 2425 | break; |
| 2426 | /* |
| 2427 | Apply transformations to a selected region of the image. |
| 2428 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2429 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2430 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2431 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2432 | if (mogrify_image == (Image *) NULL) |
| 2433 | break; |
| 2434 | region_image=(*image); |
| 2435 | *image=mogrify_image; |
| 2436 | mogrify_image=(Image *) NULL; |
| 2437 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2438 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2439 | if (LocaleCompare("render",option+1) == 0) |
| 2440 | { |
| 2441 | (void) SyncImageSettings(mogrify_info,*image); |
| 2442 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2443 | break; |
| 2444 | } |
| 2445 | if (LocaleCompare("remap",option+1) == 0) |
| 2446 | { |
| 2447 | Image |
| 2448 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2449 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2450 | /* |
| 2451 | Transform image colors to match this set of colors. |
| 2452 | */ |
| 2453 | (void) SyncImageSettings(mogrify_info,*image); |
| 2454 | if (*option == '+') |
| 2455 | break; |
| 2456 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2457 | if (remap_image == (Image *) NULL) |
| 2458 | break; |
| 2459 | (void) RemapImage(quantize_info,*image,remap_image); |
| 2460 | InheritException(exception,&(*image)->exception); |
| 2461 | remap_image=DestroyImage(remap_image); |
| 2462 | break; |
| 2463 | } |
| 2464 | if (LocaleCompare("repage",option+1) == 0) |
| 2465 | { |
| 2466 | if (*option == '+') |
| 2467 | { |
| 2468 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2469 | break; |
| 2470 | } |
| 2471 | (void) ResetImagePage(*image,argv[i+1]); |
| 2472 | InheritException(exception,&(*image)->exception); |
| 2473 | break; |
| 2474 | } |
| 2475 | if (LocaleCompare("resample",option+1) == 0) |
| 2476 | { |
| 2477 | /* |
| 2478 | Resample image. |
| 2479 | */ |
| 2480 | (void) SyncImageSettings(mogrify_info,*image); |
| 2481 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2482 | if ((flags & SigmaValue) == 0) |
| 2483 | geometry_info.sigma=geometry_info.rho; |
| 2484 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
| 2485 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2486 | break; |
| 2487 | } |
| 2488 | if (LocaleCompare("resize",option+1) == 0) |
| 2489 | { |
| 2490 | /* |
| 2491 | Resize image. |
| 2492 | */ |
| 2493 | (void) SyncImageSettings(mogrify_info,*image); |
| 2494 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2495 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2496 | (*image)->filter,(*image)->blur,exception); |
| 2497 | break; |
| 2498 | } |
| 2499 | if (LocaleCompare("roll",option+1) == 0) |
| 2500 | { |
| 2501 | /* |
| 2502 | Roll image. |
| 2503 | */ |
| 2504 | (void) SyncImageSettings(mogrify_info,*image); |
| 2505 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2506 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2507 | break; |
| 2508 | } |
| 2509 | if (LocaleCompare("rotate",option+1) == 0) |
| 2510 | { |
| 2511 | char |
| 2512 | *geometry; |
| 2513 | |
| 2514 | /* |
| 2515 | Check for conditional image rotation. |
| 2516 | */ |
| 2517 | (void) SyncImageSettings(mogrify_info,*image); |
| 2518 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2519 | if ((*image)->columns <= (*image)->rows) |
| 2520 | break; |
| 2521 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2522 | if ((*image)->columns >= (*image)->rows) |
| 2523 | break; |
| 2524 | /* |
| 2525 | Rotate image. |
| 2526 | */ |
| 2527 | geometry=ConstantString(argv[i+1]); |
| 2528 | (void) SubstituteString(&geometry,">",""); |
| 2529 | (void) SubstituteString(&geometry,"<",""); |
| 2530 | (void) ParseGeometry(geometry,&geometry_info); |
| 2531 | geometry=DestroyString(geometry); |
| 2532 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
| 2533 | break; |
| 2534 | } |
| 2535 | break; |
| 2536 | } |
| 2537 | case 's': |
| 2538 | { |
| 2539 | if (LocaleCompare("sample",option+1) == 0) |
| 2540 | { |
| 2541 | /* |
| 2542 | Sample image with pixel replication. |
| 2543 | */ |
| 2544 | (void) SyncImageSettings(mogrify_info,*image); |
| 2545 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2546 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
| 2547 | exception); |
| 2548 | break; |
| 2549 | } |
| 2550 | if (LocaleCompare("scale",option+1) == 0) |
| 2551 | { |
| 2552 | /* |
| 2553 | Resize image. |
| 2554 | */ |
| 2555 | (void) SyncImageSettings(mogrify_info,*image); |
| 2556 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2557 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2558 | exception); |
| 2559 | break; |
| 2560 | } |
| 2561 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2562 | { |
| 2563 | /* |
| 2564 | Selectively blur pixels within a contrast threshold. |
| 2565 | */ |
| 2566 | (void) SyncImageSettings(mogrify_info,*image); |
| 2567 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2568 | if ((flags & PercentValue) != 0) |
| 2569 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2570 | mogrify_image=SelectiveBlurImage(*image,geometry_info.rho, |
| 2571 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2572 | break; |
| 2573 | } |
| 2574 | if (LocaleCompare("separate",option+1) == 0) |
| 2575 | { |
| 2576 | /* |
| 2577 | Break channels into separate images. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2578 | */ |
| 2579 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 2580 | mogrify_image=SeparateImages(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2581 | break; |
| 2582 | } |
| 2583 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2584 | { |
| 2585 | double |
| 2586 | threshold; |
| 2587 | |
| 2588 | /* |
| 2589 | Sepia-tone image. |
| 2590 | */ |
| 2591 | (void) SyncImageSettings(mogrify_info,*image); |
| 2592 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2593 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
| 2594 | break; |
| 2595 | } |
| 2596 | if (LocaleCompare("segment",option+1) == 0) |
| 2597 | { |
| 2598 | /* |
| 2599 | Segment image. |
| 2600 | */ |
| 2601 | (void) SyncImageSettings(mogrify_info,*image); |
| 2602 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2603 | if ((flags & SigmaValue) == 0) |
| 2604 | geometry_info.sigma=1.0; |
| 2605 | (void) SegmentImage(*image,(*image)->colorspace, |
| 2606 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma); |
| 2607 | InheritException(exception,&(*image)->exception); |
| 2608 | break; |
| 2609 | } |
| 2610 | if (LocaleCompare("set",option+1) == 0) |
| 2611 | { |
| 2612 | char |
| 2613 | *value; |
| 2614 | |
| 2615 | /* |
| 2616 | Set image option. |
| 2617 | */ |
| 2618 | if (*option == '+') |
| 2619 | { |
| 2620 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2621 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2622 | else |
| 2623 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2624 | { |
| 2625 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
| 2626 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2627 | } |
| 2628 | else |
| 2629 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2630 | break; |
| 2631 | } |
| 2632 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 2633 | if (value == (char *) NULL) |
| 2634 | break; |
| 2635 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2636 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2637 | exception); |
| 2638 | else |
| 2639 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2640 | { |
| 2641 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
| 2642 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
| 2643 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2644 | } |
| 2645 | else |
| 2646 | (void) SetImageProperty(*image,argv[i+1],value); |
| 2647 | value=DestroyString(value); |
| 2648 | break; |
| 2649 | } |
| 2650 | if (LocaleCompare("shade",option+1) == 0) |
| 2651 | { |
| 2652 | /* |
| 2653 | Shade image. |
| 2654 | */ |
| 2655 | (void) SyncImageSettings(mogrify_info,*image); |
| 2656 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2657 | if ((flags & SigmaValue) == 0) |
| 2658 | geometry_info.sigma=1.0; |
| 2659 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2660 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2661 | break; |
| 2662 | } |
| 2663 | if (LocaleCompare("shadow",option+1) == 0) |
| 2664 | { |
| 2665 | /* |
| 2666 | Shadow image. |
| 2667 | */ |
| 2668 | (void) SyncImageSettings(mogrify_info,*image); |
| 2669 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2670 | if ((flags & SigmaValue) == 0) |
| 2671 | geometry_info.sigma=1.0; |
| 2672 | if ((flags & XiValue) == 0) |
| 2673 | geometry_info.xi=4.0; |
| 2674 | if ((flags & PsiValue) == 0) |
| 2675 | geometry_info.psi=4.0; |
| 2676 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
| 2677 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 2678 | ceil(geometry_info.psi-0.5),exception); |
| 2679 | break; |
| 2680 | } |
| 2681 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2682 | { |
| 2683 | /* |
| 2684 | Sharpen image. |
| 2685 | */ |
| 2686 | (void) SyncImageSettings(mogrify_info,*image); |
| 2687 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2688 | if ((flags & SigmaValue) == 0) |
| 2689 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2690 | mogrify_image=SharpenImage(*image,geometry_info.rho, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2691 | geometry_info.sigma,exception); |
| 2692 | break; |
| 2693 | } |
| 2694 | if (LocaleCompare("shave",option+1) == 0) |
| 2695 | { |
| 2696 | /* |
| 2697 | Shave the image edges. |
| 2698 | */ |
| 2699 | (void) SyncImageSettings(mogrify_info,*image); |
| 2700 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2701 | mogrify_image=ShaveImage(*image,&geometry,exception); |
| 2702 | break; |
| 2703 | } |
| 2704 | if (LocaleCompare("shear",option+1) == 0) |
| 2705 | { |
| 2706 | /* |
| 2707 | Shear image. |
| 2708 | */ |
| 2709 | (void) SyncImageSettings(mogrify_info,*image); |
| 2710 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2711 | if ((flags & SigmaValue) == 0) |
| 2712 | geometry_info.sigma=geometry_info.rho; |
| 2713 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2714 | geometry_info.sigma,exception); |
| 2715 | break; |
| 2716 | } |
| 2717 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2718 | { |
| 2719 | /* |
| 2720 | Sigmoidal non-linearity contrast control. |
| 2721 | */ |
| 2722 | (void) SyncImageSettings(mogrify_info,*image); |
| 2723 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2724 | if ((flags & SigmaValue) == 0) |
| 2725 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 2726 | if ((flags & PercentValue) != 0) |
| 2727 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2728 | 100.0; |
cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 2729 | (void) SigmoidalContrastImage(*image,(*option == '-') ? |
| 2730 | MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2731 | InheritException(exception,&(*image)->exception); |
| 2732 | break; |
| 2733 | } |
| 2734 | if (LocaleCompare("sketch",option+1) == 0) |
| 2735 | { |
| 2736 | /* |
| 2737 | Sketch image. |
| 2738 | */ |
| 2739 | (void) SyncImageSettings(mogrify_info,*image); |
| 2740 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2741 | if ((flags & SigmaValue) == 0) |
| 2742 | geometry_info.sigma=1.0; |
| 2743 | mogrify_image=SketchImage(*image,geometry_info.rho, |
| 2744 | geometry_info.sigma,geometry_info.xi,exception); |
| 2745 | break; |
| 2746 | } |
| 2747 | if (LocaleCompare("solarize",option+1) == 0) |
| 2748 | { |
| 2749 | double |
| 2750 | threshold; |
| 2751 | |
| 2752 | (void) SyncImageSettings(mogrify_info,*image); |
| 2753 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2754 | (void) SolarizeImage(*image,threshold); |
| 2755 | InheritException(exception,&(*image)->exception); |
| 2756 | break; |
| 2757 | } |
| 2758 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2759 | { |
| 2760 | SparseColorMethod |
| 2761 | method; |
| 2762 | |
| 2763 | char |
| 2764 | *arguments; |
| 2765 | |
| 2766 | /* |
| 2767 | Sparse Color Interpolated Gradient |
| 2768 | */ |
| 2769 | (void) SyncImageSettings(mogrify_info,*image); |
| 2770 | method=(SparseColorMethod) ParseCommandOption( |
| 2771 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
| 2772 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 2773 | InheritException(exception,&(*image)->exception); |
| 2774 | if (arguments == (char *) NULL) |
| 2775 | break; |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 2776 | mogrify_image=SparseColorOption(*image,method,arguments, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2777 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2778 | arguments=DestroyString(arguments); |
| 2779 | break; |
| 2780 | } |
| 2781 | if (LocaleCompare("splice",option+1) == 0) |
| 2782 | { |
| 2783 | /* |
| 2784 | Splice a solid color into the image. |
| 2785 | */ |
| 2786 | (void) SyncImageSettings(mogrify_info,*image); |
| 2787 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 2788 | mogrify_image=SpliceImage(*image,&geometry,exception); |
| 2789 | break; |
| 2790 | } |
| 2791 | if (LocaleCompare("spread",option+1) == 0) |
| 2792 | { |
| 2793 | /* |
| 2794 | Spread an image. |
| 2795 | */ |
| 2796 | (void) SyncImageSettings(mogrify_info,*image); |
| 2797 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2798 | mogrify_image=SpreadImage(*image,geometry_info.rho,exception); |
| 2799 | break; |
| 2800 | } |
| 2801 | if (LocaleCompare("statistic",option+1) == 0) |
| 2802 | { |
| 2803 | StatisticType |
| 2804 | type; |
| 2805 | |
| 2806 | (void) SyncImageSettings(mogrify_info,*image); |
| 2807 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
| 2808 | MagickFalse,argv[i+1]); |
| 2809 | (void) ParseGeometry(argv[i+2],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2810 | mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho, |
| 2811 | (size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2812 | break; |
| 2813 | } |
| 2814 | if (LocaleCompare("stretch",option+1) == 0) |
| 2815 | { |
| 2816 | if (*option == '+') |
| 2817 | { |
| 2818 | draw_info->stretch=UndefinedStretch; |
| 2819 | break; |
| 2820 | } |
| 2821 | draw_info->stretch=(StretchType) ParseCommandOption( |
| 2822 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2823 | break; |
| 2824 | } |
| 2825 | if (LocaleCompare("strip",option+1) == 0) |
| 2826 | { |
| 2827 | /* |
| 2828 | Strip image of profiles and comments. |
| 2829 | */ |
| 2830 | (void) SyncImageSettings(mogrify_info,*image); |
| 2831 | (void) StripImage(*image); |
| 2832 | InheritException(exception,&(*image)->exception); |
| 2833 | break; |
| 2834 | } |
| 2835 | if (LocaleCompare("stroke",option+1) == 0) |
| 2836 | { |
| 2837 | ExceptionInfo |
| 2838 | *sans; |
| 2839 | |
| 2840 | if (*option == '+') |
| 2841 | { |
| 2842 | (void) QueryColorDatabase("none",&draw_info->stroke,exception); |
| 2843 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2844 | draw_info->stroke_pattern=DestroyImage( |
| 2845 | draw_info->stroke_pattern); |
| 2846 | break; |
| 2847 | } |
| 2848 | sans=AcquireExceptionInfo(); |
| 2849 | status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans); |
| 2850 | sans=DestroyExceptionInfo(sans); |
| 2851 | if (status == MagickFalse) |
| 2852 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2853 | exception); |
| 2854 | break; |
| 2855 | } |
| 2856 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2857 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 2858 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 2859 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2860 | break; |
| 2861 | } |
| 2862 | if (LocaleCompare("style",option+1) == 0) |
| 2863 | { |
| 2864 | if (*option == '+') |
| 2865 | { |
| 2866 | draw_info->style=UndefinedStyle; |
| 2867 | break; |
| 2868 | } |
| 2869 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 2870 | MagickFalse,argv[i+1]); |
| 2871 | break; |
| 2872 | } |
| 2873 | if (LocaleCompare("swirl",option+1) == 0) |
| 2874 | { |
| 2875 | /* |
| 2876 | Swirl image. |
| 2877 | */ |
| 2878 | (void) SyncImageSettings(mogrify_info,*image); |
| 2879 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2880 | mogrify_image=SwirlImage(*image,geometry_info.rho,exception); |
| 2881 | break; |
| 2882 | } |
| 2883 | break; |
| 2884 | } |
| 2885 | case 't': |
| 2886 | { |
| 2887 | if (LocaleCompare("threshold",option+1) == 0) |
| 2888 | { |
| 2889 | double |
| 2890 | threshold; |
| 2891 | |
| 2892 | /* |
| 2893 | Threshold image. |
| 2894 | */ |
| 2895 | (void) SyncImageSettings(mogrify_info,*image); |
| 2896 | if (*option == '+') |
anthony | 247a86d | 2011-05-03 13:18:18 +0000 | [diff] [blame] | 2897 | threshold=(double) QuantumRange/2; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2898 | else |
| 2899 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2900 | (void) BilevelImage(*image,threshold); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2901 | InheritException(exception,&(*image)->exception); |
| 2902 | break; |
| 2903 | } |
| 2904 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2905 | { |
| 2906 | /* |
| 2907 | Thumbnail image. |
| 2908 | */ |
| 2909 | (void) SyncImageSettings(mogrify_info,*image); |
| 2910 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2911 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2912 | exception); |
| 2913 | break; |
| 2914 | } |
| 2915 | if (LocaleCompare("tile",option+1) == 0) |
| 2916 | { |
| 2917 | if (*option == '+') |
| 2918 | { |
| 2919 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2920 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2921 | break; |
| 2922 | } |
| 2923 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2924 | exception); |
| 2925 | break; |
| 2926 | } |
| 2927 | if (LocaleCompare("tint",option+1) == 0) |
| 2928 | { |
| 2929 | /* |
| 2930 | Tint the image. |
| 2931 | */ |
| 2932 | (void) SyncImageSettings(mogrify_info,*image); |
| 2933 | mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception); |
| 2934 | break; |
| 2935 | } |
| 2936 | if (LocaleCompare("transform",option+1) == 0) |
| 2937 | { |
| 2938 | /* |
| 2939 | Affine transform image. |
| 2940 | */ |
| 2941 | (void) SyncImageSettings(mogrify_info,*image); |
| 2942 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
| 2943 | exception); |
| 2944 | break; |
| 2945 | } |
| 2946 | if (LocaleCompare("transparent",option+1) == 0) |
| 2947 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2948 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2949 | target; |
| 2950 | |
| 2951 | (void) SyncImageSettings(mogrify_info,*image); |
| 2952 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2953 | (void) TransparentPaintImage(*image,&target,(Quantum) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2954 | TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2955 | InheritException(exception,&(*image)->exception); |
| 2956 | break; |
| 2957 | } |
| 2958 | if (LocaleCompare("transpose",option+1) == 0) |
| 2959 | { |
| 2960 | /* |
| 2961 | Transpose image scanlines. |
| 2962 | */ |
| 2963 | (void) SyncImageSettings(mogrify_info,*image); |
| 2964 | mogrify_image=TransposeImage(*image,exception); |
| 2965 | break; |
| 2966 | } |
| 2967 | if (LocaleCompare("transverse",option+1) == 0) |
| 2968 | { |
| 2969 | /* |
| 2970 | Transverse image scanlines. |
| 2971 | */ |
| 2972 | (void) SyncImageSettings(mogrify_info,*image); |
| 2973 | mogrify_image=TransverseImage(*image,exception); |
| 2974 | break; |
| 2975 | } |
| 2976 | if (LocaleCompare("treedepth",option+1) == 0) |
| 2977 | { |
| 2978 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
| 2979 | break; |
| 2980 | } |
| 2981 | if (LocaleCompare("trim",option+1) == 0) |
| 2982 | { |
| 2983 | /* |
| 2984 | Trim image. |
| 2985 | */ |
| 2986 | (void) SyncImageSettings(mogrify_info,*image); |
| 2987 | mogrify_image=TrimImage(*image,exception); |
| 2988 | break; |
| 2989 | } |
| 2990 | if (LocaleCompare("type",option+1) == 0) |
| 2991 | { |
| 2992 | ImageType |
| 2993 | type; |
| 2994 | |
| 2995 | (void) SyncImageSettings(mogrify_info,*image); |
| 2996 | if (*option == '+') |
| 2997 | type=UndefinedType; |
| 2998 | else |
| 2999 | type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 3000 | argv[i+1]); |
| 3001 | (*image)->type=UndefinedType; |
| 3002 | (void) SetImageType(*image,type); |
| 3003 | InheritException(exception,&(*image)->exception); |
| 3004 | break; |
| 3005 | } |
| 3006 | break; |
| 3007 | } |
| 3008 | case 'u': |
| 3009 | { |
| 3010 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3011 | { |
| 3012 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 3013 | exception); |
| 3014 | break; |
| 3015 | } |
| 3016 | if (LocaleCompare("unique",option+1) == 0) |
| 3017 | { |
| 3018 | if (*option == '+') |
| 3019 | { |
| 3020 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
| 3021 | break; |
| 3022 | } |
| 3023 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
| 3024 | (void) SetImageArtifact(*image,"verbose","true"); |
| 3025 | break; |
| 3026 | } |
| 3027 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3028 | { |
| 3029 | /* |
| 3030 | Unique image colors. |
| 3031 | */ |
| 3032 | (void) SyncImageSettings(mogrify_info,*image); |
| 3033 | mogrify_image=UniqueImageColors(*image,exception); |
| 3034 | break; |
| 3035 | } |
| 3036 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3037 | { |
| 3038 | /* |
| 3039 | Unsharp mask image. |
| 3040 | */ |
| 3041 | (void) SyncImageSettings(mogrify_info,*image); |
| 3042 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3043 | if ((flags & SigmaValue) == 0) |
| 3044 | geometry_info.sigma=1.0; |
| 3045 | if ((flags & XiValue) == 0) |
| 3046 | geometry_info.xi=1.0; |
| 3047 | if ((flags & PsiValue) == 0) |
| 3048 | geometry_info.psi=0.05; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3049 | mogrify_image=UnsharpMaskImage(*image,geometry_info.rho, |
| 3050 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3051 | break; |
| 3052 | } |
| 3053 | break; |
| 3054 | } |
| 3055 | case 'v': |
| 3056 | { |
| 3057 | if (LocaleCompare("verbose",option+1) == 0) |
| 3058 | { |
| 3059 | (void) SetImageArtifact(*image,option+1, |
| 3060 | *option == '+' ? "false" : "true"); |
| 3061 | break; |
| 3062 | } |
| 3063 | if (LocaleCompare("vignette",option+1) == 0) |
| 3064 | { |
| 3065 | /* |
| 3066 | Vignette image. |
| 3067 | */ |
| 3068 | (void) SyncImageSettings(mogrify_info,*image); |
| 3069 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3070 | if ((flags & SigmaValue) == 0) |
| 3071 | geometry_info.sigma=1.0; |
| 3072 | if ((flags & XiValue) == 0) |
| 3073 | geometry_info.xi=0.1*(*image)->columns; |
| 3074 | if ((flags & PsiValue) == 0) |
| 3075 | geometry_info.psi=0.1*(*image)->rows; |
| 3076 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
| 3077 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3078 | ceil(geometry_info.psi-0.5),exception); |
| 3079 | break; |
| 3080 | } |
| 3081 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3082 | { |
| 3083 | if (*option == '+') |
| 3084 | { |
| 3085 | (void) SetImageVirtualPixelMethod(*image, |
| 3086 | UndefinedVirtualPixelMethod); |
| 3087 | break; |
| 3088 | } |
| 3089 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3090 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 3091 | argv[i+1])); |
| 3092 | break; |
| 3093 | } |
| 3094 | break; |
| 3095 | } |
| 3096 | case 'w': |
| 3097 | { |
| 3098 | if (LocaleCompare("wave",option+1) == 0) |
| 3099 | { |
| 3100 | /* |
| 3101 | Wave image. |
| 3102 | */ |
| 3103 | (void) SyncImageSettings(mogrify_info,*image); |
| 3104 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3105 | if ((flags & SigmaValue) == 0) |
| 3106 | geometry_info.sigma=1.0; |
| 3107 | mogrify_image=WaveImage(*image,geometry_info.rho, |
| 3108 | geometry_info.sigma,exception); |
| 3109 | break; |
| 3110 | } |
| 3111 | if (LocaleCompare("weight",option+1) == 0) |
| 3112 | { |
| 3113 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
| 3114 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3115 | draw_info->weight=0; |
| 3116 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3117 | draw_info->weight=700; |
| 3118 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3119 | if (draw_info->weight <= 800) |
| 3120 | draw_info->weight+=100; |
| 3121 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3122 | if (draw_info->weight >= 100) |
| 3123 | draw_info->weight-=100; |
| 3124 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3125 | draw_info->weight=400; |
| 3126 | break; |
| 3127 | } |
| 3128 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3129 | { |
| 3130 | /* |
| 3131 | White threshold image. |
| 3132 | */ |
| 3133 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3134 | (void) WhiteThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3135 | InheritException(exception,&(*image)->exception); |
| 3136 | break; |
| 3137 | } |
| 3138 | break; |
| 3139 | } |
| 3140 | default: |
| 3141 | break; |
| 3142 | } |
| 3143 | /* |
| 3144 | Replace current image with any image that was generated |
| 3145 | */ |
| 3146 | if (mogrify_image != (Image *) NULL) |
| 3147 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3148 | i+=count; |
| 3149 | } |
| 3150 | if (region_image != (Image *) NULL) |
| 3151 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3152 | /* |
| 3153 | Composite transformed region onto image. |
| 3154 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3155 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3156 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3157 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 3158 | region_geometry.x,region_geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3159 | InheritException(exception,®ion_image->exception); |
| 3160 | *image=DestroyImage(*image); |
| 3161 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3162 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3163 | } |
| 3164 | /* |
| 3165 | Free resources. |
| 3166 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3167 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3168 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3169 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 3170 | status=(MagickStatusType) ((*image)->exception.severity == |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 3171 | UndefinedException ? 1 : 0); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3172 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3173 | } |
| 3174 | |
| 3175 | /* |
| 3176 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3177 | % % |
| 3178 | % % |
| 3179 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3180 | + 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] | 3181 | % % |
| 3182 | % % |
| 3183 | % % |
| 3184 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3185 | % |
| 3186 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3187 | % transforms include image scaling, image rotation, color reduction, and |
| 3188 | % others. The transmogrified image overwrites the original image. |
| 3189 | % |
| 3190 | % The format of the MogrifyImageCommand method is: |
| 3191 | % |
| 3192 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3193 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3194 | % |
| 3195 | % A description of each parameter follows: |
| 3196 | % |
| 3197 | % o image_info: the image info. |
| 3198 | % |
| 3199 | % o argc: the number of elements in the argument vector. |
| 3200 | % |
| 3201 | % o argv: A text array containing the command line arguments. |
| 3202 | % |
| 3203 | % o metadata: any metadata is returned here. |
| 3204 | % |
| 3205 | % o exception: return any errors or warnings in this structure. |
| 3206 | % |
| 3207 | */ |
| 3208 | |
| 3209 | static MagickBooleanType MogrifyUsage(void) |
| 3210 | { |
| 3211 | static const char |
| 3212 | *miscellaneous[]= |
| 3213 | { |
| 3214 | "-debug events display copious debugging information", |
| 3215 | "-help print program options", |
| 3216 | "-list type print a list of supported option arguments", |
| 3217 | "-log format format of debugging information", |
| 3218 | "-version print version information", |
| 3219 | (char *) NULL |
| 3220 | }, |
| 3221 | *operators[]= |
| 3222 | { |
| 3223 | "-adaptive-blur geometry", |
| 3224 | " adaptively blur pixels; decrease effect near edges", |
| 3225 | "-adaptive-resize geometry", |
| 3226 | " adaptively resize image using 'mesh' interpolation", |
| 3227 | "-adaptive-sharpen geometry", |
| 3228 | " adaptively sharpen pixels; increase effect near edges", |
| 3229 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3230 | " transparent, extract, background, or shape", |
| 3231 | "-annotate geometry text", |
| 3232 | " annotate the image with text", |
| 3233 | "-auto-gamma automagically adjust gamma level of image", |
| 3234 | "-auto-level automagically adjust color levels of image", |
| 3235 | "-auto-orient automagically orient (rotate) image", |
| 3236 | "-bench iterations measure performance", |
| 3237 | "-black-threshold value", |
| 3238 | " force all pixels below the threshold into black", |
| 3239 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3240 | "-blur geometry reduce image noise and reduce detail levels", |
| 3241 | "-border geometry surround image with a border of color", |
| 3242 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3243 | "-brightness-contrast geometry", |
| 3244 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3245 | "-cdl filename color correct with a color decision list", |
| 3246 | "-charcoal radius simulate a charcoal drawing", |
| 3247 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3248 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3249 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3250 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3251 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3252 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3253 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3254 | "-contrast enhance or reduce the image contrast", |
| 3255 | "-contrast-stretch geometry", |
| 3256 | " improve contrast by `stretching' the intensity range", |
| 3257 | "-convolve coefficients", |
| 3258 | " apply a convolution kernel to the image", |
| 3259 | "-cycle amount cycle the image colormap", |
| 3260 | "-decipher filename convert cipher pixels to plain pixels", |
| 3261 | "-deskew threshold straighten an image", |
| 3262 | "-despeckle reduce the speckles within an image", |
| 3263 | "-distort method args", |
| 3264 | " distort images according to given method ad args", |
| 3265 | "-draw string annotate the image with a graphic primitive", |
| 3266 | "-edge radius apply a filter to detect edges in the image", |
| 3267 | "-encipher filename convert plain pixels to cipher pixels", |
| 3268 | "-emboss radius emboss an image", |
| 3269 | "-enhance apply a digital filter to enhance a noisy image", |
| 3270 | "-equalize perform histogram equalization to an image", |
| 3271 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3272 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3273 | "-extent geometry set the image size", |
| 3274 | "-extract geometry extract area from image", |
| 3275 | "-fft implements the discrete Fourier transform (DFT)", |
| 3276 | "-flip flip image vertically", |
| 3277 | "-floodfill geometry color", |
| 3278 | " floodfill the image with color", |
| 3279 | "-flop flop image horizontally", |
| 3280 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3281 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3282 | " apply function over image values", |
| 3283 | "-gamma value level of gamma correction", |
| 3284 | "-gaussian-blur geometry", |
| 3285 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3286 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3287 | "-identify identify the format and characteristics of the image", |
| 3288 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3289 | "-implode amount implode image pixels about the center", |
| 3290 | "-lat geometry local adaptive thresholding", |
| 3291 | "-layers method optimize, merge, or compare image layers", |
| 3292 | "-level value adjust the level of image contrast", |
| 3293 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3294 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3295 | "-linear-stretch geometry", |
| 3296 | " improve contrast by `stretching with saturation'", |
| 3297 | "-liquid-rescale geometry", |
| 3298 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3299 | "-median geometry apply a median filter to the image", |
glennrp | 30d2dc6 | 2011-06-25 03:17:16 +0000 | [diff] [blame] | 3300 | "-mode geometry make each pixel the 'predominant color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3301 | "-modulate value vary the brightness, saturation, and hue", |
| 3302 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3303 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3304 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3305 | "-motion-blur geometry", |
| 3306 | " simulate motion blur", |
| 3307 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3308 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3309 | "-normalize transform image to span the full range of colors", |
| 3310 | "-opaque color change this color to the fill color", |
| 3311 | "-ordered-dither NxN", |
| 3312 | " add a noise pattern to the image with specific", |
| 3313 | " amplitudes", |
| 3314 | "-paint radius simulate an oil painting", |
| 3315 | "-polaroid angle simulate a Polaroid picture", |
| 3316 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3317 | "-profile filename add, delete, or apply an image profile", |
| 3318 | "-quantize colorspace reduce colors in this colorspace", |
| 3319 | "-radial-blur angle radial blur the image", |
| 3320 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3321 | "-random-threshold low,high", |
| 3322 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3323 | "-region geometry apply options to a portion of the image", |
| 3324 | "-render render vector graphics", |
| 3325 | "-repage geometry size and location of an image canvas", |
| 3326 | "-resample geometry change the resolution of an image", |
| 3327 | "-resize geometry resize the image", |
| 3328 | "-roll geometry roll an image vertically or horizontally", |
| 3329 | "-rotate degrees apply Paeth rotation to the image", |
| 3330 | "-sample geometry scale image with pixel sampling", |
| 3331 | "-scale geometry scale the image", |
| 3332 | "-segment values segment an image", |
| 3333 | "-selective-blur geometry", |
| 3334 | " selectively blur pixels within a contrast threshold", |
| 3335 | "-sepia-tone threshold", |
| 3336 | " simulate a sepia-toned photo", |
| 3337 | "-set property value set an image property", |
| 3338 | "-shade degrees shade the image using a distant light source", |
| 3339 | "-shadow geometry simulate an image shadow", |
| 3340 | "-sharpen geometry sharpen the image", |
| 3341 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3342 | "-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] | 3343 | "-sigmoidal-contrast geometry", |
| 3344 | " increase the contrast without saturating highlights or shadows", |
| 3345 | "-sketch geometry simulate a pencil sketch", |
| 3346 | "-solarize threshold negate all pixels above the threshold level", |
| 3347 | "-sparse-color method args", |
| 3348 | " fill in a image based on a few color points", |
| 3349 | "-splice geometry splice the background color into the image", |
| 3350 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3351 | "-statistic type radius", |
| 3352 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3353 | "-strip strip image of all profiles and comments", |
| 3354 | "-swirl degrees swirl image pixels about the center", |
| 3355 | "-threshold value threshold the image", |
| 3356 | "-thumbnail geometry create a thumbnail of the image", |
| 3357 | "-tile filename tile image when filling a graphic primitive", |
| 3358 | "-tint value tint the image with the fill color", |
| 3359 | "-transform affine transform image", |
| 3360 | "-transparent color make this color transparent within the image", |
| 3361 | "-transpose flip image vertically and rotate 90 degrees", |
| 3362 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3363 | "-trim trim image edges", |
| 3364 | "-type type image type", |
| 3365 | "-unique-colors discard all but one of any pixel color", |
| 3366 | "-unsharp geometry sharpen the image", |
| 3367 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3368 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3369 | "-white-threshold value", |
| 3370 | " force all pixels above the threshold into white", |
| 3371 | (char *) NULL |
| 3372 | }, |
| 3373 | *sequence_operators[]= |
| 3374 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3375 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3376 | "-clut apply a color lookup table to the image", |
| 3377 | "-coalesce merge a sequence of images", |
| 3378 | "-combine combine a sequence of images", |
| 3379 | "-composite composite image", |
| 3380 | "-crop geometry cut out a rectangular region of the image", |
| 3381 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3382 | "-evaluate-sequence operator", |
| 3383 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3384 | "-flatten flatten a sequence of images", |
| 3385 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3386 | "-hald-clut apply a Hald color lookup table to the image", |
| 3387 | "-morph value morph an image sequence", |
| 3388 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3389 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3390 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3391 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3392 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3393 | "-write filename write images to this file", |
| 3394 | (char *) NULL |
| 3395 | }, |
| 3396 | *settings[]= |
| 3397 | { |
| 3398 | "-adjoin join images into a single multi-image file", |
| 3399 | "-affine matrix affine transform matrix", |
| 3400 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3401 | "-antialias remove pixel-aliasing", |
| 3402 | "-authenticate password", |
| 3403 | " decipher image with this password", |
| 3404 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3405 | "-background color background color", |
| 3406 | "-bias value add bias when convolving an image", |
| 3407 | "-black-point-compensation", |
| 3408 | " use black point compensation", |
| 3409 | "-blue-primary point chromaticity blue primary point", |
| 3410 | "-bordercolor color border color", |
| 3411 | "-caption string assign a caption to an image", |
| 3412 | "-channel type apply option to select image channels", |
| 3413 | "-colors value preferred number of colors in the image", |
| 3414 | "-colorspace type alternate image colorspace", |
| 3415 | "-comment string annotate image with comment", |
| 3416 | "-compose operator set image composite operator", |
| 3417 | "-compress type type of pixel compression when writing the image", |
| 3418 | "-define format:option", |
| 3419 | " define one or more image format options", |
| 3420 | "-delay value display the next image after pausing", |
| 3421 | "-density geometry horizontal and vertical density of the image", |
| 3422 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3423 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3424 | "-display server get image or font from this X server", |
| 3425 | "-dispose method layer disposal method", |
| 3426 | "-dither method apply error diffusion to image", |
| 3427 | "-encoding type text encoding type", |
| 3428 | "-endian type endianness (MSB or LSB) of the image", |
| 3429 | "-family name render text with this font family", |
| 3430 | "-fill color color to use when filling a graphic primitive", |
| 3431 | "-filter type use this filter when resizing an image", |
| 3432 | "-font name render text with this font", |
| 3433 | "-format \"string\" output formatted image characteristics", |
| 3434 | "-fuzz distance colors within this distance are considered equal", |
| 3435 | "-gravity type horizontal and vertical text placement", |
| 3436 | "-green-primary point chromaticity green primary point", |
| 3437 | "-intent type type of rendering intent when managing the image color", |
| 3438 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3439 | "-interline-spacing value", |
| 3440 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3441 | "-interpolate method pixel color interpolation method", |
| 3442 | "-interword-spacing value", |
| 3443 | " set the space between two words", |
| 3444 | "-kerning value set the space between two letters", |
| 3445 | "-label string assign a label to an image", |
| 3446 | "-limit type value pixel cache resource limit", |
| 3447 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3448 | "-mask filename associate a mask with the image", |
| 3449 | "-mattecolor color frame color", |
| 3450 | "-monitor monitor progress", |
| 3451 | "-orient type image orientation", |
| 3452 | "-page geometry size and location of an image canvas (setting)", |
| 3453 | "-ping efficiently determine image attributes", |
| 3454 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3455 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3456 | "-preview type image preview type", |
| 3457 | "-quality value JPEG/MIFF/PNG compression level", |
| 3458 | "-quiet suppress all warning messages", |
| 3459 | "-red-primary point chromaticity red primary point", |
| 3460 | "-regard-warnings pay attention to warning messages", |
| 3461 | "-remap filename transform image colors to match this set of colors", |
| 3462 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3463 | "-sampling-factor geometry", |
| 3464 | " horizontal and vertical sampling factor", |
| 3465 | "-scene value image scene number", |
| 3466 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3467 | "-size geometry width and height of image", |
| 3468 | "-stretch type render text with this font stretch", |
| 3469 | "-stroke color graphic primitive stroke color", |
| 3470 | "-strokewidth value graphic primitive stroke width", |
| 3471 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3472 | "-synchronize synchronize image to storage device", |
| 3473 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3474 | "-texture filename name of texture to tile onto the image background", |
| 3475 | "-tile-offset geometry", |
| 3476 | " tile offset", |
| 3477 | "-treedepth value color tree depth", |
| 3478 | "-transparent-color color", |
| 3479 | " transparent color", |
| 3480 | "-undercolor color annotation bounding box color", |
| 3481 | "-units type the units of image resolution", |
| 3482 | "-verbose print detailed information about the image", |
| 3483 | "-view FlashPix viewing transforms", |
| 3484 | "-virtual-pixel method", |
| 3485 | " virtual pixel access method", |
| 3486 | "-weight type render text with this font weight", |
| 3487 | "-white-point point chromaticity white point", |
| 3488 | (char *) NULL |
| 3489 | }, |
| 3490 | *stack_operators[]= |
| 3491 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3492 | "-delete indexes delete the image from the image sequence", |
| 3493 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3494 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3495 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3496 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3497 | "-swap indexes swap two images in the image sequence", |
| 3498 | (char *) NULL |
| 3499 | }; |
| 3500 | |
| 3501 | const char |
| 3502 | **p; |
| 3503 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3504 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3505 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3506 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3507 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3508 | GetClientName()); |
| 3509 | (void) printf("\nImage Settings:\n"); |
| 3510 | for (p=settings; *p != (char *) NULL; p++) |
| 3511 | (void) printf(" %s\n",*p); |
| 3512 | (void) printf("\nImage Operators:\n"); |
| 3513 | for (p=operators; *p != (char *) NULL; p++) |
| 3514 | (void) printf(" %s\n",*p); |
| 3515 | (void) printf("\nImage Sequence Operators:\n"); |
| 3516 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3517 | (void) printf(" %s\n",*p); |
| 3518 | (void) printf("\nImage Stack Operators:\n"); |
| 3519 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3520 | (void) printf(" %s\n",*p); |
| 3521 | (void) printf("\nMiscellaneous Options:\n"); |
| 3522 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3523 | (void) printf(" %s\n",*p); |
| 3524 | (void) printf( |
| 3525 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3526 | (void) printf( |
| 3527 | "number. To specify a particular image format, precede the filename\n"); |
| 3528 | (void) printf( |
| 3529 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3530 | (void) printf( |
| 3531 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3532 | (void) printf("'-' for standard input or output.\n"); |
| 3533 | return(MagickFalse); |
| 3534 | } |
| 3535 | |
| 3536 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3537 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3538 | { |
| 3539 | #define DestroyMogrify() \ |
| 3540 | { \ |
| 3541 | if (format != (char *) NULL) \ |
| 3542 | format=DestroyString(format); \ |
| 3543 | if (path != (char *) NULL) \ |
| 3544 | path=DestroyString(path); \ |
| 3545 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3546 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3547 | argv[i]=DestroyString(argv[i]); \ |
| 3548 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3549 | } |
| 3550 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3551 | { \ |
| 3552 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3553 | option); \ |
| 3554 | DestroyMogrify(); \ |
| 3555 | return(MagickFalse); \ |
| 3556 | } |
| 3557 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3558 | { \ |
| 3559 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3560 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3561 | DestroyMogrify(); \ |
| 3562 | return(MagickFalse); \ |
| 3563 | } |
| 3564 | |
| 3565 | char |
| 3566 | *format, |
| 3567 | *option, |
| 3568 | *path; |
| 3569 | |
| 3570 | Image |
| 3571 | *image; |
| 3572 | |
| 3573 | ImageStack |
| 3574 | image_stack[MaxImageStackDepth+1]; |
| 3575 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3576 | MagickBooleanType |
| 3577 | global_colormap; |
| 3578 | |
| 3579 | MagickBooleanType |
| 3580 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3581 | pend, |
| 3582 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3583 | |
| 3584 | MagickStatusType |
| 3585 | status; |
| 3586 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3587 | register ssize_t |
| 3588 | i; |
| 3589 | |
| 3590 | ssize_t |
| 3591 | j, |
| 3592 | k; |
| 3593 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3594 | /* |
| 3595 | Set defaults. |
| 3596 | */ |
| 3597 | assert(image_info != (ImageInfo *) NULL); |
| 3598 | assert(image_info->signature == MagickSignature); |
| 3599 | if (image_info->debug != MagickFalse) |
| 3600 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3601 | assert(exception != (ExceptionInfo *) NULL); |
| 3602 | if (argc == 2) |
| 3603 | { |
| 3604 | option=argv[1]; |
| 3605 | if ((LocaleCompare("version",option+1) == 0) || |
| 3606 | (LocaleCompare("-version",option+1) == 0)) |
| 3607 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3608 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3609 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 3610 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 3611 | GetMagickCopyright()); |
| 3612 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 3613 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3614 | return(MagickFalse); |
| 3615 | } |
| 3616 | } |
| 3617 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3618 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3619 | format=(char *) NULL; |
| 3620 | path=(char *) NULL; |
| 3621 | global_colormap=MagickFalse; |
| 3622 | k=0; |
| 3623 | j=1; |
| 3624 | NewImageStack(); |
| 3625 | option=(char *) NULL; |
| 3626 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3627 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3628 | status=MagickTrue; |
| 3629 | /* |
| 3630 | Parse command line. |
| 3631 | */ |
| 3632 | ReadCommandlLine(argc,&argv); |
| 3633 | status=ExpandFilenames(&argc,&argv); |
| 3634 | if (status == MagickFalse) |
| 3635 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3636 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3637 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3638 | { |
| 3639 | option=argv[i]; |
| 3640 | if (LocaleCompare(option,"(") == 0) |
| 3641 | { |
| 3642 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3643 | if (k == MaxImageStackDepth) |
| 3644 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3645 | option); |
| 3646 | PushImageStack(); |
| 3647 | continue; |
| 3648 | } |
| 3649 | if (LocaleCompare(option,")") == 0) |
| 3650 | { |
| 3651 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3652 | if (k == 0) |
| 3653 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3654 | PopImageStack(); |
| 3655 | continue; |
| 3656 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3657 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3658 | { |
| 3659 | char |
| 3660 | backup_filename[MaxTextExtent], |
| 3661 | *filename; |
| 3662 | |
| 3663 | Image |
| 3664 | *images; |
| 3665 | |
| 3666 | /* |
| 3667 | Option is a file name: begin by reading image from specified file. |
| 3668 | */ |
| 3669 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3670 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3671 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3672 | filename=argv[++i]; |
| 3673 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 3674 | images=ReadImages(image_info,exception); |
| 3675 | status&=(images != (Image *) NULL) && |
| 3676 | (exception->severity < ErrorException); |
| 3677 | if (images == (Image *) NULL) |
| 3678 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3679 | if (format != (char *) NULL) |
| 3680 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3681 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3682 | if (path != (char *) NULL) |
| 3683 | { |
| 3684 | GetPathComponent(option,TailPath,filename); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3685 | (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3686 | path,*DirectorySeparator,filename); |
| 3687 | } |
| 3688 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3689 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3690 | AppendImageStack(images); |
| 3691 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3692 | if (global_colormap != MagickFalse) |
| 3693 | { |
| 3694 | QuantizeInfo |
| 3695 | *quantize_info; |
| 3696 | |
| 3697 | quantize_info=AcquireQuantizeInfo(image_info); |
| 3698 | (void) RemapImages(quantize_info,images,(Image *) NULL); |
| 3699 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3700 | } |
| 3701 | *backup_filename='\0'; |
| 3702 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3703 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3704 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3705 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3706 | i; |
| 3707 | |
| 3708 | /* |
| 3709 | Rename image file as backup. |
| 3710 | */ |
| 3711 | (void) CopyMagickString(backup_filename,image->filename, |
| 3712 | MaxTextExtent); |
| 3713 | for (i=0; i < 6; i++) |
| 3714 | { |
| 3715 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3716 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3717 | break; |
| 3718 | } |
| 3719 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
| 3720 | (rename(image->filename,backup_filename) != 0)) |
| 3721 | *backup_filename='\0'; |
| 3722 | } |
| 3723 | /* |
| 3724 | Write transmogrified image to disk. |
| 3725 | */ |
| 3726 | image_info->synchronize=MagickTrue; |
| 3727 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3728 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
| 3729 | (void) remove(backup_filename); |
| 3730 | RemoveAllImageStack(); |
| 3731 | continue; |
| 3732 | } |
| 3733 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3734 | switch (*(option+1)) |
| 3735 | { |
| 3736 | case 'a': |
| 3737 | { |
| 3738 | if (LocaleCompare("adaptive-blur",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-resize",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("adaptive-sharpen",option+1) == 0) |
| 3757 | { |
| 3758 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3759 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3760 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3761 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3762 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3763 | break; |
| 3764 | } |
| 3765 | if (LocaleCompare("affine",option+1) == 0) |
| 3766 | { |
| 3767 | if (*option == '+') |
| 3768 | break; |
| 3769 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3770 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3771 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3772 | break; |
| 3773 | } |
| 3774 | if (LocaleCompare("alpha",option+1) == 0) |
| 3775 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3776 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3777 | type; |
| 3778 | |
| 3779 | if (*option == '+') |
| 3780 | break; |
| 3781 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3782 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3783 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3784 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3785 | if (type < 0) |
| 3786 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3787 | argv[i]); |
| 3788 | break; |
| 3789 | } |
| 3790 | if (LocaleCompare("annotate",option+1) == 0) |
| 3791 | { |
| 3792 | if (*option == '+') |
| 3793 | break; |
| 3794 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3795 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3796 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3797 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3798 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3799 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3800 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3801 | i++; |
| 3802 | break; |
| 3803 | } |
| 3804 | if (LocaleCompare("antialias",option+1) == 0) |
| 3805 | break; |
| 3806 | if (LocaleCompare("append",option+1) == 0) |
| 3807 | break; |
| 3808 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3809 | { |
| 3810 | if (*option == '+') |
| 3811 | break; |
| 3812 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3813 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3814 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3815 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3816 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3817 | break; |
| 3818 | } |
| 3819 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3820 | { |
| 3821 | if (*option == '+') |
| 3822 | break; |
| 3823 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3824 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3825 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3826 | break; |
| 3827 | } |
| 3828 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3829 | break; |
| 3830 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3831 | break; |
| 3832 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3833 | break; |
| 3834 | if (LocaleCompare("average",option+1) == 0) |
| 3835 | break; |
| 3836 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3837 | } |
| 3838 | case 'b': |
| 3839 | { |
| 3840 | if (LocaleCompare("background",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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3846 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3847 | break; |
| 3848 | } |
| 3849 | if (LocaleCompare("bias",option+1) == 0) |
| 3850 | { |
| 3851 | if (*option == '+') |
| 3852 | break; |
| 3853 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3854 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3855 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3856 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3857 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3858 | break; |
| 3859 | } |
| 3860 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 3861 | break; |
| 3862 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 3863 | { |
| 3864 | if (*option == '+') |
| 3865 | break; |
| 3866 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3867 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3868 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3869 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3870 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3871 | break; |
| 3872 | } |
| 3873 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3874 | { |
| 3875 | if (*option == '+') |
| 3876 | break; |
| 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("blue-shift",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("blur",option+1) == 0) |
| 3894 | { |
| 3895 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3896 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3897 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3898 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3899 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3900 | break; |
| 3901 | } |
| 3902 | if (LocaleCompare("border",option+1) == 0) |
| 3903 | { |
| 3904 | if (*option == '+') |
| 3905 | break; |
| 3906 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3907 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3908 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3909 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3910 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3911 | break; |
| 3912 | } |
| 3913 | if (LocaleCompare("bordercolor",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 | } |
| 3922 | if (LocaleCompare("box",option+1) == 0) |
| 3923 | { |
| 3924 | if (*option == '+') |
| 3925 | break; |
| 3926 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3927 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3928 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3929 | break; |
| 3930 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3931 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 3932 | { |
| 3933 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3934 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3935 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3936 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3937 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3938 | break; |
| 3939 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3940 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3941 | } |
| 3942 | case 'c': |
| 3943 | { |
| 3944 | if (LocaleCompare("cache",option+1) == 0) |
| 3945 | { |
| 3946 | if (*option == '+') |
| 3947 | break; |
| 3948 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3949 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3950 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3951 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3952 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3953 | break; |
| 3954 | } |
| 3955 | if (LocaleCompare("caption",option+1) == 0) |
| 3956 | { |
| 3957 | if (*option == '+') |
| 3958 | break; |
| 3959 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3960 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3961 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3962 | break; |
| 3963 | } |
| 3964 | if (LocaleCompare("channel",option+1) == 0) |
| 3965 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3966 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3967 | channel; |
| 3968 | |
| 3969 | if (*option == '+') |
| 3970 | break; |
| 3971 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3972 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3973 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3974 | channel=ParseChannelOption(argv[i]); |
| 3975 | if (channel < 0) |
| 3976 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 3977 | argv[i]); |
| 3978 | break; |
| 3979 | } |
| 3980 | if (LocaleCompare("cdl",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-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3986 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3987 | break; |
| 3988 | } |
| 3989 | if (LocaleCompare("charcoal",option+1) == 0) |
| 3990 | { |
| 3991 | if (*option == '+') |
| 3992 | break; |
| 3993 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3994 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3995 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3996 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3997 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3998 | break; |
| 3999 | } |
| 4000 | if (LocaleCompare("chop",option+1) == 0) |
| 4001 | { |
| 4002 | if (*option == '+') |
| 4003 | break; |
| 4004 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4005 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4006 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4007 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4008 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4009 | break; |
| 4010 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4011 | if (LocaleCompare("clamp",option+1) == 0) |
| 4012 | break; |
| 4013 | if (LocaleCompare("clip",option+1) == 0) |
| 4014 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4015 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4016 | { |
| 4017 | if (*option == '+') |
| 4018 | break; |
| 4019 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4020 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4021 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4022 | break; |
| 4023 | } |
| 4024 | if (LocaleCompare("clut",option+1) == 0) |
| 4025 | break; |
| 4026 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4027 | break; |
| 4028 | if (LocaleCompare("colorize",option+1) == 0) |
| 4029 | { |
| 4030 | if (*option == '+') |
| 4031 | break; |
| 4032 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4033 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4034 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4035 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4036 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4037 | break; |
| 4038 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4039 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4040 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4041 | KernelInfo |
| 4042 | *kernel_info; |
| 4043 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4044 | if (*option == '+') |
| 4045 | break; |
| 4046 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4047 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4048 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4049 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4050 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4051 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4052 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4053 | break; |
| 4054 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4055 | if (LocaleCompare("colors",option+1) == 0) |
| 4056 | { |
| 4057 | if (*option == '+') |
| 4058 | break; |
| 4059 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4060 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4061 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4062 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4063 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4064 | break; |
| 4065 | } |
| 4066 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4067 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4068 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4069 | colorspace; |
| 4070 | |
| 4071 | if (*option == '+') |
| 4072 | break; |
| 4073 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4074 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4075 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4076 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4077 | argv[i]); |
| 4078 | if (colorspace < 0) |
| 4079 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4080 | argv[i]); |
| 4081 | break; |
| 4082 | } |
| 4083 | if (LocaleCompare("combine",option+1) == 0) |
| 4084 | break; |
| 4085 | if (LocaleCompare("comment",option+1) == 0) |
| 4086 | { |
| 4087 | if (*option == '+') |
| 4088 | break; |
| 4089 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4090 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4091 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4092 | break; |
| 4093 | } |
| 4094 | if (LocaleCompare("composite",option+1) == 0) |
| 4095 | break; |
| 4096 | if (LocaleCompare("compress",option+1) == 0) |
| 4097 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4098 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4099 | compress; |
| 4100 | |
| 4101 | if (*option == '+') |
| 4102 | break; |
| 4103 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4104 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4105 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4106 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4107 | argv[i]); |
| 4108 | if (compress < 0) |
| 4109 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4110 | argv[i]); |
| 4111 | break; |
| 4112 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4113 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4114 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4115 | if (LocaleCompare("contrast",option+1) == 0) |
| 4116 | break; |
| 4117 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4118 | { |
| 4119 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4120 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4121 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4122 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4123 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4124 | break; |
| 4125 | } |
| 4126 | if (LocaleCompare("convolve",option+1) == 0) |
| 4127 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4128 | KernelInfo |
| 4129 | *kernel_info; |
| 4130 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4131 | if (*option == '+') |
| 4132 | break; |
| 4133 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4134 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4135 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4136 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4137 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4138 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4139 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4140 | break; |
| 4141 | } |
| 4142 | if (LocaleCompare("crop",option+1) == 0) |
| 4143 | { |
| 4144 | if (*option == '+') |
| 4145 | break; |
| 4146 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4147 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4148 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4149 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4150 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4151 | break; |
| 4152 | } |
| 4153 | if (LocaleCompare("cycle",option+1) == 0) |
| 4154 | { |
| 4155 | if (*option == '+') |
| 4156 | break; |
| 4157 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4158 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4159 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4160 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4161 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4162 | break; |
| 4163 | } |
| 4164 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4165 | } |
| 4166 | case 'd': |
| 4167 | { |
| 4168 | if (LocaleCompare("decipher",option+1) == 0) |
| 4169 | { |
| 4170 | if (*option == '+') |
| 4171 | break; |
| 4172 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4173 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4174 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4175 | break; |
| 4176 | } |
| 4177 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4178 | break; |
| 4179 | if (LocaleCompare("debug",option+1) == 0) |
| 4180 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4181 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4182 | event; |
| 4183 | |
| 4184 | if (*option == '+') |
| 4185 | break; |
| 4186 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4187 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4188 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4189 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4190 | if (event < 0) |
| 4191 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4192 | argv[i]); |
| 4193 | (void) SetLogEventMask(argv[i]); |
| 4194 | break; |
| 4195 | } |
| 4196 | if (LocaleCompare("define",option+1) == 0) |
| 4197 | { |
| 4198 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4199 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4200 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4201 | if (*option == '+') |
| 4202 | { |
| 4203 | const char |
| 4204 | *define; |
| 4205 | |
| 4206 | define=GetImageOption(image_info,argv[i]); |
| 4207 | if (define == (const char *) NULL) |
| 4208 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4209 | break; |
| 4210 | } |
| 4211 | break; |
| 4212 | } |
| 4213 | if (LocaleCompare("delay",option+1) == 0) |
| 4214 | { |
| 4215 | if (*option == '+') |
| 4216 | break; |
| 4217 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4218 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4219 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4220 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4221 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4222 | break; |
| 4223 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4224 | if (LocaleCompare("delete",option+1) == 0) |
| 4225 | { |
| 4226 | if (*option == '+') |
| 4227 | break; |
| 4228 | i++; |
| 4229 | if (i == (ssize_t) (argc-1)) |
| 4230 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4231 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4232 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4233 | break; |
| 4234 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4235 | if (LocaleCompare("density",option+1) == 0) |
| 4236 | { |
| 4237 | if (*option == '+') |
| 4238 | break; |
| 4239 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4240 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4241 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4242 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4243 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4244 | break; |
| 4245 | } |
| 4246 | if (LocaleCompare("depth",option+1) == 0) |
| 4247 | { |
| 4248 | if (*option == '+') |
| 4249 | break; |
| 4250 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4251 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4252 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4253 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4254 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4255 | break; |
| 4256 | } |
| 4257 | if (LocaleCompare("deskew",option+1) == 0) |
| 4258 | { |
| 4259 | if (*option == '+') |
| 4260 | break; |
| 4261 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4262 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4263 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4264 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4265 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4266 | break; |
| 4267 | } |
| 4268 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4269 | break; |
| 4270 | if (LocaleCompare("dft",option+1) == 0) |
| 4271 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4272 | if (LocaleCompare("direction",option+1) == 0) |
| 4273 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4274 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4275 | direction; |
| 4276 | |
| 4277 | if (*option == '+') |
| 4278 | break; |
| 4279 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4280 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4281 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4282 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4283 | argv[i]); |
| 4284 | if (direction < 0) |
| 4285 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4286 | argv[i]); |
| 4287 | break; |
| 4288 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4289 | if (LocaleCompare("display",option+1) == 0) |
| 4290 | { |
| 4291 | if (*option == '+') |
| 4292 | break; |
| 4293 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4294 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4295 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4296 | break; |
| 4297 | } |
| 4298 | if (LocaleCompare("dispose",option+1) == 0) |
| 4299 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4300 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4301 | dispose; |
| 4302 | |
| 4303 | if (*option == '+') |
| 4304 | break; |
| 4305 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4306 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4307 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4308 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4309 | if (dispose < 0) |
| 4310 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4311 | argv[i]); |
| 4312 | break; |
| 4313 | } |
| 4314 | if (LocaleCompare("distort",option+1) == 0) |
| 4315 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4316 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4317 | op; |
| 4318 | |
| 4319 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4320 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4321 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4322 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4323 | if (op < 0) |
| 4324 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4325 | argv[i]); |
| 4326 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4327 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4328 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4329 | break; |
| 4330 | } |
| 4331 | if (LocaleCompare("dither",option+1) == 0) |
| 4332 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4333 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4334 | method; |
| 4335 | |
| 4336 | if (*option == '+') |
| 4337 | break; |
| 4338 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4339 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4340 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4341 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4342 | if (method < 0) |
| 4343 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4344 | argv[i]); |
| 4345 | break; |
| 4346 | } |
| 4347 | if (LocaleCompare("draw",option+1) == 0) |
| 4348 | { |
| 4349 | if (*option == '+') |
| 4350 | break; |
| 4351 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4352 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4353 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4354 | break; |
| 4355 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4356 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4357 | { |
| 4358 | if (*option == '+') |
| 4359 | break; |
| 4360 | i++; |
| 4361 | if (i == (ssize_t) (argc-1)) |
| 4362 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4363 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4364 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4365 | break; |
| 4366 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4367 | if (LocaleCompare("duration",option+1) == 0) |
| 4368 | { |
| 4369 | if (*option == '+') |
| 4370 | break; |
| 4371 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4372 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4373 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4374 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4375 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4376 | break; |
| 4377 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4378 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4379 | } |
| 4380 | case 'e': |
| 4381 | { |
| 4382 | if (LocaleCompare("edge",option+1) == 0) |
| 4383 | { |
| 4384 | if (*option == '+') |
| 4385 | break; |
| 4386 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4387 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4388 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4389 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4390 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4391 | break; |
| 4392 | } |
| 4393 | if (LocaleCompare("emboss",option+1) == 0) |
| 4394 | { |
| 4395 | if (*option == '+') |
| 4396 | break; |
| 4397 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4398 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4399 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4400 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4401 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4402 | break; |
| 4403 | } |
| 4404 | if (LocaleCompare("encipher",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("encoding",option+1) == 0) |
| 4414 | { |
| 4415 | if (*option == '+') |
| 4416 | break; |
| 4417 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4418 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4419 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4420 | break; |
| 4421 | } |
| 4422 | if (LocaleCompare("endian",option+1) == 0) |
| 4423 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4424 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4425 | endian; |
| 4426 | |
| 4427 | if (*option == '+') |
| 4428 | break; |
| 4429 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4430 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4431 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4432 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4433 | if (endian < 0) |
| 4434 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4435 | argv[i]); |
| 4436 | break; |
| 4437 | } |
| 4438 | if (LocaleCompare("enhance",option+1) == 0) |
| 4439 | break; |
| 4440 | if (LocaleCompare("equalize",option+1) == 0) |
| 4441 | break; |
| 4442 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4443 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4444 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4445 | op; |
| 4446 | |
| 4447 | if (*option == '+') |
| 4448 | break; |
| 4449 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4450 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4451 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4452 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4453 | if (op < 0) |
| 4454 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4455 | argv[i]); |
| 4456 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4457 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4458 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4459 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4460 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4461 | break; |
| 4462 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4463 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4464 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4465 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4466 | op; |
| 4467 | |
| 4468 | if (*option == '+') |
| 4469 | break; |
| 4470 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4471 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4472 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4473 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4474 | if (op < 0) |
| 4475 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4476 | argv[i]); |
| 4477 | break; |
| 4478 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4479 | if (LocaleCompare("extent",option+1) == 0) |
| 4480 | { |
| 4481 | if (*option == '+') |
| 4482 | break; |
| 4483 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4484 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4485 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4486 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4487 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4488 | break; |
| 4489 | } |
| 4490 | if (LocaleCompare("extract",option+1) == 0) |
| 4491 | { |
| 4492 | if (*option == '+') |
| 4493 | break; |
| 4494 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4495 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4496 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4497 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4498 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4499 | break; |
| 4500 | } |
| 4501 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4502 | } |
| 4503 | case 'f': |
| 4504 | { |
| 4505 | if (LocaleCompare("family",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-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4511 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4512 | break; |
| 4513 | } |
| 4514 | if (LocaleCompare("fill",option+1) == 0) |
| 4515 | { |
| 4516 | if (*option == '+') |
| 4517 | break; |
| 4518 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4519 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4520 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4521 | break; |
| 4522 | } |
| 4523 | if (LocaleCompare("filter",option+1) == 0) |
| 4524 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4525 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4526 | filter; |
| 4527 | |
| 4528 | if (*option == '+') |
| 4529 | break; |
| 4530 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4531 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4532 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4533 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4534 | if (filter < 0) |
| 4535 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4536 | argv[i]); |
| 4537 | break; |
| 4538 | } |
| 4539 | if (LocaleCompare("flatten",option+1) == 0) |
| 4540 | break; |
| 4541 | if (LocaleCompare("flip",option+1) == 0) |
| 4542 | break; |
| 4543 | if (LocaleCompare("flop",option+1) == 0) |
| 4544 | break; |
| 4545 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4546 | { |
| 4547 | if (*option == '+') |
| 4548 | break; |
| 4549 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4550 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4551 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4552 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4553 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 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("font",option+1) == 0) |
| 4560 | { |
| 4561 | if (*option == '+') |
| 4562 | break; |
| 4563 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4564 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4565 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4566 | break; |
| 4567 | } |
| 4568 | if (LocaleCompare("format",option+1) == 0) |
| 4569 | { |
| 4570 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4571 | (void) CloneString(&format,(char *) NULL); |
| 4572 | if (*option == '+') |
| 4573 | break; |
| 4574 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4575 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4576 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4577 | (void) CloneString(&format,argv[i]); |
| 4578 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4579 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4580 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4581 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4582 | if (*image_info->magick == '\0') |
| 4583 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4584 | format); |
| 4585 | break; |
| 4586 | } |
| 4587 | if (LocaleCompare("frame",option+1) == 0) |
| 4588 | { |
| 4589 | if (*option == '+') |
| 4590 | break; |
| 4591 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4592 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4593 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4594 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4595 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4596 | break; |
| 4597 | } |
| 4598 | if (LocaleCompare("function",option+1) == 0) |
| 4599 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4600 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4601 | op; |
| 4602 | |
| 4603 | if (*option == '+') |
| 4604 | break; |
| 4605 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4606 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4607 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4608 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4609 | if (op < 0) |
| 4610 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4611 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4612 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4613 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4614 | break; |
| 4615 | } |
| 4616 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4617 | { |
| 4618 | if (*option == '+') |
| 4619 | break; |
| 4620 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4621 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4622 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4623 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4624 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4625 | break; |
| 4626 | } |
| 4627 | if (LocaleCompare("fx",option+1) == 0) |
| 4628 | { |
| 4629 | if (*option == '+') |
| 4630 | break; |
| 4631 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4632 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4633 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4634 | break; |
| 4635 | } |
| 4636 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4637 | } |
| 4638 | case 'g': |
| 4639 | { |
| 4640 | if (LocaleCompare("gamma",option+1) == 0) |
| 4641 | { |
| 4642 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4643 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4644 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4645 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4646 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4647 | break; |
| 4648 | } |
| 4649 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4650 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4651 | { |
| 4652 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4653 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4654 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4655 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4656 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4657 | break; |
| 4658 | } |
| 4659 | if (LocaleCompare("geometry",option+1) == 0) |
| 4660 | { |
| 4661 | if (*option == '+') |
| 4662 | break; |
| 4663 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4664 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4665 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4666 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4667 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4668 | break; |
| 4669 | } |
| 4670 | if (LocaleCompare("gravity",option+1) == 0) |
| 4671 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4672 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4673 | gravity; |
| 4674 | |
| 4675 | if (*option == '+') |
| 4676 | break; |
| 4677 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4678 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4679 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4680 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4681 | if (gravity < 0) |
| 4682 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4683 | argv[i]); |
| 4684 | break; |
| 4685 | } |
| 4686 | if (LocaleCompare("green-primary",option+1) == 0) |
| 4687 | { |
| 4688 | if (*option == '+') |
| 4689 | break; |
| 4690 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4691 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4692 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4693 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4694 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4695 | break; |
| 4696 | } |
| 4697 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4698 | } |
| 4699 | case 'h': |
| 4700 | { |
| 4701 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4702 | break; |
| 4703 | if ((LocaleCompare("help",option+1) == 0) || |
| 4704 | (LocaleCompare("-help",option+1) == 0)) |
| 4705 | return(MogrifyUsage()); |
| 4706 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4707 | } |
| 4708 | case 'i': |
| 4709 | { |
| 4710 | if (LocaleCompare("identify",option+1) == 0) |
| 4711 | break; |
| 4712 | if (LocaleCompare("idft",option+1) == 0) |
| 4713 | break; |
| 4714 | if (LocaleCompare("implode",option+1) == 0) |
| 4715 | { |
| 4716 | if (*option == '+') |
| 4717 | break; |
| 4718 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4719 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4720 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4721 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4722 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4723 | break; |
| 4724 | } |
| 4725 | if (LocaleCompare("intent",option+1) == 0) |
| 4726 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4727 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4728 | intent; |
| 4729 | |
| 4730 | if (*option == '+') |
| 4731 | break; |
| 4732 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4733 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4734 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4735 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4736 | if (intent < 0) |
| 4737 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4738 | argv[i]); |
| 4739 | break; |
| 4740 | } |
| 4741 | if (LocaleCompare("interlace",option+1) == 0) |
| 4742 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4743 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4744 | interlace; |
| 4745 | |
| 4746 | if (*option == '+') |
| 4747 | break; |
| 4748 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4749 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4750 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4751 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4752 | argv[i]); |
| 4753 | if (interlace < 0) |
| 4754 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4755 | argv[i]); |
| 4756 | break; |
| 4757 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4758 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4759 | { |
| 4760 | if (*option == '+') |
| 4761 | break; |
| 4762 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4763 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4764 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4765 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4766 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4767 | break; |
| 4768 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4769 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4770 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4771 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4772 | interpolate; |
| 4773 | |
| 4774 | if (*option == '+') |
| 4775 | break; |
| 4776 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4777 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4778 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4779 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4780 | argv[i]); |
| 4781 | if (interpolate < 0) |
| 4782 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4783 | argv[i]); |
| 4784 | break; |
| 4785 | } |
| 4786 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4787 | { |
| 4788 | if (*option == '+') |
| 4789 | break; |
| 4790 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4791 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4792 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4793 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4794 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4795 | break; |
| 4796 | } |
| 4797 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4798 | } |
| 4799 | case 'k': |
| 4800 | { |
| 4801 | if (LocaleCompare("kerning",option+1) == 0) |
| 4802 | { |
| 4803 | if (*option == '+') |
| 4804 | break; |
| 4805 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4806 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4807 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4808 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4809 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4810 | break; |
| 4811 | } |
| 4812 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4813 | } |
| 4814 | case 'l': |
| 4815 | { |
| 4816 | if (LocaleCompare("label",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 | break; |
| 4824 | } |
| 4825 | if (LocaleCompare("lat",option+1) == 0) |
| 4826 | { |
| 4827 | if (*option == '+') |
| 4828 | break; |
| 4829 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4830 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4831 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4832 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4833 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4834 | } |
| 4835 | if (LocaleCompare("layers",option+1) == 0) |
| 4836 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4837 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4838 | type; |
| 4839 | |
| 4840 | if (*option == '+') |
| 4841 | break; |
| 4842 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4843 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4844 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4845 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4846 | if (type < 0) |
| 4847 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4848 | argv[i]); |
| 4849 | break; |
| 4850 | } |
| 4851 | if (LocaleCompare("level",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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4857 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4858 | break; |
| 4859 | } |
| 4860 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4861 | { |
| 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 | break; |
| 4866 | } |
| 4867 | if (LocaleCompare("linewidth",option+1) == 0) |
| 4868 | { |
| 4869 | if (*option == '+') |
| 4870 | break; |
| 4871 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4872 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4873 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4874 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4875 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4876 | break; |
| 4877 | } |
| 4878 | if (LocaleCompare("limit",option+1) == 0) |
| 4879 | { |
| 4880 | char |
| 4881 | *p; |
| 4882 | |
| 4883 | double |
| 4884 | value; |
| 4885 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4886 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4887 | resource; |
| 4888 | |
| 4889 | if (*option == '+') |
| 4890 | break; |
| 4891 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4892 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4893 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4894 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4895 | argv[i]); |
| 4896 | if (resource < 0) |
| 4897 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4898 | argv[i]); |
| 4899 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4900 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4901 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 4902 | value=InterpretLocaleValue(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4903 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4904 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4905 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4906 | break; |
| 4907 | } |
| 4908 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4909 | { |
| 4910 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4911 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4912 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4913 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4914 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4915 | break; |
| 4916 | } |
| 4917 | if (LocaleCompare("list",option+1) == 0) |
| 4918 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4919 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4920 | list; |
| 4921 | |
| 4922 | if (*option == '+') |
| 4923 | break; |
| 4924 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4925 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4926 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4927 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4928 | if (list < 0) |
| 4929 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4930 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4931 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4932 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4933 | } |
| 4934 | if (LocaleCompare("log",option+1) == 0) |
| 4935 | { |
| 4936 | if (*option == '+') |
| 4937 | break; |
| 4938 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4939 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4940 | (strchr(argv[i],'%') == (char *) NULL)) |
| 4941 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4942 | break; |
| 4943 | } |
| 4944 | if (LocaleCompare("loop",option+1) == 0) |
| 4945 | { |
| 4946 | if (*option == '+') |
| 4947 | break; |
| 4948 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4949 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4950 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4951 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4952 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4953 | break; |
| 4954 | } |
| 4955 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4956 | } |
| 4957 | case 'm': |
| 4958 | { |
| 4959 | if (LocaleCompare("map",option+1) == 0) |
| 4960 | { |
| 4961 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 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("mask",option+1) == 0) |
| 4970 | { |
| 4971 | if (*option == '+') |
| 4972 | break; |
| 4973 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4974 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4975 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4976 | break; |
| 4977 | } |
| 4978 | if (LocaleCompare("matte",option+1) == 0) |
| 4979 | break; |
| 4980 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 4981 | { |
| 4982 | if (*option == '+') |
| 4983 | break; |
| 4984 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4985 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4986 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4987 | break; |
| 4988 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 4989 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 4990 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 4991 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 4992 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4993 | if (LocaleCompare("modulate",option+1) == 0) |
| 4994 | { |
| 4995 | if (*option == '+') |
| 4996 | break; |
| 4997 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4998 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4999 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5000 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5001 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5002 | break; |
| 5003 | } |
| 5004 | if (LocaleCompare("median",option+1) == 0) |
| 5005 | { |
| 5006 | if (*option == '+') |
| 5007 | break; |
| 5008 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5009 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5010 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5011 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5012 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5013 | break; |
| 5014 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5015 | if (LocaleCompare("mode",option+1) == 0) |
| 5016 | { |
| 5017 | if (*option == '+') |
| 5018 | break; |
| 5019 | i++; |
| 5020 | if (i == (ssize_t) argc) |
| 5021 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5022 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5023 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5024 | break; |
| 5025 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5026 | if (LocaleCompare("monitor",option+1) == 0) |
| 5027 | break; |
| 5028 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5029 | break; |
| 5030 | if (LocaleCompare("morph",option+1) == 0) |
| 5031 | { |
| 5032 | if (*option == '+') |
| 5033 | break; |
| 5034 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5035 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5036 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5037 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5038 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5039 | break; |
| 5040 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5041 | if (LocaleCompare("morphology",option+1) == 0) |
| 5042 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5043 | char |
| 5044 | token[MaxTextExtent]; |
| 5045 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5046 | KernelInfo |
| 5047 | *kernel_info; |
| 5048 | |
| 5049 | ssize_t |
| 5050 | op; |
| 5051 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5052 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5053 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5054 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5055 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5056 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5057 | if (op < 0) |
| 5058 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5059 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5060 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5061 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5062 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5063 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5064 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5065 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5066 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5067 | break; |
| 5068 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5069 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5070 | break; |
| 5071 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5072 | { |
| 5073 | if (*option == '+') |
| 5074 | break; |
| 5075 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5076 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5077 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5078 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5079 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5080 | break; |
| 5081 | } |
| 5082 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5083 | } |
| 5084 | case 'n': |
| 5085 | { |
| 5086 | if (LocaleCompare("negate",option+1) == 0) |
| 5087 | break; |
| 5088 | if (LocaleCompare("noise",option+1) == 0) |
| 5089 | { |
| 5090 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5091 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5092 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5093 | if (*option == '+') |
| 5094 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5095 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5096 | noise; |
| 5097 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5098 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5099 | if (noise < 0) |
| 5100 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5101 | argv[i]); |
| 5102 | break; |
| 5103 | } |
| 5104 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5105 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5106 | break; |
| 5107 | } |
| 5108 | if (LocaleCompare("noop",option+1) == 0) |
| 5109 | break; |
| 5110 | if (LocaleCompare("normalize",option+1) == 0) |
| 5111 | break; |
| 5112 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5113 | } |
| 5114 | case 'o': |
| 5115 | { |
| 5116 | if (LocaleCompare("opaque",option+1) == 0) |
| 5117 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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("ordered-dither",option+1) == 0) |
| 5124 | { |
| 5125 | if (*option == '+') |
| 5126 | break; |
| 5127 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5128 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5129 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5130 | break; |
| 5131 | } |
| 5132 | if (LocaleCompare("orient",option+1) == 0) |
| 5133 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5134 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5135 | orientation; |
| 5136 | |
| 5137 | orientation=UndefinedOrientation; |
| 5138 | if (*option == '+') |
| 5139 | break; |
| 5140 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5141 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5142 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5143 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5144 | argv[i]); |
| 5145 | if (orientation < 0) |
| 5146 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5147 | argv[i]); |
| 5148 | break; |
| 5149 | } |
| 5150 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5151 | } |
| 5152 | case 'p': |
| 5153 | { |
| 5154 | if (LocaleCompare("page",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 | break; |
| 5162 | } |
| 5163 | if (LocaleCompare("paint",option+1) == 0) |
| 5164 | { |
| 5165 | if (*option == '+') |
| 5166 | break; |
| 5167 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5168 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5169 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5170 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5171 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5172 | break; |
| 5173 | } |
| 5174 | if (LocaleCompare("path",option+1) == 0) |
| 5175 | { |
| 5176 | (void) CloneString(&path,(char *) NULL); |
| 5177 | if (*option == '+') |
| 5178 | break; |
| 5179 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5180 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5181 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5182 | (void) CloneString(&path,argv[i]); |
| 5183 | break; |
| 5184 | } |
| 5185 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5186 | { |
| 5187 | if (*option == '+') |
| 5188 | break; |
| 5189 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5190 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5191 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5192 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5193 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5194 | break; |
| 5195 | } |
| 5196 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5197 | { |
| 5198 | if (*option == '+') |
| 5199 | break; |
| 5200 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5201 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5202 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5203 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5204 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5205 | break; |
| 5206 | } |
| 5207 | if (LocaleCompare("posterize",option+1) == 0) |
| 5208 | { |
| 5209 | if (*option == '+') |
| 5210 | break; |
| 5211 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5212 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5213 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5214 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5215 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5216 | break; |
| 5217 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5218 | if (LocaleCompare("precision",option+1) == 0) |
| 5219 | { |
| 5220 | if (*option == '+') |
| 5221 | break; |
| 5222 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5223 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5224 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5225 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5226 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5227 | break; |
| 5228 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5229 | if (LocaleCompare("print",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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5235 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5236 | break; |
| 5237 | } |
| 5238 | if (LocaleCompare("process",option+1) == 0) |
| 5239 | { |
| 5240 | if (*option == '+') |
| 5241 | break; |
| 5242 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5243 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5244 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5245 | break; |
| 5246 | } |
| 5247 | if (LocaleCompare("profile",option+1) == 0) |
| 5248 | { |
| 5249 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5250 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5251 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5252 | break; |
| 5253 | } |
| 5254 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5255 | } |
| 5256 | case 'q': |
| 5257 | { |
| 5258 | if (LocaleCompare("quality",option+1) == 0) |
| 5259 | { |
| 5260 | if (*option == '+') |
| 5261 | break; |
| 5262 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5263 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5264 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5265 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5266 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5267 | break; |
| 5268 | } |
| 5269 | if (LocaleCompare("quantize",option+1) == 0) |
| 5270 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5271 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5272 | colorspace; |
| 5273 | |
| 5274 | if (*option == '+') |
| 5275 | break; |
| 5276 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5277 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5278 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5279 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5280 | argv[i]); |
| 5281 | if (colorspace < 0) |
| 5282 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5283 | argv[i]); |
| 5284 | break; |
| 5285 | } |
| 5286 | if (LocaleCompare("quiet",option+1) == 0) |
| 5287 | break; |
| 5288 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5289 | } |
| 5290 | case 'r': |
| 5291 | { |
| 5292 | if (LocaleCompare("radial-blur",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("raise",option+1) == 0) |
| 5302 | { |
| 5303 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5304 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5305 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5306 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5307 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5308 | break; |
| 5309 | } |
| 5310 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5311 | { |
| 5312 | if (*option == '+') |
| 5313 | break; |
| 5314 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5315 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5316 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5317 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5318 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5319 | break; |
| 5320 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5321 | if (LocaleCompare("recolor",option+1) == 0) |
| 5322 | { |
| 5323 | if (*option == '+') |
| 5324 | break; |
| 5325 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5326 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5327 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5328 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5329 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5330 | break; |
| 5331 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5332 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5333 | { |
| 5334 | if (*option == '+') |
| 5335 | break; |
| 5336 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5337 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5338 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5339 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5340 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5341 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5342 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5343 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5344 | if (LocaleCompare("region",option+1) == 0) |
| 5345 | { |
| 5346 | if (*option == '+') |
| 5347 | break; |
| 5348 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5349 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5350 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5351 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5352 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5353 | break; |
| 5354 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5355 | if (LocaleCompare("remap",option+1) == 0) |
| 5356 | { |
| 5357 | if (*option == '+') |
| 5358 | break; |
| 5359 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5360 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5361 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5362 | break; |
| 5363 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5364 | if (LocaleCompare("render",option+1) == 0) |
| 5365 | break; |
| 5366 | if (LocaleCompare("repage",option+1) == 0) |
| 5367 | { |
| 5368 | if (*option == '+') |
| 5369 | break; |
| 5370 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5371 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5372 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5373 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5374 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5375 | break; |
| 5376 | } |
| 5377 | if (LocaleCompare("resample",option+1) == 0) |
| 5378 | { |
| 5379 | if (*option == '+') |
| 5380 | break; |
| 5381 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5382 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5383 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5384 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5385 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5386 | break; |
| 5387 | } |
| 5388 | if (LocaleCompare("resize",option+1) == 0) |
| 5389 | { |
| 5390 | if (*option == '+') |
| 5391 | break; |
| 5392 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5393 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5394 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5395 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5396 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5397 | break; |
| 5398 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5399 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5400 | { |
| 5401 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5402 | break; |
| 5403 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5404 | if (LocaleCompare("reverse",option+1) == 0) |
| 5405 | break; |
| 5406 | if (LocaleCompare("roll",option+1) == 0) |
| 5407 | { |
| 5408 | if (*option == '+') |
| 5409 | break; |
| 5410 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5411 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5412 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5413 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5414 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5415 | break; |
| 5416 | } |
| 5417 | if (LocaleCompare("rotate",option+1) == 0) |
| 5418 | { |
| 5419 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5420 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5421 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5422 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5423 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5424 | break; |
| 5425 | } |
| 5426 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5427 | } |
| 5428 | case 's': |
| 5429 | { |
| 5430 | if (LocaleCompare("sample",option+1) == 0) |
| 5431 | { |
| 5432 | if (*option == '+') |
| 5433 | break; |
| 5434 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5435 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5436 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5437 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5438 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5439 | break; |
| 5440 | } |
| 5441 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5442 | { |
| 5443 | if (*option == '+') |
| 5444 | break; |
| 5445 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5446 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5447 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5448 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5449 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5450 | break; |
| 5451 | } |
| 5452 | if (LocaleCompare("scale",option+1) == 0) |
| 5453 | { |
| 5454 | if (*option == '+') |
| 5455 | break; |
| 5456 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5457 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5458 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5459 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5460 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5461 | break; |
| 5462 | } |
| 5463 | if (LocaleCompare("scene",option+1) == 0) |
| 5464 | { |
| 5465 | if (*option == '+') |
| 5466 | break; |
| 5467 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5468 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5469 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5470 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5471 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5472 | break; |
| 5473 | } |
| 5474 | if (LocaleCompare("seed",option+1) == 0) |
| 5475 | { |
| 5476 | if (*option == '+') |
| 5477 | break; |
| 5478 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5479 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5480 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5481 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5482 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5483 | break; |
| 5484 | } |
| 5485 | if (LocaleCompare("segment",option+1) == 0) |
| 5486 | { |
| 5487 | if (*option == '+') |
| 5488 | break; |
| 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("selective-blur",option+1) == 0) |
| 5497 | { |
| 5498 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5499 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5500 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5501 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5502 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5503 | break; |
| 5504 | } |
| 5505 | if (LocaleCompare("separate",option+1) == 0) |
| 5506 | break; |
| 5507 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5508 | { |
| 5509 | if (*option == '+') |
| 5510 | break; |
| 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 (IsGeometry(argv[i]) == MagickFalse) |
| 5515 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5516 | break; |
| 5517 | } |
| 5518 | if (LocaleCompare("set",option+1) == 0) |
| 5519 | { |
| 5520 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5521 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5522 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5523 | if (*option == '+') |
| 5524 | break; |
| 5525 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5526 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5527 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5528 | break; |
| 5529 | } |
| 5530 | if (LocaleCompare("shade",option+1) == 0) |
| 5531 | { |
| 5532 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5533 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5534 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5535 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5536 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5537 | break; |
| 5538 | } |
| 5539 | if (LocaleCompare("shadow",option+1) == 0) |
| 5540 | { |
| 5541 | if (*option == '+') |
| 5542 | break; |
| 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("sharpen",option+1) == 0) |
| 5551 | { |
| 5552 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5553 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5554 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5555 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5556 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5557 | break; |
| 5558 | } |
| 5559 | if (LocaleCompare("shave",option+1) == 0) |
| 5560 | { |
| 5561 | if (*option == '+') |
| 5562 | break; |
| 5563 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5564 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5565 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5566 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5567 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5568 | break; |
| 5569 | } |
| 5570 | if (LocaleCompare("shear",option+1) == 0) |
| 5571 | { |
| 5572 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5573 | if (i == (ssize_t) argc) |
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("sigmoidal-contrast",option+1) == 0) |
| 5580 | { |
| 5581 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5582 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5583 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5584 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5585 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5586 | break; |
| 5587 | } |
| 5588 | if (LocaleCompare("size",option+1) == 0) |
| 5589 | { |
| 5590 | if (*option == '+') |
| 5591 | break; |
| 5592 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5593 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5594 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5595 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5596 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5597 | break; |
| 5598 | } |
| 5599 | if (LocaleCompare("sketch",option+1) == 0) |
| 5600 | { |
| 5601 | if (*option == '+') |
| 5602 | break; |
| 5603 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5604 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5605 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5606 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5607 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5608 | break; |
| 5609 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5610 | if (LocaleCompare("smush",option+1) == 0) |
| 5611 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5612 | i++; |
| 5613 | if (i == (ssize_t) argc) |
| 5614 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5615 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5616 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5617 | i++; |
| 5618 | break; |
| 5619 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5620 | if (LocaleCompare("solarize",option+1) == 0) |
| 5621 | { |
| 5622 | if (*option == '+') |
| 5623 | break; |
| 5624 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5625 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5626 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5627 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5628 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5629 | break; |
| 5630 | } |
| 5631 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5632 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5633 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5634 | op; |
| 5635 | |
| 5636 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5637 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5638 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5639 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5640 | if (op < 0) |
| 5641 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5642 | argv[i]); |
| 5643 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5644 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5645 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5646 | break; |
| 5647 | } |
| 5648 | if (LocaleCompare("spread",option+1) == 0) |
| 5649 | { |
| 5650 | if (*option == '+') |
| 5651 | break; |
| 5652 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5653 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5654 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5655 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5656 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5657 | break; |
| 5658 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5659 | if (LocaleCompare("statistic",option+1) == 0) |
| 5660 | { |
| 5661 | ssize_t |
| 5662 | op; |
| 5663 | |
| 5664 | if (*option == '+') |
| 5665 | break; |
| 5666 | i++; |
| 5667 | if (i == (ssize_t) argc) |
| 5668 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5669 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5670 | if (op < 0) |
| 5671 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5672 | argv[i]); |
| 5673 | i++; |
| 5674 | if (i == (ssize_t) (argc-1)) |
| 5675 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5676 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5677 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5678 | break; |
| 5679 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5680 | if (LocaleCompare("stretch",option+1) == 0) |
| 5681 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5682 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5683 | stretch; |
| 5684 | |
| 5685 | if (*option == '+') |
| 5686 | break; |
| 5687 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5688 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5689 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5690 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5691 | if (stretch < 0) |
| 5692 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5693 | argv[i]); |
| 5694 | break; |
| 5695 | } |
| 5696 | if (LocaleCompare("strip",option+1) == 0) |
| 5697 | break; |
| 5698 | if (LocaleCompare("stroke",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 | break; |
| 5706 | } |
| 5707 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5708 | { |
| 5709 | if (*option == '+') |
| 5710 | break; |
| 5711 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5712 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5713 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5714 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5715 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5716 | break; |
| 5717 | } |
| 5718 | if (LocaleCompare("style",option+1) == 0) |
| 5719 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5720 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5721 | style; |
| 5722 | |
| 5723 | if (*option == '+') |
| 5724 | break; |
| 5725 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5726 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5727 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5728 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5729 | if (style < 0) |
| 5730 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5731 | argv[i]); |
| 5732 | break; |
| 5733 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5734 | if (LocaleCompare("swap",option+1) == 0) |
| 5735 | { |
| 5736 | if (*option == '+') |
| 5737 | break; |
| 5738 | i++; |
| 5739 | if (i == (ssize_t) (argc-1)) |
| 5740 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5741 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5742 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5743 | break; |
| 5744 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5745 | if (LocaleCompare("swirl",option+1) == 0) |
| 5746 | { |
| 5747 | if (*option == '+') |
| 5748 | break; |
| 5749 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5750 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5751 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5752 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5753 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5754 | break; |
| 5755 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5756 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5757 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5758 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5759 | } |
| 5760 | case 't': |
| 5761 | { |
| 5762 | if (LocaleCompare("taint",option+1) == 0) |
| 5763 | break; |
| 5764 | if (LocaleCompare("texture",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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5770 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5771 | break; |
| 5772 | } |
| 5773 | if (LocaleCompare("tile",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-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5779 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5780 | break; |
| 5781 | } |
| 5782 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5783 | { |
| 5784 | if (*option == '+') |
| 5785 | break; |
| 5786 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5787 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5788 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5789 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5790 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5791 | break; |
| 5792 | } |
| 5793 | if (LocaleCompare("tint",option+1) == 0) |
| 5794 | { |
| 5795 | if (*option == '+') |
| 5796 | break; |
| 5797 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5798 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5799 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5800 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5801 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5802 | break; |
| 5803 | } |
| 5804 | if (LocaleCompare("transform",option+1) == 0) |
| 5805 | break; |
| 5806 | if (LocaleCompare("transpose",option+1) == 0) |
| 5807 | break; |
| 5808 | if (LocaleCompare("transverse",option+1) == 0) |
| 5809 | break; |
| 5810 | if (LocaleCompare("threshold",option+1) == 0) |
| 5811 | { |
| 5812 | if (*option == '+') |
| 5813 | break; |
| 5814 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5815 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5816 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5817 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5818 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5819 | break; |
| 5820 | } |
| 5821 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5822 | { |
| 5823 | if (*option == '+') |
| 5824 | break; |
| 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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5829 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5830 | break; |
| 5831 | } |
| 5832 | if (LocaleCompare("transparent",option+1) == 0) |
| 5833 | { |
| 5834 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5835 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5836 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5837 | break; |
| 5838 | } |
| 5839 | if (LocaleCompare("transparent-color",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-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5845 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5846 | break; |
| 5847 | } |
| 5848 | if (LocaleCompare("treedepth",option+1) == 0) |
| 5849 | { |
| 5850 | if (*option == '+') |
| 5851 | break; |
| 5852 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5853 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5854 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5855 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5856 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5857 | break; |
| 5858 | } |
| 5859 | if (LocaleCompare("trim",option+1) == 0) |
| 5860 | break; |
| 5861 | if (LocaleCompare("type",option+1) == 0) |
| 5862 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5863 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5864 | type; |
| 5865 | |
| 5866 | if (*option == '+') |
| 5867 | break; |
| 5868 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5869 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5870 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5871 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5872 | if (type < 0) |
| 5873 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5874 | argv[i]); |
| 5875 | break; |
| 5876 | } |
| 5877 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5878 | } |
| 5879 | case 'u': |
| 5880 | { |
| 5881 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5882 | { |
| 5883 | if (*option == '+') |
| 5884 | break; |
| 5885 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5886 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5887 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5888 | break; |
| 5889 | } |
| 5890 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5891 | break; |
| 5892 | if (LocaleCompare("units",option+1) == 0) |
| 5893 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5894 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5895 | units; |
| 5896 | |
| 5897 | if (*option == '+') |
| 5898 | break; |
| 5899 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5900 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5901 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5902 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5903 | argv[i]); |
| 5904 | if (units < 0) |
| 5905 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5906 | argv[i]); |
| 5907 | break; |
| 5908 | } |
| 5909 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5910 | { |
| 5911 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5912 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5913 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5914 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5915 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5916 | break; |
| 5917 | } |
| 5918 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5919 | } |
| 5920 | case 'v': |
| 5921 | { |
| 5922 | if (LocaleCompare("verbose",option+1) == 0) |
| 5923 | { |
| 5924 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 5925 | break; |
| 5926 | } |
| 5927 | if ((LocaleCompare("version",option+1) == 0) || |
| 5928 | (LocaleCompare("-version",option+1) == 0)) |
| 5929 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 5930 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5931 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 5932 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 5933 | GetMagickCopyright()); |
| 5934 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 5935 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5936 | break; |
| 5937 | } |
| 5938 | if (LocaleCompare("view",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 | break; |
| 5946 | } |
| 5947 | if (LocaleCompare("vignette",option+1) == 0) |
| 5948 | { |
| 5949 | if (*option == '+') |
| 5950 | break; |
| 5951 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5952 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5953 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5954 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5955 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5956 | break; |
| 5957 | } |
| 5958 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 5959 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5960 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5961 | method; |
| 5962 | |
| 5963 | if (*option == '+') |
| 5964 | break; |
| 5965 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5966 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5967 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5968 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5969 | argv[i]); |
| 5970 | if (method < 0) |
| 5971 | ThrowMogrifyException(OptionError, |
| 5972 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 5973 | break; |
| 5974 | } |
| 5975 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5976 | } |
| 5977 | case 'w': |
| 5978 | { |
| 5979 | if (LocaleCompare("wave",option+1) == 0) |
| 5980 | { |
| 5981 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5982 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5983 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5984 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5985 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5986 | break; |
| 5987 | } |
| 5988 | if (LocaleCompare("weight",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-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5994 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5995 | break; |
| 5996 | } |
| 5997 | if (LocaleCompare("white-point",option+1) == 0) |
| 5998 | { |
| 5999 | if (*option == '+') |
| 6000 | break; |
| 6001 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6002 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6003 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6004 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6005 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6006 | break; |
| 6007 | } |
| 6008 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6009 | { |
| 6010 | if (*option == '+') |
| 6011 | break; |
| 6012 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6013 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6014 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6015 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6016 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6017 | break; |
| 6018 | } |
| 6019 | if (LocaleCompare("write",option+1) == 0) |
| 6020 | { |
| 6021 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6022 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6023 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6024 | break; |
| 6025 | } |
| 6026 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6027 | } |
| 6028 | case '?': |
| 6029 | break; |
| 6030 | default: |
| 6031 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6032 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6033 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 6034 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6035 | if (fire != MagickFalse) |
| 6036 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6037 | } |
| 6038 | if (k != 0) |
| 6039 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6040 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6041 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6042 | DestroyMogrify(); |
| 6043 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6044 | } |
| 6045 | |
| 6046 | /* |
| 6047 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6048 | % % |
| 6049 | % % |
| 6050 | % % |
| 6051 | + M o g r i f y I m a g e I n f o % |
| 6052 | % % |
| 6053 | % % |
| 6054 | % % |
| 6055 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6056 | % |
| 6057 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6058 | % prescribed by command line options. |
| 6059 | % |
| 6060 | % The format of the MogrifyImageInfo method is: |
| 6061 | % |
| 6062 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6063 | % const char **argv,ExceptionInfo *exception) |
| 6064 | % |
| 6065 | % A description of each parameter follows: |
| 6066 | % |
| 6067 | % o image_info: the image info.. |
| 6068 | % |
| 6069 | % o argc: Specifies a pointer to an integer describing the number of |
| 6070 | % elements in the argument vector. |
| 6071 | % |
| 6072 | % o argv: Specifies a pointer to a text array containing the command line |
| 6073 | % arguments. |
| 6074 | % |
| 6075 | % o exception: return any errors or warnings in this structure. |
| 6076 | % |
| 6077 | */ |
| 6078 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6079 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6080 | { |
| 6081 | const char |
| 6082 | *option; |
| 6083 | |
| 6084 | GeometryInfo |
| 6085 | geometry_info; |
| 6086 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6087 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6088 | count; |
| 6089 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6090 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6091 | i; |
| 6092 | |
| 6093 | /* |
| 6094 | Initialize method variables. |
| 6095 | */ |
| 6096 | assert(image_info != (ImageInfo *) NULL); |
| 6097 | assert(image_info->signature == MagickSignature); |
| 6098 | if (image_info->debug != MagickFalse) |
| 6099 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6100 | image_info->filename); |
| 6101 | if (argc < 0) |
| 6102 | return(MagickTrue); |
| 6103 | /* |
| 6104 | Set the image settings. |
| 6105 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6106 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6107 | { |
| 6108 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6109 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6110 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6111 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6112 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6113 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6114 | break; |
| 6115 | switch (*(option+1)) |
| 6116 | { |
| 6117 | case 'a': |
| 6118 | { |
| 6119 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6120 | { |
| 6121 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6122 | break; |
| 6123 | } |
| 6124 | if (LocaleCompare("antialias",option+1) == 0) |
| 6125 | { |
| 6126 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6127 | break; |
| 6128 | } |
| 6129 | if (LocaleCompare("attenuate",option+1) == 0) |
| 6130 | { |
| 6131 | if (*option == '+') |
| 6132 | { |
| 6133 | (void) DeleteImageOption(image_info,option+1); |
| 6134 | break; |
| 6135 | } |
| 6136 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6137 | break; |
| 6138 | } |
| 6139 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6140 | { |
| 6141 | if (*option == '+') |
| 6142 | (void) CloneString(&image_info->authenticate,(char *) NULL); |
| 6143 | else |
| 6144 | (void) CloneString(&image_info->authenticate,argv[i+1]); |
| 6145 | break; |
| 6146 | } |
| 6147 | break; |
| 6148 | } |
| 6149 | case 'b': |
| 6150 | { |
| 6151 | if (LocaleCompare("background",option+1) == 0) |
| 6152 | { |
| 6153 | if (*option == '+') |
| 6154 | { |
| 6155 | (void) DeleteImageOption(image_info,option+1); |
| 6156 | (void) QueryColorDatabase(BackgroundColor, |
| 6157 | &image_info->background_color,exception); |
| 6158 | break; |
| 6159 | } |
| 6160 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6161 | (void) QueryColorDatabase(argv[i+1],&image_info->background_color, |
| 6162 | exception); |
| 6163 | break; |
| 6164 | } |
| 6165 | if (LocaleCompare("bias",option+1) == 0) |
| 6166 | { |
| 6167 | if (*option == '+') |
| 6168 | { |
| 6169 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6170 | break; |
| 6171 | } |
| 6172 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6173 | break; |
| 6174 | } |
| 6175 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6176 | { |
| 6177 | if (*option == '+') |
| 6178 | { |
| 6179 | (void) SetImageOption(image_info,option+1,"false"); |
| 6180 | break; |
| 6181 | } |
| 6182 | (void) SetImageOption(image_info,option+1,"true"); |
| 6183 | break; |
| 6184 | } |
| 6185 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6186 | { |
| 6187 | if (*option == '+') |
| 6188 | { |
| 6189 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6190 | break; |
| 6191 | } |
| 6192 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6193 | break; |
| 6194 | } |
| 6195 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6196 | { |
| 6197 | if (*option == '+') |
| 6198 | { |
| 6199 | (void) DeleteImageOption(image_info,option+1); |
| 6200 | (void) QueryColorDatabase(BorderColor,&image_info->border_color, |
| 6201 | exception); |
| 6202 | break; |
| 6203 | } |
| 6204 | (void) QueryColorDatabase(argv[i+1],&image_info->border_color, |
| 6205 | exception); |
| 6206 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6207 | break; |
| 6208 | } |
| 6209 | if (LocaleCompare("box",option+1) == 0) |
| 6210 | { |
| 6211 | if (*option == '+') |
| 6212 | { |
| 6213 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6214 | break; |
| 6215 | } |
| 6216 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6217 | break; |
| 6218 | } |
| 6219 | break; |
| 6220 | } |
| 6221 | case 'c': |
| 6222 | { |
| 6223 | if (LocaleCompare("cache",option+1) == 0) |
| 6224 | { |
| 6225 | MagickSizeType |
| 6226 | limit; |
| 6227 | |
| 6228 | limit=MagickResourceInfinity; |
| 6229 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6230 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6231 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6232 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6233 | break; |
| 6234 | } |
| 6235 | if (LocaleCompare("caption",option+1) == 0) |
| 6236 | { |
| 6237 | if (*option == '+') |
| 6238 | { |
| 6239 | (void) DeleteImageOption(image_info,option+1); |
| 6240 | break; |
| 6241 | } |
| 6242 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6243 | break; |
| 6244 | } |
| 6245 | if (LocaleCompare("channel",option+1) == 0) |
| 6246 | { |
| 6247 | if (*option == '+') |
| 6248 | { |
| 6249 | image_info->channel=DefaultChannels; |
| 6250 | break; |
| 6251 | } |
| 6252 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6253 | break; |
| 6254 | } |
| 6255 | if (LocaleCompare("colors",option+1) == 0) |
| 6256 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6257 | image_info->colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6258 | break; |
| 6259 | } |
| 6260 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6261 | { |
| 6262 | if (*option == '+') |
| 6263 | { |
| 6264 | image_info->colorspace=UndefinedColorspace; |
| 6265 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6266 | break; |
| 6267 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6268 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6269 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6270 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6271 | break; |
| 6272 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6273 | if (LocaleCompare("comment",option+1) == 0) |
| 6274 | { |
| 6275 | if (*option == '+') |
| 6276 | { |
| 6277 | (void) DeleteImageOption(image_info,option+1); |
| 6278 | break; |
| 6279 | } |
| 6280 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6281 | break; |
| 6282 | } |
| 6283 | if (LocaleCompare("compose",option+1) == 0) |
| 6284 | { |
| 6285 | if (*option == '+') |
| 6286 | { |
| 6287 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6288 | break; |
| 6289 | } |
| 6290 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6291 | break; |
| 6292 | } |
| 6293 | if (LocaleCompare("compress",option+1) == 0) |
| 6294 | { |
| 6295 | if (*option == '+') |
| 6296 | { |
| 6297 | image_info->compression=UndefinedCompression; |
| 6298 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6299 | break; |
| 6300 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6301 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6302 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6303 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6304 | break; |
| 6305 | } |
| 6306 | break; |
| 6307 | } |
| 6308 | case 'd': |
| 6309 | { |
| 6310 | if (LocaleCompare("debug",option+1) == 0) |
| 6311 | { |
| 6312 | if (*option == '+') |
| 6313 | (void) SetLogEventMask("none"); |
| 6314 | else |
| 6315 | (void) SetLogEventMask(argv[i+1]); |
| 6316 | image_info->debug=IsEventLogging(); |
| 6317 | break; |
| 6318 | } |
| 6319 | if (LocaleCompare("define",option+1) == 0) |
| 6320 | { |
| 6321 | if (*option == '+') |
| 6322 | { |
| 6323 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6324 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6325 | else |
| 6326 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6327 | break; |
| 6328 | } |
| 6329 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6330 | { |
| 6331 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6332 | exception); |
| 6333 | break; |
| 6334 | } |
| 6335 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6336 | break; |
| 6337 | } |
| 6338 | if (LocaleCompare("delay",option+1) == 0) |
| 6339 | { |
| 6340 | if (*option == '+') |
| 6341 | { |
| 6342 | (void) SetImageOption(image_info,option+1,"0"); |
| 6343 | break; |
| 6344 | } |
| 6345 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6346 | break; |
| 6347 | } |
| 6348 | if (LocaleCompare("density",option+1) == 0) |
| 6349 | { |
| 6350 | /* |
| 6351 | Set image density. |
| 6352 | */ |
| 6353 | if (*option == '+') |
| 6354 | { |
| 6355 | if (image_info->density != (char *) NULL) |
| 6356 | image_info->density=DestroyString(image_info->density); |
| 6357 | (void) SetImageOption(image_info,option+1,"72"); |
| 6358 | break; |
| 6359 | } |
| 6360 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6361 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6362 | break; |
| 6363 | } |
| 6364 | if (LocaleCompare("depth",option+1) == 0) |
| 6365 | { |
| 6366 | if (*option == '+') |
| 6367 | { |
| 6368 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6369 | break; |
| 6370 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6371 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6372 | break; |
| 6373 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6374 | if (LocaleCompare("direction",option+1) == 0) |
| 6375 | { |
| 6376 | if (*option == '+') |
| 6377 | { |
| 6378 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6379 | break; |
| 6380 | } |
| 6381 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6382 | break; |
| 6383 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6384 | if (LocaleCompare("display",option+1) == 0) |
| 6385 | { |
| 6386 | if (*option == '+') |
| 6387 | { |
| 6388 | if (image_info->server_name != (char *) NULL) |
| 6389 | image_info->server_name=DestroyString( |
| 6390 | image_info->server_name); |
| 6391 | break; |
| 6392 | } |
| 6393 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6394 | break; |
| 6395 | } |
| 6396 | if (LocaleCompare("dispose",option+1) == 0) |
| 6397 | { |
| 6398 | if (*option == '+') |
| 6399 | { |
| 6400 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6401 | break; |
| 6402 | } |
| 6403 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6404 | break; |
| 6405 | } |
| 6406 | if (LocaleCompare("dither",option+1) == 0) |
| 6407 | { |
| 6408 | if (*option == '+') |
| 6409 | { |
| 6410 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6411 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6412 | break; |
| 6413 | } |
| 6414 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6415 | image_info->dither=MagickTrue; |
| 6416 | break; |
| 6417 | } |
| 6418 | break; |
| 6419 | } |
| 6420 | case 'e': |
| 6421 | { |
| 6422 | if (LocaleCompare("encoding",option+1) == 0) |
| 6423 | { |
| 6424 | if (*option == '+') |
| 6425 | { |
| 6426 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6427 | break; |
| 6428 | } |
| 6429 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6430 | break; |
| 6431 | } |
| 6432 | if (LocaleCompare("endian",option+1) == 0) |
| 6433 | { |
| 6434 | if (*option == '+') |
| 6435 | { |
| 6436 | image_info->endian=UndefinedEndian; |
| 6437 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6438 | break; |
| 6439 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6440 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6441 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6442 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6443 | break; |
| 6444 | } |
| 6445 | if (LocaleCompare("extract",option+1) == 0) |
| 6446 | { |
| 6447 | /* |
| 6448 | Set image extract geometry. |
| 6449 | */ |
| 6450 | if (*option == '+') |
| 6451 | { |
| 6452 | if (image_info->extract != (char *) NULL) |
| 6453 | image_info->extract=DestroyString(image_info->extract); |
| 6454 | break; |
| 6455 | } |
| 6456 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6457 | break; |
| 6458 | } |
| 6459 | break; |
| 6460 | } |
| 6461 | case 'f': |
| 6462 | { |
| 6463 | if (LocaleCompare("fill",option+1) == 0) |
| 6464 | { |
| 6465 | if (*option == '+') |
| 6466 | { |
| 6467 | (void) SetImageOption(image_info,option+1,"none"); |
| 6468 | break; |
| 6469 | } |
| 6470 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6471 | break; |
| 6472 | } |
| 6473 | if (LocaleCompare("filter",option+1) == 0) |
| 6474 | { |
| 6475 | if (*option == '+') |
| 6476 | { |
| 6477 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6478 | break; |
| 6479 | } |
| 6480 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6481 | break; |
| 6482 | } |
| 6483 | if (LocaleCompare("font",option+1) == 0) |
| 6484 | { |
| 6485 | if (*option == '+') |
| 6486 | { |
| 6487 | if (image_info->font != (char *) NULL) |
| 6488 | image_info->font=DestroyString(image_info->font); |
| 6489 | break; |
| 6490 | } |
| 6491 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6492 | break; |
| 6493 | } |
| 6494 | if (LocaleCompare("format",option+1) == 0) |
| 6495 | { |
| 6496 | register const char |
| 6497 | *q; |
| 6498 | |
| 6499 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6500 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6501 | image_info->ping=MagickFalse; |
| 6502 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6503 | break; |
| 6504 | } |
| 6505 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6506 | { |
| 6507 | if (*option == '+') |
| 6508 | { |
| 6509 | image_info->fuzz=0.0; |
| 6510 | (void) SetImageOption(image_info,option+1,"0"); |
| 6511 | break; |
| 6512 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6513 | image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6514 | 1.0); |
| 6515 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6516 | break; |
| 6517 | } |
| 6518 | break; |
| 6519 | } |
| 6520 | case 'g': |
| 6521 | { |
| 6522 | if (LocaleCompare("gravity",option+1) == 0) |
| 6523 | { |
| 6524 | if (*option == '+') |
| 6525 | { |
| 6526 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6527 | break; |
| 6528 | } |
| 6529 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6530 | break; |
| 6531 | } |
| 6532 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6533 | { |
| 6534 | if (*option == '+') |
| 6535 | { |
| 6536 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6537 | break; |
| 6538 | } |
| 6539 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6540 | break; |
| 6541 | } |
| 6542 | break; |
| 6543 | } |
| 6544 | case 'i': |
| 6545 | { |
| 6546 | if (LocaleCompare("intent",option+1) == 0) |
| 6547 | { |
| 6548 | if (*option == '+') |
| 6549 | { |
| 6550 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6551 | break; |
| 6552 | } |
| 6553 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6554 | break; |
| 6555 | } |
| 6556 | if (LocaleCompare("interlace",option+1) == 0) |
| 6557 | { |
| 6558 | if (*option == '+') |
| 6559 | { |
| 6560 | image_info->interlace=UndefinedInterlace; |
| 6561 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6562 | break; |
| 6563 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6564 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6565 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6566 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6567 | break; |
| 6568 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6569 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6570 | { |
| 6571 | if (*option == '+') |
| 6572 | { |
| 6573 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6574 | break; |
| 6575 | } |
| 6576 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6577 | break; |
| 6578 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6579 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6580 | { |
| 6581 | if (*option == '+') |
| 6582 | { |
| 6583 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6584 | break; |
| 6585 | } |
| 6586 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6587 | break; |
| 6588 | } |
| 6589 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6590 | { |
| 6591 | if (*option == '+') |
| 6592 | { |
| 6593 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6594 | break; |
| 6595 | } |
| 6596 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6597 | break; |
| 6598 | } |
| 6599 | break; |
| 6600 | } |
| 6601 | case 'k': |
| 6602 | { |
| 6603 | if (LocaleCompare("kerning",option+1) == 0) |
| 6604 | { |
| 6605 | if (*option == '+') |
| 6606 | { |
| 6607 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6608 | break; |
| 6609 | } |
| 6610 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6611 | break; |
| 6612 | } |
| 6613 | break; |
| 6614 | } |
| 6615 | case 'l': |
| 6616 | { |
| 6617 | if (LocaleCompare("label",option+1) == 0) |
| 6618 | { |
| 6619 | if (*option == '+') |
| 6620 | { |
| 6621 | (void) DeleteImageOption(image_info,option+1); |
| 6622 | break; |
| 6623 | } |
| 6624 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6625 | break; |
| 6626 | } |
| 6627 | if (LocaleCompare("limit",option+1) == 0) |
| 6628 | { |
| 6629 | MagickSizeType |
| 6630 | limit; |
| 6631 | |
| 6632 | ResourceType |
| 6633 | type; |
| 6634 | |
| 6635 | if (*option == '+') |
| 6636 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6637 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6638 | MagickFalse,argv[i+1]); |
| 6639 | limit=MagickResourceInfinity; |
| 6640 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6641 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6642 | (void) SetMagickResourceLimit(type,limit); |
| 6643 | break; |
| 6644 | } |
| 6645 | if (LocaleCompare("list",option+1) == 0) |
| 6646 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6647 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6648 | list; |
| 6649 | |
| 6650 | /* |
| 6651 | Display configuration list. |
| 6652 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6653 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6654 | switch (list) |
| 6655 | { |
| 6656 | case MagickCoderOptions: |
| 6657 | { |
| 6658 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6659 | break; |
| 6660 | } |
| 6661 | case MagickColorOptions: |
| 6662 | { |
| 6663 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6664 | break; |
| 6665 | } |
| 6666 | case MagickConfigureOptions: |
| 6667 | { |
| 6668 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6669 | break; |
| 6670 | } |
| 6671 | case MagickDelegateOptions: |
| 6672 | { |
| 6673 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6674 | break; |
| 6675 | } |
| 6676 | case MagickFontOptions: |
| 6677 | { |
| 6678 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6679 | break; |
| 6680 | } |
| 6681 | case MagickFormatOptions: |
| 6682 | { |
| 6683 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6684 | break; |
| 6685 | } |
| 6686 | case MagickLocaleOptions: |
| 6687 | { |
| 6688 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6689 | break; |
| 6690 | } |
| 6691 | case MagickLogOptions: |
| 6692 | { |
| 6693 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6694 | break; |
| 6695 | } |
| 6696 | case MagickMagicOptions: |
| 6697 | { |
| 6698 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6699 | break; |
| 6700 | } |
| 6701 | case MagickMimeOptions: |
| 6702 | { |
| 6703 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6704 | break; |
| 6705 | } |
| 6706 | case MagickModuleOptions: |
| 6707 | { |
| 6708 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6709 | break; |
| 6710 | } |
| 6711 | case MagickPolicyOptions: |
| 6712 | { |
| 6713 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6714 | break; |
| 6715 | } |
| 6716 | case MagickResourceOptions: |
| 6717 | { |
| 6718 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6719 | break; |
| 6720 | } |
| 6721 | case MagickThresholdOptions: |
| 6722 | { |
| 6723 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6724 | break; |
| 6725 | } |
| 6726 | default: |
| 6727 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6728 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6729 | exception); |
| 6730 | break; |
| 6731 | } |
| 6732 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6733 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6734 | } |
| 6735 | if (LocaleCompare("log",option+1) == 0) |
| 6736 | { |
| 6737 | if (*option == '+') |
| 6738 | break; |
| 6739 | (void) SetLogFormat(argv[i+1]); |
| 6740 | break; |
| 6741 | } |
| 6742 | if (LocaleCompare("loop",option+1) == 0) |
| 6743 | { |
| 6744 | if (*option == '+') |
| 6745 | { |
| 6746 | (void) SetImageOption(image_info,option+1,"0"); |
| 6747 | break; |
| 6748 | } |
| 6749 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6750 | break; |
| 6751 | } |
| 6752 | break; |
| 6753 | } |
| 6754 | case 'm': |
| 6755 | { |
| 6756 | if (LocaleCompare("matte",option+1) == 0) |
| 6757 | { |
| 6758 | if (*option == '+') |
| 6759 | { |
| 6760 | (void) SetImageOption(image_info,option+1,"false"); |
| 6761 | break; |
| 6762 | } |
| 6763 | (void) SetImageOption(image_info,option+1,"true"); |
| 6764 | break; |
| 6765 | } |
| 6766 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6767 | { |
| 6768 | if (*option == '+') |
| 6769 | { |
| 6770 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6771 | (void) QueryColorDatabase(MatteColor,&image_info->matte_color, |
| 6772 | exception); |
| 6773 | break; |
| 6774 | } |
| 6775 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6776 | (void) QueryColorDatabase(argv[i+1],&image_info->matte_color, |
| 6777 | exception); |
| 6778 | break; |
| 6779 | } |
| 6780 | if (LocaleCompare("monitor",option+1) == 0) |
| 6781 | { |
| 6782 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6783 | (void *) NULL); |
| 6784 | break; |
| 6785 | } |
| 6786 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6787 | { |
| 6788 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6789 | break; |
| 6790 | } |
| 6791 | break; |
| 6792 | } |
| 6793 | case 'o': |
| 6794 | { |
| 6795 | if (LocaleCompare("orient",option+1) == 0) |
| 6796 | { |
| 6797 | if (*option == '+') |
| 6798 | { |
| 6799 | image_info->orientation=UndefinedOrientation; |
| 6800 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6801 | break; |
| 6802 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6803 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6804 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6805 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6806 | break; |
| 6807 | } |
| 6808 | } |
| 6809 | case 'p': |
| 6810 | { |
| 6811 | if (LocaleCompare("page",option+1) == 0) |
| 6812 | { |
| 6813 | char |
| 6814 | *canonical_page, |
| 6815 | page[MaxTextExtent]; |
| 6816 | |
| 6817 | const char |
| 6818 | *image_option; |
| 6819 | |
| 6820 | MagickStatusType |
| 6821 | flags; |
| 6822 | |
| 6823 | RectangleInfo |
| 6824 | geometry; |
| 6825 | |
| 6826 | if (*option == '+') |
| 6827 | { |
| 6828 | (void) DeleteImageOption(image_info,option+1); |
| 6829 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6830 | break; |
| 6831 | } |
| 6832 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6833 | image_option=GetImageOption(image_info,"page"); |
| 6834 | if (image_option != (const char *) NULL) |
| 6835 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6836 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6837 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6838 | canonical_page=DestroyString(canonical_page); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6839 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6840 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6841 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6842 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6843 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6844 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6845 | (void) SetImageOption(image_info,option+1,page); |
| 6846 | (void) CloneString(&image_info->page,page); |
| 6847 | break; |
| 6848 | } |
| 6849 | if (LocaleCompare("pen",option+1) == 0) |
| 6850 | { |
| 6851 | if (*option == '+') |
| 6852 | { |
| 6853 | (void) SetImageOption(image_info,option+1,"none"); |
| 6854 | break; |
| 6855 | } |
| 6856 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6857 | break; |
| 6858 | } |
| 6859 | if (LocaleCompare("ping",option+1) == 0) |
| 6860 | { |
| 6861 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6862 | break; |
| 6863 | } |
| 6864 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6865 | { |
| 6866 | if (*option == '+') |
| 6867 | geometry_info.rho=0.0; |
| 6868 | else |
| 6869 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6870 | image_info->pointsize=geometry_info.rho; |
| 6871 | break; |
| 6872 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6873 | if (LocaleCompare("precision",option+1) == 0) |
| 6874 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6875 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6876 | break; |
| 6877 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6878 | if (LocaleCompare("preview",option+1) == 0) |
| 6879 | { |
| 6880 | /* |
| 6881 | Preview image. |
| 6882 | */ |
| 6883 | if (*option == '+') |
| 6884 | { |
| 6885 | image_info->preview_type=UndefinedPreview; |
| 6886 | break; |
| 6887 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6888 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6889 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6890 | break; |
| 6891 | } |
| 6892 | break; |
| 6893 | } |
| 6894 | case 'q': |
| 6895 | { |
| 6896 | if (LocaleCompare("quality",option+1) == 0) |
| 6897 | { |
| 6898 | /* |
| 6899 | Set image compression quality. |
| 6900 | */ |
| 6901 | if (*option == '+') |
| 6902 | { |
| 6903 | image_info->quality=UndefinedCompressionQuality; |
| 6904 | (void) SetImageOption(image_info,option+1,"0"); |
| 6905 | break; |
| 6906 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6907 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6908 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6909 | break; |
| 6910 | } |
| 6911 | if (LocaleCompare("quiet",option+1) == 0) |
| 6912 | { |
| 6913 | static WarningHandler |
| 6914 | warning_handler = (WarningHandler) NULL; |
| 6915 | |
| 6916 | if (*option == '+') |
| 6917 | { |
| 6918 | /* |
| 6919 | Restore error or warning messages. |
| 6920 | */ |
| 6921 | warning_handler=SetWarningHandler(warning_handler); |
| 6922 | break; |
| 6923 | } |
| 6924 | /* |
| 6925 | Suppress error or warning messages. |
| 6926 | */ |
| 6927 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6928 | break; |
| 6929 | } |
| 6930 | break; |
| 6931 | } |
| 6932 | case 'r': |
| 6933 | { |
| 6934 | if (LocaleCompare("red-primary",option+1) == 0) |
| 6935 | { |
| 6936 | if (*option == '+') |
| 6937 | { |
| 6938 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6939 | break; |
| 6940 | } |
| 6941 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6942 | break; |
| 6943 | } |
| 6944 | break; |
| 6945 | } |
| 6946 | case 's': |
| 6947 | { |
| 6948 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 6949 | { |
| 6950 | /* |
| 6951 | Set image sampling factor. |
| 6952 | */ |
| 6953 | if (*option == '+') |
| 6954 | { |
| 6955 | if (image_info->sampling_factor != (char *) NULL) |
| 6956 | image_info->sampling_factor=DestroyString( |
| 6957 | image_info->sampling_factor); |
| 6958 | break; |
| 6959 | } |
| 6960 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 6961 | break; |
| 6962 | } |
| 6963 | if (LocaleCompare("scene",option+1) == 0) |
| 6964 | { |
| 6965 | /* |
| 6966 | Set image scene. |
| 6967 | */ |
| 6968 | if (*option == '+') |
| 6969 | { |
| 6970 | image_info->scene=0; |
| 6971 | (void) SetImageOption(image_info,option+1,"0"); |
| 6972 | break; |
| 6973 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6974 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6975 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6976 | break; |
| 6977 | } |
| 6978 | if (LocaleCompare("seed",option+1) == 0) |
| 6979 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6980 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6981 | seed; |
| 6982 | |
| 6983 | if (*option == '+') |
| 6984 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6985 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6986 | SeedPseudoRandomGenerator(seed); |
| 6987 | break; |
| 6988 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6989 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6990 | SeedPseudoRandomGenerator(seed); |
| 6991 | break; |
| 6992 | } |
| 6993 | if (LocaleCompare("size",option+1) == 0) |
| 6994 | { |
| 6995 | if (*option == '+') |
| 6996 | { |
| 6997 | if (image_info->size != (char *) NULL) |
| 6998 | image_info->size=DestroyString(image_info->size); |
| 6999 | break; |
| 7000 | } |
| 7001 | (void) CloneString(&image_info->size,argv[i+1]); |
| 7002 | break; |
| 7003 | } |
| 7004 | if (LocaleCompare("stroke",option+1) == 0) |
| 7005 | { |
| 7006 | if (*option == '+') |
| 7007 | { |
| 7008 | (void) SetImageOption(image_info,option+1,"none"); |
| 7009 | break; |
| 7010 | } |
| 7011 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7012 | break; |
| 7013 | } |
| 7014 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7015 | { |
| 7016 | if (*option == '+') |
| 7017 | { |
| 7018 | (void) SetImageOption(image_info,option+1,"0"); |
| 7019 | break; |
| 7020 | } |
| 7021 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7022 | break; |
| 7023 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7024 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7025 | { |
| 7026 | if (*option == '+') |
| 7027 | { |
| 7028 | image_info->synchronize=MagickFalse; |
| 7029 | break; |
| 7030 | } |
| 7031 | image_info->synchronize=MagickTrue; |
| 7032 | break; |
| 7033 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7034 | break; |
| 7035 | } |
| 7036 | case 't': |
| 7037 | { |
| 7038 | if (LocaleCompare("taint",option+1) == 0) |
| 7039 | { |
| 7040 | if (*option == '+') |
| 7041 | { |
| 7042 | (void) SetImageOption(image_info,option+1,"false"); |
| 7043 | break; |
| 7044 | } |
| 7045 | (void) SetImageOption(image_info,option+1,"true"); |
| 7046 | break; |
| 7047 | } |
| 7048 | if (LocaleCompare("texture",option+1) == 0) |
| 7049 | { |
| 7050 | if (*option == '+') |
| 7051 | { |
| 7052 | if (image_info->texture != (char *) NULL) |
| 7053 | image_info->texture=DestroyString(image_info->texture); |
| 7054 | break; |
| 7055 | } |
| 7056 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7057 | break; |
| 7058 | } |
| 7059 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7060 | { |
| 7061 | if (*option == '+') |
| 7062 | { |
| 7063 | (void) SetImageOption(image_info,option+1,"0"); |
| 7064 | break; |
| 7065 | } |
| 7066 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7067 | break; |
| 7068 | } |
| 7069 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7070 | { |
| 7071 | if (*option == '+') |
| 7072 | { |
| 7073 | (void) QueryColorDatabase("none",&image_info->transparent_color, exception); |
| 7074 | (void) SetImageOption(image_info,option+1,"none"); |
| 7075 | break; |
| 7076 | } |
| 7077 | (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color, |
| 7078 | exception); |
| 7079 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7080 | break; |
| 7081 | } |
| 7082 | if (LocaleCompare("type",option+1) == 0) |
| 7083 | { |
| 7084 | if (*option == '+') |
| 7085 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7086 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7087 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7088 | break; |
| 7089 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7090 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7091 | MagickFalse,argv[i+1]); |
| 7092 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7093 | break; |
| 7094 | } |
| 7095 | break; |
| 7096 | } |
| 7097 | case 'u': |
| 7098 | { |
| 7099 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7100 | { |
| 7101 | if (*option == '+') |
| 7102 | { |
| 7103 | (void) DeleteImageOption(image_info,option+1); |
| 7104 | break; |
| 7105 | } |
| 7106 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7107 | break; |
| 7108 | } |
| 7109 | if (LocaleCompare("units",option+1) == 0) |
| 7110 | { |
| 7111 | if (*option == '+') |
| 7112 | { |
| 7113 | image_info->units=UndefinedResolution; |
| 7114 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7115 | break; |
| 7116 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7117 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7118 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7119 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7120 | break; |
| 7121 | } |
| 7122 | break; |
| 7123 | } |
| 7124 | case 'v': |
| 7125 | { |
| 7126 | if (LocaleCompare("verbose",option+1) == 0) |
| 7127 | { |
| 7128 | if (*option == '+') |
| 7129 | { |
| 7130 | image_info->verbose=MagickFalse; |
| 7131 | break; |
| 7132 | } |
| 7133 | image_info->verbose=MagickTrue; |
| 7134 | image_info->ping=MagickFalse; |
| 7135 | break; |
| 7136 | } |
| 7137 | if (LocaleCompare("view",option+1) == 0) |
| 7138 | { |
| 7139 | if (*option == '+') |
| 7140 | { |
| 7141 | if (image_info->view != (char *) NULL) |
| 7142 | image_info->view=DestroyString(image_info->view); |
| 7143 | break; |
| 7144 | } |
| 7145 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7146 | break; |
| 7147 | } |
| 7148 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7149 | { |
| 7150 | if (*option == '+') |
| 7151 | { |
| 7152 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7153 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7154 | break; |
| 7155 | } |
| 7156 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7157 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7158 | argv[i+1]); |
| 7159 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7160 | break; |
| 7161 | } |
| 7162 | break; |
| 7163 | } |
| 7164 | case 'w': |
| 7165 | { |
| 7166 | if (LocaleCompare("white-point",option+1) == 0) |
| 7167 | { |
| 7168 | if (*option == '+') |
| 7169 | { |
| 7170 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7171 | break; |
| 7172 | } |
| 7173 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7174 | break; |
| 7175 | } |
| 7176 | break; |
| 7177 | } |
| 7178 | default: |
| 7179 | break; |
| 7180 | } |
| 7181 | i+=count; |
| 7182 | } |
| 7183 | return(MagickTrue); |
| 7184 | } |
| 7185 | |
| 7186 | /* |
| 7187 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7188 | % % |
| 7189 | % % |
| 7190 | % % |
| 7191 | + M o g r i f y I m a g e L i s t % |
| 7192 | % % |
| 7193 | % % |
| 7194 | % % |
| 7195 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7196 | % |
| 7197 | % MogrifyImageList() applies any command line options that might affect the |
| 7198 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7199 | % |
| 7200 | % The format of the MogrifyImage method is: |
| 7201 | % |
| 7202 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7203 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7204 | % |
| 7205 | % A description of each parameter follows: |
| 7206 | % |
| 7207 | % o image_info: the image info.. |
| 7208 | % |
| 7209 | % o argc: Specifies a pointer to an integer describing the number of |
| 7210 | % elements in the argument vector. |
| 7211 | % |
| 7212 | % o argv: Specifies a pointer to a text array containing the command line |
| 7213 | % arguments. |
| 7214 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7215 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7216 | % |
| 7217 | % o exception: return any errors or warnings in this structure. |
| 7218 | % |
| 7219 | */ |
| 7220 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7221 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7222 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7223 | const char |
| 7224 | *option; |
| 7225 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7226 | ImageInfo |
| 7227 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7228 | |
| 7229 | MagickStatusType |
| 7230 | status; |
| 7231 | |
| 7232 | QuantizeInfo |
| 7233 | *quantize_info; |
| 7234 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7235 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7236 | i; |
| 7237 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7238 | ssize_t |
| 7239 | count, |
| 7240 | index; |
| 7241 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7242 | /* |
| 7243 | Apply options to the image list. |
| 7244 | */ |
| 7245 | assert(image_info != (ImageInfo *) NULL); |
| 7246 | assert(image_info->signature == MagickSignature); |
| 7247 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7248 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7249 | assert((*images)->signature == MagickSignature); |
| 7250 | if ((*images)->debug != MagickFalse) |
| 7251 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7252 | (*images)->filename); |
| 7253 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7254 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7255 | mogrify_info=CloneImageInfo(image_info); |
| 7256 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7257 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7258 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7259 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7260 | if (*images == (Image *) NULL) |
| 7261 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7262 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7263 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7264 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7265 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7266 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7267 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7268 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7269 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7270 | switch (*(option+1)) |
| 7271 | { |
| 7272 | case 'a': |
| 7273 | { |
| 7274 | if (LocaleCompare("affinity",option+1) == 0) |
| 7275 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7276 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7277 | if (*option == '+') |
| 7278 | { |
| 7279 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7280 | InheritException(exception,&(*images)->exception); |
| 7281 | break; |
| 7282 | } |
| 7283 | i++; |
| 7284 | break; |
| 7285 | } |
| 7286 | if (LocaleCompare("append",option+1) == 0) |
| 7287 | { |
| 7288 | Image |
| 7289 | *append_image; |
| 7290 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7291 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7292 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7293 | MagickFalse,exception); |
| 7294 | if (append_image == (Image *) NULL) |
| 7295 | { |
| 7296 | status=MagickFalse; |
| 7297 | break; |
| 7298 | } |
| 7299 | *images=DestroyImageList(*images); |
| 7300 | *images=append_image; |
| 7301 | break; |
| 7302 | } |
| 7303 | if (LocaleCompare("average",option+1) == 0) |
| 7304 | { |
| 7305 | Image |
| 7306 | *average_image; |
| 7307 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7308 | /* |
| 7309 | Average an image sequence (deprecated). |
| 7310 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7311 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7312 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7313 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7314 | if (average_image == (Image *) NULL) |
| 7315 | { |
| 7316 | status=MagickFalse; |
| 7317 | break; |
| 7318 | } |
| 7319 | *images=DestroyImageList(*images); |
| 7320 | *images=average_image; |
| 7321 | break; |
| 7322 | } |
| 7323 | break; |
| 7324 | } |
| 7325 | case 'c': |
| 7326 | { |
| 7327 | if (LocaleCompare("channel",option+1) == 0) |
| 7328 | { |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7329 | ChannelType |
| 7330 | channel; |
| 7331 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7332 | if (*option == '+') |
| 7333 | { |
| 7334 | channel=DefaultChannels; |
| 7335 | break; |
| 7336 | } |
| 7337 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 7338 | SetPixelChannelMap(*images,channel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7339 | break; |
| 7340 | } |
| 7341 | if (LocaleCompare("clut",option+1) == 0) |
| 7342 | { |
| 7343 | Image |
| 7344 | *clut_image, |
| 7345 | *image; |
| 7346 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7347 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7348 | image=RemoveFirstImageFromList(images); |
| 7349 | clut_image=RemoveFirstImageFromList(images); |
| 7350 | if (clut_image == (Image *) NULL) |
| 7351 | { |
| 7352 | status=MagickFalse; |
| 7353 | break; |
| 7354 | } |
cristy | f89cb1d | 2011-07-07 01:24:37 +0000 | [diff] [blame] | 7355 | (void) ClutImage(image,clut_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7356 | clut_image=DestroyImage(clut_image); |
| 7357 | InheritException(exception,&image->exception); |
| 7358 | *images=DestroyImageList(*images); |
| 7359 | *images=image; |
| 7360 | break; |
| 7361 | } |
| 7362 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7363 | { |
| 7364 | Image |
| 7365 | *coalesce_image; |
| 7366 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7367 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7368 | coalesce_image=CoalesceImages(*images,exception); |
| 7369 | if (coalesce_image == (Image *) NULL) |
| 7370 | { |
| 7371 | status=MagickFalse; |
| 7372 | break; |
| 7373 | } |
| 7374 | *images=DestroyImageList(*images); |
| 7375 | *images=coalesce_image; |
| 7376 | break; |
| 7377 | } |
| 7378 | if (LocaleCompare("combine",option+1) == 0) |
| 7379 | { |
| 7380 | Image |
| 7381 | *combine_image; |
| 7382 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7383 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 7384 | combine_image=CombineImages(*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7385 | if (combine_image == (Image *) NULL) |
| 7386 | { |
| 7387 | status=MagickFalse; |
| 7388 | break; |
| 7389 | } |
| 7390 | *images=DestroyImageList(*images); |
| 7391 | *images=combine_image; |
| 7392 | break; |
| 7393 | } |
| 7394 | if (LocaleCompare("composite",option+1) == 0) |
| 7395 | { |
| 7396 | Image |
| 7397 | *mask_image, |
| 7398 | *composite_image, |
| 7399 | *image; |
| 7400 | |
| 7401 | RectangleInfo |
| 7402 | geometry; |
| 7403 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7404 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7405 | image=RemoveFirstImageFromList(images); |
| 7406 | composite_image=RemoveFirstImageFromList(images); |
| 7407 | if (composite_image == (Image *) NULL) |
| 7408 | { |
| 7409 | status=MagickFalse; |
| 7410 | break; |
| 7411 | } |
| 7412 | (void) TransformImage(&composite_image,(char *) NULL, |
| 7413 | composite_image->geometry); |
| 7414 | SetGeometry(composite_image,&geometry); |
| 7415 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7416 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7417 | &geometry); |
| 7418 | mask_image=RemoveFirstImageFromList(images); |
| 7419 | if (mask_image != (Image *) NULL) |
| 7420 | { |
| 7421 | if ((image->compose == DisplaceCompositeOp) || |
| 7422 | (image->compose == DistortCompositeOp)) |
| 7423 | { |
| 7424 | /* |
| 7425 | Merge Y displacement into X displacement image. |
| 7426 | */ |
| 7427 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
| 7428 | mask_image,0,0); |
| 7429 | mask_image=DestroyImage(mask_image); |
| 7430 | } |
| 7431 | else |
| 7432 | { |
| 7433 | /* |
| 7434 | Set a blending mask for the composition. |
| 7435 | */ |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7436 | /* POSIBLE ERROR; what if image->mask already set */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7437 | image->mask=mask_image; |
| 7438 | (void) NegateImage(image->mask,MagickFalse); |
| 7439 | } |
| 7440 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7441 | (void) CompositeImage(image,image->compose,composite_image, |
| 7442 | geometry.x,geometry.y); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7443 | if (mask_image != (Image *) NULL) |
| 7444 | mask_image=image->mask=DestroyImage(image->mask); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7445 | composite_image=DestroyImage(composite_image); |
| 7446 | InheritException(exception,&image->exception); |
| 7447 | *images=DestroyImageList(*images); |
| 7448 | *images=image; |
| 7449 | break; |
| 7450 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7451 | #if 0 |
| 7452 | This has been merged completely into MogrifyImage() |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7453 | if (LocaleCompare("crop",option+1) == 0) |
| 7454 | { |
| 7455 | MagickStatusType |
| 7456 | flags; |
| 7457 | |
| 7458 | RectangleInfo |
| 7459 | geometry; |
| 7460 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7461 | /* |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7462 | Crop Image. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7463 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7464 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7465 | flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception); |
| 7466 | if (((geometry.width == 0) && (geometry.height == 0)) || |
| 7467 | ((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 7468 | break; |
| 7469 | (void) TransformImages(images,argv[i+1],(char *) NULL); |
| 7470 | InheritException(exception,&(*images)->exception); |
| 7471 | break; |
| 7472 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7473 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7474 | break; |
| 7475 | } |
| 7476 | case 'd': |
| 7477 | { |
| 7478 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7479 | { |
| 7480 | Image |
| 7481 | *deconstruct_image; |
| 7482 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7483 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7484 | deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer, |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 7485 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7486 | if (deconstruct_image == (Image *) NULL) |
| 7487 | { |
| 7488 | status=MagickFalse; |
| 7489 | break; |
| 7490 | } |
| 7491 | *images=DestroyImageList(*images); |
| 7492 | *images=deconstruct_image; |
| 7493 | break; |
| 7494 | } |
| 7495 | if (LocaleCompare("delete",option+1) == 0) |
| 7496 | { |
| 7497 | if (*option == '+') |
| 7498 | DeleteImages(images,"-1",exception); |
| 7499 | else |
| 7500 | DeleteImages(images,argv[i+1],exception); |
| 7501 | break; |
| 7502 | } |
| 7503 | if (LocaleCompare("dither",option+1) == 0) |
| 7504 | { |
| 7505 | if (*option == '+') |
| 7506 | { |
| 7507 | quantize_info->dither=MagickFalse; |
| 7508 | break; |
| 7509 | } |
| 7510 | quantize_info->dither=MagickTrue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7511 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7512 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7513 | break; |
| 7514 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7515 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7516 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7517 | Image |
| 7518 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7519 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7520 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7521 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7522 | else |
| 7523 | { |
| 7524 | const char |
| 7525 | *p; |
| 7526 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7527 | size_t |
| 7528 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7529 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7530 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7531 | p=strchr(argv[i+1],','); |
| 7532 | if (p == (const char *) NULL) |
| 7533 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7534 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7535 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7536 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7537 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7538 | } |
| 7539 | AppendImageToList(images, duplicate_images); |
| 7540 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7541 | break; |
| 7542 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7543 | break; |
| 7544 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7545 | case 'e': |
| 7546 | { |
| 7547 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7548 | { |
| 7549 | Image |
| 7550 | *evaluate_image; |
| 7551 | |
| 7552 | MagickEvaluateOperator |
| 7553 | op; |
| 7554 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7555 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7556 | op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions, |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7557 | MagickFalse,argv[i+1]); |
| 7558 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7559 | if (evaluate_image == (Image *) NULL) |
| 7560 | { |
| 7561 | status=MagickFalse; |
| 7562 | break; |
| 7563 | } |
| 7564 | *images=DestroyImageList(*images); |
| 7565 | *images=evaluate_image; |
| 7566 | break; |
| 7567 | } |
| 7568 | break; |
| 7569 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7570 | case 'f': |
| 7571 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7572 | if (LocaleCompare("fft",option+1) == 0) |
| 7573 | { |
| 7574 | Image |
| 7575 | *fourier_image; |
| 7576 | |
| 7577 | /* |
| 7578 | Implements the discrete Fourier transform (DFT). |
| 7579 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7580 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7581 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7582 | MagickTrue : MagickFalse,exception); |
| 7583 | if (fourier_image == (Image *) NULL) |
| 7584 | break; |
| 7585 | *images=DestroyImage(*images); |
| 7586 | *images=fourier_image; |
| 7587 | break; |
| 7588 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7589 | if (LocaleCompare("flatten",option+1) == 0) |
| 7590 | { |
| 7591 | Image |
| 7592 | *flatten_image; |
| 7593 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7594 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7595 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7596 | if (flatten_image == (Image *) NULL) |
| 7597 | break; |
| 7598 | *images=DestroyImageList(*images); |
| 7599 | *images=flatten_image; |
| 7600 | break; |
| 7601 | } |
| 7602 | if (LocaleCompare("fx",option+1) == 0) |
| 7603 | { |
| 7604 | Image |
| 7605 | *fx_image; |
| 7606 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7607 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 7608 | fx_image=FxImage(*images,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7609 | if (fx_image == (Image *) NULL) |
| 7610 | { |
| 7611 | status=MagickFalse; |
| 7612 | break; |
| 7613 | } |
| 7614 | *images=DestroyImageList(*images); |
| 7615 | *images=fx_image; |
| 7616 | break; |
| 7617 | } |
| 7618 | break; |
| 7619 | } |
| 7620 | case 'h': |
| 7621 | { |
| 7622 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7623 | { |
| 7624 | Image |
| 7625 | *hald_image, |
| 7626 | *image; |
| 7627 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7628 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7629 | image=RemoveFirstImageFromList(images); |
| 7630 | hald_image=RemoveFirstImageFromList(images); |
| 7631 | if (hald_image == (Image *) NULL) |
| 7632 | { |
| 7633 | status=MagickFalse; |
| 7634 | break; |
| 7635 | } |
cristy | f89cb1d | 2011-07-07 01:24:37 +0000 | [diff] [blame] | 7636 | (void) HaldClutImage(image,hald_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7637 | hald_image=DestroyImage(hald_image); |
| 7638 | InheritException(exception,&image->exception); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7639 | if (*images != (Image *) NULL) |
| 7640 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7641 | *images=image; |
| 7642 | break; |
| 7643 | } |
| 7644 | break; |
| 7645 | } |
| 7646 | case 'i': |
| 7647 | { |
| 7648 | if (LocaleCompare("ift",option+1) == 0) |
| 7649 | { |
| 7650 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7651 | *fourier_image, |
| 7652 | *magnitude_image, |
| 7653 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7654 | |
| 7655 | /* |
| 7656 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7657 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7658 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7659 | magnitude_image=RemoveFirstImageFromList(images); |
| 7660 | phase_image=RemoveFirstImageFromList(images); |
| 7661 | if (phase_image == (Image *) NULL) |
| 7662 | { |
| 7663 | status=MagickFalse; |
| 7664 | break; |
| 7665 | } |
| 7666 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7667 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7668 | if (fourier_image == (Image *) NULL) |
| 7669 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7670 | if (*images != (Image *) NULL) |
| 7671 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7672 | *images=fourier_image; |
| 7673 | break; |
| 7674 | } |
| 7675 | if (LocaleCompare("insert",option+1) == 0) |
| 7676 | { |
| 7677 | Image |
| 7678 | *p, |
| 7679 | *q; |
| 7680 | |
| 7681 | index=0; |
| 7682 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7683 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7684 | p=RemoveLastImageFromList(images); |
| 7685 | if (p == (Image *) NULL) |
| 7686 | { |
| 7687 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7688 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7689 | status=MagickFalse; |
| 7690 | break; |
| 7691 | } |
| 7692 | q=p; |
| 7693 | if (index == 0) |
| 7694 | PrependImageToList(images,q); |
| 7695 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7696 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7697 | AppendImageToList(images,q); |
| 7698 | else |
| 7699 | { |
| 7700 | q=GetImageFromList(*images,index-1); |
| 7701 | if (q == (Image *) NULL) |
| 7702 | { |
| 7703 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7704 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7705 | status=MagickFalse; |
| 7706 | break; |
| 7707 | } |
| 7708 | InsertImageInList(&q,p); |
| 7709 | } |
| 7710 | *images=GetFirstImageInList(q); |
| 7711 | break; |
| 7712 | } |
| 7713 | break; |
| 7714 | } |
| 7715 | case 'l': |
| 7716 | { |
| 7717 | if (LocaleCompare("layers",option+1) == 0) |
| 7718 | { |
| 7719 | Image |
| 7720 | *layers; |
| 7721 | |
| 7722 | ImageLayerMethod |
| 7723 | method; |
| 7724 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7725 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7726 | layers=(Image *) NULL; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7727 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7728 | MagickFalse,argv[i+1]); |
| 7729 | switch (method) |
| 7730 | { |
| 7731 | case CoalesceLayer: |
| 7732 | { |
| 7733 | layers=CoalesceImages(*images,exception); |
| 7734 | break; |
| 7735 | } |
| 7736 | case CompareAnyLayer: |
| 7737 | case CompareClearLayer: |
| 7738 | case CompareOverlayLayer: |
| 7739 | default: |
| 7740 | { |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7741 | layers=CompareImagesLayers(*images,method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7742 | break; |
| 7743 | } |
| 7744 | case MergeLayer: |
| 7745 | case FlattenLayer: |
| 7746 | case MosaicLayer: |
| 7747 | case TrimBoundsLayer: |
| 7748 | { |
| 7749 | layers=MergeImageLayers(*images,method,exception); |
| 7750 | break; |
| 7751 | } |
| 7752 | case DisposeLayer: |
| 7753 | { |
| 7754 | layers=DisposeImages(*images,exception); |
| 7755 | break; |
| 7756 | } |
| 7757 | case OptimizeImageLayer: |
| 7758 | { |
| 7759 | layers=OptimizeImageLayers(*images,exception); |
| 7760 | break; |
| 7761 | } |
| 7762 | case OptimizePlusLayer: |
| 7763 | { |
| 7764 | layers=OptimizePlusImageLayers(*images,exception); |
| 7765 | break; |
| 7766 | } |
| 7767 | case OptimizeTransLayer: |
| 7768 | { |
| 7769 | OptimizeImageTransparency(*images,exception); |
| 7770 | break; |
| 7771 | } |
| 7772 | case RemoveDupsLayer: |
| 7773 | { |
| 7774 | RemoveDuplicateLayers(images,exception); |
| 7775 | break; |
| 7776 | } |
| 7777 | case RemoveZeroLayer: |
| 7778 | { |
| 7779 | RemoveZeroDelayLayers(images,exception); |
| 7780 | break; |
| 7781 | } |
| 7782 | case OptimizeLayer: |
| 7783 | { |
| 7784 | /* |
| 7785 | General Purpose, GIF Animation Optimizer. |
| 7786 | */ |
| 7787 | layers=CoalesceImages(*images,exception); |
| 7788 | if (layers == (Image *) NULL) |
| 7789 | { |
| 7790 | status=MagickFalse; |
| 7791 | break; |
| 7792 | } |
| 7793 | InheritException(exception,&layers->exception); |
| 7794 | *images=DestroyImageList(*images); |
| 7795 | *images=layers; |
| 7796 | layers=OptimizeImageLayers(*images,exception); |
| 7797 | if (layers == (Image *) NULL) |
| 7798 | { |
| 7799 | status=MagickFalse; |
| 7800 | break; |
| 7801 | } |
| 7802 | InheritException(exception,&layers->exception); |
| 7803 | *images=DestroyImageList(*images); |
| 7804 | *images=layers; |
| 7805 | layers=(Image *) NULL; |
| 7806 | OptimizeImageTransparency(*images,exception); |
| 7807 | InheritException(exception,&(*images)->exception); |
| 7808 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7809 | break; |
| 7810 | } |
| 7811 | case CompositeLayer: |
| 7812 | { |
| 7813 | CompositeOperator |
| 7814 | compose; |
| 7815 | |
| 7816 | Image |
| 7817 | *source; |
| 7818 | |
| 7819 | RectangleInfo |
| 7820 | geometry; |
| 7821 | |
| 7822 | /* |
| 7823 | Split image sequence at the first 'NULL:' image. |
| 7824 | */ |
| 7825 | source=(*images); |
| 7826 | while (source != (Image *) NULL) |
| 7827 | { |
| 7828 | source=GetNextImageInList(source); |
| 7829 | if ((source != (Image *) NULL) && |
| 7830 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7831 | break; |
| 7832 | } |
| 7833 | if (source != (Image *) NULL) |
| 7834 | { |
| 7835 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7836 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7837 | source=(Image *) NULL; |
| 7838 | else |
| 7839 | { |
| 7840 | /* |
| 7841 | Separate the two lists, junk the null: image. |
| 7842 | */ |
| 7843 | source=SplitImageList(source->previous); |
| 7844 | DeleteImageFromList(&source); |
| 7845 | } |
| 7846 | } |
| 7847 | if (source == (Image *) NULL) |
| 7848 | { |
| 7849 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7850 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7851 | status=MagickFalse; |
| 7852 | break; |
| 7853 | } |
| 7854 | /* |
| 7855 | Adjust offset with gravity and virtual canvas. |
| 7856 | */ |
| 7857 | SetGeometry(*images,&geometry); |
| 7858 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7859 | geometry.width=source->page.width != 0 ? |
| 7860 | source->page.width : source->columns; |
| 7861 | geometry.height=source->page.height != 0 ? |
| 7862 | source->page.height : source->rows; |
| 7863 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7864 | (*images)->page.width : (*images)->columns, |
| 7865 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7866 | (*images)->rows,(*images)->gravity,&geometry); |
| 7867 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7868 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7869 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7870 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7871 | MagickComposeOptions,MagickFalse,option); |
| 7872 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7873 | exception); |
| 7874 | source=DestroyImageList(source); |
| 7875 | break; |
| 7876 | } |
| 7877 | } |
| 7878 | if (layers == (Image *) NULL) |
| 7879 | break; |
| 7880 | InheritException(exception,&layers->exception); |
| 7881 | *images=DestroyImageList(*images); |
| 7882 | *images=layers; |
| 7883 | break; |
| 7884 | } |
| 7885 | break; |
| 7886 | } |
| 7887 | case 'm': |
| 7888 | { |
| 7889 | if (LocaleCompare("map",option+1) == 0) |
| 7890 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7891 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7892 | if (*option == '+') |
| 7893 | { |
| 7894 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7895 | InheritException(exception,&(*images)->exception); |
| 7896 | break; |
| 7897 | } |
| 7898 | i++; |
| 7899 | break; |
| 7900 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7901 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7902 | { |
| 7903 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7904 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7905 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7906 | /* |
| 7907 | Maximum image sequence (deprecated). |
| 7908 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7909 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7910 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7911 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7912 | { |
| 7913 | status=MagickFalse; |
| 7914 | break; |
| 7915 | } |
| 7916 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7917 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7918 | break; |
| 7919 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7920 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7921 | { |
| 7922 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7923 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7924 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7925 | /* |
| 7926 | Minimum image sequence (deprecated). |
| 7927 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7928 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7929 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7930 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7931 | { |
| 7932 | status=MagickFalse; |
| 7933 | break; |
| 7934 | } |
| 7935 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7936 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7937 | break; |
| 7938 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7939 | if (LocaleCompare("morph",option+1) == 0) |
| 7940 | { |
| 7941 | Image |
| 7942 | *morph_image; |
| 7943 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7944 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7945 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7946 | exception); |
| 7947 | if (morph_image == (Image *) NULL) |
| 7948 | { |
| 7949 | status=MagickFalse; |
| 7950 | break; |
| 7951 | } |
| 7952 | *images=DestroyImageList(*images); |
| 7953 | *images=morph_image; |
| 7954 | break; |
| 7955 | } |
| 7956 | if (LocaleCompare("mosaic",option+1) == 0) |
| 7957 | { |
| 7958 | Image |
| 7959 | *mosaic_image; |
| 7960 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7961 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7962 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 7963 | if (mosaic_image == (Image *) NULL) |
| 7964 | { |
| 7965 | status=MagickFalse; |
| 7966 | break; |
| 7967 | } |
| 7968 | *images=DestroyImageList(*images); |
| 7969 | *images=mosaic_image; |
| 7970 | break; |
| 7971 | } |
| 7972 | break; |
| 7973 | } |
| 7974 | case 'p': |
| 7975 | { |
| 7976 | if (LocaleCompare("print",option+1) == 0) |
| 7977 | { |
| 7978 | char |
| 7979 | *string; |
| 7980 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7981 | (void) SyncImagesSettings(mogrify_info,*images); |
| 7982 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7983 | if (string == (char *) NULL) |
| 7984 | break; |
| 7985 | InheritException(exception,&(*images)->exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 7986 | (void) FormatLocaleFile(stdout,"%s",string); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7987 | string=DestroyString(string); |
| 7988 | } |
| 7989 | if (LocaleCompare("process",option+1) == 0) |
| 7990 | { |
| 7991 | char |
| 7992 | **arguments; |
| 7993 | |
| 7994 | int |
| 7995 | j, |
| 7996 | number_arguments; |
| 7997 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7998 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7999 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 8000 | if (arguments == (char **) NULL) |
| 8001 | break; |
| 8002 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 8003 | { |
| 8004 | char |
| 8005 | breaker, |
| 8006 | quote, |
| 8007 | *token; |
| 8008 | |
| 8009 | const char |
| 8010 | *arguments; |
| 8011 | |
| 8012 | int |
| 8013 | next, |
| 8014 | status; |
| 8015 | |
| 8016 | size_t |
| 8017 | length; |
| 8018 | |
| 8019 | TokenInfo |
| 8020 | *token_info; |
| 8021 | |
| 8022 | /* |
| 8023 | Support old style syntax, filter="-option arg". |
| 8024 | */ |
| 8025 | length=strlen(argv[i+1]); |
| 8026 | token=(char *) NULL; |
cristy | 37e0b38 | 2011-06-07 13:31:21 +0000 | [diff] [blame] | 8027 | if (~length >= (MaxTextExtent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8028 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8029 | sizeof(*token)); |
| 8030 | if (token == (char *) NULL) |
| 8031 | break; |
| 8032 | next=0; |
| 8033 | arguments=argv[i+1]; |
| 8034 | token_info=AcquireTokenInfo(); |
| 8035 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8036 | "\"",'\0',&breaker,&next,"e); |
| 8037 | token_info=DestroyTokenInfo(token_info); |
| 8038 | if (status == 0) |
| 8039 | { |
| 8040 | const char |
| 8041 | *argv; |
| 8042 | |
| 8043 | argv=(&(arguments[next])); |
| 8044 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8045 | exception); |
| 8046 | } |
| 8047 | token=DestroyString(token); |
| 8048 | break; |
| 8049 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8050 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8051 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8052 | number_arguments-2,(const char **) arguments+2,exception); |
| 8053 | for (j=0; j < number_arguments; j++) |
| 8054 | arguments[j]=DestroyString(arguments[j]); |
| 8055 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8056 | break; |
| 8057 | } |
| 8058 | break; |
| 8059 | } |
| 8060 | case 'r': |
| 8061 | { |
| 8062 | if (LocaleCompare("reverse",option+1) == 0) |
| 8063 | { |
| 8064 | ReverseImageList(images); |
| 8065 | InheritException(exception,&(*images)->exception); |
| 8066 | break; |
| 8067 | } |
| 8068 | break; |
| 8069 | } |
| 8070 | case 's': |
| 8071 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8072 | if (LocaleCompare("smush",option+1) == 0) |
| 8073 | { |
| 8074 | Image |
| 8075 | *smush_image; |
| 8076 | |
| 8077 | ssize_t |
| 8078 | offset; |
| 8079 | |
| 8080 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8081 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8082 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8083 | MagickFalse,offset,exception); |
| 8084 | if (smush_image == (Image *) NULL) |
| 8085 | { |
| 8086 | status=MagickFalse; |
| 8087 | break; |
| 8088 | } |
| 8089 | *images=DestroyImageList(*images); |
| 8090 | *images=smush_image; |
| 8091 | break; |
| 8092 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8093 | if (LocaleCompare("swap",option+1) == 0) |
| 8094 | { |
| 8095 | Image |
| 8096 | *p, |
| 8097 | *q, |
| 8098 | *swap; |
| 8099 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8100 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8101 | swap_index; |
| 8102 | |
| 8103 | index=(-1); |
| 8104 | swap_index=(-2); |
| 8105 | if (*option != '+') |
| 8106 | { |
| 8107 | GeometryInfo |
| 8108 | geometry_info; |
| 8109 | |
| 8110 | MagickStatusType |
| 8111 | flags; |
| 8112 | |
| 8113 | swap_index=(-1); |
| 8114 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8115 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8116 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8117 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8118 | } |
| 8119 | p=GetImageFromList(*images,index); |
| 8120 | q=GetImageFromList(*images,swap_index); |
| 8121 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8122 | { |
| 8123 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8124 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8125 | status=MagickFalse; |
| 8126 | break; |
| 8127 | } |
| 8128 | if (p == q) |
| 8129 | break; |
| 8130 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8131 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8132 | ReplaceImageInList(&q,swap); |
| 8133 | *images=GetFirstImageInList(q); |
| 8134 | break; |
| 8135 | } |
| 8136 | break; |
| 8137 | } |
| 8138 | case 'w': |
| 8139 | { |
| 8140 | if (LocaleCompare("write",option+1) == 0) |
| 8141 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8142 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8143 | key[MaxTextExtent]; |
| 8144 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8145 | Image |
| 8146 | *write_images; |
| 8147 | |
| 8148 | ImageInfo |
| 8149 | *write_info; |
| 8150 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8151 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8152 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8153 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8154 | write_images=(*images); |
| 8155 | if (*option == '+') |
| 8156 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8157 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8158 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8159 | write_info=DestroyImageInfo(write_info); |
| 8160 | if (*option == '+') |
| 8161 | write_images=DestroyImageList(write_images); |
| 8162 | break; |
| 8163 | } |
| 8164 | break; |
| 8165 | } |
| 8166 | default: |
| 8167 | break; |
| 8168 | } |
| 8169 | i+=count; |
| 8170 | } |
| 8171 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8172 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8173 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8174 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8175 | } |
| 8176 | |
| 8177 | /* |
| 8178 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8179 | % % |
| 8180 | % % |
| 8181 | % % |
| 8182 | + M o g r i f y I m a g e s % |
| 8183 | % % |
| 8184 | % % |
| 8185 | % % |
| 8186 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8187 | % |
| 8188 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8189 | % prescribed by command line options. |
| 8190 | % |
| 8191 | % The format of the MogrifyImage method is: |
| 8192 | % |
| 8193 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8194 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8195 | % Image **images,Exceptioninfo *exception) |
| 8196 | % |
| 8197 | % A description of each parameter follows: |
| 8198 | % |
| 8199 | % o image_info: the image info.. |
| 8200 | % |
| 8201 | % o post: If true, post process image list operators otherwise pre-process. |
| 8202 | % |
| 8203 | % o argc: Specifies a pointer to an integer describing the number of |
| 8204 | % elements in the argument vector. |
| 8205 | % |
| 8206 | % o argv: Specifies a pointer to a text array containing the command line |
| 8207 | % arguments. |
| 8208 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8209 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8210 | % |
| 8211 | % o exception: return any errors or warnings in this structure. |
| 8212 | % |
| 8213 | */ |
| 8214 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8215 | const MagickBooleanType post,const int argc,const char **argv, |
| 8216 | Image **images,ExceptionInfo *exception) |
| 8217 | { |
| 8218 | #define MogrifyImageTag "Mogrify/Image" |
| 8219 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8220 | MagickStatusType |
| 8221 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8222 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8223 | MagickBooleanType |
| 8224 | proceed; |
| 8225 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8226 | size_t |
| 8227 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8228 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8229 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8230 | i; |
| 8231 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8232 | assert(image_info != (ImageInfo *) NULL); |
| 8233 | assert(image_info->signature == MagickSignature); |
| 8234 | if (images == (Image **) NULL) |
| 8235 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8236 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8237 | assert((*images)->signature == MagickSignature); |
| 8238 | if ((*images)->debug != MagickFalse) |
| 8239 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8240 | (*images)->filename); |
| 8241 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8242 | return(MagickTrue); |
| 8243 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8244 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8245 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8246 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8247 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8248 | (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc, |
| 8249 | post?"post":"pre"); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8250 | #endif |
| 8251 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8252 | /* |
| 8253 | Pre-process multi-image sequence operators |
| 8254 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8255 | if (post == MagickFalse) |
| 8256 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8257 | /* |
| 8258 | For each image, process simple single image operators |
| 8259 | */ |
| 8260 | i=0; |
| 8261 | n=GetImageListLength(*images); |
| 8262 | for (;;) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8263 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8264 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8265 | (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long) |
| 8266 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8267 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8268 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8269 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8270 | if (proceed == MagickFalse) |
| 8271 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8272 | if ( (*images)->next == (Image *) NULL ) |
| 8273 | break; |
| 8274 | *images=(*images)->next; |
| 8275 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8276 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8277 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8278 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8279 | (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long) |
| 8280 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8281 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8282 | |
| 8283 | /* |
| 8284 | Post-process, multi-image sequence operators |
| 8285 | */ |
| 8286 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8287 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8288 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8289 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8290 | } |