cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % M M OOO GGGGG RRRR IIIII FFFFF Y Y % |
| 7 | % MM MM O O G R R I F Y Y % |
| 8 | % M M M O O G GGG RRRR I FFF Y % |
| 9 | % M M O O G G R R I F Y % |
| 10 | % M M OOO GGGG R R IIIII F Y % |
| 11 | % % |
| 12 | % % |
| 13 | % MagickWand Module Methods % |
| 14 | % % |
| 15 | % Software Design % |
| 16 | % John Cristy % |
| 17 | % March 2000 % |
| 18 | % % |
| 19 | % % |
cristy | 7e41fe8 | 2010-12-04 23:12:08 +0000 | [diff] [blame] | 20 | % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 21 | % dedicated to making software imaging solutions freely available. % |
| 22 | % % |
| 23 | % You may not use this file except in compliance with the License. You may % |
| 24 | % obtain a copy of the License at % |
| 25 | % % |
| 26 | % http://www.imagemagick.org/script/license.php % |
| 27 | % % |
| 28 | % Unless required by applicable law or agreed to in writing, software % |
| 29 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 30 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 31 | % See the License for the specific language governing permissions and % |
| 32 | % limitations under the License. % |
| 33 | % % |
| 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 35 | % |
| 36 | % Use the mogrify program to resize an image, blur, crop, despeckle, dither, |
| 37 | % draw on, flip, join, re-sample, and much more. This tool is similiar to |
| 38 | % convert except that the original image file is overwritten (unless you |
| 39 | % change the file suffix with the -format option) with any changes you |
cristy | 6a917d9 | 2009-10-06 19:23:54 +0000 | [diff] [blame] | 40 | % request. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 41 | % |
| 42 | */ |
| 43 | |
| 44 | /* |
| 45 | Include declarations. |
| 46 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 47 | #include "MagickWand/studio.h" |
| 48 | #include "MagickWand/MagickWand.h" |
| 49 | #include "MagickWand/mogrify-private.h" |
| 50 | #undef DegreesToRadians |
| 51 | #undef RadiansToDegrees |
| 52 | #include "MagickCore/image-private.h" |
| 53 | #include "MagickCore/monitor-private.h" |
| 54 | #include "MagickCore/thread-private.h" |
| 55 | #include "MagickCore/string-private.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 56 | |
| 57 | /* |
cristy | 154fa9d | 2011-08-05 14:25:15 +0000 | [diff] [blame] | 58 | Constant declaration. |
| 59 | */ |
cristy | 3a557c0 | 2011-08-06 19:48:02 +0000 | [diff] [blame] | 60 | static const char |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 61 | MogrifyBackgroundColor[] = "#ffffff", /* white */ |
| 62 | MogrifyBorderColor[] = "#dfdfdf", /* gray */ |
| 63 | MogrifyMatteColor[] = "#bdbdbd"; /* gray */ |
cristy | 154fa9d | 2011-08-05 14:25:15 +0000 | [diff] [blame] | 64 | |
| 65 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 66 | Define declarations. |
| 67 | */ |
| 68 | #define UndefinedCompressionQuality 0UL |
| 69 | |
| 70 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 71 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 72 | % % |
| 73 | % % |
| 74 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 75 | % M a g i c k C o m m a n d G e n e s i s % |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 76 | % % |
| 77 | % % |
| 78 | % % |
| 79 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 80 | % |
| 81 | % MagickCommandGenesis() applies image processing options to an image as |
| 82 | % prescribed by command line options. |
| 83 | % |
| 84 | % The format of the MagickCommandGenesis method is: |
| 85 | % |
| 86 | % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 87 | % MagickCommand command,int argc,char **argv,char **metadata, |
| 88 | % ExceptionInfo *exception) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 89 | % |
| 90 | % A description of each parameter follows: |
| 91 | % |
| 92 | % o image_info: the image info. |
| 93 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 94 | % o command: Choose from ConvertImageCommand, IdentifyImageCommand, |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 95 | % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 96 | % ConjureImageCommand, StreamImageCommand, ImportImageCommand, |
| 97 | % DisplayImageCommand, or AnimateImageCommand. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 98 | % |
| 99 | % o argc: Specifies a pointer to an integer describing the number of |
| 100 | % elements in the argument vector. |
| 101 | % |
| 102 | % o argv: Specifies a pointer to a text array containing the command line |
| 103 | % arguments. |
| 104 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 105 | % o metadata: any metadata is returned here. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 106 | % |
| 107 | % o exception: return any errors or warnings in this structure. |
| 108 | % |
| 109 | */ |
| 110 | WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
| 111 | MagickCommand command,int argc,char **argv,char **metadata, |
| 112 | ExceptionInfo *exception) |
| 113 | { |
| 114 | char |
| 115 | *option; |
| 116 | |
| 117 | double |
| 118 | duration, |
| 119 | elapsed_time, |
| 120 | user_time; |
| 121 | |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 122 | MagickBooleanType |
| 123 | concurrent, |
| 124 | regard_warnings, |
| 125 | status; |
| 126 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 127 | register ssize_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 128 | i; |
| 129 | |
| 130 | TimerInfo |
| 131 | *timer; |
| 132 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 133 | size_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 134 | iterations; |
| 135 | |
cristy | d0a94fa | 2010-03-12 14:18:11 +0000 | [diff] [blame] | 136 | (void) setlocale(LC_ALL,""); |
| 137 | (void) setlocale(LC_NUMERIC,"C"); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 138 | concurrent=MagickFalse; |
| 139 | duration=(-1.0); |
| 140 | iterations=1; |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 141 | status=MagickFalse; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 142 | regard_warnings=MagickFalse; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 143 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 144 | { |
| 145 | option=argv[i]; |
| 146 | if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) |
| 147 | continue; |
| 148 | if (LocaleCompare("bench",option+1) == 0) |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 149 | iterations=StringToUnsignedLong(argv[++i]); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 150 | if (LocaleCompare("concurrent",option+1) == 0) |
| 151 | concurrent=MagickTrue; |
| 152 | if (LocaleCompare("debug",option+1) == 0) |
| 153 | (void) SetLogEventMask(argv[++i]); |
| 154 | if (LocaleCompare("duration",option+1) == 0) |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 155 | duration=InterpretLocaleValue(argv[++i],(char **) NULL); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 156 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 157 | regard_warnings=MagickTrue; |
| 158 | } |
| 159 | timer=AcquireTimerInfo(); |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 160 | if (concurrent == MagickFalse) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 161 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 162 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 163 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 164 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 165 | continue; |
| 166 | if (duration > 0) |
| 167 | { |
| 168 | if (GetElapsedTime(timer) > duration) |
| 169 | continue; |
| 170 | (void) ContinueTimer(timer); |
| 171 | } |
| 172 | status=command(image_info,argc,argv,metadata,exception); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 173 | if (exception->severity != UndefinedException) |
| 174 | { |
| 175 | if ((exception->severity > ErrorException) || |
| 176 | (regard_warnings != MagickFalse)) |
| 177 | status=MagickTrue; |
| 178 | CatchException(exception); |
| 179 | } |
cristy | 3d1a551 | 2009-10-25 21:23:27 +0000 | [diff] [blame] | 180 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 181 | { |
| 182 | (void) fputs(*metadata,stdout); |
| 183 | (void) fputc('\n',stdout); |
| 184 | *metadata=DestroyString(*metadata); |
| 185 | } |
| 186 | } |
| 187 | } |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 188 | else |
| 189 | { |
| 190 | SetOpenMPNested(1); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 191 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 192 | # pragma omp parallel for shared(status) |
| 193 | #endif |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 194 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 195 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 196 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 197 | continue; |
| 198 | if (duration > 0) |
| 199 | { |
| 200 | if (GetElapsedTime(timer) > duration) |
| 201 | continue; |
| 202 | (void) ContinueTimer(timer); |
| 203 | } |
| 204 | status=command(image_info,argc,argv,metadata,exception); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 205 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 206 | # pragma omp critical (MagickCore_CommandGenesis) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 207 | #endif |
| 208 | { |
| 209 | if (exception->severity != UndefinedException) |
| 210 | { |
| 211 | if ((exception->severity > ErrorException) || |
| 212 | (regard_warnings != MagickFalse)) |
| 213 | status=MagickTrue; |
| 214 | CatchException(exception); |
| 215 | } |
| 216 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 217 | { |
| 218 | (void) fputs(*metadata,stdout); |
| 219 | (void) fputc('\n',stdout); |
| 220 | *metadata=DestroyString(*metadata); |
| 221 | } |
| 222 | } |
| 223 | } |
| 224 | } |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 225 | if (iterations > 1) |
| 226 | { |
| 227 | elapsed_time=GetElapsedTime(timer); |
| 228 | user_time=GetUserTime(timer); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 229 | (void) FormatLocaleFile(stderr, |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 230 | "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double) |
| 231 | iterations,1.0*iterations/elapsed_time,user_time,(double) |
| 232 | (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double) |
| 233 | (1000.0*(elapsed_time-floor(elapsed_time)))); |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 234 | (void) fflush(stderr); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 235 | } |
| 236 | timer=DestroyTimerInfo(timer); |
cristy | 1f9e1ed | 2009-11-18 04:09:38 +0000 | [diff] [blame] | 237 | return(status); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | /* |
| 241 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 242 | % % |
| 243 | % % |
| 244 | % % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 245 | + M o g r i f y I m a g e % |
| 246 | % % |
| 247 | % % |
| 248 | % % |
| 249 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 250 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 251 | % MogrifyImage() applies simple single image processing options to a single |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 252 | % image that may be part of a large list, but also handles any 'region' |
| 253 | % image handling. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 254 | % |
| 255 | % The image in the list may be modified in three different ways... |
| 256 | % |
| 257 | % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 258 | % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 259 | % * replace by a list of images (only the -separate option!) |
| 260 | % |
| 261 | % In each case the result is returned into the list, and a pointer to the |
| 262 | % modified image (last image added if replaced by a list of images) is |
| 263 | % returned. |
| 264 | % |
| 265 | % ASIDE: The -crop is present but restricted to non-tile single image crops |
| 266 | % |
| 267 | % This means if all the images are being processed (such as by |
| 268 | % MogrifyImages(), next image to be processed will be as per the pointer |
| 269 | % (*image)->next. Also the image list may grow as a result of some specific |
| 270 | % operations but as images are never merged or deleted, it will never shrink |
| 271 | % in length. Typically the list will remain the same length. |
| 272 | % |
| 273 | % WARNING: As the image pointed to may be replaced, the first image in the |
| 274 | % list may also change. GetFirstImageInList() should be used by caller if |
| 275 | % they wish return the Image pointer to the first image in list. |
| 276 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 277 | % |
| 278 | % The format of the MogrifyImage method is: |
| 279 | % |
| 280 | % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 281 | % const char **argv,Image **image) |
| 282 | % |
| 283 | % A description of each parameter follows: |
| 284 | % |
| 285 | % o image_info: the image info.. |
| 286 | % |
| 287 | % o argc: Specifies a pointer to an integer describing the number of |
| 288 | % elements in the argument vector. |
| 289 | % |
| 290 | % o argv: Specifies a pointer to a text array containing the command line |
| 291 | % arguments. |
| 292 | % |
| 293 | % o image: the image. |
| 294 | % |
| 295 | % o exception: return any errors or warnings in this structure. |
| 296 | % |
| 297 | */ |
| 298 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 299 | /* |
| 300 | ** GetImageCache() will read an image into a image cache if not already |
| 301 | ** present then return the image that is in the cache under that filename. |
| 302 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 303 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 304 | ExceptionInfo *exception) |
| 305 | { |
| 306 | char |
| 307 | key[MaxTextExtent]; |
| 308 | |
| 309 | ExceptionInfo |
| 310 | *sans_exception; |
| 311 | |
| 312 | Image |
| 313 | *image; |
| 314 | |
| 315 | ImageInfo |
| 316 | *read_info; |
| 317 | |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 318 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 319 | sans_exception=AcquireExceptionInfo(); |
| 320 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 321 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 322 | if (image != (Image *) NULL) |
| 323 | return(image); |
| 324 | read_info=CloneImageInfo(image_info); |
| 325 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 326 | image=ReadImage(read_info,exception); |
| 327 | read_info=DestroyImageInfo(read_info); |
| 328 | if (image != (Image *) NULL) |
| 329 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 330 | return(image); |
| 331 | } |
| 332 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 333 | static MagickBooleanType IsPathWritable(const char *path) |
| 334 | { |
| 335 | if (IsPathAccessible(path) == MagickFalse) |
| 336 | return(MagickFalse); |
| 337 | if (access(path,W_OK) != 0) |
| 338 | return(MagickFalse); |
| 339 | return(MagickTrue); |
| 340 | } |
| 341 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 342 | static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 343 | { |
| 344 | if (x > y) |
| 345 | return(x); |
| 346 | return(y); |
| 347 | } |
| 348 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 349 | static MagickBooleanType MonitorProgress(const char *text, |
| 350 | const MagickOffsetType offset,const MagickSizeType extent, |
| 351 | void *wand_unused(client_data)) |
| 352 | { |
| 353 | char |
| 354 | message[MaxTextExtent], |
| 355 | tag[MaxTextExtent]; |
| 356 | |
| 357 | const char |
| 358 | *locale_message; |
| 359 | |
| 360 | register char |
| 361 | *p; |
| 362 | |
| 363 | if (extent < 2) |
| 364 | return(MagickTrue); |
| 365 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 366 | p=strrchr(tag,'/'); |
| 367 | if (p != (char *) NULL) |
| 368 | *p='\0'; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 369 | (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 370 | locale_message=GetLocaleMessage(message); |
| 371 | if (locale_message == message) |
| 372 | locale_message=tag; |
| 373 | if (p == (char *) NULL) |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 374 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", |
| 375 | locale_message,(long) offset,(unsigned long) extent,(long) |
| 376 | (100L*offset/(extent-1))); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 377 | else |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 378 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 379 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 380 | (100L*offset/(extent-1))); |
| 381 | if (offset == (MagickOffsetType) (extent-1)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 382 | (void) FormatLocaleFile(stderr,"\n"); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 383 | (void) fflush(stderr); |
| 384 | return(MagickTrue); |
| 385 | } |
| 386 | |
| 387 | /* |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 388 | ** SparseColorOption() parses the complex -sparse-color argument into an |
| 389 | ** an array of floating point values then calls SparseColorImage(). |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 390 | ** Argument is a complex mix of floating-point pixel coodinates, and color |
| 391 | ** specifications (or direct floating point numbers). The number of floats |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 392 | ** needed to represent a color varies depending on the current channel |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 393 | ** setting. |
| 394 | */ |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 395 | static Image *SparseColorOption(const Image *image, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 396 | const SparseColorMethod method,const char *arguments, |
| 397 | const MagickBooleanType color_from_image,ExceptionInfo *exception) |
| 398 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 399 | char |
| 400 | token[MaxTextExtent]; |
| 401 | |
| 402 | const char |
| 403 | *p; |
| 404 | |
| 405 | double |
| 406 | *sparse_arguments; |
| 407 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 408 | Image |
| 409 | *sparse_image; |
| 410 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 411 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 412 | color; |
| 413 | |
| 414 | MagickBooleanType |
| 415 | error; |
| 416 | |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 417 | register size_t |
| 418 | x; |
| 419 | |
| 420 | size_t |
| 421 | number_arguments, |
| 422 | number_colors; |
| 423 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 424 | assert(image != (Image *) NULL); |
| 425 | assert(image->signature == MagickSignature); |
| 426 | if (image->debug != MagickFalse) |
| 427 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 428 | assert(exception != (ExceptionInfo *) NULL); |
| 429 | assert(exception->signature == MagickSignature); |
| 430 | /* |
| 431 | Limit channels according to image - and add up number of color channel. |
| 432 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 433 | number_colors=0; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 434 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 435 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 436 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 437 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 438 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 439 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 440 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 441 | (image->colorspace == CMYKColorspace)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 442 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 443 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 444 | (image->matte != MagickFalse)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 445 | number_colors++; |
| 446 | |
| 447 | /* |
| 448 | Read string, to determine number of arguments needed, |
| 449 | */ |
| 450 | p=arguments; |
| 451 | x=0; |
| 452 | while( *p != '\0' ) |
| 453 | { |
| 454 | GetMagickToken(p,&p,token); |
| 455 | if ( token[0] == ',' ) continue; |
| 456 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 457 | if ( color_from_image ) { |
| 458 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 459 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 460 | "Color arg given, when colors are coming from image"); |
| 461 | return( (Image *)NULL); |
| 462 | } |
| 463 | x += number_colors; /* color argument */ |
| 464 | } |
| 465 | else { |
| 466 | x++; /* floating point argument */ |
| 467 | } |
| 468 | } |
| 469 | error=MagickTrue; |
| 470 | if ( color_from_image ) { |
| 471 | /* just the control points are being given */ |
| 472 | error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; |
| 473 | number_arguments=(x/2)*(2+number_colors); |
| 474 | } |
| 475 | else { |
| 476 | /* control points and color values */ |
| 477 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; |
| 478 | number_arguments=x; |
| 479 | } |
| 480 | if ( error ) { |
| 481 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 482 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 483 | "Invalid number of Arguments"); |
| 484 | return( (Image *)NULL); |
| 485 | } |
| 486 | |
| 487 | /* Allocate and fill in the floating point arguments */ |
| 488 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 489 | sizeof(*sparse_arguments)); |
| 490 | if (sparse_arguments == (double *) NULL) { |
| 491 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 492 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 493 | return( (Image *)NULL); |
| 494 | } |
| 495 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 496 | sizeof(*sparse_arguments)); |
| 497 | p=arguments; |
| 498 | x=0; |
| 499 | while( *p != '\0' && x < number_arguments ) { |
| 500 | /* X coordinate */ |
| 501 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 502 | if ( token[0] == '\0' ) break; |
| 503 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 504 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 505 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 506 | "Color found, instead of X-coord"); |
| 507 | error = MagickTrue; |
| 508 | break; |
| 509 | } |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 510 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 511 | /* Y coordinate */ |
| 512 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 513 | if ( token[0] == '\0' ) break; |
| 514 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 515 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 516 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 517 | "Color found, instead of Y-coord"); |
| 518 | error = MagickTrue; |
| 519 | break; |
| 520 | } |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 521 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 522 | /* color values for this control point */ |
| 523 | #if 0 |
| 524 | if ( (color_from_image ) { |
| 525 | /* get color from image */ |
| 526 | /* HOW??? */ |
| 527 | } |
| 528 | else |
| 529 | #endif |
| 530 | { |
| 531 | /* color name or function given in string argument */ |
| 532 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 533 | if ( token[0] == '\0' ) break; |
| 534 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 535 | /* Color string given */ |
| 536 | (void) QueryMagickColor(token,&color,exception); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 537 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 538 | sparse_arguments[x++] = QuantumScale*color.red; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 539 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 540 | sparse_arguments[x++] = QuantumScale*color.green; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 541 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 542 | sparse_arguments[x++] = QuantumScale*color.blue; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 543 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 544 | (image->colorspace == CMYKColorspace)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 545 | sparse_arguments[x++] = QuantumScale*color.black; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 546 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 547 | (image->matte != MagickFalse)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 548 | sparse_arguments[x++] = QuantumScale*color.alpha; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 549 | } |
| 550 | else { |
| 551 | /* Colors given as a set of floating point values - experimental */ |
| 552 | /* NB: token contains the first floating point value to use! */ |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 553 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 554 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 555 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 556 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 557 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 558 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 559 | token[0] = ','; /* used this token - get another */ |
| 560 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 561 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 562 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 563 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 564 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 565 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 566 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 567 | token[0] = ','; /* used this token - get another */ |
| 568 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 569 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 570 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 571 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 572 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 573 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 574 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 575 | token[0] = ','; /* used this token - get another */ |
| 576 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 577 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 578 | (image->colorspace == CMYKColorspace)) |
| 579 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 580 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 581 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 582 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 583 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 584 | token[0] = ','; /* used this token - get another */ |
| 585 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 586 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 587 | (image->matte != MagickFalse)) |
| 588 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 589 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 590 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 591 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 592 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 593 | token[0] = ','; /* used this token - get another */ |
| 594 | } |
| 595 | } |
| 596 | } |
| 597 | } |
| 598 | if ( number_arguments != x && !error ) { |
| 599 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
| 600 | "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error"); |
| 601 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 602 | return( (Image *)NULL); |
| 603 | } |
| 604 | if ( error ) |
| 605 | return( (Image *)NULL); |
| 606 | |
| 607 | /* Call the Interpolation function with the parsed arguments */ |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 608 | sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, |
| 609 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 610 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 611 | return( sparse_image ); |
| 612 | } |
| 613 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 614 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 615 | const char **argv,Image **image,ExceptionInfo *exception) |
| 616 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 617 | ChannelType |
| 618 | channel; |
| 619 | |
| 620 | const char |
| 621 | *format, |
| 622 | *option; |
| 623 | |
| 624 | DrawInfo |
| 625 | *draw_info; |
| 626 | |
| 627 | GeometryInfo |
| 628 | geometry_info; |
| 629 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 630 | Image |
| 631 | *region_image; |
| 632 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 633 | ImageInfo |
| 634 | *mogrify_info; |
| 635 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 636 | MagickStatusType |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 637 | status; |
| 638 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 639 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 640 | fill; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 641 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 642 | MagickStatusType |
| 643 | flags; |
| 644 | |
| 645 | QuantizeInfo |
| 646 | *quantize_info; |
| 647 | |
| 648 | RectangleInfo |
| 649 | geometry, |
| 650 | region_geometry; |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame] | 651 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 652 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 653 | i; |
| 654 | |
| 655 | /* |
| 656 | Initialize method variables. |
| 657 | */ |
| 658 | assert(image_info != (const ImageInfo *) NULL); |
| 659 | assert(image_info->signature == MagickSignature); |
| 660 | assert(image != (Image **) NULL); |
| 661 | assert((*image)->signature == MagickSignature); |
| 662 | if ((*image)->debug != MagickFalse) |
| 663 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); |
| 664 | if (argc < 0) |
| 665 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 666 | mogrify_info=CloneImageInfo(image_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 667 | draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL); |
| 668 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 669 | SetGeometryInfo(&geometry_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 670 | GetPixelInfo(*image,&fill); |
| 671 | SetPixelInfoPacket(*image,&(*image)->background_color,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 672 | channel=mogrify_info->channel; |
| 673 | format=GetImageOption(mogrify_info,"format"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 674 | SetGeometry(*image,®ion_geometry); |
| 675 | region_image=NewImageList(); |
| 676 | /* |
| 677 | Transmogrify the image. |
| 678 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 679 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 680 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 681 | Image |
| 682 | *mogrify_image; |
| 683 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 684 | ssize_t |
| 685 | count; |
| 686 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 687 | option=argv[i]; |
| 688 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 689 | continue; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 690 | count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option), |
| 691 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 692 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 693 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 694 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 695 | mogrify_image=(Image *)NULL; |
| 696 | switch (*(option+1)) |
| 697 | { |
| 698 | case 'a': |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 699 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 700 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 701 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 702 | /* |
| 703 | Adaptive blur image. |
| 704 | */ |
| 705 | (void) SyncImageSettings(mogrify_info,*image); |
| 706 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 707 | if ((flags & SigmaValue) == 0) |
| 708 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 709 | mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho, |
| 710 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 711 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 712 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 713 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 714 | { |
| 715 | /* |
| 716 | Adaptive resize image. |
| 717 | */ |
| 718 | (void) SyncImageSettings(mogrify_info,*image); |
| 719 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 720 | mogrify_image=AdaptiveResizeImage(*image,geometry.width, |
| 721 | geometry.height,exception); |
| 722 | break; |
| 723 | } |
| 724 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 725 | { |
| 726 | /* |
| 727 | Adaptive sharpen image. |
| 728 | */ |
| 729 | (void) SyncImageSettings(mogrify_info,*image); |
| 730 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 731 | if ((flags & SigmaValue) == 0) |
| 732 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 733 | mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho, |
| 734 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 735 | break; |
| 736 | } |
| 737 | if (LocaleCompare("affine",option+1) == 0) |
| 738 | { |
| 739 | /* |
| 740 | Affine matrix. |
| 741 | */ |
| 742 | if (*option == '+') |
| 743 | { |
| 744 | GetAffineMatrix(&draw_info->affine); |
| 745 | break; |
| 746 | } |
| 747 | (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); |
| 748 | break; |
| 749 | } |
| 750 | if (LocaleCompare("alpha",option+1) == 0) |
| 751 | { |
| 752 | AlphaChannelType |
| 753 | alpha_type; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 754 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 755 | (void) SyncImageSettings(mogrify_info,*image); |
| 756 | alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions, |
| 757 | MagickFalse,argv[i+1]); |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 758 | (void) SetImageAlphaChannel(*image,alpha_type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 759 | break; |
| 760 | } |
| 761 | if (LocaleCompare("annotate",option+1) == 0) |
| 762 | { |
| 763 | char |
| 764 | *text, |
| 765 | geometry[MaxTextExtent]; |
| 766 | |
| 767 | /* |
| 768 | Annotate image. |
| 769 | */ |
| 770 | (void) SyncImageSettings(mogrify_info,*image); |
| 771 | SetGeometryInfo(&geometry_info); |
| 772 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 773 | if ((flags & SigmaValue) == 0) |
| 774 | geometry_info.sigma=geometry_info.rho; |
| 775 | text=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 776 | InheritException(exception,&(*image)->exception); |
| 777 | if (text == (char *) NULL) |
| 778 | break; |
| 779 | (void) CloneString(&draw_info->text,text); |
| 780 | text=DestroyString(text); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 781 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 782 | geometry_info.xi,geometry_info.psi); |
| 783 | (void) CloneString(&draw_info->geometry,geometry); |
| 784 | draw_info->affine.sx=cos(DegreesToRadians( |
| 785 | fmod(geometry_info.rho,360.0))); |
| 786 | draw_info->affine.rx=sin(DegreesToRadians( |
| 787 | fmod(geometry_info.rho,360.0))); |
| 788 | draw_info->affine.ry=(-sin(DegreesToRadians( |
| 789 | fmod(geometry_info.sigma,360.0)))); |
| 790 | draw_info->affine.sy=cos(DegreesToRadians( |
| 791 | fmod(geometry_info.sigma,360.0))); |
| 792 | (void) AnnotateImage(*image,draw_info); |
| 793 | InheritException(exception,&(*image)->exception); |
| 794 | break; |
| 795 | } |
| 796 | if (LocaleCompare("antialias",option+1) == 0) |
| 797 | { |
| 798 | draw_info->stroke_antialias=(*option == '-') ? MagickTrue : |
| 799 | MagickFalse; |
| 800 | draw_info->text_antialias=(*option == '-') ? MagickTrue : |
| 801 | MagickFalse; |
| 802 | break; |
| 803 | } |
| 804 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 805 | { |
| 806 | /* |
| 807 | Auto Adjust Gamma of image based on its mean |
| 808 | */ |
| 809 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 9511120 | 2011-08-09 19:41:42 +0000 | [diff] [blame] | 810 | (void) AutoGammaImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 811 | break; |
| 812 | } |
| 813 | if (LocaleCompare("auto-level",option+1) == 0) |
| 814 | { |
| 815 | /* |
| 816 | Perfectly Normalize (max/min stretch) the image |
| 817 | */ |
| 818 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 9511120 | 2011-08-09 19:41:42 +0000 | [diff] [blame] | 819 | (void) AutoLevelImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 820 | break; |
| 821 | } |
| 822 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 823 | { |
| 824 | (void) SyncImageSettings(mogrify_info,*image); |
| 825 | switch ((*image)->orientation) |
| 826 | { |
| 827 | case TopRightOrientation: |
| 828 | { |
| 829 | mogrify_image=FlopImage(*image,exception); |
| 830 | break; |
| 831 | } |
| 832 | case BottomRightOrientation: |
| 833 | { |
| 834 | mogrify_image=RotateImage(*image,180.0,exception); |
| 835 | break; |
| 836 | } |
| 837 | case BottomLeftOrientation: |
| 838 | { |
| 839 | mogrify_image=FlipImage(*image,exception); |
| 840 | break; |
| 841 | } |
| 842 | case LeftTopOrientation: |
| 843 | { |
| 844 | mogrify_image=TransposeImage(*image,exception); |
| 845 | break; |
| 846 | } |
| 847 | case RightTopOrientation: |
| 848 | { |
| 849 | mogrify_image=RotateImage(*image,90.0,exception); |
| 850 | break; |
| 851 | } |
| 852 | case RightBottomOrientation: |
| 853 | { |
| 854 | mogrify_image=TransverseImage(*image,exception); |
| 855 | break; |
| 856 | } |
| 857 | case LeftBottomOrientation: |
| 858 | { |
| 859 | mogrify_image=RotateImage(*image,270.0,exception); |
| 860 | break; |
| 861 | } |
| 862 | default: |
| 863 | break; |
| 864 | } |
| 865 | if (mogrify_image != (Image *) NULL) |
| 866 | mogrify_image->orientation=TopLeftOrientation; |
| 867 | break; |
| 868 | } |
| 869 | break; |
| 870 | } |
| 871 | case 'b': |
| 872 | { |
| 873 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 874 | { |
| 875 | /* |
| 876 | Black threshold image. |
| 877 | */ |
| 878 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 879 | (void) BlackThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 880 | InheritException(exception,&(*image)->exception); |
| 881 | break; |
| 882 | } |
| 883 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 884 | { |
| 885 | /* |
| 886 | Blue shift image. |
| 887 | */ |
| 888 | (void) SyncImageSettings(mogrify_info,*image); |
| 889 | geometry_info.rho=1.5; |
| 890 | if (*option == '-') |
| 891 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 892 | mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception); |
| 893 | break; |
| 894 | } |
| 895 | if (LocaleCompare("blur",option+1) == 0) |
| 896 | { |
| 897 | /* |
| 898 | Gaussian blur image. |
| 899 | */ |
| 900 | (void) SyncImageSettings(mogrify_info,*image); |
| 901 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 902 | if ((flags & SigmaValue) == 0) |
| 903 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 904 | mogrify_image=BlurImage(*image,geometry_info.rho, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 905 | geometry_info.sigma,exception); |
| 906 | break; |
| 907 | } |
| 908 | if (LocaleCompare("border",option+1) == 0) |
| 909 | { |
| 910 | /* |
| 911 | Surround image with a border of solid color. |
| 912 | */ |
| 913 | (void) SyncImageSettings(mogrify_info,*image); |
| 914 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 915 | if ((flags & SigmaValue) == 0) |
| 916 | geometry.height=geometry.width; |
| 917 | mogrify_image=BorderImage(*image,&geometry,exception); |
| 918 | break; |
| 919 | } |
| 920 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 921 | { |
| 922 | if (*option == '+') |
| 923 | { |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 924 | (void) QueryColorDatabase(MogrifyBorderColor,&draw_info->border_color, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 925 | exception); |
| 926 | break; |
| 927 | } |
| 928 | (void) QueryColorDatabase(argv[i+1],&draw_info->border_color, |
| 929 | exception); |
| 930 | break; |
| 931 | } |
| 932 | if (LocaleCompare("box",option+1) == 0) |
| 933 | { |
| 934 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 935 | exception); |
| 936 | break; |
| 937 | } |
| 938 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 939 | { |
| 940 | double |
| 941 | brightness, |
| 942 | contrast; |
| 943 | |
| 944 | GeometryInfo |
| 945 | geometry_info; |
| 946 | |
| 947 | MagickStatusType |
| 948 | flags; |
| 949 | |
| 950 | /* |
| 951 | Brightness / contrast image. |
| 952 | */ |
| 953 | (void) SyncImageSettings(mogrify_info,*image); |
| 954 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 955 | brightness=geometry_info.rho; |
| 956 | contrast=0.0; |
| 957 | if ((flags & SigmaValue) != 0) |
| 958 | contrast=geometry_info.sigma; |
cristy | 444eda6 | 2011-08-10 02:07:46 +0000 | [diff] [blame] | 959 | (void) BrightnessContrastImage(*image,brightness,contrast, |
| 960 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 961 | InheritException(exception,&(*image)->exception); |
| 962 | break; |
| 963 | } |
| 964 | break; |
| 965 | } |
| 966 | case 'c': |
| 967 | { |
| 968 | if (LocaleCompare("cdl",option+1) == 0) |
| 969 | { |
| 970 | char |
| 971 | *color_correction_collection; |
| 972 | |
| 973 | /* |
| 974 | Color correct with a color decision list. |
| 975 | */ |
| 976 | (void) SyncImageSettings(mogrify_info,*image); |
| 977 | color_correction_collection=FileToString(argv[i+1],~0,exception); |
| 978 | if (color_correction_collection == (char *) NULL) |
| 979 | break; |
cristy | 1bfa9f0 | 2011-08-11 02:35:43 +0000 | [diff] [blame^] | 980 | (void) ColorDecisionListImage(*image,color_correction_collection, |
| 981 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 982 | InheritException(exception,&(*image)->exception); |
| 983 | break; |
| 984 | } |
| 985 | if (LocaleCompare("channel",option+1) == 0) |
| 986 | { |
| 987 | if (*option == '+') |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 988 | channel=DefaultChannels; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 989 | else |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 990 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 991 | SetPixelChannelMap(*image,channel); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 992 | break; |
| 993 | } |
| 994 | if (LocaleCompare("charcoal",option+1) == 0) |
| 995 | { |
| 996 | /* |
| 997 | Charcoal image. |
| 998 | */ |
| 999 | (void) SyncImageSettings(mogrify_info,*image); |
| 1000 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1001 | if ((flags & SigmaValue) == 0) |
| 1002 | geometry_info.sigma=1.0; |
| 1003 | mogrify_image=CharcoalImage(*image,geometry_info.rho, |
| 1004 | geometry_info.sigma,exception); |
| 1005 | break; |
| 1006 | } |
| 1007 | if (LocaleCompare("chop",option+1) == 0) |
| 1008 | { |
| 1009 | /* |
| 1010 | Chop the image. |
| 1011 | */ |
| 1012 | (void) SyncImageSettings(mogrify_info,*image); |
| 1013 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1014 | mogrify_image=ChopImage(*image,&geometry,exception); |
| 1015 | break; |
| 1016 | } |
| 1017 | if (LocaleCompare("clamp",option+1) == 0) |
| 1018 | { |
| 1019 | /* |
| 1020 | Clamp image. |
| 1021 | */ |
| 1022 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1023 | (void) ClampImage(*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1024 | InheritException(exception,&(*image)->exception); |
| 1025 | break; |
| 1026 | } |
| 1027 | if (LocaleCompare("clip",option+1) == 0) |
| 1028 | { |
| 1029 | (void) SyncImageSettings(mogrify_info,*image); |
| 1030 | if (*option == '+') |
| 1031 | { |
| 1032 | (void) SetImageClipMask(*image,(Image *) NULL); |
| 1033 | InheritException(exception,&(*image)->exception); |
| 1034 | break; |
| 1035 | } |
| 1036 | (void) ClipImage(*image); |
| 1037 | InheritException(exception,&(*image)->exception); |
| 1038 | break; |
| 1039 | } |
| 1040 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1041 | { |
| 1042 | CacheView |
| 1043 | *mask_view; |
| 1044 | |
| 1045 | Image |
| 1046 | *mask_image; |
| 1047 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1048 | register Quantum |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1049 | *restrict q; |
| 1050 | |
| 1051 | register ssize_t |
| 1052 | x; |
| 1053 | |
| 1054 | ssize_t |
| 1055 | y; |
| 1056 | |
| 1057 | (void) SyncImageSettings(mogrify_info,*image); |
| 1058 | if (*option == '+') |
| 1059 | { |
| 1060 | /* |
| 1061 | Remove a mask. |
| 1062 | */ |
| 1063 | (void) SetImageMask(*image,(Image *) NULL); |
| 1064 | InheritException(exception,&(*image)->exception); |
| 1065 | break; |
| 1066 | } |
| 1067 | /* |
| 1068 | Set the image mask. |
| 1069 | FUTURE: This Should Be a SetImageAlphaChannel() call, Or two. |
| 1070 | */ |
| 1071 | mask_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1072 | if (mask_image == (Image *) NULL) |
| 1073 | break; |
cristy | 574cc26 | 2011-08-05 01:23:58 +0000 | [diff] [blame] | 1074 | if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1075 | return(MagickFalse); |
| 1076 | mask_view=AcquireCacheView(mask_image); |
| 1077 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1078 | { |
| 1079 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1080 | exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1081 | if (q == (const Quantum *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1082 | break; |
| 1083 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1084 | { |
| 1085 | if (mask_image->matte == MagickFalse) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1086 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 1087 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1088 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1089 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1090 | q+=GetPixelChannels(mask_image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1091 | } |
| 1092 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
| 1093 | break; |
| 1094 | } |
| 1095 | mask_view=DestroyCacheView(mask_view); |
| 1096 | mask_image->matte=MagickTrue; |
| 1097 | (void) SetImageClipMask(*image,mask_image); |
| 1098 | mask_image=DestroyImage(mask_image); |
| 1099 | InheritException(exception,&(*image)->exception); |
| 1100 | break; |
| 1101 | } |
| 1102 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1103 | { |
| 1104 | (void) SyncImageSettings(mogrify_info,*image); |
| 1105 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
| 1106 | MagickFalse); |
| 1107 | InheritException(exception,&(*image)->exception); |
| 1108 | break; |
| 1109 | } |
| 1110 | if (LocaleCompare("colorize",option+1) == 0) |
| 1111 | { |
| 1112 | /* |
| 1113 | Colorize the image. |
| 1114 | */ |
| 1115 | (void) SyncImageSettings(mogrify_info,*image); |
| 1116 | mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill, |
| 1117 | exception); |
| 1118 | break; |
| 1119 | } |
| 1120 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1121 | { |
| 1122 | KernelInfo |
| 1123 | *kernel; |
| 1124 | |
| 1125 | (void) SyncImageSettings(mogrify_info,*image); |
| 1126 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1127 | if (kernel == (KernelInfo *) NULL) |
| 1128 | break; |
| 1129 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 1130 | kernel=DestroyKernelInfo(kernel); |
| 1131 | break; |
| 1132 | } |
| 1133 | if (LocaleCompare("colors",option+1) == 0) |
| 1134 | { |
| 1135 | /* |
| 1136 | Reduce the number of colors in the image. |
| 1137 | */ |
| 1138 | (void) SyncImageSettings(mogrify_info,*image); |
| 1139 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
| 1140 | if (quantize_info->number_colors == 0) |
| 1141 | break; |
| 1142 | if (((*image)->storage_class == DirectClass) || |
| 1143 | (*image)->colors > quantize_info->number_colors) |
| 1144 | (void) QuantizeImage(quantize_info,*image); |
| 1145 | else |
| 1146 | (void) CompressImageColormap(*image); |
| 1147 | InheritException(exception,&(*image)->exception); |
| 1148 | break; |
| 1149 | } |
| 1150 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1151 | { |
| 1152 | ColorspaceType |
| 1153 | colorspace; |
| 1154 | |
| 1155 | (void) SyncImageSettings(mogrify_info,*image); |
| 1156 | if (*option == '+') |
| 1157 | { |
| 1158 | (void) TransformImageColorspace(*image,RGBColorspace); |
| 1159 | InheritException(exception,&(*image)->exception); |
| 1160 | break; |
| 1161 | } |
| 1162 | colorspace=(ColorspaceType) ParseCommandOption( |
| 1163 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 1164 | (void) TransformImageColorspace(*image,colorspace); |
| 1165 | InheritException(exception,&(*image)->exception); |
| 1166 | break; |
| 1167 | } |
| 1168 | if (LocaleCompare("contrast",option+1) == 0) |
| 1169 | { |
| 1170 | (void) SyncImageSettings(mogrify_info,*image); |
| 1171 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
| 1172 | MagickFalse); |
| 1173 | InheritException(exception,&(*image)->exception); |
| 1174 | break; |
| 1175 | } |
| 1176 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1177 | { |
| 1178 | double |
| 1179 | black_point, |
| 1180 | white_point; |
| 1181 | |
| 1182 | MagickStatusType |
| 1183 | flags; |
| 1184 | |
| 1185 | /* |
| 1186 | Contrast stretch image. |
| 1187 | */ |
| 1188 | (void) SyncImageSettings(mogrify_info,*image); |
| 1189 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1190 | black_point=geometry_info.rho; |
| 1191 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1192 | black_point; |
| 1193 | if ((flags & PercentValue) != 0) |
| 1194 | { |
| 1195 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1196 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1197 | } |
| 1198 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1199 | white_point; |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1200 | (void) ContrastStretchImage(*image,black_point,white_point); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1201 | InheritException(exception,&(*image)->exception); |
| 1202 | break; |
| 1203 | } |
| 1204 | if (LocaleCompare("convolve",option+1) == 0) |
| 1205 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1206 | KernelInfo |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1207 | *kernel_info; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1208 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1209 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1210 | kernel_info=AcquireKernelInfo(argv[i+1]); |
| 1211 | if (kernel_info == (KernelInfo *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1212 | break; |
cristy | 0a92238 | 2011-07-16 15:30:34 +0000 | [diff] [blame] | 1213 | kernel_info->bias=(*image)->bias; |
cristy | 5e6be1e | 2011-07-16 01:23:39 +0000 | [diff] [blame] | 1214 | mogrify_image=ConvolveImage(*image,kernel_info,exception); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1215 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1216 | break; |
| 1217 | } |
| 1218 | if (LocaleCompare("crop",option+1) == 0) |
| 1219 | { |
| 1220 | /* |
| 1221 | Crop a image to a smaller size |
| 1222 | */ |
| 1223 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1224 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1225 | break; |
| 1226 | } |
| 1227 | if (LocaleCompare("cycle",option+1) == 0) |
| 1228 | { |
| 1229 | /* |
| 1230 | Cycle an image colormap. |
| 1231 | */ |
| 1232 | (void) SyncImageSettings(mogrify_info,*image); |
| 1233 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1])); |
| 1234 | InheritException(exception,&(*image)->exception); |
| 1235 | break; |
| 1236 | } |
| 1237 | break; |
| 1238 | } |
| 1239 | case 'd': |
| 1240 | { |
| 1241 | if (LocaleCompare("decipher",option+1) == 0) |
| 1242 | { |
| 1243 | StringInfo |
| 1244 | *passkey; |
| 1245 | |
| 1246 | /* |
| 1247 | Decipher pixels. |
| 1248 | */ |
| 1249 | (void) SyncImageSettings(mogrify_info,*image); |
| 1250 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1251 | if (passkey != (StringInfo *) NULL) |
| 1252 | { |
| 1253 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1254 | passkey=DestroyStringInfo(passkey); |
| 1255 | } |
| 1256 | break; |
| 1257 | } |
| 1258 | if (LocaleCompare("density",option+1) == 0) |
| 1259 | { |
| 1260 | /* |
| 1261 | Set image density. |
| 1262 | */ |
| 1263 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1264 | break; |
| 1265 | } |
| 1266 | if (LocaleCompare("depth",option+1) == 0) |
| 1267 | { |
| 1268 | (void) SyncImageSettings(mogrify_info,*image); |
| 1269 | if (*option == '+') |
| 1270 | { |
| 1271 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH); |
| 1272 | break; |
| 1273 | } |
| 1274 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1])); |
| 1275 | break; |
| 1276 | } |
| 1277 | if (LocaleCompare("deskew",option+1) == 0) |
| 1278 | { |
| 1279 | double |
| 1280 | threshold; |
| 1281 | |
| 1282 | /* |
| 1283 | Straighten the image. |
| 1284 | */ |
| 1285 | (void) SyncImageSettings(mogrify_info,*image); |
| 1286 | if (*option == '+') |
| 1287 | threshold=40.0*QuantumRange/100.0; |
| 1288 | else |
| 1289 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 1290 | mogrify_image=DeskewImage(*image,threshold,exception); |
| 1291 | break; |
| 1292 | } |
| 1293 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1294 | { |
| 1295 | /* |
| 1296 | Reduce the speckles within an image. |
| 1297 | */ |
| 1298 | (void) SyncImageSettings(mogrify_info,*image); |
| 1299 | mogrify_image=DespeckleImage(*image,exception); |
| 1300 | break; |
| 1301 | } |
| 1302 | if (LocaleCompare("display",option+1) == 0) |
| 1303 | { |
| 1304 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1305 | break; |
| 1306 | } |
| 1307 | if (LocaleCompare("distort",option+1) == 0) |
| 1308 | { |
| 1309 | char |
| 1310 | *args, |
| 1311 | token[MaxTextExtent]; |
| 1312 | |
| 1313 | const char |
| 1314 | *p; |
| 1315 | |
| 1316 | DistortImageMethod |
| 1317 | method; |
| 1318 | |
| 1319 | double |
| 1320 | *arguments; |
| 1321 | |
| 1322 | register ssize_t |
| 1323 | x; |
| 1324 | |
| 1325 | size_t |
| 1326 | number_arguments; |
| 1327 | |
| 1328 | /* |
| 1329 | Distort image. |
| 1330 | */ |
| 1331 | (void) SyncImageSettings(mogrify_info,*image); |
| 1332 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, |
| 1333 | MagickFalse,argv[i+1]); |
| 1334 | if ( method == ResizeDistortion ) |
| 1335 | { |
| 1336 | /* Special Case - Argument is actually a resize geometry! |
| 1337 | ** Convert that to an appropriate distortion argument array. |
| 1338 | */ |
| 1339 | double |
| 1340 | resize_args[2]; |
| 1341 | (void) ParseRegionGeometry(*image,argv[i+2],&geometry, |
| 1342 | exception); |
| 1343 | resize_args[0]=(double)geometry.width; |
| 1344 | resize_args[1]=(double)geometry.height; |
| 1345 | mogrify_image=DistortImage(*image,method,(size_t)2, |
| 1346 | resize_args,MagickTrue,exception); |
| 1347 | break; |
| 1348 | } |
| 1349 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 1350 | InheritException(exception,&(*image)->exception); |
| 1351 | if (args == (char *) NULL) |
| 1352 | break; |
| 1353 | p=(char *) args; |
| 1354 | for (x=0; *p != '\0'; x++) |
| 1355 | { |
| 1356 | GetMagickToken(p,&p,token); |
| 1357 | if (*token == ',') |
| 1358 | GetMagickToken(p,&p,token); |
| 1359 | } |
| 1360 | number_arguments=(size_t) x; |
| 1361 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1362 | sizeof(*arguments)); |
| 1363 | if (arguments == (double *) NULL) |
| 1364 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1365 | "MemoryAllocationFailed",(*image)->filename); |
| 1366 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1367 | sizeof(*arguments)); |
| 1368 | p=(char *) args; |
| 1369 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 1370 | { |
| 1371 | GetMagickToken(p,&p,token); |
| 1372 | if (*token == ',') |
| 1373 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1374 | arguments[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1375 | } |
| 1376 | args=DestroyString(args); |
| 1377 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
| 1378 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1379 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1380 | break; |
| 1381 | } |
| 1382 | if (LocaleCompare("dither",option+1) == 0) |
| 1383 | { |
| 1384 | if (*option == '+') |
| 1385 | { |
| 1386 | quantize_info->dither=MagickFalse; |
| 1387 | break; |
| 1388 | } |
| 1389 | quantize_info->dither=MagickTrue; |
| 1390 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
| 1391 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1392 | if (quantize_info->dither_method == NoDitherMethod) |
| 1393 | quantize_info->dither=MagickFalse; |
| 1394 | break; |
| 1395 | } |
| 1396 | if (LocaleCompare("draw",option+1) == 0) |
| 1397 | { |
| 1398 | /* |
| 1399 | Draw image. |
| 1400 | */ |
| 1401 | (void) SyncImageSettings(mogrify_info,*image); |
| 1402 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
| 1403 | (void) DrawImage(*image,draw_info); |
| 1404 | InheritException(exception,&(*image)->exception); |
| 1405 | break; |
| 1406 | } |
| 1407 | break; |
| 1408 | } |
| 1409 | case 'e': |
| 1410 | { |
| 1411 | if (LocaleCompare("edge",option+1) == 0) |
| 1412 | { |
| 1413 | /* |
| 1414 | Enhance edges in the image. |
| 1415 | */ |
| 1416 | (void) SyncImageSettings(mogrify_info,*image); |
| 1417 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1418 | if ((flags & SigmaValue) == 0) |
| 1419 | geometry_info.sigma=1.0; |
| 1420 | mogrify_image=EdgeImage(*image,geometry_info.rho,exception); |
| 1421 | break; |
| 1422 | } |
| 1423 | if (LocaleCompare("emboss",option+1) == 0) |
| 1424 | { |
| 1425 | /* |
| 1426 | Gaussian embossen image. |
| 1427 | */ |
| 1428 | (void) SyncImageSettings(mogrify_info,*image); |
| 1429 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1430 | if ((flags & SigmaValue) == 0) |
| 1431 | geometry_info.sigma=1.0; |
| 1432 | mogrify_image=EmbossImage(*image,geometry_info.rho, |
| 1433 | geometry_info.sigma,exception); |
| 1434 | break; |
| 1435 | } |
| 1436 | if (LocaleCompare("encipher",option+1) == 0) |
| 1437 | { |
| 1438 | StringInfo |
| 1439 | *passkey; |
| 1440 | |
| 1441 | /* |
| 1442 | Encipher pixels. |
| 1443 | */ |
| 1444 | (void) SyncImageSettings(mogrify_info,*image); |
| 1445 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1446 | if (passkey != (StringInfo *) NULL) |
| 1447 | { |
| 1448 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1449 | passkey=DestroyStringInfo(passkey); |
| 1450 | } |
| 1451 | break; |
| 1452 | } |
| 1453 | if (LocaleCompare("encoding",option+1) == 0) |
| 1454 | { |
| 1455 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1456 | break; |
| 1457 | } |
| 1458 | if (LocaleCompare("enhance",option+1) == 0) |
| 1459 | { |
| 1460 | /* |
| 1461 | Enhance image. |
| 1462 | */ |
| 1463 | (void) SyncImageSettings(mogrify_info,*image); |
| 1464 | mogrify_image=EnhanceImage(*image,exception); |
| 1465 | break; |
| 1466 | } |
| 1467 | if (LocaleCompare("equalize",option+1) == 0) |
| 1468 | { |
| 1469 | /* |
| 1470 | Equalize image. |
| 1471 | */ |
| 1472 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1473 | (void) EqualizeImage(*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1474 | InheritException(exception,&(*image)->exception); |
| 1475 | break; |
| 1476 | } |
| 1477 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1478 | { |
| 1479 | double |
| 1480 | constant; |
| 1481 | |
| 1482 | MagickEvaluateOperator |
| 1483 | op; |
| 1484 | |
| 1485 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1486 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 1487 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1488 | constant=SiPrefixToDouble(argv[i+2],QuantumRange); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1489 | (void) EvaluateImage(*image,op,constant,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1490 | break; |
| 1491 | } |
| 1492 | if (LocaleCompare("extent",option+1) == 0) |
| 1493 | { |
| 1494 | /* |
| 1495 | Set the image extent. |
| 1496 | */ |
| 1497 | (void) SyncImageSettings(mogrify_info,*image); |
| 1498 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1499 | if (geometry.width == 0) |
| 1500 | geometry.width=(*image)->columns; |
| 1501 | if (geometry.height == 0) |
| 1502 | geometry.height=(*image)->rows; |
| 1503 | mogrify_image=ExtentImage(*image,&geometry,exception); |
| 1504 | break; |
| 1505 | } |
| 1506 | break; |
| 1507 | } |
| 1508 | case 'f': |
| 1509 | { |
| 1510 | if (LocaleCompare("family",option+1) == 0) |
| 1511 | { |
| 1512 | if (*option == '+') |
| 1513 | { |
| 1514 | if (draw_info->family != (char *) NULL) |
| 1515 | draw_info->family=DestroyString(draw_info->family); |
| 1516 | break; |
| 1517 | } |
| 1518 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1519 | break; |
| 1520 | } |
| 1521 | if (LocaleCompare("features",option+1) == 0) |
| 1522 | { |
| 1523 | if (*option == '+') |
| 1524 | { |
| 1525 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1526 | break; |
| 1527 | } |
| 1528 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1529 | break; |
| 1530 | } |
| 1531 | if (LocaleCompare("fill",option+1) == 0) |
| 1532 | { |
| 1533 | ExceptionInfo |
| 1534 | *sans; |
| 1535 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1536 | GetPixelInfo(*image,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1537 | if (*option == '+') |
| 1538 | { |
| 1539 | (void) QueryMagickColor("none",&fill,exception); |
| 1540 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 1541 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1542 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1543 | break; |
| 1544 | } |
| 1545 | sans=AcquireExceptionInfo(); |
| 1546 | (void) QueryMagickColor(argv[i+1],&fill,sans); |
| 1547 | status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans); |
| 1548 | sans=DestroyExceptionInfo(sans); |
| 1549 | if (status == MagickFalse) |
| 1550 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 1551 | exception); |
| 1552 | break; |
| 1553 | } |
| 1554 | if (LocaleCompare("flip",option+1) == 0) |
| 1555 | { |
| 1556 | /* |
| 1557 | Flip image scanlines. |
| 1558 | */ |
| 1559 | (void) SyncImageSettings(mogrify_info,*image); |
| 1560 | mogrify_image=FlipImage(*image,exception); |
| 1561 | break; |
| 1562 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1563 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1564 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1565 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1566 | target; |
| 1567 | |
| 1568 | /* |
| 1569 | Floodfill image. |
| 1570 | */ |
| 1571 | (void) SyncImageSettings(mogrify_info,*image); |
| 1572 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1573 | (void) QueryMagickColor(argv[i+2],&target,exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1574 | (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x, |
| 1575 | geometry.y,*option == '-' ? MagickFalse : MagickTrue); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1576 | InheritException(exception,&(*image)->exception); |
| 1577 | break; |
| 1578 | } |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1579 | if (LocaleCompare("flop",option+1) == 0) |
| 1580 | { |
| 1581 | /* |
| 1582 | Flop image scanlines. |
| 1583 | */ |
| 1584 | (void) SyncImageSettings(mogrify_info,*image); |
| 1585 | mogrify_image=FlopImage(*image,exception); |
| 1586 | break; |
| 1587 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1588 | if (LocaleCompare("font",option+1) == 0) |
| 1589 | { |
| 1590 | if (*option == '+') |
| 1591 | { |
| 1592 | if (draw_info->font != (char *) NULL) |
| 1593 | draw_info->font=DestroyString(draw_info->font); |
| 1594 | break; |
| 1595 | } |
| 1596 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1597 | break; |
| 1598 | } |
| 1599 | if (LocaleCompare("format",option+1) == 0) |
| 1600 | { |
| 1601 | format=argv[i+1]; |
| 1602 | break; |
| 1603 | } |
| 1604 | if (LocaleCompare("frame",option+1) == 0) |
| 1605 | { |
| 1606 | FrameInfo |
| 1607 | frame_info; |
| 1608 | |
| 1609 | /* |
| 1610 | Surround image with an ornamental border. |
| 1611 | */ |
| 1612 | (void) SyncImageSettings(mogrify_info,*image); |
| 1613 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1614 | frame_info.width=geometry.width; |
| 1615 | frame_info.height=geometry.height; |
| 1616 | if ((flags & HeightValue) == 0) |
| 1617 | frame_info.height=geometry.width; |
| 1618 | frame_info.outer_bevel=geometry.x; |
| 1619 | frame_info.inner_bevel=geometry.y; |
| 1620 | frame_info.x=(ssize_t) frame_info.width; |
| 1621 | frame_info.y=(ssize_t) frame_info.height; |
| 1622 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1623 | frame_info.height=(*image)->rows+2*frame_info.height; |
| 1624 | mogrify_image=FrameImage(*image,&frame_info,exception); |
| 1625 | break; |
| 1626 | } |
| 1627 | if (LocaleCompare("function",option+1) == 0) |
| 1628 | { |
| 1629 | char |
| 1630 | *arguments, |
| 1631 | token[MaxTextExtent]; |
| 1632 | |
| 1633 | const char |
| 1634 | *p; |
| 1635 | |
| 1636 | double |
| 1637 | *parameters; |
| 1638 | |
| 1639 | MagickFunction |
| 1640 | function; |
| 1641 | |
| 1642 | register ssize_t |
| 1643 | x; |
| 1644 | |
| 1645 | size_t |
| 1646 | number_parameters; |
| 1647 | |
| 1648 | /* |
| 1649 | Function Modify Image Values |
| 1650 | */ |
| 1651 | (void) SyncImageSettings(mogrify_info,*image); |
| 1652 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, |
| 1653 | MagickFalse,argv[i+1]); |
| 1654 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 1655 | InheritException(exception,&(*image)->exception); |
| 1656 | if (arguments == (char *) NULL) |
| 1657 | break; |
| 1658 | p=(char *) arguments; |
| 1659 | for (x=0; *p != '\0'; x++) |
| 1660 | { |
| 1661 | GetMagickToken(p,&p,token); |
| 1662 | if (*token == ',') |
| 1663 | GetMagickToken(p,&p,token); |
| 1664 | } |
| 1665 | number_parameters=(size_t) x; |
| 1666 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1667 | sizeof(*parameters)); |
| 1668 | if (parameters == (double *) NULL) |
| 1669 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1670 | "MemoryAllocationFailed",(*image)->filename); |
| 1671 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1672 | sizeof(*parameters)); |
| 1673 | p=(char *) arguments; |
| 1674 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
| 1675 | { |
| 1676 | GetMagickToken(p,&p,token); |
| 1677 | if (*token == ',') |
| 1678 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1679 | parameters[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1680 | } |
| 1681 | arguments=DestroyString(arguments); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1682 | (void) FunctionImage(*image,function,number_parameters,parameters, |
| 1683 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1684 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1685 | break; |
| 1686 | } |
| 1687 | break; |
| 1688 | } |
| 1689 | case 'g': |
| 1690 | { |
| 1691 | if (LocaleCompare("gamma",option+1) == 0) |
| 1692 | { |
| 1693 | /* |
| 1694 | Gamma image. |
| 1695 | */ |
| 1696 | (void) SyncImageSettings(mogrify_info,*image); |
| 1697 | if (*option == '+') |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1698 | (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1699 | else |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 1700 | (void) GammaImage(*image,InterpretLocaleValue(argv[i+1], |
| 1701 | (char **) NULL),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1702 | break; |
| 1703 | } |
| 1704 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1705 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1706 | { |
| 1707 | /* |
| 1708 | Gaussian blur image. |
| 1709 | */ |
| 1710 | (void) SyncImageSettings(mogrify_info,*image); |
| 1711 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1712 | if ((flags & SigmaValue) == 0) |
| 1713 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1714 | mogrify_image=GaussianBlurImage(*image,geometry_info.rho, |
| 1715 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1716 | break; |
| 1717 | } |
| 1718 | if (LocaleCompare("geometry",option+1) == 0) |
| 1719 | { |
| 1720 | /* |
| 1721 | Record Image offset, Resize last image. |
| 1722 | */ |
| 1723 | (void) SyncImageSettings(mogrify_info,*image); |
| 1724 | if (*option == '+') |
| 1725 | { |
| 1726 | if ((*image)->geometry != (char *) NULL) |
| 1727 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1728 | break; |
| 1729 | } |
| 1730 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1731 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1732 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1733 | else |
| 1734 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 1735 | (*image)->filter,(*image)->blur,exception); |
| 1736 | break; |
| 1737 | } |
| 1738 | if (LocaleCompare("gravity",option+1) == 0) |
| 1739 | { |
| 1740 | if (*option == '+') |
| 1741 | { |
| 1742 | draw_info->gravity=UndefinedGravity; |
| 1743 | break; |
| 1744 | } |
| 1745 | draw_info->gravity=(GravityType) ParseCommandOption( |
| 1746 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1747 | break; |
| 1748 | } |
| 1749 | break; |
| 1750 | } |
| 1751 | case 'h': |
| 1752 | { |
| 1753 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1754 | { |
| 1755 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1756 | break; |
| 1757 | } |
| 1758 | break; |
| 1759 | } |
| 1760 | case 'i': |
| 1761 | { |
| 1762 | if (LocaleCompare("identify",option+1) == 0) |
| 1763 | { |
| 1764 | char |
| 1765 | *text; |
| 1766 | |
| 1767 | (void) SyncImageSettings(mogrify_info,*image); |
| 1768 | if (format == (char *) NULL) |
| 1769 | { |
| 1770 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose); |
| 1771 | InheritException(exception,&(*image)->exception); |
| 1772 | break; |
| 1773 | } |
| 1774 | text=InterpretImageProperties(mogrify_info,*image,format); |
| 1775 | InheritException(exception,&(*image)->exception); |
| 1776 | if (text == (char *) NULL) |
| 1777 | break; |
| 1778 | (void) fputs(text,stdout); |
| 1779 | (void) fputc('\n',stdout); |
| 1780 | text=DestroyString(text); |
| 1781 | break; |
| 1782 | } |
| 1783 | if (LocaleCompare("implode",option+1) == 0) |
| 1784 | { |
| 1785 | /* |
| 1786 | Implode image. |
| 1787 | */ |
| 1788 | (void) SyncImageSettings(mogrify_info,*image); |
| 1789 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1790 | mogrify_image=ImplodeImage(*image,geometry_info.rho,exception); |
| 1791 | break; |
| 1792 | } |
| 1793 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1794 | { |
| 1795 | if (*option == '+') |
| 1796 | (void) ParseGeometry("0",&geometry_info); |
| 1797 | else |
| 1798 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1799 | draw_info->interline_spacing=geometry_info.rho; |
| 1800 | break; |
| 1801 | } |
| 1802 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1803 | { |
| 1804 | if (*option == '+') |
| 1805 | (void) ParseGeometry("0",&geometry_info); |
| 1806 | else |
| 1807 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1808 | draw_info->interword_spacing=geometry_info.rho; |
| 1809 | break; |
| 1810 | } |
| 1811 | break; |
| 1812 | } |
| 1813 | case 'k': |
| 1814 | { |
| 1815 | if (LocaleCompare("kerning",option+1) == 0) |
| 1816 | { |
| 1817 | if (*option == '+') |
| 1818 | (void) ParseGeometry("0",&geometry_info); |
| 1819 | else |
| 1820 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1821 | draw_info->kerning=geometry_info.rho; |
| 1822 | break; |
| 1823 | } |
| 1824 | break; |
| 1825 | } |
| 1826 | case 'l': |
| 1827 | { |
| 1828 | if (LocaleCompare("lat",option+1) == 0) |
| 1829 | { |
| 1830 | /* |
| 1831 | Local adaptive threshold image. |
| 1832 | */ |
| 1833 | (void) SyncImageSettings(mogrify_info,*image); |
| 1834 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1835 | if ((flags & PercentValue) != 0) |
| 1836 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 1837 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
cristy | de5cc63 | 2011-07-18 14:47:00 +0000 | [diff] [blame] | 1838 | geometry_info.rho,(size_t) geometry_info.sigma,(double) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1839 | geometry_info.xi,exception); |
| 1840 | break; |
| 1841 | } |
| 1842 | if (LocaleCompare("level",option+1) == 0) |
| 1843 | { |
| 1844 | MagickRealType |
| 1845 | black_point, |
| 1846 | gamma, |
| 1847 | white_point; |
| 1848 | |
| 1849 | MagickStatusType |
| 1850 | flags; |
| 1851 | |
| 1852 | /* |
| 1853 | Parse levels. |
| 1854 | */ |
| 1855 | (void) SyncImageSettings(mogrify_info,*image); |
| 1856 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1857 | black_point=geometry_info.rho; |
| 1858 | white_point=(MagickRealType) QuantumRange; |
| 1859 | if ((flags & SigmaValue) != 0) |
| 1860 | white_point=geometry_info.sigma; |
| 1861 | gamma=1.0; |
| 1862 | if ((flags & XiValue) != 0) |
| 1863 | gamma=geometry_info.xi; |
| 1864 | if ((flags & PercentValue) != 0) |
| 1865 | { |
| 1866 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 1867 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 1868 | } |
| 1869 | if ((flags & SigmaValue) == 0) |
| 1870 | white_point=(MagickRealType) QuantumRange-black_point; |
| 1871 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1872 | (void) LevelizeImage(*image,black_point,white_point,gamma); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1873 | else |
cristy | 01e9afd | 2011-08-10 17:38:41 +0000 | [diff] [blame] | 1874 | (void) LevelImage(*image,black_point,white_point,gamma, |
| 1875 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1876 | InheritException(exception,&(*image)->exception); |
| 1877 | break; |
| 1878 | } |
| 1879 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1880 | { |
| 1881 | char |
| 1882 | token[MaxTextExtent]; |
| 1883 | |
| 1884 | const char |
| 1885 | *p; |
| 1886 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1887 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1888 | black_point, |
| 1889 | white_point; |
| 1890 | |
| 1891 | p=(const char *) argv[i+1]; |
| 1892 | GetMagickToken(p,&p,token); /* get black point color */ |
| 1893 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1894 | (void) QueryMagickColor(token,&black_point,exception); |
| 1895 | else |
| 1896 | (void) QueryMagickColor("#000000",&black_point,exception); |
| 1897 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1898 | GetMagickToken(p,&p,token); |
| 1899 | if (*token == '\0') |
| 1900 | white_point=black_point; /* set everything to that color */ |
| 1901 | else |
| 1902 | { |
| 1903 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 1904 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 1905 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1906 | (void) QueryMagickColor(token,&white_point,exception); |
| 1907 | else |
| 1908 | (void) QueryMagickColor("#ffffff",&white_point,exception); |
| 1909 | } |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 1910 | (void) LevelImageColors(*image,&black_point,&white_point, |
| 1911 | *option == '+' ? MagickTrue : MagickFalse); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1912 | break; |
| 1913 | } |
| 1914 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 1915 | { |
| 1916 | double |
| 1917 | black_point, |
| 1918 | white_point; |
| 1919 | |
| 1920 | MagickStatusType |
| 1921 | flags; |
| 1922 | |
| 1923 | (void) SyncImageSettings(mogrify_info,*image); |
| 1924 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1925 | black_point=geometry_info.rho; |
| 1926 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 1927 | if ((flags & SigmaValue) != 0) |
| 1928 | white_point=geometry_info.sigma; |
| 1929 | if ((flags & PercentValue) != 0) |
| 1930 | { |
| 1931 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1932 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1933 | } |
| 1934 | if ((flags & SigmaValue) == 0) |
| 1935 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1936 | black_point; |
| 1937 | (void) LinearStretchImage(*image,black_point,white_point); |
| 1938 | InheritException(exception,&(*image)->exception); |
| 1939 | break; |
| 1940 | } |
| 1941 | if (LocaleCompare("linewidth",option+1) == 0) |
| 1942 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1943 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 1944 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1945 | break; |
| 1946 | } |
| 1947 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 1948 | { |
| 1949 | /* |
| 1950 | Liquid rescale image. |
| 1951 | */ |
| 1952 | (void) SyncImageSettings(mogrify_info,*image); |
| 1953 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1954 | if ((flags & XValue) == 0) |
| 1955 | geometry.x=1; |
| 1956 | if ((flags & YValue) == 0) |
| 1957 | geometry.y=0; |
| 1958 | mogrify_image=LiquidRescaleImage(*image,geometry.width, |
| 1959 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 1960 | break; |
| 1961 | } |
| 1962 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 1963 | { |
| 1964 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1965 | break; |
| 1966 | } |
| 1967 | break; |
| 1968 | } |
| 1969 | case 'm': |
| 1970 | { |
| 1971 | if (LocaleCompare("map",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1972 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1973 | Image |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1974 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1975 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1976 | /* |
| 1977 | Transform image colors to match this set of colors. |
| 1978 | */ |
| 1979 | (void) SyncImageSettings(mogrify_info,*image); |
| 1980 | if (*option == '+') |
| 1981 | break; |
| 1982 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1983 | if (remap_image == (Image *) NULL) |
| 1984 | break; |
| 1985 | (void) RemapImage(quantize_info,*image,remap_image); |
| 1986 | InheritException(exception,&(*image)->exception); |
| 1987 | remap_image=DestroyImage(remap_image); |
| 1988 | break; |
| 1989 | } |
| 1990 | if (LocaleCompare("mask",option+1) == 0) |
| 1991 | { |
| 1992 | Image |
| 1993 | *mask; |
| 1994 | |
| 1995 | (void) SyncImageSettings(mogrify_info,*image); |
| 1996 | if (*option == '+') |
| 1997 | { |
| 1998 | /* |
| 1999 | Remove a mask. |
| 2000 | */ |
| 2001 | (void) SetImageMask(*image,(Image *) NULL); |
| 2002 | InheritException(exception,&(*image)->exception); |
| 2003 | break; |
| 2004 | } |
| 2005 | /* |
| 2006 | Set the image mask. |
| 2007 | */ |
| 2008 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2009 | if (mask == (Image *) NULL) |
| 2010 | break; |
| 2011 | (void) SetImageMask(*image,mask); |
| 2012 | mask=DestroyImage(mask); |
| 2013 | InheritException(exception,&(*image)->exception); |
| 2014 | break; |
| 2015 | } |
| 2016 | if (LocaleCompare("matte",option+1) == 0) |
| 2017 | { |
| 2018 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 2019 | SetAlphaChannel : DeactivateAlphaChannel,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2020 | break; |
| 2021 | } |
| 2022 | if (LocaleCompare("median",option+1) == 0) |
| 2023 | { |
| 2024 | /* |
| 2025 | Median filter image. |
| 2026 | */ |
| 2027 | (void) SyncImageSettings(mogrify_info,*image); |
| 2028 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2029 | mogrify_image=StatisticImage(*image,MedianStatistic,(size_t) |
| 2030 | geometry_info.rho,(size_t) geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2031 | break; |
| 2032 | } |
| 2033 | if (LocaleCompare("mode",option+1) == 0) |
| 2034 | { |
| 2035 | /* |
| 2036 | Mode image. |
| 2037 | */ |
| 2038 | (void) SyncImageSettings(mogrify_info,*image); |
| 2039 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2040 | mogrify_image=StatisticImage(*image,ModeStatistic,(size_t) |
| 2041 | geometry_info.rho,(size_t) geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2042 | break; |
| 2043 | } |
| 2044 | if (LocaleCompare("modulate",option+1) == 0) |
| 2045 | { |
| 2046 | (void) SyncImageSettings(mogrify_info,*image); |
| 2047 | (void) ModulateImage(*image,argv[i+1]); |
| 2048 | InheritException(exception,&(*image)->exception); |
| 2049 | break; |
| 2050 | } |
| 2051 | if (LocaleCompare("monitor",option+1) == 0) |
| 2052 | { |
| 2053 | if (*option == '+') |
| 2054 | { |
| 2055 | (void) SetImageProgressMonitor(*image, |
| 2056 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2057 | break; |
| 2058 | } |
| 2059 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2060 | (void *) NULL); |
| 2061 | break; |
| 2062 | } |
| 2063 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2064 | { |
| 2065 | (void) SyncImageSettings(mogrify_info,*image); |
| 2066 | (void) SetImageType(*image,BilevelType); |
| 2067 | InheritException(exception,&(*image)->exception); |
| 2068 | break; |
| 2069 | } |
| 2070 | if (LocaleCompare("morphology",option+1) == 0) |
| 2071 | { |
| 2072 | char |
| 2073 | token[MaxTextExtent]; |
| 2074 | |
| 2075 | const char |
| 2076 | *p; |
| 2077 | |
| 2078 | KernelInfo |
| 2079 | *kernel; |
| 2080 | |
| 2081 | MorphologyMethod |
| 2082 | method; |
| 2083 | |
| 2084 | ssize_t |
| 2085 | iterations; |
| 2086 | |
| 2087 | /* |
| 2088 | Morphological Image Operation |
| 2089 | */ |
| 2090 | (void) SyncImageSettings(mogrify_info,*image); |
| 2091 | p=argv[i+1]; |
| 2092 | GetMagickToken(p,&p,token); |
| 2093 | method=(MorphologyMethod) ParseCommandOption(MagickMorphologyOptions, |
| 2094 | MagickFalse,token); |
| 2095 | iterations=1L; |
| 2096 | GetMagickToken(p,&p,token); |
| 2097 | if ((*p == ':') || (*p == ',')) |
| 2098 | GetMagickToken(p,&p,token); |
| 2099 | if ((*p != '\0')) |
| 2100 | iterations=(ssize_t) StringToLong(p); |
| 2101 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2102 | if (kernel == (KernelInfo *) NULL) |
| 2103 | { |
| 2104 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2105 | OptionError,"UnabletoParseKernel","morphology"); |
| 2106 | status=MagickFalse; |
| 2107 | break; |
| 2108 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2109 | mogrify_image=MorphologyImage(*image,method,iterations,kernel, |
| 2110 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2111 | kernel=DestroyKernelInfo(kernel); |
| 2112 | break; |
| 2113 | } |
| 2114 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2115 | { |
| 2116 | /* |
| 2117 | Motion blur image. |
| 2118 | */ |
| 2119 | (void) SyncImageSettings(mogrify_info,*image); |
| 2120 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2121 | if ((flags & SigmaValue) == 0) |
| 2122 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2123 | mogrify_image=MotionBlurImage(*image,geometry_info.rho, |
| 2124 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2125 | break; |
| 2126 | } |
| 2127 | break; |
| 2128 | } |
| 2129 | case 'n': |
| 2130 | { |
| 2131 | if (LocaleCompare("negate",option+1) == 0) |
| 2132 | { |
| 2133 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2134 | (void) NegateImage(*image,*option == '+' ? MagickTrue : |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 2135 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2136 | break; |
| 2137 | } |
| 2138 | if (LocaleCompare("noise",option+1) == 0) |
| 2139 | { |
| 2140 | (void) SyncImageSettings(mogrify_info,*image); |
| 2141 | if (*option == '-') |
| 2142 | { |
| 2143 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2144 | mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t) |
| 2145 | geometry_info.rho,(size_t) geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2146 | } |
| 2147 | else |
| 2148 | { |
| 2149 | NoiseType |
| 2150 | noise; |
| 2151 | |
| 2152 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
| 2153 | MagickFalse,argv[i+1]); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 2154 | mogrify_image=AddNoiseImage(*image,noise,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2155 | } |
| 2156 | break; |
| 2157 | } |
| 2158 | if (LocaleCompare("normalize",option+1) == 0) |
| 2159 | { |
| 2160 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2161 | (void) NormalizeImage(*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2162 | InheritException(exception,&(*image)->exception); |
| 2163 | break; |
| 2164 | } |
| 2165 | break; |
| 2166 | } |
| 2167 | case 'o': |
| 2168 | { |
| 2169 | if (LocaleCompare("opaque",option+1) == 0) |
| 2170 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2171 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2172 | target; |
| 2173 | |
| 2174 | (void) SyncImageSettings(mogrify_info,*image); |
| 2175 | (void) QueryMagickColor(argv[i+1],&target,exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 2176 | (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ? |
| 2177 | MagickFalse : MagickTrue); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2178 | break; |
| 2179 | } |
| 2180 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2181 | { |
| 2182 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 1302067 | 2011-07-08 02:33:26 +0000 | [diff] [blame] | 2183 | (void) OrderedPosterizeImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2184 | break; |
| 2185 | } |
| 2186 | break; |
| 2187 | } |
| 2188 | case 'p': |
| 2189 | { |
| 2190 | if (LocaleCompare("paint",option+1) == 0) |
| 2191 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2192 | (void) SyncImageSettings(mogrify_info,*image); |
| 2193 | (void) ParseGeometry(argv[i+1],&geometry_info); |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 2194 | mogrify_image=OilPaintImage(*image,geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2195 | break; |
| 2196 | } |
| 2197 | if (LocaleCompare("pen",option+1) == 0) |
| 2198 | { |
| 2199 | if (*option == '+') |
| 2200 | { |
| 2201 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 2202 | break; |
| 2203 | } |
| 2204 | (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception); |
| 2205 | break; |
| 2206 | } |
| 2207 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2208 | { |
| 2209 | if (*option == '+') |
| 2210 | (void) ParseGeometry("12",&geometry_info); |
| 2211 | else |
| 2212 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2213 | draw_info->pointsize=geometry_info.rho; |
| 2214 | break; |
| 2215 | } |
| 2216 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2217 | { |
| 2218 | double |
| 2219 | angle; |
| 2220 | |
| 2221 | RandomInfo |
| 2222 | *random_info; |
| 2223 | |
| 2224 | /* |
| 2225 | Simulate a Polaroid picture. |
| 2226 | */ |
| 2227 | (void) SyncImageSettings(mogrify_info,*image); |
| 2228 | random_info=AcquireRandomInfo(); |
| 2229 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2230 | random_info=DestroyRandomInfo(random_info); |
| 2231 | if (*option == '-') |
| 2232 | { |
| 2233 | SetGeometryInfo(&geometry_info); |
| 2234 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2235 | angle=geometry_info.rho; |
| 2236 | } |
| 2237 | mogrify_image=PolaroidImage(*image,draw_info,angle,exception); |
| 2238 | break; |
| 2239 | } |
| 2240 | if (LocaleCompare("posterize",option+1) == 0) |
| 2241 | { |
| 2242 | /* |
| 2243 | Posterize image. |
| 2244 | */ |
| 2245 | (void) SyncImageSettings(mogrify_info,*image); |
| 2246 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
| 2247 | quantize_info->dither); |
| 2248 | InheritException(exception,&(*image)->exception); |
| 2249 | break; |
| 2250 | } |
| 2251 | if (LocaleCompare("preview",option+1) == 0) |
| 2252 | { |
| 2253 | PreviewType |
| 2254 | preview_type; |
| 2255 | |
| 2256 | /* |
| 2257 | Preview image. |
| 2258 | */ |
| 2259 | (void) SyncImageSettings(mogrify_info,*image); |
| 2260 | if (*option == '+') |
| 2261 | preview_type=UndefinedPreview; |
| 2262 | else |
| 2263 | preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions, |
| 2264 | MagickFalse,argv[i+1]); |
| 2265 | mogrify_image=PreviewImage(*image,preview_type,exception); |
| 2266 | break; |
| 2267 | } |
| 2268 | if (LocaleCompare("profile",option+1) == 0) |
| 2269 | { |
| 2270 | const char |
| 2271 | *name; |
| 2272 | |
| 2273 | const StringInfo |
| 2274 | *profile; |
| 2275 | |
| 2276 | Image |
| 2277 | *profile_image; |
| 2278 | |
| 2279 | ImageInfo |
| 2280 | *profile_info; |
| 2281 | |
| 2282 | (void) SyncImageSettings(mogrify_info,*image); |
| 2283 | if (*option == '+') |
| 2284 | { |
| 2285 | /* |
| 2286 | Remove a profile from the image. |
| 2287 | */ |
| 2288 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
| 2289 | NULL,0,MagickTrue); |
| 2290 | InheritException(exception,&(*image)->exception); |
| 2291 | break; |
| 2292 | } |
| 2293 | /* |
| 2294 | Associate a profile with the image. |
| 2295 | */ |
| 2296 | profile_info=CloneImageInfo(mogrify_info); |
| 2297 | profile=GetImageProfile(*image,"iptc"); |
| 2298 | if (profile != (StringInfo *) NULL) |
| 2299 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2300 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2301 | profile_info=DestroyImageInfo(profile_info); |
| 2302 | if (profile_image == (Image *) NULL) |
| 2303 | { |
| 2304 | StringInfo |
| 2305 | *profile; |
| 2306 | |
| 2307 | profile_info=CloneImageInfo(mogrify_info); |
| 2308 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2309 | MaxTextExtent); |
| 2310 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
| 2311 | if (profile != (StringInfo *) NULL) |
| 2312 | { |
| 2313 | (void) ProfileImage(*image,profile_info->magick, |
| 2314 | GetStringInfoDatum(profile),(size_t) |
| 2315 | GetStringInfoLength(profile),MagickFalse); |
| 2316 | profile=DestroyStringInfo(profile); |
| 2317 | } |
| 2318 | profile_info=DestroyImageInfo(profile_info); |
| 2319 | break; |
| 2320 | } |
| 2321 | ResetImageProfileIterator(profile_image); |
| 2322 | name=GetNextImageProfile(profile_image); |
| 2323 | while (name != (const char *) NULL) |
| 2324 | { |
| 2325 | profile=GetImageProfile(profile_image,name); |
| 2326 | if (profile != (StringInfo *) NULL) |
| 2327 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
| 2328 | (size_t) GetStringInfoLength(profile),MagickFalse); |
| 2329 | name=GetNextImageProfile(profile_image); |
| 2330 | } |
| 2331 | profile_image=DestroyImage(profile_image); |
| 2332 | break; |
| 2333 | } |
| 2334 | break; |
| 2335 | } |
| 2336 | case 'q': |
| 2337 | { |
| 2338 | if (LocaleCompare("quantize",option+1) == 0) |
| 2339 | { |
| 2340 | if (*option == '+') |
| 2341 | { |
| 2342 | quantize_info->colorspace=UndefinedColorspace; |
| 2343 | break; |
| 2344 | } |
| 2345 | quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
| 2346 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2347 | break; |
| 2348 | } |
| 2349 | break; |
| 2350 | } |
| 2351 | case 'r': |
| 2352 | { |
| 2353 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2354 | { |
| 2355 | /* |
| 2356 | Radial blur image. |
| 2357 | */ |
| 2358 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2359 | mogrify_image=RadialBlurImage(*image,InterpretLocaleValue(argv[i+1], |
| 2360 | (char **) NULL),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2361 | break; |
| 2362 | } |
| 2363 | if (LocaleCompare("raise",option+1) == 0) |
| 2364 | { |
| 2365 | /* |
| 2366 | Surround image with a raise of solid color. |
| 2367 | */ |
| 2368 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2369 | if ((flags & SigmaValue) == 0) |
| 2370 | geometry.height=geometry.width; |
| 2371 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
| 2372 | MagickFalse); |
| 2373 | InheritException(exception,&(*image)->exception); |
| 2374 | break; |
| 2375 | } |
| 2376 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2377 | { |
| 2378 | /* |
| 2379 | Threshold image. |
| 2380 | */ |
| 2381 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2382 | (void) RandomThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2383 | break; |
| 2384 | } |
| 2385 | if (LocaleCompare("recolor",option+1) == 0) |
| 2386 | { |
| 2387 | KernelInfo |
| 2388 | *kernel; |
| 2389 | |
| 2390 | (void) SyncImageSettings(mogrify_info,*image); |
| 2391 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2392 | if (kernel == (KernelInfo *) NULL) |
| 2393 | break; |
| 2394 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 2395 | kernel=DestroyKernelInfo(kernel); |
| 2396 | break; |
| 2397 | } |
| 2398 | if (LocaleCompare("region",option+1) == 0) |
| 2399 | { |
| 2400 | (void) SyncImageSettings(mogrify_info,*image); |
| 2401 | if (region_image != (Image *) NULL) |
| 2402 | { |
| 2403 | /* |
| 2404 | Composite region. |
| 2405 | */ |
| 2406 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2407 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 2408 | region_geometry.x,region_geometry.y); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2409 | InheritException(exception,®ion_image->exception); |
| 2410 | *image=DestroyImage(*image); |
| 2411 | *image=region_image; |
| 2412 | region_image = (Image *) NULL; |
| 2413 | } |
| 2414 | if (*option == '+') |
| 2415 | break; |
| 2416 | /* |
| 2417 | Apply transformations to a selected region of the image. |
| 2418 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2419 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2420 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2421 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2422 | if (mogrify_image == (Image *) NULL) |
| 2423 | break; |
| 2424 | region_image=(*image); |
| 2425 | *image=mogrify_image; |
| 2426 | mogrify_image=(Image *) NULL; |
| 2427 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2428 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2429 | if (LocaleCompare("render",option+1) == 0) |
| 2430 | { |
| 2431 | (void) SyncImageSettings(mogrify_info,*image); |
| 2432 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2433 | break; |
| 2434 | } |
| 2435 | if (LocaleCompare("remap",option+1) == 0) |
| 2436 | { |
| 2437 | Image |
| 2438 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2439 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2440 | /* |
| 2441 | Transform image colors to match this set of colors. |
| 2442 | */ |
| 2443 | (void) SyncImageSettings(mogrify_info,*image); |
| 2444 | if (*option == '+') |
| 2445 | break; |
| 2446 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2447 | if (remap_image == (Image *) NULL) |
| 2448 | break; |
| 2449 | (void) RemapImage(quantize_info,*image,remap_image); |
| 2450 | InheritException(exception,&(*image)->exception); |
| 2451 | remap_image=DestroyImage(remap_image); |
| 2452 | break; |
| 2453 | } |
| 2454 | if (LocaleCompare("repage",option+1) == 0) |
| 2455 | { |
| 2456 | if (*option == '+') |
| 2457 | { |
| 2458 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2459 | break; |
| 2460 | } |
| 2461 | (void) ResetImagePage(*image,argv[i+1]); |
| 2462 | InheritException(exception,&(*image)->exception); |
| 2463 | break; |
| 2464 | } |
| 2465 | if (LocaleCompare("resample",option+1) == 0) |
| 2466 | { |
| 2467 | /* |
| 2468 | Resample image. |
| 2469 | */ |
| 2470 | (void) SyncImageSettings(mogrify_info,*image); |
| 2471 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2472 | if ((flags & SigmaValue) == 0) |
| 2473 | geometry_info.sigma=geometry_info.rho; |
| 2474 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
| 2475 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2476 | break; |
| 2477 | } |
| 2478 | if (LocaleCompare("resize",option+1) == 0) |
| 2479 | { |
| 2480 | /* |
| 2481 | Resize image. |
| 2482 | */ |
| 2483 | (void) SyncImageSettings(mogrify_info,*image); |
| 2484 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2485 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2486 | (*image)->filter,(*image)->blur,exception); |
| 2487 | break; |
| 2488 | } |
| 2489 | if (LocaleCompare("roll",option+1) == 0) |
| 2490 | { |
| 2491 | /* |
| 2492 | Roll image. |
| 2493 | */ |
| 2494 | (void) SyncImageSettings(mogrify_info,*image); |
| 2495 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2496 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2497 | break; |
| 2498 | } |
| 2499 | if (LocaleCompare("rotate",option+1) == 0) |
| 2500 | { |
| 2501 | char |
| 2502 | *geometry; |
| 2503 | |
| 2504 | /* |
| 2505 | Check for conditional image rotation. |
| 2506 | */ |
| 2507 | (void) SyncImageSettings(mogrify_info,*image); |
| 2508 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2509 | if ((*image)->columns <= (*image)->rows) |
| 2510 | break; |
| 2511 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2512 | if ((*image)->columns >= (*image)->rows) |
| 2513 | break; |
| 2514 | /* |
| 2515 | Rotate image. |
| 2516 | */ |
| 2517 | geometry=ConstantString(argv[i+1]); |
| 2518 | (void) SubstituteString(&geometry,">",""); |
| 2519 | (void) SubstituteString(&geometry,"<",""); |
| 2520 | (void) ParseGeometry(geometry,&geometry_info); |
| 2521 | geometry=DestroyString(geometry); |
| 2522 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
| 2523 | break; |
| 2524 | } |
| 2525 | break; |
| 2526 | } |
| 2527 | case 's': |
| 2528 | { |
| 2529 | if (LocaleCompare("sample",option+1) == 0) |
| 2530 | { |
| 2531 | /* |
| 2532 | Sample image with pixel replication. |
| 2533 | */ |
| 2534 | (void) SyncImageSettings(mogrify_info,*image); |
| 2535 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2536 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
| 2537 | exception); |
| 2538 | break; |
| 2539 | } |
| 2540 | if (LocaleCompare("scale",option+1) == 0) |
| 2541 | { |
| 2542 | /* |
| 2543 | Resize image. |
| 2544 | */ |
| 2545 | (void) SyncImageSettings(mogrify_info,*image); |
| 2546 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2547 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2548 | exception); |
| 2549 | break; |
| 2550 | } |
| 2551 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2552 | { |
| 2553 | /* |
| 2554 | Selectively blur pixels within a contrast threshold. |
| 2555 | */ |
| 2556 | (void) SyncImageSettings(mogrify_info,*image); |
| 2557 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2558 | if ((flags & PercentValue) != 0) |
| 2559 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2560 | mogrify_image=SelectiveBlurImage(*image,geometry_info.rho, |
| 2561 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2562 | break; |
| 2563 | } |
| 2564 | if (LocaleCompare("separate",option+1) == 0) |
| 2565 | { |
| 2566 | /* |
| 2567 | Break channels into separate images. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2568 | */ |
| 2569 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 2570 | mogrify_image=SeparateImages(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2571 | break; |
| 2572 | } |
| 2573 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2574 | { |
| 2575 | double |
| 2576 | threshold; |
| 2577 | |
| 2578 | /* |
| 2579 | Sepia-tone image. |
| 2580 | */ |
| 2581 | (void) SyncImageSettings(mogrify_info,*image); |
| 2582 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2583 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
| 2584 | break; |
| 2585 | } |
| 2586 | if (LocaleCompare("segment",option+1) == 0) |
| 2587 | { |
| 2588 | /* |
| 2589 | Segment image. |
| 2590 | */ |
| 2591 | (void) SyncImageSettings(mogrify_info,*image); |
| 2592 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2593 | if ((flags & SigmaValue) == 0) |
| 2594 | geometry_info.sigma=1.0; |
| 2595 | (void) SegmentImage(*image,(*image)->colorspace, |
| 2596 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma); |
| 2597 | InheritException(exception,&(*image)->exception); |
| 2598 | break; |
| 2599 | } |
| 2600 | if (LocaleCompare("set",option+1) == 0) |
| 2601 | { |
| 2602 | char |
| 2603 | *value; |
| 2604 | |
| 2605 | /* |
| 2606 | Set image option. |
| 2607 | */ |
| 2608 | if (*option == '+') |
| 2609 | { |
| 2610 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2611 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2612 | else |
| 2613 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2614 | { |
| 2615 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
| 2616 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2617 | } |
| 2618 | else |
| 2619 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2620 | break; |
| 2621 | } |
| 2622 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 2623 | if (value == (char *) NULL) |
| 2624 | break; |
| 2625 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2626 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2627 | exception); |
| 2628 | else |
| 2629 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2630 | { |
| 2631 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
| 2632 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
| 2633 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2634 | } |
| 2635 | else |
| 2636 | (void) SetImageProperty(*image,argv[i+1],value); |
| 2637 | value=DestroyString(value); |
| 2638 | break; |
| 2639 | } |
| 2640 | if (LocaleCompare("shade",option+1) == 0) |
| 2641 | { |
| 2642 | /* |
| 2643 | Shade image. |
| 2644 | */ |
| 2645 | (void) SyncImageSettings(mogrify_info,*image); |
| 2646 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2647 | if ((flags & SigmaValue) == 0) |
| 2648 | geometry_info.sigma=1.0; |
| 2649 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2650 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2651 | break; |
| 2652 | } |
| 2653 | if (LocaleCompare("shadow",option+1) == 0) |
| 2654 | { |
| 2655 | /* |
| 2656 | Shadow image. |
| 2657 | */ |
| 2658 | (void) SyncImageSettings(mogrify_info,*image); |
| 2659 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2660 | if ((flags & SigmaValue) == 0) |
| 2661 | geometry_info.sigma=1.0; |
| 2662 | if ((flags & XiValue) == 0) |
| 2663 | geometry_info.xi=4.0; |
| 2664 | if ((flags & PsiValue) == 0) |
| 2665 | geometry_info.psi=4.0; |
| 2666 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
| 2667 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 2668 | ceil(geometry_info.psi-0.5),exception); |
| 2669 | break; |
| 2670 | } |
| 2671 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2672 | { |
| 2673 | /* |
| 2674 | Sharpen image. |
| 2675 | */ |
| 2676 | (void) SyncImageSettings(mogrify_info,*image); |
| 2677 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2678 | if ((flags & SigmaValue) == 0) |
| 2679 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2680 | mogrify_image=SharpenImage(*image,geometry_info.rho, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2681 | geometry_info.sigma,exception); |
| 2682 | break; |
| 2683 | } |
| 2684 | if (LocaleCompare("shave",option+1) == 0) |
| 2685 | { |
| 2686 | /* |
| 2687 | Shave the image edges. |
| 2688 | */ |
| 2689 | (void) SyncImageSettings(mogrify_info,*image); |
| 2690 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2691 | mogrify_image=ShaveImage(*image,&geometry,exception); |
| 2692 | break; |
| 2693 | } |
| 2694 | if (LocaleCompare("shear",option+1) == 0) |
| 2695 | { |
| 2696 | /* |
| 2697 | Shear image. |
| 2698 | */ |
| 2699 | (void) SyncImageSettings(mogrify_info,*image); |
| 2700 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2701 | if ((flags & SigmaValue) == 0) |
| 2702 | geometry_info.sigma=geometry_info.rho; |
| 2703 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2704 | geometry_info.sigma,exception); |
| 2705 | break; |
| 2706 | } |
| 2707 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2708 | { |
| 2709 | /* |
| 2710 | Sigmoidal non-linearity contrast control. |
| 2711 | */ |
| 2712 | (void) SyncImageSettings(mogrify_info,*image); |
| 2713 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2714 | if ((flags & SigmaValue) == 0) |
| 2715 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 2716 | if ((flags & PercentValue) != 0) |
| 2717 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2718 | 100.0; |
cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 2719 | (void) SigmoidalContrastImage(*image,(*option == '-') ? |
| 2720 | MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2721 | InheritException(exception,&(*image)->exception); |
| 2722 | break; |
| 2723 | } |
| 2724 | if (LocaleCompare("sketch",option+1) == 0) |
| 2725 | { |
| 2726 | /* |
| 2727 | Sketch image. |
| 2728 | */ |
| 2729 | (void) SyncImageSettings(mogrify_info,*image); |
| 2730 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2731 | if ((flags & SigmaValue) == 0) |
| 2732 | geometry_info.sigma=1.0; |
| 2733 | mogrify_image=SketchImage(*image,geometry_info.rho, |
| 2734 | geometry_info.sigma,geometry_info.xi,exception); |
| 2735 | break; |
| 2736 | } |
| 2737 | if (LocaleCompare("solarize",option+1) == 0) |
| 2738 | { |
| 2739 | double |
| 2740 | threshold; |
| 2741 | |
| 2742 | (void) SyncImageSettings(mogrify_info,*image); |
| 2743 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2744 | (void) SolarizeImage(*image,threshold); |
| 2745 | InheritException(exception,&(*image)->exception); |
| 2746 | break; |
| 2747 | } |
| 2748 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2749 | { |
| 2750 | SparseColorMethod |
| 2751 | method; |
| 2752 | |
| 2753 | char |
| 2754 | *arguments; |
| 2755 | |
| 2756 | /* |
| 2757 | Sparse Color Interpolated Gradient |
| 2758 | */ |
| 2759 | (void) SyncImageSettings(mogrify_info,*image); |
| 2760 | method=(SparseColorMethod) ParseCommandOption( |
| 2761 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
| 2762 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 2763 | InheritException(exception,&(*image)->exception); |
| 2764 | if (arguments == (char *) NULL) |
| 2765 | break; |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 2766 | mogrify_image=SparseColorOption(*image,method,arguments, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2767 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2768 | arguments=DestroyString(arguments); |
| 2769 | break; |
| 2770 | } |
| 2771 | if (LocaleCompare("splice",option+1) == 0) |
| 2772 | { |
| 2773 | /* |
| 2774 | Splice a solid color into the image. |
| 2775 | */ |
| 2776 | (void) SyncImageSettings(mogrify_info,*image); |
| 2777 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 2778 | mogrify_image=SpliceImage(*image,&geometry,exception); |
| 2779 | break; |
| 2780 | } |
| 2781 | if (LocaleCompare("spread",option+1) == 0) |
| 2782 | { |
| 2783 | /* |
| 2784 | Spread an image. |
| 2785 | */ |
| 2786 | (void) SyncImageSettings(mogrify_info,*image); |
| 2787 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2788 | mogrify_image=SpreadImage(*image,geometry_info.rho,exception); |
| 2789 | break; |
| 2790 | } |
| 2791 | if (LocaleCompare("statistic",option+1) == 0) |
| 2792 | { |
| 2793 | StatisticType |
| 2794 | type; |
| 2795 | |
| 2796 | (void) SyncImageSettings(mogrify_info,*image); |
| 2797 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
| 2798 | MagickFalse,argv[i+1]); |
| 2799 | (void) ParseGeometry(argv[i+2],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2800 | mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho, |
| 2801 | (size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2802 | break; |
| 2803 | } |
| 2804 | if (LocaleCompare("stretch",option+1) == 0) |
| 2805 | { |
| 2806 | if (*option == '+') |
| 2807 | { |
| 2808 | draw_info->stretch=UndefinedStretch; |
| 2809 | break; |
| 2810 | } |
| 2811 | draw_info->stretch=(StretchType) ParseCommandOption( |
| 2812 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2813 | break; |
| 2814 | } |
| 2815 | if (LocaleCompare("strip",option+1) == 0) |
| 2816 | { |
| 2817 | /* |
| 2818 | Strip image of profiles and comments. |
| 2819 | */ |
| 2820 | (void) SyncImageSettings(mogrify_info,*image); |
| 2821 | (void) StripImage(*image); |
| 2822 | InheritException(exception,&(*image)->exception); |
| 2823 | break; |
| 2824 | } |
| 2825 | if (LocaleCompare("stroke",option+1) == 0) |
| 2826 | { |
| 2827 | ExceptionInfo |
| 2828 | *sans; |
| 2829 | |
| 2830 | if (*option == '+') |
| 2831 | { |
| 2832 | (void) QueryColorDatabase("none",&draw_info->stroke,exception); |
| 2833 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2834 | draw_info->stroke_pattern=DestroyImage( |
| 2835 | draw_info->stroke_pattern); |
| 2836 | break; |
| 2837 | } |
| 2838 | sans=AcquireExceptionInfo(); |
| 2839 | status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans); |
| 2840 | sans=DestroyExceptionInfo(sans); |
| 2841 | if (status == MagickFalse) |
| 2842 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2843 | exception); |
| 2844 | break; |
| 2845 | } |
| 2846 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2847 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 2848 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 2849 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2850 | break; |
| 2851 | } |
| 2852 | if (LocaleCompare("style",option+1) == 0) |
| 2853 | { |
| 2854 | if (*option == '+') |
| 2855 | { |
| 2856 | draw_info->style=UndefinedStyle; |
| 2857 | break; |
| 2858 | } |
| 2859 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 2860 | MagickFalse,argv[i+1]); |
| 2861 | break; |
| 2862 | } |
| 2863 | if (LocaleCompare("swirl",option+1) == 0) |
| 2864 | { |
| 2865 | /* |
| 2866 | Swirl image. |
| 2867 | */ |
| 2868 | (void) SyncImageSettings(mogrify_info,*image); |
| 2869 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2870 | mogrify_image=SwirlImage(*image,geometry_info.rho,exception); |
| 2871 | break; |
| 2872 | } |
| 2873 | break; |
| 2874 | } |
| 2875 | case 't': |
| 2876 | { |
| 2877 | if (LocaleCompare("threshold",option+1) == 0) |
| 2878 | { |
| 2879 | double |
| 2880 | threshold; |
| 2881 | |
| 2882 | /* |
| 2883 | Threshold image. |
| 2884 | */ |
| 2885 | (void) SyncImageSettings(mogrify_info,*image); |
| 2886 | if (*option == '+') |
anthony | 247a86d | 2011-05-03 13:18:18 +0000 | [diff] [blame] | 2887 | threshold=(double) QuantumRange/2; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2888 | else |
| 2889 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2890 | (void) BilevelImage(*image,threshold); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2891 | InheritException(exception,&(*image)->exception); |
| 2892 | break; |
| 2893 | } |
| 2894 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2895 | { |
| 2896 | /* |
| 2897 | Thumbnail image. |
| 2898 | */ |
| 2899 | (void) SyncImageSettings(mogrify_info,*image); |
| 2900 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2901 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2902 | exception); |
| 2903 | break; |
| 2904 | } |
| 2905 | if (LocaleCompare("tile",option+1) == 0) |
| 2906 | { |
| 2907 | if (*option == '+') |
| 2908 | { |
| 2909 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2910 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2911 | break; |
| 2912 | } |
| 2913 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2914 | exception); |
| 2915 | break; |
| 2916 | } |
| 2917 | if (LocaleCompare("tint",option+1) == 0) |
| 2918 | { |
| 2919 | /* |
| 2920 | Tint the image. |
| 2921 | */ |
| 2922 | (void) SyncImageSettings(mogrify_info,*image); |
| 2923 | mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception); |
| 2924 | break; |
| 2925 | } |
| 2926 | if (LocaleCompare("transform",option+1) == 0) |
| 2927 | { |
| 2928 | /* |
| 2929 | Affine transform image. |
| 2930 | */ |
| 2931 | (void) SyncImageSettings(mogrify_info,*image); |
| 2932 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
| 2933 | exception); |
| 2934 | break; |
| 2935 | } |
| 2936 | if (LocaleCompare("transparent",option+1) == 0) |
| 2937 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2938 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2939 | target; |
| 2940 | |
| 2941 | (void) SyncImageSettings(mogrify_info,*image); |
| 2942 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2943 | (void) TransparentPaintImage(*image,&target,(Quantum) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2944 | TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2945 | InheritException(exception,&(*image)->exception); |
| 2946 | break; |
| 2947 | } |
| 2948 | if (LocaleCompare("transpose",option+1) == 0) |
| 2949 | { |
| 2950 | /* |
| 2951 | Transpose image scanlines. |
| 2952 | */ |
| 2953 | (void) SyncImageSettings(mogrify_info,*image); |
| 2954 | mogrify_image=TransposeImage(*image,exception); |
| 2955 | break; |
| 2956 | } |
| 2957 | if (LocaleCompare("transverse",option+1) == 0) |
| 2958 | { |
| 2959 | /* |
| 2960 | Transverse image scanlines. |
| 2961 | */ |
| 2962 | (void) SyncImageSettings(mogrify_info,*image); |
| 2963 | mogrify_image=TransverseImage(*image,exception); |
| 2964 | break; |
| 2965 | } |
| 2966 | if (LocaleCompare("treedepth",option+1) == 0) |
| 2967 | { |
| 2968 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
| 2969 | break; |
| 2970 | } |
| 2971 | if (LocaleCompare("trim",option+1) == 0) |
| 2972 | { |
| 2973 | /* |
| 2974 | Trim image. |
| 2975 | */ |
| 2976 | (void) SyncImageSettings(mogrify_info,*image); |
| 2977 | mogrify_image=TrimImage(*image,exception); |
| 2978 | break; |
| 2979 | } |
| 2980 | if (LocaleCompare("type",option+1) == 0) |
| 2981 | { |
| 2982 | ImageType |
| 2983 | type; |
| 2984 | |
| 2985 | (void) SyncImageSettings(mogrify_info,*image); |
| 2986 | if (*option == '+') |
| 2987 | type=UndefinedType; |
| 2988 | else |
| 2989 | type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 2990 | argv[i+1]); |
| 2991 | (*image)->type=UndefinedType; |
| 2992 | (void) SetImageType(*image,type); |
| 2993 | InheritException(exception,&(*image)->exception); |
| 2994 | break; |
| 2995 | } |
| 2996 | break; |
| 2997 | } |
| 2998 | case 'u': |
| 2999 | { |
| 3000 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3001 | { |
| 3002 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 3003 | exception); |
| 3004 | break; |
| 3005 | } |
| 3006 | if (LocaleCompare("unique",option+1) == 0) |
| 3007 | { |
| 3008 | if (*option == '+') |
| 3009 | { |
| 3010 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
| 3011 | break; |
| 3012 | } |
| 3013 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
| 3014 | (void) SetImageArtifact(*image,"verbose","true"); |
| 3015 | break; |
| 3016 | } |
| 3017 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3018 | { |
| 3019 | /* |
| 3020 | Unique image colors. |
| 3021 | */ |
| 3022 | (void) SyncImageSettings(mogrify_info,*image); |
| 3023 | mogrify_image=UniqueImageColors(*image,exception); |
| 3024 | break; |
| 3025 | } |
| 3026 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3027 | { |
| 3028 | /* |
| 3029 | Unsharp mask image. |
| 3030 | */ |
| 3031 | (void) SyncImageSettings(mogrify_info,*image); |
| 3032 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3033 | if ((flags & SigmaValue) == 0) |
| 3034 | geometry_info.sigma=1.0; |
| 3035 | if ((flags & XiValue) == 0) |
| 3036 | geometry_info.xi=1.0; |
| 3037 | if ((flags & PsiValue) == 0) |
| 3038 | geometry_info.psi=0.05; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3039 | mogrify_image=UnsharpMaskImage(*image,geometry_info.rho, |
| 3040 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3041 | break; |
| 3042 | } |
| 3043 | break; |
| 3044 | } |
| 3045 | case 'v': |
| 3046 | { |
| 3047 | if (LocaleCompare("verbose",option+1) == 0) |
| 3048 | { |
| 3049 | (void) SetImageArtifact(*image,option+1, |
| 3050 | *option == '+' ? "false" : "true"); |
| 3051 | break; |
| 3052 | } |
| 3053 | if (LocaleCompare("vignette",option+1) == 0) |
| 3054 | { |
| 3055 | /* |
| 3056 | Vignette image. |
| 3057 | */ |
| 3058 | (void) SyncImageSettings(mogrify_info,*image); |
| 3059 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3060 | if ((flags & SigmaValue) == 0) |
| 3061 | geometry_info.sigma=1.0; |
| 3062 | if ((flags & XiValue) == 0) |
| 3063 | geometry_info.xi=0.1*(*image)->columns; |
| 3064 | if ((flags & PsiValue) == 0) |
| 3065 | geometry_info.psi=0.1*(*image)->rows; |
| 3066 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
| 3067 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3068 | ceil(geometry_info.psi-0.5),exception); |
| 3069 | break; |
| 3070 | } |
| 3071 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3072 | { |
| 3073 | if (*option == '+') |
| 3074 | { |
| 3075 | (void) SetImageVirtualPixelMethod(*image, |
| 3076 | UndefinedVirtualPixelMethod); |
| 3077 | break; |
| 3078 | } |
| 3079 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3080 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 3081 | argv[i+1])); |
| 3082 | break; |
| 3083 | } |
| 3084 | break; |
| 3085 | } |
| 3086 | case 'w': |
| 3087 | { |
| 3088 | if (LocaleCompare("wave",option+1) == 0) |
| 3089 | { |
| 3090 | /* |
| 3091 | Wave image. |
| 3092 | */ |
| 3093 | (void) SyncImageSettings(mogrify_info,*image); |
| 3094 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3095 | if ((flags & SigmaValue) == 0) |
| 3096 | geometry_info.sigma=1.0; |
| 3097 | mogrify_image=WaveImage(*image,geometry_info.rho, |
| 3098 | geometry_info.sigma,exception); |
| 3099 | break; |
| 3100 | } |
| 3101 | if (LocaleCompare("weight",option+1) == 0) |
| 3102 | { |
| 3103 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
| 3104 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3105 | draw_info->weight=0; |
| 3106 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3107 | draw_info->weight=700; |
| 3108 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3109 | if (draw_info->weight <= 800) |
| 3110 | draw_info->weight+=100; |
| 3111 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3112 | if (draw_info->weight >= 100) |
| 3113 | draw_info->weight-=100; |
| 3114 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3115 | draw_info->weight=400; |
| 3116 | break; |
| 3117 | } |
| 3118 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3119 | { |
| 3120 | /* |
| 3121 | White threshold image. |
| 3122 | */ |
| 3123 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3124 | (void) WhiteThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3125 | InheritException(exception,&(*image)->exception); |
| 3126 | break; |
| 3127 | } |
| 3128 | break; |
| 3129 | } |
| 3130 | default: |
| 3131 | break; |
| 3132 | } |
| 3133 | /* |
| 3134 | Replace current image with any image that was generated |
| 3135 | */ |
| 3136 | if (mogrify_image != (Image *) NULL) |
| 3137 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3138 | i+=count; |
| 3139 | } |
| 3140 | if (region_image != (Image *) NULL) |
| 3141 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3142 | /* |
| 3143 | Composite transformed region onto image. |
| 3144 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3145 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3146 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3147 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 3148 | region_geometry.x,region_geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3149 | InheritException(exception,®ion_image->exception); |
| 3150 | *image=DestroyImage(*image); |
| 3151 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3152 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3153 | } |
| 3154 | /* |
| 3155 | Free resources. |
| 3156 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3157 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3158 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3159 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 3160 | status=(MagickStatusType) ((*image)->exception.severity == |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 3161 | UndefinedException ? 1 : 0); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3162 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3163 | } |
| 3164 | |
| 3165 | /* |
| 3166 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3167 | % % |
| 3168 | % % |
| 3169 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3170 | + 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] | 3171 | % % |
| 3172 | % % |
| 3173 | % % |
| 3174 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3175 | % |
| 3176 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3177 | % transforms include image scaling, image rotation, color reduction, and |
| 3178 | % others. The transmogrified image overwrites the original image. |
| 3179 | % |
| 3180 | % The format of the MogrifyImageCommand method is: |
| 3181 | % |
| 3182 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3183 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3184 | % |
| 3185 | % A description of each parameter follows: |
| 3186 | % |
| 3187 | % o image_info: the image info. |
| 3188 | % |
| 3189 | % o argc: the number of elements in the argument vector. |
| 3190 | % |
| 3191 | % o argv: A text array containing the command line arguments. |
| 3192 | % |
| 3193 | % o metadata: any metadata is returned here. |
| 3194 | % |
| 3195 | % o exception: return any errors or warnings in this structure. |
| 3196 | % |
| 3197 | */ |
| 3198 | |
| 3199 | static MagickBooleanType MogrifyUsage(void) |
| 3200 | { |
| 3201 | static const char |
| 3202 | *miscellaneous[]= |
| 3203 | { |
| 3204 | "-debug events display copious debugging information", |
| 3205 | "-help print program options", |
| 3206 | "-list type print a list of supported option arguments", |
| 3207 | "-log format format of debugging information", |
| 3208 | "-version print version information", |
| 3209 | (char *) NULL |
| 3210 | }, |
| 3211 | *operators[]= |
| 3212 | { |
| 3213 | "-adaptive-blur geometry", |
| 3214 | " adaptively blur pixels; decrease effect near edges", |
| 3215 | "-adaptive-resize geometry", |
| 3216 | " adaptively resize image using 'mesh' interpolation", |
| 3217 | "-adaptive-sharpen geometry", |
| 3218 | " adaptively sharpen pixels; increase effect near edges", |
| 3219 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3220 | " transparent, extract, background, or shape", |
| 3221 | "-annotate geometry text", |
| 3222 | " annotate the image with text", |
| 3223 | "-auto-gamma automagically adjust gamma level of image", |
| 3224 | "-auto-level automagically adjust color levels of image", |
| 3225 | "-auto-orient automagically orient (rotate) image", |
| 3226 | "-bench iterations measure performance", |
| 3227 | "-black-threshold value", |
| 3228 | " force all pixels below the threshold into black", |
| 3229 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3230 | "-blur geometry reduce image noise and reduce detail levels", |
| 3231 | "-border geometry surround image with a border of color", |
| 3232 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3233 | "-brightness-contrast geometry", |
| 3234 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3235 | "-cdl filename color correct with a color decision list", |
| 3236 | "-charcoal radius simulate a charcoal drawing", |
| 3237 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3238 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3239 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3240 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3241 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3242 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3243 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3244 | "-contrast enhance or reduce the image contrast", |
| 3245 | "-contrast-stretch geometry", |
| 3246 | " improve contrast by `stretching' the intensity range", |
| 3247 | "-convolve coefficients", |
| 3248 | " apply a convolution kernel to the image", |
| 3249 | "-cycle amount cycle the image colormap", |
| 3250 | "-decipher filename convert cipher pixels to plain pixels", |
| 3251 | "-deskew threshold straighten an image", |
| 3252 | "-despeckle reduce the speckles within an image", |
| 3253 | "-distort method args", |
| 3254 | " distort images according to given method ad args", |
| 3255 | "-draw string annotate the image with a graphic primitive", |
| 3256 | "-edge radius apply a filter to detect edges in the image", |
| 3257 | "-encipher filename convert plain pixels to cipher pixels", |
| 3258 | "-emboss radius emboss an image", |
| 3259 | "-enhance apply a digital filter to enhance a noisy image", |
| 3260 | "-equalize perform histogram equalization to an image", |
| 3261 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3262 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3263 | "-extent geometry set the image size", |
| 3264 | "-extract geometry extract area from image", |
| 3265 | "-fft implements the discrete Fourier transform (DFT)", |
| 3266 | "-flip flip image vertically", |
| 3267 | "-floodfill geometry color", |
| 3268 | " floodfill the image with color", |
| 3269 | "-flop flop image horizontally", |
| 3270 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3271 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3272 | " apply function over image values", |
| 3273 | "-gamma value level of gamma correction", |
| 3274 | "-gaussian-blur geometry", |
| 3275 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3276 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3277 | "-identify identify the format and characteristics of the image", |
| 3278 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3279 | "-implode amount implode image pixels about the center", |
| 3280 | "-lat geometry local adaptive thresholding", |
| 3281 | "-layers method optimize, merge, or compare image layers", |
| 3282 | "-level value adjust the level of image contrast", |
| 3283 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3284 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3285 | "-linear-stretch geometry", |
| 3286 | " improve contrast by `stretching with saturation'", |
| 3287 | "-liquid-rescale geometry", |
| 3288 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3289 | "-median geometry apply a median filter to the image", |
glennrp | 30d2dc6 | 2011-06-25 03:17:16 +0000 | [diff] [blame] | 3290 | "-mode geometry make each pixel the 'predominant color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3291 | "-modulate value vary the brightness, saturation, and hue", |
| 3292 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3293 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3294 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3295 | "-motion-blur geometry", |
| 3296 | " simulate motion blur", |
| 3297 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3298 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3299 | "-normalize transform image to span the full range of colors", |
| 3300 | "-opaque color change this color to the fill color", |
| 3301 | "-ordered-dither NxN", |
| 3302 | " add a noise pattern to the image with specific", |
| 3303 | " amplitudes", |
| 3304 | "-paint radius simulate an oil painting", |
| 3305 | "-polaroid angle simulate a Polaroid picture", |
| 3306 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3307 | "-profile filename add, delete, or apply an image profile", |
| 3308 | "-quantize colorspace reduce colors in this colorspace", |
| 3309 | "-radial-blur angle radial blur the image", |
| 3310 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3311 | "-random-threshold low,high", |
| 3312 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3313 | "-region geometry apply options to a portion of the image", |
| 3314 | "-render render vector graphics", |
| 3315 | "-repage geometry size and location of an image canvas", |
| 3316 | "-resample geometry change the resolution of an image", |
| 3317 | "-resize geometry resize the image", |
| 3318 | "-roll geometry roll an image vertically or horizontally", |
| 3319 | "-rotate degrees apply Paeth rotation to the image", |
| 3320 | "-sample geometry scale image with pixel sampling", |
| 3321 | "-scale geometry scale the image", |
| 3322 | "-segment values segment an image", |
| 3323 | "-selective-blur geometry", |
| 3324 | " selectively blur pixels within a contrast threshold", |
| 3325 | "-sepia-tone threshold", |
| 3326 | " simulate a sepia-toned photo", |
| 3327 | "-set property value set an image property", |
| 3328 | "-shade degrees shade the image using a distant light source", |
| 3329 | "-shadow geometry simulate an image shadow", |
| 3330 | "-sharpen geometry sharpen the image", |
| 3331 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3332 | "-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] | 3333 | "-sigmoidal-contrast geometry", |
| 3334 | " increase the contrast without saturating highlights or shadows", |
| 3335 | "-sketch geometry simulate a pencil sketch", |
| 3336 | "-solarize threshold negate all pixels above the threshold level", |
| 3337 | "-sparse-color method args", |
| 3338 | " fill in a image based on a few color points", |
| 3339 | "-splice geometry splice the background color into the image", |
| 3340 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3341 | "-statistic type radius", |
| 3342 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3343 | "-strip strip image of all profiles and comments", |
| 3344 | "-swirl degrees swirl image pixels about the center", |
| 3345 | "-threshold value threshold the image", |
| 3346 | "-thumbnail geometry create a thumbnail of the image", |
| 3347 | "-tile filename tile image when filling a graphic primitive", |
| 3348 | "-tint value tint the image with the fill color", |
| 3349 | "-transform affine transform image", |
| 3350 | "-transparent color make this color transparent within the image", |
| 3351 | "-transpose flip image vertically and rotate 90 degrees", |
| 3352 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3353 | "-trim trim image edges", |
| 3354 | "-type type image type", |
| 3355 | "-unique-colors discard all but one of any pixel color", |
| 3356 | "-unsharp geometry sharpen the image", |
| 3357 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3358 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3359 | "-white-threshold value", |
| 3360 | " force all pixels above the threshold into white", |
| 3361 | (char *) NULL |
| 3362 | }, |
| 3363 | *sequence_operators[]= |
| 3364 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3365 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3366 | "-clut apply a color lookup table to the image", |
| 3367 | "-coalesce merge a sequence of images", |
| 3368 | "-combine combine a sequence of images", |
| 3369 | "-composite composite image", |
| 3370 | "-crop geometry cut out a rectangular region of the image", |
| 3371 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3372 | "-evaluate-sequence operator", |
| 3373 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3374 | "-flatten flatten a sequence of images", |
| 3375 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3376 | "-hald-clut apply a Hald color lookup table to the image", |
| 3377 | "-morph value morph an image sequence", |
| 3378 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3379 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3380 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3381 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3382 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3383 | "-write filename write images to this file", |
| 3384 | (char *) NULL |
| 3385 | }, |
| 3386 | *settings[]= |
| 3387 | { |
| 3388 | "-adjoin join images into a single multi-image file", |
| 3389 | "-affine matrix affine transform matrix", |
| 3390 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3391 | "-antialias remove pixel-aliasing", |
| 3392 | "-authenticate password", |
| 3393 | " decipher image with this password", |
| 3394 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3395 | "-background color background color", |
| 3396 | "-bias value add bias when convolving an image", |
| 3397 | "-black-point-compensation", |
| 3398 | " use black point compensation", |
| 3399 | "-blue-primary point chromaticity blue primary point", |
| 3400 | "-bordercolor color border color", |
| 3401 | "-caption string assign a caption to an image", |
| 3402 | "-channel type apply option to select image channels", |
| 3403 | "-colors value preferred number of colors in the image", |
| 3404 | "-colorspace type alternate image colorspace", |
| 3405 | "-comment string annotate image with comment", |
| 3406 | "-compose operator set image composite operator", |
| 3407 | "-compress type type of pixel compression when writing the image", |
| 3408 | "-define format:option", |
| 3409 | " define one or more image format options", |
| 3410 | "-delay value display the next image after pausing", |
| 3411 | "-density geometry horizontal and vertical density of the image", |
| 3412 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3413 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3414 | "-display server get image or font from this X server", |
| 3415 | "-dispose method layer disposal method", |
| 3416 | "-dither method apply error diffusion to image", |
| 3417 | "-encoding type text encoding type", |
| 3418 | "-endian type endianness (MSB or LSB) of the image", |
| 3419 | "-family name render text with this font family", |
| 3420 | "-fill color color to use when filling a graphic primitive", |
| 3421 | "-filter type use this filter when resizing an image", |
| 3422 | "-font name render text with this font", |
| 3423 | "-format \"string\" output formatted image characteristics", |
| 3424 | "-fuzz distance colors within this distance are considered equal", |
| 3425 | "-gravity type horizontal and vertical text placement", |
| 3426 | "-green-primary point chromaticity green primary point", |
| 3427 | "-intent type type of rendering intent when managing the image color", |
| 3428 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3429 | "-interline-spacing value", |
| 3430 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3431 | "-interpolate method pixel color interpolation method", |
| 3432 | "-interword-spacing value", |
| 3433 | " set the space between two words", |
| 3434 | "-kerning value set the space between two letters", |
| 3435 | "-label string assign a label to an image", |
| 3436 | "-limit type value pixel cache resource limit", |
| 3437 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3438 | "-mask filename associate a mask with the image", |
| 3439 | "-mattecolor color frame color", |
| 3440 | "-monitor monitor progress", |
| 3441 | "-orient type image orientation", |
| 3442 | "-page geometry size and location of an image canvas (setting)", |
| 3443 | "-ping efficiently determine image attributes", |
| 3444 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3445 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3446 | "-preview type image preview type", |
| 3447 | "-quality value JPEG/MIFF/PNG compression level", |
| 3448 | "-quiet suppress all warning messages", |
| 3449 | "-red-primary point chromaticity red primary point", |
| 3450 | "-regard-warnings pay attention to warning messages", |
| 3451 | "-remap filename transform image colors to match this set of colors", |
| 3452 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3453 | "-sampling-factor geometry", |
| 3454 | " horizontal and vertical sampling factor", |
| 3455 | "-scene value image scene number", |
| 3456 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3457 | "-size geometry width and height of image", |
| 3458 | "-stretch type render text with this font stretch", |
| 3459 | "-stroke color graphic primitive stroke color", |
| 3460 | "-strokewidth value graphic primitive stroke width", |
| 3461 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3462 | "-synchronize synchronize image to storage device", |
| 3463 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3464 | "-texture filename name of texture to tile onto the image background", |
| 3465 | "-tile-offset geometry", |
| 3466 | " tile offset", |
| 3467 | "-treedepth value color tree depth", |
| 3468 | "-transparent-color color", |
| 3469 | " transparent color", |
| 3470 | "-undercolor color annotation bounding box color", |
| 3471 | "-units type the units of image resolution", |
| 3472 | "-verbose print detailed information about the image", |
| 3473 | "-view FlashPix viewing transforms", |
| 3474 | "-virtual-pixel method", |
| 3475 | " virtual pixel access method", |
| 3476 | "-weight type render text with this font weight", |
| 3477 | "-white-point point chromaticity white point", |
| 3478 | (char *) NULL |
| 3479 | }, |
| 3480 | *stack_operators[]= |
| 3481 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3482 | "-delete indexes delete the image from the image sequence", |
| 3483 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3484 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3485 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3486 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3487 | "-swap indexes swap two images in the image sequence", |
| 3488 | (char *) NULL |
| 3489 | }; |
| 3490 | |
| 3491 | const char |
| 3492 | **p; |
| 3493 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3494 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3495 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3496 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3497 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3498 | GetClientName()); |
| 3499 | (void) printf("\nImage Settings:\n"); |
| 3500 | for (p=settings; *p != (char *) NULL; p++) |
| 3501 | (void) printf(" %s\n",*p); |
| 3502 | (void) printf("\nImage Operators:\n"); |
| 3503 | for (p=operators; *p != (char *) NULL; p++) |
| 3504 | (void) printf(" %s\n",*p); |
| 3505 | (void) printf("\nImage Sequence Operators:\n"); |
| 3506 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3507 | (void) printf(" %s\n",*p); |
| 3508 | (void) printf("\nImage Stack Operators:\n"); |
| 3509 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3510 | (void) printf(" %s\n",*p); |
| 3511 | (void) printf("\nMiscellaneous Options:\n"); |
| 3512 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3513 | (void) printf(" %s\n",*p); |
| 3514 | (void) printf( |
| 3515 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3516 | (void) printf( |
| 3517 | "number. To specify a particular image format, precede the filename\n"); |
| 3518 | (void) printf( |
| 3519 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3520 | (void) printf( |
| 3521 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3522 | (void) printf("'-' for standard input or output.\n"); |
| 3523 | return(MagickFalse); |
| 3524 | } |
| 3525 | |
| 3526 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3527 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3528 | { |
| 3529 | #define DestroyMogrify() \ |
| 3530 | { \ |
| 3531 | if (format != (char *) NULL) \ |
| 3532 | format=DestroyString(format); \ |
| 3533 | if (path != (char *) NULL) \ |
| 3534 | path=DestroyString(path); \ |
| 3535 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3536 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3537 | argv[i]=DestroyString(argv[i]); \ |
| 3538 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3539 | } |
| 3540 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3541 | { \ |
| 3542 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3543 | option); \ |
| 3544 | DestroyMogrify(); \ |
| 3545 | return(MagickFalse); \ |
| 3546 | } |
| 3547 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3548 | { \ |
| 3549 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3550 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3551 | DestroyMogrify(); \ |
| 3552 | return(MagickFalse); \ |
| 3553 | } |
| 3554 | |
| 3555 | char |
| 3556 | *format, |
| 3557 | *option, |
| 3558 | *path; |
| 3559 | |
| 3560 | Image |
| 3561 | *image; |
| 3562 | |
| 3563 | ImageStack |
| 3564 | image_stack[MaxImageStackDepth+1]; |
| 3565 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3566 | MagickBooleanType |
| 3567 | global_colormap; |
| 3568 | |
| 3569 | MagickBooleanType |
| 3570 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3571 | pend, |
| 3572 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3573 | |
| 3574 | MagickStatusType |
| 3575 | status; |
| 3576 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3577 | register ssize_t |
| 3578 | i; |
| 3579 | |
| 3580 | ssize_t |
| 3581 | j, |
| 3582 | k; |
| 3583 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3584 | /* |
| 3585 | Set defaults. |
| 3586 | */ |
| 3587 | assert(image_info != (ImageInfo *) NULL); |
| 3588 | assert(image_info->signature == MagickSignature); |
| 3589 | if (image_info->debug != MagickFalse) |
| 3590 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3591 | assert(exception != (ExceptionInfo *) NULL); |
| 3592 | if (argc == 2) |
| 3593 | { |
| 3594 | option=argv[1]; |
| 3595 | if ((LocaleCompare("version",option+1) == 0) || |
| 3596 | (LocaleCompare("-version",option+1) == 0)) |
| 3597 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3598 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3599 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 3600 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 3601 | GetMagickCopyright()); |
| 3602 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 3603 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3604 | return(MagickFalse); |
| 3605 | } |
| 3606 | } |
| 3607 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3608 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3609 | format=(char *) NULL; |
| 3610 | path=(char *) NULL; |
| 3611 | global_colormap=MagickFalse; |
| 3612 | k=0; |
| 3613 | j=1; |
| 3614 | NewImageStack(); |
| 3615 | option=(char *) NULL; |
| 3616 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3617 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3618 | status=MagickTrue; |
| 3619 | /* |
| 3620 | Parse command line. |
| 3621 | */ |
| 3622 | ReadCommandlLine(argc,&argv); |
| 3623 | status=ExpandFilenames(&argc,&argv); |
| 3624 | if (status == MagickFalse) |
| 3625 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3626 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3627 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3628 | { |
| 3629 | option=argv[i]; |
| 3630 | if (LocaleCompare(option,"(") == 0) |
| 3631 | { |
| 3632 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3633 | if (k == MaxImageStackDepth) |
| 3634 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3635 | option); |
| 3636 | PushImageStack(); |
| 3637 | continue; |
| 3638 | } |
| 3639 | if (LocaleCompare(option,")") == 0) |
| 3640 | { |
| 3641 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3642 | if (k == 0) |
| 3643 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3644 | PopImageStack(); |
| 3645 | continue; |
| 3646 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3647 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3648 | { |
| 3649 | char |
| 3650 | backup_filename[MaxTextExtent], |
| 3651 | *filename; |
| 3652 | |
| 3653 | Image |
| 3654 | *images; |
| 3655 | |
| 3656 | /* |
| 3657 | Option is a file name: begin by reading image from specified file. |
| 3658 | */ |
| 3659 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3660 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3661 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3662 | filename=argv[++i]; |
| 3663 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 3664 | images=ReadImages(image_info,exception); |
| 3665 | status&=(images != (Image *) NULL) && |
| 3666 | (exception->severity < ErrorException); |
| 3667 | if (images == (Image *) NULL) |
| 3668 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3669 | if (format != (char *) NULL) |
| 3670 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3671 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3672 | if (path != (char *) NULL) |
| 3673 | { |
| 3674 | GetPathComponent(option,TailPath,filename); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3675 | (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3676 | path,*DirectorySeparator,filename); |
| 3677 | } |
| 3678 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3679 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3680 | AppendImageStack(images); |
| 3681 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3682 | if (global_colormap != MagickFalse) |
| 3683 | { |
| 3684 | QuantizeInfo |
| 3685 | *quantize_info; |
| 3686 | |
| 3687 | quantize_info=AcquireQuantizeInfo(image_info); |
| 3688 | (void) RemapImages(quantize_info,images,(Image *) NULL); |
| 3689 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3690 | } |
| 3691 | *backup_filename='\0'; |
| 3692 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3693 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3694 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3695 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3696 | i; |
| 3697 | |
| 3698 | /* |
| 3699 | Rename image file as backup. |
| 3700 | */ |
| 3701 | (void) CopyMagickString(backup_filename,image->filename, |
| 3702 | MaxTextExtent); |
| 3703 | for (i=0; i < 6; i++) |
| 3704 | { |
| 3705 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3706 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3707 | break; |
| 3708 | } |
| 3709 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
| 3710 | (rename(image->filename,backup_filename) != 0)) |
| 3711 | *backup_filename='\0'; |
| 3712 | } |
| 3713 | /* |
| 3714 | Write transmogrified image to disk. |
| 3715 | */ |
| 3716 | image_info->synchronize=MagickTrue; |
| 3717 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3718 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
| 3719 | (void) remove(backup_filename); |
| 3720 | RemoveAllImageStack(); |
| 3721 | continue; |
| 3722 | } |
| 3723 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3724 | switch (*(option+1)) |
| 3725 | { |
| 3726 | case 'a': |
| 3727 | { |
| 3728 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3729 | { |
| 3730 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3731 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3732 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3733 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3734 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3735 | break; |
| 3736 | } |
| 3737 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3738 | { |
| 3739 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3740 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3741 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3742 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3743 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3744 | break; |
| 3745 | } |
| 3746 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3747 | { |
| 3748 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3749 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3750 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3751 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3752 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3753 | break; |
| 3754 | } |
| 3755 | if (LocaleCompare("affine",option+1) == 0) |
| 3756 | { |
| 3757 | if (*option == '+') |
| 3758 | break; |
| 3759 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3760 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3761 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3762 | break; |
| 3763 | } |
| 3764 | if (LocaleCompare("alpha",option+1) == 0) |
| 3765 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3766 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3767 | type; |
| 3768 | |
| 3769 | if (*option == '+') |
| 3770 | break; |
| 3771 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3772 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3773 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3774 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3775 | if (type < 0) |
| 3776 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3777 | argv[i]); |
| 3778 | break; |
| 3779 | } |
| 3780 | if (LocaleCompare("annotate",option+1) == 0) |
| 3781 | { |
| 3782 | if (*option == '+') |
| 3783 | break; |
| 3784 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3785 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3786 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3787 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3788 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3789 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3790 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3791 | i++; |
| 3792 | break; |
| 3793 | } |
| 3794 | if (LocaleCompare("antialias",option+1) == 0) |
| 3795 | break; |
| 3796 | if (LocaleCompare("append",option+1) == 0) |
| 3797 | break; |
| 3798 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3799 | { |
| 3800 | if (*option == '+') |
| 3801 | break; |
| 3802 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3803 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3804 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3805 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3806 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3807 | break; |
| 3808 | } |
| 3809 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3810 | { |
| 3811 | if (*option == '+') |
| 3812 | break; |
| 3813 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3814 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3815 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3816 | break; |
| 3817 | } |
| 3818 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3819 | break; |
| 3820 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3821 | break; |
| 3822 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3823 | break; |
| 3824 | if (LocaleCompare("average",option+1) == 0) |
| 3825 | break; |
| 3826 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3827 | } |
| 3828 | case 'b': |
| 3829 | { |
| 3830 | if (LocaleCompare("background",option+1) == 0) |
| 3831 | { |
| 3832 | if (*option == '+') |
| 3833 | break; |
| 3834 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3835 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3836 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3837 | break; |
| 3838 | } |
| 3839 | if (LocaleCompare("bias",option+1) == 0) |
| 3840 | { |
| 3841 | if (*option == '+') |
| 3842 | break; |
| 3843 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3844 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3845 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3846 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3847 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3848 | break; |
| 3849 | } |
| 3850 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 3851 | break; |
| 3852 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 3853 | { |
| 3854 | if (*option == '+') |
| 3855 | break; |
| 3856 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3857 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3858 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3859 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3860 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3861 | break; |
| 3862 | } |
| 3863 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3864 | { |
| 3865 | if (*option == '+') |
| 3866 | break; |
| 3867 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3868 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3869 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3870 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3871 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3872 | break; |
| 3873 | } |
| 3874 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3875 | { |
| 3876 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3877 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3878 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3879 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3880 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3881 | break; |
| 3882 | } |
| 3883 | if (LocaleCompare("blur",option+1) == 0) |
| 3884 | { |
| 3885 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3886 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3887 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3888 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3889 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3890 | break; |
| 3891 | } |
| 3892 | if (LocaleCompare("border",option+1) == 0) |
| 3893 | { |
| 3894 | if (*option == '+') |
| 3895 | break; |
| 3896 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3897 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3898 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3899 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3900 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3901 | break; |
| 3902 | } |
| 3903 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3904 | { |
| 3905 | if (*option == '+') |
| 3906 | break; |
| 3907 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3908 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3909 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3910 | break; |
| 3911 | } |
| 3912 | if (LocaleCompare("box",option+1) == 0) |
| 3913 | { |
| 3914 | if (*option == '+') |
| 3915 | break; |
| 3916 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3917 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3918 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3919 | break; |
| 3920 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3921 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 3922 | { |
| 3923 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3924 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3925 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3926 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3927 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3928 | break; |
| 3929 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3930 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3931 | } |
| 3932 | case 'c': |
| 3933 | { |
| 3934 | if (LocaleCompare("cache",option+1) == 0) |
| 3935 | { |
| 3936 | if (*option == '+') |
| 3937 | break; |
| 3938 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3939 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3940 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3941 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3942 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3943 | break; |
| 3944 | } |
| 3945 | if (LocaleCompare("caption",option+1) == 0) |
| 3946 | { |
| 3947 | if (*option == '+') |
| 3948 | break; |
| 3949 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3950 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3951 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3952 | break; |
| 3953 | } |
| 3954 | if (LocaleCompare("channel",option+1) == 0) |
| 3955 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3956 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3957 | channel; |
| 3958 | |
| 3959 | if (*option == '+') |
| 3960 | break; |
| 3961 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3962 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3963 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3964 | channel=ParseChannelOption(argv[i]); |
| 3965 | if (channel < 0) |
| 3966 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 3967 | argv[i]); |
| 3968 | break; |
| 3969 | } |
| 3970 | if (LocaleCompare("cdl",option+1) == 0) |
| 3971 | { |
| 3972 | if (*option == '+') |
| 3973 | break; |
| 3974 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3975 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3976 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3977 | break; |
| 3978 | } |
| 3979 | if (LocaleCompare("charcoal",option+1) == 0) |
| 3980 | { |
| 3981 | if (*option == '+') |
| 3982 | break; |
| 3983 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3984 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3985 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3986 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3987 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3988 | break; |
| 3989 | } |
| 3990 | if (LocaleCompare("chop",option+1) == 0) |
| 3991 | { |
| 3992 | if (*option == '+') |
| 3993 | break; |
| 3994 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3995 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3996 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3997 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3998 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3999 | break; |
| 4000 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4001 | if (LocaleCompare("clamp",option+1) == 0) |
| 4002 | break; |
| 4003 | if (LocaleCompare("clip",option+1) == 0) |
| 4004 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4005 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4006 | { |
| 4007 | if (*option == '+') |
| 4008 | break; |
| 4009 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4010 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4011 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4012 | break; |
| 4013 | } |
| 4014 | if (LocaleCompare("clut",option+1) == 0) |
| 4015 | break; |
| 4016 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4017 | break; |
| 4018 | if (LocaleCompare("colorize",option+1) == 0) |
| 4019 | { |
| 4020 | if (*option == '+') |
| 4021 | break; |
| 4022 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4023 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4024 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4025 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4026 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4027 | break; |
| 4028 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4029 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4030 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4031 | KernelInfo |
| 4032 | *kernel_info; |
| 4033 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4034 | if (*option == '+') |
| 4035 | break; |
| 4036 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4037 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4038 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4039 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4040 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4041 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4042 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4043 | break; |
| 4044 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4045 | if (LocaleCompare("colors",option+1) == 0) |
| 4046 | { |
| 4047 | if (*option == '+') |
| 4048 | break; |
| 4049 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4050 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4051 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4052 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4053 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4054 | break; |
| 4055 | } |
| 4056 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4057 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4058 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4059 | colorspace; |
| 4060 | |
| 4061 | if (*option == '+') |
| 4062 | break; |
| 4063 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4064 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4065 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4066 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4067 | argv[i]); |
| 4068 | if (colorspace < 0) |
| 4069 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4070 | argv[i]); |
| 4071 | break; |
| 4072 | } |
| 4073 | if (LocaleCompare("combine",option+1) == 0) |
| 4074 | break; |
| 4075 | if (LocaleCompare("comment",option+1) == 0) |
| 4076 | { |
| 4077 | if (*option == '+') |
| 4078 | break; |
| 4079 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4080 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4081 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4082 | break; |
| 4083 | } |
| 4084 | if (LocaleCompare("composite",option+1) == 0) |
| 4085 | break; |
| 4086 | if (LocaleCompare("compress",option+1) == 0) |
| 4087 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4088 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4089 | compress; |
| 4090 | |
| 4091 | if (*option == '+') |
| 4092 | break; |
| 4093 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4094 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4095 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4096 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4097 | argv[i]); |
| 4098 | if (compress < 0) |
| 4099 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4100 | argv[i]); |
| 4101 | break; |
| 4102 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4103 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4104 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4105 | if (LocaleCompare("contrast",option+1) == 0) |
| 4106 | break; |
| 4107 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4108 | { |
| 4109 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4110 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4111 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4112 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4113 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4114 | break; |
| 4115 | } |
| 4116 | if (LocaleCompare("convolve",option+1) == 0) |
| 4117 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4118 | KernelInfo |
| 4119 | *kernel_info; |
| 4120 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4121 | if (*option == '+') |
| 4122 | break; |
| 4123 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4124 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4125 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4126 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4127 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4128 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4129 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4130 | break; |
| 4131 | } |
| 4132 | if (LocaleCompare("crop",option+1) == 0) |
| 4133 | { |
| 4134 | if (*option == '+') |
| 4135 | break; |
| 4136 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4137 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4138 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4139 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4140 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4141 | break; |
| 4142 | } |
| 4143 | if (LocaleCompare("cycle",option+1) == 0) |
| 4144 | { |
| 4145 | if (*option == '+') |
| 4146 | break; |
| 4147 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4148 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4149 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4150 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4151 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4152 | break; |
| 4153 | } |
| 4154 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4155 | } |
| 4156 | case 'd': |
| 4157 | { |
| 4158 | if (LocaleCompare("decipher",option+1) == 0) |
| 4159 | { |
| 4160 | if (*option == '+') |
| 4161 | break; |
| 4162 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4163 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4164 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4165 | break; |
| 4166 | } |
| 4167 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4168 | break; |
| 4169 | if (LocaleCompare("debug",option+1) == 0) |
| 4170 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4171 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4172 | event; |
| 4173 | |
| 4174 | if (*option == '+') |
| 4175 | break; |
| 4176 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4177 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4178 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4179 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4180 | if (event < 0) |
| 4181 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4182 | argv[i]); |
| 4183 | (void) SetLogEventMask(argv[i]); |
| 4184 | break; |
| 4185 | } |
| 4186 | if (LocaleCompare("define",option+1) == 0) |
| 4187 | { |
| 4188 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4189 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4190 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4191 | if (*option == '+') |
| 4192 | { |
| 4193 | const char |
| 4194 | *define; |
| 4195 | |
| 4196 | define=GetImageOption(image_info,argv[i]); |
| 4197 | if (define == (const char *) NULL) |
| 4198 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4199 | break; |
| 4200 | } |
| 4201 | break; |
| 4202 | } |
| 4203 | if (LocaleCompare("delay",option+1) == 0) |
| 4204 | { |
| 4205 | if (*option == '+') |
| 4206 | break; |
| 4207 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4208 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4209 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4210 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4211 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4212 | break; |
| 4213 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4214 | if (LocaleCompare("delete",option+1) == 0) |
| 4215 | { |
| 4216 | if (*option == '+') |
| 4217 | break; |
| 4218 | i++; |
| 4219 | if (i == (ssize_t) (argc-1)) |
| 4220 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4221 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4222 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4223 | break; |
| 4224 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4225 | if (LocaleCompare("density",option+1) == 0) |
| 4226 | { |
| 4227 | if (*option == '+') |
| 4228 | break; |
| 4229 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4230 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4231 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4232 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4233 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4234 | break; |
| 4235 | } |
| 4236 | if (LocaleCompare("depth",option+1) == 0) |
| 4237 | { |
| 4238 | if (*option == '+') |
| 4239 | break; |
| 4240 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4241 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4242 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4243 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4244 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4245 | break; |
| 4246 | } |
| 4247 | if (LocaleCompare("deskew",option+1) == 0) |
| 4248 | { |
| 4249 | if (*option == '+') |
| 4250 | break; |
| 4251 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4252 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4253 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4254 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4255 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4256 | break; |
| 4257 | } |
| 4258 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4259 | break; |
| 4260 | if (LocaleCompare("dft",option+1) == 0) |
| 4261 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4262 | if (LocaleCompare("direction",option+1) == 0) |
| 4263 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4264 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4265 | direction; |
| 4266 | |
| 4267 | if (*option == '+') |
| 4268 | break; |
| 4269 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4270 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4271 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4272 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4273 | argv[i]); |
| 4274 | if (direction < 0) |
| 4275 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4276 | argv[i]); |
| 4277 | break; |
| 4278 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4279 | if (LocaleCompare("display",option+1) == 0) |
| 4280 | { |
| 4281 | if (*option == '+') |
| 4282 | break; |
| 4283 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4284 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4285 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4286 | break; |
| 4287 | } |
| 4288 | if (LocaleCompare("dispose",option+1) == 0) |
| 4289 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4290 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4291 | dispose; |
| 4292 | |
| 4293 | if (*option == '+') |
| 4294 | break; |
| 4295 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4296 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4297 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4298 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4299 | if (dispose < 0) |
| 4300 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4301 | argv[i]); |
| 4302 | break; |
| 4303 | } |
| 4304 | if (LocaleCompare("distort",option+1) == 0) |
| 4305 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4306 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4307 | op; |
| 4308 | |
| 4309 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4310 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4311 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4312 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4313 | if (op < 0) |
| 4314 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4315 | argv[i]); |
| 4316 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4317 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4318 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4319 | break; |
| 4320 | } |
| 4321 | if (LocaleCompare("dither",option+1) == 0) |
| 4322 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4323 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4324 | method; |
| 4325 | |
| 4326 | if (*option == '+') |
| 4327 | break; |
| 4328 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4329 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4330 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4331 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4332 | if (method < 0) |
| 4333 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4334 | argv[i]); |
| 4335 | break; |
| 4336 | } |
| 4337 | if (LocaleCompare("draw",option+1) == 0) |
| 4338 | { |
| 4339 | if (*option == '+') |
| 4340 | break; |
| 4341 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4342 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4343 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4344 | break; |
| 4345 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4346 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4347 | { |
| 4348 | if (*option == '+') |
| 4349 | break; |
| 4350 | i++; |
| 4351 | if (i == (ssize_t) (argc-1)) |
| 4352 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4353 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4354 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4355 | break; |
| 4356 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4357 | if (LocaleCompare("duration",option+1) == 0) |
| 4358 | { |
| 4359 | if (*option == '+') |
| 4360 | break; |
| 4361 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4362 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4363 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4364 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4365 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4366 | break; |
| 4367 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4368 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4369 | } |
| 4370 | case 'e': |
| 4371 | { |
| 4372 | if (LocaleCompare("edge",option+1) == 0) |
| 4373 | { |
| 4374 | if (*option == '+') |
| 4375 | break; |
| 4376 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4377 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4378 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4379 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4380 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4381 | break; |
| 4382 | } |
| 4383 | if (LocaleCompare("emboss",option+1) == 0) |
| 4384 | { |
| 4385 | if (*option == '+') |
| 4386 | break; |
| 4387 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4388 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4389 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4390 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4391 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4392 | break; |
| 4393 | } |
| 4394 | if (LocaleCompare("encipher",option+1) == 0) |
| 4395 | { |
| 4396 | if (*option == '+') |
| 4397 | break; |
| 4398 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4399 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4400 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4401 | break; |
| 4402 | } |
| 4403 | if (LocaleCompare("encoding",option+1) == 0) |
| 4404 | { |
| 4405 | if (*option == '+') |
| 4406 | break; |
| 4407 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4408 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4409 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4410 | break; |
| 4411 | } |
| 4412 | if (LocaleCompare("endian",option+1) == 0) |
| 4413 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4414 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4415 | endian; |
| 4416 | |
| 4417 | if (*option == '+') |
| 4418 | break; |
| 4419 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4420 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4421 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4422 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4423 | if (endian < 0) |
| 4424 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4425 | argv[i]); |
| 4426 | break; |
| 4427 | } |
| 4428 | if (LocaleCompare("enhance",option+1) == 0) |
| 4429 | break; |
| 4430 | if (LocaleCompare("equalize",option+1) == 0) |
| 4431 | break; |
| 4432 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4433 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4434 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4435 | op; |
| 4436 | |
| 4437 | if (*option == '+') |
| 4438 | break; |
| 4439 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4440 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4441 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4442 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4443 | if (op < 0) |
| 4444 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4445 | argv[i]); |
| 4446 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4447 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4448 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4449 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4450 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4451 | break; |
| 4452 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4453 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4454 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4455 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4456 | op; |
| 4457 | |
| 4458 | if (*option == '+') |
| 4459 | break; |
| 4460 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4461 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4462 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4463 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4464 | if (op < 0) |
| 4465 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4466 | argv[i]); |
| 4467 | break; |
| 4468 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4469 | if (LocaleCompare("extent",option+1) == 0) |
| 4470 | { |
| 4471 | if (*option == '+') |
| 4472 | break; |
| 4473 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4474 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4475 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4476 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4477 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4478 | break; |
| 4479 | } |
| 4480 | if (LocaleCompare("extract",option+1) == 0) |
| 4481 | { |
| 4482 | if (*option == '+') |
| 4483 | break; |
| 4484 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4485 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4486 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4487 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4488 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4489 | break; |
| 4490 | } |
| 4491 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4492 | } |
| 4493 | case 'f': |
| 4494 | { |
| 4495 | if (LocaleCompare("family",option+1) == 0) |
| 4496 | { |
| 4497 | if (*option == '+') |
| 4498 | break; |
| 4499 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4500 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4501 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4502 | break; |
| 4503 | } |
| 4504 | if (LocaleCompare("fill",option+1) == 0) |
| 4505 | { |
| 4506 | if (*option == '+') |
| 4507 | break; |
| 4508 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4509 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4510 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4511 | break; |
| 4512 | } |
| 4513 | if (LocaleCompare("filter",option+1) == 0) |
| 4514 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4515 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4516 | filter; |
| 4517 | |
| 4518 | if (*option == '+') |
| 4519 | break; |
| 4520 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4521 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4522 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4523 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4524 | if (filter < 0) |
| 4525 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4526 | argv[i]); |
| 4527 | break; |
| 4528 | } |
| 4529 | if (LocaleCompare("flatten",option+1) == 0) |
| 4530 | break; |
| 4531 | if (LocaleCompare("flip",option+1) == 0) |
| 4532 | break; |
| 4533 | if (LocaleCompare("flop",option+1) == 0) |
| 4534 | break; |
| 4535 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4536 | { |
| 4537 | if (*option == '+') |
| 4538 | break; |
| 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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4543 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4544 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4545 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4546 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4547 | break; |
| 4548 | } |
| 4549 | if (LocaleCompare("font",option+1) == 0) |
| 4550 | { |
| 4551 | if (*option == '+') |
| 4552 | break; |
| 4553 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4554 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4555 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4556 | break; |
| 4557 | } |
| 4558 | if (LocaleCompare("format",option+1) == 0) |
| 4559 | { |
| 4560 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4561 | (void) CloneString(&format,(char *) NULL); |
| 4562 | if (*option == '+') |
| 4563 | break; |
| 4564 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4565 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4566 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4567 | (void) CloneString(&format,argv[i]); |
| 4568 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4569 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4570 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4571 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4572 | if (*image_info->magick == '\0') |
| 4573 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4574 | format); |
| 4575 | break; |
| 4576 | } |
| 4577 | if (LocaleCompare("frame",option+1) == 0) |
| 4578 | { |
| 4579 | if (*option == '+') |
| 4580 | break; |
| 4581 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4582 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4583 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4584 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4585 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4586 | break; |
| 4587 | } |
| 4588 | if (LocaleCompare("function",option+1) == 0) |
| 4589 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4590 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4591 | op; |
| 4592 | |
| 4593 | if (*option == '+') |
| 4594 | break; |
| 4595 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4596 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4597 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4598 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4599 | if (op < 0) |
| 4600 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4601 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4602 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4603 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4604 | break; |
| 4605 | } |
| 4606 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4607 | { |
| 4608 | if (*option == '+') |
| 4609 | break; |
| 4610 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4611 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4612 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4613 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4614 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4615 | break; |
| 4616 | } |
| 4617 | if (LocaleCompare("fx",option+1) == 0) |
| 4618 | { |
| 4619 | if (*option == '+') |
| 4620 | break; |
| 4621 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4622 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4623 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4624 | break; |
| 4625 | } |
| 4626 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4627 | } |
| 4628 | case 'g': |
| 4629 | { |
| 4630 | if (LocaleCompare("gamma",option+1) == 0) |
| 4631 | { |
| 4632 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4633 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4634 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4635 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4636 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4637 | break; |
| 4638 | } |
| 4639 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4640 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4641 | { |
| 4642 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4643 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4644 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4645 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4646 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4647 | break; |
| 4648 | } |
| 4649 | if (LocaleCompare("geometry",option+1) == 0) |
| 4650 | { |
| 4651 | if (*option == '+') |
| 4652 | break; |
| 4653 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4654 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4655 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4656 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4657 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4658 | break; |
| 4659 | } |
| 4660 | if (LocaleCompare("gravity",option+1) == 0) |
| 4661 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4662 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4663 | gravity; |
| 4664 | |
| 4665 | if (*option == '+') |
| 4666 | break; |
| 4667 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4668 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4669 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4670 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4671 | if (gravity < 0) |
| 4672 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4673 | argv[i]); |
| 4674 | break; |
| 4675 | } |
| 4676 | if (LocaleCompare("green-primary",option+1) == 0) |
| 4677 | { |
| 4678 | if (*option == '+') |
| 4679 | break; |
| 4680 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4681 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4682 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4683 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4684 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4685 | break; |
| 4686 | } |
| 4687 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4688 | } |
| 4689 | case 'h': |
| 4690 | { |
| 4691 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4692 | break; |
| 4693 | if ((LocaleCompare("help",option+1) == 0) || |
| 4694 | (LocaleCompare("-help",option+1) == 0)) |
| 4695 | return(MogrifyUsage()); |
| 4696 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4697 | } |
| 4698 | case 'i': |
| 4699 | { |
| 4700 | if (LocaleCompare("identify",option+1) == 0) |
| 4701 | break; |
| 4702 | if (LocaleCompare("idft",option+1) == 0) |
| 4703 | break; |
| 4704 | if (LocaleCompare("implode",option+1) == 0) |
| 4705 | { |
| 4706 | if (*option == '+') |
| 4707 | break; |
| 4708 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4709 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4710 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4711 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4712 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4713 | break; |
| 4714 | } |
| 4715 | if (LocaleCompare("intent",option+1) == 0) |
| 4716 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4717 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4718 | intent; |
| 4719 | |
| 4720 | if (*option == '+') |
| 4721 | break; |
| 4722 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4723 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4724 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4725 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4726 | if (intent < 0) |
| 4727 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4728 | argv[i]); |
| 4729 | break; |
| 4730 | } |
| 4731 | if (LocaleCompare("interlace",option+1) == 0) |
| 4732 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4733 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4734 | interlace; |
| 4735 | |
| 4736 | if (*option == '+') |
| 4737 | break; |
| 4738 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4739 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4740 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4741 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4742 | argv[i]); |
| 4743 | if (interlace < 0) |
| 4744 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4745 | argv[i]); |
| 4746 | break; |
| 4747 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4748 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4749 | { |
| 4750 | if (*option == '+') |
| 4751 | break; |
| 4752 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4753 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4754 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4755 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4756 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4757 | break; |
| 4758 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4759 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4760 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4761 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4762 | interpolate; |
| 4763 | |
| 4764 | if (*option == '+') |
| 4765 | break; |
| 4766 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4767 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4768 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4769 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4770 | argv[i]); |
| 4771 | if (interpolate < 0) |
| 4772 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4773 | argv[i]); |
| 4774 | break; |
| 4775 | } |
| 4776 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4777 | { |
| 4778 | if (*option == '+') |
| 4779 | break; |
| 4780 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4781 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4782 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4783 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4784 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4785 | break; |
| 4786 | } |
| 4787 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4788 | } |
| 4789 | case 'k': |
| 4790 | { |
| 4791 | if (LocaleCompare("kerning",option+1) == 0) |
| 4792 | { |
| 4793 | if (*option == '+') |
| 4794 | break; |
| 4795 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4796 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4797 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4798 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4799 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4800 | break; |
| 4801 | } |
| 4802 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4803 | } |
| 4804 | case 'l': |
| 4805 | { |
| 4806 | if (LocaleCompare("label",option+1) == 0) |
| 4807 | { |
| 4808 | if (*option == '+') |
| 4809 | break; |
| 4810 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4811 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4812 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4813 | break; |
| 4814 | } |
| 4815 | if (LocaleCompare("lat",option+1) == 0) |
| 4816 | { |
| 4817 | if (*option == '+') |
| 4818 | break; |
| 4819 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4820 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4821 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4822 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4823 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4824 | } |
| 4825 | if (LocaleCompare("layers",option+1) == 0) |
| 4826 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4827 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4828 | type; |
| 4829 | |
| 4830 | if (*option == '+') |
| 4831 | break; |
| 4832 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4833 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4834 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4835 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4836 | if (type < 0) |
| 4837 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4838 | argv[i]); |
| 4839 | break; |
| 4840 | } |
| 4841 | if (LocaleCompare("level",option+1) == 0) |
| 4842 | { |
| 4843 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4844 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4845 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4846 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4847 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4848 | break; |
| 4849 | } |
| 4850 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4851 | { |
| 4852 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4853 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4854 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4855 | break; |
| 4856 | } |
| 4857 | if (LocaleCompare("linewidth",option+1) == 0) |
| 4858 | { |
| 4859 | if (*option == '+') |
| 4860 | break; |
| 4861 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4862 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4863 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4864 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4865 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4866 | break; |
| 4867 | } |
| 4868 | if (LocaleCompare("limit",option+1) == 0) |
| 4869 | { |
| 4870 | char |
| 4871 | *p; |
| 4872 | |
| 4873 | double |
| 4874 | value; |
| 4875 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4876 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4877 | resource; |
| 4878 | |
| 4879 | if (*option == '+') |
| 4880 | break; |
| 4881 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4882 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4883 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4884 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4885 | argv[i]); |
| 4886 | if (resource < 0) |
| 4887 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4888 | argv[i]); |
| 4889 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4890 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4891 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 4892 | value=InterpretLocaleValue(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4893 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4894 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4895 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4896 | break; |
| 4897 | } |
| 4898 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4899 | { |
| 4900 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4901 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4902 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4903 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4904 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4905 | break; |
| 4906 | } |
| 4907 | if (LocaleCompare("list",option+1) == 0) |
| 4908 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4909 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4910 | list; |
| 4911 | |
| 4912 | if (*option == '+') |
| 4913 | break; |
| 4914 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4915 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4916 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4917 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4918 | if (list < 0) |
| 4919 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4920 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4921 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4922 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4923 | } |
| 4924 | if (LocaleCompare("log",option+1) == 0) |
| 4925 | { |
| 4926 | if (*option == '+') |
| 4927 | break; |
| 4928 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4929 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4930 | (strchr(argv[i],'%') == (char *) NULL)) |
| 4931 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4932 | break; |
| 4933 | } |
| 4934 | if (LocaleCompare("loop",option+1) == 0) |
| 4935 | { |
| 4936 | if (*option == '+') |
| 4937 | break; |
| 4938 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4939 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4940 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4941 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4942 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4943 | break; |
| 4944 | } |
| 4945 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4946 | } |
| 4947 | case 'm': |
| 4948 | { |
| 4949 | if (LocaleCompare("map",option+1) == 0) |
| 4950 | { |
| 4951 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 4952 | if (*option == '+') |
| 4953 | break; |
| 4954 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4955 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4956 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4957 | break; |
| 4958 | } |
| 4959 | if (LocaleCompare("mask",option+1) == 0) |
| 4960 | { |
| 4961 | if (*option == '+') |
| 4962 | break; |
| 4963 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4964 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4965 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4966 | break; |
| 4967 | } |
| 4968 | if (LocaleCompare("matte",option+1) == 0) |
| 4969 | break; |
| 4970 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 4971 | { |
| 4972 | if (*option == '+') |
| 4973 | break; |
| 4974 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4975 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4976 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4977 | break; |
| 4978 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 4979 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 4980 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 4981 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 4982 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4983 | if (LocaleCompare("modulate",option+1) == 0) |
| 4984 | { |
| 4985 | if (*option == '+') |
| 4986 | break; |
| 4987 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4988 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4989 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4990 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4991 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4992 | break; |
| 4993 | } |
| 4994 | if (LocaleCompare("median",option+1) == 0) |
| 4995 | { |
| 4996 | if (*option == '+') |
| 4997 | break; |
| 4998 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4999 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5000 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5001 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5002 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5003 | break; |
| 5004 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5005 | if (LocaleCompare("mode",option+1) == 0) |
| 5006 | { |
| 5007 | if (*option == '+') |
| 5008 | break; |
| 5009 | i++; |
| 5010 | if (i == (ssize_t) argc) |
| 5011 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5012 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5013 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5014 | break; |
| 5015 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5016 | if (LocaleCompare("monitor",option+1) == 0) |
| 5017 | break; |
| 5018 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5019 | break; |
| 5020 | if (LocaleCompare("morph",option+1) == 0) |
| 5021 | { |
| 5022 | if (*option == '+') |
| 5023 | break; |
| 5024 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5025 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5026 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5027 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5028 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5029 | break; |
| 5030 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5031 | if (LocaleCompare("morphology",option+1) == 0) |
| 5032 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5033 | char |
| 5034 | token[MaxTextExtent]; |
| 5035 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5036 | KernelInfo |
| 5037 | *kernel_info; |
| 5038 | |
| 5039 | ssize_t |
| 5040 | op; |
| 5041 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5042 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5043 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5044 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5045 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5046 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5047 | if (op < 0) |
| 5048 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5049 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5050 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5051 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5052 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5053 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5054 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5055 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5056 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5057 | break; |
| 5058 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5059 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5060 | break; |
| 5061 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5062 | { |
| 5063 | if (*option == '+') |
| 5064 | break; |
| 5065 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5066 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5067 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5068 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5069 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5070 | break; |
| 5071 | } |
| 5072 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5073 | } |
| 5074 | case 'n': |
| 5075 | { |
| 5076 | if (LocaleCompare("negate",option+1) == 0) |
| 5077 | break; |
| 5078 | if (LocaleCompare("noise",option+1) == 0) |
| 5079 | { |
| 5080 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5081 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5082 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5083 | if (*option == '+') |
| 5084 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5085 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5086 | noise; |
| 5087 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5088 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5089 | if (noise < 0) |
| 5090 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5091 | argv[i]); |
| 5092 | break; |
| 5093 | } |
| 5094 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5095 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5096 | break; |
| 5097 | } |
| 5098 | if (LocaleCompare("noop",option+1) == 0) |
| 5099 | break; |
| 5100 | if (LocaleCompare("normalize",option+1) == 0) |
| 5101 | break; |
| 5102 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5103 | } |
| 5104 | case 'o': |
| 5105 | { |
| 5106 | if (LocaleCompare("opaque",option+1) == 0) |
| 5107 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5108 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5109 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5110 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5111 | break; |
| 5112 | } |
| 5113 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5114 | { |
| 5115 | if (*option == '+') |
| 5116 | break; |
| 5117 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5118 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5119 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5120 | break; |
| 5121 | } |
| 5122 | if (LocaleCompare("orient",option+1) == 0) |
| 5123 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5124 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5125 | orientation; |
| 5126 | |
| 5127 | orientation=UndefinedOrientation; |
| 5128 | if (*option == '+') |
| 5129 | break; |
| 5130 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5131 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5132 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5133 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5134 | argv[i]); |
| 5135 | if (orientation < 0) |
| 5136 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5137 | argv[i]); |
| 5138 | break; |
| 5139 | } |
| 5140 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5141 | } |
| 5142 | case 'p': |
| 5143 | { |
| 5144 | if (LocaleCompare("page",option+1) == 0) |
| 5145 | { |
| 5146 | if (*option == '+') |
| 5147 | break; |
| 5148 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5149 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5150 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5151 | break; |
| 5152 | } |
| 5153 | if (LocaleCompare("paint",option+1) == 0) |
| 5154 | { |
| 5155 | if (*option == '+') |
| 5156 | break; |
| 5157 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5158 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5159 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5160 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5161 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5162 | break; |
| 5163 | } |
| 5164 | if (LocaleCompare("path",option+1) == 0) |
| 5165 | { |
| 5166 | (void) CloneString(&path,(char *) NULL); |
| 5167 | if (*option == '+') |
| 5168 | break; |
| 5169 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5170 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5171 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5172 | (void) CloneString(&path,argv[i]); |
| 5173 | break; |
| 5174 | } |
| 5175 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5176 | { |
| 5177 | if (*option == '+') |
| 5178 | break; |
| 5179 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5180 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5181 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5182 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5183 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5184 | break; |
| 5185 | } |
| 5186 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5187 | { |
| 5188 | if (*option == '+') |
| 5189 | break; |
| 5190 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5191 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5192 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5193 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5194 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5195 | break; |
| 5196 | } |
| 5197 | if (LocaleCompare("posterize",option+1) == 0) |
| 5198 | { |
| 5199 | if (*option == '+') |
| 5200 | break; |
| 5201 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5202 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5203 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5204 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5205 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5206 | break; |
| 5207 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5208 | if (LocaleCompare("precision",option+1) == 0) |
| 5209 | { |
| 5210 | if (*option == '+') |
| 5211 | break; |
| 5212 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5213 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5214 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5215 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5216 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5217 | break; |
| 5218 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5219 | if (LocaleCompare("print",option+1) == 0) |
| 5220 | { |
| 5221 | if (*option == '+') |
| 5222 | break; |
| 5223 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5224 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5225 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5226 | break; |
| 5227 | } |
| 5228 | if (LocaleCompare("process",option+1) == 0) |
| 5229 | { |
| 5230 | if (*option == '+') |
| 5231 | break; |
| 5232 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5233 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5234 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5235 | break; |
| 5236 | } |
| 5237 | if (LocaleCompare("profile",option+1) == 0) |
| 5238 | { |
| 5239 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5240 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5241 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5242 | break; |
| 5243 | } |
| 5244 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5245 | } |
| 5246 | case 'q': |
| 5247 | { |
| 5248 | if (LocaleCompare("quality",option+1) == 0) |
| 5249 | { |
| 5250 | if (*option == '+') |
| 5251 | break; |
| 5252 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5253 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5254 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5255 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5256 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5257 | break; |
| 5258 | } |
| 5259 | if (LocaleCompare("quantize",option+1) == 0) |
| 5260 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5261 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5262 | colorspace; |
| 5263 | |
| 5264 | if (*option == '+') |
| 5265 | break; |
| 5266 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5267 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5268 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5269 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5270 | argv[i]); |
| 5271 | if (colorspace < 0) |
| 5272 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5273 | argv[i]); |
| 5274 | break; |
| 5275 | } |
| 5276 | if (LocaleCompare("quiet",option+1) == 0) |
| 5277 | break; |
| 5278 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5279 | } |
| 5280 | case 'r': |
| 5281 | { |
| 5282 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5283 | { |
| 5284 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5285 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5286 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5287 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5288 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5289 | break; |
| 5290 | } |
| 5291 | if (LocaleCompare("raise",option+1) == 0) |
| 5292 | { |
| 5293 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5294 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5295 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5296 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5297 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5298 | break; |
| 5299 | } |
| 5300 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5301 | { |
| 5302 | if (*option == '+') |
| 5303 | break; |
| 5304 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5305 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5306 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5307 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5308 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5309 | break; |
| 5310 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5311 | if (LocaleCompare("recolor",option+1) == 0) |
| 5312 | { |
| 5313 | if (*option == '+') |
| 5314 | break; |
| 5315 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5316 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5317 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5318 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5319 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5320 | break; |
| 5321 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5322 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5323 | { |
| 5324 | if (*option == '+') |
| 5325 | break; |
| 5326 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5327 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5328 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5329 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5330 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5331 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5332 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5333 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5334 | if (LocaleCompare("region",option+1) == 0) |
| 5335 | { |
| 5336 | if (*option == '+') |
| 5337 | break; |
| 5338 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5339 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5340 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5341 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5342 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5343 | break; |
| 5344 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5345 | if (LocaleCompare("remap",option+1) == 0) |
| 5346 | { |
| 5347 | if (*option == '+') |
| 5348 | break; |
| 5349 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5350 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5351 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5352 | break; |
| 5353 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5354 | if (LocaleCompare("render",option+1) == 0) |
| 5355 | break; |
| 5356 | if (LocaleCompare("repage",option+1) == 0) |
| 5357 | { |
| 5358 | if (*option == '+') |
| 5359 | break; |
| 5360 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5361 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5362 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5363 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5364 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5365 | break; |
| 5366 | } |
| 5367 | if (LocaleCompare("resample",option+1) == 0) |
| 5368 | { |
| 5369 | if (*option == '+') |
| 5370 | break; |
| 5371 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5372 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5373 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5374 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5375 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5376 | break; |
| 5377 | } |
| 5378 | if (LocaleCompare("resize",option+1) == 0) |
| 5379 | { |
| 5380 | if (*option == '+') |
| 5381 | break; |
| 5382 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5383 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5384 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5385 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5386 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5387 | break; |
| 5388 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5389 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5390 | { |
| 5391 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5392 | break; |
| 5393 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5394 | if (LocaleCompare("reverse",option+1) == 0) |
| 5395 | break; |
| 5396 | if (LocaleCompare("roll",option+1) == 0) |
| 5397 | { |
| 5398 | if (*option == '+') |
| 5399 | break; |
| 5400 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5401 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5402 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5403 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5404 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5405 | break; |
| 5406 | } |
| 5407 | if (LocaleCompare("rotate",option+1) == 0) |
| 5408 | { |
| 5409 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5410 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5411 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5412 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5413 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5414 | break; |
| 5415 | } |
| 5416 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5417 | } |
| 5418 | case 's': |
| 5419 | { |
| 5420 | if (LocaleCompare("sample",option+1) == 0) |
| 5421 | { |
| 5422 | if (*option == '+') |
| 5423 | break; |
| 5424 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5425 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5426 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5427 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5428 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5429 | break; |
| 5430 | } |
| 5431 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5432 | { |
| 5433 | if (*option == '+') |
| 5434 | break; |
| 5435 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5436 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5437 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5438 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5439 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5440 | break; |
| 5441 | } |
| 5442 | if (LocaleCompare("scale",option+1) == 0) |
| 5443 | { |
| 5444 | if (*option == '+') |
| 5445 | break; |
| 5446 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5447 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5448 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5449 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5450 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5451 | break; |
| 5452 | } |
| 5453 | if (LocaleCompare("scene",option+1) == 0) |
| 5454 | { |
| 5455 | if (*option == '+') |
| 5456 | break; |
| 5457 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5458 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5459 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5460 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5461 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5462 | break; |
| 5463 | } |
| 5464 | if (LocaleCompare("seed",option+1) == 0) |
| 5465 | { |
| 5466 | if (*option == '+') |
| 5467 | break; |
| 5468 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5469 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5470 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5471 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5472 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5473 | break; |
| 5474 | } |
| 5475 | if (LocaleCompare("segment",option+1) == 0) |
| 5476 | { |
| 5477 | if (*option == '+') |
| 5478 | break; |
| 5479 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5480 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5481 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5482 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5483 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5484 | break; |
| 5485 | } |
| 5486 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5487 | { |
| 5488 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5489 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5490 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5491 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5492 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5493 | break; |
| 5494 | } |
| 5495 | if (LocaleCompare("separate",option+1) == 0) |
| 5496 | break; |
| 5497 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5498 | { |
| 5499 | if (*option == '+') |
| 5500 | break; |
| 5501 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5502 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5503 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5504 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5505 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5506 | break; |
| 5507 | } |
| 5508 | if (LocaleCompare("set",option+1) == 0) |
| 5509 | { |
| 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 | if (*option == '+') |
| 5514 | break; |
| 5515 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5516 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5517 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5518 | break; |
| 5519 | } |
| 5520 | if (LocaleCompare("shade",option+1) == 0) |
| 5521 | { |
| 5522 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5523 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5524 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5525 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5526 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5527 | break; |
| 5528 | } |
| 5529 | if (LocaleCompare("shadow",option+1) == 0) |
| 5530 | { |
| 5531 | if (*option == '+') |
| 5532 | break; |
| 5533 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5534 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5535 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5536 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5537 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5538 | break; |
| 5539 | } |
| 5540 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5541 | { |
| 5542 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5543 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5544 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5545 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5546 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5547 | break; |
| 5548 | } |
| 5549 | if (LocaleCompare("shave",option+1) == 0) |
| 5550 | { |
| 5551 | if (*option == '+') |
| 5552 | break; |
| 5553 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5554 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5555 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5556 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5557 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5558 | break; |
| 5559 | } |
| 5560 | if (LocaleCompare("shear",option+1) == 0) |
| 5561 | { |
| 5562 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5563 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5564 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5565 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5566 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5567 | break; |
| 5568 | } |
| 5569 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5570 | { |
| 5571 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5572 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5573 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5574 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5575 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5576 | break; |
| 5577 | } |
| 5578 | if (LocaleCompare("size",option+1) == 0) |
| 5579 | { |
| 5580 | if (*option == '+') |
| 5581 | break; |
| 5582 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5583 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5584 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5585 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5586 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5587 | break; |
| 5588 | } |
| 5589 | if (LocaleCompare("sketch",option+1) == 0) |
| 5590 | { |
| 5591 | if (*option == '+') |
| 5592 | break; |
| 5593 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5594 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5595 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5596 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5597 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5598 | break; |
| 5599 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5600 | if (LocaleCompare("smush",option+1) == 0) |
| 5601 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5602 | i++; |
| 5603 | if (i == (ssize_t) argc) |
| 5604 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5605 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5606 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5607 | i++; |
| 5608 | break; |
| 5609 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5610 | if (LocaleCompare("solarize",option+1) == 0) |
| 5611 | { |
| 5612 | if (*option == '+') |
| 5613 | break; |
| 5614 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5615 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5616 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5617 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5618 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5619 | break; |
| 5620 | } |
| 5621 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5622 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5623 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5624 | op; |
| 5625 | |
| 5626 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5627 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5628 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5629 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5630 | if (op < 0) |
| 5631 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5632 | argv[i]); |
| 5633 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5634 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5635 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5636 | break; |
| 5637 | } |
| 5638 | if (LocaleCompare("spread",option+1) == 0) |
| 5639 | { |
| 5640 | if (*option == '+') |
| 5641 | break; |
| 5642 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5643 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5644 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5645 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5646 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5647 | break; |
| 5648 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5649 | if (LocaleCompare("statistic",option+1) == 0) |
| 5650 | { |
| 5651 | ssize_t |
| 5652 | op; |
| 5653 | |
| 5654 | if (*option == '+') |
| 5655 | break; |
| 5656 | i++; |
| 5657 | if (i == (ssize_t) argc) |
| 5658 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5659 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5660 | if (op < 0) |
| 5661 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5662 | argv[i]); |
| 5663 | i++; |
| 5664 | if (i == (ssize_t) (argc-1)) |
| 5665 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5666 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5667 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5668 | break; |
| 5669 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5670 | if (LocaleCompare("stretch",option+1) == 0) |
| 5671 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5672 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5673 | stretch; |
| 5674 | |
| 5675 | if (*option == '+') |
| 5676 | break; |
| 5677 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5678 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5679 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5680 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5681 | if (stretch < 0) |
| 5682 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5683 | argv[i]); |
| 5684 | break; |
| 5685 | } |
| 5686 | if (LocaleCompare("strip",option+1) == 0) |
| 5687 | break; |
| 5688 | if (LocaleCompare("stroke",option+1) == 0) |
| 5689 | { |
| 5690 | if (*option == '+') |
| 5691 | break; |
| 5692 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5693 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5694 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5695 | break; |
| 5696 | } |
| 5697 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5698 | { |
| 5699 | if (*option == '+') |
| 5700 | break; |
| 5701 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5702 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5703 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5704 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5705 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5706 | break; |
| 5707 | } |
| 5708 | if (LocaleCompare("style",option+1) == 0) |
| 5709 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5710 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5711 | style; |
| 5712 | |
| 5713 | if (*option == '+') |
| 5714 | break; |
| 5715 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5716 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5717 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5718 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5719 | if (style < 0) |
| 5720 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5721 | argv[i]); |
| 5722 | break; |
| 5723 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5724 | if (LocaleCompare("swap",option+1) == 0) |
| 5725 | { |
| 5726 | if (*option == '+') |
| 5727 | break; |
| 5728 | i++; |
| 5729 | if (i == (ssize_t) (argc-1)) |
| 5730 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5731 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5732 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5733 | break; |
| 5734 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5735 | if (LocaleCompare("swirl",option+1) == 0) |
| 5736 | { |
| 5737 | if (*option == '+') |
| 5738 | break; |
| 5739 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5740 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5741 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5742 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5743 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5744 | break; |
| 5745 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5746 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5747 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5748 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5749 | } |
| 5750 | case 't': |
| 5751 | { |
| 5752 | if (LocaleCompare("taint",option+1) == 0) |
| 5753 | break; |
| 5754 | if (LocaleCompare("texture",option+1) == 0) |
| 5755 | { |
| 5756 | if (*option == '+') |
| 5757 | break; |
| 5758 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5759 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5760 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5761 | break; |
| 5762 | } |
| 5763 | if (LocaleCompare("tile",option+1) == 0) |
| 5764 | { |
| 5765 | if (*option == '+') |
| 5766 | break; |
| 5767 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5768 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5769 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5770 | break; |
| 5771 | } |
| 5772 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5773 | { |
| 5774 | if (*option == '+') |
| 5775 | break; |
| 5776 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5777 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5778 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5779 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5780 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5781 | break; |
| 5782 | } |
| 5783 | if (LocaleCompare("tint",option+1) == 0) |
| 5784 | { |
| 5785 | if (*option == '+') |
| 5786 | break; |
| 5787 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5788 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5789 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5790 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5791 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5792 | break; |
| 5793 | } |
| 5794 | if (LocaleCompare("transform",option+1) == 0) |
| 5795 | break; |
| 5796 | if (LocaleCompare("transpose",option+1) == 0) |
| 5797 | break; |
| 5798 | if (LocaleCompare("transverse",option+1) == 0) |
| 5799 | break; |
| 5800 | if (LocaleCompare("threshold",option+1) == 0) |
| 5801 | { |
| 5802 | if (*option == '+') |
| 5803 | break; |
| 5804 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5805 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5806 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5807 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5808 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5809 | break; |
| 5810 | } |
| 5811 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5812 | { |
| 5813 | if (*option == '+') |
| 5814 | break; |
| 5815 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5816 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5817 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5818 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5819 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5820 | break; |
| 5821 | } |
| 5822 | if (LocaleCompare("transparent",option+1) == 0) |
| 5823 | { |
| 5824 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5825 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5826 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5827 | break; |
| 5828 | } |
| 5829 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 5830 | { |
| 5831 | if (*option == '+') |
| 5832 | break; |
| 5833 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5834 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5835 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5836 | break; |
| 5837 | } |
| 5838 | if (LocaleCompare("treedepth",option+1) == 0) |
| 5839 | { |
| 5840 | if (*option == '+') |
| 5841 | break; |
| 5842 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5843 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5844 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5845 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5846 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5847 | break; |
| 5848 | } |
| 5849 | if (LocaleCompare("trim",option+1) == 0) |
| 5850 | break; |
| 5851 | if (LocaleCompare("type",option+1) == 0) |
| 5852 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5853 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5854 | type; |
| 5855 | |
| 5856 | if (*option == '+') |
| 5857 | break; |
| 5858 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5859 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5860 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5861 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5862 | if (type < 0) |
| 5863 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5864 | argv[i]); |
| 5865 | break; |
| 5866 | } |
| 5867 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5868 | } |
| 5869 | case 'u': |
| 5870 | { |
| 5871 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5872 | { |
| 5873 | if (*option == '+') |
| 5874 | break; |
| 5875 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5876 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5877 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5878 | break; |
| 5879 | } |
| 5880 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5881 | break; |
| 5882 | if (LocaleCompare("units",option+1) == 0) |
| 5883 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5884 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5885 | units; |
| 5886 | |
| 5887 | if (*option == '+') |
| 5888 | break; |
| 5889 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5890 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5891 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5892 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5893 | argv[i]); |
| 5894 | if (units < 0) |
| 5895 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5896 | argv[i]); |
| 5897 | break; |
| 5898 | } |
| 5899 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5900 | { |
| 5901 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5902 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5903 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5904 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5905 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5906 | break; |
| 5907 | } |
| 5908 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5909 | } |
| 5910 | case 'v': |
| 5911 | { |
| 5912 | if (LocaleCompare("verbose",option+1) == 0) |
| 5913 | { |
| 5914 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 5915 | break; |
| 5916 | } |
| 5917 | if ((LocaleCompare("version",option+1) == 0) || |
| 5918 | (LocaleCompare("-version",option+1) == 0)) |
| 5919 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 5920 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5921 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 5922 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 5923 | GetMagickCopyright()); |
| 5924 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 5925 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5926 | break; |
| 5927 | } |
| 5928 | if (LocaleCompare("view",option+1) == 0) |
| 5929 | { |
| 5930 | if (*option == '+') |
| 5931 | break; |
| 5932 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5933 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5934 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5935 | break; |
| 5936 | } |
| 5937 | if (LocaleCompare("vignette",option+1) == 0) |
| 5938 | { |
| 5939 | if (*option == '+') |
| 5940 | break; |
| 5941 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5942 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5943 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5944 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5945 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5946 | break; |
| 5947 | } |
| 5948 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 5949 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5950 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5951 | method; |
| 5952 | |
| 5953 | if (*option == '+') |
| 5954 | break; |
| 5955 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5956 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5957 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5958 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5959 | argv[i]); |
| 5960 | if (method < 0) |
| 5961 | ThrowMogrifyException(OptionError, |
| 5962 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 5963 | break; |
| 5964 | } |
| 5965 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5966 | } |
| 5967 | case 'w': |
| 5968 | { |
| 5969 | if (LocaleCompare("wave",option+1) == 0) |
| 5970 | { |
| 5971 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5972 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5973 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5974 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5975 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5976 | break; |
| 5977 | } |
| 5978 | if (LocaleCompare("weight",option+1) == 0) |
| 5979 | { |
| 5980 | if (*option == '+') |
| 5981 | break; |
| 5982 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5983 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5984 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5985 | break; |
| 5986 | } |
| 5987 | if (LocaleCompare("white-point",option+1) == 0) |
| 5988 | { |
| 5989 | if (*option == '+') |
| 5990 | break; |
| 5991 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5992 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5993 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5994 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5995 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5996 | break; |
| 5997 | } |
| 5998 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 5999 | { |
| 6000 | if (*option == '+') |
| 6001 | break; |
| 6002 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6003 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6004 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6005 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6006 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6007 | break; |
| 6008 | } |
| 6009 | if (LocaleCompare("write",option+1) == 0) |
| 6010 | { |
| 6011 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6012 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6013 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6014 | break; |
| 6015 | } |
| 6016 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6017 | } |
| 6018 | case '?': |
| 6019 | break; |
| 6020 | default: |
| 6021 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6022 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6023 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 6024 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6025 | if (fire != MagickFalse) |
| 6026 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6027 | } |
| 6028 | if (k != 0) |
| 6029 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6030 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6031 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6032 | DestroyMogrify(); |
| 6033 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6034 | } |
| 6035 | |
| 6036 | /* |
| 6037 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6038 | % % |
| 6039 | % % |
| 6040 | % % |
| 6041 | + M o g r i f y I m a g e I n f o % |
| 6042 | % % |
| 6043 | % % |
| 6044 | % % |
| 6045 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6046 | % |
| 6047 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6048 | % prescribed by command line options. |
| 6049 | % |
| 6050 | % The format of the MogrifyImageInfo method is: |
| 6051 | % |
| 6052 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6053 | % const char **argv,ExceptionInfo *exception) |
| 6054 | % |
| 6055 | % A description of each parameter follows: |
| 6056 | % |
| 6057 | % o image_info: the image info.. |
| 6058 | % |
| 6059 | % o argc: Specifies a pointer to an integer describing the number of |
| 6060 | % elements in the argument vector. |
| 6061 | % |
| 6062 | % o argv: Specifies a pointer to a text array containing the command line |
| 6063 | % arguments. |
| 6064 | % |
| 6065 | % o exception: return any errors or warnings in this structure. |
| 6066 | % |
| 6067 | */ |
| 6068 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6069 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6070 | { |
| 6071 | const char |
| 6072 | *option; |
| 6073 | |
| 6074 | GeometryInfo |
| 6075 | geometry_info; |
| 6076 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6077 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6078 | count; |
| 6079 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6080 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6081 | i; |
| 6082 | |
| 6083 | /* |
| 6084 | Initialize method variables. |
| 6085 | */ |
| 6086 | assert(image_info != (ImageInfo *) NULL); |
| 6087 | assert(image_info->signature == MagickSignature); |
| 6088 | if (image_info->debug != MagickFalse) |
| 6089 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6090 | image_info->filename); |
| 6091 | if (argc < 0) |
| 6092 | return(MagickTrue); |
| 6093 | /* |
| 6094 | Set the image settings. |
| 6095 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6096 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6097 | { |
| 6098 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6099 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6100 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6101 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6102 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6103 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6104 | break; |
| 6105 | switch (*(option+1)) |
| 6106 | { |
| 6107 | case 'a': |
| 6108 | { |
| 6109 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6110 | { |
| 6111 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6112 | break; |
| 6113 | } |
| 6114 | if (LocaleCompare("antialias",option+1) == 0) |
| 6115 | { |
| 6116 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6117 | break; |
| 6118 | } |
| 6119 | if (LocaleCompare("attenuate",option+1) == 0) |
| 6120 | { |
| 6121 | if (*option == '+') |
| 6122 | { |
| 6123 | (void) DeleteImageOption(image_info,option+1); |
| 6124 | break; |
| 6125 | } |
| 6126 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6127 | break; |
| 6128 | } |
| 6129 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6130 | { |
| 6131 | if (*option == '+') |
| 6132 | (void) CloneString(&image_info->authenticate,(char *) NULL); |
| 6133 | else |
| 6134 | (void) CloneString(&image_info->authenticate,argv[i+1]); |
| 6135 | break; |
| 6136 | } |
| 6137 | break; |
| 6138 | } |
| 6139 | case 'b': |
| 6140 | { |
| 6141 | if (LocaleCompare("background",option+1) == 0) |
| 6142 | { |
| 6143 | if (*option == '+') |
| 6144 | { |
| 6145 | (void) DeleteImageOption(image_info,option+1); |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6146 | (void) QueryColorDatabase(MogrifyBackgroundColor, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6147 | &image_info->background_color,exception); |
| 6148 | break; |
| 6149 | } |
| 6150 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6151 | (void) QueryColorDatabase(argv[i+1],&image_info->background_color, |
| 6152 | exception); |
| 6153 | break; |
| 6154 | } |
| 6155 | if (LocaleCompare("bias",option+1) == 0) |
| 6156 | { |
| 6157 | if (*option == '+') |
| 6158 | { |
| 6159 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6160 | break; |
| 6161 | } |
| 6162 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6163 | break; |
| 6164 | } |
| 6165 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6166 | { |
| 6167 | if (*option == '+') |
| 6168 | { |
| 6169 | (void) SetImageOption(image_info,option+1,"false"); |
| 6170 | break; |
| 6171 | } |
| 6172 | (void) SetImageOption(image_info,option+1,"true"); |
| 6173 | break; |
| 6174 | } |
| 6175 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6176 | { |
| 6177 | if (*option == '+') |
| 6178 | { |
| 6179 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6180 | break; |
| 6181 | } |
| 6182 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6183 | break; |
| 6184 | } |
| 6185 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6186 | { |
| 6187 | if (*option == '+') |
| 6188 | { |
| 6189 | (void) DeleteImageOption(image_info,option+1); |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6190 | (void) QueryColorDatabase(MogrifyBorderColor, |
| 6191 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6192 | break; |
| 6193 | } |
| 6194 | (void) QueryColorDatabase(argv[i+1],&image_info->border_color, |
| 6195 | exception); |
| 6196 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6197 | break; |
| 6198 | } |
| 6199 | if (LocaleCompare("box",option+1) == 0) |
| 6200 | { |
| 6201 | if (*option == '+') |
| 6202 | { |
| 6203 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6204 | break; |
| 6205 | } |
| 6206 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6207 | break; |
| 6208 | } |
| 6209 | break; |
| 6210 | } |
| 6211 | case 'c': |
| 6212 | { |
| 6213 | if (LocaleCompare("cache",option+1) == 0) |
| 6214 | { |
| 6215 | MagickSizeType |
| 6216 | limit; |
| 6217 | |
| 6218 | limit=MagickResourceInfinity; |
| 6219 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6220 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6221 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6222 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6223 | break; |
| 6224 | } |
| 6225 | if (LocaleCompare("caption",option+1) == 0) |
| 6226 | { |
| 6227 | if (*option == '+') |
| 6228 | { |
| 6229 | (void) DeleteImageOption(image_info,option+1); |
| 6230 | break; |
| 6231 | } |
| 6232 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6233 | break; |
| 6234 | } |
| 6235 | if (LocaleCompare("channel",option+1) == 0) |
| 6236 | { |
| 6237 | if (*option == '+') |
| 6238 | { |
| 6239 | image_info->channel=DefaultChannels; |
| 6240 | break; |
| 6241 | } |
| 6242 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6243 | break; |
| 6244 | } |
| 6245 | if (LocaleCompare("colors",option+1) == 0) |
| 6246 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6247 | image_info->colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6248 | break; |
| 6249 | } |
| 6250 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6251 | { |
| 6252 | if (*option == '+') |
| 6253 | { |
| 6254 | image_info->colorspace=UndefinedColorspace; |
| 6255 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6256 | break; |
| 6257 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6258 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6259 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6260 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6261 | break; |
| 6262 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6263 | if (LocaleCompare("comment",option+1) == 0) |
| 6264 | { |
| 6265 | if (*option == '+') |
| 6266 | { |
| 6267 | (void) DeleteImageOption(image_info,option+1); |
| 6268 | break; |
| 6269 | } |
| 6270 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6271 | break; |
| 6272 | } |
| 6273 | if (LocaleCompare("compose",option+1) == 0) |
| 6274 | { |
| 6275 | if (*option == '+') |
| 6276 | { |
| 6277 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6278 | break; |
| 6279 | } |
| 6280 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6281 | break; |
| 6282 | } |
| 6283 | if (LocaleCompare("compress",option+1) == 0) |
| 6284 | { |
| 6285 | if (*option == '+') |
| 6286 | { |
| 6287 | image_info->compression=UndefinedCompression; |
| 6288 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6289 | break; |
| 6290 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6291 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6292 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6293 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6294 | break; |
| 6295 | } |
| 6296 | break; |
| 6297 | } |
| 6298 | case 'd': |
| 6299 | { |
| 6300 | if (LocaleCompare("debug",option+1) == 0) |
| 6301 | { |
| 6302 | if (*option == '+') |
| 6303 | (void) SetLogEventMask("none"); |
| 6304 | else |
| 6305 | (void) SetLogEventMask(argv[i+1]); |
| 6306 | image_info->debug=IsEventLogging(); |
| 6307 | break; |
| 6308 | } |
| 6309 | if (LocaleCompare("define",option+1) == 0) |
| 6310 | { |
| 6311 | if (*option == '+') |
| 6312 | { |
| 6313 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6314 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6315 | else |
| 6316 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6317 | break; |
| 6318 | } |
| 6319 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6320 | { |
| 6321 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6322 | exception); |
| 6323 | break; |
| 6324 | } |
| 6325 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6326 | break; |
| 6327 | } |
| 6328 | if (LocaleCompare("delay",option+1) == 0) |
| 6329 | { |
| 6330 | if (*option == '+') |
| 6331 | { |
| 6332 | (void) SetImageOption(image_info,option+1,"0"); |
| 6333 | break; |
| 6334 | } |
| 6335 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6336 | break; |
| 6337 | } |
| 6338 | if (LocaleCompare("density",option+1) == 0) |
| 6339 | { |
| 6340 | /* |
| 6341 | Set image density. |
| 6342 | */ |
| 6343 | if (*option == '+') |
| 6344 | { |
| 6345 | if (image_info->density != (char *) NULL) |
| 6346 | image_info->density=DestroyString(image_info->density); |
| 6347 | (void) SetImageOption(image_info,option+1,"72"); |
| 6348 | break; |
| 6349 | } |
| 6350 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6351 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6352 | break; |
| 6353 | } |
| 6354 | if (LocaleCompare("depth",option+1) == 0) |
| 6355 | { |
| 6356 | if (*option == '+') |
| 6357 | { |
| 6358 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6359 | break; |
| 6360 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6361 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6362 | break; |
| 6363 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6364 | if (LocaleCompare("direction",option+1) == 0) |
| 6365 | { |
| 6366 | if (*option == '+') |
| 6367 | { |
| 6368 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6369 | break; |
| 6370 | } |
| 6371 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6372 | break; |
| 6373 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6374 | if (LocaleCompare("display",option+1) == 0) |
| 6375 | { |
| 6376 | if (*option == '+') |
| 6377 | { |
| 6378 | if (image_info->server_name != (char *) NULL) |
| 6379 | image_info->server_name=DestroyString( |
| 6380 | image_info->server_name); |
| 6381 | break; |
| 6382 | } |
| 6383 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6384 | break; |
| 6385 | } |
| 6386 | if (LocaleCompare("dispose",option+1) == 0) |
| 6387 | { |
| 6388 | if (*option == '+') |
| 6389 | { |
| 6390 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6391 | break; |
| 6392 | } |
| 6393 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6394 | break; |
| 6395 | } |
| 6396 | if (LocaleCompare("dither",option+1) == 0) |
| 6397 | { |
| 6398 | if (*option == '+') |
| 6399 | { |
| 6400 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6401 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6402 | break; |
| 6403 | } |
| 6404 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6405 | image_info->dither=MagickTrue; |
| 6406 | break; |
| 6407 | } |
| 6408 | break; |
| 6409 | } |
| 6410 | case 'e': |
| 6411 | { |
| 6412 | if (LocaleCompare("encoding",option+1) == 0) |
| 6413 | { |
| 6414 | if (*option == '+') |
| 6415 | { |
| 6416 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6417 | break; |
| 6418 | } |
| 6419 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6420 | break; |
| 6421 | } |
| 6422 | if (LocaleCompare("endian",option+1) == 0) |
| 6423 | { |
| 6424 | if (*option == '+') |
| 6425 | { |
| 6426 | image_info->endian=UndefinedEndian; |
| 6427 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6428 | break; |
| 6429 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6430 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6431 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6432 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6433 | break; |
| 6434 | } |
| 6435 | if (LocaleCompare("extract",option+1) == 0) |
| 6436 | { |
| 6437 | /* |
| 6438 | Set image extract geometry. |
| 6439 | */ |
| 6440 | if (*option == '+') |
| 6441 | { |
| 6442 | if (image_info->extract != (char *) NULL) |
| 6443 | image_info->extract=DestroyString(image_info->extract); |
| 6444 | break; |
| 6445 | } |
| 6446 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6447 | break; |
| 6448 | } |
| 6449 | break; |
| 6450 | } |
| 6451 | case 'f': |
| 6452 | { |
| 6453 | if (LocaleCompare("fill",option+1) == 0) |
| 6454 | { |
| 6455 | if (*option == '+') |
| 6456 | { |
| 6457 | (void) SetImageOption(image_info,option+1,"none"); |
| 6458 | break; |
| 6459 | } |
| 6460 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6461 | break; |
| 6462 | } |
| 6463 | if (LocaleCompare("filter",option+1) == 0) |
| 6464 | { |
| 6465 | if (*option == '+') |
| 6466 | { |
| 6467 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6468 | break; |
| 6469 | } |
| 6470 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6471 | break; |
| 6472 | } |
| 6473 | if (LocaleCompare("font",option+1) == 0) |
| 6474 | { |
| 6475 | if (*option == '+') |
| 6476 | { |
| 6477 | if (image_info->font != (char *) NULL) |
| 6478 | image_info->font=DestroyString(image_info->font); |
| 6479 | break; |
| 6480 | } |
| 6481 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6482 | break; |
| 6483 | } |
| 6484 | if (LocaleCompare("format",option+1) == 0) |
| 6485 | { |
| 6486 | register const char |
| 6487 | *q; |
| 6488 | |
| 6489 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6490 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6491 | image_info->ping=MagickFalse; |
| 6492 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6493 | break; |
| 6494 | } |
| 6495 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6496 | { |
| 6497 | if (*option == '+') |
| 6498 | { |
| 6499 | image_info->fuzz=0.0; |
| 6500 | (void) SetImageOption(image_info,option+1,"0"); |
| 6501 | break; |
| 6502 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6503 | image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6504 | 1.0); |
| 6505 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6506 | break; |
| 6507 | } |
| 6508 | break; |
| 6509 | } |
| 6510 | case 'g': |
| 6511 | { |
| 6512 | if (LocaleCompare("gravity",option+1) == 0) |
| 6513 | { |
| 6514 | if (*option == '+') |
| 6515 | { |
| 6516 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6517 | break; |
| 6518 | } |
| 6519 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6520 | break; |
| 6521 | } |
| 6522 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6523 | { |
| 6524 | if (*option == '+') |
| 6525 | { |
| 6526 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6527 | break; |
| 6528 | } |
| 6529 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6530 | break; |
| 6531 | } |
| 6532 | break; |
| 6533 | } |
| 6534 | case 'i': |
| 6535 | { |
| 6536 | if (LocaleCompare("intent",option+1) == 0) |
| 6537 | { |
| 6538 | if (*option == '+') |
| 6539 | { |
| 6540 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6541 | break; |
| 6542 | } |
| 6543 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6544 | break; |
| 6545 | } |
| 6546 | if (LocaleCompare("interlace",option+1) == 0) |
| 6547 | { |
| 6548 | if (*option == '+') |
| 6549 | { |
| 6550 | image_info->interlace=UndefinedInterlace; |
| 6551 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6552 | break; |
| 6553 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6554 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6555 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6556 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6557 | break; |
| 6558 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6559 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6560 | { |
| 6561 | if (*option == '+') |
| 6562 | { |
| 6563 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6564 | break; |
| 6565 | } |
| 6566 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6567 | break; |
| 6568 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6569 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6570 | { |
| 6571 | if (*option == '+') |
| 6572 | { |
| 6573 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6574 | break; |
| 6575 | } |
| 6576 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6577 | break; |
| 6578 | } |
| 6579 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6580 | { |
| 6581 | if (*option == '+') |
| 6582 | { |
| 6583 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6584 | break; |
| 6585 | } |
| 6586 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6587 | break; |
| 6588 | } |
| 6589 | break; |
| 6590 | } |
| 6591 | case 'k': |
| 6592 | { |
| 6593 | if (LocaleCompare("kerning",option+1) == 0) |
| 6594 | { |
| 6595 | if (*option == '+') |
| 6596 | { |
| 6597 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6598 | break; |
| 6599 | } |
| 6600 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6601 | break; |
| 6602 | } |
| 6603 | break; |
| 6604 | } |
| 6605 | case 'l': |
| 6606 | { |
| 6607 | if (LocaleCompare("label",option+1) == 0) |
| 6608 | { |
| 6609 | if (*option == '+') |
| 6610 | { |
| 6611 | (void) DeleteImageOption(image_info,option+1); |
| 6612 | break; |
| 6613 | } |
| 6614 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6615 | break; |
| 6616 | } |
| 6617 | if (LocaleCompare("limit",option+1) == 0) |
| 6618 | { |
| 6619 | MagickSizeType |
| 6620 | limit; |
| 6621 | |
| 6622 | ResourceType |
| 6623 | type; |
| 6624 | |
| 6625 | if (*option == '+') |
| 6626 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6627 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6628 | MagickFalse,argv[i+1]); |
| 6629 | limit=MagickResourceInfinity; |
| 6630 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6631 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6632 | (void) SetMagickResourceLimit(type,limit); |
| 6633 | break; |
| 6634 | } |
| 6635 | if (LocaleCompare("list",option+1) == 0) |
| 6636 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6637 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6638 | list; |
| 6639 | |
| 6640 | /* |
| 6641 | Display configuration list. |
| 6642 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6643 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6644 | switch (list) |
| 6645 | { |
| 6646 | case MagickCoderOptions: |
| 6647 | { |
| 6648 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6649 | break; |
| 6650 | } |
| 6651 | case MagickColorOptions: |
| 6652 | { |
| 6653 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6654 | break; |
| 6655 | } |
| 6656 | case MagickConfigureOptions: |
| 6657 | { |
| 6658 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6659 | break; |
| 6660 | } |
| 6661 | case MagickDelegateOptions: |
| 6662 | { |
| 6663 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6664 | break; |
| 6665 | } |
| 6666 | case MagickFontOptions: |
| 6667 | { |
| 6668 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6669 | break; |
| 6670 | } |
| 6671 | case MagickFormatOptions: |
| 6672 | { |
| 6673 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6674 | break; |
| 6675 | } |
| 6676 | case MagickLocaleOptions: |
| 6677 | { |
| 6678 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6679 | break; |
| 6680 | } |
| 6681 | case MagickLogOptions: |
| 6682 | { |
| 6683 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6684 | break; |
| 6685 | } |
| 6686 | case MagickMagicOptions: |
| 6687 | { |
| 6688 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6689 | break; |
| 6690 | } |
| 6691 | case MagickMimeOptions: |
| 6692 | { |
| 6693 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6694 | break; |
| 6695 | } |
| 6696 | case MagickModuleOptions: |
| 6697 | { |
| 6698 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6699 | break; |
| 6700 | } |
| 6701 | case MagickPolicyOptions: |
| 6702 | { |
| 6703 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6704 | break; |
| 6705 | } |
| 6706 | case MagickResourceOptions: |
| 6707 | { |
| 6708 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6709 | break; |
| 6710 | } |
| 6711 | case MagickThresholdOptions: |
| 6712 | { |
| 6713 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6714 | break; |
| 6715 | } |
| 6716 | default: |
| 6717 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6718 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6719 | exception); |
| 6720 | break; |
| 6721 | } |
| 6722 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6723 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6724 | } |
| 6725 | if (LocaleCompare("log",option+1) == 0) |
| 6726 | { |
| 6727 | if (*option == '+') |
| 6728 | break; |
| 6729 | (void) SetLogFormat(argv[i+1]); |
| 6730 | break; |
| 6731 | } |
| 6732 | if (LocaleCompare("loop",option+1) == 0) |
| 6733 | { |
| 6734 | if (*option == '+') |
| 6735 | { |
| 6736 | (void) SetImageOption(image_info,option+1,"0"); |
| 6737 | break; |
| 6738 | } |
| 6739 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6740 | break; |
| 6741 | } |
| 6742 | break; |
| 6743 | } |
| 6744 | case 'm': |
| 6745 | { |
| 6746 | if (LocaleCompare("matte",option+1) == 0) |
| 6747 | { |
| 6748 | if (*option == '+') |
| 6749 | { |
| 6750 | (void) SetImageOption(image_info,option+1,"false"); |
| 6751 | break; |
| 6752 | } |
| 6753 | (void) SetImageOption(image_info,option+1,"true"); |
| 6754 | break; |
| 6755 | } |
| 6756 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6757 | { |
| 6758 | if (*option == '+') |
| 6759 | { |
| 6760 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6761 | (void) QueryColorDatabase(MogrifyMatteColor, |
| 6762 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6763 | break; |
| 6764 | } |
| 6765 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6766 | (void) QueryColorDatabase(argv[i+1],&image_info->matte_color, |
| 6767 | exception); |
| 6768 | break; |
| 6769 | } |
| 6770 | if (LocaleCompare("monitor",option+1) == 0) |
| 6771 | { |
| 6772 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6773 | (void *) NULL); |
| 6774 | break; |
| 6775 | } |
| 6776 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6777 | { |
| 6778 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6779 | break; |
| 6780 | } |
| 6781 | break; |
| 6782 | } |
| 6783 | case 'o': |
| 6784 | { |
| 6785 | if (LocaleCompare("orient",option+1) == 0) |
| 6786 | { |
| 6787 | if (*option == '+') |
| 6788 | { |
| 6789 | image_info->orientation=UndefinedOrientation; |
| 6790 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6791 | break; |
| 6792 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6793 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6794 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6795 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6796 | break; |
| 6797 | } |
| 6798 | } |
| 6799 | case 'p': |
| 6800 | { |
| 6801 | if (LocaleCompare("page",option+1) == 0) |
| 6802 | { |
| 6803 | char |
| 6804 | *canonical_page, |
| 6805 | page[MaxTextExtent]; |
| 6806 | |
| 6807 | const char |
| 6808 | *image_option; |
| 6809 | |
| 6810 | MagickStatusType |
| 6811 | flags; |
| 6812 | |
| 6813 | RectangleInfo |
| 6814 | geometry; |
| 6815 | |
| 6816 | if (*option == '+') |
| 6817 | { |
| 6818 | (void) DeleteImageOption(image_info,option+1); |
| 6819 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6820 | break; |
| 6821 | } |
| 6822 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6823 | image_option=GetImageOption(image_info,"page"); |
| 6824 | if (image_option != (const char *) NULL) |
| 6825 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6826 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6827 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6828 | canonical_page=DestroyString(canonical_page); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6829 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6830 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6831 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6832 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6833 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6834 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6835 | (void) SetImageOption(image_info,option+1,page); |
| 6836 | (void) CloneString(&image_info->page,page); |
| 6837 | break; |
| 6838 | } |
| 6839 | if (LocaleCompare("pen",option+1) == 0) |
| 6840 | { |
| 6841 | if (*option == '+') |
| 6842 | { |
| 6843 | (void) SetImageOption(image_info,option+1,"none"); |
| 6844 | break; |
| 6845 | } |
| 6846 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6847 | break; |
| 6848 | } |
| 6849 | if (LocaleCompare("ping",option+1) == 0) |
| 6850 | { |
| 6851 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6852 | break; |
| 6853 | } |
| 6854 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6855 | { |
| 6856 | if (*option == '+') |
| 6857 | geometry_info.rho=0.0; |
| 6858 | else |
| 6859 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6860 | image_info->pointsize=geometry_info.rho; |
| 6861 | break; |
| 6862 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6863 | if (LocaleCompare("precision",option+1) == 0) |
| 6864 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6865 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6866 | break; |
| 6867 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6868 | if (LocaleCompare("preview",option+1) == 0) |
| 6869 | { |
| 6870 | /* |
| 6871 | Preview image. |
| 6872 | */ |
| 6873 | if (*option == '+') |
| 6874 | { |
| 6875 | image_info->preview_type=UndefinedPreview; |
| 6876 | break; |
| 6877 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6878 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6879 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6880 | break; |
| 6881 | } |
| 6882 | break; |
| 6883 | } |
| 6884 | case 'q': |
| 6885 | { |
| 6886 | if (LocaleCompare("quality",option+1) == 0) |
| 6887 | { |
| 6888 | /* |
| 6889 | Set image compression quality. |
| 6890 | */ |
| 6891 | if (*option == '+') |
| 6892 | { |
| 6893 | image_info->quality=UndefinedCompressionQuality; |
| 6894 | (void) SetImageOption(image_info,option+1,"0"); |
| 6895 | break; |
| 6896 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6897 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6898 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6899 | break; |
| 6900 | } |
| 6901 | if (LocaleCompare("quiet",option+1) == 0) |
| 6902 | { |
| 6903 | static WarningHandler |
| 6904 | warning_handler = (WarningHandler) NULL; |
| 6905 | |
| 6906 | if (*option == '+') |
| 6907 | { |
| 6908 | /* |
| 6909 | Restore error or warning messages. |
| 6910 | */ |
| 6911 | warning_handler=SetWarningHandler(warning_handler); |
| 6912 | break; |
| 6913 | } |
| 6914 | /* |
| 6915 | Suppress error or warning messages. |
| 6916 | */ |
| 6917 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6918 | break; |
| 6919 | } |
| 6920 | break; |
| 6921 | } |
| 6922 | case 'r': |
| 6923 | { |
| 6924 | if (LocaleCompare("red-primary",option+1) == 0) |
| 6925 | { |
| 6926 | if (*option == '+') |
| 6927 | { |
| 6928 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6929 | break; |
| 6930 | } |
| 6931 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6932 | break; |
| 6933 | } |
| 6934 | break; |
| 6935 | } |
| 6936 | case 's': |
| 6937 | { |
| 6938 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 6939 | { |
| 6940 | /* |
| 6941 | Set image sampling factor. |
| 6942 | */ |
| 6943 | if (*option == '+') |
| 6944 | { |
| 6945 | if (image_info->sampling_factor != (char *) NULL) |
| 6946 | image_info->sampling_factor=DestroyString( |
| 6947 | image_info->sampling_factor); |
| 6948 | break; |
| 6949 | } |
| 6950 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 6951 | break; |
| 6952 | } |
| 6953 | if (LocaleCompare("scene",option+1) == 0) |
| 6954 | { |
| 6955 | /* |
| 6956 | Set image scene. |
| 6957 | */ |
| 6958 | if (*option == '+') |
| 6959 | { |
| 6960 | image_info->scene=0; |
| 6961 | (void) SetImageOption(image_info,option+1,"0"); |
| 6962 | break; |
| 6963 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6964 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6965 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6966 | break; |
| 6967 | } |
| 6968 | if (LocaleCompare("seed",option+1) == 0) |
| 6969 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6970 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6971 | seed; |
| 6972 | |
| 6973 | if (*option == '+') |
| 6974 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6975 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6976 | SeedPseudoRandomGenerator(seed); |
| 6977 | break; |
| 6978 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6979 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6980 | SeedPseudoRandomGenerator(seed); |
| 6981 | break; |
| 6982 | } |
| 6983 | if (LocaleCompare("size",option+1) == 0) |
| 6984 | { |
| 6985 | if (*option == '+') |
| 6986 | { |
| 6987 | if (image_info->size != (char *) NULL) |
| 6988 | image_info->size=DestroyString(image_info->size); |
| 6989 | break; |
| 6990 | } |
| 6991 | (void) CloneString(&image_info->size,argv[i+1]); |
| 6992 | break; |
| 6993 | } |
| 6994 | if (LocaleCompare("stroke",option+1) == 0) |
| 6995 | { |
| 6996 | if (*option == '+') |
| 6997 | { |
| 6998 | (void) SetImageOption(image_info,option+1,"none"); |
| 6999 | break; |
| 7000 | } |
| 7001 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7002 | break; |
| 7003 | } |
| 7004 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7005 | { |
| 7006 | if (*option == '+') |
| 7007 | { |
| 7008 | (void) SetImageOption(image_info,option+1,"0"); |
| 7009 | break; |
| 7010 | } |
| 7011 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7012 | break; |
| 7013 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7014 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7015 | { |
| 7016 | if (*option == '+') |
| 7017 | { |
| 7018 | image_info->synchronize=MagickFalse; |
| 7019 | break; |
| 7020 | } |
| 7021 | image_info->synchronize=MagickTrue; |
| 7022 | break; |
| 7023 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7024 | break; |
| 7025 | } |
| 7026 | case 't': |
| 7027 | { |
| 7028 | if (LocaleCompare("taint",option+1) == 0) |
| 7029 | { |
| 7030 | if (*option == '+') |
| 7031 | { |
| 7032 | (void) SetImageOption(image_info,option+1,"false"); |
| 7033 | break; |
| 7034 | } |
| 7035 | (void) SetImageOption(image_info,option+1,"true"); |
| 7036 | break; |
| 7037 | } |
| 7038 | if (LocaleCompare("texture",option+1) == 0) |
| 7039 | { |
| 7040 | if (*option == '+') |
| 7041 | { |
| 7042 | if (image_info->texture != (char *) NULL) |
| 7043 | image_info->texture=DestroyString(image_info->texture); |
| 7044 | break; |
| 7045 | } |
| 7046 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7047 | break; |
| 7048 | } |
| 7049 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7050 | { |
| 7051 | if (*option == '+') |
| 7052 | { |
| 7053 | (void) SetImageOption(image_info,option+1,"0"); |
| 7054 | break; |
| 7055 | } |
| 7056 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7057 | break; |
| 7058 | } |
| 7059 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7060 | { |
| 7061 | if (*option == '+') |
| 7062 | { |
| 7063 | (void) QueryColorDatabase("none",&image_info->transparent_color, exception); |
| 7064 | (void) SetImageOption(image_info,option+1,"none"); |
| 7065 | break; |
| 7066 | } |
| 7067 | (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color, |
| 7068 | exception); |
| 7069 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7070 | break; |
| 7071 | } |
| 7072 | if (LocaleCompare("type",option+1) == 0) |
| 7073 | { |
| 7074 | if (*option == '+') |
| 7075 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7076 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7077 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7078 | break; |
| 7079 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7080 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7081 | MagickFalse,argv[i+1]); |
| 7082 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7083 | break; |
| 7084 | } |
| 7085 | break; |
| 7086 | } |
| 7087 | case 'u': |
| 7088 | { |
| 7089 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7090 | { |
| 7091 | if (*option == '+') |
| 7092 | { |
| 7093 | (void) DeleteImageOption(image_info,option+1); |
| 7094 | break; |
| 7095 | } |
| 7096 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7097 | break; |
| 7098 | } |
| 7099 | if (LocaleCompare("units",option+1) == 0) |
| 7100 | { |
| 7101 | if (*option == '+') |
| 7102 | { |
| 7103 | image_info->units=UndefinedResolution; |
| 7104 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7105 | break; |
| 7106 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7107 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7108 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7109 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7110 | break; |
| 7111 | } |
| 7112 | break; |
| 7113 | } |
| 7114 | case 'v': |
| 7115 | { |
| 7116 | if (LocaleCompare("verbose",option+1) == 0) |
| 7117 | { |
| 7118 | if (*option == '+') |
| 7119 | { |
| 7120 | image_info->verbose=MagickFalse; |
| 7121 | break; |
| 7122 | } |
| 7123 | image_info->verbose=MagickTrue; |
| 7124 | image_info->ping=MagickFalse; |
| 7125 | break; |
| 7126 | } |
| 7127 | if (LocaleCompare("view",option+1) == 0) |
| 7128 | { |
| 7129 | if (*option == '+') |
| 7130 | { |
| 7131 | if (image_info->view != (char *) NULL) |
| 7132 | image_info->view=DestroyString(image_info->view); |
| 7133 | break; |
| 7134 | } |
| 7135 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7136 | break; |
| 7137 | } |
| 7138 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7139 | { |
| 7140 | if (*option == '+') |
| 7141 | { |
| 7142 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7143 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7144 | break; |
| 7145 | } |
| 7146 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7147 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7148 | argv[i+1]); |
| 7149 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7150 | break; |
| 7151 | } |
| 7152 | break; |
| 7153 | } |
| 7154 | case 'w': |
| 7155 | { |
| 7156 | if (LocaleCompare("white-point",option+1) == 0) |
| 7157 | { |
| 7158 | if (*option == '+') |
| 7159 | { |
| 7160 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7161 | break; |
| 7162 | } |
| 7163 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7164 | break; |
| 7165 | } |
| 7166 | break; |
| 7167 | } |
| 7168 | default: |
| 7169 | break; |
| 7170 | } |
| 7171 | i+=count; |
| 7172 | } |
| 7173 | return(MagickTrue); |
| 7174 | } |
| 7175 | |
| 7176 | /* |
| 7177 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7178 | % % |
| 7179 | % % |
| 7180 | % % |
| 7181 | + M o g r i f y I m a g e L i s t % |
| 7182 | % % |
| 7183 | % % |
| 7184 | % % |
| 7185 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7186 | % |
| 7187 | % MogrifyImageList() applies any command line options that might affect the |
| 7188 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7189 | % |
| 7190 | % The format of the MogrifyImage method is: |
| 7191 | % |
| 7192 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7193 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7194 | % |
| 7195 | % A description of each parameter follows: |
| 7196 | % |
| 7197 | % o image_info: the image info.. |
| 7198 | % |
| 7199 | % o argc: Specifies a pointer to an integer describing the number of |
| 7200 | % elements in the argument vector. |
| 7201 | % |
| 7202 | % o argv: Specifies a pointer to a text array containing the command line |
| 7203 | % arguments. |
| 7204 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7205 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7206 | % |
| 7207 | % o exception: return any errors or warnings in this structure. |
| 7208 | % |
| 7209 | */ |
| 7210 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7211 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7212 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7213 | const char |
| 7214 | *option; |
| 7215 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7216 | ImageInfo |
| 7217 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7218 | |
| 7219 | MagickStatusType |
| 7220 | status; |
| 7221 | |
| 7222 | QuantizeInfo |
| 7223 | *quantize_info; |
| 7224 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7225 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7226 | i; |
| 7227 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7228 | ssize_t |
| 7229 | count, |
| 7230 | index; |
| 7231 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7232 | /* |
| 7233 | Apply options to the image list. |
| 7234 | */ |
| 7235 | assert(image_info != (ImageInfo *) NULL); |
| 7236 | assert(image_info->signature == MagickSignature); |
| 7237 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7238 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7239 | assert((*images)->signature == MagickSignature); |
| 7240 | if ((*images)->debug != MagickFalse) |
| 7241 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7242 | (*images)->filename); |
| 7243 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7244 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7245 | mogrify_info=CloneImageInfo(image_info); |
| 7246 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7247 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7248 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7249 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7250 | if (*images == (Image *) NULL) |
| 7251 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7252 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7253 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7254 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7255 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7256 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7257 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7258 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7259 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7260 | switch (*(option+1)) |
| 7261 | { |
| 7262 | case 'a': |
| 7263 | { |
| 7264 | if (LocaleCompare("affinity",option+1) == 0) |
| 7265 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7266 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7267 | if (*option == '+') |
| 7268 | { |
| 7269 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7270 | InheritException(exception,&(*images)->exception); |
| 7271 | break; |
| 7272 | } |
| 7273 | i++; |
| 7274 | break; |
| 7275 | } |
| 7276 | if (LocaleCompare("append",option+1) == 0) |
| 7277 | { |
| 7278 | Image |
| 7279 | *append_image; |
| 7280 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7281 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7282 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7283 | MagickFalse,exception); |
| 7284 | if (append_image == (Image *) NULL) |
| 7285 | { |
| 7286 | status=MagickFalse; |
| 7287 | break; |
| 7288 | } |
| 7289 | *images=DestroyImageList(*images); |
| 7290 | *images=append_image; |
| 7291 | break; |
| 7292 | } |
| 7293 | if (LocaleCompare("average",option+1) == 0) |
| 7294 | { |
| 7295 | Image |
| 7296 | *average_image; |
| 7297 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7298 | /* |
| 7299 | Average an image sequence (deprecated). |
| 7300 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7301 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7302 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7303 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7304 | if (average_image == (Image *) NULL) |
| 7305 | { |
| 7306 | status=MagickFalse; |
| 7307 | break; |
| 7308 | } |
| 7309 | *images=DestroyImageList(*images); |
| 7310 | *images=average_image; |
| 7311 | break; |
| 7312 | } |
| 7313 | break; |
| 7314 | } |
| 7315 | case 'c': |
| 7316 | { |
| 7317 | if (LocaleCompare("channel",option+1) == 0) |
| 7318 | { |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7319 | ChannelType |
| 7320 | channel; |
| 7321 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7322 | if (*option == '+') |
| 7323 | { |
| 7324 | channel=DefaultChannels; |
| 7325 | break; |
| 7326 | } |
| 7327 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 7328 | SetPixelChannelMap(*images,channel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7329 | break; |
| 7330 | } |
| 7331 | if (LocaleCompare("clut",option+1) == 0) |
| 7332 | { |
| 7333 | Image |
| 7334 | *clut_image, |
| 7335 | *image; |
| 7336 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7337 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7338 | image=RemoveFirstImageFromList(images); |
| 7339 | clut_image=RemoveFirstImageFromList(images); |
| 7340 | if (clut_image == (Image *) NULL) |
| 7341 | { |
| 7342 | status=MagickFalse; |
| 7343 | break; |
| 7344 | } |
cristy | 444eda6 | 2011-08-10 02:07:46 +0000 | [diff] [blame] | 7345 | (void) ClutImage(image,clut_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7346 | clut_image=DestroyImage(clut_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7347 | *images=DestroyImageList(*images); |
| 7348 | *images=image; |
| 7349 | break; |
| 7350 | } |
| 7351 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7352 | { |
| 7353 | Image |
| 7354 | *coalesce_image; |
| 7355 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7356 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7357 | coalesce_image=CoalesceImages(*images,exception); |
| 7358 | if (coalesce_image == (Image *) NULL) |
| 7359 | { |
| 7360 | status=MagickFalse; |
| 7361 | break; |
| 7362 | } |
| 7363 | *images=DestroyImageList(*images); |
| 7364 | *images=coalesce_image; |
| 7365 | break; |
| 7366 | } |
| 7367 | if (LocaleCompare("combine",option+1) == 0) |
| 7368 | { |
| 7369 | Image |
| 7370 | *combine_image; |
| 7371 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7372 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 7373 | combine_image=CombineImages(*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7374 | if (combine_image == (Image *) NULL) |
| 7375 | { |
| 7376 | status=MagickFalse; |
| 7377 | break; |
| 7378 | } |
| 7379 | *images=DestroyImageList(*images); |
| 7380 | *images=combine_image; |
| 7381 | break; |
| 7382 | } |
| 7383 | if (LocaleCompare("composite",option+1) == 0) |
| 7384 | { |
| 7385 | Image |
| 7386 | *mask_image, |
| 7387 | *composite_image, |
| 7388 | *image; |
| 7389 | |
| 7390 | RectangleInfo |
| 7391 | geometry; |
| 7392 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7393 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7394 | image=RemoveFirstImageFromList(images); |
| 7395 | composite_image=RemoveFirstImageFromList(images); |
| 7396 | if (composite_image == (Image *) NULL) |
| 7397 | { |
| 7398 | status=MagickFalse; |
| 7399 | break; |
| 7400 | } |
| 7401 | (void) TransformImage(&composite_image,(char *) NULL, |
| 7402 | composite_image->geometry); |
| 7403 | SetGeometry(composite_image,&geometry); |
| 7404 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7405 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7406 | &geometry); |
| 7407 | mask_image=RemoveFirstImageFromList(images); |
| 7408 | if (mask_image != (Image *) NULL) |
| 7409 | { |
| 7410 | if ((image->compose == DisplaceCompositeOp) || |
| 7411 | (image->compose == DistortCompositeOp)) |
| 7412 | { |
| 7413 | /* |
| 7414 | Merge Y displacement into X displacement image. |
| 7415 | */ |
| 7416 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
| 7417 | mask_image,0,0); |
| 7418 | mask_image=DestroyImage(mask_image); |
| 7419 | } |
| 7420 | else |
| 7421 | { |
| 7422 | /* |
| 7423 | Set a blending mask for the composition. |
| 7424 | */ |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7425 | /* POSIBLE ERROR; what if image->mask already set */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7426 | image->mask=mask_image; |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 7427 | (void) NegateImage(image->mask,MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7428 | } |
| 7429 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7430 | (void) CompositeImage(image,image->compose,composite_image, |
| 7431 | geometry.x,geometry.y); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7432 | if (mask_image != (Image *) NULL) |
| 7433 | mask_image=image->mask=DestroyImage(image->mask); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7434 | composite_image=DestroyImage(composite_image); |
| 7435 | InheritException(exception,&image->exception); |
| 7436 | *images=DestroyImageList(*images); |
| 7437 | *images=image; |
| 7438 | break; |
| 7439 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7440 | #if 0 |
| 7441 | This has been merged completely into MogrifyImage() |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7442 | if (LocaleCompare("crop",option+1) == 0) |
| 7443 | { |
| 7444 | MagickStatusType |
| 7445 | flags; |
| 7446 | |
| 7447 | RectangleInfo |
| 7448 | geometry; |
| 7449 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7450 | /* |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7451 | Crop Image. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7452 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7453 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7454 | flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception); |
| 7455 | if (((geometry.width == 0) && (geometry.height == 0)) || |
| 7456 | ((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 7457 | break; |
| 7458 | (void) TransformImages(images,argv[i+1],(char *) NULL); |
| 7459 | InheritException(exception,&(*images)->exception); |
| 7460 | break; |
| 7461 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7462 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7463 | break; |
| 7464 | } |
| 7465 | case 'd': |
| 7466 | { |
| 7467 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7468 | { |
| 7469 | Image |
| 7470 | *deconstruct_image; |
| 7471 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7472 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7473 | deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer, |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 7474 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7475 | if (deconstruct_image == (Image *) NULL) |
| 7476 | { |
| 7477 | status=MagickFalse; |
| 7478 | break; |
| 7479 | } |
| 7480 | *images=DestroyImageList(*images); |
| 7481 | *images=deconstruct_image; |
| 7482 | break; |
| 7483 | } |
| 7484 | if (LocaleCompare("delete",option+1) == 0) |
| 7485 | { |
| 7486 | if (*option == '+') |
| 7487 | DeleteImages(images,"-1",exception); |
| 7488 | else |
| 7489 | DeleteImages(images,argv[i+1],exception); |
| 7490 | break; |
| 7491 | } |
| 7492 | if (LocaleCompare("dither",option+1) == 0) |
| 7493 | { |
| 7494 | if (*option == '+') |
| 7495 | { |
| 7496 | quantize_info->dither=MagickFalse; |
| 7497 | break; |
| 7498 | } |
| 7499 | quantize_info->dither=MagickTrue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7500 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7501 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7502 | break; |
| 7503 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7504 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7505 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7506 | Image |
| 7507 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7508 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7509 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7510 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7511 | else |
| 7512 | { |
| 7513 | const char |
| 7514 | *p; |
| 7515 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7516 | size_t |
| 7517 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7518 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7519 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7520 | p=strchr(argv[i+1],','); |
| 7521 | if (p == (const char *) NULL) |
| 7522 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7523 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7524 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7525 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7526 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7527 | } |
| 7528 | AppendImageToList(images, duplicate_images); |
| 7529 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7530 | break; |
| 7531 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7532 | break; |
| 7533 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7534 | case 'e': |
| 7535 | { |
| 7536 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7537 | { |
| 7538 | Image |
| 7539 | *evaluate_image; |
| 7540 | |
| 7541 | MagickEvaluateOperator |
| 7542 | op; |
| 7543 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7544 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7545 | op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions, |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7546 | MagickFalse,argv[i+1]); |
| 7547 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7548 | if (evaluate_image == (Image *) NULL) |
| 7549 | { |
| 7550 | status=MagickFalse; |
| 7551 | break; |
| 7552 | } |
| 7553 | *images=DestroyImageList(*images); |
| 7554 | *images=evaluate_image; |
| 7555 | break; |
| 7556 | } |
| 7557 | break; |
| 7558 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7559 | case 'f': |
| 7560 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7561 | if (LocaleCompare("fft",option+1) == 0) |
| 7562 | { |
| 7563 | Image |
| 7564 | *fourier_image; |
| 7565 | |
| 7566 | /* |
| 7567 | Implements the discrete Fourier transform (DFT). |
| 7568 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7569 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7570 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7571 | MagickTrue : MagickFalse,exception); |
| 7572 | if (fourier_image == (Image *) NULL) |
| 7573 | break; |
| 7574 | *images=DestroyImage(*images); |
| 7575 | *images=fourier_image; |
| 7576 | break; |
| 7577 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7578 | if (LocaleCompare("flatten",option+1) == 0) |
| 7579 | { |
| 7580 | Image |
| 7581 | *flatten_image; |
| 7582 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7583 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7584 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7585 | if (flatten_image == (Image *) NULL) |
| 7586 | break; |
| 7587 | *images=DestroyImageList(*images); |
| 7588 | *images=flatten_image; |
| 7589 | break; |
| 7590 | } |
| 7591 | if (LocaleCompare("fx",option+1) == 0) |
| 7592 | { |
| 7593 | Image |
| 7594 | *fx_image; |
| 7595 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7596 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 7597 | fx_image=FxImage(*images,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7598 | if (fx_image == (Image *) NULL) |
| 7599 | { |
| 7600 | status=MagickFalse; |
| 7601 | break; |
| 7602 | } |
| 7603 | *images=DestroyImageList(*images); |
| 7604 | *images=fx_image; |
| 7605 | break; |
| 7606 | } |
| 7607 | break; |
| 7608 | } |
| 7609 | case 'h': |
| 7610 | { |
| 7611 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7612 | { |
| 7613 | Image |
| 7614 | *hald_image, |
| 7615 | *image; |
| 7616 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7617 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7618 | image=RemoveFirstImageFromList(images); |
| 7619 | hald_image=RemoveFirstImageFromList(images); |
| 7620 | if (hald_image == (Image *) NULL) |
| 7621 | { |
| 7622 | status=MagickFalse; |
| 7623 | break; |
| 7624 | } |
cristy | f89cb1d | 2011-07-07 01:24:37 +0000 | [diff] [blame] | 7625 | (void) HaldClutImage(image,hald_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7626 | hald_image=DestroyImage(hald_image); |
| 7627 | InheritException(exception,&image->exception); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7628 | if (*images != (Image *) NULL) |
| 7629 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7630 | *images=image; |
| 7631 | break; |
| 7632 | } |
| 7633 | break; |
| 7634 | } |
| 7635 | case 'i': |
| 7636 | { |
| 7637 | if (LocaleCompare("ift",option+1) == 0) |
| 7638 | { |
| 7639 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7640 | *fourier_image, |
| 7641 | *magnitude_image, |
| 7642 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7643 | |
| 7644 | /* |
| 7645 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7646 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7647 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7648 | magnitude_image=RemoveFirstImageFromList(images); |
| 7649 | phase_image=RemoveFirstImageFromList(images); |
| 7650 | if (phase_image == (Image *) NULL) |
| 7651 | { |
| 7652 | status=MagickFalse; |
| 7653 | break; |
| 7654 | } |
| 7655 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7656 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7657 | if (fourier_image == (Image *) NULL) |
| 7658 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7659 | if (*images != (Image *) NULL) |
| 7660 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7661 | *images=fourier_image; |
| 7662 | break; |
| 7663 | } |
| 7664 | if (LocaleCompare("insert",option+1) == 0) |
| 7665 | { |
| 7666 | Image |
| 7667 | *p, |
| 7668 | *q; |
| 7669 | |
| 7670 | index=0; |
| 7671 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7672 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7673 | p=RemoveLastImageFromList(images); |
| 7674 | if (p == (Image *) NULL) |
| 7675 | { |
| 7676 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7677 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7678 | status=MagickFalse; |
| 7679 | break; |
| 7680 | } |
| 7681 | q=p; |
| 7682 | if (index == 0) |
| 7683 | PrependImageToList(images,q); |
| 7684 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7685 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7686 | AppendImageToList(images,q); |
| 7687 | else |
| 7688 | { |
| 7689 | q=GetImageFromList(*images,index-1); |
| 7690 | if (q == (Image *) NULL) |
| 7691 | { |
| 7692 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7693 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7694 | status=MagickFalse; |
| 7695 | break; |
| 7696 | } |
| 7697 | InsertImageInList(&q,p); |
| 7698 | } |
| 7699 | *images=GetFirstImageInList(q); |
| 7700 | break; |
| 7701 | } |
| 7702 | break; |
| 7703 | } |
| 7704 | case 'l': |
| 7705 | { |
| 7706 | if (LocaleCompare("layers",option+1) == 0) |
| 7707 | { |
| 7708 | Image |
| 7709 | *layers; |
| 7710 | |
| 7711 | ImageLayerMethod |
| 7712 | method; |
| 7713 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7714 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7715 | layers=(Image *) NULL; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7716 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7717 | MagickFalse,argv[i+1]); |
| 7718 | switch (method) |
| 7719 | { |
| 7720 | case CoalesceLayer: |
| 7721 | { |
| 7722 | layers=CoalesceImages(*images,exception); |
| 7723 | break; |
| 7724 | } |
| 7725 | case CompareAnyLayer: |
| 7726 | case CompareClearLayer: |
| 7727 | case CompareOverlayLayer: |
| 7728 | default: |
| 7729 | { |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7730 | layers=CompareImagesLayers(*images,method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7731 | break; |
| 7732 | } |
| 7733 | case MergeLayer: |
| 7734 | case FlattenLayer: |
| 7735 | case MosaicLayer: |
| 7736 | case TrimBoundsLayer: |
| 7737 | { |
| 7738 | layers=MergeImageLayers(*images,method,exception); |
| 7739 | break; |
| 7740 | } |
| 7741 | case DisposeLayer: |
| 7742 | { |
| 7743 | layers=DisposeImages(*images,exception); |
| 7744 | break; |
| 7745 | } |
| 7746 | case OptimizeImageLayer: |
| 7747 | { |
| 7748 | layers=OptimizeImageLayers(*images,exception); |
| 7749 | break; |
| 7750 | } |
| 7751 | case OptimizePlusLayer: |
| 7752 | { |
| 7753 | layers=OptimizePlusImageLayers(*images,exception); |
| 7754 | break; |
| 7755 | } |
| 7756 | case OptimizeTransLayer: |
| 7757 | { |
| 7758 | OptimizeImageTransparency(*images,exception); |
| 7759 | break; |
| 7760 | } |
| 7761 | case RemoveDupsLayer: |
| 7762 | { |
| 7763 | RemoveDuplicateLayers(images,exception); |
| 7764 | break; |
| 7765 | } |
| 7766 | case RemoveZeroLayer: |
| 7767 | { |
| 7768 | RemoveZeroDelayLayers(images,exception); |
| 7769 | break; |
| 7770 | } |
| 7771 | case OptimizeLayer: |
| 7772 | { |
| 7773 | /* |
| 7774 | General Purpose, GIF Animation Optimizer. |
| 7775 | */ |
| 7776 | layers=CoalesceImages(*images,exception); |
| 7777 | if (layers == (Image *) NULL) |
| 7778 | { |
| 7779 | status=MagickFalse; |
| 7780 | break; |
| 7781 | } |
| 7782 | InheritException(exception,&layers->exception); |
| 7783 | *images=DestroyImageList(*images); |
| 7784 | *images=layers; |
| 7785 | layers=OptimizeImageLayers(*images,exception); |
| 7786 | if (layers == (Image *) NULL) |
| 7787 | { |
| 7788 | status=MagickFalse; |
| 7789 | break; |
| 7790 | } |
| 7791 | InheritException(exception,&layers->exception); |
| 7792 | *images=DestroyImageList(*images); |
| 7793 | *images=layers; |
| 7794 | layers=(Image *) NULL; |
| 7795 | OptimizeImageTransparency(*images,exception); |
| 7796 | InheritException(exception,&(*images)->exception); |
| 7797 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7798 | break; |
| 7799 | } |
| 7800 | case CompositeLayer: |
| 7801 | { |
| 7802 | CompositeOperator |
| 7803 | compose; |
| 7804 | |
| 7805 | Image |
| 7806 | *source; |
| 7807 | |
| 7808 | RectangleInfo |
| 7809 | geometry; |
| 7810 | |
| 7811 | /* |
| 7812 | Split image sequence at the first 'NULL:' image. |
| 7813 | */ |
| 7814 | source=(*images); |
| 7815 | while (source != (Image *) NULL) |
| 7816 | { |
| 7817 | source=GetNextImageInList(source); |
| 7818 | if ((source != (Image *) NULL) && |
| 7819 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7820 | break; |
| 7821 | } |
| 7822 | if (source != (Image *) NULL) |
| 7823 | { |
| 7824 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7825 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7826 | source=(Image *) NULL; |
| 7827 | else |
| 7828 | { |
| 7829 | /* |
| 7830 | Separate the two lists, junk the null: image. |
| 7831 | */ |
| 7832 | source=SplitImageList(source->previous); |
| 7833 | DeleteImageFromList(&source); |
| 7834 | } |
| 7835 | } |
| 7836 | if (source == (Image *) NULL) |
| 7837 | { |
| 7838 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7839 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7840 | status=MagickFalse; |
| 7841 | break; |
| 7842 | } |
| 7843 | /* |
| 7844 | Adjust offset with gravity and virtual canvas. |
| 7845 | */ |
| 7846 | SetGeometry(*images,&geometry); |
| 7847 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7848 | geometry.width=source->page.width != 0 ? |
| 7849 | source->page.width : source->columns; |
| 7850 | geometry.height=source->page.height != 0 ? |
| 7851 | source->page.height : source->rows; |
| 7852 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7853 | (*images)->page.width : (*images)->columns, |
| 7854 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7855 | (*images)->rows,(*images)->gravity,&geometry); |
| 7856 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7857 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7858 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7859 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7860 | MagickComposeOptions,MagickFalse,option); |
| 7861 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7862 | exception); |
| 7863 | source=DestroyImageList(source); |
| 7864 | break; |
| 7865 | } |
| 7866 | } |
| 7867 | if (layers == (Image *) NULL) |
| 7868 | break; |
| 7869 | InheritException(exception,&layers->exception); |
| 7870 | *images=DestroyImageList(*images); |
| 7871 | *images=layers; |
| 7872 | break; |
| 7873 | } |
| 7874 | break; |
| 7875 | } |
| 7876 | case 'm': |
| 7877 | { |
| 7878 | if (LocaleCompare("map",option+1) == 0) |
| 7879 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7880 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7881 | if (*option == '+') |
| 7882 | { |
| 7883 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7884 | InheritException(exception,&(*images)->exception); |
| 7885 | break; |
| 7886 | } |
| 7887 | i++; |
| 7888 | break; |
| 7889 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7890 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7891 | { |
| 7892 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7893 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7894 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7895 | /* |
| 7896 | Maximum image sequence (deprecated). |
| 7897 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7898 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7899 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7900 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7901 | { |
| 7902 | status=MagickFalse; |
| 7903 | break; |
| 7904 | } |
| 7905 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7906 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7907 | break; |
| 7908 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7909 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7910 | { |
| 7911 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7912 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7913 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7914 | /* |
| 7915 | Minimum image sequence (deprecated). |
| 7916 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7917 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7918 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7919 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7920 | { |
| 7921 | status=MagickFalse; |
| 7922 | break; |
| 7923 | } |
| 7924 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7925 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7926 | break; |
| 7927 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7928 | if (LocaleCompare("morph",option+1) == 0) |
| 7929 | { |
| 7930 | Image |
| 7931 | *morph_image; |
| 7932 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7933 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7934 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7935 | exception); |
| 7936 | if (morph_image == (Image *) NULL) |
| 7937 | { |
| 7938 | status=MagickFalse; |
| 7939 | break; |
| 7940 | } |
| 7941 | *images=DestroyImageList(*images); |
| 7942 | *images=morph_image; |
| 7943 | break; |
| 7944 | } |
| 7945 | if (LocaleCompare("mosaic",option+1) == 0) |
| 7946 | { |
| 7947 | Image |
| 7948 | *mosaic_image; |
| 7949 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7950 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7951 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 7952 | if (mosaic_image == (Image *) NULL) |
| 7953 | { |
| 7954 | status=MagickFalse; |
| 7955 | break; |
| 7956 | } |
| 7957 | *images=DestroyImageList(*images); |
| 7958 | *images=mosaic_image; |
| 7959 | break; |
| 7960 | } |
| 7961 | break; |
| 7962 | } |
| 7963 | case 'p': |
| 7964 | { |
| 7965 | if (LocaleCompare("print",option+1) == 0) |
| 7966 | { |
| 7967 | char |
| 7968 | *string; |
| 7969 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7970 | (void) SyncImagesSettings(mogrify_info,*images); |
| 7971 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7972 | if (string == (char *) NULL) |
| 7973 | break; |
| 7974 | InheritException(exception,&(*images)->exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 7975 | (void) FormatLocaleFile(stdout,"%s",string); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7976 | string=DestroyString(string); |
| 7977 | } |
| 7978 | if (LocaleCompare("process",option+1) == 0) |
| 7979 | { |
| 7980 | char |
| 7981 | **arguments; |
| 7982 | |
| 7983 | int |
| 7984 | j, |
| 7985 | number_arguments; |
| 7986 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7987 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7988 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 7989 | if (arguments == (char **) NULL) |
| 7990 | break; |
| 7991 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 7992 | { |
| 7993 | char |
| 7994 | breaker, |
| 7995 | quote, |
| 7996 | *token; |
| 7997 | |
| 7998 | const char |
| 7999 | *arguments; |
| 8000 | |
| 8001 | int |
| 8002 | next, |
| 8003 | status; |
| 8004 | |
| 8005 | size_t |
| 8006 | length; |
| 8007 | |
| 8008 | TokenInfo |
| 8009 | *token_info; |
| 8010 | |
| 8011 | /* |
| 8012 | Support old style syntax, filter="-option arg". |
| 8013 | */ |
| 8014 | length=strlen(argv[i+1]); |
| 8015 | token=(char *) NULL; |
cristy | 37e0b38 | 2011-06-07 13:31:21 +0000 | [diff] [blame] | 8016 | if (~length >= (MaxTextExtent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8017 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8018 | sizeof(*token)); |
| 8019 | if (token == (char *) NULL) |
| 8020 | break; |
| 8021 | next=0; |
| 8022 | arguments=argv[i+1]; |
| 8023 | token_info=AcquireTokenInfo(); |
| 8024 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8025 | "\"",'\0',&breaker,&next,"e); |
| 8026 | token_info=DestroyTokenInfo(token_info); |
| 8027 | if (status == 0) |
| 8028 | { |
| 8029 | const char |
| 8030 | *argv; |
| 8031 | |
| 8032 | argv=(&(arguments[next])); |
| 8033 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8034 | exception); |
| 8035 | } |
| 8036 | token=DestroyString(token); |
| 8037 | break; |
| 8038 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8039 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8040 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8041 | number_arguments-2,(const char **) arguments+2,exception); |
| 8042 | for (j=0; j < number_arguments; j++) |
| 8043 | arguments[j]=DestroyString(arguments[j]); |
| 8044 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8045 | break; |
| 8046 | } |
| 8047 | break; |
| 8048 | } |
| 8049 | case 'r': |
| 8050 | { |
| 8051 | if (LocaleCompare("reverse",option+1) == 0) |
| 8052 | { |
| 8053 | ReverseImageList(images); |
| 8054 | InheritException(exception,&(*images)->exception); |
| 8055 | break; |
| 8056 | } |
| 8057 | break; |
| 8058 | } |
| 8059 | case 's': |
| 8060 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8061 | if (LocaleCompare("smush",option+1) == 0) |
| 8062 | { |
| 8063 | Image |
| 8064 | *smush_image; |
| 8065 | |
| 8066 | ssize_t |
| 8067 | offset; |
| 8068 | |
| 8069 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8070 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8071 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8072 | MagickFalse,offset,exception); |
| 8073 | if (smush_image == (Image *) NULL) |
| 8074 | { |
| 8075 | status=MagickFalse; |
| 8076 | break; |
| 8077 | } |
| 8078 | *images=DestroyImageList(*images); |
| 8079 | *images=smush_image; |
| 8080 | break; |
| 8081 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8082 | if (LocaleCompare("swap",option+1) == 0) |
| 8083 | { |
| 8084 | Image |
| 8085 | *p, |
| 8086 | *q, |
| 8087 | *swap; |
| 8088 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8089 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8090 | swap_index; |
| 8091 | |
| 8092 | index=(-1); |
| 8093 | swap_index=(-2); |
| 8094 | if (*option != '+') |
| 8095 | { |
| 8096 | GeometryInfo |
| 8097 | geometry_info; |
| 8098 | |
| 8099 | MagickStatusType |
| 8100 | flags; |
| 8101 | |
| 8102 | swap_index=(-1); |
| 8103 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8104 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8105 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8106 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8107 | } |
| 8108 | p=GetImageFromList(*images,index); |
| 8109 | q=GetImageFromList(*images,swap_index); |
| 8110 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8111 | { |
| 8112 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8113 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8114 | status=MagickFalse; |
| 8115 | break; |
| 8116 | } |
| 8117 | if (p == q) |
| 8118 | break; |
| 8119 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8120 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8121 | ReplaceImageInList(&q,swap); |
| 8122 | *images=GetFirstImageInList(q); |
| 8123 | break; |
| 8124 | } |
| 8125 | break; |
| 8126 | } |
| 8127 | case 'w': |
| 8128 | { |
| 8129 | if (LocaleCompare("write",option+1) == 0) |
| 8130 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8131 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8132 | key[MaxTextExtent]; |
| 8133 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8134 | Image |
| 8135 | *write_images; |
| 8136 | |
| 8137 | ImageInfo |
| 8138 | *write_info; |
| 8139 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8140 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8141 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8142 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8143 | write_images=(*images); |
| 8144 | if (*option == '+') |
| 8145 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8146 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8147 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8148 | write_info=DestroyImageInfo(write_info); |
| 8149 | if (*option == '+') |
| 8150 | write_images=DestroyImageList(write_images); |
| 8151 | break; |
| 8152 | } |
| 8153 | break; |
| 8154 | } |
| 8155 | default: |
| 8156 | break; |
| 8157 | } |
| 8158 | i+=count; |
| 8159 | } |
| 8160 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8161 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8162 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8163 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8164 | } |
| 8165 | |
| 8166 | /* |
| 8167 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8168 | % % |
| 8169 | % % |
| 8170 | % % |
| 8171 | + M o g r i f y I m a g e s % |
| 8172 | % % |
| 8173 | % % |
| 8174 | % % |
| 8175 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8176 | % |
| 8177 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8178 | % prescribed by command line options. |
| 8179 | % |
| 8180 | % The format of the MogrifyImage method is: |
| 8181 | % |
| 8182 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8183 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8184 | % Image **images,Exceptioninfo *exception) |
| 8185 | % |
| 8186 | % A description of each parameter follows: |
| 8187 | % |
| 8188 | % o image_info: the image info.. |
| 8189 | % |
| 8190 | % o post: If true, post process image list operators otherwise pre-process. |
| 8191 | % |
| 8192 | % o argc: Specifies a pointer to an integer describing the number of |
| 8193 | % elements in the argument vector. |
| 8194 | % |
| 8195 | % o argv: Specifies a pointer to a text array containing the command line |
| 8196 | % arguments. |
| 8197 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8198 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8199 | % |
| 8200 | % o exception: return any errors or warnings in this structure. |
| 8201 | % |
| 8202 | */ |
| 8203 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8204 | const MagickBooleanType post,const int argc,const char **argv, |
| 8205 | Image **images,ExceptionInfo *exception) |
| 8206 | { |
| 8207 | #define MogrifyImageTag "Mogrify/Image" |
| 8208 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8209 | MagickStatusType |
| 8210 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8211 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8212 | MagickBooleanType |
| 8213 | proceed; |
| 8214 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8215 | size_t |
| 8216 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8217 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8218 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8219 | i; |
| 8220 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8221 | assert(image_info != (ImageInfo *) NULL); |
| 8222 | assert(image_info->signature == MagickSignature); |
| 8223 | if (images == (Image **) NULL) |
| 8224 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8225 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8226 | assert((*images)->signature == MagickSignature); |
| 8227 | if ((*images)->debug != MagickFalse) |
| 8228 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8229 | (*images)->filename); |
| 8230 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8231 | return(MagickTrue); |
| 8232 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8233 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8234 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8235 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8236 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8237 | (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc, |
| 8238 | post?"post":"pre"); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8239 | #endif |
| 8240 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8241 | /* |
| 8242 | Pre-process multi-image sequence operators |
| 8243 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8244 | if (post == MagickFalse) |
| 8245 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8246 | /* |
| 8247 | For each image, process simple single image operators |
| 8248 | */ |
| 8249 | i=0; |
| 8250 | n=GetImageListLength(*images); |
| 8251 | for (;;) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8252 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8253 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8254 | (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long) |
| 8255 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8256 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8257 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8258 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8259 | if (proceed == MagickFalse) |
| 8260 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8261 | if ( (*images)->next == (Image *) NULL ) |
| 8262 | break; |
| 8263 | *images=(*images)->next; |
| 8264 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8265 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8266 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8267 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8268 | (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long) |
| 8269 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8270 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8271 | |
| 8272 | /* |
| 8273 | Post-process, multi-image sequence operators |
| 8274 | */ |
| 8275 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8276 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8277 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8278 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8279 | } |