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 | 0a92238 | 2011-07-16 15:30:34 +0000 | [diff] [blame^] | 1204 | kernel_info->bias=(*image)->bias; |
cristy | 5e6be1e | 2011-07-16 01:23:39 +0000 | [diff] [blame] | 1205 | mogrify_image=ConvolveImage(*image,kernel_info,exception); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1206 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1207 | break; |
| 1208 | } |
| 1209 | if (LocaleCompare("crop",option+1) == 0) |
| 1210 | { |
| 1211 | /* |
| 1212 | Crop a image to a smaller size |
| 1213 | */ |
| 1214 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1215 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1216 | break; |
| 1217 | } |
| 1218 | if (LocaleCompare("cycle",option+1) == 0) |
| 1219 | { |
| 1220 | /* |
| 1221 | Cycle an image colormap. |
| 1222 | */ |
| 1223 | (void) SyncImageSettings(mogrify_info,*image); |
| 1224 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1])); |
| 1225 | InheritException(exception,&(*image)->exception); |
| 1226 | break; |
| 1227 | } |
| 1228 | break; |
| 1229 | } |
| 1230 | case 'd': |
| 1231 | { |
| 1232 | if (LocaleCompare("decipher",option+1) == 0) |
| 1233 | { |
| 1234 | StringInfo |
| 1235 | *passkey; |
| 1236 | |
| 1237 | /* |
| 1238 | Decipher pixels. |
| 1239 | */ |
| 1240 | (void) SyncImageSettings(mogrify_info,*image); |
| 1241 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1242 | if (passkey != (StringInfo *) NULL) |
| 1243 | { |
| 1244 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1245 | passkey=DestroyStringInfo(passkey); |
| 1246 | } |
| 1247 | break; |
| 1248 | } |
| 1249 | if (LocaleCompare("density",option+1) == 0) |
| 1250 | { |
| 1251 | /* |
| 1252 | Set image density. |
| 1253 | */ |
| 1254 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1255 | break; |
| 1256 | } |
| 1257 | if (LocaleCompare("depth",option+1) == 0) |
| 1258 | { |
| 1259 | (void) SyncImageSettings(mogrify_info,*image); |
| 1260 | if (*option == '+') |
| 1261 | { |
| 1262 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH); |
| 1263 | break; |
| 1264 | } |
| 1265 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1])); |
| 1266 | break; |
| 1267 | } |
| 1268 | if (LocaleCompare("deskew",option+1) == 0) |
| 1269 | { |
| 1270 | double |
| 1271 | threshold; |
| 1272 | |
| 1273 | /* |
| 1274 | Straighten the image. |
| 1275 | */ |
| 1276 | (void) SyncImageSettings(mogrify_info,*image); |
| 1277 | if (*option == '+') |
| 1278 | threshold=40.0*QuantumRange/100.0; |
| 1279 | else |
| 1280 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 1281 | mogrify_image=DeskewImage(*image,threshold,exception); |
| 1282 | break; |
| 1283 | } |
| 1284 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1285 | { |
| 1286 | /* |
| 1287 | Reduce the speckles within an image. |
| 1288 | */ |
| 1289 | (void) SyncImageSettings(mogrify_info,*image); |
| 1290 | mogrify_image=DespeckleImage(*image,exception); |
| 1291 | break; |
| 1292 | } |
| 1293 | if (LocaleCompare("display",option+1) == 0) |
| 1294 | { |
| 1295 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1296 | break; |
| 1297 | } |
| 1298 | if (LocaleCompare("distort",option+1) == 0) |
| 1299 | { |
| 1300 | char |
| 1301 | *args, |
| 1302 | token[MaxTextExtent]; |
| 1303 | |
| 1304 | const char |
| 1305 | *p; |
| 1306 | |
| 1307 | DistortImageMethod |
| 1308 | method; |
| 1309 | |
| 1310 | double |
| 1311 | *arguments; |
| 1312 | |
| 1313 | register ssize_t |
| 1314 | x; |
| 1315 | |
| 1316 | size_t |
| 1317 | number_arguments; |
| 1318 | |
| 1319 | /* |
| 1320 | Distort image. |
| 1321 | */ |
| 1322 | (void) SyncImageSettings(mogrify_info,*image); |
| 1323 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, |
| 1324 | MagickFalse,argv[i+1]); |
| 1325 | if ( method == ResizeDistortion ) |
| 1326 | { |
| 1327 | /* Special Case - Argument is actually a resize geometry! |
| 1328 | ** Convert that to an appropriate distortion argument array. |
| 1329 | */ |
| 1330 | double |
| 1331 | resize_args[2]; |
| 1332 | (void) ParseRegionGeometry(*image,argv[i+2],&geometry, |
| 1333 | exception); |
| 1334 | resize_args[0]=(double)geometry.width; |
| 1335 | resize_args[1]=(double)geometry.height; |
| 1336 | mogrify_image=DistortImage(*image,method,(size_t)2, |
| 1337 | resize_args,MagickTrue,exception); |
| 1338 | break; |
| 1339 | } |
| 1340 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 1341 | InheritException(exception,&(*image)->exception); |
| 1342 | if (args == (char *) NULL) |
| 1343 | break; |
| 1344 | p=(char *) args; |
| 1345 | for (x=0; *p != '\0'; x++) |
| 1346 | { |
| 1347 | GetMagickToken(p,&p,token); |
| 1348 | if (*token == ',') |
| 1349 | GetMagickToken(p,&p,token); |
| 1350 | } |
| 1351 | number_arguments=(size_t) x; |
| 1352 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1353 | sizeof(*arguments)); |
| 1354 | if (arguments == (double *) NULL) |
| 1355 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1356 | "MemoryAllocationFailed",(*image)->filename); |
| 1357 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1358 | sizeof(*arguments)); |
| 1359 | p=(char *) args; |
| 1360 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 1361 | { |
| 1362 | GetMagickToken(p,&p,token); |
| 1363 | if (*token == ',') |
| 1364 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1365 | arguments[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1366 | } |
| 1367 | args=DestroyString(args); |
| 1368 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
| 1369 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1370 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1371 | break; |
| 1372 | } |
| 1373 | if (LocaleCompare("dither",option+1) == 0) |
| 1374 | { |
| 1375 | if (*option == '+') |
| 1376 | { |
| 1377 | quantize_info->dither=MagickFalse; |
| 1378 | break; |
| 1379 | } |
| 1380 | quantize_info->dither=MagickTrue; |
| 1381 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
| 1382 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1383 | if (quantize_info->dither_method == NoDitherMethod) |
| 1384 | quantize_info->dither=MagickFalse; |
| 1385 | break; |
| 1386 | } |
| 1387 | if (LocaleCompare("draw",option+1) == 0) |
| 1388 | { |
| 1389 | /* |
| 1390 | Draw image. |
| 1391 | */ |
| 1392 | (void) SyncImageSettings(mogrify_info,*image); |
| 1393 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
| 1394 | (void) DrawImage(*image,draw_info); |
| 1395 | InheritException(exception,&(*image)->exception); |
| 1396 | break; |
| 1397 | } |
| 1398 | break; |
| 1399 | } |
| 1400 | case 'e': |
| 1401 | { |
| 1402 | if (LocaleCompare("edge",option+1) == 0) |
| 1403 | { |
| 1404 | /* |
| 1405 | Enhance edges in the image. |
| 1406 | */ |
| 1407 | (void) SyncImageSettings(mogrify_info,*image); |
| 1408 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1409 | if ((flags & SigmaValue) == 0) |
| 1410 | geometry_info.sigma=1.0; |
| 1411 | mogrify_image=EdgeImage(*image,geometry_info.rho,exception); |
| 1412 | break; |
| 1413 | } |
| 1414 | if (LocaleCompare("emboss",option+1) == 0) |
| 1415 | { |
| 1416 | /* |
| 1417 | Gaussian embossen 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=EmbossImage(*image,geometry_info.rho, |
| 1424 | geometry_info.sigma,exception); |
| 1425 | break; |
| 1426 | } |
| 1427 | if (LocaleCompare("encipher",option+1) == 0) |
| 1428 | { |
| 1429 | StringInfo |
| 1430 | *passkey; |
| 1431 | |
| 1432 | /* |
| 1433 | Encipher pixels. |
| 1434 | */ |
| 1435 | (void) SyncImageSettings(mogrify_info,*image); |
| 1436 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1437 | if (passkey != (StringInfo *) NULL) |
| 1438 | { |
| 1439 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1440 | passkey=DestroyStringInfo(passkey); |
| 1441 | } |
| 1442 | break; |
| 1443 | } |
| 1444 | if (LocaleCompare("encoding",option+1) == 0) |
| 1445 | { |
| 1446 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1447 | break; |
| 1448 | } |
| 1449 | if (LocaleCompare("enhance",option+1) == 0) |
| 1450 | { |
| 1451 | /* |
| 1452 | Enhance image. |
| 1453 | */ |
| 1454 | (void) SyncImageSettings(mogrify_info,*image); |
| 1455 | mogrify_image=EnhanceImage(*image,exception); |
| 1456 | break; |
| 1457 | } |
| 1458 | if (LocaleCompare("equalize",option+1) == 0) |
| 1459 | { |
| 1460 | /* |
| 1461 | Equalize image. |
| 1462 | */ |
| 1463 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1464 | (void) EqualizeImage(*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1465 | InheritException(exception,&(*image)->exception); |
| 1466 | break; |
| 1467 | } |
| 1468 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1469 | { |
| 1470 | double |
| 1471 | constant; |
| 1472 | |
| 1473 | MagickEvaluateOperator |
| 1474 | op; |
| 1475 | |
| 1476 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1477 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 1478 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1479 | constant=SiPrefixToDouble(argv[i+2],QuantumRange); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1480 | (void) EvaluateImage(*image,op,constant,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1481 | break; |
| 1482 | } |
| 1483 | if (LocaleCompare("extent",option+1) == 0) |
| 1484 | { |
| 1485 | /* |
| 1486 | Set the image extent. |
| 1487 | */ |
| 1488 | (void) SyncImageSettings(mogrify_info,*image); |
| 1489 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1490 | if (geometry.width == 0) |
| 1491 | geometry.width=(*image)->columns; |
| 1492 | if (geometry.height == 0) |
| 1493 | geometry.height=(*image)->rows; |
| 1494 | mogrify_image=ExtentImage(*image,&geometry,exception); |
| 1495 | break; |
| 1496 | } |
| 1497 | break; |
| 1498 | } |
| 1499 | case 'f': |
| 1500 | { |
| 1501 | if (LocaleCompare("family",option+1) == 0) |
| 1502 | { |
| 1503 | if (*option == '+') |
| 1504 | { |
| 1505 | if (draw_info->family != (char *) NULL) |
| 1506 | draw_info->family=DestroyString(draw_info->family); |
| 1507 | break; |
| 1508 | } |
| 1509 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1510 | break; |
| 1511 | } |
| 1512 | if (LocaleCompare("features",option+1) == 0) |
| 1513 | { |
| 1514 | if (*option == '+') |
| 1515 | { |
| 1516 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1517 | break; |
| 1518 | } |
| 1519 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1520 | break; |
| 1521 | } |
| 1522 | if (LocaleCompare("fill",option+1) == 0) |
| 1523 | { |
| 1524 | ExceptionInfo |
| 1525 | *sans; |
| 1526 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1527 | GetPixelInfo(*image,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1528 | if (*option == '+') |
| 1529 | { |
| 1530 | (void) QueryMagickColor("none",&fill,exception); |
| 1531 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 1532 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1533 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1534 | break; |
| 1535 | } |
| 1536 | sans=AcquireExceptionInfo(); |
| 1537 | (void) QueryMagickColor(argv[i+1],&fill,sans); |
| 1538 | status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans); |
| 1539 | sans=DestroyExceptionInfo(sans); |
| 1540 | if (status == MagickFalse) |
| 1541 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 1542 | exception); |
| 1543 | break; |
| 1544 | } |
| 1545 | if (LocaleCompare("flip",option+1) == 0) |
| 1546 | { |
| 1547 | /* |
| 1548 | Flip image scanlines. |
| 1549 | */ |
| 1550 | (void) SyncImageSettings(mogrify_info,*image); |
| 1551 | mogrify_image=FlipImage(*image,exception); |
| 1552 | break; |
| 1553 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1554 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1555 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1556 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1557 | target; |
| 1558 | |
| 1559 | /* |
| 1560 | Floodfill image. |
| 1561 | */ |
| 1562 | (void) SyncImageSettings(mogrify_info,*image); |
| 1563 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1564 | (void) QueryMagickColor(argv[i+2],&target,exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1565 | (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x, |
| 1566 | geometry.y,*option == '-' ? MagickFalse : MagickTrue); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1567 | InheritException(exception,&(*image)->exception); |
| 1568 | break; |
| 1569 | } |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1570 | if (LocaleCompare("flop",option+1) == 0) |
| 1571 | { |
| 1572 | /* |
| 1573 | Flop image scanlines. |
| 1574 | */ |
| 1575 | (void) SyncImageSettings(mogrify_info,*image); |
| 1576 | mogrify_image=FlopImage(*image,exception); |
| 1577 | break; |
| 1578 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1579 | if (LocaleCompare("font",option+1) == 0) |
| 1580 | { |
| 1581 | if (*option == '+') |
| 1582 | { |
| 1583 | if (draw_info->font != (char *) NULL) |
| 1584 | draw_info->font=DestroyString(draw_info->font); |
| 1585 | break; |
| 1586 | } |
| 1587 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1588 | break; |
| 1589 | } |
| 1590 | if (LocaleCompare("format",option+1) == 0) |
| 1591 | { |
| 1592 | format=argv[i+1]; |
| 1593 | break; |
| 1594 | } |
| 1595 | if (LocaleCompare("frame",option+1) == 0) |
| 1596 | { |
| 1597 | FrameInfo |
| 1598 | frame_info; |
| 1599 | |
| 1600 | /* |
| 1601 | Surround image with an ornamental border. |
| 1602 | */ |
| 1603 | (void) SyncImageSettings(mogrify_info,*image); |
| 1604 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1605 | frame_info.width=geometry.width; |
| 1606 | frame_info.height=geometry.height; |
| 1607 | if ((flags & HeightValue) == 0) |
| 1608 | frame_info.height=geometry.width; |
| 1609 | frame_info.outer_bevel=geometry.x; |
| 1610 | frame_info.inner_bevel=geometry.y; |
| 1611 | frame_info.x=(ssize_t) frame_info.width; |
| 1612 | frame_info.y=(ssize_t) frame_info.height; |
| 1613 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1614 | frame_info.height=(*image)->rows+2*frame_info.height; |
| 1615 | mogrify_image=FrameImage(*image,&frame_info,exception); |
| 1616 | break; |
| 1617 | } |
| 1618 | if (LocaleCompare("function",option+1) == 0) |
| 1619 | { |
| 1620 | char |
| 1621 | *arguments, |
| 1622 | token[MaxTextExtent]; |
| 1623 | |
| 1624 | const char |
| 1625 | *p; |
| 1626 | |
| 1627 | double |
| 1628 | *parameters; |
| 1629 | |
| 1630 | MagickFunction |
| 1631 | function; |
| 1632 | |
| 1633 | register ssize_t |
| 1634 | x; |
| 1635 | |
| 1636 | size_t |
| 1637 | number_parameters; |
| 1638 | |
| 1639 | /* |
| 1640 | Function Modify Image Values |
| 1641 | */ |
| 1642 | (void) SyncImageSettings(mogrify_info,*image); |
| 1643 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, |
| 1644 | MagickFalse,argv[i+1]); |
| 1645 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 1646 | InheritException(exception,&(*image)->exception); |
| 1647 | if (arguments == (char *) NULL) |
| 1648 | break; |
| 1649 | p=(char *) arguments; |
| 1650 | for (x=0; *p != '\0'; x++) |
| 1651 | { |
| 1652 | GetMagickToken(p,&p,token); |
| 1653 | if (*token == ',') |
| 1654 | GetMagickToken(p,&p,token); |
| 1655 | } |
| 1656 | number_parameters=(size_t) x; |
| 1657 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1658 | sizeof(*parameters)); |
| 1659 | if (parameters == (double *) NULL) |
| 1660 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1661 | "MemoryAllocationFailed",(*image)->filename); |
| 1662 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1663 | sizeof(*parameters)); |
| 1664 | p=(char *) arguments; |
| 1665 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
| 1666 | { |
| 1667 | GetMagickToken(p,&p,token); |
| 1668 | if (*token == ',') |
| 1669 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1670 | parameters[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1671 | } |
| 1672 | arguments=DestroyString(arguments); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1673 | (void) FunctionImage(*image,function,number_parameters,parameters, |
| 1674 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1675 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1676 | break; |
| 1677 | } |
| 1678 | break; |
| 1679 | } |
| 1680 | case 'g': |
| 1681 | { |
| 1682 | if (LocaleCompare("gamma",option+1) == 0) |
| 1683 | { |
| 1684 | /* |
| 1685 | Gamma image. |
| 1686 | */ |
| 1687 | (void) SyncImageSettings(mogrify_info,*image); |
| 1688 | if (*option == '+') |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1689 | (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1690 | else |
| 1691 | { |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1692 | (void) GammaImage(*image,InterpretLocaleValue(argv[i+1], |
| 1693 | (char **) NULL)); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1694 | InheritException(exception,&(*image)->exception); |
| 1695 | } |
| 1696 | break; |
| 1697 | } |
| 1698 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1699 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1700 | { |
| 1701 | /* |
| 1702 | Gaussian blur image. |
| 1703 | */ |
| 1704 | (void) SyncImageSettings(mogrify_info,*image); |
| 1705 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1706 | if ((flags & SigmaValue) == 0) |
| 1707 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1708 | mogrify_image=GaussianBlurImage(*image,geometry_info.rho, |
| 1709 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1710 | break; |
| 1711 | } |
| 1712 | if (LocaleCompare("geometry",option+1) == 0) |
| 1713 | { |
| 1714 | /* |
| 1715 | Record Image offset, Resize last image. |
| 1716 | */ |
| 1717 | (void) SyncImageSettings(mogrify_info,*image); |
| 1718 | if (*option == '+') |
| 1719 | { |
| 1720 | if ((*image)->geometry != (char *) NULL) |
| 1721 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1722 | break; |
| 1723 | } |
| 1724 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1725 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1726 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1727 | else |
| 1728 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 1729 | (*image)->filter,(*image)->blur,exception); |
| 1730 | break; |
| 1731 | } |
| 1732 | if (LocaleCompare("gravity",option+1) == 0) |
| 1733 | { |
| 1734 | if (*option == '+') |
| 1735 | { |
| 1736 | draw_info->gravity=UndefinedGravity; |
| 1737 | break; |
| 1738 | } |
| 1739 | draw_info->gravity=(GravityType) ParseCommandOption( |
| 1740 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1741 | break; |
| 1742 | } |
| 1743 | break; |
| 1744 | } |
| 1745 | case 'h': |
| 1746 | { |
| 1747 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1748 | { |
| 1749 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1750 | break; |
| 1751 | } |
| 1752 | break; |
| 1753 | } |
| 1754 | case 'i': |
| 1755 | { |
| 1756 | if (LocaleCompare("identify",option+1) == 0) |
| 1757 | { |
| 1758 | char |
| 1759 | *text; |
| 1760 | |
| 1761 | (void) SyncImageSettings(mogrify_info,*image); |
| 1762 | if (format == (char *) NULL) |
| 1763 | { |
| 1764 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose); |
| 1765 | InheritException(exception,&(*image)->exception); |
| 1766 | break; |
| 1767 | } |
| 1768 | text=InterpretImageProperties(mogrify_info,*image,format); |
| 1769 | InheritException(exception,&(*image)->exception); |
| 1770 | if (text == (char *) NULL) |
| 1771 | break; |
| 1772 | (void) fputs(text,stdout); |
| 1773 | (void) fputc('\n',stdout); |
| 1774 | text=DestroyString(text); |
| 1775 | break; |
| 1776 | } |
| 1777 | if (LocaleCompare("implode",option+1) == 0) |
| 1778 | { |
| 1779 | /* |
| 1780 | Implode image. |
| 1781 | */ |
| 1782 | (void) SyncImageSettings(mogrify_info,*image); |
| 1783 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1784 | mogrify_image=ImplodeImage(*image,geometry_info.rho,exception); |
| 1785 | break; |
| 1786 | } |
| 1787 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1788 | { |
| 1789 | if (*option == '+') |
| 1790 | (void) ParseGeometry("0",&geometry_info); |
| 1791 | else |
| 1792 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1793 | draw_info->interline_spacing=geometry_info.rho; |
| 1794 | break; |
| 1795 | } |
| 1796 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1797 | { |
| 1798 | if (*option == '+') |
| 1799 | (void) ParseGeometry("0",&geometry_info); |
| 1800 | else |
| 1801 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1802 | draw_info->interword_spacing=geometry_info.rho; |
| 1803 | break; |
| 1804 | } |
| 1805 | break; |
| 1806 | } |
| 1807 | case 'k': |
| 1808 | { |
| 1809 | if (LocaleCompare("kerning",option+1) == 0) |
| 1810 | { |
| 1811 | if (*option == '+') |
| 1812 | (void) ParseGeometry("0",&geometry_info); |
| 1813 | else |
| 1814 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1815 | draw_info->kerning=geometry_info.rho; |
| 1816 | break; |
| 1817 | } |
| 1818 | break; |
| 1819 | } |
| 1820 | case 'l': |
| 1821 | { |
| 1822 | if (LocaleCompare("lat",option+1) == 0) |
| 1823 | { |
| 1824 | /* |
| 1825 | Local adaptive threshold image. |
| 1826 | */ |
| 1827 | (void) SyncImageSettings(mogrify_info,*image); |
| 1828 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1829 | if ((flags & PercentValue) != 0) |
| 1830 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 1831 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
| 1832 | geometry_info.rho,(size_t) geometry_info.sigma,(ssize_t) |
| 1833 | geometry_info.xi,exception); |
| 1834 | break; |
| 1835 | } |
| 1836 | if (LocaleCompare("level",option+1) == 0) |
| 1837 | { |
| 1838 | MagickRealType |
| 1839 | black_point, |
| 1840 | gamma, |
| 1841 | white_point; |
| 1842 | |
| 1843 | MagickStatusType |
| 1844 | flags; |
| 1845 | |
| 1846 | /* |
| 1847 | Parse levels. |
| 1848 | */ |
| 1849 | (void) SyncImageSettings(mogrify_info,*image); |
| 1850 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1851 | black_point=geometry_info.rho; |
| 1852 | white_point=(MagickRealType) QuantumRange; |
| 1853 | if ((flags & SigmaValue) != 0) |
| 1854 | white_point=geometry_info.sigma; |
| 1855 | gamma=1.0; |
| 1856 | if ((flags & XiValue) != 0) |
| 1857 | gamma=geometry_info.xi; |
| 1858 | if ((flags & PercentValue) != 0) |
| 1859 | { |
| 1860 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 1861 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 1862 | } |
| 1863 | if ((flags & SigmaValue) == 0) |
| 1864 | white_point=(MagickRealType) QuantumRange-black_point; |
| 1865 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1866 | (void) LevelizeImage(*image,black_point,white_point,gamma); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1867 | else |
cristy | f89cb1d | 2011-07-07 01:24:37 +0000 | [diff] [blame] | 1868 | (void) LevelImage(*image,black_point,white_point,gamma); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1869 | InheritException(exception,&(*image)->exception); |
| 1870 | break; |
| 1871 | } |
| 1872 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1873 | { |
| 1874 | char |
| 1875 | token[MaxTextExtent]; |
| 1876 | |
| 1877 | const char |
| 1878 | *p; |
| 1879 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1880 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1881 | black_point, |
| 1882 | white_point; |
| 1883 | |
| 1884 | p=(const char *) argv[i+1]; |
| 1885 | GetMagickToken(p,&p,token); /* get black point color */ |
| 1886 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1887 | (void) QueryMagickColor(token,&black_point,exception); |
| 1888 | else |
| 1889 | (void) QueryMagickColor("#000000",&black_point,exception); |
| 1890 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1891 | GetMagickToken(p,&p,token); |
| 1892 | if (*token == '\0') |
| 1893 | white_point=black_point; /* set everything to that color */ |
| 1894 | else |
| 1895 | { |
| 1896 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 1897 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 1898 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1899 | (void) QueryMagickColor(token,&white_point,exception); |
| 1900 | else |
| 1901 | (void) QueryMagickColor("#ffffff",&white_point,exception); |
| 1902 | } |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 1903 | (void) LevelImageColors(*image,&black_point,&white_point, |
| 1904 | *option == '+' ? MagickTrue : MagickFalse); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1905 | break; |
| 1906 | } |
| 1907 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 1908 | { |
| 1909 | double |
| 1910 | black_point, |
| 1911 | white_point; |
| 1912 | |
| 1913 | MagickStatusType |
| 1914 | flags; |
| 1915 | |
| 1916 | (void) SyncImageSettings(mogrify_info,*image); |
| 1917 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1918 | black_point=geometry_info.rho; |
| 1919 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 1920 | if ((flags & SigmaValue) != 0) |
| 1921 | white_point=geometry_info.sigma; |
| 1922 | if ((flags & PercentValue) != 0) |
| 1923 | { |
| 1924 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1925 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1926 | } |
| 1927 | if ((flags & SigmaValue) == 0) |
| 1928 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1929 | black_point; |
| 1930 | (void) LinearStretchImage(*image,black_point,white_point); |
| 1931 | InheritException(exception,&(*image)->exception); |
| 1932 | break; |
| 1933 | } |
| 1934 | if (LocaleCompare("linewidth",option+1) == 0) |
| 1935 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1936 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 1937 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1938 | break; |
| 1939 | } |
| 1940 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 1941 | { |
| 1942 | /* |
| 1943 | Liquid rescale image. |
| 1944 | */ |
| 1945 | (void) SyncImageSettings(mogrify_info,*image); |
| 1946 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1947 | if ((flags & XValue) == 0) |
| 1948 | geometry.x=1; |
| 1949 | if ((flags & YValue) == 0) |
| 1950 | geometry.y=0; |
| 1951 | mogrify_image=LiquidRescaleImage(*image,geometry.width, |
| 1952 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 1953 | break; |
| 1954 | } |
| 1955 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 1956 | { |
| 1957 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1958 | break; |
| 1959 | } |
| 1960 | break; |
| 1961 | } |
| 1962 | case 'm': |
| 1963 | { |
| 1964 | if (LocaleCompare("map",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1965 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1966 | Image |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1967 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1968 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1969 | /* |
| 1970 | Transform image colors to match this set of colors. |
| 1971 | */ |
| 1972 | (void) SyncImageSettings(mogrify_info,*image); |
| 1973 | if (*option == '+') |
| 1974 | break; |
| 1975 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1976 | if (remap_image == (Image *) NULL) |
| 1977 | break; |
| 1978 | (void) RemapImage(quantize_info,*image,remap_image); |
| 1979 | InheritException(exception,&(*image)->exception); |
| 1980 | remap_image=DestroyImage(remap_image); |
| 1981 | break; |
| 1982 | } |
| 1983 | if (LocaleCompare("mask",option+1) == 0) |
| 1984 | { |
| 1985 | Image |
| 1986 | *mask; |
| 1987 | |
| 1988 | (void) SyncImageSettings(mogrify_info,*image); |
| 1989 | if (*option == '+') |
| 1990 | { |
| 1991 | /* |
| 1992 | Remove a mask. |
| 1993 | */ |
| 1994 | (void) SetImageMask(*image,(Image *) NULL); |
| 1995 | InheritException(exception,&(*image)->exception); |
| 1996 | break; |
| 1997 | } |
| 1998 | /* |
| 1999 | Set the image mask. |
| 2000 | */ |
| 2001 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2002 | if (mask == (Image *) NULL) |
| 2003 | break; |
| 2004 | (void) SetImageMask(*image,mask); |
| 2005 | mask=DestroyImage(mask); |
| 2006 | InheritException(exception,&(*image)->exception); |
| 2007 | break; |
| 2008 | } |
| 2009 | if (LocaleCompare("matte",option+1) == 0) |
| 2010 | { |
| 2011 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
| 2012 | SetAlphaChannel : DeactivateAlphaChannel ); |
| 2013 | InheritException(exception,&(*image)->exception); |
| 2014 | break; |
| 2015 | } |
| 2016 | if (LocaleCompare("median",option+1) == 0) |
| 2017 | { |
| 2018 | /* |
| 2019 | Median filter image. |
| 2020 | */ |
| 2021 | (void) SyncImageSettings(mogrify_info,*image); |
| 2022 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2023 | mogrify_image=StatisticImage(*image,MedianStatistic,(size_t) |
| 2024 | geometry_info.rho,(size_t) geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2025 | break; |
| 2026 | } |
| 2027 | if (LocaleCompare("mode",option+1) == 0) |
| 2028 | { |
| 2029 | /* |
| 2030 | Mode image. |
| 2031 | */ |
| 2032 | (void) SyncImageSettings(mogrify_info,*image); |
| 2033 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2034 | mogrify_image=StatisticImage(*image,ModeStatistic,(size_t) |
| 2035 | geometry_info.rho,(size_t) geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2036 | break; |
| 2037 | } |
| 2038 | if (LocaleCompare("modulate",option+1) == 0) |
| 2039 | { |
| 2040 | (void) SyncImageSettings(mogrify_info,*image); |
| 2041 | (void) ModulateImage(*image,argv[i+1]); |
| 2042 | InheritException(exception,&(*image)->exception); |
| 2043 | break; |
| 2044 | } |
| 2045 | if (LocaleCompare("monitor",option+1) == 0) |
| 2046 | { |
| 2047 | if (*option == '+') |
| 2048 | { |
| 2049 | (void) SetImageProgressMonitor(*image, |
| 2050 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2051 | break; |
| 2052 | } |
| 2053 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2054 | (void *) NULL); |
| 2055 | break; |
| 2056 | } |
| 2057 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2058 | { |
| 2059 | (void) SyncImageSettings(mogrify_info,*image); |
| 2060 | (void) SetImageType(*image,BilevelType); |
| 2061 | InheritException(exception,&(*image)->exception); |
| 2062 | break; |
| 2063 | } |
| 2064 | if (LocaleCompare("morphology",option+1) == 0) |
| 2065 | { |
| 2066 | char |
| 2067 | token[MaxTextExtent]; |
| 2068 | |
| 2069 | const char |
| 2070 | *p; |
| 2071 | |
| 2072 | KernelInfo |
| 2073 | *kernel; |
| 2074 | |
| 2075 | MorphologyMethod |
| 2076 | method; |
| 2077 | |
| 2078 | ssize_t |
| 2079 | iterations; |
| 2080 | |
| 2081 | /* |
| 2082 | Morphological Image Operation |
| 2083 | */ |
| 2084 | (void) SyncImageSettings(mogrify_info,*image); |
| 2085 | p=argv[i+1]; |
| 2086 | GetMagickToken(p,&p,token); |
| 2087 | method=(MorphologyMethod) ParseCommandOption(MagickMorphologyOptions, |
| 2088 | MagickFalse,token); |
| 2089 | iterations=1L; |
| 2090 | GetMagickToken(p,&p,token); |
| 2091 | if ((*p == ':') || (*p == ',')) |
| 2092 | GetMagickToken(p,&p,token); |
| 2093 | if ((*p != '\0')) |
| 2094 | iterations=(ssize_t) StringToLong(p); |
| 2095 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2096 | if (kernel == (KernelInfo *) NULL) |
| 2097 | { |
| 2098 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2099 | OptionError,"UnabletoParseKernel","morphology"); |
| 2100 | status=MagickFalse; |
| 2101 | break; |
| 2102 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2103 | mogrify_image=MorphologyImage(*image,method,iterations,kernel, |
| 2104 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2105 | kernel=DestroyKernelInfo(kernel); |
| 2106 | break; |
| 2107 | } |
| 2108 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2109 | { |
| 2110 | /* |
| 2111 | Motion blur image. |
| 2112 | */ |
| 2113 | (void) SyncImageSettings(mogrify_info,*image); |
| 2114 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2115 | if ((flags & SigmaValue) == 0) |
| 2116 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2117 | mogrify_image=MotionBlurImage(*image,geometry_info.rho, |
| 2118 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2119 | break; |
| 2120 | } |
| 2121 | break; |
| 2122 | } |
| 2123 | case 'n': |
| 2124 | { |
| 2125 | if (LocaleCompare("negate",option+1) == 0) |
| 2126 | { |
| 2127 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2128 | (void) NegateImage(*image,*option == '+' ? MagickTrue : |
| 2129 | MagickFalse); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2130 | InheritException(exception,&(*image)->exception); |
| 2131 | break; |
| 2132 | } |
| 2133 | if (LocaleCompare("noise",option+1) == 0) |
| 2134 | { |
| 2135 | (void) SyncImageSettings(mogrify_info,*image); |
| 2136 | if (*option == '-') |
| 2137 | { |
| 2138 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2139 | mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t) |
| 2140 | geometry_info.rho,(size_t) geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2141 | } |
| 2142 | else |
| 2143 | { |
| 2144 | NoiseType |
| 2145 | noise; |
| 2146 | |
| 2147 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
| 2148 | MagickFalse,argv[i+1]); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 2149 | mogrify_image=AddNoiseImage(*image,noise,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2150 | } |
| 2151 | break; |
| 2152 | } |
| 2153 | if (LocaleCompare("normalize",option+1) == 0) |
| 2154 | { |
| 2155 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2156 | (void) NormalizeImage(*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2157 | InheritException(exception,&(*image)->exception); |
| 2158 | break; |
| 2159 | } |
| 2160 | break; |
| 2161 | } |
| 2162 | case 'o': |
| 2163 | { |
| 2164 | if (LocaleCompare("opaque",option+1) == 0) |
| 2165 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2166 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2167 | target; |
| 2168 | |
| 2169 | (void) SyncImageSettings(mogrify_info,*image); |
| 2170 | (void) QueryMagickColor(argv[i+1],&target,exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 2171 | (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ? |
| 2172 | MagickFalse : MagickTrue); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2173 | break; |
| 2174 | } |
| 2175 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2176 | { |
| 2177 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 1302067 | 2011-07-08 02:33:26 +0000 | [diff] [blame] | 2178 | (void) OrderedPosterizeImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2179 | break; |
| 2180 | } |
| 2181 | break; |
| 2182 | } |
| 2183 | case 'p': |
| 2184 | { |
| 2185 | if (LocaleCompare("paint",option+1) == 0) |
| 2186 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2187 | (void) SyncImageSettings(mogrify_info,*image); |
| 2188 | (void) ParseGeometry(argv[i+1],&geometry_info); |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 2189 | mogrify_image=OilPaintImage(*image,geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2190 | break; |
| 2191 | } |
| 2192 | if (LocaleCompare("pen",option+1) == 0) |
| 2193 | { |
| 2194 | if (*option == '+') |
| 2195 | { |
| 2196 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 2197 | break; |
| 2198 | } |
| 2199 | (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception); |
| 2200 | break; |
| 2201 | } |
| 2202 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2203 | { |
| 2204 | if (*option == '+') |
| 2205 | (void) ParseGeometry("12",&geometry_info); |
| 2206 | else |
| 2207 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2208 | draw_info->pointsize=geometry_info.rho; |
| 2209 | break; |
| 2210 | } |
| 2211 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2212 | { |
| 2213 | double |
| 2214 | angle; |
| 2215 | |
| 2216 | RandomInfo |
| 2217 | *random_info; |
| 2218 | |
| 2219 | /* |
| 2220 | Simulate a Polaroid picture. |
| 2221 | */ |
| 2222 | (void) SyncImageSettings(mogrify_info,*image); |
| 2223 | random_info=AcquireRandomInfo(); |
| 2224 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2225 | random_info=DestroyRandomInfo(random_info); |
| 2226 | if (*option == '-') |
| 2227 | { |
| 2228 | SetGeometryInfo(&geometry_info); |
| 2229 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2230 | angle=geometry_info.rho; |
| 2231 | } |
| 2232 | mogrify_image=PolaroidImage(*image,draw_info,angle,exception); |
| 2233 | break; |
| 2234 | } |
| 2235 | if (LocaleCompare("posterize",option+1) == 0) |
| 2236 | { |
| 2237 | /* |
| 2238 | Posterize image. |
| 2239 | */ |
| 2240 | (void) SyncImageSettings(mogrify_info,*image); |
| 2241 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
| 2242 | quantize_info->dither); |
| 2243 | InheritException(exception,&(*image)->exception); |
| 2244 | break; |
| 2245 | } |
| 2246 | if (LocaleCompare("preview",option+1) == 0) |
| 2247 | { |
| 2248 | PreviewType |
| 2249 | preview_type; |
| 2250 | |
| 2251 | /* |
| 2252 | Preview image. |
| 2253 | */ |
| 2254 | (void) SyncImageSettings(mogrify_info,*image); |
| 2255 | if (*option == '+') |
| 2256 | preview_type=UndefinedPreview; |
| 2257 | else |
| 2258 | preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions, |
| 2259 | MagickFalse,argv[i+1]); |
| 2260 | mogrify_image=PreviewImage(*image,preview_type,exception); |
| 2261 | break; |
| 2262 | } |
| 2263 | if (LocaleCompare("profile",option+1) == 0) |
| 2264 | { |
| 2265 | const char |
| 2266 | *name; |
| 2267 | |
| 2268 | const StringInfo |
| 2269 | *profile; |
| 2270 | |
| 2271 | Image |
| 2272 | *profile_image; |
| 2273 | |
| 2274 | ImageInfo |
| 2275 | *profile_info; |
| 2276 | |
| 2277 | (void) SyncImageSettings(mogrify_info,*image); |
| 2278 | if (*option == '+') |
| 2279 | { |
| 2280 | /* |
| 2281 | Remove a profile from the image. |
| 2282 | */ |
| 2283 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
| 2284 | NULL,0,MagickTrue); |
| 2285 | InheritException(exception,&(*image)->exception); |
| 2286 | break; |
| 2287 | } |
| 2288 | /* |
| 2289 | Associate a profile with the image. |
| 2290 | */ |
| 2291 | profile_info=CloneImageInfo(mogrify_info); |
| 2292 | profile=GetImageProfile(*image,"iptc"); |
| 2293 | if (profile != (StringInfo *) NULL) |
| 2294 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2295 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2296 | profile_info=DestroyImageInfo(profile_info); |
| 2297 | if (profile_image == (Image *) NULL) |
| 2298 | { |
| 2299 | StringInfo |
| 2300 | *profile; |
| 2301 | |
| 2302 | profile_info=CloneImageInfo(mogrify_info); |
| 2303 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2304 | MaxTextExtent); |
| 2305 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
| 2306 | if (profile != (StringInfo *) NULL) |
| 2307 | { |
| 2308 | (void) ProfileImage(*image,profile_info->magick, |
| 2309 | GetStringInfoDatum(profile),(size_t) |
| 2310 | GetStringInfoLength(profile),MagickFalse); |
| 2311 | profile=DestroyStringInfo(profile); |
| 2312 | } |
| 2313 | profile_info=DestroyImageInfo(profile_info); |
| 2314 | break; |
| 2315 | } |
| 2316 | ResetImageProfileIterator(profile_image); |
| 2317 | name=GetNextImageProfile(profile_image); |
| 2318 | while (name != (const char *) NULL) |
| 2319 | { |
| 2320 | profile=GetImageProfile(profile_image,name); |
| 2321 | if (profile != (StringInfo *) NULL) |
| 2322 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
| 2323 | (size_t) GetStringInfoLength(profile),MagickFalse); |
| 2324 | name=GetNextImageProfile(profile_image); |
| 2325 | } |
| 2326 | profile_image=DestroyImage(profile_image); |
| 2327 | break; |
| 2328 | } |
| 2329 | break; |
| 2330 | } |
| 2331 | case 'q': |
| 2332 | { |
| 2333 | if (LocaleCompare("quantize",option+1) == 0) |
| 2334 | { |
| 2335 | if (*option == '+') |
| 2336 | { |
| 2337 | quantize_info->colorspace=UndefinedColorspace; |
| 2338 | break; |
| 2339 | } |
| 2340 | quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
| 2341 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2342 | break; |
| 2343 | } |
| 2344 | break; |
| 2345 | } |
| 2346 | case 'r': |
| 2347 | { |
| 2348 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2349 | { |
| 2350 | /* |
| 2351 | Radial blur image. |
| 2352 | */ |
| 2353 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2354 | mogrify_image=RadialBlurImage(*image,InterpretLocaleValue(argv[i+1], |
| 2355 | (char **) NULL),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2356 | break; |
| 2357 | } |
| 2358 | if (LocaleCompare("raise",option+1) == 0) |
| 2359 | { |
| 2360 | /* |
| 2361 | Surround image with a raise of solid color. |
| 2362 | */ |
| 2363 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2364 | if ((flags & SigmaValue) == 0) |
| 2365 | geometry.height=geometry.width; |
| 2366 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
| 2367 | MagickFalse); |
| 2368 | InheritException(exception,&(*image)->exception); |
| 2369 | break; |
| 2370 | } |
| 2371 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2372 | { |
| 2373 | /* |
| 2374 | Threshold image. |
| 2375 | */ |
| 2376 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2377 | (void) RandomThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2378 | break; |
| 2379 | } |
| 2380 | if (LocaleCompare("recolor",option+1) == 0) |
| 2381 | { |
| 2382 | KernelInfo |
| 2383 | *kernel; |
| 2384 | |
| 2385 | (void) SyncImageSettings(mogrify_info,*image); |
| 2386 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2387 | if (kernel == (KernelInfo *) NULL) |
| 2388 | break; |
| 2389 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 2390 | kernel=DestroyKernelInfo(kernel); |
| 2391 | break; |
| 2392 | } |
| 2393 | if (LocaleCompare("region",option+1) == 0) |
| 2394 | { |
| 2395 | (void) SyncImageSettings(mogrify_info,*image); |
| 2396 | if (region_image != (Image *) NULL) |
| 2397 | { |
| 2398 | /* |
| 2399 | Composite region. |
| 2400 | */ |
| 2401 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2402 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 2403 | region_geometry.x,region_geometry.y); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2404 | InheritException(exception,®ion_image->exception); |
| 2405 | *image=DestroyImage(*image); |
| 2406 | *image=region_image; |
| 2407 | region_image = (Image *) NULL; |
| 2408 | } |
| 2409 | if (*option == '+') |
| 2410 | break; |
| 2411 | /* |
| 2412 | Apply transformations to a selected region of the image. |
| 2413 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2414 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2415 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2416 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2417 | if (mogrify_image == (Image *) NULL) |
| 2418 | break; |
| 2419 | region_image=(*image); |
| 2420 | *image=mogrify_image; |
| 2421 | mogrify_image=(Image *) NULL; |
| 2422 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2423 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2424 | if (LocaleCompare("render",option+1) == 0) |
| 2425 | { |
| 2426 | (void) SyncImageSettings(mogrify_info,*image); |
| 2427 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2428 | break; |
| 2429 | } |
| 2430 | if (LocaleCompare("remap",option+1) == 0) |
| 2431 | { |
| 2432 | Image |
| 2433 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2434 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2435 | /* |
| 2436 | Transform image colors to match this set of colors. |
| 2437 | */ |
| 2438 | (void) SyncImageSettings(mogrify_info,*image); |
| 2439 | if (*option == '+') |
| 2440 | break; |
| 2441 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2442 | if (remap_image == (Image *) NULL) |
| 2443 | break; |
| 2444 | (void) RemapImage(quantize_info,*image,remap_image); |
| 2445 | InheritException(exception,&(*image)->exception); |
| 2446 | remap_image=DestroyImage(remap_image); |
| 2447 | break; |
| 2448 | } |
| 2449 | if (LocaleCompare("repage",option+1) == 0) |
| 2450 | { |
| 2451 | if (*option == '+') |
| 2452 | { |
| 2453 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2454 | break; |
| 2455 | } |
| 2456 | (void) ResetImagePage(*image,argv[i+1]); |
| 2457 | InheritException(exception,&(*image)->exception); |
| 2458 | break; |
| 2459 | } |
| 2460 | if (LocaleCompare("resample",option+1) == 0) |
| 2461 | { |
| 2462 | /* |
| 2463 | Resample image. |
| 2464 | */ |
| 2465 | (void) SyncImageSettings(mogrify_info,*image); |
| 2466 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2467 | if ((flags & SigmaValue) == 0) |
| 2468 | geometry_info.sigma=geometry_info.rho; |
| 2469 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
| 2470 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2471 | break; |
| 2472 | } |
| 2473 | if (LocaleCompare("resize",option+1) == 0) |
| 2474 | { |
| 2475 | /* |
| 2476 | Resize image. |
| 2477 | */ |
| 2478 | (void) SyncImageSettings(mogrify_info,*image); |
| 2479 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2480 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2481 | (*image)->filter,(*image)->blur,exception); |
| 2482 | break; |
| 2483 | } |
| 2484 | if (LocaleCompare("roll",option+1) == 0) |
| 2485 | { |
| 2486 | /* |
| 2487 | Roll image. |
| 2488 | */ |
| 2489 | (void) SyncImageSettings(mogrify_info,*image); |
| 2490 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2491 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2492 | break; |
| 2493 | } |
| 2494 | if (LocaleCompare("rotate",option+1) == 0) |
| 2495 | { |
| 2496 | char |
| 2497 | *geometry; |
| 2498 | |
| 2499 | /* |
| 2500 | Check for conditional image rotation. |
| 2501 | */ |
| 2502 | (void) SyncImageSettings(mogrify_info,*image); |
| 2503 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2504 | if ((*image)->columns <= (*image)->rows) |
| 2505 | break; |
| 2506 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2507 | if ((*image)->columns >= (*image)->rows) |
| 2508 | break; |
| 2509 | /* |
| 2510 | Rotate image. |
| 2511 | */ |
| 2512 | geometry=ConstantString(argv[i+1]); |
| 2513 | (void) SubstituteString(&geometry,">",""); |
| 2514 | (void) SubstituteString(&geometry,"<",""); |
| 2515 | (void) ParseGeometry(geometry,&geometry_info); |
| 2516 | geometry=DestroyString(geometry); |
| 2517 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
| 2518 | break; |
| 2519 | } |
| 2520 | break; |
| 2521 | } |
| 2522 | case 's': |
| 2523 | { |
| 2524 | if (LocaleCompare("sample",option+1) == 0) |
| 2525 | { |
| 2526 | /* |
| 2527 | Sample image with pixel replication. |
| 2528 | */ |
| 2529 | (void) SyncImageSettings(mogrify_info,*image); |
| 2530 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2531 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
| 2532 | exception); |
| 2533 | break; |
| 2534 | } |
| 2535 | if (LocaleCompare("scale",option+1) == 0) |
| 2536 | { |
| 2537 | /* |
| 2538 | Resize image. |
| 2539 | */ |
| 2540 | (void) SyncImageSettings(mogrify_info,*image); |
| 2541 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2542 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2543 | exception); |
| 2544 | break; |
| 2545 | } |
| 2546 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2547 | { |
| 2548 | /* |
| 2549 | Selectively blur pixels within a contrast threshold. |
| 2550 | */ |
| 2551 | (void) SyncImageSettings(mogrify_info,*image); |
| 2552 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2553 | if ((flags & PercentValue) != 0) |
| 2554 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2555 | mogrify_image=SelectiveBlurImage(*image,geometry_info.rho, |
| 2556 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2557 | break; |
| 2558 | } |
| 2559 | if (LocaleCompare("separate",option+1) == 0) |
| 2560 | { |
| 2561 | /* |
| 2562 | Break channels into separate images. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2563 | */ |
| 2564 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 2565 | mogrify_image=SeparateImages(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2566 | break; |
| 2567 | } |
| 2568 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2569 | { |
| 2570 | double |
| 2571 | threshold; |
| 2572 | |
| 2573 | /* |
| 2574 | Sepia-tone image. |
| 2575 | */ |
| 2576 | (void) SyncImageSettings(mogrify_info,*image); |
| 2577 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2578 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
| 2579 | break; |
| 2580 | } |
| 2581 | if (LocaleCompare("segment",option+1) == 0) |
| 2582 | { |
| 2583 | /* |
| 2584 | Segment image. |
| 2585 | */ |
| 2586 | (void) SyncImageSettings(mogrify_info,*image); |
| 2587 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2588 | if ((flags & SigmaValue) == 0) |
| 2589 | geometry_info.sigma=1.0; |
| 2590 | (void) SegmentImage(*image,(*image)->colorspace, |
| 2591 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma); |
| 2592 | InheritException(exception,&(*image)->exception); |
| 2593 | break; |
| 2594 | } |
| 2595 | if (LocaleCompare("set",option+1) == 0) |
| 2596 | { |
| 2597 | char |
| 2598 | *value; |
| 2599 | |
| 2600 | /* |
| 2601 | Set image option. |
| 2602 | */ |
| 2603 | if (*option == '+') |
| 2604 | { |
| 2605 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2606 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2607 | else |
| 2608 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2609 | { |
| 2610 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
| 2611 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2612 | } |
| 2613 | else |
| 2614 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2615 | break; |
| 2616 | } |
| 2617 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 2618 | if (value == (char *) NULL) |
| 2619 | break; |
| 2620 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2621 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2622 | exception); |
| 2623 | else |
| 2624 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2625 | { |
| 2626 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
| 2627 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
| 2628 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2629 | } |
| 2630 | else |
| 2631 | (void) SetImageProperty(*image,argv[i+1],value); |
| 2632 | value=DestroyString(value); |
| 2633 | break; |
| 2634 | } |
| 2635 | if (LocaleCompare("shade",option+1) == 0) |
| 2636 | { |
| 2637 | /* |
| 2638 | Shade image. |
| 2639 | */ |
| 2640 | (void) SyncImageSettings(mogrify_info,*image); |
| 2641 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2642 | if ((flags & SigmaValue) == 0) |
| 2643 | geometry_info.sigma=1.0; |
| 2644 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2645 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2646 | break; |
| 2647 | } |
| 2648 | if (LocaleCompare("shadow",option+1) == 0) |
| 2649 | { |
| 2650 | /* |
| 2651 | Shadow image. |
| 2652 | */ |
| 2653 | (void) SyncImageSettings(mogrify_info,*image); |
| 2654 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2655 | if ((flags & SigmaValue) == 0) |
| 2656 | geometry_info.sigma=1.0; |
| 2657 | if ((flags & XiValue) == 0) |
| 2658 | geometry_info.xi=4.0; |
| 2659 | if ((flags & PsiValue) == 0) |
| 2660 | geometry_info.psi=4.0; |
| 2661 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
| 2662 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 2663 | ceil(geometry_info.psi-0.5),exception); |
| 2664 | break; |
| 2665 | } |
| 2666 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2667 | { |
| 2668 | /* |
| 2669 | Sharpen image. |
| 2670 | */ |
| 2671 | (void) SyncImageSettings(mogrify_info,*image); |
| 2672 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2673 | if ((flags & SigmaValue) == 0) |
| 2674 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2675 | mogrify_image=SharpenImage(*image,geometry_info.rho, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2676 | geometry_info.sigma,exception); |
| 2677 | break; |
| 2678 | } |
| 2679 | if (LocaleCompare("shave",option+1) == 0) |
| 2680 | { |
| 2681 | /* |
| 2682 | Shave the image edges. |
| 2683 | */ |
| 2684 | (void) SyncImageSettings(mogrify_info,*image); |
| 2685 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2686 | mogrify_image=ShaveImage(*image,&geometry,exception); |
| 2687 | break; |
| 2688 | } |
| 2689 | if (LocaleCompare("shear",option+1) == 0) |
| 2690 | { |
| 2691 | /* |
| 2692 | Shear image. |
| 2693 | */ |
| 2694 | (void) SyncImageSettings(mogrify_info,*image); |
| 2695 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2696 | if ((flags & SigmaValue) == 0) |
| 2697 | geometry_info.sigma=geometry_info.rho; |
| 2698 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2699 | geometry_info.sigma,exception); |
| 2700 | break; |
| 2701 | } |
| 2702 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2703 | { |
| 2704 | /* |
| 2705 | Sigmoidal non-linearity contrast control. |
| 2706 | */ |
| 2707 | (void) SyncImageSettings(mogrify_info,*image); |
| 2708 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2709 | if ((flags & SigmaValue) == 0) |
| 2710 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 2711 | if ((flags & PercentValue) != 0) |
| 2712 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2713 | 100.0; |
cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 2714 | (void) SigmoidalContrastImage(*image,(*option == '-') ? |
| 2715 | MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2716 | InheritException(exception,&(*image)->exception); |
| 2717 | break; |
| 2718 | } |
| 2719 | if (LocaleCompare("sketch",option+1) == 0) |
| 2720 | { |
| 2721 | /* |
| 2722 | Sketch image. |
| 2723 | */ |
| 2724 | (void) SyncImageSettings(mogrify_info,*image); |
| 2725 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2726 | if ((flags & SigmaValue) == 0) |
| 2727 | geometry_info.sigma=1.0; |
| 2728 | mogrify_image=SketchImage(*image,geometry_info.rho, |
| 2729 | geometry_info.sigma,geometry_info.xi,exception); |
| 2730 | break; |
| 2731 | } |
| 2732 | if (LocaleCompare("solarize",option+1) == 0) |
| 2733 | { |
| 2734 | double |
| 2735 | threshold; |
| 2736 | |
| 2737 | (void) SyncImageSettings(mogrify_info,*image); |
| 2738 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2739 | (void) SolarizeImage(*image,threshold); |
| 2740 | InheritException(exception,&(*image)->exception); |
| 2741 | break; |
| 2742 | } |
| 2743 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2744 | { |
| 2745 | SparseColorMethod |
| 2746 | method; |
| 2747 | |
| 2748 | char |
| 2749 | *arguments; |
| 2750 | |
| 2751 | /* |
| 2752 | Sparse Color Interpolated Gradient |
| 2753 | */ |
| 2754 | (void) SyncImageSettings(mogrify_info,*image); |
| 2755 | method=(SparseColorMethod) ParseCommandOption( |
| 2756 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
| 2757 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 2758 | InheritException(exception,&(*image)->exception); |
| 2759 | if (arguments == (char *) NULL) |
| 2760 | break; |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 2761 | mogrify_image=SparseColorOption(*image,method,arguments, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2762 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2763 | arguments=DestroyString(arguments); |
| 2764 | break; |
| 2765 | } |
| 2766 | if (LocaleCompare("splice",option+1) == 0) |
| 2767 | { |
| 2768 | /* |
| 2769 | Splice a solid color into the image. |
| 2770 | */ |
| 2771 | (void) SyncImageSettings(mogrify_info,*image); |
| 2772 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 2773 | mogrify_image=SpliceImage(*image,&geometry,exception); |
| 2774 | break; |
| 2775 | } |
| 2776 | if (LocaleCompare("spread",option+1) == 0) |
| 2777 | { |
| 2778 | /* |
| 2779 | Spread an image. |
| 2780 | */ |
| 2781 | (void) SyncImageSettings(mogrify_info,*image); |
| 2782 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2783 | mogrify_image=SpreadImage(*image,geometry_info.rho,exception); |
| 2784 | break; |
| 2785 | } |
| 2786 | if (LocaleCompare("statistic",option+1) == 0) |
| 2787 | { |
| 2788 | StatisticType |
| 2789 | type; |
| 2790 | |
| 2791 | (void) SyncImageSettings(mogrify_info,*image); |
| 2792 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
| 2793 | MagickFalse,argv[i+1]); |
| 2794 | (void) ParseGeometry(argv[i+2],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2795 | mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho, |
| 2796 | (size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2797 | break; |
| 2798 | } |
| 2799 | if (LocaleCompare("stretch",option+1) == 0) |
| 2800 | { |
| 2801 | if (*option == '+') |
| 2802 | { |
| 2803 | draw_info->stretch=UndefinedStretch; |
| 2804 | break; |
| 2805 | } |
| 2806 | draw_info->stretch=(StretchType) ParseCommandOption( |
| 2807 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2808 | break; |
| 2809 | } |
| 2810 | if (LocaleCompare("strip",option+1) == 0) |
| 2811 | { |
| 2812 | /* |
| 2813 | Strip image of profiles and comments. |
| 2814 | */ |
| 2815 | (void) SyncImageSettings(mogrify_info,*image); |
| 2816 | (void) StripImage(*image); |
| 2817 | InheritException(exception,&(*image)->exception); |
| 2818 | break; |
| 2819 | } |
| 2820 | if (LocaleCompare("stroke",option+1) == 0) |
| 2821 | { |
| 2822 | ExceptionInfo |
| 2823 | *sans; |
| 2824 | |
| 2825 | if (*option == '+') |
| 2826 | { |
| 2827 | (void) QueryColorDatabase("none",&draw_info->stroke,exception); |
| 2828 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2829 | draw_info->stroke_pattern=DestroyImage( |
| 2830 | draw_info->stroke_pattern); |
| 2831 | break; |
| 2832 | } |
| 2833 | sans=AcquireExceptionInfo(); |
| 2834 | status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans); |
| 2835 | sans=DestroyExceptionInfo(sans); |
| 2836 | if (status == MagickFalse) |
| 2837 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2838 | exception); |
| 2839 | break; |
| 2840 | } |
| 2841 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2842 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 2843 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 2844 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2845 | break; |
| 2846 | } |
| 2847 | if (LocaleCompare("style",option+1) == 0) |
| 2848 | { |
| 2849 | if (*option == '+') |
| 2850 | { |
| 2851 | draw_info->style=UndefinedStyle; |
| 2852 | break; |
| 2853 | } |
| 2854 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 2855 | MagickFalse,argv[i+1]); |
| 2856 | break; |
| 2857 | } |
| 2858 | if (LocaleCompare("swirl",option+1) == 0) |
| 2859 | { |
| 2860 | /* |
| 2861 | Swirl image. |
| 2862 | */ |
| 2863 | (void) SyncImageSettings(mogrify_info,*image); |
| 2864 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2865 | mogrify_image=SwirlImage(*image,geometry_info.rho,exception); |
| 2866 | break; |
| 2867 | } |
| 2868 | break; |
| 2869 | } |
| 2870 | case 't': |
| 2871 | { |
| 2872 | if (LocaleCompare("threshold",option+1) == 0) |
| 2873 | { |
| 2874 | double |
| 2875 | threshold; |
| 2876 | |
| 2877 | /* |
| 2878 | Threshold image. |
| 2879 | */ |
| 2880 | (void) SyncImageSettings(mogrify_info,*image); |
| 2881 | if (*option == '+') |
anthony | 247a86d | 2011-05-03 13:18:18 +0000 | [diff] [blame] | 2882 | threshold=(double) QuantumRange/2; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2883 | else |
| 2884 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2885 | (void) BilevelImage(*image,threshold); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2886 | InheritException(exception,&(*image)->exception); |
| 2887 | break; |
| 2888 | } |
| 2889 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2890 | { |
| 2891 | /* |
| 2892 | Thumbnail image. |
| 2893 | */ |
| 2894 | (void) SyncImageSettings(mogrify_info,*image); |
| 2895 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2896 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2897 | exception); |
| 2898 | break; |
| 2899 | } |
| 2900 | if (LocaleCompare("tile",option+1) == 0) |
| 2901 | { |
| 2902 | if (*option == '+') |
| 2903 | { |
| 2904 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2905 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2906 | break; |
| 2907 | } |
| 2908 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2909 | exception); |
| 2910 | break; |
| 2911 | } |
| 2912 | if (LocaleCompare("tint",option+1) == 0) |
| 2913 | { |
| 2914 | /* |
| 2915 | Tint the image. |
| 2916 | */ |
| 2917 | (void) SyncImageSettings(mogrify_info,*image); |
| 2918 | mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception); |
| 2919 | break; |
| 2920 | } |
| 2921 | if (LocaleCompare("transform",option+1) == 0) |
| 2922 | { |
| 2923 | /* |
| 2924 | Affine transform image. |
| 2925 | */ |
| 2926 | (void) SyncImageSettings(mogrify_info,*image); |
| 2927 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
| 2928 | exception); |
| 2929 | break; |
| 2930 | } |
| 2931 | if (LocaleCompare("transparent",option+1) == 0) |
| 2932 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2933 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2934 | target; |
| 2935 | |
| 2936 | (void) SyncImageSettings(mogrify_info,*image); |
| 2937 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2938 | (void) TransparentPaintImage(*image,&target,(Quantum) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2939 | TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2940 | InheritException(exception,&(*image)->exception); |
| 2941 | break; |
| 2942 | } |
| 2943 | if (LocaleCompare("transpose",option+1) == 0) |
| 2944 | { |
| 2945 | /* |
| 2946 | Transpose image scanlines. |
| 2947 | */ |
| 2948 | (void) SyncImageSettings(mogrify_info,*image); |
| 2949 | mogrify_image=TransposeImage(*image,exception); |
| 2950 | break; |
| 2951 | } |
| 2952 | if (LocaleCompare("transverse",option+1) == 0) |
| 2953 | { |
| 2954 | /* |
| 2955 | Transverse image scanlines. |
| 2956 | */ |
| 2957 | (void) SyncImageSettings(mogrify_info,*image); |
| 2958 | mogrify_image=TransverseImage(*image,exception); |
| 2959 | break; |
| 2960 | } |
| 2961 | if (LocaleCompare("treedepth",option+1) == 0) |
| 2962 | { |
| 2963 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
| 2964 | break; |
| 2965 | } |
| 2966 | if (LocaleCompare("trim",option+1) == 0) |
| 2967 | { |
| 2968 | /* |
| 2969 | Trim image. |
| 2970 | */ |
| 2971 | (void) SyncImageSettings(mogrify_info,*image); |
| 2972 | mogrify_image=TrimImage(*image,exception); |
| 2973 | break; |
| 2974 | } |
| 2975 | if (LocaleCompare("type",option+1) == 0) |
| 2976 | { |
| 2977 | ImageType |
| 2978 | type; |
| 2979 | |
| 2980 | (void) SyncImageSettings(mogrify_info,*image); |
| 2981 | if (*option == '+') |
| 2982 | type=UndefinedType; |
| 2983 | else |
| 2984 | type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 2985 | argv[i+1]); |
| 2986 | (*image)->type=UndefinedType; |
| 2987 | (void) SetImageType(*image,type); |
| 2988 | InheritException(exception,&(*image)->exception); |
| 2989 | break; |
| 2990 | } |
| 2991 | break; |
| 2992 | } |
| 2993 | case 'u': |
| 2994 | { |
| 2995 | if (LocaleCompare("undercolor",option+1) == 0) |
| 2996 | { |
| 2997 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 2998 | exception); |
| 2999 | break; |
| 3000 | } |
| 3001 | if (LocaleCompare("unique",option+1) == 0) |
| 3002 | { |
| 3003 | if (*option == '+') |
| 3004 | { |
| 3005 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
| 3006 | break; |
| 3007 | } |
| 3008 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
| 3009 | (void) SetImageArtifact(*image,"verbose","true"); |
| 3010 | break; |
| 3011 | } |
| 3012 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3013 | { |
| 3014 | /* |
| 3015 | Unique image colors. |
| 3016 | */ |
| 3017 | (void) SyncImageSettings(mogrify_info,*image); |
| 3018 | mogrify_image=UniqueImageColors(*image,exception); |
| 3019 | break; |
| 3020 | } |
| 3021 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3022 | { |
| 3023 | /* |
| 3024 | Unsharp mask image. |
| 3025 | */ |
| 3026 | (void) SyncImageSettings(mogrify_info,*image); |
| 3027 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3028 | if ((flags & SigmaValue) == 0) |
| 3029 | geometry_info.sigma=1.0; |
| 3030 | if ((flags & XiValue) == 0) |
| 3031 | geometry_info.xi=1.0; |
| 3032 | if ((flags & PsiValue) == 0) |
| 3033 | geometry_info.psi=0.05; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3034 | mogrify_image=UnsharpMaskImage(*image,geometry_info.rho, |
| 3035 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3036 | break; |
| 3037 | } |
| 3038 | break; |
| 3039 | } |
| 3040 | case 'v': |
| 3041 | { |
| 3042 | if (LocaleCompare("verbose",option+1) == 0) |
| 3043 | { |
| 3044 | (void) SetImageArtifact(*image,option+1, |
| 3045 | *option == '+' ? "false" : "true"); |
| 3046 | break; |
| 3047 | } |
| 3048 | if (LocaleCompare("vignette",option+1) == 0) |
| 3049 | { |
| 3050 | /* |
| 3051 | Vignette image. |
| 3052 | */ |
| 3053 | (void) SyncImageSettings(mogrify_info,*image); |
| 3054 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3055 | if ((flags & SigmaValue) == 0) |
| 3056 | geometry_info.sigma=1.0; |
| 3057 | if ((flags & XiValue) == 0) |
| 3058 | geometry_info.xi=0.1*(*image)->columns; |
| 3059 | if ((flags & PsiValue) == 0) |
| 3060 | geometry_info.psi=0.1*(*image)->rows; |
| 3061 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
| 3062 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3063 | ceil(geometry_info.psi-0.5),exception); |
| 3064 | break; |
| 3065 | } |
| 3066 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3067 | { |
| 3068 | if (*option == '+') |
| 3069 | { |
| 3070 | (void) SetImageVirtualPixelMethod(*image, |
| 3071 | UndefinedVirtualPixelMethod); |
| 3072 | break; |
| 3073 | } |
| 3074 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3075 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 3076 | argv[i+1])); |
| 3077 | break; |
| 3078 | } |
| 3079 | break; |
| 3080 | } |
| 3081 | case 'w': |
| 3082 | { |
| 3083 | if (LocaleCompare("wave",option+1) == 0) |
| 3084 | { |
| 3085 | /* |
| 3086 | Wave image. |
| 3087 | */ |
| 3088 | (void) SyncImageSettings(mogrify_info,*image); |
| 3089 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3090 | if ((flags & SigmaValue) == 0) |
| 3091 | geometry_info.sigma=1.0; |
| 3092 | mogrify_image=WaveImage(*image,geometry_info.rho, |
| 3093 | geometry_info.sigma,exception); |
| 3094 | break; |
| 3095 | } |
| 3096 | if (LocaleCompare("weight",option+1) == 0) |
| 3097 | { |
| 3098 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
| 3099 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3100 | draw_info->weight=0; |
| 3101 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3102 | draw_info->weight=700; |
| 3103 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3104 | if (draw_info->weight <= 800) |
| 3105 | draw_info->weight+=100; |
| 3106 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3107 | if (draw_info->weight >= 100) |
| 3108 | draw_info->weight-=100; |
| 3109 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3110 | draw_info->weight=400; |
| 3111 | break; |
| 3112 | } |
| 3113 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3114 | { |
| 3115 | /* |
| 3116 | White threshold image. |
| 3117 | */ |
| 3118 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3119 | (void) WhiteThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3120 | InheritException(exception,&(*image)->exception); |
| 3121 | break; |
| 3122 | } |
| 3123 | break; |
| 3124 | } |
| 3125 | default: |
| 3126 | break; |
| 3127 | } |
| 3128 | /* |
| 3129 | Replace current image with any image that was generated |
| 3130 | */ |
| 3131 | if (mogrify_image != (Image *) NULL) |
| 3132 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3133 | i+=count; |
| 3134 | } |
| 3135 | if (region_image != (Image *) NULL) |
| 3136 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3137 | /* |
| 3138 | Composite transformed region onto image. |
| 3139 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3140 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3141 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3142 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 3143 | region_geometry.x,region_geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3144 | InheritException(exception,®ion_image->exception); |
| 3145 | *image=DestroyImage(*image); |
| 3146 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3147 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3148 | } |
| 3149 | /* |
| 3150 | Free resources. |
| 3151 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3152 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3153 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3154 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 3155 | status=(MagickStatusType) ((*image)->exception.severity == |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 3156 | UndefinedException ? 1 : 0); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3157 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3158 | } |
| 3159 | |
| 3160 | /* |
| 3161 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3162 | % % |
| 3163 | % % |
| 3164 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3165 | + 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] | 3166 | % % |
| 3167 | % % |
| 3168 | % % |
| 3169 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3170 | % |
| 3171 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3172 | % transforms include image scaling, image rotation, color reduction, and |
| 3173 | % others. The transmogrified image overwrites the original image. |
| 3174 | % |
| 3175 | % The format of the MogrifyImageCommand method is: |
| 3176 | % |
| 3177 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3178 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3179 | % |
| 3180 | % A description of each parameter follows: |
| 3181 | % |
| 3182 | % o image_info: the image info. |
| 3183 | % |
| 3184 | % o argc: the number of elements in the argument vector. |
| 3185 | % |
| 3186 | % o argv: A text array containing the command line arguments. |
| 3187 | % |
| 3188 | % o metadata: any metadata is returned here. |
| 3189 | % |
| 3190 | % o exception: return any errors or warnings in this structure. |
| 3191 | % |
| 3192 | */ |
| 3193 | |
| 3194 | static MagickBooleanType MogrifyUsage(void) |
| 3195 | { |
| 3196 | static const char |
| 3197 | *miscellaneous[]= |
| 3198 | { |
| 3199 | "-debug events display copious debugging information", |
| 3200 | "-help print program options", |
| 3201 | "-list type print a list of supported option arguments", |
| 3202 | "-log format format of debugging information", |
| 3203 | "-version print version information", |
| 3204 | (char *) NULL |
| 3205 | }, |
| 3206 | *operators[]= |
| 3207 | { |
| 3208 | "-adaptive-blur geometry", |
| 3209 | " adaptively blur pixels; decrease effect near edges", |
| 3210 | "-adaptive-resize geometry", |
| 3211 | " adaptively resize image using 'mesh' interpolation", |
| 3212 | "-adaptive-sharpen geometry", |
| 3213 | " adaptively sharpen pixels; increase effect near edges", |
| 3214 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3215 | " transparent, extract, background, or shape", |
| 3216 | "-annotate geometry text", |
| 3217 | " annotate the image with text", |
| 3218 | "-auto-gamma automagically adjust gamma level of image", |
| 3219 | "-auto-level automagically adjust color levels of image", |
| 3220 | "-auto-orient automagically orient (rotate) image", |
| 3221 | "-bench iterations measure performance", |
| 3222 | "-black-threshold value", |
| 3223 | " force all pixels below the threshold into black", |
| 3224 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3225 | "-blur geometry reduce image noise and reduce detail levels", |
| 3226 | "-border geometry surround image with a border of color", |
| 3227 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3228 | "-brightness-contrast geometry", |
| 3229 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3230 | "-cdl filename color correct with a color decision list", |
| 3231 | "-charcoal radius simulate a charcoal drawing", |
| 3232 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3233 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3234 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3235 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3236 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3237 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3238 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3239 | "-contrast enhance or reduce the image contrast", |
| 3240 | "-contrast-stretch geometry", |
| 3241 | " improve contrast by `stretching' the intensity range", |
| 3242 | "-convolve coefficients", |
| 3243 | " apply a convolution kernel to the image", |
| 3244 | "-cycle amount cycle the image colormap", |
| 3245 | "-decipher filename convert cipher pixels to plain pixels", |
| 3246 | "-deskew threshold straighten an image", |
| 3247 | "-despeckle reduce the speckles within an image", |
| 3248 | "-distort method args", |
| 3249 | " distort images according to given method ad args", |
| 3250 | "-draw string annotate the image with a graphic primitive", |
| 3251 | "-edge radius apply a filter to detect edges in the image", |
| 3252 | "-encipher filename convert plain pixels to cipher pixels", |
| 3253 | "-emboss radius emboss an image", |
| 3254 | "-enhance apply a digital filter to enhance a noisy image", |
| 3255 | "-equalize perform histogram equalization to an image", |
| 3256 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3257 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3258 | "-extent geometry set the image size", |
| 3259 | "-extract geometry extract area from image", |
| 3260 | "-fft implements the discrete Fourier transform (DFT)", |
| 3261 | "-flip flip image vertically", |
| 3262 | "-floodfill geometry color", |
| 3263 | " floodfill the image with color", |
| 3264 | "-flop flop image horizontally", |
| 3265 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3266 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3267 | " apply function over image values", |
| 3268 | "-gamma value level of gamma correction", |
| 3269 | "-gaussian-blur geometry", |
| 3270 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3271 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3272 | "-identify identify the format and characteristics of the image", |
| 3273 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3274 | "-implode amount implode image pixels about the center", |
| 3275 | "-lat geometry local adaptive thresholding", |
| 3276 | "-layers method optimize, merge, or compare image layers", |
| 3277 | "-level value adjust the level of image contrast", |
| 3278 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3279 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3280 | "-linear-stretch geometry", |
| 3281 | " improve contrast by `stretching with saturation'", |
| 3282 | "-liquid-rescale geometry", |
| 3283 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3284 | "-median geometry apply a median filter to the image", |
glennrp | 30d2dc6 | 2011-06-25 03:17:16 +0000 | [diff] [blame] | 3285 | "-mode geometry make each pixel the 'predominant color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3286 | "-modulate value vary the brightness, saturation, and hue", |
| 3287 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3288 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3289 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3290 | "-motion-blur geometry", |
| 3291 | " simulate motion blur", |
| 3292 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3293 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3294 | "-normalize transform image to span the full range of colors", |
| 3295 | "-opaque color change this color to the fill color", |
| 3296 | "-ordered-dither NxN", |
| 3297 | " add a noise pattern to the image with specific", |
| 3298 | " amplitudes", |
| 3299 | "-paint radius simulate an oil painting", |
| 3300 | "-polaroid angle simulate a Polaroid picture", |
| 3301 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3302 | "-profile filename add, delete, or apply an image profile", |
| 3303 | "-quantize colorspace reduce colors in this colorspace", |
| 3304 | "-radial-blur angle radial blur the image", |
| 3305 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3306 | "-random-threshold low,high", |
| 3307 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3308 | "-region geometry apply options to a portion of the image", |
| 3309 | "-render render vector graphics", |
| 3310 | "-repage geometry size and location of an image canvas", |
| 3311 | "-resample geometry change the resolution of an image", |
| 3312 | "-resize geometry resize the image", |
| 3313 | "-roll geometry roll an image vertically or horizontally", |
| 3314 | "-rotate degrees apply Paeth rotation to the image", |
| 3315 | "-sample geometry scale image with pixel sampling", |
| 3316 | "-scale geometry scale the image", |
| 3317 | "-segment values segment an image", |
| 3318 | "-selective-blur geometry", |
| 3319 | " selectively blur pixels within a contrast threshold", |
| 3320 | "-sepia-tone threshold", |
| 3321 | " simulate a sepia-toned photo", |
| 3322 | "-set property value set an image property", |
| 3323 | "-shade degrees shade the image using a distant light source", |
| 3324 | "-shadow geometry simulate an image shadow", |
| 3325 | "-sharpen geometry sharpen the image", |
| 3326 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3327 | "-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] | 3328 | "-sigmoidal-contrast geometry", |
| 3329 | " increase the contrast without saturating highlights or shadows", |
| 3330 | "-sketch geometry simulate a pencil sketch", |
| 3331 | "-solarize threshold negate all pixels above the threshold level", |
| 3332 | "-sparse-color method args", |
| 3333 | " fill in a image based on a few color points", |
| 3334 | "-splice geometry splice the background color into the image", |
| 3335 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3336 | "-statistic type radius", |
| 3337 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3338 | "-strip strip image of all profiles and comments", |
| 3339 | "-swirl degrees swirl image pixels about the center", |
| 3340 | "-threshold value threshold the image", |
| 3341 | "-thumbnail geometry create a thumbnail of the image", |
| 3342 | "-tile filename tile image when filling a graphic primitive", |
| 3343 | "-tint value tint the image with the fill color", |
| 3344 | "-transform affine transform image", |
| 3345 | "-transparent color make this color transparent within the image", |
| 3346 | "-transpose flip image vertically and rotate 90 degrees", |
| 3347 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3348 | "-trim trim image edges", |
| 3349 | "-type type image type", |
| 3350 | "-unique-colors discard all but one of any pixel color", |
| 3351 | "-unsharp geometry sharpen the image", |
| 3352 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3353 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3354 | "-white-threshold value", |
| 3355 | " force all pixels above the threshold into white", |
| 3356 | (char *) NULL |
| 3357 | }, |
| 3358 | *sequence_operators[]= |
| 3359 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3360 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3361 | "-clut apply a color lookup table to the image", |
| 3362 | "-coalesce merge a sequence of images", |
| 3363 | "-combine combine a sequence of images", |
| 3364 | "-composite composite image", |
| 3365 | "-crop geometry cut out a rectangular region of the image", |
| 3366 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3367 | "-evaluate-sequence operator", |
| 3368 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3369 | "-flatten flatten a sequence of images", |
| 3370 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3371 | "-hald-clut apply a Hald color lookup table to the image", |
| 3372 | "-morph value morph an image sequence", |
| 3373 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3374 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3375 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3376 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3377 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3378 | "-write filename write images to this file", |
| 3379 | (char *) NULL |
| 3380 | }, |
| 3381 | *settings[]= |
| 3382 | { |
| 3383 | "-adjoin join images into a single multi-image file", |
| 3384 | "-affine matrix affine transform matrix", |
| 3385 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3386 | "-antialias remove pixel-aliasing", |
| 3387 | "-authenticate password", |
| 3388 | " decipher image with this password", |
| 3389 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3390 | "-background color background color", |
| 3391 | "-bias value add bias when convolving an image", |
| 3392 | "-black-point-compensation", |
| 3393 | " use black point compensation", |
| 3394 | "-blue-primary point chromaticity blue primary point", |
| 3395 | "-bordercolor color border color", |
| 3396 | "-caption string assign a caption to an image", |
| 3397 | "-channel type apply option to select image channels", |
| 3398 | "-colors value preferred number of colors in the image", |
| 3399 | "-colorspace type alternate image colorspace", |
| 3400 | "-comment string annotate image with comment", |
| 3401 | "-compose operator set image composite operator", |
| 3402 | "-compress type type of pixel compression when writing the image", |
| 3403 | "-define format:option", |
| 3404 | " define one or more image format options", |
| 3405 | "-delay value display the next image after pausing", |
| 3406 | "-density geometry horizontal and vertical density of the image", |
| 3407 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3408 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3409 | "-display server get image or font from this X server", |
| 3410 | "-dispose method layer disposal method", |
| 3411 | "-dither method apply error diffusion to image", |
| 3412 | "-encoding type text encoding type", |
| 3413 | "-endian type endianness (MSB or LSB) of the image", |
| 3414 | "-family name render text with this font family", |
| 3415 | "-fill color color to use when filling a graphic primitive", |
| 3416 | "-filter type use this filter when resizing an image", |
| 3417 | "-font name render text with this font", |
| 3418 | "-format \"string\" output formatted image characteristics", |
| 3419 | "-fuzz distance colors within this distance are considered equal", |
| 3420 | "-gravity type horizontal and vertical text placement", |
| 3421 | "-green-primary point chromaticity green primary point", |
| 3422 | "-intent type type of rendering intent when managing the image color", |
| 3423 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3424 | "-interline-spacing value", |
| 3425 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3426 | "-interpolate method pixel color interpolation method", |
| 3427 | "-interword-spacing value", |
| 3428 | " set the space between two words", |
| 3429 | "-kerning value set the space between two letters", |
| 3430 | "-label string assign a label to an image", |
| 3431 | "-limit type value pixel cache resource limit", |
| 3432 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3433 | "-mask filename associate a mask with the image", |
| 3434 | "-mattecolor color frame color", |
| 3435 | "-monitor monitor progress", |
| 3436 | "-orient type image orientation", |
| 3437 | "-page geometry size and location of an image canvas (setting)", |
| 3438 | "-ping efficiently determine image attributes", |
| 3439 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3440 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3441 | "-preview type image preview type", |
| 3442 | "-quality value JPEG/MIFF/PNG compression level", |
| 3443 | "-quiet suppress all warning messages", |
| 3444 | "-red-primary point chromaticity red primary point", |
| 3445 | "-regard-warnings pay attention to warning messages", |
| 3446 | "-remap filename transform image colors to match this set of colors", |
| 3447 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3448 | "-sampling-factor geometry", |
| 3449 | " horizontal and vertical sampling factor", |
| 3450 | "-scene value image scene number", |
| 3451 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3452 | "-size geometry width and height of image", |
| 3453 | "-stretch type render text with this font stretch", |
| 3454 | "-stroke color graphic primitive stroke color", |
| 3455 | "-strokewidth value graphic primitive stroke width", |
| 3456 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3457 | "-synchronize synchronize image to storage device", |
| 3458 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3459 | "-texture filename name of texture to tile onto the image background", |
| 3460 | "-tile-offset geometry", |
| 3461 | " tile offset", |
| 3462 | "-treedepth value color tree depth", |
| 3463 | "-transparent-color color", |
| 3464 | " transparent color", |
| 3465 | "-undercolor color annotation bounding box color", |
| 3466 | "-units type the units of image resolution", |
| 3467 | "-verbose print detailed information about the image", |
| 3468 | "-view FlashPix viewing transforms", |
| 3469 | "-virtual-pixel method", |
| 3470 | " virtual pixel access method", |
| 3471 | "-weight type render text with this font weight", |
| 3472 | "-white-point point chromaticity white point", |
| 3473 | (char *) NULL |
| 3474 | }, |
| 3475 | *stack_operators[]= |
| 3476 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3477 | "-delete indexes delete the image from the image sequence", |
| 3478 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3479 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3480 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3481 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3482 | "-swap indexes swap two images in the image sequence", |
| 3483 | (char *) NULL |
| 3484 | }; |
| 3485 | |
| 3486 | const char |
| 3487 | **p; |
| 3488 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3489 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3490 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3491 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3492 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3493 | GetClientName()); |
| 3494 | (void) printf("\nImage Settings:\n"); |
| 3495 | for (p=settings; *p != (char *) NULL; p++) |
| 3496 | (void) printf(" %s\n",*p); |
| 3497 | (void) printf("\nImage Operators:\n"); |
| 3498 | for (p=operators; *p != (char *) NULL; p++) |
| 3499 | (void) printf(" %s\n",*p); |
| 3500 | (void) printf("\nImage Sequence Operators:\n"); |
| 3501 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3502 | (void) printf(" %s\n",*p); |
| 3503 | (void) printf("\nImage Stack Operators:\n"); |
| 3504 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3505 | (void) printf(" %s\n",*p); |
| 3506 | (void) printf("\nMiscellaneous Options:\n"); |
| 3507 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3508 | (void) printf(" %s\n",*p); |
| 3509 | (void) printf( |
| 3510 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3511 | (void) printf( |
| 3512 | "number. To specify a particular image format, precede the filename\n"); |
| 3513 | (void) printf( |
| 3514 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3515 | (void) printf( |
| 3516 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3517 | (void) printf("'-' for standard input or output.\n"); |
| 3518 | return(MagickFalse); |
| 3519 | } |
| 3520 | |
| 3521 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3522 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3523 | { |
| 3524 | #define DestroyMogrify() \ |
| 3525 | { \ |
| 3526 | if (format != (char *) NULL) \ |
| 3527 | format=DestroyString(format); \ |
| 3528 | if (path != (char *) NULL) \ |
| 3529 | path=DestroyString(path); \ |
| 3530 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3531 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3532 | argv[i]=DestroyString(argv[i]); \ |
| 3533 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3534 | } |
| 3535 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3536 | { \ |
| 3537 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3538 | option); \ |
| 3539 | DestroyMogrify(); \ |
| 3540 | return(MagickFalse); \ |
| 3541 | } |
| 3542 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3543 | { \ |
| 3544 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3545 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3546 | DestroyMogrify(); \ |
| 3547 | return(MagickFalse); \ |
| 3548 | } |
| 3549 | |
| 3550 | char |
| 3551 | *format, |
| 3552 | *option, |
| 3553 | *path; |
| 3554 | |
| 3555 | Image |
| 3556 | *image; |
| 3557 | |
| 3558 | ImageStack |
| 3559 | image_stack[MaxImageStackDepth+1]; |
| 3560 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3561 | MagickBooleanType |
| 3562 | global_colormap; |
| 3563 | |
| 3564 | MagickBooleanType |
| 3565 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3566 | pend, |
| 3567 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3568 | |
| 3569 | MagickStatusType |
| 3570 | status; |
| 3571 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3572 | register ssize_t |
| 3573 | i; |
| 3574 | |
| 3575 | ssize_t |
| 3576 | j, |
| 3577 | k; |
| 3578 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3579 | /* |
| 3580 | Set defaults. |
| 3581 | */ |
| 3582 | assert(image_info != (ImageInfo *) NULL); |
| 3583 | assert(image_info->signature == MagickSignature); |
| 3584 | if (image_info->debug != MagickFalse) |
| 3585 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3586 | assert(exception != (ExceptionInfo *) NULL); |
| 3587 | if (argc == 2) |
| 3588 | { |
| 3589 | option=argv[1]; |
| 3590 | if ((LocaleCompare("version",option+1) == 0) || |
| 3591 | (LocaleCompare("-version",option+1) == 0)) |
| 3592 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3593 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3594 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 3595 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 3596 | GetMagickCopyright()); |
| 3597 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 3598 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3599 | return(MagickFalse); |
| 3600 | } |
| 3601 | } |
| 3602 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3603 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3604 | format=(char *) NULL; |
| 3605 | path=(char *) NULL; |
| 3606 | global_colormap=MagickFalse; |
| 3607 | k=0; |
| 3608 | j=1; |
| 3609 | NewImageStack(); |
| 3610 | option=(char *) NULL; |
| 3611 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3612 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3613 | status=MagickTrue; |
| 3614 | /* |
| 3615 | Parse command line. |
| 3616 | */ |
| 3617 | ReadCommandlLine(argc,&argv); |
| 3618 | status=ExpandFilenames(&argc,&argv); |
| 3619 | if (status == MagickFalse) |
| 3620 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3621 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3622 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3623 | { |
| 3624 | option=argv[i]; |
| 3625 | if (LocaleCompare(option,"(") == 0) |
| 3626 | { |
| 3627 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3628 | if (k == MaxImageStackDepth) |
| 3629 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3630 | option); |
| 3631 | PushImageStack(); |
| 3632 | continue; |
| 3633 | } |
| 3634 | if (LocaleCompare(option,")") == 0) |
| 3635 | { |
| 3636 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3637 | if (k == 0) |
| 3638 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3639 | PopImageStack(); |
| 3640 | continue; |
| 3641 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3642 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3643 | { |
| 3644 | char |
| 3645 | backup_filename[MaxTextExtent], |
| 3646 | *filename; |
| 3647 | |
| 3648 | Image |
| 3649 | *images; |
| 3650 | |
| 3651 | /* |
| 3652 | Option is a file name: begin by reading image from specified file. |
| 3653 | */ |
| 3654 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3655 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3656 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3657 | filename=argv[++i]; |
| 3658 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 3659 | images=ReadImages(image_info,exception); |
| 3660 | status&=(images != (Image *) NULL) && |
| 3661 | (exception->severity < ErrorException); |
| 3662 | if (images == (Image *) NULL) |
| 3663 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3664 | if (format != (char *) NULL) |
| 3665 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3666 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3667 | if (path != (char *) NULL) |
| 3668 | { |
| 3669 | GetPathComponent(option,TailPath,filename); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3670 | (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3671 | path,*DirectorySeparator,filename); |
| 3672 | } |
| 3673 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3674 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3675 | AppendImageStack(images); |
| 3676 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3677 | if (global_colormap != MagickFalse) |
| 3678 | { |
| 3679 | QuantizeInfo |
| 3680 | *quantize_info; |
| 3681 | |
| 3682 | quantize_info=AcquireQuantizeInfo(image_info); |
| 3683 | (void) RemapImages(quantize_info,images,(Image *) NULL); |
| 3684 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3685 | } |
| 3686 | *backup_filename='\0'; |
| 3687 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3688 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3689 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3690 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3691 | i; |
| 3692 | |
| 3693 | /* |
| 3694 | Rename image file as backup. |
| 3695 | */ |
| 3696 | (void) CopyMagickString(backup_filename,image->filename, |
| 3697 | MaxTextExtent); |
| 3698 | for (i=0; i < 6; i++) |
| 3699 | { |
| 3700 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3701 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3702 | break; |
| 3703 | } |
| 3704 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
| 3705 | (rename(image->filename,backup_filename) != 0)) |
| 3706 | *backup_filename='\0'; |
| 3707 | } |
| 3708 | /* |
| 3709 | Write transmogrified image to disk. |
| 3710 | */ |
| 3711 | image_info->synchronize=MagickTrue; |
| 3712 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3713 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
| 3714 | (void) remove(backup_filename); |
| 3715 | RemoveAllImageStack(); |
| 3716 | continue; |
| 3717 | } |
| 3718 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3719 | switch (*(option+1)) |
| 3720 | { |
| 3721 | case 'a': |
| 3722 | { |
| 3723 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3724 | { |
| 3725 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3726 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3727 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3728 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3729 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3730 | break; |
| 3731 | } |
| 3732 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3733 | { |
| 3734 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3735 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3736 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3737 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3738 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3739 | break; |
| 3740 | } |
| 3741 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3742 | { |
| 3743 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3744 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3745 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3746 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3747 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3748 | break; |
| 3749 | } |
| 3750 | if (LocaleCompare("affine",option+1) == 0) |
| 3751 | { |
| 3752 | if (*option == '+') |
| 3753 | break; |
| 3754 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3755 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3756 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3757 | break; |
| 3758 | } |
| 3759 | if (LocaleCompare("alpha",option+1) == 0) |
| 3760 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3761 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3762 | type; |
| 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 | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3769 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3770 | if (type < 0) |
| 3771 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3772 | argv[i]); |
| 3773 | break; |
| 3774 | } |
| 3775 | if (LocaleCompare("annotate",option+1) == 0) |
| 3776 | { |
| 3777 | if (*option == '+') |
| 3778 | break; |
| 3779 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3780 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3781 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3782 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3783 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3784 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3785 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3786 | i++; |
| 3787 | break; |
| 3788 | } |
| 3789 | if (LocaleCompare("antialias",option+1) == 0) |
| 3790 | break; |
| 3791 | if (LocaleCompare("append",option+1) == 0) |
| 3792 | break; |
| 3793 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3794 | { |
| 3795 | if (*option == '+') |
| 3796 | break; |
| 3797 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3798 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3799 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3800 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3801 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3802 | break; |
| 3803 | } |
| 3804 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3805 | { |
| 3806 | if (*option == '+') |
| 3807 | break; |
| 3808 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3809 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3810 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3811 | break; |
| 3812 | } |
| 3813 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3814 | break; |
| 3815 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3816 | break; |
| 3817 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3818 | break; |
| 3819 | if (LocaleCompare("average",option+1) == 0) |
| 3820 | break; |
| 3821 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3822 | } |
| 3823 | case 'b': |
| 3824 | { |
| 3825 | if (LocaleCompare("background",option+1) == 0) |
| 3826 | { |
| 3827 | if (*option == '+') |
| 3828 | break; |
| 3829 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3830 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3831 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3832 | break; |
| 3833 | } |
| 3834 | if (LocaleCompare("bias",option+1) == 0) |
| 3835 | { |
| 3836 | if (*option == '+') |
| 3837 | break; |
| 3838 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3839 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3840 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3841 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3842 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3843 | break; |
| 3844 | } |
| 3845 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 3846 | break; |
| 3847 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 3848 | { |
| 3849 | if (*option == '+') |
| 3850 | break; |
| 3851 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3852 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3853 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3854 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3855 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3856 | break; |
| 3857 | } |
| 3858 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3859 | { |
| 3860 | if (*option == '+') |
| 3861 | break; |
| 3862 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3863 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3864 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3865 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3866 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3867 | break; |
| 3868 | } |
| 3869 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3870 | { |
| 3871 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3872 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3873 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3874 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3875 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3876 | break; |
| 3877 | } |
| 3878 | if (LocaleCompare("blur",option+1) == 0) |
| 3879 | { |
| 3880 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3881 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3882 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3883 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3884 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3885 | break; |
| 3886 | } |
| 3887 | if (LocaleCompare("border",option+1) == 0) |
| 3888 | { |
| 3889 | if (*option == '+') |
| 3890 | break; |
| 3891 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3892 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3893 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3894 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3895 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3896 | break; |
| 3897 | } |
| 3898 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3899 | { |
| 3900 | if (*option == '+') |
| 3901 | break; |
| 3902 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3903 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3904 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3905 | break; |
| 3906 | } |
| 3907 | if (LocaleCompare("box",option+1) == 0) |
| 3908 | { |
| 3909 | if (*option == '+') |
| 3910 | break; |
| 3911 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3912 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3913 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3914 | break; |
| 3915 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3916 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 3917 | { |
| 3918 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3919 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3920 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3921 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3922 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3923 | break; |
| 3924 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3925 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3926 | } |
| 3927 | case 'c': |
| 3928 | { |
| 3929 | if (LocaleCompare("cache",option+1) == 0) |
| 3930 | { |
| 3931 | if (*option == '+') |
| 3932 | break; |
| 3933 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3934 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3935 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3936 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3937 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3938 | break; |
| 3939 | } |
| 3940 | if (LocaleCompare("caption",option+1) == 0) |
| 3941 | { |
| 3942 | if (*option == '+') |
| 3943 | break; |
| 3944 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3945 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3946 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3947 | break; |
| 3948 | } |
| 3949 | if (LocaleCompare("channel",option+1) == 0) |
| 3950 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3951 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3952 | channel; |
| 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-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3958 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3959 | channel=ParseChannelOption(argv[i]); |
| 3960 | if (channel < 0) |
| 3961 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 3962 | argv[i]); |
| 3963 | break; |
| 3964 | } |
| 3965 | if (LocaleCompare("cdl",option+1) == 0) |
| 3966 | { |
| 3967 | if (*option == '+') |
| 3968 | break; |
| 3969 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3970 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3971 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3972 | break; |
| 3973 | } |
| 3974 | if (LocaleCompare("charcoal",option+1) == 0) |
| 3975 | { |
| 3976 | if (*option == '+') |
| 3977 | break; |
| 3978 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3979 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3980 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3981 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3982 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3983 | break; |
| 3984 | } |
| 3985 | if (LocaleCompare("chop",option+1) == 0) |
| 3986 | { |
| 3987 | if (*option == '+') |
| 3988 | break; |
| 3989 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3990 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3991 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3992 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3993 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3994 | break; |
| 3995 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 3996 | if (LocaleCompare("clamp",option+1) == 0) |
| 3997 | break; |
| 3998 | if (LocaleCompare("clip",option+1) == 0) |
| 3999 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4000 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4001 | { |
| 4002 | if (*option == '+') |
| 4003 | break; |
| 4004 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4005 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4006 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4007 | break; |
| 4008 | } |
| 4009 | if (LocaleCompare("clut",option+1) == 0) |
| 4010 | break; |
| 4011 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4012 | break; |
| 4013 | if (LocaleCompare("colorize",option+1) == 0) |
| 4014 | { |
| 4015 | if (*option == '+') |
| 4016 | break; |
| 4017 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4018 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4019 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4020 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4021 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4022 | break; |
| 4023 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4024 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4025 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4026 | KernelInfo |
| 4027 | *kernel_info; |
| 4028 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4029 | if (*option == '+') |
| 4030 | break; |
| 4031 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4032 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4033 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4034 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4035 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4036 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4037 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4038 | break; |
| 4039 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4040 | if (LocaleCompare("colors",option+1) == 0) |
| 4041 | { |
| 4042 | if (*option == '+') |
| 4043 | break; |
| 4044 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4045 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4046 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4047 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4048 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4049 | break; |
| 4050 | } |
| 4051 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4052 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4053 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4054 | colorspace; |
| 4055 | |
| 4056 | if (*option == '+') |
| 4057 | break; |
| 4058 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4059 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4060 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4061 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4062 | argv[i]); |
| 4063 | if (colorspace < 0) |
| 4064 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4065 | argv[i]); |
| 4066 | break; |
| 4067 | } |
| 4068 | if (LocaleCompare("combine",option+1) == 0) |
| 4069 | break; |
| 4070 | if (LocaleCompare("comment",option+1) == 0) |
| 4071 | { |
| 4072 | if (*option == '+') |
| 4073 | break; |
| 4074 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4075 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4076 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4077 | break; |
| 4078 | } |
| 4079 | if (LocaleCompare("composite",option+1) == 0) |
| 4080 | break; |
| 4081 | if (LocaleCompare("compress",option+1) == 0) |
| 4082 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4083 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4084 | compress; |
| 4085 | |
| 4086 | if (*option == '+') |
| 4087 | break; |
| 4088 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4089 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4090 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4091 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4092 | argv[i]); |
| 4093 | if (compress < 0) |
| 4094 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4095 | argv[i]); |
| 4096 | break; |
| 4097 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4098 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4099 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4100 | if (LocaleCompare("contrast",option+1) == 0) |
| 4101 | break; |
| 4102 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4103 | { |
| 4104 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4105 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4106 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4107 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4108 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4109 | break; |
| 4110 | } |
| 4111 | if (LocaleCompare("convolve",option+1) == 0) |
| 4112 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4113 | KernelInfo |
| 4114 | *kernel_info; |
| 4115 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4116 | if (*option == '+') |
| 4117 | break; |
| 4118 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4119 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4120 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4121 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4122 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4123 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4124 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4125 | break; |
| 4126 | } |
| 4127 | if (LocaleCompare("crop",option+1) == 0) |
| 4128 | { |
| 4129 | if (*option == '+') |
| 4130 | break; |
| 4131 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4132 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4133 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4134 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4135 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4136 | break; |
| 4137 | } |
| 4138 | if (LocaleCompare("cycle",option+1) == 0) |
| 4139 | { |
| 4140 | if (*option == '+') |
| 4141 | break; |
| 4142 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4143 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4144 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4145 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4146 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4147 | break; |
| 4148 | } |
| 4149 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4150 | } |
| 4151 | case 'd': |
| 4152 | { |
| 4153 | if (LocaleCompare("decipher",option+1) == 0) |
| 4154 | { |
| 4155 | if (*option == '+') |
| 4156 | break; |
| 4157 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4158 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4159 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4160 | break; |
| 4161 | } |
| 4162 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4163 | break; |
| 4164 | if (LocaleCompare("debug",option+1) == 0) |
| 4165 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4166 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4167 | event; |
| 4168 | |
| 4169 | if (*option == '+') |
| 4170 | break; |
| 4171 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4172 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4173 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4174 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4175 | if (event < 0) |
| 4176 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4177 | argv[i]); |
| 4178 | (void) SetLogEventMask(argv[i]); |
| 4179 | break; |
| 4180 | } |
| 4181 | if (LocaleCompare("define",option+1) == 0) |
| 4182 | { |
| 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); |
| 4186 | if (*option == '+') |
| 4187 | { |
| 4188 | const char |
| 4189 | *define; |
| 4190 | |
| 4191 | define=GetImageOption(image_info,argv[i]); |
| 4192 | if (define == (const char *) NULL) |
| 4193 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4194 | break; |
| 4195 | } |
| 4196 | break; |
| 4197 | } |
| 4198 | if (LocaleCompare("delay",option+1) == 0) |
| 4199 | { |
| 4200 | if (*option == '+') |
| 4201 | break; |
| 4202 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4203 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4204 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4205 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4206 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4207 | break; |
| 4208 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4209 | if (LocaleCompare("delete",option+1) == 0) |
| 4210 | { |
| 4211 | if (*option == '+') |
| 4212 | break; |
| 4213 | i++; |
| 4214 | if (i == (ssize_t) (argc-1)) |
| 4215 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4216 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4217 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4218 | break; |
| 4219 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4220 | if (LocaleCompare("density",option+1) == 0) |
| 4221 | { |
| 4222 | if (*option == '+') |
| 4223 | break; |
| 4224 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4225 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4226 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4227 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4228 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4229 | break; |
| 4230 | } |
| 4231 | if (LocaleCompare("depth",option+1) == 0) |
| 4232 | { |
| 4233 | if (*option == '+') |
| 4234 | break; |
| 4235 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4236 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4237 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4238 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4239 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4240 | break; |
| 4241 | } |
| 4242 | if (LocaleCompare("deskew",option+1) == 0) |
| 4243 | { |
| 4244 | if (*option == '+') |
| 4245 | break; |
| 4246 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4247 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4248 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4249 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4250 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4251 | break; |
| 4252 | } |
| 4253 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4254 | break; |
| 4255 | if (LocaleCompare("dft",option+1) == 0) |
| 4256 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4257 | if (LocaleCompare("direction",option+1) == 0) |
| 4258 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4259 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4260 | direction; |
| 4261 | |
| 4262 | if (*option == '+') |
| 4263 | break; |
| 4264 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4265 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4266 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4267 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4268 | argv[i]); |
| 4269 | if (direction < 0) |
| 4270 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4271 | argv[i]); |
| 4272 | break; |
| 4273 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4274 | if (LocaleCompare("display",option+1) == 0) |
| 4275 | { |
| 4276 | if (*option == '+') |
| 4277 | break; |
| 4278 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4279 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4280 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4281 | break; |
| 4282 | } |
| 4283 | if (LocaleCompare("dispose",option+1) == 0) |
| 4284 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4285 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4286 | dispose; |
| 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); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4293 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4294 | if (dispose < 0) |
| 4295 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4296 | argv[i]); |
| 4297 | break; |
| 4298 | } |
| 4299 | if (LocaleCompare("distort",option+1) == 0) |
| 4300 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4301 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4302 | op; |
| 4303 | |
| 4304 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4305 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4306 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4307 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4308 | if (op < 0) |
| 4309 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4310 | argv[i]); |
| 4311 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4312 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4313 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4314 | break; |
| 4315 | } |
| 4316 | if (LocaleCompare("dither",option+1) == 0) |
| 4317 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4318 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4319 | method; |
| 4320 | |
| 4321 | if (*option == '+') |
| 4322 | break; |
| 4323 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4324 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4325 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4326 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4327 | if (method < 0) |
| 4328 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4329 | argv[i]); |
| 4330 | break; |
| 4331 | } |
| 4332 | if (LocaleCompare("draw",option+1) == 0) |
| 4333 | { |
| 4334 | if (*option == '+') |
| 4335 | break; |
| 4336 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4337 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4338 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4339 | break; |
| 4340 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4341 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4342 | { |
| 4343 | if (*option == '+') |
| 4344 | break; |
| 4345 | i++; |
| 4346 | if (i == (ssize_t) (argc-1)) |
| 4347 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4348 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4349 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4350 | break; |
| 4351 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4352 | if (LocaleCompare("duration",option+1) == 0) |
| 4353 | { |
| 4354 | if (*option == '+') |
| 4355 | break; |
| 4356 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4357 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4358 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4359 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4360 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4361 | break; |
| 4362 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4363 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4364 | } |
| 4365 | case 'e': |
| 4366 | { |
| 4367 | if (LocaleCompare("edge",option+1) == 0) |
| 4368 | { |
| 4369 | if (*option == '+') |
| 4370 | break; |
| 4371 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4372 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4373 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4374 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4375 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4376 | break; |
| 4377 | } |
| 4378 | if (LocaleCompare("emboss",option+1) == 0) |
| 4379 | { |
| 4380 | if (*option == '+') |
| 4381 | break; |
| 4382 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4383 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4384 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4385 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4386 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4387 | break; |
| 4388 | } |
| 4389 | if (LocaleCompare("encipher",option+1) == 0) |
| 4390 | { |
| 4391 | if (*option == '+') |
| 4392 | break; |
| 4393 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4394 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4395 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4396 | break; |
| 4397 | } |
| 4398 | if (LocaleCompare("encoding",option+1) == 0) |
| 4399 | { |
| 4400 | if (*option == '+') |
| 4401 | break; |
| 4402 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4403 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4404 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4405 | break; |
| 4406 | } |
| 4407 | if (LocaleCompare("endian",option+1) == 0) |
| 4408 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4409 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4410 | endian; |
| 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); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4417 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4418 | if (endian < 0) |
| 4419 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4420 | argv[i]); |
| 4421 | break; |
| 4422 | } |
| 4423 | if (LocaleCompare("enhance",option+1) == 0) |
| 4424 | break; |
| 4425 | if (LocaleCompare("equalize",option+1) == 0) |
| 4426 | break; |
| 4427 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4428 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4429 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4430 | op; |
| 4431 | |
| 4432 | if (*option == '+') |
| 4433 | break; |
| 4434 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4435 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4436 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4437 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4438 | if (op < 0) |
| 4439 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4440 | argv[i]); |
| 4441 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4442 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4443 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4444 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4445 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4446 | break; |
| 4447 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4448 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4449 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4450 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4451 | op; |
| 4452 | |
| 4453 | if (*option == '+') |
| 4454 | break; |
| 4455 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4456 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4457 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4458 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4459 | if (op < 0) |
| 4460 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4461 | argv[i]); |
| 4462 | break; |
| 4463 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4464 | if (LocaleCompare("extent",option+1) == 0) |
| 4465 | { |
| 4466 | if (*option == '+') |
| 4467 | break; |
| 4468 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4469 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4470 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4471 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4472 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4473 | break; |
| 4474 | } |
| 4475 | if (LocaleCompare("extract",option+1) == 0) |
| 4476 | { |
| 4477 | if (*option == '+') |
| 4478 | break; |
| 4479 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4480 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4481 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4482 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4483 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4484 | break; |
| 4485 | } |
| 4486 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4487 | } |
| 4488 | case 'f': |
| 4489 | { |
| 4490 | if (LocaleCompare("family",option+1) == 0) |
| 4491 | { |
| 4492 | if (*option == '+') |
| 4493 | break; |
| 4494 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4495 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4496 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4497 | break; |
| 4498 | } |
| 4499 | if (LocaleCompare("fill",option+1) == 0) |
| 4500 | { |
| 4501 | if (*option == '+') |
| 4502 | break; |
| 4503 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4504 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4505 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4506 | break; |
| 4507 | } |
| 4508 | if (LocaleCompare("filter",option+1) == 0) |
| 4509 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4510 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4511 | filter; |
| 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); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4518 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4519 | if (filter < 0) |
| 4520 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4521 | argv[i]); |
| 4522 | break; |
| 4523 | } |
| 4524 | if (LocaleCompare("flatten",option+1) == 0) |
| 4525 | break; |
| 4526 | if (LocaleCompare("flip",option+1) == 0) |
| 4527 | break; |
| 4528 | if (LocaleCompare("flop",option+1) == 0) |
| 4529 | break; |
| 4530 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4531 | { |
| 4532 | if (*option == '+') |
| 4533 | break; |
| 4534 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4535 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4536 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4537 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4538 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4539 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4540 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4541 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4542 | break; |
| 4543 | } |
| 4544 | if (LocaleCompare("font",option+1) == 0) |
| 4545 | { |
| 4546 | if (*option == '+') |
| 4547 | break; |
| 4548 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4549 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4550 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4551 | break; |
| 4552 | } |
| 4553 | if (LocaleCompare("format",option+1) == 0) |
| 4554 | { |
| 4555 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4556 | (void) CloneString(&format,(char *) NULL); |
| 4557 | if (*option == '+') |
| 4558 | break; |
| 4559 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4560 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4561 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4562 | (void) CloneString(&format,argv[i]); |
| 4563 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4564 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4565 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4566 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4567 | if (*image_info->magick == '\0') |
| 4568 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4569 | format); |
| 4570 | break; |
| 4571 | } |
| 4572 | if (LocaleCompare("frame",option+1) == 0) |
| 4573 | { |
| 4574 | if (*option == '+') |
| 4575 | break; |
| 4576 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4577 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4578 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4579 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4580 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4581 | break; |
| 4582 | } |
| 4583 | if (LocaleCompare("function",option+1) == 0) |
| 4584 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4585 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4586 | op; |
| 4587 | |
| 4588 | if (*option == '+') |
| 4589 | break; |
| 4590 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4591 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4592 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4593 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4594 | if (op < 0) |
| 4595 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4596 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4597 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4598 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4599 | break; |
| 4600 | } |
| 4601 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4602 | { |
| 4603 | if (*option == '+') |
| 4604 | break; |
| 4605 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4606 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4607 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4608 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4609 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4610 | break; |
| 4611 | } |
| 4612 | if (LocaleCompare("fx",option+1) == 0) |
| 4613 | { |
| 4614 | if (*option == '+') |
| 4615 | break; |
| 4616 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4617 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4618 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4619 | break; |
| 4620 | } |
| 4621 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4622 | } |
| 4623 | case 'g': |
| 4624 | { |
| 4625 | if (LocaleCompare("gamma",option+1) == 0) |
| 4626 | { |
| 4627 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4628 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4629 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4630 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4631 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4632 | break; |
| 4633 | } |
| 4634 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4635 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4636 | { |
| 4637 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4638 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4639 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4640 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4641 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4642 | break; |
| 4643 | } |
| 4644 | if (LocaleCompare("geometry",option+1) == 0) |
| 4645 | { |
| 4646 | if (*option == '+') |
| 4647 | break; |
| 4648 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4649 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4650 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4651 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4652 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4653 | break; |
| 4654 | } |
| 4655 | if (LocaleCompare("gravity",option+1) == 0) |
| 4656 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4657 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4658 | gravity; |
| 4659 | |
| 4660 | if (*option == '+') |
| 4661 | break; |
| 4662 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4663 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4664 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4665 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4666 | if (gravity < 0) |
| 4667 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4668 | argv[i]); |
| 4669 | break; |
| 4670 | } |
| 4671 | if (LocaleCompare("green-primary",option+1) == 0) |
| 4672 | { |
| 4673 | if (*option == '+') |
| 4674 | break; |
| 4675 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4676 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4677 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4678 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4679 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4680 | break; |
| 4681 | } |
| 4682 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4683 | } |
| 4684 | case 'h': |
| 4685 | { |
| 4686 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4687 | break; |
| 4688 | if ((LocaleCompare("help",option+1) == 0) || |
| 4689 | (LocaleCompare("-help",option+1) == 0)) |
| 4690 | return(MogrifyUsage()); |
| 4691 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4692 | } |
| 4693 | case 'i': |
| 4694 | { |
| 4695 | if (LocaleCompare("identify",option+1) == 0) |
| 4696 | break; |
| 4697 | if (LocaleCompare("idft",option+1) == 0) |
| 4698 | break; |
| 4699 | if (LocaleCompare("implode",option+1) == 0) |
| 4700 | { |
| 4701 | if (*option == '+') |
| 4702 | break; |
| 4703 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4704 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4705 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4706 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4707 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4708 | break; |
| 4709 | } |
| 4710 | if (LocaleCompare("intent",option+1) == 0) |
| 4711 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4712 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4713 | intent; |
| 4714 | |
| 4715 | if (*option == '+') |
| 4716 | break; |
| 4717 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4718 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4719 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4720 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4721 | if (intent < 0) |
| 4722 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4723 | argv[i]); |
| 4724 | break; |
| 4725 | } |
| 4726 | if (LocaleCompare("interlace",option+1) == 0) |
| 4727 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4728 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4729 | interlace; |
| 4730 | |
| 4731 | if (*option == '+') |
| 4732 | break; |
| 4733 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4734 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4735 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4736 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4737 | argv[i]); |
| 4738 | if (interlace < 0) |
| 4739 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4740 | argv[i]); |
| 4741 | break; |
| 4742 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4743 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4744 | { |
| 4745 | if (*option == '+') |
| 4746 | break; |
| 4747 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4748 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4749 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4750 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4751 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4752 | break; |
| 4753 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4754 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4755 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4756 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4757 | interpolate; |
| 4758 | |
| 4759 | if (*option == '+') |
| 4760 | break; |
| 4761 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4762 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4763 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4764 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4765 | argv[i]); |
| 4766 | if (interpolate < 0) |
| 4767 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4768 | argv[i]); |
| 4769 | break; |
| 4770 | } |
| 4771 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4772 | { |
| 4773 | if (*option == '+') |
| 4774 | break; |
| 4775 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4776 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4777 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4778 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4779 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4780 | break; |
| 4781 | } |
| 4782 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4783 | } |
| 4784 | case 'k': |
| 4785 | { |
| 4786 | if (LocaleCompare("kerning",option+1) == 0) |
| 4787 | { |
| 4788 | if (*option == '+') |
| 4789 | break; |
| 4790 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4791 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4792 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4793 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4794 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4795 | break; |
| 4796 | } |
| 4797 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4798 | } |
| 4799 | case 'l': |
| 4800 | { |
| 4801 | if (LocaleCompare("label",option+1) == 0) |
| 4802 | { |
| 4803 | if (*option == '+') |
| 4804 | break; |
| 4805 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4806 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4807 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4808 | break; |
| 4809 | } |
| 4810 | if (LocaleCompare("lat",option+1) == 0) |
| 4811 | { |
| 4812 | if (*option == '+') |
| 4813 | break; |
| 4814 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4815 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4816 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4817 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4818 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4819 | } |
| 4820 | if (LocaleCompare("layers",option+1) == 0) |
| 4821 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4822 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4823 | type; |
| 4824 | |
| 4825 | if (*option == '+') |
| 4826 | break; |
| 4827 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4828 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4829 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4830 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4831 | if (type < 0) |
| 4832 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4833 | argv[i]); |
| 4834 | break; |
| 4835 | } |
| 4836 | if (LocaleCompare("level",option+1) == 0) |
| 4837 | { |
| 4838 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4839 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4840 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4841 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4842 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4843 | break; |
| 4844 | } |
| 4845 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4846 | { |
| 4847 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4848 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4849 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4850 | break; |
| 4851 | } |
| 4852 | if (LocaleCompare("linewidth",option+1) == 0) |
| 4853 | { |
| 4854 | if (*option == '+') |
| 4855 | break; |
| 4856 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4857 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4858 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4859 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4860 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4861 | break; |
| 4862 | } |
| 4863 | if (LocaleCompare("limit",option+1) == 0) |
| 4864 | { |
| 4865 | char |
| 4866 | *p; |
| 4867 | |
| 4868 | double |
| 4869 | value; |
| 4870 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4871 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4872 | resource; |
| 4873 | |
| 4874 | if (*option == '+') |
| 4875 | break; |
| 4876 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4877 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4878 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4879 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4880 | argv[i]); |
| 4881 | if (resource < 0) |
| 4882 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4883 | argv[i]); |
| 4884 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4885 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4886 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 4887 | value=InterpretLocaleValue(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4888 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4889 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4890 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4891 | break; |
| 4892 | } |
| 4893 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4894 | { |
| 4895 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4896 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4897 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4898 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4899 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4900 | break; |
| 4901 | } |
| 4902 | if (LocaleCompare("list",option+1) == 0) |
| 4903 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4904 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4905 | list; |
| 4906 | |
| 4907 | if (*option == '+') |
| 4908 | break; |
| 4909 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4910 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4911 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4912 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4913 | if (list < 0) |
| 4914 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4915 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4916 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4917 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4918 | } |
| 4919 | if (LocaleCompare("log",option+1) == 0) |
| 4920 | { |
| 4921 | if (*option == '+') |
| 4922 | break; |
| 4923 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4924 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4925 | (strchr(argv[i],'%') == (char *) NULL)) |
| 4926 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4927 | break; |
| 4928 | } |
| 4929 | if (LocaleCompare("loop",option+1) == 0) |
| 4930 | { |
| 4931 | if (*option == '+') |
| 4932 | break; |
| 4933 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4934 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4935 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4936 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4937 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4938 | break; |
| 4939 | } |
| 4940 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4941 | } |
| 4942 | case 'm': |
| 4943 | { |
| 4944 | if (LocaleCompare("map",option+1) == 0) |
| 4945 | { |
| 4946 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 4947 | if (*option == '+') |
| 4948 | break; |
| 4949 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4950 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4951 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4952 | break; |
| 4953 | } |
| 4954 | if (LocaleCompare("mask",option+1) == 0) |
| 4955 | { |
| 4956 | if (*option == '+') |
| 4957 | break; |
| 4958 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4959 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4960 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4961 | break; |
| 4962 | } |
| 4963 | if (LocaleCompare("matte",option+1) == 0) |
| 4964 | break; |
| 4965 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 4966 | { |
| 4967 | if (*option == '+') |
| 4968 | break; |
| 4969 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4970 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4971 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4972 | break; |
| 4973 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 4974 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 4975 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 4976 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 4977 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4978 | if (LocaleCompare("modulate",option+1) == 0) |
| 4979 | { |
| 4980 | if (*option == '+') |
| 4981 | break; |
| 4982 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4983 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4984 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4985 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4986 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4987 | break; |
| 4988 | } |
| 4989 | if (LocaleCompare("median",option+1) == 0) |
| 4990 | { |
| 4991 | if (*option == '+') |
| 4992 | break; |
| 4993 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4994 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4995 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4996 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4997 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4998 | break; |
| 4999 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5000 | if (LocaleCompare("mode",option+1) == 0) |
| 5001 | { |
| 5002 | if (*option == '+') |
| 5003 | break; |
| 5004 | i++; |
| 5005 | if (i == (ssize_t) argc) |
| 5006 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5007 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5008 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5009 | break; |
| 5010 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5011 | if (LocaleCompare("monitor",option+1) == 0) |
| 5012 | break; |
| 5013 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5014 | break; |
| 5015 | if (LocaleCompare("morph",option+1) == 0) |
| 5016 | { |
| 5017 | if (*option == '+') |
| 5018 | break; |
| 5019 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5020 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5021 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5022 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5023 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5024 | break; |
| 5025 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5026 | if (LocaleCompare("morphology",option+1) == 0) |
| 5027 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5028 | char |
| 5029 | token[MaxTextExtent]; |
| 5030 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5031 | KernelInfo |
| 5032 | *kernel_info; |
| 5033 | |
| 5034 | ssize_t |
| 5035 | op; |
| 5036 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5037 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5038 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5039 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5040 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5041 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5042 | if (op < 0) |
| 5043 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5044 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5045 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5046 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5047 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5048 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5049 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5050 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5051 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5052 | break; |
| 5053 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5054 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5055 | break; |
| 5056 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5057 | { |
| 5058 | if (*option == '+') |
| 5059 | break; |
| 5060 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5061 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5062 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5063 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5064 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5065 | break; |
| 5066 | } |
| 5067 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5068 | } |
| 5069 | case 'n': |
| 5070 | { |
| 5071 | if (LocaleCompare("negate",option+1) == 0) |
| 5072 | break; |
| 5073 | if (LocaleCompare("noise",option+1) == 0) |
| 5074 | { |
| 5075 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5076 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5077 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5078 | if (*option == '+') |
| 5079 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5080 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5081 | noise; |
| 5082 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5083 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5084 | if (noise < 0) |
| 5085 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5086 | argv[i]); |
| 5087 | break; |
| 5088 | } |
| 5089 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5090 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5091 | break; |
| 5092 | } |
| 5093 | if (LocaleCompare("noop",option+1) == 0) |
| 5094 | break; |
| 5095 | if (LocaleCompare("normalize",option+1) == 0) |
| 5096 | break; |
| 5097 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5098 | } |
| 5099 | case 'o': |
| 5100 | { |
| 5101 | if (LocaleCompare("opaque",option+1) == 0) |
| 5102 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5103 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5104 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5105 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5106 | break; |
| 5107 | } |
| 5108 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5109 | { |
| 5110 | if (*option == '+') |
| 5111 | break; |
| 5112 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5113 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5114 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5115 | break; |
| 5116 | } |
| 5117 | if (LocaleCompare("orient",option+1) == 0) |
| 5118 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5119 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5120 | orientation; |
| 5121 | |
| 5122 | orientation=UndefinedOrientation; |
| 5123 | if (*option == '+') |
| 5124 | break; |
| 5125 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5126 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5127 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5128 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5129 | argv[i]); |
| 5130 | if (orientation < 0) |
| 5131 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5132 | argv[i]); |
| 5133 | break; |
| 5134 | } |
| 5135 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5136 | } |
| 5137 | case 'p': |
| 5138 | { |
| 5139 | if (LocaleCompare("page",option+1) == 0) |
| 5140 | { |
| 5141 | if (*option == '+') |
| 5142 | break; |
| 5143 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5144 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5145 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5146 | break; |
| 5147 | } |
| 5148 | if (LocaleCompare("paint",option+1) == 0) |
| 5149 | { |
| 5150 | if (*option == '+') |
| 5151 | break; |
| 5152 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5153 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5154 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5155 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5156 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5157 | break; |
| 5158 | } |
| 5159 | if (LocaleCompare("path",option+1) == 0) |
| 5160 | { |
| 5161 | (void) CloneString(&path,(char *) NULL); |
| 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 | (void) CloneString(&path,argv[i]); |
| 5168 | break; |
| 5169 | } |
| 5170 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5171 | { |
| 5172 | if (*option == '+') |
| 5173 | break; |
| 5174 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5175 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5176 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5177 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5178 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5179 | break; |
| 5180 | } |
| 5181 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5182 | { |
| 5183 | if (*option == '+') |
| 5184 | break; |
| 5185 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5186 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5187 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5188 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5189 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5190 | break; |
| 5191 | } |
| 5192 | if (LocaleCompare("posterize",option+1) == 0) |
| 5193 | { |
| 5194 | if (*option == '+') |
| 5195 | break; |
| 5196 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5197 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5198 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5199 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5200 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5201 | break; |
| 5202 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5203 | if (LocaleCompare("precision",option+1) == 0) |
| 5204 | { |
| 5205 | if (*option == '+') |
| 5206 | break; |
| 5207 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5208 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5209 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5210 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5211 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5212 | break; |
| 5213 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5214 | if (LocaleCompare("print",option+1) == 0) |
| 5215 | { |
| 5216 | if (*option == '+') |
| 5217 | break; |
| 5218 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5219 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5220 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5221 | break; |
| 5222 | } |
| 5223 | if (LocaleCompare("process",option+1) == 0) |
| 5224 | { |
| 5225 | if (*option == '+') |
| 5226 | break; |
| 5227 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5228 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5229 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5230 | break; |
| 5231 | } |
| 5232 | if (LocaleCompare("profile",option+1) == 0) |
| 5233 | { |
| 5234 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5235 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5236 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5237 | break; |
| 5238 | } |
| 5239 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5240 | } |
| 5241 | case 'q': |
| 5242 | { |
| 5243 | if (LocaleCompare("quality",option+1) == 0) |
| 5244 | { |
| 5245 | if (*option == '+') |
| 5246 | break; |
| 5247 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5248 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5249 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5250 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5251 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5252 | break; |
| 5253 | } |
| 5254 | if (LocaleCompare("quantize",option+1) == 0) |
| 5255 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5256 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5257 | colorspace; |
| 5258 | |
| 5259 | if (*option == '+') |
| 5260 | break; |
| 5261 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5262 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5263 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5264 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5265 | argv[i]); |
| 5266 | if (colorspace < 0) |
| 5267 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5268 | argv[i]); |
| 5269 | break; |
| 5270 | } |
| 5271 | if (LocaleCompare("quiet",option+1) == 0) |
| 5272 | break; |
| 5273 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5274 | } |
| 5275 | case 'r': |
| 5276 | { |
| 5277 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5278 | { |
| 5279 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5280 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5281 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5282 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5283 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5284 | break; |
| 5285 | } |
| 5286 | if (LocaleCompare("raise",option+1) == 0) |
| 5287 | { |
| 5288 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5289 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5290 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5291 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5292 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5293 | break; |
| 5294 | } |
| 5295 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5296 | { |
| 5297 | if (*option == '+') |
| 5298 | break; |
| 5299 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5300 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5301 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5302 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5303 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5304 | break; |
| 5305 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5306 | if (LocaleCompare("recolor",option+1) == 0) |
| 5307 | { |
| 5308 | if (*option == '+') |
| 5309 | break; |
| 5310 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5311 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5312 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5313 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5314 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5315 | break; |
| 5316 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5317 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5318 | { |
| 5319 | if (*option == '+') |
| 5320 | break; |
| 5321 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5322 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5323 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5324 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5325 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5326 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5327 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5328 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5329 | if (LocaleCompare("region",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 | break; |
| 5339 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5340 | if (LocaleCompare("remap",option+1) == 0) |
| 5341 | { |
| 5342 | if (*option == '+') |
| 5343 | break; |
| 5344 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5345 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5346 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5347 | break; |
| 5348 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5349 | if (LocaleCompare("render",option+1) == 0) |
| 5350 | break; |
| 5351 | if (LocaleCompare("repage",option+1) == 0) |
| 5352 | { |
| 5353 | if (*option == '+') |
| 5354 | break; |
| 5355 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5356 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5357 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5358 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5359 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5360 | break; |
| 5361 | } |
| 5362 | if (LocaleCompare("resample",option+1) == 0) |
| 5363 | { |
| 5364 | if (*option == '+') |
| 5365 | break; |
| 5366 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5367 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5368 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5369 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5370 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5371 | break; |
| 5372 | } |
| 5373 | if (LocaleCompare("resize",option+1) == 0) |
| 5374 | { |
| 5375 | if (*option == '+') |
| 5376 | break; |
| 5377 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5378 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5379 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5380 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5381 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5382 | break; |
| 5383 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5384 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5385 | { |
| 5386 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5387 | break; |
| 5388 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5389 | if (LocaleCompare("reverse",option+1) == 0) |
| 5390 | break; |
| 5391 | if (LocaleCompare("roll",option+1) == 0) |
| 5392 | { |
| 5393 | if (*option == '+') |
| 5394 | break; |
| 5395 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5396 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5397 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5398 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5399 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5400 | break; |
| 5401 | } |
| 5402 | if (LocaleCompare("rotate",option+1) == 0) |
| 5403 | { |
| 5404 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5405 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5406 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5407 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5408 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5409 | break; |
| 5410 | } |
| 5411 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5412 | } |
| 5413 | case 's': |
| 5414 | { |
| 5415 | if (LocaleCompare("sample",option+1) == 0) |
| 5416 | { |
| 5417 | if (*option == '+') |
| 5418 | break; |
| 5419 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5420 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5421 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5422 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5423 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5424 | break; |
| 5425 | } |
| 5426 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5427 | { |
| 5428 | if (*option == '+') |
| 5429 | break; |
| 5430 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5431 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5432 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5433 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5434 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5435 | break; |
| 5436 | } |
| 5437 | if (LocaleCompare("scale",option+1) == 0) |
| 5438 | { |
| 5439 | if (*option == '+') |
| 5440 | break; |
| 5441 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5442 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5443 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5444 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5445 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5446 | break; |
| 5447 | } |
| 5448 | if (LocaleCompare("scene",option+1) == 0) |
| 5449 | { |
| 5450 | if (*option == '+') |
| 5451 | break; |
| 5452 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5453 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5454 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5455 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5456 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5457 | break; |
| 5458 | } |
| 5459 | if (LocaleCompare("seed",option+1) == 0) |
| 5460 | { |
| 5461 | if (*option == '+') |
| 5462 | break; |
| 5463 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5464 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5465 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5466 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5467 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5468 | break; |
| 5469 | } |
| 5470 | if (LocaleCompare("segment",option+1) == 0) |
| 5471 | { |
| 5472 | if (*option == '+') |
| 5473 | break; |
| 5474 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5475 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5476 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5477 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5478 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5479 | break; |
| 5480 | } |
| 5481 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5482 | { |
| 5483 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5484 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5485 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5486 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5487 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5488 | break; |
| 5489 | } |
| 5490 | if (LocaleCompare("separate",option+1) == 0) |
| 5491 | break; |
| 5492 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5493 | { |
| 5494 | if (*option == '+') |
| 5495 | break; |
| 5496 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5497 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5498 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5499 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5500 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5501 | break; |
| 5502 | } |
| 5503 | if (LocaleCompare("set",option+1) == 0) |
| 5504 | { |
| 5505 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5506 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5507 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5508 | if (*option == '+') |
| 5509 | break; |
| 5510 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5511 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5512 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5513 | break; |
| 5514 | } |
| 5515 | if (LocaleCompare("shade",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 (IsGeometry(argv[i]) == MagickFalse) |
| 5521 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5522 | break; |
| 5523 | } |
| 5524 | if (LocaleCompare("shadow",option+1) == 0) |
| 5525 | { |
| 5526 | if (*option == '+') |
| 5527 | break; |
| 5528 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5529 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5530 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5531 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5532 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5533 | break; |
| 5534 | } |
| 5535 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5536 | { |
| 5537 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5538 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5539 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5540 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5541 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5542 | break; |
| 5543 | } |
| 5544 | if (LocaleCompare("shave",option+1) == 0) |
| 5545 | { |
| 5546 | if (*option == '+') |
| 5547 | break; |
| 5548 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5549 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5550 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5551 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5552 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5553 | break; |
| 5554 | } |
| 5555 | if (LocaleCompare("shear",option+1) == 0) |
| 5556 | { |
| 5557 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5558 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5559 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5560 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5561 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5562 | break; |
| 5563 | } |
| 5564 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5565 | { |
| 5566 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5567 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5568 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5569 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5570 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5571 | break; |
| 5572 | } |
| 5573 | if (LocaleCompare("size",option+1) == 0) |
| 5574 | { |
| 5575 | if (*option == '+') |
| 5576 | break; |
| 5577 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5578 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5579 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5580 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5581 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5582 | break; |
| 5583 | } |
| 5584 | if (LocaleCompare("sketch",option+1) == 0) |
| 5585 | { |
| 5586 | if (*option == '+') |
| 5587 | break; |
| 5588 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5589 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5590 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5591 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5592 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5593 | break; |
| 5594 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5595 | if (LocaleCompare("smush",option+1) == 0) |
| 5596 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5597 | i++; |
| 5598 | if (i == (ssize_t) argc) |
| 5599 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5600 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5601 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5602 | i++; |
| 5603 | break; |
| 5604 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5605 | if (LocaleCompare("solarize",option+1) == 0) |
| 5606 | { |
| 5607 | if (*option == '+') |
| 5608 | break; |
| 5609 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5610 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5611 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5612 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5613 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5614 | break; |
| 5615 | } |
| 5616 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5617 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5618 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5619 | op; |
| 5620 | |
| 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); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5624 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5625 | if (op < 0) |
| 5626 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5627 | argv[i]); |
| 5628 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5629 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5630 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5631 | break; |
| 5632 | } |
| 5633 | if (LocaleCompare("spread",option+1) == 0) |
| 5634 | { |
| 5635 | if (*option == '+') |
| 5636 | break; |
| 5637 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5638 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5639 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5640 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5641 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5642 | break; |
| 5643 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5644 | if (LocaleCompare("statistic",option+1) == 0) |
| 5645 | { |
| 5646 | ssize_t |
| 5647 | op; |
| 5648 | |
| 5649 | if (*option == '+') |
| 5650 | break; |
| 5651 | i++; |
| 5652 | if (i == (ssize_t) argc) |
| 5653 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5654 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5655 | if (op < 0) |
| 5656 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5657 | argv[i]); |
| 5658 | i++; |
| 5659 | if (i == (ssize_t) (argc-1)) |
| 5660 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5661 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5662 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5663 | break; |
| 5664 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5665 | if (LocaleCompare("stretch",option+1) == 0) |
| 5666 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5667 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5668 | stretch; |
| 5669 | |
| 5670 | if (*option == '+') |
| 5671 | break; |
| 5672 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5673 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5674 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5675 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5676 | if (stretch < 0) |
| 5677 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5678 | argv[i]); |
| 5679 | break; |
| 5680 | } |
| 5681 | if (LocaleCompare("strip",option+1) == 0) |
| 5682 | break; |
| 5683 | if (LocaleCompare("stroke",option+1) == 0) |
| 5684 | { |
| 5685 | if (*option == '+') |
| 5686 | break; |
| 5687 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5688 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5689 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5690 | break; |
| 5691 | } |
| 5692 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5693 | { |
| 5694 | if (*option == '+') |
| 5695 | break; |
| 5696 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5697 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5698 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5699 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5700 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5701 | break; |
| 5702 | } |
| 5703 | if (LocaleCompare("style",option+1) == 0) |
| 5704 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5705 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5706 | style; |
| 5707 | |
| 5708 | if (*option == '+') |
| 5709 | break; |
| 5710 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5711 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5712 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5713 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5714 | if (style < 0) |
| 5715 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5716 | argv[i]); |
| 5717 | break; |
| 5718 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5719 | if (LocaleCompare("swap",option+1) == 0) |
| 5720 | { |
| 5721 | if (*option == '+') |
| 5722 | break; |
| 5723 | i++; |
| 5724 | if (i == (ssize_t) (argc-1)) |
| 5725 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5726 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5727 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5728 | break; |
| 5729 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5730 | if (LocaleCompare("swirl",option+1) == 0) |
| 5731 | { |
| 5732 | if (*option == '+') |
| 5733 | break; |
| 5734 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5735 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5736 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5737 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5738 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5739 | break; |
| 5740 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5741 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5742 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5743 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5744 | } |
| 5745 | case 't': |
| 5746 | { |
| 5747 | if (LocaleCompare("taint",option+1) == 0) |
| 5748 | break; |
| 5749 | if (LocaleCompare("texture",option+1) == 0) |
| 5750 | { |
| 5751 | if (*option == '+') |
| 5752 | break; |
| 5753 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5754 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5755 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5756 | break; |
| 5757 | } |
| 5758 | if (LocaleCompare("tile",option+1) == 0) |
| 5759 | { |
| 5760 | if (*option == '+') |
| 5761 | break; |
| 5762 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5763 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5764 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5765 | break; |
| 5766 | } |
| 5767 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5768 | { |
| 5769 | if (*option == '+') |
| 5770 | break; |
| 5771 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5772 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5773 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5774 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5775 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5776 | break; |
| 5777 | } |
| 5778 | if (LocaleCompare("tint",option+1) == 0) |
| 5779 | { |
| 5780 | if (*option == '+') |
| 5781 | break; |
| 5782 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5783 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5784 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5785 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5786 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5787 | break; |
| 5788 | } |
| 5789 | if (LocaleCompare("transform",option+1) == 0) |
| 5790 | break; |
| 5791 | if (LocaleCompare("transpose",option+1) == 0) |
| 5792 | break; |
| 5793 | if (LocaleCompare("transverse",option+1) == 0) |
| 5794 | break; |
| 5795 | if (LocaleCompare("threshold",option+1) == 0) |
| 5796 | { |
| 5797 | if (*option == '+') |
| 5798 | break; |
| 5799 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5800 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5801 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5802 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5803 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5804 | break; |
| 5805 | } |
| 5806 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5807 | { |
| 5808 | if (*option == '+') |
| 5809 | break; |
| 5810 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5811 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5812 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5813 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5814 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5815 | break; |
| 5816 | } |
| 5817 | if (LocaleCompare("transparent",option+1) == 0) |
| 5818 | { |
| 5819 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5820 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5821 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5822 | break; |
| 5823 | } |
| 5824 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 5825 | { |
| 5826 | if (*option == '+') |
| 5827 | break; |
| 5828 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5829 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5830 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5831 | break; |
| 5832 | } |
| 5833 | if (LocaleCompare("treedepth",option+1) == 0) |
| 5834 | { |
| 5835 | if (*option == '+') |
| 5836 | break; |
| 5837 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5838 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5839 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5840 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5841 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5842 | break; |
| 5843 | } |
| 5844 | if (LocaleCompare("trim",option+1) == 0) |
| 5845 | break; |
| 5846 | if (LocaleCompare("type",option+1) == 0) |
| 5847 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5848 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5849 | type; |
| 5850 | |
| 5851 | if (*option == '+') |
| 5852 | break; |
| 5853 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5854 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5855 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5856 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5857 | if (type < 0) |
| 5858 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5859 | argv[i]); |
| 5860 | break; |
| 5861 | } |
| 5862 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5863 | } |
| 5864 | case 'u': |
| 5865 | { |
| 5866 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5867 | { |
| 5868 | if (*option == '+') |
| 5869 | break; |
| 5870 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5871 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5872 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5873 | break; |
| 5874 | } |
| 5875 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5876 | break; |
| 5877 | if (LocaleCompare("units",option+1) == 0) |
| 5878 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5879 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5880 | units; |
| 5881 | |
| 5882 | if (*option == '+') |
| 5883 | break; |
| 5884 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5885 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5886 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5887 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5888 | argv[i]); |
| 5889 | if (units < 0) |
| 5890 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5891 | argv[i]); |
| 5892 | break; |
| 5893 | } |
| 5894 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5895 | { |
| 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); |
| 5899 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5900 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5901 | break; |
| 5902 | } |
| 5903 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5904 | } |
| 5905 | case 'v': |
| 5906 | { |
| 5907 | if (LocaleCompare("verbose",option+1) == 0) |
| 5908 | { |
| 5909 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 5910 | break; |
| 5911 | } |
| 5912 | if ((LocaleCompare("version",option+1) == 0) || |
| 5913 | (LocaleCompare("-version",option+1) == 0)) |
| 5914 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 5915 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5916 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 5917 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 5918 | GetMagickCopyright()); |
| 5919 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 5920 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5921 | break; |
| 5922 | } |
| 5923 | if (LocaleCompare("view",option+1) == 0) |
| 5924 | { |
| 5925 | if (*option == '+') |
| 5926 | break; |
| 5927 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5928 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5929 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5930 | break; |
| 5931 | } |
| 5932 | if (LocaleCompare("vignette",option+1) == 0) |
| 5933 | { |
| 5934 | if (*option == '+') |
| 5935 | break; |
| 5936 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5937 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5938 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5939 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5940 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5941 | break; |
| 5942 | } |
| 5943 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 5944 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5945 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5946 | method; |
| 5947 | |
| 5948 | if (*option == '+') |
| 5949 | break; |
| 5950 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5951 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5952 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5953 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5954 | argv[i]); |
| 5955 | if (method < 0) |
| 5956 | ThrowMogrifyException(OptionError, |
| 5957 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 5958 | break; |
| 5959 | } |
| 5960 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5961 | } |
| 5962 | case 'w': |
| 5963 | { |
| 5964 | if (LocaleCompare("wave",option+1) == 0) |
| 5965 | { |
| 5966 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5967 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5968 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5969 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5970 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5971 | break; |
| 5972 | } |
| 5973 | if (LocaleCompare("weight",option+1) == 0) |
| 5974 | { |
| 5975 | if (*option == '+') |
| 5976 | break; |
| 5977 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5978 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5979 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5980 | break; |
| 5981 | } |
| 5982 | if (LocaleCompare("white-point",option+1) == 0) |
| 5983 | { |
| 5984 | if (*option == '+') |
| 5985 | break; |
| 5986 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5987 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5988 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5989 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5990 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5991 | break; |
| 5992 | } |
| 5993 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 5994 | { |
| 5995 | if (*option == '+') |
| 5996 | break; |
| 5997 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5998 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5999 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6000 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6001 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6002 | break; |
| 6003 | } |
| 6004 | if (LocaleCompare("write",option+1) == 0) |
| 6005 | { |
| 6006 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6007 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6008 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6009 | break; |
| 6010 | } |
| 6011 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6012 | } |
| 6013 | case '?': |
| 6014 | break; |
| 6015 | default: |
| 6016 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6017 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6018 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 6019 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6020 | if (fire != MagickFalse) |
| 6021 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6022 | } |
| 6023 | if (k != 0) |
| 6024 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6025 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6026 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6027 | DestroyMogrify(); |
| 6028 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6029 | } |
| 6030 | |
| 6031 | /* |
| 6032 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6033 | % % |
| 6034 | % % |
| 6035 | % % |
| 6036 | + M o g r i f y I m a g e I n f o % |
| 6037 | % % |
| 6038 | % % |
| 6039 | % % |
| 6040 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6041 | % |
| 6042 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6043 | % prescribed by command line options. |
| 6044 | % |
| 6045 | % The format of the MogrifyImageInfo method is: |
| 6046 | % |
| 6047 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6048 | % const char **argv,ExceptionInfo *exception) |
| 6049 | % |
| 6050 | % A description of each parameter follows: |
| 6051 | % |
| 6052 | % o image_info: the image info.. |
| 6053 | % |
| 6054 | % o argc: Specifies a pointer to an integer describing the number of |
| 6055 | % elements in the argument vector. |
| 6056 | % |
| 6057 | % o argv: Specifies a pointer to a text array containing the command line |
| 6058 | % arguments. |
| 6059 | % |
| 6060 | % o exception: return any errors or warnings in this structure. |
| 6061 | % |
| 6062 | */ |
| 6063 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6064 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6065 | { |
| 6066 | const char |
| 6067 | *option; |
| 6068 | |
| 6069 | GeometryInfo |
| 6070 | geometry_info; |
| 6071 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6072 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6073 | count; |
| 6074 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6075 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6076 | i; |
| 6077 | |
| 6078 | /* |
| 6079 | Initialize method variables. |
| 6080 | */ |
| 6081 | assert(image_info != (ImageInfo *) NULL); |
| 6082 | assert(image_info->signature == MagickSignature); |
| 6083 | if (image_info->debug != MagickFalse) |
| 6084 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6085 | image_info->filename); |
| 6086 | if (argc < 0) |
| 6087 | return(MagickTrue); |
| 6088 | /* |
| 6089 | Set the image settings. |
| 6090 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6091 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6092 | { |
| 6093 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6094 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6095 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6096 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6097 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6098 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6099 | break; |
| 6100 | switch (*(option+1)) |
| 6101 | { |
| 6102 | case 'a': |
| 6103 | { |
| 6104 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6105 | { |
| 6106 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6107 | break; |
| 6108 | } |
| 6109 | if (LocaleCompare("antialias",option+1) == 0) |
| 6110 | { |
| 6111 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6112 | break; |
| 6113 | } |
| 6114 | if (LocaleCompare("attenuate",option+1) == 0) |
| 6115 | { |
| 6116 | if (*option == '+') |
| 6117 | { |
| 6118 | (void) DeleteImageOption(image_info,option+1); |
| 6119 | break; |
| 6120 | } |
| 6121 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6122 | break; |
| 6123 | } |
| 6124 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6125 | { |
| 6126 | if (*option == '+') |
| 6127 | (void) CloneString(&image_info->authenticate,(char *) NULL); |
| 6128 | else |
| 6129 | (void) CloneString(&image_info->authenticate,argv[i+1]); |
| 6130 | break; |
| 6131 | } |
| 6132 | break; |
| 6133 | } |
| 6134 | case 'b': |
| 6135 | { |
| 6136 | if (LocaleCompare("background",option+1) == 0) |
| 6137 | { |
| 6138 | if (*option == '+') |
| 6139 | { |
| 6140 | (void) DeleteImageOption(image_info,option+1); |
| 6141 | (void) QueryColorDatabase(BackgroundColor, |
| 6142 | &image_info->background_color,exception); |
| 6143 | break; |
| 6144 | } |
| 6145 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6146 | (void) QueryColorDatabase(argv[i+1],&image_info->background_color, |
| 6147 | exception); |
| 6148 | break; |
| 6149 | } |
| 6150 | if (LocaleCompare("bias",option+1) == 0) |
| 6151 | { |
| 6152 | if (*option == '+') |
| 6153 | { |
| 6154 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6155 | break; |
| 6156 | } |
| 6157 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6158 | break; |
| 6159 | } |
| 6160 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6161 | { |
| 6162 | if (*option == '+') |
| 6163 | { |
| 6164 | (void) SetImageOption(image_info,option+1,"false"); |
| 6165 | break; |
| 6166 | } |
| 6167 | (void) SetImageOption(image_info,option+1,"true"); |
| 6168 | break; |
| 6169 | } |
| 6170 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6171 | { |
| 6172 | if (*option == '+') |
| 6173 | { |
| 6174 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6175 | break; |
| 6176 | } |
| 6177 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6178 | break; |
| 6179 | } |
| 6180 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6181 | { |
| 6182 | if (*option == '+') |
| 6183 | { |
| 6184 | (void) DeleteImageOption(image_info,option+1); |
| 6185 | (void) QueryColorDatabase(BorderColor,&image_info->border_color, |
| 6186 | exception); |
| 6187 | break; |
| 6188 | } |
| 6189 | (void) QueryColorDatabase(argv[i+1],&image_info->border_color, |
| 6190 | exception); |
| 6191 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6192 | break; |
| 6193 | } |
| 6194 | if (LocaleCompare("box",option+1) == 0) |
| 6195 | { |
| 6196 | if (*option == '+') |
| 6197 | { |
| 6198 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6199 | break; |
| 6200 | } |
| 6201 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6202 | break; |
| 6203 | } |
| 6204 | break; |
| 6205 | } |
| 6206 | case 'c': |
| 6207 | { |
| 6208 | if (LocaleCompare("cache",option+1) == 0) |
| 6209 | { |
| 6210 | MagickSizeType |
| 6211 | limit; |
| 6212 | |
| 6213 | limit=MagickResourceInfinity; |
| 6214 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6215 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6216 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6217 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6218 | break; |
| 6219 | } |
| 6220 | if (LocaleCompare("caption",option+1) == 0) |
| 6221 | { |
| 6222 | if (*option == '+') |
| 6223 | { |
| 6224 | (void) DeleteImageOption(image_info,option+1); |
| 6225 | break; |
| 6226 | } |
| 6227 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6228 | break; |
| 6229 | } |
| 6230 | if (LocaleCompare("channel",option+1) == 0) |
| 6231 | { |
| 6232 | if (*option == '+') |
| 6233 | { |
| 6234 | image_info->channel=DefaultChannels; |
| 6235 | break; |
| 6236 | } |
| 6237 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6238 | break; |
| 6239 | } |
| 6240 | if (LocaleCompare("colors",option+1) == 0) |
| 6241 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6242 | image_info->colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6243 | break; |
| 6244 | } |
| 6245 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6246 | { |
| 6247 | if (*option == '+') |
| 6248 | { |
| 6249 | image_info->colorspace=UndefinedColorspace; |
| 6250 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6251 | break; |
| 6252 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6253 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6254 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6255 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6256 | break; |
| 6257 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6258 | if (LocaleCompare("comment",option+1) == 0) |
| 6259 | { |
| 6260 | if (*option == '+') |
| 6261 | { |
| 6262 | (void) DeleteImageOption(image_info,option+1); |
| 6263 | break; |
| 6264 | } |
| 6265 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6266 | break; |
| 6267 | } |
| 6268 | if (LocaleCompare("compose",option+1) == 0) |
| 6269 | { |
| 6270 | if (*option == '+') |
| 6271 | { |
| 6272 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6273 | break; |
| 6274 | } |
| 6275 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6276 | break; |
| 6277 | } |
| 6278 | if (LocaleCompare("compress",option+1) == 0) |
| 6279 | { |
| 6280 | if (*option == '+') |
| 6281 | { |
| 6282 | image_info->compression=UndefinedCompression; |
| 6283 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6284 | break; |
| 6285 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6286 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6287 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6288 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6289 | break; |
| 6290 | } |
| 6291 | break; |
| 6292 | } |
| 6293 | case 'd': |
| 6294 | { |
| 6295 | if (LocaleCompare("debug",option+1) == 0) |
| 6296 | { |
| 6297 | if (*option == '+') |
| 6298 | (void) SetLogEventMask("none"); |
| 6299 | else |
| 6300 | (void) SetLogEventMask(argv[i+1]); |
| 6301 | image_info->debug=IsEventLogging(); |
| 6302 | break; |
| 6303 | } |
| 6304 | if (LocaleCompare("define",option+1) == 0) |
| 6305 | { |
| 6306 | if (*option == '+') |
| 6307 | { |
| 6308 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6309 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6310 | else |
| 6311 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6312 | break; |
| 6313 | } |
| 6314 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6315 | { |
| 6316 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6317 | exception); |
| 6318 | break; |
| 6319 | } |
| 6320 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6321 | break; |
| 6322 | } |
| 6323 | if (LocaleCompare("delay",option+1) == 0) |
| 6324 | { |
| 6325 | if (*option == '+') |
| 6326 | { |
| 6327 | (void) SetImageOption(image_info,option+1,"0"); |
| 6328 | break; |
| 6329 | } |
| 6330 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6331 | break; |
| 6332 | } |
| 6333 | if (LocaleCompare("density",option+1) == 0) |
| 6334 | { |
| 6335 | /* |
| 6336 | Set image density. |
| 6337 | */ |
| 6338 | if (*option == '+') |
| 6339 | { |
| 6340 | if (image_info->density != (char *) NULL) |
| 6341 | image_info->density=DestroyString(image_info->density); |
| 6342 | (void) SetImageOption(image_info,option+1,"72"); |
| 6343 | break; |
| 6344 | } |
| 6345 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6346 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6347 | break; |
| 6348 | } |
| 6349 | if (LocaleCompare("depth",option+1) == 0) |
| 6350 | { |
| 6351 | if (*option == '+') |
| 6352 | { |
| 6353 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6354 | break; |
| 6355 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6356 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6357 | break; |
| 6358 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6359 | if (LocaleCompare("direction",option+1) == 0) |
| 6360 | { |
| 6361 | if (*option == '+') |
| 6362 | { |
| 6363 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6364 | break; |
| 6365 | } |
| 6366 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6367 | break; |
| 6368 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6369 | if (LocaleCompare("display",option+1) == 0) |
| 6370 | { |
| 6371 | if (*option == '+') |
| 6372 | { |
| 6373 | if (image_info->server_name != (char *) NULL) |
| 6374 | image_info->server_name=DestroyString( |
| 6375 | image_info->server_name); |
| 6376 | break; |
| 6377 | } |
| 6378 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6379 | break; |
| 6380 | } |
| 6381 | if (LocaleCompare("dispose",option+1) == 0) |
| 6382 | { |
| 6383 | if (*option == '+') |
| 6384 | { |
| 6385 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6386 | break; |
| 6387 | } |
| 6388 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6389 | break; |
| 6390 | } |
| 6391 | if (LocaleCompare("dither",option+1) == 0) |
| 6392 | { |
| 6393 | if (*option == '+') |
| 6394 | { |
| 6395 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6396 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6397 | break; |
| 6398 | } |
| 6399 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6400 | image_info->dither=MagickTrue; |
| 6401 | break; |
| 6402 | } |
| 6403 | break; |
| 6404 | } |
| 6405 | case 'e': |
| 6406 | { |
| 6407 | if (LocaleCompare("encoding",option+1) == 0) |
| 6408 | { |
| 6409 | if (*option == '+') |
| 6410 | { |
| 6411 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6412 | break; |
| 6413 | } |
| 6414 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6415 | break; |
| 6416 | } |
| 6417 | if (LocaleCompare("endian",option+1) == 0) |
| 6418 | { |
| 6419 | if (*option == '+') |
| 6420 | { |
| 6421 | image_info->endian=UndefinedEndian; |
| 6422 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6423 | break; |
| 6424 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6425 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6426 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6427 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6428 | break; |
| 6429 | } |
| 6430 | if (LocaleCompare("extract",option+1) == 0) |
| 6431 | { |
| 6432 | /* |
| 6433 | Set image extract geometry. |
| 6434 | */ |
| 6435 | if (*option == '+') |
| 6436 | { |
| 6437 | if (image_info->extract != (char *) NULL) |
| 6438 | image_info->extract=DestroyString(image_info->extract); |
| 6439 | break; |
| 6440 | } |
| 6441 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6442 | break; |
| 6443 | } |
| 6444 | break; |
| 6445 | } |
| 6446 | case 'f': |
| 6447 | { |
| 6448 | if (LocaleCompare("fill",option+1) == 0) |
| 6449 | { |
| 6450 | if (*option == '+') |
| 6451 | { |
| 6452 | (void) SetImageOption(image_info,option+1,"none"); |
| 6453 | break; |
| 6454 | } |
| 6455 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6456 | break; |
| 6457 | } |
| 6458 | if (LocaleCompare("filter",option+1) == 0) |
| 6459 | { |
| 6460 | if (*option == '+') |
| 6461 | { |
| 6462 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6463 | break; |
| 6464 | } |
| 6465 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6466 | break; |
| 6467 | } |
| 6468 | if (LocaleCompare("font",option+1) == 0) |
| 6469 | { |
| 6470 | if (*option == '+') |
| 6471 | { |
| 6472 | if (image_info->font != (char *) NULL) |
| 6473 | image_info->font=DestroyString(image_info->font); |
| 6474 | break; |
| 6475 | } |
| 6476 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6477 | break; |
| 6478 | } |
| 6479 | if (LocaleCompare("format",option+1) == 0) |
| 6480 | { |
| 6481 | register const char |
| 6482 | *q; |
| 6483 | |
| 6484 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6485 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6486 | image_info->ping=MagickFalse; |
| 6487 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6488 | break; |
| 6489 | } |
| 6490 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6491 | { |
| 6492 | if (*option == '+') |
| 6493 | { |
| 6494 | image_info->fuzz=0.0; |
| 6495 | (void) SetImageOption(image_info,option+1,"0"); |
| 6496 | break; |
| 6497 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6498 | image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6499 | 1.0); |
| 6500 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6501 | break; |
| 6502 | } |
| 6503 | break; |
| 6504 | } |
| 6505 | case 'g': |
| 6506 | { |
| 6507 | if (LocaleCompare("gravity",option+1) == 0) |
| 6508 | { |
| 6509 | if (*option == '+') |
| 6510 | { |
| 6511 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6512 | break; |
| 6513 | } |
| 6514 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6515 | break; |
| 6516 | } |
| 6517 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6518 | { |
| 6519 | if (*option == '+') |
| 6520 | { |
| 6521 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6522 | break; |
| 6523 | } |
| 6524 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6525 | break; |
| 6526 | } |
| 6527 | break; |
| 6528 | } |
| 6529 | case 'i': |
| 6530 | { |
| 6531 | if (LocaleCompare("intent",option+1) == 0) |
| 6532 | { |
| 6533 | if (*option == '+') |
| 6534 | { |
| 6535 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6536 | break; |
| 6537 | } |
| 6538 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6539 | break; |
| 6540 | } |
| 6541 | if (LocaleCompare("interlace",option+1) == 0) |
| 6542 | { |
| 6543 | if (*option == '+') |
| 6544 | { |
| 6545 | image_info->interlace=UndefinedInterlace; |
| 6546 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6547 | break; |
| 6548 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6549 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6550 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6551 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6552 | break; |
| 6553 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6554 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6555 | { |
| 6556 | if (*option == '+') |
| 6557 | { |
| 6558 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6559 | break; |
| 6560 | } |
| 6561 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6562 | break; |
| 6563 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6564 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6565 | { |
| 6566 | if (*option == '+') |
| 6567 | { |
| 6568 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6569 | break; |
| 6570 | } |
| 6571 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6572 | break; |
| 6573 | } |
| 6574 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6575 | { |
| 6576 | if (*option == '+') |
| 6577 | { |
| 6578 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6579 | break; |
| 6580 | } |
| 6581 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6582 | break; |
| 6583 | } |
| 6584 | break; |
| 6585 | } |
| 6586 | case 'k': |
| 6587 | { |
| 6588 | if (LocaleCompare("kerning",option+1) == 0) |
| 6589 | { |
| 6590 | if (*option == '+') |
| 6591 | { |
| 6592 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6593 | break; |
| 6594 | } |
| 6595 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6596 | break; |
| 6597 | } |
| 6598 | break; |
| 6599 | } |
| 6600 | case 'l': |
| 6601 | { |
| 6602 | if (LocaleCompare("label",option+1) == 0) |
| 6603 | { |
| 6604 | if (*option == '+') |
| 6605 | { |
| 6606 | (void) DeleteImageOption(image_info,option+1); |
| 6607 | break; |
| 6608 | } |
| 6609 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6610 | break; |
| 6611 | } |
| 6612 | if (LocaleCompare("limit",option+1) == 0) |
| 6613 | { |
| 6614 | MagickSizeType |
| 6615 | limit; |
| 6616 | |
| 6617 | ResourceType |
| 6618 | type; |
| 6619 | |
| 6620 | if (*option == '+') |
| 6621 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6622 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6623 | MagickFalse,argv[i+1]); |
| 6624 | limit=MagickResourceInfinity; |
| 6625 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6626 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6627 | (void) SetMagickResourceLimit(type,limit); |
| 6628 | break; |
| 6629 | } |
| 6630 | if (LocaleCompare("list",option+1) == 0) |
| 6631 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6632 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6633 | list; |
| 6634 | |
| 6635 | /* |
| 6636 | Display configuration list. |
| 6637 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6638 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6639 | switch (list) |
| 6640 | { |
| 6641 | case MagickCoderOptions: |
| 6642 | { |
| 6643 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6644 | break; |
| 6645 | } |
| 6646 | case MagickColorOptions: |
| 6647 | { |
| 6648 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6649 | break; |
| 6650 | } |
| 6651 | case MagickConfigureOptions: |
| 6652 | { |
| 6653 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6654 | break; |
| 6655 | } |
| 6656 | case MagickDelegateOptions: |
| 6657 | { |
| 6658 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6659 | break; |
| 6660 | } |
| 6661 | case MagickFontOptions: |
| 6662 | { |
| 6663 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6664 | break; |
| 6665 | } |
| 6666 | case MagickFormatOptions: |
| 6667 | { |
| 6668 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6669 | break; |
| 6670 | } |
| 6671 | case MagickLocaleOptions: |
| 6672 | { |
| 6673 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6674 | break; |
| 6675 | } |
| 6676 | case MagickLogOptions: |
| 6677 | { |
| 6678 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6679 | break; |
| 6680 | } |
| 6681 | case MagickMagicOptions: |
| 6682 | { |
| 6683 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6684 | break; |
| 6685 | } |
| 6686 | case MagickMimeOptions: |
| 6687 | { |
| 6688 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6689 | break; |
| 6690 | } |
| 6691 | case MagickModuleOptions: |
| 6692 | { |
| 6693 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6694 | break; |
| 6695 | } |
| 6696 | case MagickPolicyOptions: |
| 6697 | { |
| 6698 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6699 | break; |
| 6700 | } |
| 6701 | case MagickResourceOptions: |
| 6702 | { |
| 6703 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6704 | break; |
| 6705 | } |
| 6706 | case MagickThresholdOptions: |
| 6707 | { |
| 6708 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6709 | break; |
| 6710 | } |
| 6711 | default: |
| 6712 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6713 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6714 | exception); |
| 6715 | break; |
| 6716 | } |
| 6717 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6718 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6719 | } |
| 6720 | if (LocaleCompare("log",option+1) == 0) |
| 6721 | { |
| 6722 | if (*option == '+') |
| 6723 | break; |
| 6724 | (void) SetLogFormat(argv[i+1]); |
| 6725 | break; |
| 6726 | } |
| 6727 | if (LocaleCompare("loop",option+1) == 0) |
| 6728 | { |
| 6729 | if (*option == '+') |
| 6730 | { |
| 6731 | (void) SetImageOption(image_info,option+1,"0"); |
| 6732 | break; |
| 6733 | } |
| 6734 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6735 | break; |
| 6736 | } |
| 6737 | break; |
| 6738 | } |
| 6739 | case 'm': |
| 6740 | { |
| 6741 | if (LocaleCompare("matte",option+1) == 0) |
| 6742 | { |
| 6743 | if (*option == '+') |
| 6744 | { |
| 6745 | (void) SetImageOption(image_info,option+1,"false"); |
| 6746 | break; |
| 6747 | } |
| 6748 | (void) SetImageOption(image_info,option+1,"true"); |
| 6749 | break; |
| 6750 | } |
| 6751 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6752 | { |
| 6753 | if (*option == '+') |
| 6754 | { |
| 6755 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6756 | (void) QueryColorDatabase(MatteColor,&image_info->matte_color, |
| 6757 | exception); |
| 6758 | break; |
| 6759 | } |
| 6760 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6761 | (void) QueryColorDatabase(argv[i+1],&image_info->matte_color, |
| 6762 | exception); |
| 6763 | break; |
| 6764 | } |
| 6765 | if (LocaleCompare("monitor",option+1) == 0) |
| 6766 | { |
| 6767 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6768 | (void *) NULL); |
| 6769 | break; |
| 6770 | } |
| 6771 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6772 | { |
| 6773 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6774 | break; |
| 6775 | } |
| 6776 | break; |
| 6777 | } |
| 6778 | case 'o': |
| 6779 | { |
| 6780 | if (LocaleCompare("orient",option+1) == 0) |
| 6781 | { |
| 6782 | if (*option == '+') |
| 6783 | { |
| 6784 | image_info->orientation=UndefinedOrientation; |
| 6785 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6786 | break; |
| 6787 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6788 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6789 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6790 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6791 | break; |
| 6792 | } |
| 6793 | } |
| 6794 | case 'p': |
| 6795 | { |
| 6796 | if (LocaleCompare("page",option+1) == 0) |
| 6797 | { |
| 6798 | char |
| 6799 | *canonical_page, |
| 6800 | page[MaxTextExtent]; |
| 6801 | |
| 6802 | const char |
| 6803 | *image_option; |
| 6804 | |
| 6805 | MagickStatusType |
| 6806 | flags; |
| 6807 | |
| 6808 | RectangleInfo |
| 6809 | geometry; |
| 6810 | |
| 6811 | if (*option == '+') |
| 6812 | { |
| 6813 | (void) DeleteImageOption(image_info,option+1); |
| 6814 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6815 | break; |
| 6816 | } |
| 6817 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6818 | image_option=GetImageOption(image_info,"page"); |
| 6819 | if (image_option != (const char *) NULL) |
| 6820 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6821 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6822 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6823 | canonical_page=DestroyString(canonical_page); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6824 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6825 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6826 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6827 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6828 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6829 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6830 | (void) SetImageOption(image_info,option+1,page); |
| 6831 | (void) CloneString(&image_info->page,page); |
| 6832 | break; |
| 6833 | } |
| 6834 | if (LocaleCompare("pen",option+1) == 0) |
| 6835 | { |
| 6836 | if (*option == '+') |
| 6837 | { |
| 6838 | (void) SetImageOption(image_info,option+1,"none"); |
| 6839 | break; |
| 6840 | } |
| 6841 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6842 | break; |
| 6843 | } |
| 6844 | if (LocaleCompare("ping",option+1) == 0) |
| 6845 | { |
| 6846 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6847 | break; |
| 6848 | } |
| 6849 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6850 | { |
| 6851 | if (*option == '+') |
| 6852 | geometry_info.rho=0.0; |
| 6853 | else |
| 6854 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6855 | image_info->pointsize=geometry_info.rho; |
| 6856 | break; |
| 6857 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6858 | if (LocaleCompare("precision",option+1) == 0) |
| 6859 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6860 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6861 | break; |
| 6862 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6863 | if (LocaleCompare("preview",option+1) == 0) |
| 6864 | { |
| 6865 | /* |
| 6866 | Preview image. |
| 6867 | */ |
| 6868 | if (*option == '+') |
| 6869 | { |
| 6870 | image_info->preview_type=UndefinedPreview; |
| 6871 | break; |
| 6872 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6873 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6874 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6875 | break; |
| 6876 | } |
| 6877 | break; |
| 6878 | } |
| 6879 | case 'q': |
| 6880 | { |
| 6881 | if (LocaleCompare("quality",option+1) == 0) |
| 6882 | { |
| 6883 | /* |
| 6884 | Set image compression quality. |
| 6885 | */ |
| 6886 | if (*option == '+') |
| 6887 | { |
| 6888 | image_info->quality=UndefinedCompressionQuality; |
| 6889 | (void) SetImageOption(image_info,option+1,"0"); |
| 6890 | break; |
| 6891 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6892 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6893 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6894 | break; |
| 6895 | } |
| 6896 | if (LocaleCompare("quiet",option+1) == 0) |
| 6897 | { |
| 6898 | static WarningHandler |
| 6899 | warning_handler = (WarningHandler) NULL; |
| 6900 | |
| 6901 | if (*option == '+') |
| 6902 | { |
| 6903 | /* |
| 6904 | Restore error or warning messages. |
| 6905 | */ |
| 6906 | warning_handler=SetWarningHandler(warning_handler); |
| 6907 | break; |
| 6908 | } |
| 6909 | /* |
| 6910 | Suppress error or warning messages. |
| 6911 | */ |
| 6912 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6913 | break; |
| 6914 | } |
| 6915 | break; |
| 6916 | } |
| 6917 | case 'r': |
| 6918 | { |
| 6919 | if (LocaleCompare("red-primary",option+1) == 0) |
| 6920 | { |
| 6921 | if (*option == '+') |
| 6922 | { |
| 6923 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6924 | break; |
| 6925 | } |
| 6926 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6927 | break; |
| 6928 | } |
| 6929 | break; |
| 6930 | } |
| 6931 | case 's': |
| 6932 | { |
| 6933 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 6934 | { |
| 6935 | /* |
| 6936 | Set image sampling factor. |
| 6937 | */ |
| 6938 | if (*option == '+') |
| 6939 | { |
| 6940 | if (image_info->sampling_factor != (char *) NULL) |
| 6941 | image_info->sampling_factor=DestroyString( |
| 6942 | image_info->sampling_factor); |
| 6943 | break; |
| 6944 | } |
| 6945 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 6946 | break; |
| 6947 | } |
| 6948 | if (LocaleCompare("scene",option+1) == 0) |
| 6949 | { |
| 6950 | /* |
| 6951 | Set image scene. |
| 6952 | */ |
| 6953 | if (*option == '+') |
| 6954 | { |
| 6955 | image_info->scene=0; |
| 6956 | (void) SetImageOption(image_info,option+1,"0"); |
| 6957 | break; |
| 6958 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6959 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6960 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6961 | break; |
| 6962 | } |
| 6963 | if (LocaleCompare("seed",option+1) == 0) |
| 6964 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6965 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6966 | seed; |
| 6967 | |
| 6968 | if (*option == '+') |
| 6969 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6970 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6971 | SeedPseudoRandomGenerator(seed); |
| 6972 | break; |
| 6973 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6974 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6975 | SeedPseudoRandomGenerator(seed); |
| 6976 | break; |
| 6977 | } |
| 6978 | if (LocaleCompare("size",option+1) == 0) |
| 6979 | { |
| 6980 | if (*option == '+') |
| 6981 | { |
| 6982 | if (image_info->size != (char *) NULL) |
| 6983 | image_info->size=DestroyString(image_info->size); |
| 6984 | break; |
| 6985 | } |
| 6986 | (void) CloneString(&image_info->size,argv[i+1]); |
| 6987 | break; |
| 6988 | } |
| 6989 | if (LocaleCompare("stroke",option+1) == 0) |
| 6990 | { |
| 6991 | if (*option == '+') |
| 6992 | { |
| 6993 | (void) SetImageOption(image_info,option+1,"none"); |
| 6994 | break; |
| 6995 | } |
| 6996 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6997 | break; |
| 6998 | } |
| 6999 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7000 | { |
| 7001 | if (*option == '+') |
| 7002 | { |
| 7003 | (void) SetImageOption(image_info,option+1,"0"); |
| 7004 | break; |
| 7005 | } |
| 7006 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7007 | break; |
| 7008 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7009 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7010 | { |
| 7011 | if (*option == '+') |
| 7012 | { |
| 7013 | image_info->synchronize=MagickFalse; |
| 7014 | break; |
| 7015 | } |
| 7016 | image_info->synchronize=MagickTrue; |
| 7017 | break; |
| 7018 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7019 | break; |
| 7020 | } |
| 7021 | case 't': |
| 7022 | { |
| 7023 | if (LocaleCompare("taint",option+1) == 0) |
| 7024 | { |
| 7025 | if (*option == '+') |
| 7026 | { |
| 7027 | (void) SetImageOption(image_info,option+1,"false"); |
| 7028 | break; |
| 7029 | } |
| 7030 | (void) SetImageOption(image_info,option+1,"true"); |
| 7031 | break; |
| 7032 | } |
| 7033 | if (LocaleCompare("texture",option+1) == 0) |
| 7034 | { |
| 7035 | if (*option == '+') |
| 7036 | { |
| 7037 | if (image_info->texture != (char *) NULL) |
| 7038 | image_info->texture=DestroyString(image_info->texture); |
| 7039 | break; |
| 7040 | } |
| 7041 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7042 | break; |
| 7043 | } |
| 7044 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7045 | { |
| 7046 | if (*option == '+') |
| 7047 | { |
| 7048 | (void) SetImageOption(image_info,option+1,"0"); |
| 7049 | break; |
| 7050 | } |
| 7051 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7052 | break; |
| 7053 | } |
| 7054 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7055 | { |
| 7056 | if (*option == '+') |
| 7057 | { |
| 7058 | (void) QueryColorDatabase("none",&image_info->transparent_color, exception); |
| 7059 | (void) SetImageOption(image_info,option+1,"none"); |
| 7060 | break; |
| 7061 | } |
| 7062 | (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color, |
| 7063 | exception); |
| 7064 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7065 | break; |
| 7066 | } |
| 7067 | if (LocaleCompare("type",option+1) == 0) |
| 7068 | { |
| 7069 | if (*option == '+') |
| 7070 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7071 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7072 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7073 | break; |
| 7074 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7075 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7076 | MagickFalse,argv[i+1]); |
| 7077 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7078 | break; |
| 7079 | } |
| 7080 | break; |
| 7081 | } |
| 7082 | case 'u': |
| 7083 | { |
| 7084 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7085 | { |
| 7086 | if (*option == '+') |
| 7087 | { |
| 7088 | (void) DeleteImageOption(image_info,option+1); |
| 7089 | break; |
| 7090 | } |
| 7091 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7092 | break; |
| 7093 | } |
| 7094 | if (LocaleCompare("units",option+1) == 0) |
| 7095 | { |
| 7096 | if (*option == '+') |
| 7097 | { |
| 7098 | image_info->units=UndefinedResolution; |
| 7099 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7100 | break; |
| 7101 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7102 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7103 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7104 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7105 | break; |
| 7106 | } |
| 7107 | break; |
| 7108 | } |
| 7109 | case 'v': |
| 7110 | { |
| 7111 | if (LocaleCompare("verbose",option+1) == 0) |
| 7112 | { |
| 7113 | if (*option == '+') |
| 7114 | { |
| 7115 | image_info->verbose=MagickFalse; |
| 7116 | break; |
| 7117 | } |
| 7118 | image_info->verbose=MagickTrue; |
| 7119 | image_info->ping=MagickFalse; |
| 7120 | break; |
| 7121 | } |
| 7122 | if (LocaleCompare("view",option+1) == 0) |
| 7123 | { |
| 7124 | if (*option == '+') |
| 7125 | { |
| 7126 | if (image_info->view != (char *) NULL) |
| 7127 | image_info->view=DestroyString(image_info->view); |
| 7128 | break; |
| 7129 | } |
| 7130 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7131 | break; |
| 7132 | } |
| 7133 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7134 | { |
| 7135 | if (*option == '+') |
| 7136 | { |
| 7137 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7138 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7139 | break; |
| 7140 | } |
| 7141 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7142 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7143 | argv[i+1]); |
| 7144 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7145 | break; |
| 7146 | } |
| 7147 | break; |
| 7148 | } |
| 7149 | case 'w': |
| 7150 | { |
| 7151 | if (LocaleCompare("white-point",option+1) == 0) |
| 7152 | { |
| 7153 | if (*option == '+') |
| 7154 | { |
| 7155 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7156 | break; |
| 7157 | } |
| 7158 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7159 | break; |
| 7160 | } |
| 7161 | break; |
| 7162 | } |
| 7163 | default: |
| 7164 | break; |
| 7165 | } |
| 7166 | i+=count; |
| 7167 | } |
| 7168 | return(MagickTrue); |
| 7169 | } |
| 7170 | |
| 7171 | /* |
| 7172 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7173 | % % |
| 7174 | % % |
| 7175 | % % |
| 7176 | + M o g r i f y I m a g e L i s t % |
| 7177 | % % |
| 7178 | % % |
| 7179 | % % |
| 7180 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7181 | % |
| 7182 | % MogrifyImageList() applies any command line options that might affect the |
| 7183 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7184 | % |
| 7185 | % The format of the MogrifyImage method is: |
| 7186 | % |
| 7187 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7188 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7189 | % |
| 7190 | % A description of each parameter follows: |
| 7191 | % |
| 7192 | % o image_info: the image info.. |
| 7193 | % |
| 7194 | % o argc: Specifies a pointer to an integer describing the number of |
| 7195 | % elements in the argument vector. |
| 7196 | % |
| 7197 | % o argv: Specifies a pointer to a text array containing the command line |
| 7198 | % arguments. |
| 7199 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7200 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7201 | % |
| 7202 | % o exception: return any errors or warnings in this structure. |
| 7203 | % |
| 7204 | */ |
| 7205 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7206 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7207 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7208 | const char |
| 7209 | *option; |
| 7210 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7211 | ImageInfo |
| 7212 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7213 | |
| 7214 | MagickStatusType |
| 7215 | status; |
| 7216 | |
| 7217 | QuantizeInfo |
| 7218 | *quantize_info; |
| 7219 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7220 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7221 | i; |
| 7222 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7223 | ssize_t |
| 7224 | count, |
| 7225 | index; |
| 7226 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7227 | /* |
| 7228 | Apply options to the image list. |
| 7229 | */ |
| 7230 | assert(image_info != (ImageInfo *) NULL); |
| 7231 | assert(image_info->signature == MagickSignature); |
| 7232 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7233 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7234 | assert((*images)->signature == MagickSignature); |
| 7235 | if ((*images)->debug != MagickFalse) |
| 7236 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7237 | (*images)->filename); |
| 7238 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7239 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7240 | mogrify_info=CloneImageInfo(image_info); |
| 7241 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7242 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7243 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7244 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7245 | if (*images == (Image *) NULL) |
| 7246 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7247 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7248 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7249 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7250 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7251 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7252 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7253 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7254 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7255 | switch (*(option+1)) |
| 7256 | { |
| 7257 | case 'a': |
| 7258 | { |
| 7259 | if (LocaleCompare("affinity",option+1) == 0) |
| 7260 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7261 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7262 | if (*option == '+') |
| 7263 | { |
| 7264 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7265 | InheritException(exception,&(*images)->exception); |
| 7266 | break; |
| 7267 | } |
| 7268 | i++; |
| 7269 | break; |
| 7270 | } |
| 7271 | if (LocaleCompare("append",option+1) == 0) |
| 7272 | { |
| 7273 | Image |
| 7274 | *append_image; |
| 7275 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7276 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7277 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7278 | MagickFalse,exception); |
| 7279 | if (append_image == (Image *) NULL) |
| 7280 | { |
| 7281 | status=MagickFalse; |
| 7282 | break; |
| 7283 | } |
| 7284 | *images=DestroyImageList(*images); |
| 7285 | *images=append_image; |
| 7286 | break; |
| 7287 | } |
| 7288 | if (LocaleCompare("average",option+1) == 0) |
| 7289 | { |
| 7290 | Image |
| 7291 | *average_image; |
| 7292 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7293 | /* |
| 7294 | Average an image sequence (deprecated). |
| 7295 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7296 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7297 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7298 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7299 | if (average_image == (Image *) NULL) |
| 7300 | { |
| 7301 | status=MagickFalse; |
| 7302 | break; |
| 7303 | } |
| 7304 | *images=DestroyImageList(*images); |
| 7305 | *images=average_image; |
| 7306 | break; |
| 7307 | } |
| 7308 | break; |
| 7309 | } |
| 7310 | case 'c': |
| 7311 | { |
| 7312 | if (LocaleCompare("channel",option+1) == 0) |
| 7313 | { |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7314 | ChannelType |
| 7315 | channel; |
| 7316 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7317 | if (*option == '+') |
| 7318 | { |
| 7319 | channel=DefaultChannels; |
| 7320 | break; |
| 7321 | } |
| 7322 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 7323 | SetPixelChannelMap(*images,channel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7324 | break; |
| 7325 | } |
| 7326 | if (LocaleCompare("clut",option+1) == 0) |
| 7327 | { |
| 7328 | Image |
| 7329 | *clut_image, |
| 7330 | *image; |
| 7331 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7332 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7333 | image=RemoveFirstImageFromList(images); |
| 7334 | clut_image=RemoveFirstImageFromList(images); |
| 7335 | if (clut_image == (Image *) NULL) |
| 7336 | { |
| 7337 | status=MagickFalse; |
| 7338 | break; |
| 7339 | } |
cristy | f89cb1d | 2011-07-07 01:24:37 +0000 | [diff] [blame] | 7340 | (void) ClutImage(image,clut_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7341 | clut_image=DestroyImage(clut_image); |
| 7342 | InheritException(exception,&image->exception); |
| 7343 | *images=DestroyImageList(*images); |
| 7344 | *images=image; |
| 7345 | break; |
| 7346 | } |
| 7347 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7348 | { |
| 7349 | Image |
| 7350 | *coalesce_image; |
| 7351 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7352 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7353 | coalesce_image=CoalesceImages(*images,exception); |
| 7354 | if (coalesce_image == (Image *) NULL) |
| 7355 | { |
| 7356 | status=MagickFalse; |
| 7357 | break; |
| 7358 | } |
| 7359 | *images=DestroyImageList(*images); |
| 7360 | *images=coalesce_image; |
| 7361 | break; |
| 7362 | } |
| 7363 | if (LocaleCompare("combine",option+1) == 0) |
| 7364 | { |
| 7365 | Image |
| 7366 | *combine_image; |
| 7367 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7368 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 7369 | combine_image=CombineImages(*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7370 | if (combine_image == (Image *) NULL) |
| 7371 | { |
| 7372 | status=MagickFalse; |
| 7373 | break; |
| 7374 | } |
| 7375 | *images=DestroyImageList(*images); |
| 7376 | *images=combine_image; |
| 7377 | break; |
| 7378 | } |
| 7379 | if (LocaleCompare("composite",option+1) == 0) |
| 7380 | { |
| 7381 | Image |
| 7382 | *mask_image, |
| 7383 | *composite_image, |
| 7384 | *image; |
| 7385 | |
| 7386 | RectangleInfo |
| 7387 | geometry; |
| 7388 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7389 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7390 | image=RemoveFirstImageFromList(images); |
| 7391 | composite_image=RemoveFirstImageFromList(images); |
| 7392 | if (composite_image == (Image *) NULL) |
| 7393 | { |
| 7394 | status=MagickFalse; |
| 7395 | break; |
| 7396 | } |
| 7397 | (void) TransformImage(&composite_image,(char *) NULL, |
| 7398 | composite_image->geometry); |
| 7399 | SetGeometry(composite_image,&geometry); |
| 7400 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7401 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7402 | &geometry); |
| 7403 | mask_image=RemoveFirstImageFromList(images); |
| 7404 | if (mask_image != (Image *) NULL) |
| 7405 | { |
| 7406 | if ((image->compose == DisplaceCompositeOp) || |
| 7407 | (image->compose == DistortCompositeOp)) |
| 7408 | { |
| 7409 | /* |
| 7410 | Merge Y displacement into X displacement image. |
| 7411 | */ |
| 7412 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
| 7413 | mask_image,0,0); |
| 7414 | mask_image=DestroyImage(mask_image); |
| 7415 | } |
| 7416 | else |
| 7417 | { |
| 7418 | /* |
| 7419 | Set a blending mask for the composition. |
| 7420 | */ |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7421 | /* POSIBLE ERROR; what if image->mask already set */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7422 | image->mask=mask_image; |
| 7423 | (void) NegateImage(image->mask,MagickFalse); |
| 7424 | } |
| 7425 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7426 | (void) CompositeImage(image,image->compose,composite_image, |
| 7427 | geometry.x,geometry.y); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7428 | if (mask_image != (Image *) NULL) |
| 7429 | mask_image=image->mask=DestroyImage(image->mask); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7430 | composite_image=DestroyImage(composite_image); |
| 7431 | InheritException(exception,&image->exception); |
| 7432 | *images=DestroyImageList(*images); |
| 7433 | *images=image; |
| 7434 | break; |
| 7435 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7436 | #if 0 |
| 7437 | This has been merged completely into MogrifyImage() |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7438 | if (LocaleCompare("crop",option+1) == 0) |
| 7439 | { |
| 7440 | MagickStatusType |
| 7441 | flags; |
| 7442 | |
| 7443 | RectangleInfo |
| 7444 | geometry; |
| 7445 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7446 | /* |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7447 | Crop Image. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7448 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7449 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7450 | flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception); |
| 7451 | if (((geometry.width == 0) && (geometry.height == 0)) || |
| 7452 | ((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 7453 | break; |
| 7454 | (void) TransformImages(images,argv[i+1],(char *) NULL); |
| 7455 | InheritException(exception,&(*images)->exception); |
| 7456 | break; |
| 7457 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7458 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7459 | break; |
| 7460 | } |
| 7461 | case 'd': |
| 7462 | { |
| 7463 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7464 | { |
| 7465 | Image |
| 7466 | *deconstruct_image; |
| 7467 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7468 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7469 | deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer, |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 7470 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7471 | if (deconstruct_image == (Image *) NULL) |
| 7472 | { |
| 7473 | status=MagickFalse; |
| 7474 | break; |
| 7475 | } |
| 7476 | *images=DestroyImageList(*images); |
| 7477 | *images=deconstruct_image; |
| 7478 | break; |
| 7479 | } |
| 7480 | if (LocaleCompare("delete",option+1) == 0) |
| 7481 | { |
| 7482 | if (*option == '+') |
| 7483 | DeleteImages(images,"-1",exception); |
| 7484 | else |
| 7485 | DeleteImages(images,argv[i+1],exception); |
| 7486 | break; |
| 7487 | } |
| 7488 | if (LocaleCompare("dither",option+1) == 0) |
| 7489 | { |
| 7490 | if (*option == '+') |
| 7491 | { |
| 7492 | quantize_info->dither=MagickFalse; |
| 7493 | break; |
| 7494 | } |
| 7495 | quantize_info->dither=MagickTrue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7496 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7497 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7498 | break; |
| 7499 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7500 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7501 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7502 | Image |
| 7503 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7504 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7505 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7506 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7507 | else |
| 7508 | { |
| 7509 | const char |
| 7510 | *p; |
| 7511 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7512 | size_t |
| 7513 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7514 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7515 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7516 | p=strchr(argv[i+1],','); |
| 7517 | if (p == (const char *) NULL) |
| 7518 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7519 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7520 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7521 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7522 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7523 | } |
| 7524 | AppendImageToList(images, duplicate_images); |
| 7525 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7526 | break; |
| 7527 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7528 | break; |
| 7529 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7530 | case 'e': |
| 7531 | { |
| 7532 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7533 | { |
| 7534 | Image |
| 7535 | *evaluate_image; |
| 7536 | |
| 7537 | MagickEvaluateOperator |
| 7538 | op; |
| 7539 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7540 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7541 | op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions, |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7542 | MagickFalse,argv[i+1]); |
| 7543 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7544 | if (evaluate_image == (Image *) NULL) |
| 7545 | { |
| 7546 | status=MagickFalse; |
| 7547 | break; |
| 7548 | } |
| 7549 | *images=DestroyImageList(*images); |
| 7550 | *images=evaluate_image; |
| 7551 | break; |
| 7552 | } |
| 7553 | break; |
| 7554 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7555 | case 'f': |
| 7556 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7557 | if (LocaleCompare("fft",option+1) == 0) |
| 7558 | { |
| 7559 | Image |
| 7560 | *fourier_image; |
| 7561 | |
| 7562 | /* |
| 7563 | Implements the discrete Fourier transform (DFT). |
| 7564 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7565 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7566 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7567 | MagickTrue : MagickFalse,exception); |
| 7568 | if (fourier_image == (Image *) NULL) |
| 7569 | break; |
| 7570 | *images=DestroyImage(*images); |
| 7571 | *images=fourier_image; |
| 7572 | break; |
| 7573 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7574 | if (LocaleCompare("flatten",option+1) == 0) |
| 7575 | { |
| 7576 | Image |
| 7577 | *flatten_image; |
| 7578 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7579 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7580 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7581 | if (flatten_image == (Image *) NULL) |
| 7582 | break; |
| 7583 | *images=DestroyImageList(*images); |
| 7584 | *images=flatten_image; |
| 7585 | break; |
| 7586 | } |
| 7587 | if (LocaleCompare("fx",option+1) == 0) |
| 7588 | { |
| 7589 | Image |
| 7590 | *fx_image; |
| 7591 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7592 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 7593 | fx_image=FxImage(*images,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7594 | if (fx_image == (Image *) NULL) |
| 7595 | { |
| 7596 | status=MagickFalse; |
| 7597 | break; |
| 7598 | } |
| 7599 | *images=DestroyImageList(*images); |
| 7600 | *images=fx_image; |
| 7601 | break; |
| 7602 | } |
| 7603 | break; |
| 7604 | } |
| 7605 | case 'h': |
| 7606 | { |
| 7607 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7608 | { |
| 7609 | Image |
| 7610 | *hald_image, |
| 7611 | *image; |
| 7612 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7613 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7614 | image=RemoveFirstImageFromList(images); |
| 7615 | hald_image=RemoveFirstImageFromList(images); |
| 7616 | if (hald_image == (Image *) NULL) |
| 7617 | { |
| 7618 | status=MagickFalse; |
| 7619 | break; |
| 7620 | } |
cristy | f89cb1d | 2011-07-07 01:24:37 +0000 | [diff] [blame] | 7621 | (void) HaldClutImage(image,hald_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7622 | hald_image=DestroyImage(hald_image); |
| 7623 | InheritException(exception,&image->exception); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7624 | if (*images != (Image *) NULL) |
| 7625 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7626 | *images=image; |
| 7627 | break; |
| 7628 | } |
| 7629 | break; |
| 7630 | } |
| 7631 | case 'i': |
| 7632 | { |
| 7633 | if (LocaleCompare("ift",option+1) == 0) |
| 7634 | { |
| 7635 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7636 | *fourier_image, |
| 7637 | *magnitude_image, |
| 7638 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7639 | |
| 7640 | /* |
| 7641 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7642 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7643 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7644 | magnitude_image=RemoveFirstImageFromList(images); |
| 7645 | phase_image=RemoveFirstImageFromList(images); |
| 7646 | if (phase_image == (Image *) NULL) |
| 7647 | { |
| 7648 | status=MagickFalse; |
| 7649 | break; |
| 7650 | } |
| 7651 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7652 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7653 | if (fourier_image == (Image *) NULL) |
| 7654 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7655 | if (*images != (Image *) NULL) |
| 7656 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7657 | *images=fourier_image; |
| 7658 | break; |
| 7659 | } |
| 7660 | if (LocaleCompare("insert",option+1) == 0) |
| 7661 | { |
| 7662 | Image |
| 7663 | *p, |
| 7664 | *q; |
| 7665 | |
| 7666 | index=0; |
| 7667 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7668 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7669 | p=RemoveLastImageFromList(images); |
| 7670 | if (p == (Image *) NULL) |
| 7671 | { |
| 7672 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7673 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7674 | status=MagickFalse; |
| 7675 | break; |
| 7676 | } |
| 7677 | q=p; |
| 7678 | if (index == 0) |
| 7679 | PrependImageToList(images,q); |
| 7680 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7681 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7682 | AppendImageToList(images,q); |
| 7683 | else |
| 7684 | { |
| 7685 | q=GetImageFromList(*images,index-1); |
| 7686 | if (q == (Image *) NULL) |
| 7687 | { |
| 7688 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7689 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7690 | status=MagickFalse; |
| 7691 | break; |
| 7692 | } |
| 7693 | InsertImageInList(&q,p); |
| 7694 | } |
| 7695 | *images=GetFirstImageInList(q); |
| 7696 | break; |
| 7697 | } |
| 7698 | break; |
| 7699 | } |
| 7700 | case 'l': |
| 7701 | { |
| 7702 | if (LocaleCompare("layers",option+1) == 0) |
| 7703 | { |
| 7704 | Image |
| 7705 | *layers; |
| 7706 | |
| 7707 | ImageLayerMethod |
| 7708 | method; |
| 7709 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7710 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7711 | layers=(Image *) NULL; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7712 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7713 | MagickFalse,argv[i+1]); |
| 7714 | switch (method) |
| 7715 | { |
| 7716 | case CoalesceLayer: |
| 7717 | { |
| 7718 | layers=CoalesceImages(*images,exception); |
| 7719 | break; |
| 7720 | } |
| 7721 | case CompareAnyLayer: |
| 7722 | case CompareClearLayer: |
| 7723 | case CompareOverlayLayer: |
| 7724 | default: |
| 7725 | { |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7726 | layers=CompareImagesLayers(*images,method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7727 | break; |
| 7728 | } |
| 7729 | case MergeLayer: |
| 7730 | case FlattenLayer: |
| 7731 | case MosaicLayer: |
| 7732 | case TrimBoundsLayer: |
| 7733 | { |
| 7734 | layers=MergeImageLayers(*images,method,exception); |
| 7735 | break; |
| 7736 | } |
| 7737 | case DisposeLayer: |
| 7738 | { |
| 7739 | layers=DisposeImages(*images,exception); |
| 7740 | break; |
| 7741 | } |
| 7742 | case OptimizeImageLayer: |
| 7743 | { |
| 7744 | layers=OptimizeImageLayers(*images,exception); |
| 7745 | break; |
| 7746 | } |
| 7747 | case OptimizePlusLayer: |
| 7748 | { |
| 7749 | layers=OptimizePlusImageLayers(*images,exception); |
| 7750 | break; |
| 7751 | } |
| 7752 | case OptimizeTransLayer: |
| 7753 | { |
| 7754 | OptimizeImageTransparency(*images,exception); |
| 7755 | break; |
| 7756 | } |
| 7757 | case RemoveDupsLayer: |
| 7758 | { |
| 7759 | RemoveDuplicateLayers(images,exception); |
| 7760 | break; |
| 7761 | } |
| 7762 | case RemoveZeroLayer: |
| 7763 | { |
| 7764 | RemoveZeroDelayLayers(images,exception); |
| 7765 | break; |
| 7766 | } |
| 7767 | case OptimizeLayer: |
| 7768 | { |
| 7769 | /* |
| 7770 | General Purpose, GIF Animation Optimizer. |
| 7771 | */ |
| 7772 | layers=CoalesceImages(*images,exception); |
| 7773 | if (layers == (Image *) NULL) |
| 7774 | { |
| 7775 | status=MagickFalse; |
| 7776 | break; |
| 7777 | } |
| 7778 | InheritException(exception,&layers->exception); |
| 7779 | *images=DestroyImageList(*images); |
| 7780 | *images=layers; |
| 7781 | layers=OptimizeImageLayers(*images,exception); |
| 7782 | if (layers == (Image *) NULL) |
| 7783 | { |
| 7784 | status=MagickFalse; |
| 7785 | break; |
| 7786 | } |
| 7787 | InheritException(exception,&layers->exception); |
| 7788 | *images=DestroyImageList(*images); |
| 7789 | *images=layers; |
| 7790 | layers=(Image *) NULL; |
| 7791 | OptimizeImageTransparency(*images,exception); |
| 7792 | InheritException(exception,&(*images)->exception); |
| 7793 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7794 | break; |
| 7795 | } |
| 7796 | case CompositeLayer: |
| 7797 | { |
| 7798 | CompositeOperator |
| 7799 | compose; |
| 7800 | |
| 7801 | Image |
| 7802 | *source; |
| 7803 | |
| 7804 | RectangleInfo |
| 7805 | geometry; |
| 7806 | |
| 7807 | /* |
| 7808 | Split image sequence at the first 'NULL:' image. |
| 7809 | */ |
| 7810 | source=(*images); |
| 7811 | while (source != (Image *) NULL) |
| 7812 | { |
| 7813 | source=GetNextImageInList(source); |
| 7814 | if ((source != (Image *) NULL) && |
| 7815 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7816 | break; |
| 7817 | } |
| 7818 | if (source != (Image *) NULL) |
| 7819 | { |
| 7820 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7821 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7822 | source=(Image *) NULL; |
| 7823 | else |
| 7824 | { |
| 7825 | /* |
| 7826 | Separate the two lists, junk the null: image. |
| 7827 | */ |
| 7828 | source=SplitImageList(source->previous); |
| 7829 | DeleteImageFromList(&source); |
| 7830 | } |
| 7831 | } |
| 7832 | if (source == (Image *) NULL) |
| 7833 | { |
| 7834 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7835 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7836 | status=MagickFalse; |
| 7837 | break; |
| 7838 | } |
| 7839 | /* |
| 7840 | Adjust offset with gravity and virtual canvas. |
| 7841 | */ |
| 7842 | SetGeometry(*images,&geometry); |
| 7843 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7844 | geometry.width=source->page.width != 0 ? |
| 7845 | source->page.width : source->columns; |
| 7846 | geometry.height=source->page.height != 0 ? |
| 7847 | source->page.height : source->rows; |
| 7848 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7849 | (*images)->page.width : (*images)->columns, |
| 7850 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7851 | (*images)->rows,(*images)->gravity,&geometry); |
| 7852 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7853 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7854 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7855 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7856 | MagickComposeOptions,MagickFalse,option); |
| 7857 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7858 | exception); |
| 7859 | source=DestroyImageList(source); |
| 7860 | break; |
| 7861 | } |
| 7862 | } |
| 7863 | if (layers == (Image *) NULL) |
| 7864 | break; |
| 7865 | InheritException(exception,&layers->exception); |
| 7866 | *images=DestroyImageList(*images); |
| 7867 | *images=layers; |
| 7868 | break; |
| 7869 | } |
| 7870 | break; |
| 7871 | } |
| 7872 | case 'm': |
| 7873 | { |
| 7874 | if (LocaleCompare("map",option+1) == 0) |
| 7875 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7876 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7877 | if (*option == '+') |
| 7878 | { |
| 7879 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7880 | InheritException(exception,&(*images)->exception); |
| 7881 | break; |
| 7882 | } |
| 7883 | i++; |
| 7884 | break; |
| 7885 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7886 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7887 | { |
| 7888 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7889 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7890 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7891 | /* |
| 7892 | Maximum image sequence (deprecated). |
| 7893 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7894 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7895 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7896 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7897 | { |
| 7898 | status=MagickFalse; |
| 7899 | break; |
| 7900 | } |
| 7901 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7902 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7903 | break; |
| 7904 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7905 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7906 | { |
| 7907 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7908 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7909 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7910 | /* |
| 7911 | Minimum image sequence (deprecated). |
| 7912 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7913 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7914 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7915 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7916 | { |
| 7917 | status=MagickFalse; |
| 7918 | break; |
| 7919 | } |
| 7920 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7921 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7922 | break; |
| 7923 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7924 | if (LocaleCompare("morph",option+1) == 0) |
| 7925 | { |
| 7926 | Image |
| 7927 | *morph_image; |
| 7928 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7929 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7930 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7931 | exception); |
| 7932 | if (morph_image == (Image *) NULL) |
| 7933 | { |
| 7934 | status=MagickFalse; |
| 7935 | break; |
| 7936 | } |
| 7937 | *images=DestroyImageList(*images); |
| 7938 | *images=morph_image; |
| 7939 | break; |
| 7940 | } |
| 7941 | if (LocaleCompare("mosaic",option+1) == 0) |
| 7942 | { |
| 7943 | Image |
| 7944 | *mosaic_image; |
| 7945 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7946 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7947 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 7948 | if (mosaic_image == (Image *) NULL) |
| 7949 | { |
| 7950 | status=MagickFalse; |
| 7951 | break; |
| 7952 | } |
| 7953 | *images=DestroyImageList(*images); |
| 7954 | *images=mosaic_image; |
| 7955 | break; |
| 7956 | } |
| 7957 | break; |
| 7958 | } |
| 7959 | case 'p': |
| 7960 | { |
| 7961 | if (LocaleCompare("print",option+1) == 0) |
| 7962 | { |
| 7963 | char |
| 7964 | *string; |
| 7965 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7966 | (void) SyncImagesSettings(mogrify_info,*images); |
| 7967 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7968 | if (string == (char *) NULL) |
| 7969 | break; |
| 7970 | InheritException(exception,&(*images)->exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 7971 | (void) FormatLocaleFile(stdout,"%s",string); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7972 | string=DestroyString(string); |
| 7973 | } |
| 7974 | if (LocaleCompare("process",option+1) == 0) |
| 7975 | { |
| 7976 | char |
| 7977 | **arguments; |
| 7978 | |
| 7979 | int |
| 7980 | j, |
| 7981 | number_arguments; |
| 7982 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7983 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7984 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 7985 | if (arguments == (char **) NULL) |
| 7986 | break; |
| 7987 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 7988 | { |
| 7989 | char |
| 7990 | breaker, |
| 7991 | quote, |
| 7992 | *token; |
| 7993 | |
| 7994 | const char |
| 7995 | *arguments; |
| 7996 | |
| 7997 | int |
| 7998 | next, |
| 7999 | status; |
| 8000 | |
| 8001 | size_t |
| 8002 | length; |
| 8003 | |
| 8004 | TokenInfo |
| 8005 | *token_info; |
| 8006 | |
| 8007 | /* |
| 8008 | Support old style syntax, filter="-option arg". |
| 8009 | */ |
| 8010 | length=strlen(argv[i+1]); |
| 8011 | token=(char *) NULL; |
cristy | 37e0b38 | 2011-06-07 13:31:21 +0000 | [diff] [blame] | 8012 | if (~length >= (MaxTextExtent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8013 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8014 | sizeof(*token)); |
| 8015 | if (token == (char *) NULL) |
| 8016 | break; |
| 8017 | next=0; |
| 8018 | arguments=argv[i+1]; |
| 8019 | token_info=AcquireTokenInfo(); |
| 8020 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8021 | "\"",'\0',&breaker,&next,"e); |
| 8022 | token_info=DestroyTokenInfo(token_info); |
| 8023 | if (status == 0) |
| 8024 | { |
| 8025 | const char |
| 8026 | *argv; |
| 8027 | |
| 8028 | argv=(&(arguments[next])); |
| 8029 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8030 | exception); |
| 8031 | } |
| 8032 | token=DestroyString(token); |
| 8033 | break; |
| 8034 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8035 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8036 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8037 | number_arguments-2,(const char **) arguments+2,exception); |
| 8038 | for (j=0; j < number_arguments; j++) |
| 8039 | arguments[j]=DestroyString(arguments[j]); |
| 8040 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8041 | break; |
| 8042 | } |
| 8043 | break; |
| 8044 | } |
| 8045 | case 'r': |
| 8046 | { |
| 8047 | if (LocaleCompare("reverse",option+1) == 0) |
| 8048 | { |
| 8049 | ReverseImageList(images); |
| 8050 | InheritException(exception,&(*images)->exception); |
| 8051 | break; |
| 8052 | } |
| 8053 | break; |
| 8054 | } |
| 8055 | case 's': |
| 8056 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8057 | if (LocaleCompare("smush",option+1) == 0) |
| 8058 | { |
| 8059 | Image |
| 8060 | *smush_image; |
| 8061 | |
| 8062 | ssize_t |
| 8063 | offset; |
| 8064 | |
| 8065 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8066 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8067 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8068 | MagickFalse,offset,exception); |
| 8069 | if (smush_image == (Image *) NULL) |
| 8070 | { |
| 8071 | status=MagickFalse; |
| 8072 | break; |
| 8073 | } |
| 8074 | *images=DestroyImageList(*images); |
| 8075 | *images=smush_image; |
| 8076 | break; |
| 8077 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8078 | if (LocaleCompare("swap",option+1) == 0) |
| 8079 | { |
| 8080 | Image |
| 8081 | *p, |
| 8082 | *q, |
| 8083 | *swap; |
| 8084 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8085 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8086 | swap_index; |
| 8087 | |
| 8088 | index=(-1); |
| 8089 | swap_index=(-2); |
| 8090 | if (*option != '+') |
| 8091 | { |
| 8092 | GeometryInfo |
| 8093 | geometry_info; |
| 8094 | |
| 8095 | MagickStatusType |
| 8096 | flags; |
| 8097 | |
| 8098 | swap_index=(-1); |
| 8099 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8100 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8101 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8102 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8103 | } |
| 8104 | p=GetImageFromList(*images,index); |
| 8105 | q=GetImageFromList(*images,swap_index); |
| 8106 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8107 | { |
| 8108 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8109 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8110 | status=MagickFalse; |
| 8111 | break; |
| 8112 | } |
| 8113 | if (p == q) |
| 8114 | break; |
| 8115 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8116 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8117 | ReplaceImageInList(&q,swap); |
| 8118 | *images=GetFirstImageInList(q); |
| 8119 | break; |
| 8120 | } |
| 8121 | break; |
| 8122 | } |
| 8123 | case 'w': |
| 8124 | { |
| 8125 | if (LocaleCompare("write",option+1) == 0) |
| 8126 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8127 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8128 | key[MaxTextExtent]; |
| 8129 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8130 | Image |
| 8131 | *write_images; |
| 8132 | |
| 8133 | ImageInfo |
| 8134 | *write_info; |
| 8135 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8136 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8137 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8138 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8139 | write_images=(*images); |
| 8140 | if (*option == '+') |
| 8141 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8142 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8143 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8144 | write_info=DestroyImageInfo(write_info); |
| 8145 | if (*option == '+') |
| 8146 | write_images=DestroyImageList(write_images); |
| 8147 | break; |
| 8148 | } |
| 8149 | break; |
| 8150 | } |
| 8151 | default: |
| 8152 | break; |
| 8153 | } |
| 8154 | i+=count; |
| 8155 | } |
| 8156 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8157 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8158 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8159 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8160 | } |
| 8161 | |
| 8162 | /* |
| 8163 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8164 | % % |
| 8165 | % % |
| 8166 | % % |
| 8167 | + M o g r i f y I m a g e s % |
| 8168 | % % |
| 8169 | % % |
| 8170 | % % |
| 8171 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8172 | % |
| 8173 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8174 | % prescribed by command line options. |
| 8175 | % |
| 8176 | % The format of the MogrifyImage method is: |
| 8177 | % |
| 8178 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8179 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8180 | % Image **images,Exceptioninfo *exception) |
| 8181 | % |
| 8182 | % A description of each parameter follows: |
| 8183 | % |
| 8184 | % o image_info: the image info.. |
| 8185 | % |
| 8186 | % o post: If true, post process image list operators otherwise pre-process. |
| 8187 | % |
| 8188 | % o argc: Specifies a pointer to an integer describing the number of |
| 8189 | % elements in the argument vector. |
| 8190 | % |
| 8191 | % o argv: Specifies a pointer to a text array containing the command line |
| 8192 | % arguments. |
| 8193 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8194 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8195 | % |
| 8196 | % o exception: return any errors or warnings in this structure. |
| 8197 | % |
| 8198 | */ |
| 8199 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8200 | const MagickBooleanType post,const int argc,const char **argv, |
| 8201 | Image **images,ExceptionInfo *exception) |
| 8202 | { |
| 8203 | #define MogrifyImageTag "Mogrify/Image" |
| 8204 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8205 | MagickStatusType |
| 8206 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8207 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8208 | MagickBooleanType |
| 8209 | proceed; |
| 8210 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8211 | size_t |
| 8212 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8213 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8214 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8215 | i; |
| 8216 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8217 | assert(image_info != (ImageInfo *) NULL); |
| 8218 | assert(image_info->signature == MagickSignature); |
| 8219 | if (images == (Image **) NULL) |
| 8220 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8221 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8222 | assert((*images)->signature == MagickSignature); |
| 8223 | if ((*images)->debug != MagickFalse) |
| 8224 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8225 | (*images)->filename); |
| 8226 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8227 | return(MagickTrue); |
| 8228 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8229 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8230 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8231 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8232 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8233 | (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc, |
| 8234 | post?"post":"pre"); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8235 | #endif |
| 8236 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8237 | /* |
| 8238 | Pre-process multi-image sequence operators |
| 8239 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8240 | if (post == MagickFalse) |
| 8241 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8242 | /* |
| 8243 | For each image, process simple single image operators |
| 8244 | */ |
| 8245 | i=0; |
| 8246 | n=GetImageListLength(*images); |
| 8247 | for (;;) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8248 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8249 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8250 | (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long) |
| 8251 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8252 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8253 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8254 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8255 | if (proceed == MagickFalse) |
| 8256 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8257 | if ( (*images)->next == (Image *) NULL ) |
| 8258 | break; |
| 8259 | *images=(*images)->next; |
| 8260 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8261 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8262 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8263 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8264 | (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long) |
| 8265 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8266 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8267 | |
| 8268 | /* |
| 8269 | Post-process, multi-image sequence operators |
| 8270 | */ |
| 8271 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8272 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8273 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8274 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8275 | } |