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 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1200 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1201 | kernel_info=AcquireKernelInfo(argv[i+1]); |
| 1202 | if (kernel_info == (KernelInfo *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1203 | break; |
cristy | 5e6be1e | 2011-07-16 01:23:39 +0000 | [diff] [blame^] | 1204 | mogrify_image=ConvolveImage(*image,kernel_info,exception); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1205 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1206 | break; |
| 1207 | } |
| 1208 | if (LocaleCompare("crop",option+1) == 0) |
| 1209 | { |
| 1210 | /* |
| 1211 | Crop a image to a smaller size |
| 1212 | */ |
| 1213 | (void) SyncImageSettings(mogrify_info,*image); |
| 1214 | #if 0 |
| 1215 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1216 | if (((geometry.width != 0) || (geometry.height != 0)) && |
| 1217 | ((flags & XValue) == 0) && ((flags & YValue) == 0)) |
| 1218 | break; |
| 1219 | #endif |
| 1220 | #if 0 |
| 1221 | mogrify_image=CloneImage(*image,0,0,MagickTrue,&(*image)->exception); |
| 1222 | mogrify_image->next = mogrify_image->previous = (Image *)NULL; |
| 1223 | (void) TransformImage(&mogrify_image,argv[i+1],(char *) NULL); |
| 1224 | InheritException(exception,&mogrify_image->exception); |
| 1225 | #else |
| 1226 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
| 1227 | #endif |
| 1228 | break; |
| 1229 | } |
| 1230 | if (LocaleCompare("cycle",option+1) == 0) |
| 1231 | { |
| 1232 | /* |
| 1233 | Cycle an image colormap. |
| 1234 | */ |
| 1235 | (void) SyncImageSettings(mogrify_info,*image); |
| 1236 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1])); |
| 1237 | InheritException(exception,&(*image)->exception); |
| 1238 | break; |
| 1239 | } |
| 1240 | break; |
| 1241 | } |
| 1242 | case 'd': |
| 1243 | { |
| 1244 | if (LocaleCompare("decipher",option+1) == 0) |
| 1245 | { |
| 1246 | StringInfo |
| 1247 | *passkey; |
| 1248 | |
| 1249 | /* |
| 1250 | Decipher pixels. |
| 1251 | */ |
| 1252 | (void) SyncImageSettings(mogrify_info,*image); |
| 1253 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1254 | if (passkey != (StringInfo *) NULL) |
| 1255 | { |
| 1256 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1257 | passkey=DestroyStringInfo(passkey); |
| 1258 | } |
| 1259 | break; |
| 1260 | } |
| 1261 | if (LocaleCompare("density",option+1) == 0) |
| 1262 | { |
| 1263 | /* |
| 1264 | Set image density. |
| 1265 | */ |
| 1266 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1267 | break; |
| 1268 | } |
| 1269 | if (LocaleCompare("depth",option+1) == 0) |
| 1270 | { |
| 1271 | (void) SyncImageSettings(mogrify_info,*image); |
| 1272 | if (*option == '+') |
| 1273 | { |
| 1274 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH); |
| 1275 | break; |
| 1276 | } |
| 1277 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1])); |
| 1278 | break; |
| 1279 | } |
| 1280 | if (LocaleCompare("deskew",option+1) == 0) |
| 1281 | { |
| 1282 | double |
| 1283 | threshold; |
| 1284 | |
| 1285 | /* |
| 1286 | Straighten the image. |
| 1287 | */ |
| 1288 | (void) SyncImageSettings(mogrify_info,*image); |
| 1289 | if (*option == '+') |
| 1290 | threshold=40.0*QuantumRange/100.0; |
| 1291 | else |
| 1292 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 1293 | mogrify_image=DeskewImage(*image,threshold,exception); |
| 1294 | break; |
| 1295 | } |
| 1296 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1297 | { |
| 1298 | /* |
| 1299 | Reduce the speckles within an image. |
| 1300 | */ |
| 1301 | (void) SyncImageSettings(mogrify_info,*image); |
| 1302 | mogrify_image=DespeckleImage(*image,exception); |
| 1303 | break; |
| 1304 | } |
| 1305 | if (LocaleCompare("display",option+1) == 0) |
| 1306 | { |
| 1307 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1308 | break; |
| 1309 | } |
| 1310 | if (LocaleCompare("distort",option+1) == 0) |
| 1311 | { |
| 1312 | char |
| 1313 | *args, |
| 1314 | token[MaxTextExtent]; |
| 1315 | |
| 1316 | const char |
| 1317 | *p; |
| 1318 | |
| 1319 | DistortImageMethod |
| 1320 | method; |
| 1321 | |
| 1322 | double |
| 1323 | *arguments; |
| 1324 | |
| 1325 | register ssize_t |
| 1326 | x; |
| 1327 | |
| 1328 | size_t |
| 1329 | number_arguments; |
| 1330 | |
| 1331 | /* |
| 1332 | Distort image. |
| 1333 | */ |
| 1334 | (void) SyncImageSettings(mogrify_info,*image); |
| 1335 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, |
| 1336 | MagickFalse,argv[i+1]); |
| 1337 | if ( method == ResizeDistortion ) |
| 1338 | { |
| 1339 | /* Special Case - Argument is actually a resize geometry! |
| 1340 | ** Convert that to an appropriate distortion argument array. |
| 1341 | */ |
| 1342 | double |
| 1343 | resize_args[2]; |
| 1344 | (void) ParseRegionGeometry(*image,argv[i+2],&geometry, |
| 1345 | exception); |
| 1346 | resize_args[0]=(double)geometry.width; |
| 1347 | resize_args[1]=(double)geometry.height; |
| 1348 | mogrify_image=DistortImage(*image,method,(size_t)2, |
| 1349 | resize_args,MagickTrue,exception); |
| 1350 | break; |
| 1351 | } |
| 1352 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 1353 | InheritException(exception,&(*image)->exception); |
| 1354 | if (args == (char *) NULL) |
| 1355 | break; |
| 1356 | p=(char *) args; |
| 1357 | for (x=0; *p != '\0'; x++) |
| 1358 | { |
| 1359 | GetMagickToken(p,&p,token); |
| 1360 | if (*token == ',') |
| 1361 | GetMagickToken(p,&p,token); |
| 1362 | } |
| 1363 | number_arguments=(size_t) x; |
| 1364 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1365 | sizeof(*arguments)); |
| 1366 | if (arguments == (double *) NULL) |
| 1367 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1368 | "MemoryAllocationFailed",(*image)->filename); |
| 1369 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1370 | sizeof(*arguments)); |
| 1371 | p=(char *) args; |
| 1372 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 1373 | { |
| 1374 | GetMagickToken(p,&p,token); |
| 1375 | if (*token == ',') |
| 1376 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1377 | arguments[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1378 | } |
| 1379 | args=DestroyString(args); |
| 1380 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
| 1381 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1382 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1383 | break; |
| 1384 | } |
| 1385 | if (LocaleCompare("dither",option+1) == 0) |
| 1386 | { |
| 1387 | if (*option == '+') |
| 1388 | { |
| 1389 | quantize_info->dither=MagickFalse; |
| 1390 | break; |
| 1391 | } |
| 1392 | quantize_info->dither=MagickTrue; |
| 1393 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
| 1394 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1395 | if (quantize_info->dither_method == NoDitherMethod) |
| 1396 | quantize_info->dither=MagickFalse; |
| 1397 | break; |
| 1398 | } |
| 1399 | if (LocaleCompare("draw",option+1) == 0) |
| 1400 | { |
| 1401 | /* |
| 1402 | Draw image. |
| 1403 | */ |
| 1404 | (void) SyncImageSettings(mogrify_info,*image); |
| 1405 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
| 1406 | (void) DrawImage(*image,draw_info); |
| 1407 | InheritException(exception,&(*image)->exception); |
| 1408 | break; |
| 1409 | } |
| 1410 | break; |
| 1411 | } |
| 1412 | case 'e': |
| 1413 | { |
| 1414 | if (LocaleCompare("edge",option+1) == 0) |
| 1415 | { |
| 1416 | /* |
| 1417 | Enhance edges in the image. |
| 1418 | */ |
| 1419 | (void) SyncImageSettings(mogrify_info,*image); |
| 1420 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1421 | if ((flags & SigmaValue) == 0) |
| 1422 | geometry_info.sigma=1.0; |
| 1423 | mogrify_image=EdgeImage(*image,geometry_info.rho,exception); |
| 1424 | break; |
| 1425 | } |
| 1426 | if (LocaleCompare("emboss",option+1) == 0) |
| 1427 | { |
| 1428 | /* |
| 1429 | Gaussian embossen image. |
| 1430 | */ |
| 1431 | (void) SyncImageSettings(mogrify_info,*image); |
| 1432 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1433 | if ((flags & SigmaValue) == 0) |
| 1434 | geometry_info.sigma=1.0; |
| 1435 | mogrify_image=EmbossImage(*image,geometry_info.rho, |
| 1436 | geometry_info.sigma,exception); |
| 1437 | break; |
| 1438 | } |
| 1439 | if (LocaleCompare("encipher",option+1) == 0) |
| 1440 | { |
| 1441 | StringInfo |
| 1442 | *passkey; |
| 1443 | |
| 1444 | /* |
| 1445 | Encipher pixels. |
| 1446 | */ |
| 1447 | (void) SyncImageSettings(mogrify_info,*image); |
| 1448 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1449 | if (passkey != (StringInfo *) NULL) |
| 1450 | { |
| 1451 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1452 | passkey=DestroyStringInfo(passkey); |
| 1453 | } |
| 1454 | break; |
| 1455 | } |
| 1456 | if (LocaleCompare("encoding",option+1) == 0) |
| 1457 | { |
| 1458 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1459 | break; |
| 1460 | } |
| 1461 | if (LocaleCompare("enhance",option+1) == 0) |
| 1462 | { |
| 1463 | /* |
| 1464 | Enhance image. |
| 1465 | */ |
| 1466 | (void) SyncImageSettings(mogrify_info,*image); |
| 1467 | mogrify_image=EnhanceImage(*image,exception); |
| 1468 | break; |
| 1469 | } |
| 1470 | if (LocaleCompare("equalize",option+1) == 0) |
| 1471 | { |
| 1472 | /* |
| 1473 | Equalize image. |
| 1474 | */ |
| 1475 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1476 | (void) EqualizeImage(*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1477 | InheritException(exception,&(*image)->exception); |
| 1478 | break; |
| 1479 | } |
| 1480 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1481 | { |
| 1482 | double |
| 1483 | constant; |
| 1484 | |
| 1485 | MagickEvaluateOperator |
| 1486 | op; |
| 1487 | |
| 1488 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1489 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 1490 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1491 | constant=SiPrefixToDouble(argv[i+2],QuantumRange); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1492 | (void) EvaluateImage(*image,op,constant,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1493 | break; |
| 1494 | } |
| 1495 | if (LocaleCompare("extent",option+1) == 0) |
| 1496 | { |
| 1497 | /* |
| 1498 | Set the image extent. |
| 1499 | */ |
| 1500 | (void) SyncImageSettings(mogrify_info,*image); |
| 1501 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1502 | if (geometry.width == 0) |
| 1503 | geometry.width=(*image)->columns; |
| 1504 | if (geometry.height == 0) |
| 1505 | geometry.height=(*image)->rows; |
| 1506 | mogrify_image=ExtentImage(*image,&geometry,exception); |
| 1507 | break; |
| 1508 | } |
| 1509 | break; |
| 1510 | } |
| 1511 | case 'f': |
| 1512 | { |
| 1513 | if (LocaleCompare("family",option+1) == 0) |
| 1514 | { |
| 1515 | if (*option == '+') |
| 1516 | { |
| 1517 | if (draw_info->family != (char *) NULL) |
| 1518 | draw_info->family=DestroyString(draw_info->family); |
| 1519 | break; |
| 1520 | } |
| 1521 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1522 | break; |
| 1523 | } |
| 1524 | if (LocaleCompare("features",option+1) == 0) |
| 1525 | { |
| 1526 | if (*option == '+') |
| 1527 | { |
| 1528 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1529 | break; |
| 1530 | } |
| 1531 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1532 | break; |
| 1533 | } |
| 1534 | if (LocaleCompare("fill",option+1) == 0) |
| 1535 | { |
| 1536 | ExceptionInfo |
| 1537 | *sans; |
| 1538 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1539 | GetPixelInfo(*image,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1540 | if (*option == '+') |
| 1541 | { |
| 1542 | (void) QueryMagickColor("none",&fill,exception); |
| 1543 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 1544 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1545 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1546 | break; |
| 1547 | } |
| 1548 | sans=AcquireExceptionInfo(); |
| 1549 | (void) QueryMagickColor(argv[i+1],&fill,sans); |
| 1550 | status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans); |
| 1551 | sans=DestroyExceptionInfo(sans); |
| 1552 | if (status == MagickFalse) |
| 1553 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 1554 | exception); |
| 1555 | break; |
| 1556 | } |
| 1557 | if (LocaleCompare("flip",option+1) == 0) |
| 1558 | { |
| 1559 | /* |
| 1560 | Flip image scanlines. |
| 1561 | */ |
| 1562 | (void) SyncImageSettings(mogrify_info,*image); |
| 1563 | mogrify_image=FlipImage(*image,exception); |
| 1564 | break; |
| 1565 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1566 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1567 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1568 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1569 | target; |
| 1570 | |
| 1571 | /* |
| 1572 | Floodfill image. |
| 1573 | */ |
| 1574 | (void) SyncImageSettings(mogrify_info,*image); |
| 1575 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1576 | (void) QueryMagickColor(argv[i+2],&target,exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1577 | (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x, |
| 1578 | geometry.y,*option == '-' ? MagickFalse : MagickTrue); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1579 | InheritException(exception,&(*image)->exception); |
| 1580 | break; |
| 1581 | } |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1582 | if (LocaleCompare("flop",option+1) == 0) |
| 1583 | { |
| 1584 | /* |
| 1585 | Flop image scanlines. |
| 1586 | */ |
| 1587 | (void) SyncImageSettings(mogrify_info,*image); |
| 1588 | mogrify_image=FlopImage(*image,exception); |
| 1589 | break; |
| 1590 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1591 | if (LocaleCompare("font",option+1) == 0) |
| 1592 | { |
| 1593 | if (*option == '+') |
| 1594 | { |
| 1595 | if (draw_info->font != (char *) NULL) |
| 1596 | draw_info->font=DestroyString(draw_info->font); |
| 1597 | break; |
| 1598 | } |
| 1599 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1600 | break; |
| 1601 | } |
| 1602 | if (LocaleCompare("format",option+1) == 0) |
| 1603 | { |
| 1604 | format=argv[i+1]; |
| 1605 | break; |
| 1606 | } |
| 1607 | if (LocaleCompare("frame",option+1) == 0) |
| 1608 | { |
| 1609 | FrameInfo |
| 1610 | frame_info; |
| 1611 | |
| 1612 | /* |
| 1613 | Surround image with an ornamental border. |
| 1614 | */ |
| 1615 | (void) SyncImageSettings(mogrify_info,*image); |
| 1616 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1617 | frame_info.width=geometry.width; |
| 1618 | frame_info.height=geometry.height; |
| 1619 | if ((flags & HeightValue) == 0) |
| 1620 | frame_info.height=geometry.width; |
| 1621 | frame_info.outer_bevel=geometry.x; |
| 1622 | frame_info.inner_bevel=geometry.y; |
| 1623 | frame_info.x=(ssize_t) frame_info.width; |
| 1624 | frame_info.y=(ssize_t) frame_info.height; |
| 1625 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1626 | frame_info.height=(*image)->rows+2*frame_info.height; |
| 1627 | mogrify_image=FrameImage(*image,&frame_info,exception); |
| 1628 | break; |
| 1629 | } |
| 1630 | if (LocaleCompare("function",option+1) == 0) |
| 1631 | { |
| 1632 | char |
| 1633 | *arguments, |
| 1634 | token[MaxTextExtent]; |
| 1635 | |
| 1636 | const char |
| 1637 | *p; |
| 1638 | |
| 1639 | double |
| 1640 | *parameters; |
| 1641 | |
| 1642 | MagickFunction |
| 1643 | function; |
| 1644 | |
| 1645 | register ssize_t |
| 1646 | x; |
| 1647 | |
| 1648 | size_t |
| 1649 | number_parameters; |
| 1650 | |
| 1651 | /* |
| 1652 | Function Modify Image Values |
| 1653 | */ |
| 1654 | (void) SyncImageSettings(mogrify_info,*image); |
| 1655 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, |
| 1656 | MagickFalse,argv[i+1]); |
| 1657 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 1658 | InheritException(exception,&(*image)->exception); |
| 1659 | if (arguments == (char *) NULL) |
| 1660 | break; |
| 1661 | p=(char *) arguments; |
| 1662 | for (x=0; *p != '\0'; x++) |
| 1663 | { |
| 1664 | GetMagickToken(p,&p,token); |
| 1665 | if (*token == ',') |
| 1666 | GetMagickToken(p,&p,token); |
| 1667 | } |
| 1668 | number_parameters=(size_t) x; |
| 1669 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1670 | sizeof(*parameters)); |
| 1671 | if (parameters == (double *) NULL) |
| 1672 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1673 | "MemoryAllocationFailed",(*image)->filename); |
| 1674 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1675 | sizeof(*parameters)); |
| 1676 | p=(char *) arguments; |
| 1677 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
| 1678 | { |
| 1679 | GetMagickToken(p,&p,token); |
| 1680 | if (*token == ',') |
| 1681 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1682 | parameters[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1683 | } |
| 1684 | arguments=DestroyString(arguments); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1685 | (void) FunctionImage(*image,function,number_parameters,parameters, |
| 1686 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1687 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1688 | break; |
| 1689 | } |
| 1690 | break; |
| 1691 | } |
| 1692 | case 'g': |
| 1693 | { |
| 1694 | if (LocaleCompare("gamma",option+1) == 0) |
| 1695 | { |
| 1696 | /* |
| 1697 | Gamma image. |
| 1698 | */ |
| 1699 | (void) SyncImageSettings(mogrify_info,*image); |
| 1700 | if (*option == '+') |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1701 | (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1702 | else |
| 1703 | { |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1704 | (void) GammaImage(*image,InterpretLocaleValue(argv[i+1], |
| 1705 | (char **) NULL)); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1706 | InheritException(exception,&(*image)->exception); |
| 1707 | } |
| 1708 | break; |
| 1709 | } |
| 1710 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1711 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1712 | { |
| 1713 | /* |
| 1714 | Gaussian blur image. |
| 1715 | */ |
| 1716 | (void) SyncImageSettings(mogrify_info,*image); |
| 1717 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1718 | if ((flags & SigmaValue) == 0) |
| 1719 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1720 | mogrify_image=GaussianBlurImage(*image,geometry_info.rho, |
| 1721 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1722 | break; |
| 1723 | } |
| 1724 | if (LocaleCompare("geometry",option+1) == 0) |
| 1725 | { |
| 1726 | /* |
| 1727 | Record Image offset, Resize last image. |
| 1728 | */ |
| 1729 | (void) SyncImageSettings(mogrify_info,*image); |
| 1730 | if (*option == '+') |
| 1731 | { |
| 1732 | if ((*image)->geometry != (char *) NULL) |
| 1733 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1734 | break; |
| 1735 | } |
| 1736 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1737 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1738 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1739 | else |
| 1740 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 1741 | (*image)->filter,(*image)->blur,exception); |
| 1742 | break; |
| 1743 | } |
| 1744 | if (LocaleCompare("gravity",option+1) == 0) |
| 1745 | { |
| 1746 | if (*option == '+') |
| 1747 | { |
| 1748 | draw_info->gravity=UndefinedGravity; |
| 1749 | break; |
| 1750 | } |
| 1751 | draw_info->gravity=(GravityType) ParseCommandOption( |
| 1752 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1753 | break; |
| 1754 | } |
| 1755 | break; |
| 1756 | } |
| 1757 | case 'h': |
| 1758 | { |
| 1759 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1760 | { |
| 1761 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1762 | break; |
| 1763 | } |
| 1764 | break; |
| 1765 | } |
| 1766 | case 'i': |
| 1767 | { |
| 1768 | if (LocaleCompare("identify",option+1) == 0) |
| 1769 | { |
| 1770 | char |
| 1771 | *text; |
| 1772 | |
| 1773 | (void) SyncImageSettings(mogrify_info,*image); |
| 1774 | if (format == (char *) NULL) |
| 1775 | { |
| 1776 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose); |
| 1777 | InheritException(exception,&(*image)->exception); |
| 1778 | break; |
| 1779 | } |
| 1780 | text=InterpretImageProperties(mogrify_info,*image,format); |
| 1781 | InheritException(exception,&(*image)->exception); |
| 1782 | if (text == (char *) NULL) |
| 1783 | break; |
| 1784 | (void) fputs(text,stdout); |
| 1785 | (void) fputc('\n',stdout); |
| 1786 | text=DestroyString(text); |
| 1787 | break; |
| 1788 | } |
| 1789 | if (LocaleCompare("implode",option+1) == 0) |
| 1790 | { |
| 1791 | /* |
| 1792 | Implode image. |
| 1793 | */ |
| 1794 | (void) SyncImageSettings(mogrify_info,*image); |
| 1795 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1796 | mogrify_image=ImplodeImage(*image,geometry_info.rho,exception); |
| 1797 | break; |
| 1798 | } |
| 1799 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1800 | { |
| 1801 | if (*option == '+') |
| 1802 | (void) ParseGeometry("0",&geometry_info); |
| 1803 | else |
| 1804 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1805 | draw_info->interline_spacing=geometry_info.rho; |
| 1806 | break; |
| 1807 | } |
| 1808 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1809 | { |
| 1810 | if (*option == '+') |
| 1811 | (void) ParseGeometry("0",&geometry_info); |
| 1812 | else |
| 1813 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1814 | draw_info->interword_spacing=geometry_info.rho; |
| 1815 | break; |
| 1816 | } |
| 1817 | break; |
| 1818 | } |
| 1819 | case 'k': |
| 1820 | { |
| 1821 | if (LocaleCompare("kerning",option+1) == 0) |
| 1822 | { |
| 1823 | if (*option == '+') |
| 1824 | (void) ParseGeometry("0",&geometry_info); |
| 1825 | else |
| 1826 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1827 | draw_info->kerning=geometry_info.rho; |
| 1828 | break; |
| 1829 | } |
| 1830 | break; |
| 1831 | } |
| 1832 | case 'l': |
| 1833 | { |
| 1834 | if (LocaleCompare("lat",option+1) == 0) |
| 1835 | { |
| 1836 | /* |
| 1837 | Local adaptive threshold image. |
| 1838 | */ |
| 1839 | (void) SyncImageSettings(mogrify_info,*image); |
| 1840 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1841 | if ((flags & PercentValue) != 0) |
| 1842 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 1843 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
| 1844 | geometry_info.rho,(size_t) geometry_info.sigma,(ssize_t) |
| 1845 | geometry_info.xi,exception); |
| 1846 | break; |
| 1847 | } |
| 1848 | if (LocaleCompare("level",option+1) == 0) |
| 1849 | { |
| 1850 | MagickRealType |
| 1851 | black_point, |
| 1852 | gamma, |
| 1853 | white_point; |
| 1854 | |
| 1855 | MagickStatusType |
| 1856 | flags; |
| 1857 | |
| 1858 | /* |
| 1859 | Parse levels. |
| 1860 | */ |
| 1861 | (void) SyncImageSettings(mogrify_info,*image); |
| 1862 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1863 | black_point=geometry_info.rho; |
| 1864 | white_point=(MagickRealType) QuantumRange; |
| 1865 | if ((flags & SigmaValue) != 0) |
| 1866 | white_point=geometry_info.sigma; |
| 1867 | gamma=1.0; |
| 1868 | if ((flags & XiValue) != 0) |
| 1869 | gamma=geometry_info.xi; |
| 1870 | if ((flags & PercentValue) != 0) |
| 1871 | { |
| 1872 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 1873 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 1874 | } |
| 1875 | if ((flags & SigmaValue) == 0) |
| 1876 | white_point=(MagickRealType) QuantumRange-black_point; |
| 1877 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1878 | (void) LevelizeImage(*image,black_point,white_point,gamma); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1879 | else |
cristy | f89cb1d | 2011-07-07 01:24:37 +0000 | [diff] [blame] | 1880 | (void) LevelImage(*image,black_point,white_point,gamma); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1881 | InheritException(exception,&(*image)->exception); |
| 1882 | break; |
| 1883 | } |
| 1884 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1885 | { |
| 1886 | char |
| 1887 | token[MaxTextExtent]; |
| 1888 | |
| 1889 | const char |
| 1890 | *p; |
| 1891 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1892 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1893 | black_point, |
| 1894 | white_point; |
| 1895 | |
| 1896 | p=(const char *) argv[i+1]; |
| 1897 | GetMagickToken(p,&p,token); /* get black point color */ |
| 1898 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1899 | (void) QueryMagickColor(token,&black_point,exception); |
| 1900 | else |
| 1901 | (void) QueryMagickColor("#000000",&black_point,exception); |
| 1902 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1903 | GetMagickToken(p,&p,token); |
| 1904 | if (*token == '\0') |
| 1905 | white_point=black_point; /* set everything to that color */ |
| 1906 | else |
| 1907 | { |
| 1908 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 1909 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 1910 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1911 | (void) QueryMagickColor(token,&white_point,exception); |
| 1912 | else |
| 1913 | (void) QueryMagickColor("#ffffff",&white_point,exception); |
| 1914 | } |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 1915 | (void) LevelImageColors(*image,&black_point,&white_point, |
| 1916 | *option == '+' ? MagickTrue : MagickFalse); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1917 | break; |
| 1918 | } |
| 1919 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 1920 | { |
| 1921 | double |
| 1922 | black_point, |
| 1923 | white_point; |
| 1924 | |
| 1925 | MagickStatusType |
| 1926 | flags; |
| 1927 | |
| 1928 | (void) SyncImageSettings(mogrify_info,*image); |
| 1929 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1930 | black_point=geometry_info.rho; |
| 1931 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 1932 | if ((flags & SigmaValue) != 0) |
| 1933 | white_point=geometry_info.sigma; |
| 1934 | if ((flags & PercentValue) != 0) |
| 1935 | { |
| 1936 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1937 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1938 | } |
| 1939 | if ((flags & SigmaValue) == 0) |
| 1940 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1941 | black_point; |
| 1942 | (void) LinearStretchImage(*image,black_point,white_point); |
| 1943 | InheritException(exception,&(*image)->exception); |
| 1944 | break; |
| 1945 | } |
| 1946 | if (LocaleCompare("linewidth",option+1) == 0) |
| 1947 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1948 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 1949 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1950 | break; |
| 1951 | } |
| 1952 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 1953 | { |
| 1954 | /* |
| 1955 | Liquid rescale image. |
| 1956 | */ |
| 1957 | (void) SyncImageSettings(mogrify_info,*image); |
| 1958 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1959 | if ((flags & XValue) == 0) |
| 1960 | geometry.x=1; |
| 1961 | if ((flags & YValue) == 0) |
| 1962 | geometry.y=0; |
| 1963 | mogrify_image=LiquidRescaleImage(*image,geometry.width, |
| 1964 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 1965 | break; |
| 1966 | } |
| 1967 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 1968 | { |
| 1969 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1970 | break; |
| 1971 | } |
| 1972 | break; |
| 1973 | } |
| 1974 | case 'm': |
| 1975 | { |
| 1976 | if (LocaleCompare("map",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1977 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1978 | Image |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1979 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1980 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1981 | /* |
| 1982 | Transform image colors to match this set of colors. |
| 1983 | */ |
| 1984 | (void) SyncImageSettings(mogrify_info,*image); |
| 1985 | if (*option == '+') |
| 1986 | break; |
| 1987 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1988 | if (remap_image == (Image *) NULL) |
| 1989 | break; |
| 1990 | (void) RemapImage(quantize_info,*image,remap_image); |
| 1991 | InheritException(exception,&(*image)->exception); |
| 1992 | remap_image=DestroyImage(remap_image); |
| 1993 | break; |
| 1994 | } |
| 1995 | if (LocaleCompare("mask",option+1) == 0) |
| 1996 | { |
| 1997 | Image |
| 1998 | *mask; |
| 1999 | |
| 2000 | (void) SyncImageSettings(mogrify_info,*image); |
| 2001 | if (*option == '+') |
| 2002 | { |
| 2003 | /* |
| 2004 | Remove a mask. |
| 2005 | */ |
| 2006 | (void) SetImageMask(*image,(Image *) NULL); |
| 2007 | InheritException(exception,&(*image)->exception); |
| 2008 | break; |
| 2009 | } |
| 2010 | /* |
| 2011 | Set the image mask. |
| 2012 | */ |
| 2013 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2014 | if (mask == (Image *) NULL) |
| 2015 | break; |
| 2016 | (void) SetImageMask(*image,mask); |
| 2017 | mask=DestroyImage(mask); |
| 2018 | InheritException(exception,&(*image)->exception); |
| 2019 | break; |
| 2020 | } |
| 2021 | if (LocaleCompare("matte",option+1) == 0) |
| 2022 | { |
| 2023 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
| 2024 | SetAlphaChannel : DeactivateAlphaChannel ); |
| 2025 | InheritException(exception,&(*image)->exception); |
| 2026 | break; |
| 2027 | } |
| 2028 | if (LocaleCompare("median",option+1) == 0) |
| 2029 | { |
| 2030 | /* |
| 2031 | Median filter image. |
| 2032 | */ |
| 2033 | (void) SyncImageSettings(mogrify_info,*image); |
| 2034 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2035 | mogrify_image=StatisticImage(*image,MedianStatistic,(size_t) |
| 2036 | geometry_info.rho,(size_t) geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2037 | break; |
| 2038 | } |
| 2039 | if (LocaleCompare("mode",option+1) == 0) |
| 2040 | { |
| 2041 | /* |
| 2042 | Mode image. |
| 2043 | */ |
| 2044 | (void) SyncImageSettings(mogrify_info,*image); |
| 2045 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2046 | mogrify_image=StatisticImage(*image,ModeStatistic,(size_t) |
| 2047 | geometry_info.rho,(size_t) geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2048 | break; |
| 2049 | } |
| 2050 | if (LocaleCompare("modulate",option+1) == 0) |
| 2051 | { |
| 2052 | (void) SyncImageSettings(mogrify_info,*image); |
| 2053 | (void) ModulateImage(*image,argv[i+1]); |
| 2054 | InheritException(exception,&(*image)->exception); |
| 2055 | break; |
| 2056 | } |
| 2057 | if (LocaleCompare("monitor",option+1) == 0) |
| 2058 | { |
| 2059 | if (*option == '+') |
| 2060 | { |
| 2061 | (void) SetImageProgressMonitor(*image, |
| 2062 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2063 | break; |
| 2064 | } |
| 2065 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2066 | (void *) NULL); |
| 2067 | break; |
| 2068 | } |
| 2069 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2070 | { |
| 2071 | (void) SyncImageSettings(mogrify_info,*image); |
| 2072 | (void) SetImageType(*image,BilevelType); |
| 2073 | InheritException(exception,&(*image)->exception); |
| 2074 | break; |
| 2075 | } |
| 2076 | if (LocaleCompare("morphology",option+1) == 0) |
| 2077 | { |
| 2078 | char |
| 2079 | token[MaxTextExtent]; |
| 2080 | |
| 2081 | const char |
| 2082 | *p; |
| 2083 | |
| 2084 | KernelInfo |
| 2085 | *kernel; |
| 2086 | |
| 2087 | MorphologyMethod |
| 2088 | method; |
| 2089 | |
| 2090 | ssize_t |
| 2091 | iterations; |
| 2092 | |
| 2093 | /* |
| 2094 | Morphological Image Operation |
| 2095 | */ |
| 2096 | (void) SyncImageSettings(mogrify_info,*image); |
| 2097 | p=argv[i+1]; |
| 2098 | GetMagickToken(p,&p,token); |
| 2099 | method=(MorphologyMethod) ParseCommandOption(MagickMorphologyOptions, |
| 2100 | MagickFalse,token); |
| 2101 | iterations=1L; |
| 2102 | GetMagickToken(p,&p,token); |
| 2103 | if ((*p == ':') || (*p == ',')) |
| 2104 | GetMagickToken(p,&p,token); |
| 2105 | if ((*p != '\0')) |
| 2106 | iterations=(ssize_t) StringToLong(p); |
| 2107 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2108 | if (kernel == (KernelInfo *) NULL) |
| 2109 | { |
| 2110 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2111 | OptionError,"UnabletoParseKernel","morphology"); |
| 2112 | status=MagickFalse; |
| 2113 | break; |
| 2114 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2115 | mogrify_image=MorphologyImage(*image,method,iterations,kernel, |
| 2116 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2117 | kernel=DestroyKernelInfo(kernel); |
| 2118 | break; |
| 2119 | } |
| 2120 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2121 | { |
| 2122 | /* |
| 2123 | Motion blur image. |
| 2124 | */ |
| 2125 | (void) SyncImageSettings(mogrify_info,*image); |
| 2126 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2127 | if ((flags & SigmaValue) == 0) |
| 2128 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2129 | mogrify_image=MotionBlurImage(*image,geometry_info.rho, |
| 2130 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2131 | break; |
| 2132 | } |
| 2133 | break; |
| 2134 | } |
| 2135 | case 'n': |
| 2136 | { |
| 2137 | if (LocaleCompare("negate",option+1) == 0) |
| 2138 | { |
| 2139 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2140 | (void) NegateImage(*image,*option == '+' ? MagickTrue : |
| 2141 | MagickFalse); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2142 | InheritException(exception,&(*image)->exception); |
| 2143 | break; |
| 2144 | } |
| 2145 | if (LocaleCompare("noise",option+1) == 0) |
| 2146 | { |
| 2147 | (void) SyncImageSettings(mogrify_info,*image); |
| 2148 | if (*option == '-') |
| 2149 | { |
| 2150 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2151 | mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t) |
| 2152 | geometry_info.rho,(size_t) geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2153 | } |
| 2154 | else |
| 2155 | { |
| 2156 | NoiseType |
| 2157 | noise; |
| 2158 | |
| 2159 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
| 2160 | MagickFalse,argv[i+1]); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 2161 | mogrify_image=AddNoiseImage(*image,noise,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2162 | } |
| 2163 | break; |
| 2164 | } |
| 2165 | if (LocaleCompare("normalize",option+1) == 0) |
| 2166 | { |
| 2167 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2168 | (void) NormalizeImage(*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2169 | InheritException(exception,&(*image)->exception); |
| 2170 | break; |
| 2171 | } |
| 2172 | break; |
| 2173 | } |
| 2174 | case 'o': |
| 2175 | { |
| 2176 | if (LocaleCompare("opaque",option+1) == 0) |
| 2177 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2178 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2179 | target; |
| 2180 | |
| 2181 | (void) SyncImageSettings(mogrify_info,*image); |
| 2182 | (void) QueryMagickColor(argv[i+1],&target,exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 2183 | (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ? |
| 2184 | MagickFalse : MagickTrue); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2185 | break; |
| 2186 | } |
| 2187 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2188 | { |
| 2189 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 1302067 | 2011-07-08 02:33:26 +0000 | [diff] [blame] | 2190 | (void) OrderedPosterizeImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2191 | break; |
| 2192 | } |
| 2193 | break; |
| 2194 | } |
| 2195 | case 'p': |
| 2196 | { |
| 2197 | if (LocaleCompare("paint",option+1) == 0) |
| 2198 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2199 | (void) SyncImageSettings(mogrify_info,*image); |
| 2200 | (void) ParseGeometry(argv[i+1],&geometry_info); |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 2201 | mogrify_image=OilPaintImage(*image,geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2202 | break; |
| 2203 | } |
| 2204 | if (LocaleCompare("pen",option+1) == 0) |
| 2205 | { |
| 2206 | if (*option == '+') |
| 2207 | { |
| 2208 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 2209 | break; |
| 2210 | } |
| 2211 | (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception); |
| 2212 | break; |
| 2213 | } |
| 2214 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2215 | { |
| 2216 | if (*option == '+') |
| 2217 | (void) ParseGeometry("12",&geometry_info); |
| 2218 | else |
| 2219 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2220 | draw_info->pointsize=geometry_info.rho; |
| 2221 | break; |
| 2222 | } |
| 2223 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2224 | { |
| 2225 | double |
| 2226 | angle; |
| 2227 | |
| 2228 | RandomInfo |
| 2229 | *random_info; |
| 2230 | |
| 2231 | /* |
| 2232 | Simulate a Polaroid picture. |
| 2233 | */ |
| 2234 | (void) SyncImageSettings(mogrify_info,*image); |
| 2235 | random_info=AcquireRandomInfo(); |
| 2236 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2237 | random_info=DestroyRandomInfo(random_info); |
| 2238 | if (*option == '-') |
| 2239 | { |
| 2240 | SetGeometryInfo(&geometry_info); |
| 2241 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2242 | angle=geometry_info.rho; |
| 2243 | } |
| 2244 | mogrify_image=PolaroidImage(*image,draw_info,angle,exception); |
| 2245 | break; |
| 2246 | } |
| 2247 | if (LocaleCompare("posterize",option+1) == 0) |
| 2248 | { |
| 2249 | /* |
| 2250 | Posterize image. |
| 2251 | */ |
| 2252 | (void) SyncImageSettings(mogrify_info,*image); |
| 2253 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
| 2254 | quantize_info->dither); |
| 2255 | InheritException(exception,&(*image)->exception); |
| 2256 | break; |
| 2257 | } |
| 2258 | if (LocaleCompare("preview",option+1) == 0) |
| 2259 | { |
| 2260 | PreviewType |
| 2261 | preview_type; |
| 2262 | |
| 2263 | /* |
| 2264 | Preview image. |
| 2265 | */ |
| 2266 | (void) SyncImageSettings(mogrify_info,*image); |
| 2267 | if (*option == '+') |
| 2268 | preview_type=UndefinedPreview; |
| 2269 | else |
| 2270 | preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions, |
| 2271 | MagickFalse,argv[i+1]); |
| 2272 | mogrify_image=PreviewImage(*image,preview_type,exception); |
| 2273 | break; |
| 2274 | } |
| 2275 | if (LocaleCompare("profile",option+1) == 0) |
| 2276 | { |
| 2277 | const char |
| 2278 | *name; |
| 2279 | |
| 2280 | const StringInfo |
| 2281 | *profile; |
| 2282 | |
| 2283 | Image |
| 2284 | *profile_image; |
| 2285 | |
| 2286 | ImageInfo |
| 2287 | *profile_info; |
| 2288 | |
| 2289 | (void) SyncImageSettings(mogrify_info,*image); |
| 2290 | if (*option == '+') |
| 2291 | { |
| 2292 | /* |
| 2293 | Remove a profile from the image. |
| 2294 | */ |
| 2295 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
| 2296 | NULL,0,MagickTrue); |
| 2297 | InheritException(exception,&(*image)->exception); |
| 2298 | break; |
| 2299 | } |
| 2300 | /* |
| 2301 | Associate a profile with the image. |
| 2302 | */ |
| 2303 | profile_info=CloneImageInfo(mogrify_info); |
| 2304 | profile=GetImageProfile(*image,"iptc"); |
| 2305 | if (profile != (StringInfo *) NULL) |
| 2306 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2307 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2308 | profile_info=DestroyImageInfo(profile_info); |
| 2309 | if (profile_image == (Image *) NULL) |
| 2310 | { |
| 2311 | StringInfo |
| 2312 | *profile; |
| 2313 | |
| 2314 | profile_info=CloneImageInfo(mogrify_info); |
| 2315 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2316 | MaxTextExtent); |
| 2317 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
| 2318 | if (profile != (StringInfo *) NULL) |
| 2319 | { |
| 2320 | (void) ProfileImage(*image,profile_info->magick, |
| 2321 | GetStringInfoDatum(profile),(size_t) |
| 2322 | GetStringInfoLength(profile),MagickFalse); |
| 2323 | profile=DestroyStringInfo(profile); |
| 2324 | } |
| 2325 | profile_info=DestroyImageInfo(profile_info); |
| 2326 | break; |
| 2327 | } |
| 2328 | ResetImageProfileIterator(profile_image); |
| 2329 | name=GetNextImageProfile(profile_image); |
| 2330 | while (name != (const char *) NULL) |
| 2331 | { |
| 2332 | profile=GetImageProfile(profile_image,name); |
| 2333 | if (profile != (StringInfo *) NULL) |
| 2334 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
| 2335 | (size_t) GetStringInfoLength(profile),MagickFalse); |
| 2336 | name=GetNextImageProfile(profile_image); |
| 2337 | } |
| 2338 | profile_image=DestroyImage(profile_image); |
| 2339 | break; |
| 2340 | } |
| 2341 | break; |
| 2342 | } |
| 2343 | case 'q': |
| 2344 | { |
| 2345 | if (LocaleCompare("quantize",option+1) == 0) |
| 2346 | { |
| 2347 | if (*option == '+') |
| 2348 | { |
| 2349 | quantize_info->colorspace=UndefinedColorspace; |
| 2350 | break; |
| 2351 | } |
| 2352 | quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
| 2353 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2354 | break; |
| 2355 | } |
| 2356 | break; |
| 2357 | } |
| 2358 | case 'r': |
| 2359 | { |
| 2360 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2361 | { |
| 2362 | /* |
| 2363 | Radial blur image. |
| 2364 | */ |
| 2365 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2366 | mogrify_image=RadialBlurImage(*image,InterpretLocaleValue(argv[i+1], |
| 2367 | (char **) NULL),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2368 | break; |
| 2369 | } |
| 2370 | if (LocaleCompare("raise",option+1) == 0) |
| 2371 | { |
| 2372 | /* |
| 2373 | Surround image with a raise of solid color. |
| 2374 | */ |
| 2375 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2376 | if ((flags & SigmaValue) == 0) |
| 2377 | geometry.height=geometry.width; |
| 2378 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
| 2379 | MagickFalse); |
| 2380 | InheritException(exception,&(*image)->exception); |
| 2381 | break; |
| 2382 | } |
| 2383 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2384 | { |
| 2385 | /* |
| 2386 | Threshold image. |
| 2387 | */ |
| 2388 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2389 | (void) RandomThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2390 | break; |
| 2391 | } |
| 2392 | if (LocaleCompare("recolor",option+1) == 0) |
| 2393 | { |
| 2394 | KernelInfo |
| 2395 | *kernel; |
| 2396 | |
| 2397 | (void) SyncImageSettings(mogrify_info,*image); |
| 2398 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2399 | if (kernel == (KernelInfo *) NULL) |
| 2400 | break; |
| 2401 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 2402 | kernel=DestroyKernelInfo(kernel); |
| 2403 | break; |
| 2404 | } |
| 2405 | if (LocaleCompare("region",option+1) == 0) |
| 2406 | { |
| 2407 | (void) SyncImageSettings(mogrify_info,*image); |
| 2408 | if (region_image != (Image *) NULL) |
| 2409 | { |
| 2410 | /* |
| 2411 | Composite region. |
| 2412 | */ |
| 2413 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2414 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 2415 | region_geometry.x,region_geometry.y); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2416 | InheritException(exception,®ion_image->exception); |
| 2417 | *image=DestroyImage(*image); |
| 2418 | *image=region_image; |
| 2419 | region_image = (Image *) NULL; |
| 2420 | } |
| 2421 | if (*option == '+') |
| 2422 | break; |
| 2423 | /* |
| 2424 | Apply transformations to a selected region of the image. |
| 2425 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2426 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2427 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2428 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2429 | if (mogrify_image == (Image *) NULL) |
| 2430 | break; |
| 2431 | region_image=(*image); |
| 2432 | *image=mogrify_image; |
| 2433 | mogrify_image=(Image *) NULL; |
| 2434 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2435 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2436 | if (LocaleCompare("render",option+1) == 0) |
| 2437 | { |
| 2438 | (void) SyncImageSettings(mogrify_info,*image); |
| 2439 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2440 | break; |
| 2441 | } |
| 2442 | if (LocaleCompare("remap",option+1) == 0) |
| 2443 | { |
| 2444 | Image |
| 2445 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2446 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2447 | /* |
| 2448 | Transform image colors to match this set of colors. |
| 2449 | */ |
| 2450 | (void) SyncImageSettings(mogrify_info,*image); |
| 2451 | if (*option == '+') |
| 2452 | break; |
| 2453 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2454 | if (remap_image == (Image *) NULL) |
| 2455 | break; |
| 2456 | (void) RemapImage(quantize_info,*image,remap_image); |
| 2457 | InheritException(exception,&(*image)->exception); |
| 2458 | remap_image=DestroyImage(remap_image); |
| 2459 | break; |
| 2460 | } |
| 2461 | if (LocaleCompare("repage",option+1) == 0) |
| 2462 | { |
| 2463 | if (*option == '+') |
| 2464 | { |
| 2465 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2466 | break; |
| 2467 | } |
| 2468 | (void) ResetImagePage(*image,argv[i+1]); |
| 2469 | InheritException(exception,&(*image)->exception); |
| 2470 | break; |
| 2471 | } |
| 2472 | if (LocaleCompare("resample",option+1) == 0) |
| 2473 | { |
| 2474 | /* |
| 2475 | Resample image. |
| 2476 | */ |
| 2477 | (void) SyncImageSettings(mogrify_info,*image); |
| 2478 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2479 | if ((flags & SigmaValue) == 0) |
| 2480 | geometry_info.sigma=geometry_info.rho; |
| 2481 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
| 2482 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2483 | break; |
| 2484 | } |
| 2485 | if (LocaleCompare("resize",option+1) == 0) |
| 2486 | { |
| 2487 | /* |
| 2488 | Resize image. |
| 2489 | */ |
| 2490 | (void) SyncImageSettings(mogrify_info,*image); |
| 2491 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2492 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2493 | (*image)->filter,(*image)->blur,exception); |
| 2494 | break; |
| 2495 | } |
| 2496 | if (LocaleCompare("roll",option+1) == 0) |
| 2497 | { |
| 2498 | /* |
| 2499 | Roll image. |
| 2500 | */ |
| 2501 | (void) SyncImageSettings(mogrify_info,*image); |
| 2502 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2503 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2504 | break; |
| 2505 | } |
| 2506 | if (LocaleCompare("rotate",option+1) == 0) |
| 2507 | { |
| 2508 | char |
| 2509 | *geometry; |
| 2510 | |
| 2511 | /* |
| 2512 | Check for conditional image rotation. |
| 2513 | */ |
| 2514 | (void) SyncImageSettings(mogrify_info,*image); |
| 2515 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2516 | if ((*image)->columns <= (*image)->rows) |
| 2517 | break; |
| 2518 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2519 | if ((*image)->columns >= (*image)->rows) |
| 2520 | break; |
| 2521 | /* |
| 2522 | Rotate image. |
| 2523 | */ |
| 2524 | geometry=ConstantString(argv[i+1]); |
| 2525 | (void) SubstituteString(&geometry,">",""); |
| 2526 | (void) SubstituteString(&geometry,"<",""); |
| 2527 | (void) ParseGeometry(geometry,&geometry_info); |
| 2528 | geometry=DestroyString(geometry); |
| 2529 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
| 2530 | break; |
| 2531 | } |
| 2532 | break; |
| 2533 | } |
| 2534 | case 's': |
| 2535 | { |
| 2536 | if (LocaleCompare("sample",option+1) == 0) |
| 2537 | { |
| 2538 | /* |
| 2539 | Sample image with pixel replication. |
| 2540 | */ |
| 2541 | (void) SyncImageSettings(mogrify_info,*image); |
| 2542 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2543 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
| 2544 | exception); |
| 2545 | break; |
| 2546 | } |
| 2547 | if (LocaleCompare("scale",option+1) == 0) |
| 2548 | { |
| 2549 | /* |
| 2550 | Resize image. |
| 2551 | */ |
| 2552 | (void) SyncImageSettings(mogrify_info,*image); |
| 2553 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2554 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2555 | exception); |
| 2556 | break; |
| 2557 | } |
| 2558 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2559 | { |
| 2560 | /* |
| 2561 | Selectively blur pixels within a contrast threshold. |
| 2562 | */ |
| 2563 | (void) SyncImageSettings(mogrify_info,*image); |
| 2564 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2565 | if ((flags & PercentValue) != 0) |
| 2566 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2567 | mogrify_image=SelectiveBlurImage(*image,geometry_info.rho, |
| 2568 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2569 | break; |
| 2570 | } |
| 2571 | if (LocaleCompare("separate",option+1) == 0) |
| 2572 | { |
| 2573 | /* |
| 2574 | Break channels into separate images. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2575 | */ |
| 2576 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 2577 | mogrify_image=SeparateImages(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2578 | break; |
| 2579 | } |
| 2580 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2581 | { |
| 2582 | double |
| 2583 | threshold; |
| 2584 | |
| 2585 | /* |
| 2586 | Sepia-tone image. |
| 2587 | */ |
| 2588 | (void) SyncImageSettings(mogrify_info,*image); |
| 2589 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2590 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
| 2591 | break; |
| 2592 | } |
| 2593 | if (LocaleCompare("segment",option+1) == 0) |
| 2594 | { |
| 2595 | /* |
| 2596 | Segment image. |
| 2597 | */ |
| 2598 | (void) SyncImageSettings(mogrify_info,*image); |
| 2599 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2600 | if ((flags & SigmaValue) == 0) |
| 2601 | geometry_info.sigma=1.0; |
| 2602 | (void) SegmentImage(*image,(*image)->colorspace, |
| 2603 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma); |
| 2604 | InheritException(exception,&(*image)->exception); |
| 2605 | break; |
| 2606 | } |
| 2607 | if (LocaleCompare("set",option+1) == 0) |
| 2608 | { |
| 2609 | char |
| 2610 | *value; |
| 2611 | |
| 2612 | /* |
| 2613 | Set image option. |
| 2614 | */ |
| 2615 | if (*option == '+') |
| 2616 | { |
| 2617 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2618 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2619 | else |
| 2620 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2621 | { |
| 2622 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
| 2623 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2624 | } |
| 2625 | else |
| 2626 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2627 | break; |
| 2628 | } |
| 2629 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 2630 | if (value == (char *) NULL) |
| 2631 | break; |
| 2632 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2633 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2634 | exception); |
| 2635 | else |
| 2636 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2637 | { |
| 2638 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
| 2639 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
| 2640 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2641 | } |
| 2642 | else |
| 2643 | (void) SetImageProperty(*image,argv[i+1],value); |
| 2644 | value=DestroyString(value); |
| 2645 | break; |
| 2646 | } |
| 2647 | if (LocaleCompare("shade",option+1) == 0) |
| 2648 | { |
| 2649 | /* |
| 2650 | Shade image. |
| 2651 | */ |
| 2652 | (void) SyncImageSettings(mogrify_info,*image); |
| 2653 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2654 | if ((flags & SigmaValue) == 0) |
| 2655 | geometry_info.sigma=1.0; |
| 2656 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2657 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2658 | break; |
| 2659 | } |
| 2660 | if (LocaleCompare("shadow",option+1) == 0) |
| 2661 | { |
| 2662 | /* |
| 2663 | Shadow image. |
| 2664 | */ |
| 2665 | (void) SyncImageSettings(mogrify_info,*image); |
| 2666 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2667 | if ((flags & SigmaValue) == 0) |
| 2668 | geometry_info.sigma=1.0; |
| 2669 | if ((flags & XiValue) == 0) |
| 2670 | geometry_info.xi=4.0; |
| 2671 | if ((flags & PsiValue) == 0) |
| 2672 | geometry_info.psi=4.0; |
| 2673 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
| 2674 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 2675 | ceil(geometry_info.psi-0.5),exception); |
| 2676 | break; |
| 2677 | } |
| 2678 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2679 | { |
| 2680 | /* |
| 2681 | Sharpen image. |
| 2682 | */ |
| 2683 | (void) SyncImageSettings(mogrify_info,*image); |
| 2684 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2685 | if ((flags & SigmaValue) == 0) |
| 2686 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2687 | mogrify_image=SharpenImage(*image,geometry_info.rho, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2688 | geometry_info.sigma,exception); |
| 2689 | break; |
| 2690 | } |
| 2691 | if (LocaleCompare("shave",option+1) == 0) |
| 2692 | { |
| 2693 | /* |
| 2694 | Shave the image edges. |
| 2695 | */ |
| 2696 | (void) SyncImageSettings(mogrify_info,*image); |
| 2697 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2698 | mogrify_image=ShaveImage(*image,&geometry,exception); |
| 2699 | break; |
| 2700 | } |
| 2701 | if (LocaleCompare("shear",option+1) == 0) |
| 2702 | { |
| 2703 | /* |
| 2704 | Shear image. |
| 2705 | */ |
| 2706 | (void) SyncImageSettings(mogrify_info,*image); |
| 2707 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2708 | if ((flags & SigmaValue) == 0) |
| 2709 | geometry_info.sigma=geometry_info.rho; |
| 2710 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2711 | geometry_info.sigma,exception); |
| 2712 | break; |
| 2713 | } |
| 2714 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2715 | { |
| 2716 | /* |
| 2717 | Sigmoidal non-linearity contrast control. |
| 2718 | */ |
| 2719 | (void) SyncImageSettings(mogrify_info,*image); |
| 2720 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2721 | if ((flags & SigmaValue) == 0) |
| 2722 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 2723 | if ((flags & PercentValue) != 0) |
| 2724 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2725 | 100.0; |
cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 2726 | (void) SigmoidalContrastImage(*image,(*option == '-') ? |
| 2727 | MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2728 | InheritException(exception,&(*image)->exception); |
| 2729 | break; |
| 2730 | } |
| 2731 | if (LocaleCompare("sketch",option+1) == 0) |
| 2732 | { |
| 2733 | /* |
| 2734 | Sketch image. |
| 2735 | */ |
| 2736 | (void) SyncImageSettings(mogrify_info,*image); |
| 2737 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2738 | if ((flags & SigmaValue) == 0) |
| 2739 | geometry_info.sigma=1.0; |
| 2740 | mogrify_image=SketchImage(*image,geometry_info.rho, |
| 2741 | geometry_info.sigma,geometry_info.xi,exception); |
| 2742 | break; |
| 2743 | } |
| 2744 | if (LocaleCompare("solarize",option+1) == 0) |
| 2745 | { |
| 2746 | double |
| 2747 | threshold; |
| 2748 | |
| 2749 | (void) SyncImageSettings(mogrify_info,*image); |
| 2750 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2751 | (void) SolarizeImage(*image,threshold); |
| 2752 | InheritException(exception,&(*image)->exception); |
| 2753 | break; |
| 2754 | } |
| 2755 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2756 | { |
| 2757 | SparseColorMethod |
| 2758 | method; |
| 2759 | |
| 2760 | char |
| 2761 | *arguments; |
| 2762 | |
| 2763 | /* |
| 2764 | Sparse Color Interpolated Gradient |
| 2765 | */ |
| 2766 | (void) SyncImageSettings(mogrify_info,*image); |
| 2767 | method=(SparseColorMethod) ParseCommandOption( |
| 2768 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
| 2769 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 2770 | InheritException(exception,&(*image)->exception); |
| 2771 | if (arguments == (char *) NULL) |
| 2772 | break; |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 2773 | mogrify_image=SparseColorOption(*image,method,arguments, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2774 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2775 | arguments=DestroyString(arguments); |
| 2776 | break; |
| 2777 | } |
| 2778 | if (LocaleCompare("splice",option+1) == 0) |
| 2779 | { |
| 2780 | /* |
| 2781 | Splice a solid color into the image. |
| 2782 | */ |
| 2783 | (void) SyncImageSettings(mogrify_info,*image); |
| 2784 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 2785 | mogrify_image=SpliceImage(*image,&geometry,exception); |
| 2786 | break; |
| 2787 | } |
| 2788 | if (LocaleCompare("spread",option+1) == 0) |
| 2789 | { |
| 2790 | /* |
| 2791 | Spread an image. |
| 2792 | */ |
| 2793 | (void) SyncImageSettings(mogrify_info,*image); |
| 2794 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2795 | mogrify_image=SpreadImage(*image,geometry_info.rho,exception); |
| 2796 | break; |
| 2797 | } |
| 2798 | if (LocaleCompare("statistic",option+1) == 0) |
| 2799 | { |
| 2800 | StatisticType |
| 2801 | type; |
| 2802 | |
| 2803 | (void) SyncImageSettings(mogrify_info,*image); |
| 2804 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
| 2805 | MagickFalse,argv[i+1]); |
| 2806 | (void) ParseGeometry(argv[i+2],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2807 | mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho, |
| 2808 | (size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2809 | break; |
| 2810 | } |
| 2811 | if (LocaleCompare("stretch",option+1) == 0) |
| 2812 | { |
| 2813 | if (*option == '+') |
| 2814 | { |
| 2815 | draw_info->stretch=UndefinedStretch; |
| 2816 | break; |
| 2817 | } |
| 2818 | draw_info->stretch=(StretchType) ParseCommandOption( |
| 2819 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2820 | break; |
| 2821 | } |
| 2822 | if (LocaleCompare("strip",option+1) == 0) |
| 2823 | { |
| 2824 | /* |
| 2825 | Strip image of profiles and comments. |
| 2826 | */ |
| 2827 | (void) SyncImageSettings(mogrify_info,*image); |
| 2828 | (void) StripImage(*image); |
| 2829 | InheritException(exception,&(*image)->exception); |
| 2830 | break; |
| 2831 | } |
| 2832 | if (LocaleCompare("stroke",option+1) == 0) |
| 2833 | { |
| 2834 | ExceptionInfo |
| 2835 | *sans; |
| 2836 | |
| 2837 | if (*option == '+') |
| 2838 | { |
| 2839 | (void) QueryColorDatabase("none",&draw_info->stroke,exception); |
| 2840 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2841 | draw_info->stroke_pattern=DestroyImage( |
| 2842 | draw_info->stroke_pattern); |
| 2843 | break; |
| 2844 | } |
| 2845 | sans=AcquireExceptionInfo(); |
| 2846 | status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans); |
| 2847 | sans=DestroyExceptionInfo(sans); |
| 2848 | if (status == MagickFalse) |
| 2849 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2850 | exception); |
| 2851 | break; |
| 2852 | } |
| 2853 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2854 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 2855 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 2856 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2857 | break; |
| 2858 | } |
| 2859 | if (LocaleCompare("style",option+1) == 0) |
| 2860 | { |
| 2861 | if (*option == '+') |
| 2862 | { |
| 2863 | draw_info->style=UndefinedStyle; |
| 2864 | break; |
| 2865 | } |
| 2866 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 2867 | MagickFalse,argv[i+1]); |
| 2868 | break; |
| 2869 | } |
| 2870 | if (LocaleCompare("swirl",option+1) == 0) |
| 2871 | { |
| 2872 | /* |
| 2873 | Swirl image. |
| 2874 | */ |
| 2875 | (void) SyncImageSettings(mogrify_info,*image); |
| 2876 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2877 | mogrify_image=SwirlImage(*image,geometry_info.rho,exception); |
| 2878 | break; |
| 2879 | } |
| 2880 | break; |
| 2881 | } |
| 2882 | case 't': |
| 2883 | { |
| 2884 | if (LocaleCompare("threshold",option+1) == 0) |
| 2885 | { |
| 2886 | double |
| 2887 | threshold; |
| 2888 | |
| 2889 | /* |
| 2890 | Threshold image. |
| 2891 | */ |
| 2892 | (void) SyncImageSettings(mogrify_info,*image); |
| 2893 | if (*option == '+') |
anthony | 247a86d | 2011-05-03 13:18:18 +0000 | [diff] [blame] | 2894 | threshold=(double) QuantumRange/2; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2895 | else |
| 2896 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2897 | (void) BilevelImage(*image,threshold); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2898 | InheritException(exception,&(*image)->exception); |
| 2899 | break; |
| 2900 | } |
| 2901 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2902 | { |
| 2903 | /* |
| 2904 | Thumbnail image. |
| 2905 | */ |
| 2906 | (void) SyncImageSettings(mogrify_info,*image); |
| 2907 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2908 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2909 | exception); |
| 2910 | break; |
| 2911 | } |
| 2912 | if (LocaleCompare("tile",option+1) == 0) |
| 2913 | { |
| 2914 | if (*option == '+') |
| 2915 | { |
| 2916 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2917 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2918 | break; |
| 2919 | } |
| 2920 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2921 | exception); |
| 2922 | break; |
| 2923 | } |
| 2924 | if (LocaleCompare("tint",option+1) == 0) |
| 2925 | { |
| 2926 | /* |
| 2927 | Tint the image. |
| 2928 | */ |
| 2929 | (void) SyncImageSettings(mogrify_info,*image); |
| 2930 | mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception); |
| 2931 | break; |
| 2932 | } |
| 2933 | if (LocaleCompare("transform",option+1) == 0) |
| 2934 | { |
| 2935 | /* |
| 2936 | Affine transform image. |
| 2937 | */ |
| 2938 | (void) SyncImageSettings(mogrify_info,*image); |
| 2939 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
| 2940 | exception); |
| 2941 | break; |
| 2942 | } |
| 2943 | if (LocaleCompare("transparent",option+1) == 0) |
| 2944 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2945 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2946 | target; |
| 2947 | |
| 2948 | (void) SyncImageSettings(mogrify_info,*image); |
| 2949 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2950 | (void) TransparentPaintImage(*image,&target,(Quantum) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2951 | TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2952 | InheritException(exception,&(*image)->exception); |
| 2953 | break; |
| 2954 | } |
| 2955 | if (LocaleCompare("transpose",option+1) == 0) |
| 2956 | { |
| 2957 | /* |
| 2958 | Transpose image scanlines. |
| 2959 | */ |
| 2960 | (void) SyncImageSettings(mogrify_info,*image); |
| 2961 | mogrify_image=TransposeImage(*image,exception); |
| 2962 | break; |
| 2963 | } |
| 2964 | if (LocaleCompare("transverse",option+1) == 0) |
| 2965 | { |
| 2966 | /* |
| 2967 | Transverse image scanlines. |
| 2968 | */ |
| 2969 | (void) SyncImageSettings(mogrify_info,*image); |
| 2970 | mogrify_image=TransverseImage(*image,exception); |
| 2971 | break; |
| 2972 | } |
| 2973 | if (LocaleCompare("treedepth",option+1) == 0) |
| 2974 | { |
| 2975 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
| 2976 | break; |
| 2977 | } |
| 2978 | if (LocaleCompare("trim",option+1) == 0) |
| 2979 | { |
| 2980 | /* |
| 2981 | Trim image. |
| 2982 | */ |
| 2983 | (void) SyncImageSettings(mogrify_info,*image); |
| 2984 | mogrify_image=TrimImage(*image,exception); |
| 2985 | break; |
| 2986 | } |
| 2987 | if (LocaleCompare("type",option+1) == 0) |
| 2988 | { |
| 2989 | ImageType |
| 2990 | type; |
| 2991 | |
| 2992 | (void) SyncImageSettings(mogrify_info,*image); |
| 2993 | if (*option == '+') |
| 2994 | type=UndefinedType; |
| 2995 | else |
| 2996 | type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 2997 | argv[i+1]); |
| 2998 | (*image)->type=UndefinedType; |
| 2999 | (void) SetImageType(*image,type); |
| 3000 | InheritException(exception,&(*image)->exception); |
| 3001 | break; |
| 3002 | } |
| 3003 | break; |
| 3004 | } |
| 3005 | case 'u': |
| 3006 | { |
| 3007 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3008 | { |
| 3009 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 3010 | exception); |
| 3011 | break; |
| 3012 | } |
| 3013 | if (LocaleCompare("unique",option+1) == 0) |
| 3014 | { |
| 3015 | if (*option == '+') |
| 3016 | { |
| 3017 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
| 3018 | break; |
| 3019 | } |
| 3020 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
| 3021 | (void) SetImageArtifact(*image,"verbose","true"); |
| 3022 | break; |
| 3023 | } |
| 3024 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3025 | { |
| 3026 | /* |
| 3027 | Unique image colors. |
| 3028 | */ |
| 3029 | (void) SyncImageSettings(mogrify_info,*image); |
| 3030 | mogrify_image=UniqueImageColors(*image,exception); |
| 3031 | break; |
| 3032 | } |
| 3033 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3034 | { |
| 3035 | /* |
| 3036 | Unsharp mask image. |
| 3037 | */ |
| 3038 | (void) SyncImageSettings(mogrify_info,*image); |
| 3039 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3040 | if ((flags & SigmaValue) == 0) |
| 3041 | geometry_info.sigma=1.0; |
| 3042 | if ((flags & XiValue) == 0) |
| 3043 | geometry_info.xi=1.0; |
| 3044 | if ((flags & PsiValue) == 0) |
| 3045 | geometry_info.psi=0.05; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3046 | mogrify_image=UnsharpMaskImage(*image,geometry_info.rho, |
| 3047 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3048 | break; |
| 3049 | } |
| 3050 | break; |
| 3051 | } |
| 3052 | case 'v': |
| 3053 | { |
| 3054 | if (LocaleCompare("verbose",option+1) == 0) |
| 3055 | { |
| 3056 | (void) SetImageArtifact(*image,option+1, |
| 3057 | *option == '+' ? "false" : "true"); |
| 3058 | break; |
| 3059 | } |
| 3060 | if (LocaleCompare("vignette",option+1) == 0) |
| 3061 | { |
| 3062 | /* |
| 3063 | Vignette image. |
| 3064 | */ |
| 3065 | (void) SyncImageSettings(mogrify_info,*image); |
| 3066 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3067 | if ((flags & SigmaValue) == 0) |
| 3068 | geometry_info.sigma=1.0; |
| 3069 | if ((flags & XiValue) == 0) |
| 3070 | geometry_info.xi=0.1*(*image)->columns; |
| 3071 | if ((flags & PsiValue) == 0) |
| 3072 | geometry_info.psi=0.1*(*image)->rows; |
| 3073 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
| 3074 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3075 | ceil(geometry_info.psi-0.5),exception); |
| 3076 | break; |
| 3077 | } |
| 3078 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3079 | { |
| 3080 | if (*option == '+') |
| 3081 | { |
| 3082 | (void) SetImageVirtualPixelMethod(*image, |
| 3083 | UndefinedVirtualPixelMethod); |
| 3084 | break; |
| 3085 | } |
| 3086 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3087 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 3088 | argv[i+1])); |
| 3089 | break; |
| 3090 | } |
| 3091 | break; |
| 3092 | } |
| 3093 | case 'w': |
| 3094 | { |
| 3095 | if (LocaleCompare("wave",option+1) == 0) |
| 3096 | { |
| 3097 | /* |
| 3098 | Wave image. |
| 3099 | */ |
| 3100 | (void) SyncImageSettings(mogrify_info,*image); |
| 3101 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3102 | if ((flags & SigmaValue) == 0) |
| 3103 | geometry_info.sigma=1.0; |
| 3104 | mogrify_image=WaveImage(*image,geometry_info.rho, |
| 3105 | geometry_info.sigma,exception); |
| 3106 | break; |
| 3107 | } |
| 3108 | if (LocaleCompare("weight",option+1) == 0) |
| 3109 | { |
| 3110 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
| 3111 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3112 | draw_info->weight=0; |
| 3113 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3114 | draw_info->weight=700; |
| 3115 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3116 | if (draw_info->weight <= 800) |
| 3117 | draw_info->weight+=100; |
| 3118 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3119 | if (draw_info->weight >= 100) |
| 3120 | draw_info->weight-=100; |
| 3121 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3122 | draw_info->weight=400; |
| 3123 | break; |
| 3124 | } |
| 3125 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3126 | { |
| 3127 | /* |
| 3128 | White threshold image. |
| 3129 | */ |
| 3130 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3131 | (void) WhiteThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3132 | InheritException(exception,&(*image)->exception); |
| 3133 | break; |
| 3134 | } |
| 3135 | break; |
| 3136 | } |
| 3137 | default: |
| 3138 | break; |
| 3139 | } |
| 3140 | /* |
| 3141 | Replace current image with any image that was generated |
| 3142 | */ |
| 3143 | if (mogrify_image != (Image *) NULL) |
| 3144 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3145 | i+=count; |
| 3146 | } |
| 3147 | if (region_image != (Image *) NULL) |
| 3148 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3149 | /* |
| 3150 | Composite transformed region onto image. |
| 3151 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3152 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3153 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3154 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 3155 | region_geometry.x,region_geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3156 | InheritException(exception,®ion_image->exception); |
| 3157 | *image=DestroyImage(*image); |
| 3158 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3159 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3160 | } |
| 3161 | /* |
| 3162 | Free resources. |
| 3163 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3164 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3165 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3166 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 3167 | status=(MagickStatusType) ((*image)->exception.severity == |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 3168 | UndefinedException ? 1 : 0); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3169 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3170 | } |
| 3171 | |
| 3172 | /* |
| 3173 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3174 | % % |
| 3175 | % % |
| 3176 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3177 | + 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] | 3178 | % % |
| 3179 | % % |
| 3180 | % % |
| 3181 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3182 | % |
| 3183 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3184 | % transforms include image scaling, image rotation, color reduction, and |
| 3185 | % others. The transmogrified image overwrites the original image. |
| 3186 | % |
| 3187 | % The format of the MogrifyImageCommand method is: |
| 3188 | % |
| 3189 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3190 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3191 | % |
| 3192 | % A description of each parameter follows: |
| 3193 | % |
| 3194 | % o image_info: the image info. |
| 3195 | % |
| 3196 | % o argc: the number of elements in the argument vector. |
| 3197 | % |
| 3198 | % o argv: A text array containing the command line arguments. |
| 3199 | % |
| 3200 | % o metadata: any metadata is returned here. |
| 3201 | % |
| 3202 | % o exception: return any errors or warnings in this structure. |
| 3203 | % |
| 3204 | */ |
| 3205 | |
| 3206 | static MagickBooleanType MogrifyUsage(void) |
| 3207 | { |
| 3208 | static const char |
| 3209 | *miscellaneous[]= |
| 3210 | { |
| 3211 | "-debug events display copious debugging information", |
| 3212 | "-help print program options", |
| 3213 | "-list type print a list of supported option arguments", |
| 3214 | "-log format format of debugging information", |
| 3215 | "-version print version information", |
| 3216 | (char *) NULL |
| 3217 | }, |
| 3218 | *operators[]= |
| 3219 | { |
| 3220 | "-adaptive-blur geometry", |
| 3221 | " adaptively blur pixels; decrease effect near edges", |
| 3222 | "-adaptive-resize geometry", |
| 3223 | " adaptively resize image using 'mesh' interpolation", |
| 3224 | "-adaptive-sharpen geometry", |
| 3225 | " adaptively sharpen pixels; increase effect near edges", |
| 3226 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3227 | " transparent, extract, background, or shape", |
| 3228 | "-annotate geometry text", |
| 3229 | " annotate the image with text", |
| 3230 | "-auto-gamma automagically adjust gamma level of image", |
| 3231 | "-auto-level automagically adjust color levels of image", |
| 3232 | "-auto-orient automagically orient (rotate) image", |
| 3233 | "-bench iterations measure performance", |
| 3234 | "-black-threshold value", |
| 3235 | " force all pixels below the threshold into black", |
| 3236 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3237 | "-blur geometry reduce image noise and reduce detail levels", |
| 3238 | "-border geometry surround image with a border of color", |
| 3239 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3240 | "-brightness-contrast geometry", |
| 3241 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3242 | "-cdl filename color correct with a color decision list", |
| 3243 | "-charcoal radius simulate a charcoal drawing", |
| 3244 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3245 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3246 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3247 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3248 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3249 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3250 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3251 | "-contrast enhance or reduce the image contrast", |
| 3252 | "-contrast-stretch geometry", |
| 3253 | " improve contrast by `stretching' the intensity range", |
| 3254 | "-convolve coefficients", |
| 3255 | " apply a convolution kernel to the image", |
| 3256 | "-cycle amount cycle the image colormap", |
| 3257 | "-decipher filename convert cipher pixels to plain pixels", |
| 3258 | "-deskew threshold straighten an image", |
| 3259 | "-despeckle reduce the speckles within an image", |
| 3260 | "-distort method args", |
| 3261 | " distort images according to given method ad args", |
| 3262 | "-draw string annotate the image with a graphic primitive", |
| 3263 | "-edge radius apply a filter to detect edges in the image", |
| 3264 | "-encipher filename convert plain pixels to cipher pixels", |
| 3265 | "-emboss radius emboss an image", |
| 3266 | "-enhance apply a digital filter to enhance a noisy image", |
| 3267 | "-equalize perform histogram equalization to an image", |
| 3268 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3269 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3270 | "-extent geometry set the image size", |
| 3271 | "-extract geometry extract area from image", |
| 3272 | "-fft implements the discrete Fourier transform (DFT)", |
| 3273 | "-flip flip image vertically", |
| 3274 | "-floodfill geometry color", |
| 3275 | " floodfill the image with color", |
| 3276 | "-flop flop image horizontally", |
| 3277 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3278 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3279 | " apply function over image values", |
| 3280 | "-gamma value level of gamma correction", |
| 3281 | "-gaussian-blur geometry", |
| 3282 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3283 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3284 | "-identify identify the format and characteristics of the image", |
| 3285 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3286 | "-implode amount implode image pixels about the center", |
| 3287 | "-lat geometry local adaptive thresholding", |
| 3288 | "-layers method optimize, merge, or compare image layers", |
| 3289 | "-level value adjust the level of image contrast", |
| 3290 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3291 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3292 | "-linear-stretch geometry", |
| 3293 | " improve contrast by `stretching with saturation'", |
| 3294 | "-liquid-rescale geometry", |
| 3295 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3296 | "-median geometry apply a median filter to the image", |
glennrp | 30d2dc6 | 2011-06-25 03:17:16 +0000 | [diff] [blame] | 3297 | "-mode geometry make each pixel the 'predominant color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3298 | "-modulate value vary the brightness, saturation, and hue", |
| 3299 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3300 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3301 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3302 | "-motion-blur geometry", |
| 3303 | " simulate motion blur", |
| 3304 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3305 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3306 | "-normalize transform image to span the full range of colors", |
| 3307 | "-opaque color change this color to the fill color", |
| 3308 | "-ordered-dither NxN", |
| 3309 | " add a noise pattern to the image with specific", |
| 3310 | " amplitudes", |
| 3311 | "-paint radius simulate an oil painting", |
| 3312 | "-polaroid angle simulate a Polaroid picture", |
| 3313 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3314 | "-profile filename add, delete, or apply an image profile", |
| 3315 | "-quantize colorspace reduce colors in this colorspace", |
| 3316 | "-radial-blur angle radial blur the image", |
| 3317 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3318 | "-random-threshold low,high", |
| 3319 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3320 | "-region geometry apply options to a portion of the image", |
| 3321 | "-render render vector graphics", |
| 3322 | "-repage geometry size and location of an image canvas", |
| 3323 | "-resample geometry change the resolution of an image", |
| 3324 | "-resize geometry resize the image", |
| 3325 | "-roll geometry roll an image vertically or horizontally", |
| 3326 | "-rotate degrees apply Paeth rotation to the image", |
| 3327 | "-sample geometry scale image with pixel sampling", |
| 3328 | "-scale geometry scale the image", |
| 3329 | "-segment values segment an image", |
| 3330 | "-selective-blur geometry", |
| 3331 | " selectively blur pixels within a contrast threshold", |
| 3332 | "-sepia-tone threshold", |
| 3333 | " simulate a sepia-toned photo", |
| 3334 | "-set property value set an image property", |
| 3335 | "-shade degrees shade the image using a distant light source", |
| 3336 | "-shadow geometry simulate an image shadow", |
| 3337 | "-sharpen geometry sharpen the image", |
| 3338 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3339 | "-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] | 3340 | "-sigmoidal-contrast geometry", |
| 3341 | " increase the contrast without saturating highlights or shadows", |
| 3342 | "-sketch geometry simulate a pencil sketch", |
| 3343 | "-solarize threshold negate all pixels above the threshold level", |
| 3344 | "-sparse-color method args", |
| 3345 | " fill in a image based on a few color points", |
| 3346 | "-splice geometry splice the background color into the image", |
| 3347 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3348 | "-statistic type radius", |
| 3349 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3350 | "-strip strip image of all profiles and comments", |
| 3351 | "-swirl degrees swirl image pixels about the center", |
| 3352 | "-threshold value threshold the image", |
| 3353 | "-thumbnail geometry create a thumbnail of the image", |
| 3354 | "-tile filename tile image when filling a graphic primitive", |
| 3355 | "-tint value tint the image with the fill color", |
| 3356 | "-transform affine transform image", |
| 3357 | "-transparent color make this color transparent within the image", |
| 3358 | "-transpose flip image vertically and rotate 90 degrees", |
| 3359 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3360 | "-trim trim image edges", |
| 3361 | "-type type image type", |
| 3362 | "-unique-colors discard all but one of any pixel color", |
| 3363 | "-unsharp geometry sharpen the image", |
| 3364 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3365 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3366 | "-white-threshold value", |
| 3367 | " force all pixels above the threshold into white", |
| 3368 | (char *) NULL |
| 3369 | }, |
| 3370 | *sequence_operators[]= |
| 3371 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3372 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3373 | "-clut apply a color lookup table to the image", |
| 3374 | "-coalesce merge a sequence of images", |
| 3375 | "-combine combine a sequence of images", |
| 3376 | "-composite composite image", |
| 3377 | "-crop geometry cut out a rectangular region of the image", |
| 3378 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3379 | "-evaluate-sequence operator", |
| 3380 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3381 | "-flatten flatten a sequence of images", |
| 3382 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3383 | "-hald-clut apply a Hald color lookup table to the image", |
| 3384 | "-morph value morph an image sequence", |
| 3385 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3386 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3387 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3388 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3389 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3390 | "-write filename write images to this file", |
| 3391 | (char *) NULL |
| 3392 | }, |
| 3393 | *settings[]= |
| 3394 | { |
| 3395 | "-adjoin join images into a single multi-image file", |
| 3396 | "-affine matrix affine transform matrix", |
| 3397 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3398 | "-antialias remove pixel-aliasing", |
| 3399 | "-authenticate password", |
| 3400 | " decipher image with this password", |
| 3401 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3402 | "-background color background color", |
| 3403 | "-bias value add bias when convolving an image", |
| 3404 | "-black-point-compensation", |
| 3405 | " use black point compensation", |
| 3406 | "-blue-primary point chromaticity blue primary point", |
| 3407 | "-bordercolor color border color", |
| 3408 | "-caption string assign a caption to an image", |
| 3409 | "-channel type apply option to select image channels", |
| 3410 | "-colors value preferred number of colors in the image", |
| 3411 | "-colorspace type alternate image colorspace", |
| 3412 | "-comment string annotate image with comment", |
| 3413 | "-compose operator set image composite operator", |
| 3414 | "-compress type type of pixel compression when writing the image", |
| 3415 | "-define format:option", |
| 3416 | " define one or more image format options", |
| 3417 | "-delay value display the next image after pausing", |
| 3418 | "-density geometry horizontal and vertical density of the image", |
| 3419 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3420 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3421 | "-display server get image or font from this X server", |
| 3422 | "-dispose method layer disposal method", |
| 3423 | "-dither method apply error diffusion to image", |
| 3424 | "-encoding type text encoding type", |
| 3425 | "-endian type endianness (MSB or LSB) of the image", |
| 3426 | "-family name render text with this font family", |
| 3427 | "-fill color color to use when filling a graphic primitive", |
| 3428 | "-filter type use this filter when resizing an image", |
| 3429 | "-font name render text with this font", |
| 3430 | "-format \"string\" output formatted image characteristics", |
| 3431 | "-fuzz distance colors within this distance are considered equal", |
| 3432 | "-gravity type horizontal and vertical text placement", |
| 3433 | "-green-primary point chromaticity green primary point", |
| 3434 | "-intent type type of rendering intent when managing the image color", |
| 3435 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3436 | "-interline-spacing value", |
| 3437 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3438 | "-interpolate method pixel color interpolation method", |
| 3439 | "-interword-spacing value", |
| 3440 | " set the space between two words", |
| 3441 | "-kerning value set the space between two letters", |
| 3442 | "-label string assign a label to an image", |
| 3443 | "-limit type value pixel cache resource limit", |
| 3444 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3445 | "-mask filename associate a mask with the image", |
| 3446 | "-mattecolor color frame color", |
| 3447 | "-monitor monitor progress", |
| 3448 | "-orient type image orientation", |
| 3449 | "-page geometry size and location of an image canvas (setting)", |
| 3450 | "-ping efficiently determine image attributes", |
| 3451 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3452 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3453 | "-preview type image preview type", |
| 3454 | "-quality value JPEG/MIFF/PNG compression level", |
| 3455 | "-quiet suppress all warning messages", |
| 3456 | "-red-primary point chromaticity red primary point", |
| 3457 | "-regard-warnings pay attention to warning messages", |
| 3458 | "-remap filename transform image colors to match this set of colors", |
| 3459 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3460 | "-sampling-factor geometry", |
| 3461 | " horizontal and vertical sampling factor", |
| 3462 | "-scene value image scene number", |
| 3463 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3464 | "-size geometry width and height of image", |
| 3465 | "-stretch type render text with this font stretch", |
| 3466 | "-stroke color graphic primitive stroke color", |
| 3467 | "-strokewidth value graphic primitive stroke width", |
| 3468 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3469 | "-synchronize synchronize image to storage device", |
| 3470 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3471 | "-texture filename name of texture to tile onto the image background", |
| 3472 | "-tile-offset geometry", |
| 3473 | " tile offset", |
| 3474 | "-treedepth value color tree depth", |
| 3475 | "-transparent-color color", |
| 3476 | " transparent color", |
| 3477 | "-undercolor color annotation bounding box color", |
| 3478 | "-units type the units of image resolution", |
| 3479 | "-verbose print detailed information about the image", |
| 3480 | "-view FlashPix viewing transforms", |
| 3481 | "-virtual-pixel method", |
| 3482 | " virtual pixel access method", |
| 3483 | "-weight type render text with this font weight", |
| 3484 | "-white-point point chromaticity white point", |
| 3485 | (char *) NULL |
| 3486 | }, |
| 3487 | *stack_operators[]= |
| 3488 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3489 | "-delete indexes delete the image from the image sequence", |
| 3490 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3491 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3492 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3493 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3494 | "-swap indexes swap two images in the image sequence", |
| 3495 | (char *) NULL |
| 3496 | }; |
| 3497 | |
| 3498 | const char |
| 3499 | **p; |
| 3500 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3501 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3502 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3503 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3504 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3505 | GetClientName()); |
| 3506 | (void) printf("\nImage Settings:\n"); |
| 3507 | for (p=settings; *p != (char *) NULL; p++) |
| 3508 | (void) printf(" %s\n",*p); |
| 3509 | (void) printf("\nImage Operators:\n"); |
| 3510 | for (p=operators; *p != (char *) NULL; p++) |
| 3511 | (void) printf(" %s\n",*p); |
| 3512 | (void) printf("\nImage Sequence Operators:\n"); |
| 3513 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3514 | (void) printf(" %s\n",*p); |
| 3515 | (void) printf("\nImage Stack Operators:\n"); |
| 3516 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3517 | (void) printf(" %s\n",*p); |
| 3518 | (void) printf("\nMiscellaneous Options:\n"); |
| 3519 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3520 | (void) printf(" %s\n",*p); |
| 3521 | (void) printf( |
| 3522 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3523 | (void) printf( |
| 3524 | "number. To specify a particular image format, precede the filename\n"); |
| 3525 | (void) printf( |
| 3526 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3527 | (void) printf( |
| 3528 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3529 | (void) printf("'-' for standard input or output.\n"); |
| 3530 | return(MagickFalse); |
| 3531 | } |
| 3532 | |
| 3533 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3534 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3535 | { |
| 3536 | #define DestroyMogrify() \ |
| 3537 | { \ |
| 3538 | if (format != (char *) NULL) \ |
| 3539 | format=DestroyString(format); \ |
| 3540 | if (path != (char *) NULL) \ |
| 3541 | path=DestroyString(path); \ |
| 3542 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3543 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3544 | argv[i]=DestroyString(argv[i]); \ |
| 3545 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3546 | } |
| 3547 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3548 | { \ |
| 3549 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3550 | option); \ |
| 3551 | DestroyMogrify(); \ |
| 3552 | return(MagickFalse); \ |
| 3553 | } |
| 3554 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3555 | { \ |
| 3556 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3557 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3558 | DestroyMogrify(); \ |
| 3559 | return(MagickFalse); \ |
| 3560 | } |
| 3561 | |
| 3562 | char |
| 3563 | *format, |
| 3564 | *option, |
| 3565 | *path; |
| 3566 | |
| 3567 | Image |
| 3568 | *image; |
| 3569 | |
| 3570 | ImageStack |
| 3571 | image_stack[MaxImageStackDepth+1]; |
| 3572 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3573 | MagickBooleanType |
| 3574 | global_colormap; |
| 3575 | |
| 3576 | MagickBooleanType |
| 3577 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3578 | pend, |
| 3579 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3580 | |
| 3581 | MagickStatusType |
| 3582 | status; |
| 3583 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3584 | register ssize_t |
| 3585 | i; |
| 3586 | |
| 3587 | ssize_t |
| 3588 | j, |
| 3589 | k; |
| 3590 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3591 | /* |
| 3592 | Set defaults. |
| 3593 | */ |
| 3594 | assert(image_info != (ImageInfo *) NULL); |
| 3595 | assert(image_info->signature == MagickSignature); |
| 3596 | if (image_info->debug != MagickFalse) |
| 3597 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3598 | assert(exception != (ExceptionInfo *) NULL); |
| 3599 | if (argc == 2) |
| 3600 | { |
| 3601 | option=argv[1]; |
| 3602 | if ((LocaleCompare("version",option+1) == 0) || |
| 3603 | (LocaleCompare("-version",option+1) == 0)) |
| 3604 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3605 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3606 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 3607 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 3608 | GetMagickCopyright()); |
| 3609 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 3610 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3611 | return(MagickFalse); |
| 3612 | } |
| 3613 | } |
| 3614 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3615 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3616 | format=(char *) NULL; |
| 3617 | path=(char *) NULL; |
| 3618 | global_colormap=MagickFalse; |
| 3619 | k=0; |
| 3620 | j=1; |
| 3621 | NewImageStack(); |
| 3622 | option=(char *) NULL; |
| 3623 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3624 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3625 | status=MagickTrue; |
| 3626 | /* |
| 3627 | Parse command line. |
| 3628 | */ |
| 3629 | ReadCommandlLine(argc,&argv); |
| 3630 | status=ExpandFilenames(&argc,&argv); |
| 3631 | if (status == MagickFalse) |
| 3632 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3633 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3634 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3635 | { |
| 3636 | option=argv[i]; |
| 3637 | if (LocaleCompare(option,"(") == 0) |
| 3638 | { |
| 3639 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3640 | if (k == MaxImageStackDepth) |
| 3641 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3642 | option); |
| 3643 | PushImageStack(); |
| 3644 | continue; |
| 3645 | } |
| 3646 | if (LocaleCompare(option,")") == 0) |
| 3647 | { |
| 3648 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3649 | if (k == 0) |
| 3650 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3651 | PopImageStack(); |
| 3652 | continue; |
| 3653 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3654 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3655 | { |
| 3656 | char |
| 3657 | backup_filename[MaxTextExtent], |
| 3658 | *filename; |
| 3659 | |
| 3660 | Image |
| 3661 | *images; |
| 3662 | |
| 3663 | /* |
| 3664 | Option is a file name: begin by reading image from specified file. |
| 3665 | */ |
| 3666 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3667 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3668 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3669 | filename=argv[++i]; |
| 3670 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 3671 | images=ReadImages(image_info,exception); |
| 3672 | status&=(images != (Image *) NULL) && |
| 3673 | (exception->severity < ErrorException); |
| 3674 | if (images == (Image *) NULL) |
| 3675 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3676 | if (format != (char *) NULL) |
| 3677 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3678 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3679 | if (path != (char *) NULL) |
| 3680 | { |
| 3681 | GetPathComponent(option,TailPath,filename); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3682 | (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3683 | path,*DirectorySeparator,filename); |
| 3684 | } |
| 3685 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3686 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3687 | AppendImageStack(images); |
| 3688 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3689 | if (global_colormap != MagickFalse) |
| 3690 | { |
| 3691 | QuantizeInfo |
| 3692 | *quantize_info; |
| 3693 | |
| 3694 | quantize_info=AcquireQuantizeInfo(image_info); |
| 3695 | (void) RemapImages(quantize_info,images,(Image *) NULL); |
| 3696 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3697 | } |
| 3698 | *backup_filename='\0'; |
| 3699 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3700 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3701 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3702 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3703 | i; |
| 3704 | |
| 3705 | /* |
| 3706 | Rename image file as backup. |
| 3707 | */ |
| 3708 | (void) CopyMagickString(backup_filename,image->filename, |
| 3709 | MaxTextExtent); |
| 3710 | for (i=0; i < 6; i++) |
| 3711 | { |
| 3712 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3713 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3714 | break; |
| 3715 | } |
| 3716 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
| 3717 | (rename(image->filename,backup_filename) != 0)) |
| 3718 | *backup_filename='\0'; |
| 3719 | } |
| 3720 | /* |
| 3721 | Write transmogrified image to disk. |
| 3722 | */ |
| 3723 | image_info->synchronize=MagickTrue; |
| 3724 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3725 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
| 3726 | (void) remove(backup_filename); |
| 3727 | RemoveAllImageStack(); |
| 3728 | continue; |
| 3729 | } |
| 3730 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3731 | switch (*(option+1)) |
| 3732 | { |
| 3733 | case 'a': |
| 3734 | { |
| 3735 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3736 | { |
| 3737 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3738 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3739 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3740 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3741 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3742 | break; |
| 3743 | } |
| 3744 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3745 | { |
| 3746 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3747 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3748 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3749 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3750 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3751 | break; |
| 3752 | } |
| 3753 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3754 | { |
| 3755 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3756 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3757 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3758 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3759 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3760 | break; |
| 3761 | } |
| 3762 | if (LocaleCompare("affine",option+1) == 0) |
| 3763 | { |
| 3764 | if (*option == '+') |
| 3765 | break; |
| 3766 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3767 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3768 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3769 | break; |
| 3770 | } |
| 3771 | if (LocaleCompare("alpha",option+1) == 0) |
| 3772 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3773 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3774 | type; |
| 3775 | |
| 3776 | if (*option == '+') |
| 3777 | break; |
| 3778 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3779 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3780 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3781 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3782 | if (type < 0) |
| 3783 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3784 | argv[i]); |
| 3785 | break; |
| 3786 | } |
| 3787 | if (LocaleCompare("annotate",option+1) == 0) |
| 3788 | { |
| 3789 | if (*option == '+') |
| 3790 | break; |
| 3791 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3792 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3793 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3794 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3795 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3796 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3797 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3798 | i++; |
| 3799 | break; |
| 3800 | } |
| 3801 | if (LocaleCompare("antialias",option+1) == 0) |
| 3802 | break; |
| 3803 | if (LocaleCompare("append",option+1) == 0) |
| 3804 | break; |
| 3805 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3806 | { |
| 3807 | if (*option == '+') |
| 3808 | break; |
| 3809 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3810 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3811 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3812 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3813 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3814 | break; |
| 3815 | } |
| 3816 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3817 | { |
| 3818 | if (*option == '+') |
| 3819 | break; |
| 3820 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3821 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3822 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3823 | break; |
| 3824 | } |
| 3825 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3826 | break; |
| 3827 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3828 | break; |
| 3829 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3830 | break; |
| 3831 | if (LocaleCompare("average",option+1) == 0) |
| 3832 | break; |
| 3833 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3834 | } |
| 3835 | case 'b': |
| 3836 | { |
| 3837 | if (LocaleCompare("background",option+1) == 0) |
| 3838 | { |
| 3839 | if (*option == '+') |
| 3840 | break; |
| 3841 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3842 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3843 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3844 | break; |
| 3845 | } |
| 3846 | if (LocaleCompare("bias",option+1) == 0) |
| 3847 | { |
| 3848 | if (*option == '+') |
| 3849 | break; |
| 3850 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3851 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3852 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3853 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3854 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3855 | break; |
| 3856 | } |
| 3857 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 3858 | break; |
| 3859 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 3860 | { |
| 3861 | if (*option == '+') |
| 3862 | break; |
| 3863 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3864 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3865 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3866 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3867 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3868 | break; |
| 3869 | } |
| 3870 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3871 | { |
| 3872 | if (*option == '+') |
| 3873 | break; |
| 3874 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3875 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3876 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3877 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3878 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3879 | break; |
| 3880 | } |
| 3881 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3882 | { |
| 3883 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3884 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3885 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3886 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3887 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3888 | break; |
| 3889 | } |
| 3890 | if (LocaleCompare("blur",option+1) == 0) |
| 3891 | { |
| 3892 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3893 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3894 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3895 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3896 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3897 | break; |
| 3898 | } |
| 3899 | if (LocaleCompare("border",option+1) == 0) |
| 3900 | { |
| 3901 | if (*option == '+') |
| 3902 | break; |
| 3903 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3904 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3905 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3906 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3907 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3908 | break; |
| 3909 | } |
| 3910 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3911 | { |
| 3912 | if (*option == '+') |
| 3913 | break; |
| 3914 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3915 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3916 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3917 | break; |
| 3918 | } |
| 3919 | if (LocaleCompare("box",option+1) == 0) |
| 3920 | { |
| 3921 | if (*option == '+') |
| 3922 | break; |
| 3923 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3924 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3925 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3926 | break; |
| 3927 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3928 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 3929 | { |
| 3930 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3931 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3932 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3933 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3934 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3935 | break; |
| 3936 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3937 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3938 | } |
| 3939 | case 'c': |
| 3940 | { |
| 3941 | if (LocaleCompare("cache",option+1) == 0) |
| 3942 | { |
| 3943 | if (*option == '+') |
| 3944 | break; |
| 3945 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3946 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3947 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3948 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3949 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3950 | break; |
| 3951 | } |
| 3952 | if (LocaleCompare("caption",option+1) == 0) |
| 3953 | { |
| 3954 | if (*option == '+') |
| 3955 | break; |
| 3956 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3957 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3958 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3959 | break; |
| 3960 | } |
| 3961 | if (LocaleCompare("channel",option+1) == 0) |
| 3962 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3963 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3964 | channel; |
| 3965 | |
| 3966 | if (*option == '+') |
| 3967 | break; |
| 3968 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3969 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3970 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3971 | channel=ParseChannelOption(argv[i]); |
| 3972 | if (channel < 0) |
| 3973 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 3974 | argv[i]); |
| 3975 | break; |
| 3976 | } |
| 3977 | if (LocaleCompare("cdl",option+1) == 0) |
| 3978 | { |
| 3979 | if (*option == '+') |
| 3980 | break; |
| 3981 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3982 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3983 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3984 | break; |
| 3985 | } |
| 3986 | if (LocaleCompare("charcoal",option+1) == 0) |
| 3987 | { |
| 3988 | if (*option == '+') |
| 3989 | break; |
| 3990 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3991 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3992 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3993 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3994 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3995 | break; |
| 3996 | } |
| 3997 | if (LocaleCompare("chop",option+1) == 0) |
| 3998 | { |
| 3999 | if (*option == '+') |
| 4000 | break; |
| 4001 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4002 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4003 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4004 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4005 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4006 | break; |
| 4007 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4008 | if (LocaleCompare("clamp",option+1) == 0) |
| 4009 | break; |
| 4010 | if (LocaleCompare("clip",option+1) == 0) |
| 4011 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4012 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4013 | { |
| 4014 | if (*option == '+') |
| 4015 | break; |
| 4016 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4017 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4018 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4019 | break; |
| 4020 | } |
| 4021 | if (LocaleCompare("clut",option+1) == 0) |
| 4022 | break; |
| 4023 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4024 | break; |
| 4025 | if (LocaleCompare("colorize",option+1) == 0) |
| 4026 | { |
| 4027 | if (*option == '+') |
| 4028 | break; |
| 4029 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4030 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4031 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4032 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4033 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4034 | break; |
| 4035 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4036 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4037 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4038 | KernelInfo |
| 4039 | *kernel_info; |
| 4040 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4041 | if (*option == '+') |
| 4042 | break; |
| 4043 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4044 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4045 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4046 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4047 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4048 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4049 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4050 | break; |
| 4051 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4052 | if (LocaleCompare("colors",option+1) == 0) |
| 4053 | { |
| 4054 | if (*option == '+') |
| 4055 | break; |
| 4056 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4057 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4058 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4059 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4060 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4061 | break; |
| 4062 | } |
| 4063 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4064 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4065 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4066 | colorspace; |
| 4067 | |
| 4068 | if (*option == '+') |
| 4069 | break; |
| 4070 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4071 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4072 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4073 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4074 | argv[i]); |
| 4075 | if (colorspace < 0) |
| 4076 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4077 | argv[i]); |
| 4078 | break; |
| 4079 | } |
| 4080 | if (LocaleCompare("combine",option+1) == 0) |
| 4081 | break; |
| 4082 | if (LocaleCompare("comment",option+1) == 0) |
| 4083 | { |
| 4084 | if (*option == '+') |
| 4085 | break; |
| 4086 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4087 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4088 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4089 | break; |
| 4090 | } |
| 4091 | if (LocaleCompare("composite",option+1) == 0) |
| 4092 | break; |
| 4093 | if (LocaleCompare("compress",option+1) == 0) |
| 4094 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4095 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4096 | compress; |
| 4097 | |
| 4098 | if (*option == '+') |
| 4099 | break; |
| 4100 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4101 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4102 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4103 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4104 | argv[i]); |
| 4105 | if (compress < 0) |
| 4106 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4107 | argv[i]); |
| 4108 | break; |
| 4109 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4110 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4111 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4112 | if (LocaleCompare("contrast",option+1) == 0) |
| 4113 | break; |
| 4114 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4115 | { |
| 4116 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4117 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4118 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4119 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4120 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4121 | break; |
| 4122 | } |
| 4123 | if (LocaleCompare("convolve",option+1) == 0) |
| 4124 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4125 | KernelInfo |
| 4126 | *kernel_info; |
| 4127 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4128 | if (*option == '+') |
| 4129 | break; |
| 4130 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4131 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4132 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4133 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4134 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4135 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4136 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4137 | break; |
| 4138 | } |
| 4139 | if (LocaleCompare("crop",option+1) == 0) |
| 4140 | { |
| 4141 | if (*option == '+') |
| 4142 | break; |
| 4143 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4144 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4145 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4146 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4147 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4148 | break; |
| 4149 | } |
| 4150 | if (LocaleCompare("cycle",option+1) == 0) |
| 4151 | { |
| 4152 | if (*option == '+') |
| 4153 | break; |
| 4154 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4155 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4156 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4157 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4158 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4159 | break; |
| 4160 | } |
| 4161 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4162 | } |
| 4163 | case 'd': |
| 4164 | { |
| 4165 | if (LocaleCompare("decipher",option+1) == 0) |
| 4166 | { |
| 4167 | if (*option == '+') |
| 4168 | break; |
| 4169 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4170 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4171 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4172 | break; |
| 4173 | } |
| 4174 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4175 | break; |
| 4176 | if (LocaleCompare("debug",option+1) == 0) |
| 4177 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4178 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4179 | event; |
| 4180 | |
| 4181 | if (*option == '+') |
| 4182 | break; |
| 4183 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4184 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4185 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4186 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4187 | if (event < 0) |
| 4188 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4189 | argv[i]); |
| 4190 | (void) SetLogEventMask(argv[i]); |
| 4191 | break; |
| 4192 | } |
| 4193 | if (LocaleCompare("define",option+1) == 0) |
| 4194 | { |
| 4195 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4196 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4197 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4198 | if (*option == '+') |
| 4199 | { |
| 4200 | const char |
| 4201 | *define; |
| 4202 | |
| 4203 | define=GetImageOption(image_info,argv[i]); |
| 4204 | if (define == (const char *) NULL) |
| 4205 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4206 | break; |
| 4207 | } |
| 4208 | break; |
| 4209 | } |
| 4210 | if (LocaleCompare("delay",option+1) == 0) |
| 4211 | { |
| 4212 | if (*option == '+') |
| 4213 | break; |
| 4214 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4215 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4216 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4217 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4218 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4219 | break; |
| 4220 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4221 | if (LocaleCompare("delete",option+1) == 0) |
| 4222 | { |
| 4223 | if (*option == '+') |
| 4224 | break; |
| 4225 | i++; |
| 4226 | if (i == (ssize_t) (argc-1)) |
| 4227 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4228 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4229 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4230 | break; |
| 4231 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4232 | if (LocaleCompare("density",option+1) == 0) |
| 4233 | { |
| 4234 | if (*option == '+') |
| 4235 | break; |
| 4236 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4237 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4238 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4239 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4240 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4241 | break; |
| 4242 | } |
| 4243 | if (LocaleCompare("depth",option+1) == 0) |
| 4244 | { |
| 4245 | if (*option == '+') |
| 4246 | break; |
| 4247 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4248 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4249 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4250 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4251 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4252 | break; |
| 4253 | } |
| 4254 | if (LocaleCompare("deskew",option+1) == 0) |
| 4255 | { |
| 4256 | if (*option == '+') |
| 4257 | break; |
| 4258 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4259 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4260 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4261 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4262 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4263 | break; |
| 4264 | } |
| 4265 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4266 | break; |
| 4267 | if (LocaleCompare("dft",option+1) == 0) |
| 4268 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4269 | if (LocaleCompare("direction",option+1) == 0) |
| 4270 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4271 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4272 | direction; |
| 4273 | |
| 4274 | if (*option == '+') |
| 4275 | break; |
| 4276 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4277 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4278 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4279 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4280 | argv[i]); |
| 4281 | if (direction < 0) |
| 4282 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4283 | argv[i]); |
| 4284 | break; |
| 4285 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4286 | if (LocaleCompare("display",option+1) == 0) |
| 4287 | { |
| 4288 | if (*option == '+') |
| 4289 | break; |
| 4290 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4291 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4292 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4293 | break; |
| 4294 | } |
| 4295 | if (LocaleCompare("dispose",option+1) == 0) |
| 4296 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4297 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4298 | dispose; |
| 4299 | |
| 4300 | if (*option == '+') |
| 4301 | break; |
| 4302 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4303 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4304 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4305 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4306 | if (dispose < 0) |
| 4307 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4308 | argv[i]); |
| 4309 | break; |
| 4310 | } |
| 4311 | if (LocaleCompare("distort",option+1) == 0) |
| 4312 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4313 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4314 | op; |
| 4315 | |
| 4316 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4317 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4318 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4319 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4320 | if (op < 0) |
| 4321 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4322 | argv[i]); |
| 4323 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4324 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4325 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4326 | break; |
| 4327 | } |
| 4328 | if (LocaleCompare("dither",option+1) == 0) |
| 4329 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4330 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4331 | method; |
| 4332 | |
| 4333 | if (*option == '+') |
| 4334 | break; |
| 4335 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4336 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4337 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4338 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4339 | if (method < 0) |
| 4340 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4341 | argv[i]); |
| 4342 | break; |
| 4343 | } |
| 4344 | if (LocaleCompare("draw",option+1) == 0) |
| 4345 | { |
| 4346 | if (*option == '+') |
| 4347 | break; |
| 4348 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4349 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4350 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4351 | break; |
| 4352 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4353 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4354 | { |
| 4355 | if (*option == '+') |
| 4356 | break; |
| 4357 | i++; |
| 4358 | if (i == (ssize_t) (argc-1)) |
| 4359 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4360 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4361 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4362 | break; |
| 4363 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4364 | if (LocaleCompare("duration",option+1) == 0) |
| 4365 | { |
| 4366 | if (*option == '+') |
| 4367 | break; |
| 4368 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4369 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4370 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4371 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4372 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4373 | break; |
| 4374 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4375 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4376 | } |
| 4377 | case 'e': |
| 4378 | { |
| 4379 | if (LocaleCompare("edge",option+1) == 0) |
| 4380 | { |
| 4381 | if (*option == '+') |
| 4382 | break; |
| 4383 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4384 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4385 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4386 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4387 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4388 | break; |
| 4389 | } |
| 4390 | if (LocaleCompare("emboss",option+1) == 0) |
| 4391 | { |
| 4392 | if (*option == '+') |
| 4393 | break; |
| 4394 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4395 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4396 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4397 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4398 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4399 | break; |
| 4400 | } |
| 4401 | if (LocaleCompare("encipher",option+1) == 0) |
| 4402 | { |
| 4403 | if (*option == '+') |
| 4404 | break; |
| 4405 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4406 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4407 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4408 | break; |
| 4409 | } |
| 4410 | if (LocaleCompare("encoding",option+1) == 0) |
| 4411 | { |
| 4412 | if (*option == '+') |
| 4413 | break; |
| 4414 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4415 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4416 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4417 | break; |
| 4418 | } |
| 4419 | if (LocaleCompare("endian",option+1) == 0) |
| 4420 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4421 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4422 | endian; |
| 4423 | |
| 4424 | if (*option == '+') |
| 4425 | break; |
| 4426 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4427 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4428 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4429 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4430 | if (endian < 0) |
| 4431 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4432 | argv[i]); |
| 4433 | break; |
| 4434 | } |
| 4435 | if (LocaleCompare("enhance",option+1) == 0) |
| 4436 | break; |
| 4437 | if (LocaleCompare("equalize",option+1) == 0) |
| 4438 | break; |
| 4439 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4440 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4441 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4442 | op; |
| 4443 | |
| 4444 | if (*option == '+') |
| 4445 | break; |
| 4446 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4447 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4448 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4449 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4450 | if (op < 0) |
| 4451 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4452 | argv[i]); |
| 4453 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4454 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4455 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4456 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4457 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4458 | break; |
| 4459 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4460 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4461 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4462 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4463 | op; |
| 4464 | |
| 4465 | if (*option == '+') |
| 4466 | break; |
| 4467 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4468 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4469 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4470 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4471 | if (op < 0) |
| 4472 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4473 | argv[i]); |
| 4474 | break; |
| 4475 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4476 | if (LocaleCompare("extent",option+1) == 0) |
| 4477 | { |
| 4478 | if (*option == '+') |
| 4479 | break; |
| 4480 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4481 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4482 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4483 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4484 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4485 | break; |
| 4486 | } |
| 4487 | if (LocaleCompare("extract",option+1) == 0) |
| 4488 | { |
| 4489 | if (*option == '+') |
| 4490 | break; |
| 4491 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4492 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4493 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4494 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4495 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4496 | break; |
| 4497 | } |
| 4498 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4499 | } |
| 4500 | case 'f': |
| 4501 | { |
| 4502 | if (LocaleCompare("family",option+1) == 0) |
| 4503 | { |
| 4504 | if (*option == '+') |
| 4505 | break; |
| 4506 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4507 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4508 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4509 | break; |
| 4510 | } |
| 4511 | if (LocaleCompare("fill",option+1) == 0) |
| 4512 | { |
| 4513 | if (*option == '+') |
| 4514 | break; |
| 4515 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4516 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4517 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4518 | break; |
| 4519 | } |
| 4520 | if (LocaleCompare("filter",option+1) == 0) |
| 4521 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4522 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4523 | filter; |
| 4524 | |
| 4525 | if (*option == '+') |
| 4526 | break; |
| 4527 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4528 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4529 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4530 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4531 | if (filter < 0) |
| 4532 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4533 | argv[i]); |
| 4534 | break; |
| 4535 | } |
| 4536 | if (LocaleCompare("flatten",option+1) == 0) |
| 4537 | break; |
| 4538 | if (LocaleCompare("flip",option+1) == 0) |
| 4539 | break; |
| 4540 | if (LocaleCompare("flop",option+1) == 0) |
| 4541 | break; |
| 4542 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4543 | { |
| 4544 | if (*option == '+') |
| 4545 | break; |
| 4546 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4547 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4548 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4549 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4550 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4551 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4552 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4553 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4554 | break; |
| 4555 | } |
| 4556 | if (LocaleCompare("font",option+1) == 0) |
| 4557 | { |
| 4558 | if (*option == '+') |
| 4559 | break; |
| 4560 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4561 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4562 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4563 | break; |
| 4564 | } |
| 4565 | if (LocaleCompare("format",option+1) == 0) |
| 4566 | { |
| 4567 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4568 | (void) CloneString(&format,(char *) NULL); |
| 4569 | if (*option == '+') |
| 4570 | break; |
| 4571 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4572 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4573 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4574 | (void) CloneString(&format,argv[i]); |
| 4575 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4576 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4577 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4578 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4579 | if (*image_info->magick == '\0') |
| 4580 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4581 | format); |
| 4582 | break; |
| 4583 | } |
| 4584 | if (LocaleCompare("frame",option+1) == 0) |
| 4585 | { |
| 4586 | if (*option == '+') |
| 4587 | break; |
| 4588 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4589 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4590 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4591 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4592 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4593 | break; |
| 4594 | } |
| 4595 | if (LocaleCompare("function",option+1) == 0) |
| 4596 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4597 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4598 | op; |
| 4599 | |
| 4600 | if (*option == '+') |
| 4601 | break; |
| 4602 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4603 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4604 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4605 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4606 | if (op < 0) |
| 4607 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4608 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4609 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4610 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4611 | break; |
| 4612 | } |
| 4613 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4614 | { |
| 4615 | if (*option == '+') |
| 4616 | break; |
| 4617 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4618 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4619 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4620 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4621 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4622 | break; |
| 4623 | } |
| 4624 | if (LocaleCompare("fx",option+1) == 0) |
| 4625 | { |
| 4626 | if (*option == '+') |
| 4627 | break; |
| 4628 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4629 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4630 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4631 | break; |
| 4632 | } |
| 4633 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4634 | } |
| 4635 | case 'g': |
| 4636 | { |
| 4637 | if (LocaleCompare("gamma",option+1) == 0) |
| 4638 | { |
| 4639 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4640 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4641 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4642 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4643 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4644 | break; |
| 4645 | } |
| 4646 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4647 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4648 | { |
| 4649 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4650 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4651 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4652 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4653 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4654 | break; |
| 4655 | } |
| 4656 | if (LocaleCompare("geometry",option+1) == 0) |
| 4657 | { |
| 4658 | if (*option == '+') |
| 4659 | break; |
| 4660 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4661 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4662 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4663 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4664 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4665 | break; |
| 4666 | } |
| 4667 | if (LocaleCompare("gravity",option+1) == 0) |
| 4668 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4669 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4670 | gravity; |
| 4671 | |
| 4672 | if (*option == '+') |
| 4673 | break; |
| 4674 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4675 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4676 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4677 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4678 | if (gravity < 0) |
| 4679 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4680 | argv[i]); |
| 4681 | break; |
| 4682 | } |
| 4683 | if (LocaleCompare("green-primary",option+1) == 0) |
| 4684 | { |
| 4685 | if (*option == '+') |
| 4686 | break; |
| 4687 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4688 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4689 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4690 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4691 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4692 | break; |
| 4693 | } |
| 4694 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4695 | } |
| 4696 | case 'h': |
| 4697 | { |
| 4698 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4699 | break; |
| 4700 | if ((LocaleCompare("help",option+1) == 0) || |
| 4701 | (LocaleCompare("-help",option+1) == 0)) |
| 4702 | return(MogrifyUsage()); |
| 4703 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4704 | } |
| 4705 | case 'i': |
| 4706 | { |
| 4707 | if (LocaleCompare("identify",option+1) == 0) |
| 4708 | break; |
| 4709 | if (LocaleCompare("idft",option+1) == 0) |
| 4710 | break; |
| 4711 | if (LocaleCompare("implode",option+1) == 0) |
| 4712 | { |
| 4713 | if (*option == '+') |
| 4714 | break; |
| 4715 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4716 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4717 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4718 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4719 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4720 | break; |
| 4721 | } |
| 4722 | if (LocaleCompare("intent",option+1) == 0) |
| 4723 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4724 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4725 | intent; |
| 4726 | |
| 4727 | if (*option == '+') |
| 4728 | break; |
| 4729 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4730 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4731 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4732 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4733 | if (intent < 0) |
| 4734 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4735 | argv[i]); |
| 4736 | break; |
| 4737 | } |
| 4738 | if (LocaleCompare("interlace",option+1) == 0) |
| 4739 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4740 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4741 | interlace; |
| 4742 | |
| 4743 | if (*option == '+') |
| 4744 | break; |
| 4745 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4746 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4747 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4748 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4749 | argv[i]); |
| 4750 | if (interlace < 0) |
| 4751 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4752 | argv[i]); |
| 4753 | break; |
| 4754 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4755 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4756 | { |
| 4757 | if (*option == '+') |
| 4758 | break; |
| 4759 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4760 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4761 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4762 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4763 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4764 | break; |
| 4765 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4766 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4767 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4768 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4769 | interpolate; |
| 4770 | |
| 4771 | if (*option == '+') |
| 4772 | break; |
| 4773 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4774 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4775 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4776 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4777 | argv[i]); |
| 4778 | if (interpolate < 0) |
| 4779 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4780 | argv[i]); |
| 4781 | break; |
| 4782 | } |
| 4783 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4784 | { |
| 4785 | if (*option == '+') |
| 4786 | break; |
| 4787 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4788 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4789 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4790 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4791 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4792 | break; |
| 4793 | } |
| 4794 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4795 | } |
| 4796 | case 'k': |
| 4797 | { |
| 4798 | if (LocaleCompare("kerning",option+1) == 0) |
| 4799 | { |
| 4800 | if (*option == '+') |
| 4801 | break; |
| 4802 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4803 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4804 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4805 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4806 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4807 | break; |
| 4808 | } |
| 4809 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4810 | } |
| 4811 | case 'l': |
| 4812 | { |
| 4813 | if (LocaleCompare("label",option+1) == 0) |
| 4814 | { |
| 4815 | if (*option == '+') |
| 4816 | break; |
| 4817 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4818 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4819 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4820 | break; |
| 4821 | } |
| 4822 | if (LocaleCompare("lat",option+1) == 0) |
| 4823 | { |
| 4824 | if (*option == '+') |
| 4825 | break; |
| 4826 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4827 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4828 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4829 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4830 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4831 | } |
| 4832 | if (LocaleCompare("layers",option+1) == 0) |
| 4833 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4834 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4835 | type; |
| 4836 | |
| 4837 | if (*option == '+') |
| 4838 | break; |
| 4839 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4840 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4841 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4842 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4843 | if (type < 0) |
| 4844 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4845 | argv[i]); |
| 4846 | break; |
| 4847 | } |
| 4848 | if (LocaleCompare("level",option+1) == 0) |
| 4849 | { |
| 4850 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4851 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4852 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4853 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4854 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4855 | break; |
| 4856 | } |
| 4857 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4858 | { |
| 4859 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4860 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4861 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4862 | break; |
| 4863 | } |
| 4864 | if (LocaleCompare("linewidth",option+1) == 0) |
| 4865 | { |
| 4866 | if (*option == '+') |
| 4867 | break; |
| 4868 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4869 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4870 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4871 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4872 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4873 | break; |
| 4874 | } |
| 4875 | if (LocaleCompare("limit",option+1) == 0) |
| 4876 | { |
| 4877 | char |
| 4878 | *p; |
| 4879 | |
| 4880 | double |
| 4881 | value; |
| 4882 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4883 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4884 | resource; |
| 4885 | |
| 4886 | if (*option == '+') |
| 4887 | break; |
| 4888 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4889 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4890 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4891 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4892 | argv[i]); |
| 4893 | if (resource < 0) |
| 4894 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4895 | argv[i]); |
| 4896 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4897 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4898 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 4899 | value=InterpretLocaleValue(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4900 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4901 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4902 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4903 | break; |
| 4904 | } |
| 4905 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4906 | { |
| 4907 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4908 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4909 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4910 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4911 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4912 | break; |
| 4913 | } |
| 4914 | if (LocaleCompare("list",option+1) == 0) |
| 4915 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4916 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4917 | list; |
| 4918 | |
| 4919 | if (*option == '+') |
| 4920 | break; |
| 4921 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4922 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4923 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4924 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4925 | if (list < 0) |
| 4926 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4927 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4928 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4929 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4930 | } |
| 4931 | if (LocaleCompare("log",option+1) == 0) |
| 4932 | { |
| 4933 | if (*option == '+') |
| 4934 | break; |
| 4935 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4936 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4937 | (strchr(argv[i],'%') == (char *) NULL)) |
| 4938 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4939 | break; |
| 4940 | } |
| 4941 | if (LocaleCompare("loop",option+1) == 0) |
| 4942 | { |
| 4943 | if (*option == '+') |
| 4944 | break; |
| 4945 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4946 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4947 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4948 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4949 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4950 | break; |
| 4951 | } |
| 4952 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4953 | } |
| 4954 | case 'm': |
| 4955 | { |
| 4956 | if (LocaleCompare("map",option+1) == 0) |
| 4957 | { |
| 4958 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 4959 | if (*option == '+') |
| 4960 | break; |
| 4961 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4962 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4963 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4964 | break; |
| 4965 | } |
| 4966 | if (LocaleCompare("mask",option+1) == 0) |
| 4967 | { |
| 4968 | if (*option == '+') |
| 4969 | break; |
| 4970 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4971 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4972 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4973 | break; |
| 4974 | } |
| 4975 | if (LocaleCompare("matte",option+1) == 0) |
| 4976 | break; |
| 4977 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 4978 | { |
| 4979 | if (*option == '+') |
| 4980 | break; |
| 4981 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4982 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4983 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4984 | break; |
| 4985 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 4986 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 4987 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 4988 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 4989 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4990 | if (LocaleCompare("modulate",option+1) == 0) |
| 4991 | { |
| 4992 | if (*option == '+') |
| 4993 | break; |
| 4994 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4995 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4996 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4997 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4998 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4999 | break; |
| 5000 | } |
| 5001 | if (LocaleCompare("median",option+1) == 0) |
| 5002 | { |
| 5003 | if (*option == '+') |
| 5004 | break; |
| 5005 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5006 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5007 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5008 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5009 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5010 | break; |
| 5011 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5012 | if (LocaleCompare("mode",option+1) == 0) |
| 5013 | { |
| 5014 | if (*option == '+') |
| 5015 | break; |
| 5016 | i++; |
| 5017 | if (i == (ssize_t) argc) |
| 5018 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5019 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5020 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5021 | break; |
| 5022 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5023 | if (LocaleCompare("monitor",option+1) == 0) |
| 5024 | break; |
| 5025 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5026 | break; |
| 5027 | if (LocaleCompare("morph",option+1) == 0) |
| 5028 | { |
| 5029 | if (*option == '+') |
| 5030 | break; |
| 5031 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5032 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5033 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5034 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5035 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5036 | break; |
| 5037 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5038 | if (LocaleCompare("morphology",option+1) == 0) |
| 5039 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5040 | char |
| 5041 | token[MaxTextExtent]; |
| 5042 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5043 | KernelInfo |
| 5044 | *kernel_info; |
| 5045 | |
| 5046 | ssize_t |
| 5047 | op; |
| 5048 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5049 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5050 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5051 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5052 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5053 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5054 | if (op < 0) |
| 5055 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5056 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5057 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5058 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5059 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5060 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5061 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5062 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5063 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5064 | break; |
| 5065 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5066 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5067 | break; |
| 5068 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5069 | { |
| 5070 | if (*option == '+') |
| 5071 | break; |
| 5072 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5073 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5074 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5075 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5076 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5077 | break; |
| 5078 | } |
| 5079 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5080 | } |
| 5081 | case 'n': |
| 5082 | { |
| 5083 | if (LocaleCompare("negate",option+1) == 0) |
| 5084 | break; |
| 5085 | if (LocaleCompare("noise",option+1) == 0) |
| 5086 | { |
| 5087 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5088 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5089 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5090 | if (*option == '+') |
| 5091 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5092 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5093 | noise; |
| 5094 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5095 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5096 | if (noise < 0) |
| 5097 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5098 | argv[i]); |
| 5099 | break; |
| 5100 | } |
| 5101 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5102 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5103 | break; |
| 5104 | } |
| 5105 | if (LocaleCompare("noop",option+1) == 0) |
| 5106 | break; |
| 5107 | if (LocaleCompare("normalize",option+1) == 0) |
| 5108 | break; |
| 5109 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5110 | } |
| 5111 | case 'o': |
| 5112 | { |
| 5113 | if (LocaleCompare("opaque",option+1) == 0) |
| 5114 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5115 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5116 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5117 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5118 | break; |
| 5119 | } |
| 5120 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5121 | { |
| 5122 | if (*option == '+') |
| 5123 | break; |
| 5124 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5125 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5126 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5127 | break; |
| 5128 | } |
| 5129 | if (LocaleCompare("orient",option+1) == 0) |
| 5130 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5131 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5132 | orientation; |
| 5133 | |
| 5134 | orientation=UndefinedOrientation; |
| 5135 | if (*option == '+') |
| 5136 | break; |
| 5137 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5138 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5139 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5140 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5141 | argv[i]); |
| 5142 | if (orientation < 0) |
| 5143 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5144 | argv[i]); |
| 5145 | break; |
| 5146 | } |
| 5147 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5148 | } |
| 5149 | case 'p': |
| 5150 | { |
| 5151 | if (LocaleCompare("page",option+1) == 0) |
| 5152 | { |
| 5153 | if (*option == '+') |
| 5154 | break; |
| 5155 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5156 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5157 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5158 | break; |
| 5159 | } |
| 5160 | if (LocaleCompare("paint",option+1) == 0) |
| 5161 | { |
| 5162 | if (*option == '+') |
| 5163 | break; |
| 5164 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5165 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5166 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5167 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5168 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5169 | break; |
| 5170 | } |
| 5171 | if (LocaleCompare("path",option+1) == 0) |
| 5172 | { |
| 5173 | (void) CloneString(&path,(char *) NULL); |
| 5174 | if (*option == '+') |
| 5175 | break; |
| 5176 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5177 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5178 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5179 | (void) CloneString(&path,argv[i]); |
| 5180 | break; |
| 5181 | } |
| 5182 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5183 | { |
| 5184 | if (*option == '+') |
| 5185 | break; |
| 5186 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5187 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5188 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5189 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5190 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5191 | break; |
| 5192 | } |
| 5193 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5194 | { |
| 5195 | if (*option == '+') |
| 5196 | break; |
| 5197 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5198 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5199 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5200 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5201 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5202 | break; |
| 5203 | } |
| 5204 | if (LocaleCompare("posterize",option+1) == 0) |
| 5205 | { |
| 5206 | if (*option == '+') |
| 5207 | break; |
| 5208 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5209 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5210 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5211 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5212 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5213 | break; |
| 5214 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5215 | if (LocaleCompare("precision",option+1) == 0) |
| 5216 | { |
| 5217 | if (*option == '+') |
| 5218 | break; |
| 5219 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5220 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5221 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5222 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5223 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5224 | break; |
| 5225 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5226 | if (LocaleCompare("print",option+1) == 0) |
| 5227 | { |
| 5228 | if (*option == '+') |
| 5229 | break; |
| 5230 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5231 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5232 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5233 | break; |
| 5234 | } |
| 5235 | if (LocaleCompare("process",option+1) == 0) |
| 5236 | { |
| 5237 | if (*option == '+') |
| 5238 | break; |
| 5239 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5240 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5241 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5242 | break; |
| 5243 | } |
| 5244 | if (LocaleCompare("profile",option+1) == 0) |
| 5245 | { |
| 5246 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5247 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5248 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5249 | break; |
| 5250 | } |
| 5251 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5252 | } |
| 5253 | case 'q': |
| 5254 | { |
| 5255 | if (LocaleCompare("quality",option+1) == 0) |
| 5256 | { |
| 5257 | if (*option == '+') |
| 5258 | break; |
| 5259 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5260 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5261 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5262 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5263 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5264 | break; |
| 5265 | } |
| 5266 | if (LocaleCompare("quantize",option+1) == 0) |
| 5267 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5268 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5269 | colorspace; |
| 5270 | |
| 5271 | if (*option == '+') |
| 5272 | break; |
| 5273 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5274 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5275 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5276 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5277 | argv[i]); |
| 5278 | if (colorspace < 0) |
| 5279 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5280 | argv[i]); |
| 5281 | break; |
| 5282 | } |
| 5283 | if (LocaleCompare("quiet",option+1) == 0) |
| 5284 | break; |
| 5285 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5286 | } |
| 5287 | case 'r': |
| 5288 | { |
| 5289 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5290 | { |
| 5291 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5292 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5293 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5294 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5295 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5296 | break; |
| 5297 | } |
| 5298 | if (LocaleCompare("raise",option+1) == 0) |
| 5299 | { |
| 5300 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5301 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5302 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5303 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5304 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5305 | break; |
| 5306 | } |
| 5307 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5308 | { |
| 5309 | if (*option == '+') |
| 5310 | break; |
| 5311 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5312 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5313 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5314 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5315 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5316 | break; |
| 5317 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5318 | if (LocaleCompare("recolor",option+1) == 0) |
| 5319 | { |
| 5320 | if (*option == '+') |
| 5321 | break; |
| 5322 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5323 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5324 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5325 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5326 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5327 | break; |
| 5328 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5329 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5330 | { |
| 5331 | if (*option == '+') |
| 5332 | break; |
| 5333 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5334 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5335 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5336 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5337 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5338 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5339 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5340 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5341 | if (LocaleCompare("region",option+1) == 0) |
| 5342 | { |
| 5343 | if (*option == '+') |
| 5344 | break; |
| 5345 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5346 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5347 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5348 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5349 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5350 | break; |
| 5351 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5352 | if (LocaleCompare("remap",option+1) == 0) |
| 5353 | { |
| 5354 | if (*option == '+') |
| 5355 | break; |
| 5356 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5357 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5358 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5359 | break; |
| 5360 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5361 | if (LocaleCompare("render",option+1) == 0) |
| 5362 | break; |
| 5363 | if (LocaleCompare("repage",option+1) == 0) |
| 5364 | { |
| 5365 | if (*option == '+') |
| 5366 | break; |
| 5367 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5368 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5369 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5370 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5371 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5372 | break; |
| 5373 | } |
| 5374 | if (LocaleCompare("resample",option+1) == 0) |
| 5375 | { |
| 5376 | if (*option == '+') |
| 5377 | break; |
| 5378 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5379 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5380 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5381 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5382 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5383 | break; |
| 5384 | } |
| 5385 | if (LocaleCompare("resize",option+1) == 0) |
| 5386 | { |
| 5387 | if (*option == '+') |
| 5388 | break; |
| 5389 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5390 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5391 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5392 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5393 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5394 | break; |
| 5395 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5396 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5397 | { |
| 5398 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5399 | break; |
| 5400 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5401 | if (LocaleCompare("reverse",option+1) == 0) |
| 5402 | break; |
| 5403 | if (LocaleCompare("roll",option+1) == 0) |
| 5404 | { |
| 5405 | if (*option == '+') |
| 5406 | break; |
| 5407 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5408 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5409 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5410 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5411 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5412 | break; |
| 5413 | } |
| 5414 | if (LocaleCompare("rotate",option+1) == 0) |
| 5415 | { |
| 5416 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5417 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5418 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5419 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5420 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5421 | break; |
| 5422 | } |
| 5423 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5424 | } |
| 5425 | case 's': |
| 5426 | { |
| 5427 | if (LocaleCompare("sample",option+1) == 0) |
| 5428 | { |
| 5429 | if (*option == '+') |
| 5430 | break; |
| 5431 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5432 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5433 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5434 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5435 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5436 | break; |
| 5437 | } |
| 5438 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5439 | { |
| 5440 | if (*option == '+') |
| 5441 | break; |
| 5442 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5443 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5444 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5445 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5446 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5447 | break; |
| 5448 | } |
| 5449 | if (LocaleCompare("scale",option+1) == 0) |
| 5450 | { |
| 5451 | if (*option == '+') |
| 5452 | break; |
| 5453 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5454 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5455 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5456 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5457 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5458 | break; |
| 5459 | } |
| 5460 | if (LocaleCompare("scene",option+1) == 0) |
| 5461 | { |
| 5462 | if (*option == '+') |
| 5463 | break; |
| 5464 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5465 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5466 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5467 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5468 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5469 | break; |
| 5470 | } |
| 5471 | if (LocaleCompare("seed",option+1) == 0) |
| 5472 | { |
| 5473 | if (*option == '+') |
| 5474 | break; |
| 5475 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5476 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5477 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5478 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5479 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5480 | break; |
| 5481 | } |
| 5482 | if (LocaleCompare("segment",option+1) == 0) |
| 5483 | { |
| 5484 | if (*option == '+') |
| 5485 | break; |
| 5486 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5487 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5488 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5489 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5490 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5491 | break; |
| 5492 | } |
| 5493 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5494 | { |
| 5495 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5496 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5497 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5498 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5499 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5500 | break; |
| 5501 | } |
| 5502 | if (LocaleCompare("separate",option+1) == 0) |
| 5503 | break; |
| 5504 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5505 | { |
| 5506 | if (*option == '+') |
| 5507 | break; |
| 5508 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5509 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5510 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5511 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5512 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5513 | break; |
| 5514 | } |
| 5515 | if (LocaleCompare("set",option+1) == 0) |
| 5516 | { |
| 5517 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5518 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5519 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5520 | if (*option == '+') |
| 5521 | break; |
| 5522 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5523 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5524 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5525 | break; |
| 5526 | } |
| 5527 | if (LocaleCompare("shade",option+1) == 0) |
| 5528 | { |
| 5529 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5530 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5531 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5532 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5533 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5534 | break; |
| 5535 | } |
| 5536 | if (LocaleCompare("shadow",option+1) == 0) |
| 5537 | { |
| 5538 | if (*option == '+') |
| 5539 | break; |
| 5540 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5541 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5542 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5543 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5544 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5545 | break; |
| 5546 | } |
| 5547 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5548 | { |
| 5549 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5550 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5551 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5552 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5553 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5554 | break; |
| 5555 | } |
| 5556 | if (LocaleCompare("shave",option+1) == 0) |
| 5557 | { |
| 5558 | if (*option == '+') |
| 5559 | break; |
| 5560 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5561 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5562 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5563 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5564 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5565 | break; |
| 5566 | } |
| 5567 | if (LocaleCompare("shear",option+1) == 0) |
| 5568 | { |
| 5569 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5570 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5571 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5572 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5573 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5574 | break; |
| 5575 | } |
| 5576 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5577 | { |
| 5578 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5579 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5580 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5581 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5582 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5583 | break; |
| 5584 | } |
| 5585 | if (LocaleCompare("size",option+1) == 0) |
| 5586 | { |
| 5587 | if (*option == '+') |
| 5588 | break; |
| 5589 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5590 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5591 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5592 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5593 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5594 | break; |
| 5595 | } |
| 5596 | if (LocaleCompare("sketch",option+1) == 0) |
| 5597 | { |
| 5598 | if (*option == '+') |
| 5599 | break; |
| 5600 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5601 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5602 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5603 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5604 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5605 | break; |
| 5606 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5607 | if (LocaleCompare("smush",option+1) == 0) |
| 5608 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5609 | i++; |
| 5610 | if (i == (ssize_t) argc) |
| 5611 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5612 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5613 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5614 | i++; |
| 5615 | break; |
| 5616 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5617 | if (LocaleCompare("solarize",option+1) == 0) |
| 5618 | { |
| 5619 | if (*option == '+') |
| 5620 | break; |
| 5621 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5622 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5623 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5624 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5625 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5626 | break; |
| 5627 | } |
| 5628 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5629 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5630 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5631 | op; |
| 5632 | |
| 5633 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5634 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5635 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5636 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5637 | if (op < 0) |
| 5638 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5639 | argv[i]); |
| 5640 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5641 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5642 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5643 | break; |
| 5644 | } |
| 5645 | if (LocaleCompare("spread",option+1) == 0) |
| 5646 | { |
| 5647 | if (*option == '+') |
| 5648 | break; |
| 5649 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5650 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5651 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5652 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5653 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5654 | break; |
| 5655 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5656 | if (LocaleCompare("statistic",option+1) == 0) |
| 5657 | { |
| 5658 | ssize_t |
| 5659 | op; |
| 5660 | |
| 5661 | if (*option == '+') |
| 5662 | break; |
| 5663 | i++; |
| 5664 | if (i == (ssize_t) argc) |
| 5665 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5666 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5667 | if (op < 0) |
| 5668 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5669 | argv[i]); |
| 5670 | i++; |
| 5671 | if (i == (ssize_t) (argc-1)) |
| 5672 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5673 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5674 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5675 | break; |
| 5676 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5677 | if (LocaleCompare("stretch",option+1) == 0) |
| 5678 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5679 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5680 | stretch; |
| 5681 | |
| 5682 | if (*option == '+') |
| 5683 | break; |
| 5684 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5685 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5686 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5687 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5688 | if (stretch < 0) |
| 5689 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5690 | argv[i]); |
| 5691 | break; |
| 5692 | } |
| 5693 | if (LocaleCompare("strip",option+1) == 0) |
| 5694 | break; |
| 5695 | if (LocaleCompare("stroke",option+1) == 0) |
| 5696 | { |
| 5697 | if (*option == '+') |
| 5698 | break; |
| 5699 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5700 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5701 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5702 | break; |
| 5703 | } |
| 5704 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5705 | { |
| 5706 | if (*option == '+') |
| 5707 | break; |
| 5708 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5709 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5710 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5711 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5712 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5713 | break; |
| 5714 | } |
| 5715 | if (LocaleCompare("style",option+1) == 0) |
| 5716 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5717 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5718 | style; |
| 5719 | |
| 5720 | if (*option == '+') |
| 5721 | break; |
| 5722 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5723 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5724 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5725 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5726 | if (style < 0) |
| 5727 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5728 | argv[i]); |
| 5729 | break; |
| 5730 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5731 | if (LocaleCompare("swap",option+1) == 0) |
| 5732 | { |
| 5733 | if (*option == '+') |
| 5734 | break; |
| 5735 | i++; |
| 5736 | if (i == (ssize_t) (argc-1)) |
| 5737 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5738 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5739 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5740 | break; |
| 5741 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5742 | if (LocaleCompare("swirl",option+1) == 0) |
| 5743 | { |
| 5744 | if (*option == '+') |
| 5745 | break; |
| 5746 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5747 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5748 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5749 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5750 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5751 | break; |
| 5752 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5753 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5754 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5755 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5756 | } |
| 5757 | case 't': |
| 5758 | { |
| 5759 | if (LocaleCompare("taint",option+1) == 0) |
| 5760 | break; |
| 5761 | if (LocaleCompare("texture",option+1) == 0) |
| 5762 | { |
| 5763 | if (*option == '+') |
| 5764 | break; |
| 5765 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5766 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5767 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5768 | break; |
| 5769 | } |
| 5770 | if (LocaleCompare("tile",option+1) == 0) |
| 5771 | { |
| 5772 | if (*option == '+') |
| 5773 | break; |
| 5774 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5775 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5776 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5777 | break; |
| 5778 | } |
| 5779 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5780 | { |
| 5781 | if (*option == '+') |
| 5782 | break; |
| 5783 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5784 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5785 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5786 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5787 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5788 | break; |
| 5789 | } |
| 5790 | if (LocaleCompare("tint",option+1) == 0) |
| 5791 | { |
| 5792 | if (*option == '+') |
| 5793 | break; |
| 5794 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5795 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5796 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5797 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5798 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5799 | break; |
| 5800 | } |
| 5801 | if (LocaleCompare("transform",option+1) == 0) |
| 5802 | break; |
| 5803 | if (LocaleCompare("transpose",option+1) == 0) |
| 5804 | break; |
| 5805 | if (LocaleCompare("transverse",option+1) == 0) |
| 5806 | break; |
| 5807 | if (LocaleCompare("threshold",option+1) == 0) |
| 5808 | { |
| 5809 | if (*option == '+') |
| 5810 | break; |
| 5811 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5812 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5813 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5814 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5815 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5816 | break; |
| 5817 | } |
| 5818 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5819 | { |
| 5820 | if (*option == '+') |
| 5821 | break; |
| 5822 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5823 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5824 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5825 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5826 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5827 | break; |
| 5828 | } |
| 5829 | if (LocaleCompare("transparent",option+1) == 0) |
| 5830 | { |
| 5831 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5832 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5833 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5834 | break; |
| 5835 | } |
| 5836 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 5837 | { |
| 5838 | if (*option == '+') |
| 5839 | break; |
| 5840 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5841 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5842 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5843 | break; |
| 5844 | } |
| 5845 | if (LocaleCompare("treedepth",option+1) == 0) |
| 5846 | { |
| 5847 | if (*option == '+') |
| 5848 | break; |
| 5849 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5850 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5851 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5852 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5853 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5854 | break; |
| 5855 | } |
| 5856 | if (LocaleCompare("trim",option+1) == 0) |
| 5857 | break; |
| 5858 | if (LocaleCompare("type",option+1) == 0) |
| 5859 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5860 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5861 | type; |
| 5862 | |
| 5863 | if (*option == '+') |
| 5864 | break; |
| 5865 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5866 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5867 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5868 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5869 | if (type < 0) |
| 5870 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5871 | argv[i]); |
| 5872 | break; |
| 5873 | } |
| 5874 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5875 | } |
| 5876 | case 'u': |
| 5877 | { |
| 5878 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5879 | { |
| 5880 | if (*option == '+') |
| 5881 | break; |
| 5882 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5883 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5884 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5885 | break; |
| 5886 | } |
| 5887 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5888 | break; |
| 5889 | if (LocaleCompare("units",option+1) == 0) |
| 5890 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5891 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5892 | units; |
| 5893 | |
| 5894 | if (*option == '+') |
| 5895 | break; |
| 5896 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5897 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5898 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5899 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5900 | argv[i]); |
| 5901 | if (units < 0) |
| 5902 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5903 | argv[i]); |
| 5904 | break; |
| 5905 | } |
| 5906 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5907 | { |
| 5908 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5909 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5910 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5911 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5912 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5913 | break; |
| 5914 | } |
| 5915 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5916 | } |
| 5917 | case 'v': |
| 5918 | { |
| 5919 | if (LocaleCompare("verbose",option+1) == 0) |
| 5920 | { |
| 5921 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 5922 | break; |
| 5923 | } |
| 5924 | if ((LocaleCompare("version",option+1) == 0) || |
| 5925 | (LocaleCompare("-version",option+1) == 0)) |
| 5926 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 5927 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5928 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 5929 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 5930 | GetMagickCopyright()); |
| 5931 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 5932 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5933 | break; |
| 5934 | } |
| 5935 | if (LocaleCompare("view",option+1) == 0) |
| 5936 | { |
| 5937 | if (*option == '+') |
| 5938 | break; |
| 5939 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5940 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5941 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5942 | break; |
| 5943 | } |
| 5944 | if (LocaleCompare("vignette",option+1) == 0) |
| 5945 | { |
| 5946 | if (*option == '+') |
| 5947 | break; |
| 5948 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5949 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5950 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5951 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5952 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5953 | break; |
| 5954 | } |
| 5955 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 5956 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5957 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5958 | method; |
| 5959 | |
| 5960 | if (*option == '+') |
| 5961 | break; |
| 5962 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5963 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5964 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5965 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5966 | argv[i]); |
| 5967 | if (method < 0) |
| 5968 | ThrowMogrifyException(OptionError, |
| 5969 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 5970 | break; |
| 5971 | } |
| 5972 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5973 | } |
| 5974 | case 'w': |
| 5975 | { |
| 5976 | if (LocaleCompare("wave",option+1) == 0) |
| 5977 | { |
| 5978 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5979 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5980 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5981 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5982 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5983 | break; |
| 5984 | } |
| 5985 | if (LocaleCompare("weight",option+1) == 0) |
| 5986 | { |
| 5987 | if (*option == '+') |
| 5988 | break; |
| 5989 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5990 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5991 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5992 | break; |
| 5993 | } |
| 5994 | if (LocaleCompare("white-point",option+1) == 0) |
| 5995 | { |
| 5996 | if (*option == '+') |
| 5997 | break; |
| 5998 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5999 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6000 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6001 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6002 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6003 | break; |
| 6004 | } |
| 6005 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6006 | { |
| 6007 | if (*option == '+') |
| 6008 | break; |
| 6009 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6010 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6011 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6012 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6013 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6014 | break; |
| 6015 | } |
| 6016 | if (LocaleCompare("write",option+1) == 0) |
| 6017 | { |
| 6018 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6019 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6020 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6021 | break; |
| 6022 | } |
| 6023 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6024 | } |
| 6025 | case '?': |
| 6026 | break; |
| 6027 | default: |
| 6028 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6029 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6030 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 6031 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6032 | if (fire != MagickFalse) |
| 6033 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6034 | } |
| 6035 | if (k != 0) |
| 6036 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6037 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6038 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6039 | DestroyMogrify(); |
| 6040 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6041 | } |
| 6042 | |
| 6043 | /* |
| 6044 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6045 | % % |
| 6046 | % % |
| 6047 | % % |
| 6048 | + M o g r i f y I m a g e I n f o % |
| 6049 | % % |
| 6050 | % % |
| 6051 | % % |
| 6052 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6053 | % |
| 6054 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6055 | % prescribed by command line options. |
| 6056 | % |
| 6057 | % The format of the MogrifyImageInfo method is: |
| 6058 | % |
| 6059 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6060 | % const char **argv,ExceptionInfo *exception) |
| 6061 | % |
| 6062 | % A description of each parameter follows: |
| 6063 | % |
| 6064 | % o image_info: the image info.. |
| 6065 | % |
| 6066 | % o argc: Specifies a pointer to an integer describing the number of |
| 6067 | % elements in the argument vector. |
| 6068 | % |
| 6069 | % o argv: Specifies a pointer to a text array containing the command line |
| 6070 | % arguments. |
| 6071 | % |
| 6072 | % o exception: return any errors or warnings in this structure. |
| 6073 | % |
| 6074 | */ |
| 6075 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6076 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6077 | { |
| 6078 | const char |
| 6079 | *option; |
| 6080 | |
| 6081 | GeometryInfo |
| 6082 | geometry_info; |
| 6083 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6084 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6085 | count; |
| 6086 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6087 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6088 | i; |
| 6089 | |
| 6090 | /* |
| 6091 | Initialize method variables. |
| 6092 | */ |
| 6093 | assert(image_info != (ImageInfo *) NULL); |
| 6094 | assert(image_info->signature == MagickSignature); |
| 6095 | if (image_info->debug != MagickFalse) |
| 6096 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6097 | image_info->filename); |
| 6098 | if (argc < 0) |
| 6099 | return(MagickTrue); |
| 6100 | /* |
| 6101 | Set the image settings. |
| 6102 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6103 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6104 | { |
| 6105 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6106 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6107 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6108 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6109 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6110 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6111 | break; |
| 6112 | switch (*(option+1)) |
| 6113 | { |
| 6114 | case 'a': |
| 6115 | { |
| 6116 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6117 | { |
| 6118 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6119 | break; |
| 6120 | } |
| 6121 | if (LocaleCompare("antialias",option+1) == 0) |
| 6122 | { |
| 6123 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6124 | break; |
| 6125 | } |
| 6126 | if (LocaleCompare("attenuate",option+1) == 0) |
| 6127 | { |
| 6128 | if (*option == '+') |
| 6129 | { |
| 6130 | (void) DeleteImageOption(image_info,option+1); |
| 6131 | break; |
| 6132 | } |
| 6133 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6134 | break; |
| 6135 | } |
| 6136 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6137 | { |
| 6138 | if (*option == '+') |
| 6139 | (void) CloneString(&image_info->authenticate,(char *) NULL); |
| 6140 | else |
| 6141 | (void) CloneString(&image_info->authenticate,argv[i+1]); |
| 6142 | break; |
| 6143 | } |
| 6144 | break; |
| 6145 | } |
| 6146 | case 'b': |
| 6147 | { |
| 6148 | if (LocaleCompare("background",option+1) == 0) |
| 6149 | { |
| 6150 | if (*option == '+') |
| 6151 | { |
| 6152 | (void) DeleteImageOption(image_info,option+1); |
| 6153 | (void) QueryColorDatabase(BackgroundColor, |
| 6154 | &image_info->background_color,exception); |
| 6155 | break; |
| 6156 | } |
| 6157 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6158 | (void) QueryColorDatabase(argv[i+1],&image_info->background_color, |
| 6159 | exception); |
| 6160 | break; |
| 6161 | } |
| 6162 | if (LocaleCompare("bias",option+1) == 0) |
| 6163 | { |
| 6164 | if (*option == '+') |
| 6165 | { |
| 6166 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6167 | break; |
| 6168 | } |
| 6169 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6170 | break; |
| 6171 | } |
| 6172 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6173 | { |
| 6174 | if (*option == '+') |
| 6175 | { |
| 6176 | (void) SetImageOption(image_info,option+1,"false"); |
| 6177 | break; |
| 6178 | } |
| 6179 | (void) SetImageOption(image_info,option+1,"true"); |
| 6180 | break; |
| 6181 | } |
| 6182 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6183 | { |
| 6184 | if (*option == '+') |
| 6185 | { |
| 6186 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6187 | break; |
| 6188 | } |
| 6189 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6190 | break; |
| 6191 | } |
| 6192 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6193 | { |
| 6194 | if (*option == '+') |
| 6195 | { |
| 6196 | (void) DeleteImageOption(image_info,option+1); |
| 6197 | (void) QueryColorDatabase(BorderColor,&image_info->border_color, |
| 6198 | exception); |
| 6199 | break; |
| 6200 | } |
| 6201 | (void) QueryColorDatabase(argv[i+1],&image_info->border_color, |
| 6202 | exception); |
| 6203 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6204 | break; |
| 6205 | } |
| 6206 | if (LocaleCompare("box",option+1) == 0) |
| 6207 | { |
| 6208 | if (*option == '+') |
| 6209 | { |
| 6210 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6211 | break; |
| 6212 | } |
| 6213 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6214 | break; |
| 6215 | } |
| 6216 | break; |
| 6217 | } |
| 6218 | case 'c': |
| 6219 | { |
| 6220 | if (LocaleCompare("cache",option+1) == 0) |
| 6221 | { |
| 6222 | MagickSizeType |
| 6223 | limit; |
| 6224 | |
| 6225 | limit=MagickResourceInfinity; |
| 6226 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6227 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6228 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6229 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6230 | break; |
| 6231 | } |
| 6232 | if (LocaleCompare("caption",option+1) == 0) |
| 6233 | { |
| 6234 | if (*option == '+') |
| 6235 | { |
| 6236 | (void) DeleteImageOption(image_info,option+1); |
| 6237 | break; |
| 6238 | } |
| 6239 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6240 | break; |
| 6241 | } |
| 6242 | if (LocaleCompare("channel",option+1) == 0) |
| 6243 | { |
| 6244 | if (*option == '+') |
| 6245 | { |
| 6246 | image_info->channel=DefaultChannels; |
| 6247 | break; |
| 6248 | } |
| 6249 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6250 | break; |
| 6251 | } |
| 6252 | if (LocaleCompare("colors",option+1) == 0) |
| 6253 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6254 | image_info->colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6255 | break; |
| 6256 | } |
| 6257 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6258 | { |
| 6259 | if (*option == '+') |
| 6260 | { |
| 6261 | image_info->colorspace=UndefinedColorspace; |
| 6262 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6263 | break; |
| 6264 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6265 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6266 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6267 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6268 | break; |
| 6269 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6270 | if (LocaleCompare("comment",option+1) == 0) |
| 6271 | { |
| 6272 | if (*option == '+') |
| 6273 | { |
| 6274 | (void) DeleteImageOption(image_info,option+1); |
| 6275 | break; |
| 6276 | } |
| 6277 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6278 | break; |
| 6279 | } |
| 6280 | if (LocaleCompare("compose",option+1) == 0) |
| 6281 | { |
| 6282 | if (*option == '+') |
| 6283 | { |
| 6284 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6285 | break; |
| 6286 | } |
| 6287 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6288 | break; |
| 6289 | } |
| 6290 | if (LocaleCompare("compress",option+1) == 0) |
| 6291 | { |
| 6292 | if (*option == '+') |
| 6293 | { |
| 6294 | image_info->compression=UndefinedCompression; |
| 6295 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6296 | break; |
| 6297 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6298 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6299 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6300 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6301 | break; |
| 6302 | } |
| 6303 | break; |
| 6304 | } |
| 6305 | case 'd': |
| 6306 | { |
| 6307 | if (LocaleCompare("debug",option+1) == 0) |
| 6308 | { |
| 6309 | if (*option == '+') |
| 6310 | (void) SetLogEventMask("none"); |
| 6311 | else |
| 6312 | (void) SetLogEventMask(argv[i+1]); |
| 6313 | image_info->debug=IsEventLogging(); |
| 6314 | break; |
| 6315 | } |
| 6316 | if (LocaleCompare("define",option+1) == 0) |
| 6317 | { |
| 6318 | if (*option == '+') |
| 6319 | { |
| 6320 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6321 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6322 | else |
| 6323 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6324 | break; |
| 6325 | } |
| 6326 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6327 | { |
| 6328 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6329 | exception); |
| 6330 | break; |
| 6331 | } |
| 6332 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6333 | break; |
| 6334 | } |
| 6335 | if (LocaleCompare("delay",option+1) == 0) |
| 6336 | { |
| 6337 | if (*option == '+') |
| 6338 | { |
| 6339 | (void) SetImageOption(image_info,option+1,"0"); |
| 6340 | break; |
| 6341 | } |
| 6342 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6343 | break; |
| 6344 | } |
| 6345 | if (LocaleCompare("density",option+1) == 0) |
| 6346 | { |
| 6347 | /* |
| 6348 | Set image density. |
| 6349 | */ |
| 6350 | if (*option == '+') |
| 6351 | { |
| 6352 | if (image_info->density != (char *) NULL) |
| 6353 | image_info->density=DestroyString(image_info->density); |
| 6354 | (void) SetImageOption(image_info,option+1,"72"); |
| 6355 | break; |
| 6356 | } |
| 6357 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6358 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6359 | break; |
| 6360 | } |
| 6361 | if (LocaleCompare("depth",option+1) == 0) |
| 6362 | { |
| 6363 | if (*option == '+') |
| 6364 | { |
| 6365 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6366 | break; |
| 6367 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6368 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6369 | break; |
| 6370 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6371 | if (LocaleCompare("direction",option+1) == 0) |
| 6372 | { |
| 6373 | if (*option == '+') |
| 6374 | { |
| 6375 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6376 | break; |
| 6377 | } |
| 6378 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6379 | break; |
| 6380 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6381 | if (LocaleCompare("display",option+1) == 0) |
| 6382 | { |
| 6383 | if (*option == '+') |
| 6384 | { |
| 6385 | if (image_info->server_name != (char *) NULL) |
| 6386 | image_info->server_name=DestroyString( |
| 6387 | image_info->server_name); |
| 6388 | break; |
| 6389 | } |
| 6390 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6391 | break; |
| 6392 | } |
| 6393 | if (LocaleCompare("dispose",option+1) == 0) |
| 6394 | { |
| 6395 | if (*option == '+') |
| 6396 | { |
| 6397 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6398 | break; |
| 6399 | } |
| 6400 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6401 | break; |
| 6402 | } |
| 6403 | if (LocaleCompare("dither",option+1) == 0) |
| 6404 | { |
| 6405 | if (*option == '+') |
| 6406 | { |
| 6407 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6408 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6409 | break; |
| 6410 | } |
| 6411 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6412 | image_info->dither=MagickTrue; |
| 6413 | break; |
| 6414 | } |
| 6415 | break; |
| 6416 | } |
| 6417 | case 'e': |
| 6418 | { |
| 6419 | if (LocaleCompare("encoding",option+1) == 0) |
| 6420 | { |
| 6421 | if (*option == '+') |
| 6422 | { |
| 6423 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6424 | break; |
| 6425 | } |
| 6426 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6427 | break; |
| 6428 | } |
| 6429 | if (LocaleCompare("endian",option+1) == 0) |
| 6430 | { |
| 6431 | if (*option == '+') |
| 6432 | { |
| 6433 | image_info->endian=UndefinedEndian; |
| 6434 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6435 | break; |
| 6436 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6437 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6438 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6439 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6440 | break; |
| 6441 | } |
| 6442 | if (LocaleCompare("extract",option+1) == 0) |
| 6443 | { |
| 6444 | /* |
| 6445 | Set image extract geometry. |
| 6446 | */ |
| 6447 | if (*option == '+') |
| 6448 | { |
| 6449 | if (image_info->extract != (char *) NULL) |
| 6450 | image_info->extract=DestroyString(image_info->extract); |
| 6451 | break; |
| 6452 | } |
| 6453 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6454 | break; |
| 6455 | } |
| 6456 | break; |
| 6457 | } |
| 6458 | case 'f': |
| 6459 | { |
| 6460 | if (LocaleCompare("fill",option+1) == 0) |
| 6461 | { |
| 6462 | if (*option == '+') |
| 6463 | { |
| 6464 | (void) SetImageOption(image_info,option+1,"none"); |
| 6465 | break; |
| 6466 | } |
| 6467 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6468 | break; |
| 6469 | } |
| 6470 | if (LocaleCompare("filter",option+1) == 0) |
| 6471 | { |
| 6472 | if (*option == '+') |
| 6473 | { |
| 6474 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6475 | break; |
| 6476 | } |
| 6477 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6478 | break; |
| 6479 | } |
| 6480 | if (LocaleCompare("font",option+1) == 0) |
| 6481 | { |
| 6482 | if (*option == '+') |
| 6483 | { |
| 6484 | if (image_info->font != (char *) NULL) |
| 6485 | image_info->font=DestroyString(image_info->font); |
| 6486 | break; |
| 6487 | } |
| 6488 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6489 | break; |
| 6490 | } |
| 6491 | if (LocaleCompare("format",option+1) == 0) |
| 6492 | { |
| 6493 | register const char |
| 6494 | *q; |
| 6495 | |
| 6496 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6497 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6498 | image_info->ping=MagickFalse; |
| 6499 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6500 | break; |
| 6501 | } |
| 6502 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6503 | { |
| 6504 | if (*option == '+') |
| 6505 | { |
| 6506 | image_info->fuzz=0.0; |
| 6507 | (void) SetImageOption(image_info,option+1,"0"); |
| 6508 | break; |
| 6509 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6510 | image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6511 | 1.0); |
| 6512 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6513 | break; |
| 6514 | } |
| 6515 | break; |
| 6516 | } |
| 6517 | case 'g': |
| 6518 | { |
| 6519 | if (LocaleCompare("gravity",option+1) == 0) |
| 6520 | { |
| 6521 | if (*option == '+') |
| 6522 | { |
| 6523 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6524 | break; |
| 6525 | } |
| 6526 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6527 | break; |
| 6528 | } |
| 6529 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6530 | { |
| 6531 | if (*option == '+') |
| 6532 | { |
| 6533 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6534 | break; |
| 6535 | } |
| 6536 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6537 | break; |
| 6538 | } |
| 6539 | break; |
| 6540 | } |
| 6541 | case 'i': |
| 6542 | { |
| 6543 | if (LocaleCompare("intent",option+1) == 0) |
| 6544 | { |
| 6545 | if (*option == '+') |
| 6546 | { |
| 6547 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6548 | break; |
| 6549 | } |
| 6550 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6551 | break; |
| 6552 | } |
| 6553 | if (LocaleCompare("interlace",option+1) == 0) |
| 6554 | { |
| 6555 | if (*option == '+') |
| 6556 | { |
| 6557 | image_info->interlace=UndefinedInterlace; |
| 6558 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6559 | break; |
| 6560 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6561 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6562 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6563 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6564 | break; |
| 6565 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6566 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6567 | { |
| 6568 | if (*option == '+') |
| 6569 | { |
| 6570 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6571 | break; |
| 6572 | } |
| 6573 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6574 | break; |
| 6575 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6576 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6577 | { |
| 6578 | if (*option == '+') |
| 6579 | { |
| 6580 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6581 | break; |
| 6582 | } |
| 6583 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6584 | break; |
| 6585 | } |
| 6586 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6587 | { |
| 6588 | if (*option == '+') |
| 6589 | { |
| 6590 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6591 | break; |
| 6592 | } |
| 6593 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6594 | break; |
| 6595 | } |
| 6596 | break; |
| 6597 | } |
| 6598 | case 'k': |
| 6599 | { |
| 6600 | if (LocaleCompare("kerning",option+1) == 0) |
| 6601 | { |
| 6602 | if (*option == '+') |
| 6603 | { |
| 6604 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6605 | break; |
| 6606 | } |
| 6607 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6608 | break; |
| 6609 | } |
| 6610 | break; |
| 6611 | } |
| 6612 | case 'l': |
| 6613 | { |
| 6614 | if (LocaleCompare("label",option+1) == 0) |
| 6615 | { |
| 6616 | if (*option == '+') |
| 6617 | { |
| 6618 | (void) DeleteImageOption(image_info,option+1); |
| 6619 | break; |
| 6620 | } |
| 6621 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6622 | break; |
| 6623 | } |
| 6624 | if (LocaleCompare("limit",option+1) == 0) |
| 6625 | { |
| 6626 | MagickSizeType |
| 6627 | limit; |
| 6628 | |
| 6629 | ResourceType |
| 6630 | type; |
| 6631 | |
| 6632 | if (*option == '+') |
| 6633 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6634 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6635 | MagickFalse,argv[i+1]); |
| 6636 | limit=MagickResourceInfinity; |
| 6637 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6638 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6639 | (void) SetMagickResourceLimit(type,limit); |
| 6640 | break; |
| 6641 | } |
| 6642 | if (LocaleCompare("list",option+1) == 0) |
| 6643 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6644 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6645 | list; |
| 6646 | |
| 6647 | /* |
| 6648 | Display configuration list. |
| 6649 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6650 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6651 | switch (list) |
| 6652 | { |
| 6653 | case MagickCoderOptions: |
| 6654 | { |
| 6655 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6656 | break; |
| 6657 | } |
| 6658 | case MagickColorOptions: |
| 6659 | { |
| 6660 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6661 | break; |
| 6662 | } |
| 6663 | case MagickConfigureOptions: |
| 6664 | { |
| 6665 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6666 | break; |
| 6667 | } |
| 6668 | case MagickDelegateOptions: |
| 6669 | { |
| 6670 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6671 | break; |
| 6672 | } |
| 6673 | case MagickFontOptions: |
| 6674 | { |
| 6675 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6676 | break; |
| 6677 | } |
| 6678 | case MagickFormatOptions: |
| 6679 | { |
| 6680 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6681 | break; |
| 6682 | } |
| 6683 | case MagickLocaleOptions: |
| 6684 | { |
| 6685 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6686 | break; |
| 6687 | } |
| 6688 | case MagickLogOptions: |
| 6689 | { |
| 6690 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6691 | break; |
| 6692 | } |
| 6693 | case MagickMagicOptions: |
| 6694 | { |
| 6695 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6696 | break; |
| 6697 | } |
| 6698 | case MagickMimeOptions: |
| 6699 | { |
| 6700 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6701 | break; |
| 6702 | } |
| 6703 | case MagickModuleOptions: |
| 6704 | { |
| 6705 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6706 | break; |
| 6707 | } |
| 6708 | case MagickPolicyOptions: |
| 6709 | { |
| 6710 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6711 | break; |
| 6712 | } |
| 6713 | case MagickResourceOptions: |
| 6714 | { |
| 6715 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6716 | break; |
| 6717 | } |
| 6718 | case MagickThresholdOptions: |
| 6719 | { |
| 6720 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6721 | break; |
| 6722 | } |
| 6723 | default: |
| 6724 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6725 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6726 | exception); |
| 6727 | break; |
| 6728 | } |
| 6729 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6730 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6731 | } |
| 6732 | if (LocaleCompare("log",option+1) == 0) |
| 6733 | { |
| 6734 | if (*option == '+') |
| 6735 | break; |
| 6736 | (void) SetLogFormat(argv[i+1]); |
| 6737 | break; |
| 6738 | } |
| 6739 | if (LocaleCompare("loop",option+1) == 0) |
| 6740 | { |
| 6741 | if (*option == '+') |
| 6742 | { |
| 6743 | (void) SetImageOption(image_info,option+1,"0"); |
| 6744 | break; |
| 6745 | } |
| 6746 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6747 | break; |
| 6748 | } |
| 6749 | break; |
| 6750 | } |
| 6751 | case 'm': |
| 6752 | { |
| 6753 | if (LocaleCompare("matte",option+1) == 0) |
| 6754 | { |
| 6755 | if (*option == '+') |
| 6756 | { |
| 6757 | (void) SetImageOption(image_info,option+1,"false"); |
| 6758 | break; |
| 6759 | } |
| 6760 | (void) SetImageOption(image_info,option+1,"true"); |
| 6761 | break; |
| 6762 | } |
| 6763 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6764 | { |
| 6765 | if (*option == '+') |
| 6766 | { |
| 6767 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6768 | (void) QueryColorDatabase(MatteColor,&image_info->matte_color, |
| 6769 | exception); |
| 6770 | break; |
| 6771 | } |
| 6772 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6773 | (void) QueryColorDatabase(argv[i+1],&image_info->matte_color, |
| 6774 | exception); |
| 6775 | break; |
| 6776 | } |
| 6777 | if (LocaleCompare("monitor",option+1) == 0) |
| 6778 | { |
| 6779 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6780 | (void *) NULL); |
| 6781 | break; |
| 6782 | } |
| 6783 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6784 | { |
| 6785 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6786 | break; |
| 6787 | } |
| 6788 | break; |
| 6789 | } |
| 6790 | case 'o': |
| 6791 | { |
| 6792 | if (LocaleCompare("orient",option+1) == 0) |
| 6793 | { |
| 6794 | if (*option == '+') |
| 6795 | { |
| 6796 | image_info->orientation=UndefinedOrientation; |
| 6797 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6798 | break; |
| 6799 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6800 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6801 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6802 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6803 | break; |
| 6804 | } |
| 6805 | } |
| 6806 | case 'p': |
| 6807 | { |
| 6808 | if (LocaleCompare("page",option+1) == 0) |
| 6809 | { |
| 6810 | char |
| 6811 | *canonical_page, |
| 6812 | page[MaxTextExtent]; |
| 6813 | |
| 6814 | const char |
| 6815 | *image_option; |
| 6816 | |
| 6817 | MagickStatusType |
| 6818 | flags; |
| 6819 | |
| 6820 | RectangleInfo |
| 6821 | geometry; |
| 6822 | |
| 6823 | if (*option == '+') |
| 6824 | { |
| 6825 | (void) DeleteImageOption(image_info,option+1); |
| 6826 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6827 | break; |
| 6828 | } |
| 6829 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6830 | image_option=GetImageOption(image_info,"page"); |
| 6831 | if (image_option != (const char *) NULL) |
| 6832 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6833 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6834 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6835 | canonical_page=DestroyString(canonical_page); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6836 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6837 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6838 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6839 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6840 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6841 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6842 | (void) SetImageOption(image_info,option+1,page); |
| 6843 | (void) CloneString(&image_info->page,page); |
| 6844 | break; |
| 6845 | } |
| 6846 | if (LocaleCompare("pen",option+1) == 0) |
| 6847 | { |
| 6848 | if (*option == '+') |
| 6849 | { |
| 6850 | (void) SetImageOption(image_info,option+1,"none"); |
| 6851 | break; |
| 6852 | } |
| 6853 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6854 | break; |
| 6855 | } |
| 6856 | if (LocaleCompare("ping",option+1) == 0) |
| 6857 | { |
| 6858 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6859 | break; |
| 6860 | } |
| 6861 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6862 | { |
| 6863 | if (*option == '+') |
| 6864 | geometry_info.rho=0.0; |
| 6865 | else |
| 6866 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6867 | image_info->pointsize=geometry_info.rho; |
| 6868 | break; |
| 6869 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6870 | if (LocaleCompare("precision",option+1) == 0) |
| 6871 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6872 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6873 | break; |
| 6874 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6875 | if (LocaleCompare("preview",option+1) == 0) |
| 6876 | { |
| 6877 | /* |
| 6878 | Preview image. |
| 6879 | */ |
| 6880 | if (*option == '+') |
| 6881 | { |
| 6882 | image_info->preview_type=UndefinedPreview; |
| 6883 | break; |
| 6884 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6885 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6886 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6887 | break; |
| 6888 | } |
| 6889 | break; |
| 6890 | } |
| 6891 | case 'q': |
| 6892 | { |
| 6893 | if (LocaleCompare("quality",option+1) == 0) |
| 6894 | { |
| 6895 | /* |
| 6896 | Set image compression quality. |
| 6897 | */ |
| 6898 | if (*option == '+') |
| 6899 | { |
| 6900 | image_info->quality=UndefinedCompressionQuality; |
| 6901 | (void) SetImageOption(image_info,option+1,"0"); |
| 6902 | break; |
| 6903 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6904 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6905 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6906 | break; |
| 6907 | } |
| 6908 | if (LocaleCompare("quiet",option+1) == 0) |
| 6909 | { |
| 6910 | static WarningHandler |
| 6911 | warning_handler = (WarningHandler) NULL; |
| 6912 | |
| 6913 | if (*option == '+') |
| 6914 | { |
| 6915 | /* |
| 6916 | Restore error or warning messages. |
| 6917 | */ |
| 6918 | warning_handler=SetWarningHandler(warning_handler); |
| 6919 | break; |
| 6920 | } |
| 6921 | /* |
| 6922 | Suppress error or warning messages. |
| 6923 | */ |
| 6924 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6925 | break; |
| 6926 | } |
| 6927 | break; |
| 6928 | } |
| 6929 | case 'r': |
| 6930 | { |
| 6931 | if (LocaleCompare("red-primary",option+1) == 0) |
| 6932 | { |
| 6933 | if (*option == '+') |
| 6934 | { |
| 6935 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6936 | break; |
| 6937 | } |
| 6938 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6939 | break; |
| 6940 | } |
| 6941 | break; |
| 6942 | } |
| 6943 | case 's': |
| 6944 | { |
| 6945 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 6946 | { |
| 6947 | /* |
| 6948 | Set image sampling factor. |
| 6949 | */ |
| 6950 | if (*option == '+') |
| 6951 | { |
| 6952 | if (image_info->sampling_factor != (char *) NULL) |
| 6953 | image_info->sampling_factor=DestroyString( |
| 6954 | image_info->sampling_factor); |
| 6955 | break; |
| 6956 | } |
| 6957 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 6958 | break; |
| 6959 | } |
| 6960 | if (LocaleCompare("scene",option+1) == 0) |
| 6961 | { |
| 6962 | /* |
| 6963 | Set image scene. |
| 6964 | */ |
| 6965 | if (*option == '+') |
| 6966 | { |
| 6967 | image_info->scene=0; |
| 6968 | (void) SetImageOption(image_info,option+1,"0"); |
| 6969 | break; |
| 6970 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6971 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6972 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6973 | break; |
| 6974 | } |
| 6975 | if (LocaleCompare("seed",option+1) == 0) |
| 6976 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6977 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6978 | seed; |
| 6979 | |
| 6980 | if (*option == '+') |
| 6981 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6982 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6983 | SeedPseudoRandomGenerator(seed); |
| 6984 | break; |
| 6985 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6986 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6987 | SeedPseudoRandomGenerator(seed); |
| 6988 | break; |
| 6989 | } |
| 6990 | if (LocaleCompare("size",option+1) == 0) |
| 6991 | { |
| 6992 | if (*option == '+') |
| 6993 | { |
| 6994 | if (image_info->size != (char *) NULL) |
| 6995 | image_info->size=DestroyString(image_info->size); |
| 6996 | break; |
| 6997 | } |
| 6998 | (void) CloneString(&image_info->size,argv[i+1]); |
| 6999 | break; |
| 7000 | } |
| 7001 | if (LocaleCompare("stroke",option+1) == 0) |
| 7002 | { |
| 7003 | if (*option == '+') |
| 7004 | { |
| 7005 | (void) SetImageOption(image_info,option+1,"none"); |
| 7006 | break; |
| 7007 | } |
| 7008 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7009 | break; |
| 7010 | } |
| 7011 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7012 | { |
| 7013 | if (*option == '+') |
| 7014 | { |
| 7015 | (void) SetImageOption(image_info,option+1,"0"); |
| 7016 | break; |
| 7017 | } |
| 7018 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7019 | break; |
| 7020 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7021 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7022 | { |
| 7023 | if (*option == '+') |
| 7024 | { |
| 7025 | image_info->synchronize=MagickFalse; |
| 7026 | break; |
| 7027 | } |
| 7028 | image_info->synchronize=MagickTrue; |
| 7029 | break; |
| 7030 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7031 | break; |
| 7032 | } |
| 7033 | case 't': |
| 7034 | { |
| 7035 | if (LocaleCompare("taint",option+1) == 0) |
| 7036 | { |
| 7037 | if (*option == '+') |
| 7038 | { |
| 7039 | (void) SetImageOption(image_info,option+1,"false"); |
| 7040 | break; |
| 7041 | } |
| 7042 | (void) SetImageOption(image_info,option+1,"true"); |
| 7043 | break; |
| 7044 | } |
| 7045 | if (LocaleCompare("texture",option+1) == 0) |
| 7046 | { |
| 7047 | if (*option == '+') |
| 7048 | { |
| 7049 | if (image_info->texture != (char *) NULL) |
| 7050 | image_info->texture=DestroyString(image_info->texture); |
| 7051 | break; |
| 7052 | } |
| 7053 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7054 | break; |
| 7055 | } |
| 7056 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7057 | { |
| 7058 | if (*option == '+') |
| 7059 | { |
| 7060 | (void) SetImageOption(image_info,option+1,"0"); |
| 7061 | break; |
| 7062 | } |
| 7063 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7064 | break; |
| 7065 | } |
| 7066 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7067 | { |
| 7068 | if (*option == '+') |
| 7069 | { |
| 7070 | (void) QueryColorDatabase("none",&image_info->transparent_color, exception); |
| 7071 | (void) SetImageOption(image_info,option+1,"none"); |
| 7072 | break; |
| 7073 | } |
| 7074 | (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color, |
| 7075 | exception); |
| 7076 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7077 | break; |
| 7078 | } |
| 7079 | if (LocaleCompare("type",option+1) == 0) |
| 7080 | { |
| 7081 | if (*option == '+') |
| 7082 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7083 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7084 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7085 | break; |
| 7086 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7087 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7088 | MagickFalse,argv[i+1]); |
| 7089 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7090 | break; |
| 7091 | } |
| 7092 | break; |
| 7093 | } |
| 7094 | case 'u': |
| 7095 | { |
| 7096 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7097 | { |
| 7098 | if (*option == '+') |
| 7099 | { |
| 7100 | (void) DeleteImageOption(image_info,option+1); |
| 7101 | break; |
| 7102 | } |
| 7103 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7104 | break; |
| 7105 | } |
| 7106 | if (LocaleCompare("units",option+1) == 0) |
| 7107 | { |
| 7108 | if (*option == '+') |
| 7109 | { |
| 7110 | image_info->units=UndefinedResolution; |
| 7111 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7112 | break; |
| 7113 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7114 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7115 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7116 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7117 | break; |
| 7118 | } |
| 7119 | break; |
| 7120 | } |
| 7121 | case 'v': |
| 7122 | { |
| 7123 | if (LocaleCompare("verbose",option+1) == 0) |
| 7124 | { |
| 7125 | if (*option == '+') |
| 7126 | { |
| 7127 | image_info->verbose=MagickFalse; |
| 7128 | break; |
| 7129 | } |
| 7130 | image_info->verbose=MagickTrue; |
| 7131 | image_info->ping=MagickFalse; |
| 7132 | break; |
| 7133 | } |
| 7134 | if (LocaleCompare("view",option+1) == 0) |
| 7135 | { |
| 7136 | if (*option == '+') |
| 7137 | { |
| 7138 | if (image_info->view != (char *) NULL) |
| 7139 | image_info->view=DestroyString(image_info->view); |
| 7140 | break; |
| 7141 | } |
| 7142 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7143 | break; |
| 7144 | } |
| 7145 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7146 | { |
| 7147 | if (*option == '+') |
| 7148 | { |
| 7149 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7150 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7151 | break; |
| 7152 | } |
| 7153 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7154 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7155 | argv[i+1]); |
| 7156 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7157 | break; |
| 7158 | } |
| 7159 | break; |
| 7160 | } |
| 7161 | case 'w': |
| 7162 | { |
| 7163 | if (LocaleCompare("white-point",option+1) == 0) |
| 7164 | { |
| 7165 | if (*option == '+') |
| 7166 | { |
| 7167 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7168 | break; |
| 7169 | } |
| 7170 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7171 | break; |
| 7172 | } |
| 7173 | break; |
| 7174 | } |
| 7175 | default: |
| 7176 | break; |
| 7177 | } |
| 7178 | i+=count; |
| 7179 | } |
| 7180 | return(MagickTrue); |
| 7181 | } |
| 7182 | |
| 7183 | /* |
| 7184 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7185 | % % |
| 7186 | % % |
| 7187 | % % |
| 7188 | + M o g r i f y I m a g e L i s t % |
| 7189 | % % |
| 7190 | % % |
| 7191 | % % |
| 7192 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7193 | % |
| 7194 | % MogrifyImageList() applies any command line options that might affect the |
| 7195 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7196 | % |
| 7197 | % The format of the MogrifyImage method is: |
| 7198 | % |
| 7199 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7200 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7201 | % |
| 7202 | % A description of each parameter follows: |
| 7203 | % |
| 7204 | % o image_info: the image info.. |
| 7205 | % |
| 7206 | % o argc: Specifies a pointer to an integer describing the number of |
| 7207 | % elements in the argument vector. |
| 7208 | % |
| 7209 | % o argv: Specifies a pointer to a text array containing the command line |
| 7210 | % arguments. |
| 7211 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7212 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7213 | % |
| 7214 | % o exception: return any errors or warnings in this structure. |
| 7215 | % |
| 7216 | */ |
| 7217 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7218 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7219 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7220 | const char |
| 7221 | *option; |
| 7222 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7223 | ImageInfo |
| 7224 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7225 | |
| 7226 | MagickStatusType |
| 7227 | status; |
| 7228 | |
| 7229 | QuantizeInfo |
| 7230 | *quantize_info; |
| 7231 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7232 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7233 | i; |
| 7234 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7235 | ssize_t |
| 7236 | count, |
| 7237 | index; |
| 7238 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7239 | /* |
| 7240 | Apply options to the image list. |
| 7241 | */ |
| 7242 | assert(image_info != (ImageInfo *) NULL); |
| 7243 | assert(image_info->signature == MagickSignature); |
| 7244 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7245 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7246 | assert((*images)->signature == MagickSignature); |
| 7247 | if ((*images)->debug != MagickFalse) |
| 7248 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7249 | (*images)->filename); |
| 7250 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7251 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7252 | mogrify_info=CloneImageInfo(image_info); |
| 7253 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7254 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7255 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7256 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7257 | if (*images == (Image *) NULL) |
| 7258 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7259 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7260 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7261 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7262 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7263 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7264 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7265 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7266 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7267 | switch (*(option+1)) |
| 7268 | { |
| 7269 | case 'a': |
| 7270 | { |
| 7271 | if (LocaleCompare("affinity",option+1) == 0) |
| 7272 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7273 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7274 | if (*option == '+') |
| 7275 | { |
| 7276 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7277 | InheritException(exception,&(*images)->exception); |
| 7278 | break; |
| 7279 | } |
| 7280 | i++; |
| 7281 | break; |
| 7282 | } |
| 7283 | if (LocaleCompare("append",option+1) == 0) |
| 7284 | { |
| 7285 | Image |
| 7286 | *append_image; |
| 7287 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7288 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7289 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7290 | MagickFalse,exception); |
| 7291 | if (append_image == (Image *) NULL) |
| 7292 | { |
| 7293 | status=MagickFalse; |
| 7294 | break; |
| 7295 | } |
| 7296 | *images=DestroyImageList(*images); |
| 7297 | *images=append_image; |
| 7298 | break; |
| 7299 | } |
| 7300 | if (LocaleCompare("average",option+1) == 0) |
| 7301 | { |
| 7302 | Image |
| 7303 | *average_image; |
| 7304 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7305 | /* |
| 7306 | Average an image sequence (deprecated). |
| 7307 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7308 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7309 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7310 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7311 | if (average_image == (Image *) NULL) |
| 7312 | { |
| 7313 | status=MagickFalse; |
| 7314 | break; |
| 7315 | } |
| 7316 | *images=DestroyImageList(*images); |
| 7317 | *images=average_image; |
| 7318 | break; |
| 7319 | } |
| 7320 | break; |
| 7321 | } |
| 7322 | case 'c': |
| 7323 | { |
| 7324 | if (LocaleCompare("channel",option+1) == 0) |
| 7325 | { |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7326 | ChannelType |
| 7327 | channel; |
| 7328 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7329 | if (*option == '+') |
| 7330 | { |
| 7331 | channel=DefaultChannels; |
| 7332 | break; |
| 7333 | } |
| 7334 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 7335 | SetPixelChannelMap(*images,channel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7336 | break; |
| 7337 | } |
| 7338 | if (LocaleCompare("clut",option+1) == 0) |
| 7339 | { |
| 7340 | Image |
| 7341 | *clut_image, |
| 7342 | *image; |
| 7343 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7344 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7345 | image=RemoveFirstImageFromList(images); |
| 7346 | clut_image=RemoveFirstImageFromList(images); |
| 7347 | if (clut_image == (Image *) NULL) |
| 7348 | { |
| 7349 | status=MagickFalse; |
| 7350 | break; |
| 7351 | } |
cristy | f89cb1d | 2011-07-07 01:24:37 +0000 | [diff] [blame] | 7352 | (void) ClutImage(image,clut_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7353 | clut_image=DestroyImage(clut_image); |
| 7354 | InheritException(exception,&image->exception); |
| 7355 | *images=DestroyImageList(*images); |
| 7356 | *images=image; |
| 7357 | break; |
| 7358 | } |
| 7359 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7360 | { |
| 7361 | Image |
| 7362 | *coalesce_image; |
| 7363 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7364 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7365 | coalesce_image=CoalesceImages(*images,exception); |
| 7366 | if (coalesce_image == (Image *) NULL) |
| 7367 | { |
| 7368 | status=MagickFalse; |
| 7369 | break; |
| 7370 | } |
| 7371 | *images=DestroyImageList(*images); |
| 7372 | *images=coalesce_image; |
| 7373 | break; |
| 7374 | } |
| 7375 | if (LocaleCompare("combine",option+1) == 0) |
| 7376 | { |
| 7377 | Image |
| 7378 | *combine_image; |
| 7379 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7380 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 7381 | combine_image=CombineImages(*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7382 | if (combine_image == (Image *) NULL) |
| 7383 | { |
| 7384 | status=MagickFalse; |
| 7385 | break; |
| 7386 | } |
| 7387 | *images=DestroyImageList(*images); |
| 7388 | *images=combine_image; |
| 7389 | break; |
| 7390 | } |
| 7391 | if (LocaleCompare("composite",option+1) == 0) |
| 7392 | { |
| 7393 | Image |
| 7394 | *mask_image, |
| 7395 | *composite_image, |
| 7396 | *image; |
| 7397 | |
| 7398 | RectangleInfo |
| 7399 | geometry; |
| 7400 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7401 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7402 | image=RemoveFirstImageFromList(images); |
| 7403 | composite_image=RemoveFirstImageFromList(images); |
| 7404 | if (composite_image == (Image *) NULL) |
| 7405 | { |
| 7406 | status=MagickFalse; |
| 7407 | break; |
| 7408 | } |
| 7409 | (void) TransformImage(&composite_image,(char *) NULL, |
| 7410 | composite_image->geometry); |
| 7411 | SetGeometry(composite_image,&geometry); |
| 7412 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7413 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7414 | &geometry); |
| 7415 | mask_image=RemoveFirstImageFromList(images); |
| 7416 | if (mask_image != (Image *) NULL) |
| 7417 | { |
| 7418 | if ((image->compose == DisplaceCompositeOp) || |
| 7419 | (image->compose == DistortCompositeOp)) |
| 7420 | { |
| 7421 | /* |
| 7422 | Merge Y displacement into X displacement image. |
| 7423 | */ |
| 7424 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
| 7425 | mask_image,0,0); |
| 7426 | mask_image=DestroyImage(mask_image); |
| 7427 | } |
| 7428 | else |
| 7429 | { |
| 7430 | /* |
| 7431 | Set a blending mask for the composition. |
| 7432 | */ |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7433 | /* POSIBLE ERROR; what if image->mask already set */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7434 | image->mask=mask_image; |
| 7435 | (void) NegateImage(image->mask,MagickFalse); |
| 7436 | } |
| 7437 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7438 | (void) CompositeImage(image,image->compose,composite_image, |
| 7439 | geometry.x,geometry.y); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7440 | if (mask_image != (Image *) NULL) |
| 7441 | mask_image=image->mask=DestroyImage(image->mask); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7442 | composite_image=DestroyImage(composite_image); |
| 7443 | InheritException(exception,&image->exception); |
| 7444 | *images=DestroyImageList(*images); |
| 7445 | *images=image; |
| 7446 | break; |
| 7447 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7448 | #if 0 |
| 7449 | This has been merged completely into MogrifyImage() |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7450 | if (LocaleCompare("crop",option+1) == 0) |
| 7451 | { |
| 7452 | MagickStatusType |
| 7453 | flags; |
| 7454 | |
| 7455 | RectangleInfo |
| 7456 | geometry; |
| 7457 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7458 | /* |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7459 | Crop Image. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7460 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7461 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7462 | flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception); |
| 7463 | if (((geometry.width == 0) && (geometry.height == 0)) || |
| 7464 | ((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 7465 | break; |
| 7466 | (void) TransformImages(images,argv[i+1],(char *) NULL); |
| 7467 | InheritException(exception,&(*images)->exception); |
| 7468 | break; |
| 7469 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7470 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7471 | break; |
| 7472 | } |
| 7473 | case 'd': |
| 7474 | { |
| 7475 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7476 | { |
| 7477 | Image |
| 7478 | *deconstruct_image; |
| 7479 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7480 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7481 | deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer, |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 7482 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7483 | if (deconstruct_image == (Image *) NULL) |
| 7484 | { |
| 7485 | status=MagickFalse; |
| 7486 | break; |
| 7487 | } |
| 7488 | *images=DestroyImageList(*images); |
| 7489 | *images=deconstruct_image; |
| 7490 | break; |
| 7491 | } |
| 7492 | if (LocaleCompare("delete",option+1) == 0) |
| 7493 | { |
| 7494 | if (*option == '+') |
| 7495 | DeleteImages(images,"-1",exception); |
| 7496 | else |
| 7497 | DeleteImages(images,argv[i+1],exception); |
| 7498 | break; |
| 7499 | } |
| 7500 | if (LocaleCompare("dither",option+1) == 0) |
| 7501 | { |
| 7502 | if (*option == '+') |
| 7503 | { |
| 7504 | quantize_info->dither=MagickFalse; |
| 7505 | break; |
| 7506 | } |
| 7507 | quantize_info->dither=MagickTrue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7508 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7509 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7510 | break; |
| 7511 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7512 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7513 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7514 | Image |
| 7515 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7516 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7517 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7518 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7519 | else |
| 7520 | { |
| 7521 | const char |
| 7522 | *p; |
| 7523 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7524 | size_t |
| 7525 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7526 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7527 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7528 | p=strchr(argv[i+1],','); |
| 7529 | if (p == (const char *) NULL) |
| 7530 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7531 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7532 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7533 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7534 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7535 | } |
| 7536 | AppendImageToList(images, duplicate_images); |
| 7537 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7538 | break; |
| 7539 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7540 | break; |
| 7541 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7542 | case 'e': |
| 7543 | { |
| 7544 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7545 | { |
| 7546 | Image |
| 7547 | *evaluate_image; |
| 7548 | |
| 7549 | MagickEvaluateOperator |
| 7550 | op; |
| 7551 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7552 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7553 | op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions, |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7554 | MagickFalse,argv[i+1]); |
| 7555 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7556 | if (evaluate_image == (Image *) NULL) |
| 7557 | { |
| 7558 | status=MagickFalse; |
| 7559 | break; |
| 7560 | } |
| 7561 | *images=DestroyImageList(*images); |
| 7562 | *images=evaluate_image; |
| 7563 | break; |
| 7564 | } |
| 7565 | break; |
| 7566 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7567 | case 'f': |
| 7568 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7569 | if (LocaleCompare("fft",option+1) == 0) |
| 7570 | { |
| 7571 | Image |
| 7572 | *fourier_image; |
| 7573 | |
| 7574 | /* |
| 7575 | Implements the discrete Fourier transform (DFT). |
| 7576 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7577 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7578 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7579 | MagickTrue : MagickFalse,exception); |
| 7580 | if (fourier_image == (Image *) NULL) |
| 7581 | break; |
| 7582 | *images=DestroyImage(*images); |
| 7583 | *images=fourier_image; |
| 7584 | break; |
| 7585 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7586 | if (LocaleCompare("flatten",option+1) == 0) |
| 7587 | { |
| 7588 | Image |
| 7589 | *flatten_image; |
| 7590 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7591 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7592 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7593 | if (flatten_image == (Image *) NULL) |
| 7594 | break; |
| 7595 | *images=DestroyImageList(*images); |
| 7596 | *images=flatten_image; |
| 7597 | break; |
| 7598 | } |
| 7599 | if (LocaleCompare("fx",option+1) == 0) |
| 7600 | { |
| 7601 | Image |
| 7602 | *fx_image; |
| 7603 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7604 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 7605 | fx_image=FxImage(*images,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7606 | if (fx_image == (Image *) NULL) |
| 7607 | { |
| 7608 | status=MagickFalse; |
| 7609 | break; |
| 7610 | } |
| 7611 | *images=DestroyImageList(*images); |
| 7612 | *images=fx_image; |
| 7613 | break; |
| 7614 | } |
| 7615 | break; |
| 7616 | } |
| 7617 | case 'h': |
| 7618 | { |
| 7619 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7620 | { |
| 7621 | Image |
| 7622 | *hald_image, |
| 7623 | *image; |
| 7624 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7625 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7626 | image=RemoveFirstImageFromList(images); |
| 7627 | hald_image=RemoveFirstImageFromList(images); |
| 7628 | if (hald_image == (Image *) NULL) |
| 7629 | { |
| 7630 | status=MagickFalse; |
| 7631 | break; |
| 7632 | } |
cristy | f89cb1d | 2011-07-07 01:24:37 +0000 | [diff] [blame] | 7633 | (void) HaldClutImage(image,hald_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7634 | hald_image=DestroyImage(hald_image); |
| 7635 | InheritException(exception,&image->exception); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7636 | if (*images != (Image *) NULL) |
| 7637 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7638 | *images=image; |
| 7639 | break; |
| 7640 | } |
| 7641 | break; |
| 7642 | } |
| 7643 | case 'i': |
| 7644 | { |
| 7645 | if (LocaleCompare("ift",option+1) == 0) |
| 7646 | { |
| 7647 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7648 | *fourier_image, |
| 7649 | *magnitude_image, |
| 7650 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7651 | |
| 7652 | /* |
| 7653 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7654 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7655 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7656 | magnitude_image=RemoveFirstImageFromList(images); |
| 7657 | phase_image=RemoveFirstImageFromList(images); |
| 7658 | if (phase_image == (Image *) NULL) |
| 7659 | { |
| 7660 | status=MagickFalse; |
| 7661 | break; |
| 7662 | } |
| 7663 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7664 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7665 | if (fourier_image == (Image *) NULL) |
| 7666 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7667 | if (*images != (Image *) NULL) |
| 7668 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7669 | *images=fourier_image; |
| 7670 | break; |
| 7671 | } |
| 7672 | if (LocaleCompare("insert",option+1) == 0) |
| 7673 | { |
| 7674 | Image |
| 7675 | *p, |
| 7676 | *q; |
| 7677 | |
| 7678 | index=0; |
| 7679 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7680 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7681 | p=RemoveLastImageFromList(images); |
| 7682 | if (p == (Image *) NULL) |
| 7683 | { |
| 7684 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7685 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7686 | status=MagickFalse; |
| 7687 | break; |
| 7688 | } |
| 7689 | q=p; |
| 7690 | if (index == 0) |
| 7691 | PrependImageToList(images,q); |
| 7692 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7693 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7694 | AppendImageToList(images,q); |
| 7695 | else |
| 7696 | { |
| 7697 | q=GetImageFromList(*images,index-1); |
| 7698 | if (q == (Image *) NULL) |
| 7699 | { |
| 7700 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7701 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7702 | status=MagickFalse; |
| 7703 | break; |
| 7704 | } |
| 7705 | InsertImageInList(&q,p); |
| 7706 | } |
| 7707 | *images=GetFirstImageInList(q); |
| 7708 | break; |
| 7709 | } |
| 7710 | break; |
| 7711 | } |
| 7712 | case 'l': |
| 7713 | { |
| 7714 | if (LocaleCompare("layers",option+1) == 0) |
| 7715 | { |
| 7716 | Image |
| 7717 | *layers; |
| 7718 | |
| 7719 | ImageLayerMethod |
| 7720 | method; |
| 7721 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7722 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7723 | layers=(Image *) NULL; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7724 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7725 | MagickFalse,argv[i+1]); |
| 7726 | switch (method) |
| 7727 | { |
| 7728 | case CoalesceLayer: |
| 7729 | { |
| 7730 | layers=CoalesceImages(*images,exception); |
| 7731 | break; |
| 7732 | } |
| 7733 | case CompareAnyLayer: |
| 7734 | case CompareClearLayer: |
| 7735 | case CompareOverlayLayer: |
| 7736 | default: |
| 7737 | { |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7738 | layers=CompareImagesLayers(*images,method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7739 | break; |
| 7740 | } |
| 7741 | case MergeLayer: |
| 7742 | case FlattenLayer: |
| 7743 | case MosaicLayer: |
| 7744 | case TrimBoundsLayer: |
| 7745 | { |
| 7746 | layers=MergeImageLayers(*images,method,exception); |
| 7747 | break; |
| 7748 | } |
| 7749 | case DisposeLayer: |
| 7750 | { |
| 7751 | layers=DisposeImages(*images,exception); |
| 7752 | break; |
| 7753 | } |
| 7754 | case OptimizeImageLayer: |
| 7755 | { |
| 7756 | layers=OptimizeImageLayers(*images,exception); |
| 7757 | break; |
| 7758 | } |
| 7759 | case OptimizePlusLayer: |
| 7760 | { |
| 7761 | layers=OptimizePlusImageLayers(*images,exception); |
| 7762 | break; |
| 7763 | } |
| 7764 | case OptimizeTransLayer: |
| 7765 | { |
| 7766 | OptimizeImageTransparency(*images,exception); |
| 7767 | break; |
| 7768 | } |
| 7769 | case RemoveDupsLayer: |
| 7770 | { |
| 7771 | RemoveDuplicateLayers(images,exception); |
| 7772 | break; |
| 7773 | } |
| 7774 | case RemoveZeroLayer: |
| 7775 | { |
| 7776 | RemoveZeroDelayLayers(images,exception); |
| 7777 | break; |
| 7778 | } |
| 7779 | case OptimizeLayer: |
| 7780 | { |
| 7781 | /* |
| 7782 | General Purpose, GIF Animation Optimizer. |
| 7783 | */ |
| 7784 | layers=CoalesceImages(*images,exception); |
| 7785 | if (layers == (Image *) NULL) |
| 7786 | { |
| 7787 | status=MagickFalse; |
| 7788 | break; |
| 7789 | } |
| 7790 | InheritException(exception,&layers->exception); |
| 7791 | *images=DestroyImageList(*images); |
| 7792 | *images=layers; |
| 7793 | layers=OptimizeImageLayers(*images,exception); |
| 7794 | if (layers == (Image *) NULL) |
| 7795 | { |
| 7796 | status=MagickFalse; |
| 7797 | break; |
| 7798 | } |
| 7799 | InheritException(exception,&layers->exception); |
| 7800 | *images=DestroyImageList(*images); |
| 7801 | *images=layers; |
| 7802 | layers=(Image *) NULL; |
| 7803 | OptimizeImageTransparency(*images,exception); |
| 7804 | InheritException(exception,&(*images)->exception); |
| 7805 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7806 | break; |
| 7807 | } |
| 7808 | case CompositeLayer: |
| 7809 | { |
| 7810 | CompositeOperator |
| 7811 | compose; |
| 7812 | |
| 7813 | Image |
| 7814 | *source; |
| 7815 | |
| 7816 | RectangleInfo |
| 7817 | geometry; |
| 7818 | |
| 7819 | /* |
| 7820 | Split image sequence at the first 'NULL:' image. |
| 7821 | */ |
| 7822 | source=(*images); |
| 7823 | while (source != (Image *) NULL) |
| 7824 | { |
| 7825 | source=GetNextImageInList(source); |
| 7826 | if ((source != (Image *) NULL) && |
| 7827 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7828 | break; |
| 7829 | } |
| 7830 | if (source != (Image *) NULL) |
| 7831 | { |
| 7832 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7833 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7834 | source=(Image *) NULL; |
| 7835 | else |
| 7836 | { |
| 7837 | /* |
| 7838 | Separate the two lists, junk the null: image. |
| 7839 | */ |
| 7840 | source=SplitImageList(source->previous); |
| 7841 | DeleteImageFromList(&source); |
| 7842 | } |
| 7843 | } |
| 7844 | if (source == (Image *) NULL) |
| 7845 | { |
| 7846 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7847 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7848 | status=MagickFalse; |
| 7849 | break; |
| 7850 | } |
| 7851 | /* |
| 7852 | Adjust offset with gravity and virtual canvas. |
| 7853 | */ |
| 7854 | SetGeometry(*images,&geometry); |
| 7855 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7856 | geometry.width=source->page.width != 0 ? |
| 7857 | source->page.width : source->columns; |
| 7858 | geometry.height=source->page.height != 0 ? |
| 7859 | source->page.height : source->rows; |
| 7860 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7861 | (*images)->page.width : (*images)->columns, |
| 7862 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7863 | (*images)->rows,(*images)->gravity,&geometry); |
| 7864 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7865 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7866 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7867 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7868 | MagickComposeOptions,MagickFalse,option); |
| 7869 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7870 | exception); |
| 7871 | source=DestroyImageList(source); |
| 7872 | break; |
| 7873 | } |
| 7874 | } |
| 7875 | if (layers == (Image *) NULL) |
| 7876 | break; |
| 7877 | InheritException(exception,&layers->exception); |
| 7878 | *images=DestroyImageList(*images); |
| 7879 | *images=layers; |
| 7880 | break; |
| 7881 | } |
| 7882 | break; |
| 7883 | } |
| 7884 | case 'm': |
| 7885 | { |
| 7886 | if (LocaleCompare("map",option+1) == 0) |
| 7887 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7888 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7889 | if (*option == '+') |
| 7890 | { |
| 7891 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7892 | InheritException(exception,&(*images)->exception); |
| 7893 | break; |
| 7894 | } |
| 7895 | i++; |
| 7896 | break; |
| 7897 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7898 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7899 | { |
| 7900 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7901 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7902 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7903 | /* |
| 7904 | Maximum image sequence (deprecated). |
| 7905 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7906 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7907 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7908 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7909 | { |
| 7910 | status=MagickFalse; |
| 7911 | break; |
| 7912 | } |
| 7913 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7914 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7915 | break; |
| 7916 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7917 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7918 | { |
| 7919 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7920 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7921 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7922 | /* |
| 7923 | Minimum image sequence (deprecated). |
| 7924 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7925 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7926 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7927 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7928 | { |
| 7929 | status=MagickFalse; |
| 7930 | break; |
| 7931 | } |
| 7932 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7933 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7934 | break; |
| 7935 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7936 | if (LocaleCompare("morph",option+1) == 0) |
| 7937 | { |
| 7938 | Image |
| 7939 | *morph_image; |
| 7940 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7941 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7942 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7943 | exception); |
| 7944 | if (morph_image == (Image *) NULL) |
| 7945 | { |
| 7946 | status=MagickFalse; |
| 7947 | break; |
| 7948 | } |
| 7949 | *images=DestroyImageList(*images); |
| 7950 | *images=morph_image; |
| 7951 | break; |
| 7952 | } |
| 7953 | if (LocaleCompare("mosaic",option+1) == 0) |
| 7954 | { |
| 7955 | Image |
| 7956 | *mosaic_image; |
| 7957 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7958 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7959 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 7960 | if (mosaic_image == (Image *) NULL) |
| 7961 | { |
| 7962 | status=MagickFalse; |
| 7963 | break; |
| 7964 | } |
| 7965 | *images=DestroyImageList(*images); |
| 7966 | *images=mosaic_image; |
| 7967 | break; |
| 7968 | } |
| 7969 | break; |
| 7970 | } |
| 7971 | case 'p': |
| 7972 | { |
| 7973 | if (LocaleCompare("print",option+1) == 0) |
| 7974 | { |
| 7975 | char |
| 7976 | *string; |
| 7977 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7978 | (void) SyncImagesSettings(mogrify_info,*images); |
| 7979 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7980 | if (string == (char *) NULL) |
| 7981 | break; |
| 7982 | InheritException(exception,&(*images)->exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 7983 | (void) FormatLocaleFile(stdout,"%s",string); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7984 | string=DestroyString(string); |
| 7985 | } |
| 7986 | if (LocaleCompare("process",option+1) == 0) |
| 7987 | { |
| 7988 | char |
| 7989 | **arguments; |
| 7990 | |
| 7991 | int |
| 7992 | j, |
| 7993 | number_arguments; |
| 7994 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7995 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7996 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 7997 | if (arguments == (char **) NULL) |
| 7998 | break; |
| 7999 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 8000 | { |
| 8001 | char |
| 8002 | breaker, |
| 8003 | quote, |
| 8004 | *token; |
| 8005 | |
| 8006 | const char |
| 8007 | *arguments; |
| 8008 | |
| 8009 | int |
| 8010 | next, |
| 8011 | status; |
| 8012 | |
| 8013 | size_t |
| 8014 | length; |
| 8015 | |
| 8016 | TokenInfo |
| 8017 | *token_info; |
| 8018 | |
| 8019 | /* |
| 8020 | Support old style syntax, filter="-option arg". |
| 8021 | */ |
| 8022 | length=strlen(argv[i+1]); |
| 8023 | token=(char *) NULL; |
cristy | 37e0b38 | 2011-06-07 13:31:21 +0000 | [diff] [blame] | 8024 | if (~length >= (MaxTextExtent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8025 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8026 | sizeof(*token)); |
| 8027 | if (token == (char *) NULL) |
| 8028 | break; |
| 8029 | next=0; |
| 8030 | arguments=argv[i+1]; |
| 8031 | token_info=AcquireTokenInfo(); |
| 8032 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8033 | "\"",'\0',&breaker,&next,"e); |
| 8034 | token_info=DestroyTokenInfo(token_info); |
| 8035 | if (status == 0) |
| 8036 | { |
| 8037 | const char |
| 8038 | *argv; |
| 8039 | |
| 8040 | argv=(&(arguments[next])); |
| 8041 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8042 | exception); |
| 8043 | } |
| 8044 | token=DestroyString(token); |
| 8045 | break; |
| 8046 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8047 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8048 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8049 | number_arguments-2,(const char **) arguments+2,exception); |
| 8050 | for (j=0; j < number_arguments; j++) |
| 8051 | arguments[j]=DestroyString(arguments[j]); |
| 8052 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8053 | break; |
| 8054 | } |
| 8055 | break; |
| 8056 | } |
| 8057 | case 'r': |
| 8058 | { |
| 8059 | if (LocaleCompare("reverse",option+1) == 0) |
| 8060 | { |
| 8061 | ReverseImageList(images); |
| 8062 | InheritException(exception,&(*images)->exception); |
| 8063 | break; |
| 8064 | } |
| 8065 | break; |
| 8066 | } |
| 8067 | case 's': |
| 8068 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8069 | if (LocaleCompare("smush",option+1) == 0) |
| 8070 | { |
| 8071 | Image |
| 8072 | *smush_image; |
| 8073 | |
| 8074 | ssize_t |
| 8075 | offset; |
| 8076 | |
| 8077 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8078 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8079 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8080 | MagickFalse,offset,exception); |
| 8081 | if (smush_image == (Image *) NULL) |
| 8082 | { |
| 8083 | status=MagickFalse; |
| 8084 | break; |
| 8085 | } |
| 8086 | *images=DestroyImageList(*images); |
| 8087 | *images=smush_image; |
| 8088 | break; |
| 8089 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8090 | if (LocaleCompare("swap",option+1) == 0) |
| 8091 | { |
| 8092 | Image |
| 8093 | *p, |
| 8094 | *q, |
| 8095 | *swap; |
| 8096 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8097 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8098 | swap_index; |
| 8099 | |
| 8100 | index=(-1); |
| 8101 | swap_index=(-2); |
| 8102 | if (*option != '+') |
| 8103 | { |
| 8104 | GeometryInfo |
| 8105 | geometry_info; |
| 8106 | |
| 8107 | MagickStatusType |
| 8108 | flags; |
| 8109 | |
| 8110 | swap_index=(-1); |
| 8111 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8112 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8113 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8114 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8115 | } |
| 8116 | p=GetImageFromList(*images,index); |
| 8117 | q=GetImageFromList(*images,swap_index); |
| 8118 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8119 | { |
| 8120 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8121 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8122 | status=MagickFalse; |
| 8123 | break; |
| 8124 | } |
| 8125 | if (p == q) |
| 8126 | break; |
| 8127 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8128 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8129 | ReplaceImageInList(&q,swap); |
| 8130 | *images=GetFirstImageInList(q); |
| 8131 | break; |
| 8132 | } |
| 8133 | break; |
| 8134 | } |
| 8135 | case 'w': |
| 8136 | { |
| 8137 | if (LocaleCompare("write",option+1) == 0) |
| 8138 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8139 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8140 | key[MaxTextExtent]; |
| 8141 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8142 | Image |
| 8143 | *write_images; |
| 8144 | |
| 8145 | ImageInfo |
| 8146 | *write_info; |
| 8147 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8148 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8149 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8150 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8151 | write_images=(*images); |
| 8152 | if (*option == '+') |
| 8153 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8154 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8155 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8156 | write_info=DestroyImageInfo(write_info); |
| 8157 | if (*option == '+') |
| 8158 | write_images=DestroyImageList(write_images); |
| 8159 | break; |
| 8160 | } |
| 8161 | break; |
| 8162 | } |
| 8163 | default: |
| 8164 | break; |
| 8165 | } |
| 8166 | i+=count; |
| 8167 | } |
| 8168 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8169 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8170 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8171 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8172 | } |
| 8173 | |
| 8174 | /* |
| 8175 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8176 | % % |
| 8177 | % % |
| 8178 | % % |
| 8179 | + M o g r i f y I m a g e s % |
| 8180 | % % |
| 8181 | % % |
| 8182 | % % |
| 8183 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8184 | % |
| 8185 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8186 | % prescribed by command line options. |
| 8187 | % |
| 8188 | % The format of the MogrifyImage method is: |
| 8189 | % |
| 8190 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8191 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8192 | % Image **images,Exceptioninfo *exception) |
| 8193 | % |
| 8194 | % A description of each parameter follows: |
| 8195 | % |
| 8196 | % o image_info: the image info.. |
| 8197 | % |
| 8198 | % o post: If true, post process image list operators otherwise pre-process. |
| 8199 | % |
| 8200 | % o argc: Specifies a pointer to an integer describing the number of |
| 8201 | % elements in the argument vector. |
| 8202 | % |
| 8203 | % o argv: Specifies a pointer to a text array containing the command line |
| 8204 | % arguments. |
| 8205 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8206 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8207 | % |
| 8208 | % o exception: return any errors or warnings in this structure. |
| 8209 | % |
| 8210 | */ |
| 8211 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8212 | const MagickBooleanType post,const int argc,const char **argv, |
| 8213 | Image **images,ExceptionInfo *exception) |
| 8214 | { |
| 8215 | #define MogrifyImageTag "Mogrify/Image" |
| 8216 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8217 | MagickStatusType |
| 8218 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8219 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8220 | MagickBooleanType |
| 8221 | proceed; |
| 8222 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8223 | size_t |
| 8224 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8225 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8226 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8227 | i; |
| 8228 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8229 | assert(image_info != (ImageInfo *) NULL); |
| 8230 | assert(image_info->signature == MagickSignature); |
| 8231 | if (images == (Image **) NULL) |
| 8232 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8233 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8234 | assert((*images)->signature == MagickSignature); |
| 8235 | if ((*images)->debug != MagickFalse) |
| 8236 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8237 | (*images)->filename); |
| 8238 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8239 | return(MagickTrue); |
| 8240 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8241 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8242 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8243 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8244 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8245 | (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc, |
| 8246 | post?"post":"pre"); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8247 | #endif |
| 8248 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8249 | /* |
| 8250 | Pre-process multi-image sequence operators |
| 8251 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8252 | if (post == MagickFalse) |
| 8253 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8254 | /* |
| 8255 | For each image, process simple single image operators |
| 8256 | */ |
| 8257 | i=0; |
| 8258 | n=GetImageListLength(*images); |
| 8259 | for (;;) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8260 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8261 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8262 | (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long) |
| 8263 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8264 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8265 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8266 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8267 | if (proceed == MagickFalse) |
| 8268 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8269 | if ( (*images)->next == (Image *) NULL ) |
| 8270 | break; |
| 8271 | *images=(*images)->next; |
| 8272 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8273 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8274 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8275 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8276 | (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long) |
| 8277 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8278 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8279 | |
| 8280 | /* |
| 8281 | Post-process, multi-image sequence operators |
| 8282 | */ |
| 8283 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8284 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8285 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8286 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8287 | } |