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 | */ |
| 47 | #include "wand/studio.h" |
| 48 | #include "wand/MagickWand.h" |
| 49 | #include "wand/mogrify-private.h" |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 50 | #include "magick/monitor-private.h" |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 51 | #include "magick/thread-private.h" |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 52 | #include "magick/string-private.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 53 | |
| 54 | /* |
| 55 | Define declarations. |
| 56 | */ |
| 57 | #define UndefinedCompressionQuality 0UL |
| 58 | |
| 59 | /* |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 60 | Constant declaration. |
| 61 | */ |
| 62 | static const char |
| 63 | BackgroundColor[] = "#fff", /* white */ |
| 64 | BorderColor[] = "#dfdfdf", /* gray */ |
| 65 | MatteColor[] = "#bdbdbd"; /* gray */ |
| 66 | |
| 67 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 68 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 69 | % % |
| 70 | % % |
| 71 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 72 | % 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] | 73 | % % |
| 74 | % % |
| 75 | % % |
| 76 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 77 | % |
| 78 | % MagickCommandGenesis() applies image processing options to an image as |
| 79 | % prescribed by command line options. |
| 80 | % |
| 81 | % The format of the MagickCommandGenesis method is: |
| 82 | % |
| 83 | % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 84 | % MagickCommand command,int argc,char **argv,char **metadata, |
| 85 | % ExceptionInfo *exception) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 86 | % |
| 87 | % A description of each parameter follows: |
| 88 | % |
| 89 | % o image_info: the image info. |
| 90 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 91 | % o command: Choose from ConvertImageCommand, IdentifyImageCommand, |
| 92 | % MogrifyImageCommand, CompositeImageCommand, CompareImageCommand, |
| 93 | % ConjureImageCommand, StreamImageCommand, ImportImageCommand, |
| 94 | % DisplayImageCommand, or AnimateImageCommand. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 95 | % |
| 96 | % o argc: Specifies a pointer to an integer describing the number of |
| 97 | % elements in the argument vector. |
| 98 | % |
| 99 | % o argv: Specifies a pointer to a text array containing the command line |
| 100 | % arguments. |
| 101 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 102 | % o metadata: any metadata is returned here. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 103 | % |
| 104 | % o exception: return any errors or warnings in this structure. |
| 105 | % |
| 106 | */ |
| 107 | WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
| 108 | MagickCommand command,int argc,char **argv,char **metadata, |
| 109 | ExceptionInfo *exception) |
| 110 | { |
| 111 | char |
| 112 | *option; |
| 113 | |
| 114 | double |
| 115 | duration, |
| 116 | elapsed_time, |
| 117 | user_time; |
| 118 | |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 119 | MagickBooleanType |
| 120 | concurrent, |
| 121 | regard_warnings, |
| 122 | status; |
| 123 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 124 | register ssize_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 125 | i; |
| 126 | |
| 127 | TimerInfo |
| 128 | *timer; |
| 129 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 130 | size_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 131 | iterations; |
| 132 | |
cristy | d0a94fa | 2010-03-12 14:18:11 +0000 | [diff] [blame] | 133 | (void) setlocale(LC_ALL,""); |
| 134 | (void) setlocale(LC_NUMERIC,"C"); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 135 | concurrent=MagickFalse; |
| 136 | duration=(-1.0); |
| 137 | iterations=1; |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 138 | status=MagickFalse; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 139 | regard_warnings=MagickFalse; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 140 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 141 | { |
| 142 | option=argv[i]; |
| 143 | if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) |
| 144 | continue; |
| 145 | if (LocaleCompare("bench",option+1) == 0) |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 146 | iterations=StringToUnsignedLong(argv[++i]); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 147 | if (LocaleCompare("concurrent",option+1) == 0) |
| 148 | concurrent=MagickTrue; |
| 149 | if (LocaleCompare("debug",option+1) == 0) |
| 150 | (void) SetLogEventMask(argv[++i]); |
| 151 | if (LocaleCompare("duration",option+1) == 0) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 152 | duration=LocaleToDouble(argv[++i],(char **) NULL); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 153 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 154 | regard_warnings=MagickTrue; |
| 155 | } |
| 156 | timer=AcquireTimerInfo(); |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 157 | if (concurrent == MagickFalse) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 158 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 159 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 160 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 161 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 162 | continue; |
| 163 | if (duration > 0) |
| 164 | { |
| 165 | if (GetElapsedTime(timer) > duration) |
| 166 | continue; |
| 167 | (void) ContinueTimer(timer); |
| 168 | } |
| 169 | status=command(image_info,argc,argv,metadata,exception); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 170 | if (exception->severity != UndefinedException) |
| 171 | { |
| 172 | if ((exception->severity > ErrorException) || |
| 173 | (regard_warnings != MagickFalse)) |
| 174 | status=MagickTrue; |
| 175 | CatchException(exception); |
| 176 | } |
cristy | 3d1a551 | 2009-10-25 21:23:27 +0000 | [diff] [blame] | 177 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 178 | { |
| 179 | (void) fputs(*metadata,stdout); |
| 180 | (void) fputc('\n',stdout); |
| 181 | *metadata=DestroyString(*metadata); |
| 182 | } |
| 183 | } |
| 184 | } |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 185 | else |
| 186 | { |
| 187 | SetOpenMPNested(1); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 188 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 189 | # pragma omp parallel for shared(status) |
| 190 | #endif |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 191 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 192 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 193 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 194 | continue; |
| 195 | if (duration > 0) |
| 196 | { |
| 197 | if (GetElapsedTime(timer) > duration) |
| 198 | continue; |
| 199 | (void) ContinueTimer(timer); |
| 200 | } |
| 201 | status=command(image_info,argc,argv,metadata,exception); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 202 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 203 | # pragma omp critical (MagickCore_CommandGenesis) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 204 | #endif |
| 205 | { |
| 206 | if (exception->severity != UndefinedException) |
| 207 | { |
| 208 | if ((exception->severity > ErrorException) || |
| 209 | (regard_warnings != MagickFalse)) |
| 210 | status=MagickTrue; |
| 211 | CatchException(exception); |
| 212 | } |
| 213 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 214 | { |
| 215 | (void) fputs(*metadata,stdout); |
| 216 | (void) fputc('\n',stdout); |
| 217 | *metadata=DestroyString(*metadata); |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | } |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 222 | if (iterations > 1) |
| 223 | { |
| 224 | elapsed_time=GetElapsedTime(timer); |
| 225 | user_time=GetUserTime(timer); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 226 | (void) FormatLocaleFile(stderr, |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 227 | "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double) |
| 228 | iterations,1.0*iterations/elapsed_time,user_time,(double) |
| 229 | (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double) |
| 230 | (1000.0*(elapsed_time-floor(elapsed_time)))); |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 231 | (void) fflush(stderr); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 232 | } |
| 233 | timer=DestroyTimerInfo(timer); |
cristy | 1f9e1ed | 2009-11-18 04:09:38 +0000 | [diff] [blame] | 234 | return(status); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | /* |
| 238 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 239 | % % |
| 240 | % % |
| 241 | % % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 242 | + M o g r i f y I m a g e % |
| 243 | % % |
| 244 | % % |
| 245 | % % |
| 246 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 247 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 248 | % MogrifyImage() applies simple single image processing options to a single |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 249 | % image that may be part of a large list, but also handles any 'region' |
| 250 | % image handling. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 251 | % |
| 252 | % The image in the list may be modified in three different ways... |
| 253 | % |
| 254 | % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 255 | % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 256 | % * replace by a list of images (only the -separate option!) |
| 257 | % |
| 258 | % In each case the result is returned into the list, and a pointer to the |
| 259 | % modified image (last image added if replaced by a list of images) is |
| 260 | % returned. |
| 261 | % |
| 262 | % ASIDE: The -crop is present but restricted to non-tile single image crops |
| 263 | % |
| 264 | % This means if all the images are being processed (such as by |
| 265 | % MogrifyImages(), next image to be processed will be as per the pointer |
| 266 | % (*image)->next. Also the image list may grow as a result of some specific |
| 267 | % operations but as images are never merged or deleted, it will never shrink |
| 268 | % in length. Typically the list will remain the same length. |
| 269 | % |
| 270 | % WARNING: As the image pointed to may be replaced, the first image in the |
| 271 | % list may also change. GetFirstImageInList() should be used by caller if |
| 272 | % they wish return the Image pointer to the first image in list. |
| 273 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 274 | % |
| 275 | % The format of the MogrifyImage method is: |
| 276 | % |
| 277 | % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 278 | % const char **argv,Image **image) |
| 279 | % |
| 280 | % A description of each parameter follows: |
| 281 | % |
| 282 | % o image_info: the image info.. |
| 283 | % |
| 284 | % o argc: Specifies a pointer to an integer describing the number of |
| 285 | % elements in the argument vector. |
| 286 | % |
| 287 | % o argv: Specifies a pointer to a text array containing the command line |
| 288 | % arguments. |
| 289 | % |
| 290 | % o image: the image. |
| 291 | % |
| 292 | % o exception: return any errors or warnings in this structure. |
| 293 | % |
| 294 | */ |
| 295 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 296 | /* |
| 297 | ** GetImageCache() will read an image into a image cache if not already |
| 298 | ** present then return the image that is in the cache under that filename. |
| 299 | */ |
| 300 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 301 | ExceptionInfo *exception) |
| 302 | { |
| 303 | char |
| 304 | key[MaxTextExtent]; |
| 305 | |
| 306 | ExceptionInfo |
| 307 | *sans_exception; |
| 308 | |
| 309 | Image |
| 310 | *image; |
| 311 | |
| 312 | ImageInfo |
| 313 | *read_info; |
| 314 | |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 315 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 316 | sans_exception=AcquireExceptionInfo(); |
| 317 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 318 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 319 | if (image != (Image *) NULL) |
| 320 | return(image); |
| 321 | read_info=CloneImageInfo(image_info); |
| 322 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 323 | image=ReadImage(read_info,exception); |
| 324 | read_info=DestroyImageInfo(read_info); |
| 325 | if (image != (Image *) NULL) |
| 326 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 327 | return(image); |
| 328 | } |
| 329 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 330 | static MagickBooleanType IsPathWritable(const char *path) |
| 331 | { |
| 332 | if (IsPathAccessible(path) == MagickFalse) |
| 333 | return(MagickFalse); |
| 334 | if (access(path,W_OK) != 0) |
| 335 | return(MagickFalse); |
| 336 | return(MagickTrue); |
| 337 | } |
| 338 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 339 | static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 340 | { |
| 341 | if (x > y) |
| 342 | return(x); |
| 343 | return(y); |
| 344 | } |
| 345 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 346 | static MagickBooleanType MonitorProgress(const char *text, |
| 347 | const MagickOffsetType offset,const MagickSizeType extent, |
| 348 | void *wand_unused(client_data)) |
| 349 | { |
| 350 | char |
| 351 | message[MaxTextExtent], |
| 352 | tag[MaxTextExtent]; |
| 353 | |
| 354 | const char |
| 355 | *locale_message; |
| 356 | |
| 357 | register char |
| 358 | *p; |
| 359 | |
| 360 | if (extent < 2) |
| 361 | return(MagickTrue); |
| 362 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 363 | p=strrchr(tag,'/'); |
| 364 | if (p != (char *) NULL) |
| 365 | *p='\0'; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 366 | (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 367 | locale_message=GetLocaleMessage(message); |
| 368 | if (locale_message == message) |
| 369 | locale_message=tag; |
| 370 | if (p == (char *) NULL) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 371 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r",locale_message, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 372 | (long) offset,(unsigned long) extent,(long) (100L*offset/(extent-1))); |
| 373 | else |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 374 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 375 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 376 | (100L*offset/(extent-1))); |
| 377 | if (offset == (MagickOffsetType) (extent-1)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 378 | (void) FormatLocaleFile(stderr,"\n"); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 379 | (void) fflush(stderr); |
| 380 | return(MagickTrue); |
| 381 | } |
| 382 | |
| 383 | /* |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 384 | ** SparseColorOption() parses the complex -sparse-color argument into an |
| 385 | ** an array of floating point values then calls SparseColorImage(). |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 386 | ** Argument is a complex mix of floating-point pixel coodinates, and color |
| 387 | ** specifications (or direct floating point numbers). The number of floats |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 388 | ** needed to represent a color varies depending on the current channel |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 389 | ** setting. |
| 390 | */ |
| 391 | static Image *SparseColorOption(const Image *image,const ChannelType channel, |
| 392 | const SparseColorMethod method,const char *arguments, |
| 393 | const MagickBooleanType color_from_image,ExceptionInfo *exception) |
| 394 | { |
| 395 | ChannelType |
| 396 | channels; |
| 397 | |
| 398 | char |
| 399 | token[MaxTextExtent]; |
| 400 | |
| 401 | const char |
| 402 | *p; |
| 403 | |
| 404 | double |
| 405 | *sparse_arguments; |
| 406 | |
| 407 | register size_t |
| 408 | x; |
| 409 | |
| 410 | size_t |
| 411 | number_arguments; |
| 412 | |
| 413 | size_t |
| 414 | number_colors; |
| 415 | |
| 416 | Image |
| 417 | *sparse_image; |
| 418 | |
| 419 | MagickPixelPacket |
| 420 | color; |
| 421 | |
| 422 | MagickBooleanType |
| 423 | error; |
| 424 | |
| 425 | assert(image != (Image *) NULL); |
| 426 | assert(image->signature == MagickSignature); |
| 427 | if (image->debug != MagickFalse) |
| 428 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 429 | assert(exception != (ExceptionInfo *) NULL); |
| 430 | assert(exception->signature == MagickSignature); |
| 431 | /* |
| 432 | Limit channels according to image - and add up number of color channel. |
| 433 | */ |
| 434 | channels=channel; |
| 435 | if (image->colorspace != CMYKColorspace) |
| 436 | channels=(ChannelType) (channels & ~IndexChannel); /* no index channel */ |
| 437 | if (image->matte == MagickFalse) |
| 438 | channels=(ChannelType) (channels & ~OpacityChannel); /* no alpha channel */ |
| 439 | number_colors=0; |
| 440 | if ((channels & RedChannel) != 0) |
| 441 | number_colors++; |
| 442 | if ((channels & GreenChannel) != 0) |
| 443 | number_colors++; |
| 444 | if ((channels & BlueChannel) != 0) |
| 445 | number_colors++; |
| 446 | if ((channels & IndexChannel) != 0) |
| 447 | number_colors++; |
| 448 | if ((channels & OpacityChannel) != 0) |
| 449 | number_colors++; |
| 450 | |
| 451 | /* |
| 452 | Read string, to determine number of arguments needed, |
| 453 | */ |
| 454 | p=arguments; |
| 455 | x=0; |
| 456 | while( *p != '\0' ) |
| 457 | { |
| 458 | GetMagickToken(p,&p,token); |
| 459 | if ( token[0] == ',' ) continue; |
| 460 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 461 | if ( color_from_image ) { |
| 462 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 463 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 464 | "Color arg given, when colors are coming from image"); |
| 465 | return( (Image *)NULL); |
| 466 | } |
| 467 | x += number_colors; /* color argument */ |
| 468 | } |
| 469 | else { |
| 470 | x++; /* floating point argument */ |
| 471 | } |
| 472 | } |
| 473 | error=MagickTrue; |
| 474 | if ( color_from_image ) { |
| 475 | /* just the control points are being given */ |
| 476 | error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; |
| 477 | number_arguments=(x/2)*(2+number_colors); |
| 478 | } |
| 479 | else { |
| 480 | /* control points and color values */ |
| 481 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; |
| 482 | number_arguments=x; |
| 483 | } |
| 484 | if ( error ) { |
| 485 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 486 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 487 | "Invalid number of Arguments"); |
| 488 | return( (Image *)NULL); |
| 489 | } |
| 490 | |
| 491 | /* Allocate and fill in the floating point arguments */ |
| 492 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 493 | sizeof(*sparse_arguments)); |
| 494 | if (sparse_arguments == (double *) NULL) { |
| 495 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 496 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 497 | return( (Image *)NULL); |
| 498 | } |
| 499 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 500 | sizeof(*sparse_arguments)); |
| 501 | p=arguments; |
| 502 | x=0; |
| 503 | while( *p != '\0' && x < number_arguments ) { |
| 504 | /* X coordinate */ |
| 505 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 506 | if ( token[0] == '\0' ) break; |
| 507 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 508 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 509 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 510 | "Color found, instead of X-coord"); |
| 511 | error = MagickTrue; |
| 512 | break; |
| 513 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 514 | sparse_arguments[x++]=LocaleToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 515 | /* Y coordinate */ |
| 516 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 517 | if ( token[0] == '\0' ) break; |
| 518 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 519 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 520 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 521 | "Color found, instead of Y-coord"); |
| 522 | error = MagickTrue; |
| 523 | break; |
| 524 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 525 | sparse_arguments[x++]=LocaleToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 526 | /* color values for this control point */ |
| 527 | #if 0 |
| 528 | if ( (color_from_image ) { |
| 529 | /* get color from image */ |
| 530 | /* HOW??? */ |
| 531 | } |
| 532 | else |
| 533 | #endif |
| 534 | { |
| 535 | /* color name or function given in string argument */ |
| 536 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 537 | if ( token[0] == '\0' ) break; |
| 538 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 539 | /* Color string given */ |
| 540 | (void) QueryMagickColor(token,&color,exception); |
| 541 | if ( channels & RedChannel ) |
| 542 | sparse_arguments[x++] = QuantumScale*color.red; |
| 543 | if ( channels & GreenChannel ) |
| 544 | sparse_arguments[x++] = QuantumScale*color.green; |
| 545 | if ( channels & BlueChannel ) |
| 546 | sparse_arguments[x++] = QuantumScale*color.blue; |
| 547 | if ( channels & IndexChannel ) |
| 548 | sparse_arguments[x++] = QuantumScale*color.index; |
| 549 | if ( channels & OpacityChannel ) |
| 550 | sparse_arguments[x++] = QuantumScale*color.opacity; |
| 551 | } |
| 552 | else { |
| 553 | /* Colors given as a set of floating point values - experimental */ |
| 554 | /* NB: token contains the first floating point value to use! */ |
| 555 | if ( channels & RedChannel ) { |
| 556 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 557 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 558 | break; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 559 | sparse_arguments[x++]=LocaleToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 560 | token[0] = ','; /* used this token - get another */ |
| 561 | } |
| 562 | if ( channels & GreenChannel ) { |
| 563 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 564 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 565 | break; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 566 | sparse_arguments[x++]=LocaleToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 567 | token[0] = ','; /* used this token - get another */ |
| 568 | } |
| 569 | if ( channels & BlueChannel ) { |
| 570 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 571 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 572 | break; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 573 | sparse_arguments[x++]=LocaleToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 574 | token[0] = ','; /* used this token - get another */ |
| 575 | } |
| 576 | if ( channels & IndexChannel ) { |
| 577 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 578 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 579 | break; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 580 | sparse_arguments[x++]=LocaleToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 581 | token[0] = ','; /* used this token - get another */ |
| 582 | } |
| 583 | if ( channels & OpacityChannel ) { |
| 584 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 585 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 586 | break; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 587 | sparse_arguments[x++]=LocaleToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 588 | token[0] = ','; /* used this token - get another */ |
| 589 | } |
| 590 | } |
| 591 | } |
| 592 | } |
| 593 | if ( number_arguments != x && !error ) { |
| 594 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
| 595 | "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error"); |
| 596 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 597 | return( (Image *)NULL); |
| 598 | } |
| 599 | if ( error ) |
| 600 | return( (Image *)NULL); |
| 601 | |
| 602 | /* Call the Interpolation function with the parsed arguments */ |
| 603 | sparse_image=SparseColorImage(image,channels,method,number_arguments, |
| 604 | sparse_arguments,exception); |
| 605 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 606 | return( sparse_image ); |
| 607 | } |
| 608 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 609 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 610 | const char **argv,Image **image,ExceptionInfo *exception) |
| 611 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 612 | ChannelType |
| 613 | channel; |
| 614 | |
| 615 | const char |
| 616 | *format, |
| 617 | *option; |
| 618 | |
| 619 | DrawInfo |
| 620 | *draw_info; |
| 621 | |
| 622 | GeometryInfo |
| 623 | geometry_info; |
| 624 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 625 | Image |
| 626 | *region_image; |
| 627 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 628 | ImageInfo |
| 629 | *mogrify_info; |
| 630 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 631 | MagickStatusType |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 632 | status; |
| 633 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 634 | MagickPixelPacket |
| 635 | fill; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 636 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 637 | MagickStatusType |
| 638 | flags; |
| 639 | |
| 640 | QuantizeInfo |
| 641 | *quantize_info; |
| 642 | |
| 643 | RectangleInfo |
| 644 | geometry, |
| 645 | region_geometry; |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame] | 646 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 647 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 648 | i; |
| 649 | |
| 650 | /* |
| 651 | Initialize method variables. |
| 652 | */ |
| 653 | assert(image_info != (const ImageInfo *) NULL); |
| 654 | assert(image_info->signature == MagickSignature); |
| 655 | assert(image != (Image **) NULL); |
| 656 | assert((*image)->signature == MagickSignature); |
| 657 | if ((*image)->debug != MagickFalse) |
| 658 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); |
| 659 | if (argc < 0) |
| 660 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 661 | mogrify_info=CloneImageInfo(image_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 662 | draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL); |
| 663 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 664 | SetGeometryInfo(&geometry_info); |
| 665 | GetMagickPixelPacket(*image,&fill); |
| 666 | SetMagickPixelPacket(*image,&(*image)->background_color,(IndexPacket *) NULL, |
| 667 | &fill); |
| 668 | channel=mogrify_info->channel; |
| 669 | format=GetImageOption(mogrify_info,"format"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 670 | SetGeometry(*image,®ion_geometry); |
| 671 | region_image=NewImageList(); |
| 672 | /* |
| 673 | Transmogrify the image. |
| 674 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 675 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 676 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 677 | Image |
| 678 | *mogrify_image; |
| 679 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 680 | ssize_t |
| 681 | count; |
| 682 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 683 | option=argv[i]; |
| 684 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 685 | continue; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 686 | count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option), |
| 687 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 688 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 689 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 690 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 691 | mogrify_image=(Image *)NULL; |
| 692 | switch (*(option+1)) |
| 693 | { |
| 694 | case 'a': |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 695 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 696 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 697 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 698 | /* |
| 699 | Adaptive blur image. |
| 700 | */ |
| 701 | (void) SyncImageSettings(mogrify_info,*image); |
| 702 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 703 | if ((flags & SigmaValue) == 0) |
| 704 | geometry_info.sigma=1.0; |
| 705 | mogrify_image=AdaptiveBlurImageChannel(*image,channel, |
| 706 | geometry_info.rho,geometry_info.sigma,exception); |
| 707 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 708 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 709 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 710 | { |
| 711 | /* |
| 712 | Adaptive resize image. |
| 713 | */ |
| 714 | (void) SyncImageSettings(mogrify_info,*image); |
| 715 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 716 | mogrify_image=AdaptiveResizeImage(*image,geometry.width, |
| 717 | geometry.height,exception); |
| 718 | break; |
| 719 | } |
| 720 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 721 | { |
| 722 | /* |
| 723 | Adaptive sharpen image. |
| 724 | */ |
| 725 | (void) SyncImageSettings(mogrify_info,*image); |
| 726 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 727 | if ((flags & SigmaValue) == 0) |
| 728 | geometry_info.sigma=1.0; |
| 729 | mogrify_image=AdaptiveSharpenImageChannel(*image,channel, |
| 730 | geometry_info.rho,geometry_info.sigma,exception); |
| 731 | break; |
| 732 | } |
| 733 | if (LocaleCompare("affine",option+1) == 0) |
| 734 | { |
| 735 | /* |
| 736 | Affine matrix. |
| 737 | */ |
| 738 | if (*option == '+') |
| 739 | { |
| 740 | GetAffineMatrix(&draw_info->affine); |
| 741 | break; |
| 742 | } |
| 743 | (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); |
| 744 | break; |
| 745 | } |
| 746 | if (LocaleCompare("alpha",option+1) == 0) |
| 747 | { |
| 748 | AlphaChannelType |
| 749 | alpha_type; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 750 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 751 | (void) SyncImageSettings(mogrify_info,*image); |
| 752 | alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions, |
| 753 | MagickFalse,argv[i+1]); |
| 754 | (void) SetImageAlphaChannel(*image,alpha_type); |
| 755 | InheritException(exception,&(*image)->exception); |
| 756 | break; |
| 757 | } |
| 758 | if (LocaleCompare("annotate",option+1) == 0) |
| 759 | { |
| 760 | char |
| 761 | *text, |
| 762 | geometry[MaxTextExtent]; |
| 763 | |
| 764 | /* |
| 765 | Annotate image. |
| 766 | */ |
| 767 | (void) SyncImageSettings(mogrify_info,*image); |
| 768 | SetGeometryInfo(&geometry_info); |
| 769 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 770 | if ((flags & SigmaValue) == 0) |
| 771 | geometry_info.sigma=geometry_info.rho; |
| 772 | text=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 773 | InheritException(exception,&(*image)->exception); |
| 774 | if (text == (char *) NULL) |
| 775 | break; |
| 776 | (void) CloneString(&draw_info->text,text); |
| 777 | text=DestroyString(text); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 778 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 779 | geometry_info.xi,geometry_info.psi); |
| 780 | (void) CloneString(&draw_info->geometry,geometry); |
| 781 | draw_info->affine.sx=cos(DegreesToRadians( |
| 782 | fmod(geometry_info.rho,360.0))); |
| 783 | draw_info->affine.rx=sin(DegreesToRadians( |
| 784 | fmod(geometry_info.rho,360.0))); |
| 785 | draw_info->affine.ry=(-sin(DegreesToRadians( |
| 786 | fmod(geometry_info.sigma,360.0)))); |
| 787 | draw_info->affine.sy=cos(DegreesToRadians( |
| 788 | fmod(geometry_info.sigma,360.0))); |
| 789 | (void) AnnotateImage(*image,draw_info); |
| 790 | InheritException(exception,&(*image)->exception); |
| 791 | break; |
| 792 | } |
| 793 | if (LocaleCompare("antialias",option+1) == 0) |
| 794 | { |
| 795 | draw_info->stroke_antialias=(*option == '-') ? MagickTrue : |
| 796 | MagickFalse; |
| 797 | draw_info->text_antialias=(*option == '-') ? MagickTrue : |
| 798 | MagickFalse; |
| 799 | break; |
| 800 | } |
| 801 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 802 | { |
| 803 | /* |
| 804 | Auto Adjust Gamma of image based on its mean |
| 805 | */ |
| 806 | (void) SyncImageSettings(mogrify_info,*image); |
| 807 | (void) AutoGammaImageChannel(*image,channel); |
| 808 | break; |
| 809 | } |
| 810 | if (LocaleCompare("auto-level",option+1) == 0) |
| 811 | { |
| 812 | /* |
| 813 | Perfectly Normalize (max/min stretch) the image |
| 814 | */ |
| 815 | (void) SyncImageSettings(mogrify_info,*image); |
| 816 | (void) AutoLevelImageChannel(*image,channel); |
| 817 | break; |
| 818 | } |
| 819 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 820 | { |
| 821 | (void) SyncImageSettings(mogrify_info,*image); |
| 822 | switch ((*image)->orientation) |
| 823 | { |
| 824 | case TopRightOrientation: |
| 825 | { |
| 826 | mogrify_image=FlopImage(*image,exception); |
| 827 | break; |
| 828 | } |
| 829 | case BottomRightOrientation: |
| 830 | { |
| 831 | mogrify_image=RotateImage(*image,180.0,exception); |
| 832 | break; |
| 833 | } |
| 834 | case BottomLeftOrientation: |
| 835 | { |
| 836 | mogrify_image=FlipImage(*image,exception); |
| 837 | break; |
| 838 | } |
| 839 | case LeftTopOrientation: |
| 840 | { |
| 841 | mogrify_image=TransposeImage(*image,exception); |
| 842 | break; |
| 843 | } |
| 844 | case RightTopOrientation: |
| 845 | { |
| 846 | mogrify_image=RotateImage(*image,90.0,exception); |
| 847 | break; |
| 848 | } |
| 849 | case RightBottomOrientation: |
| 850 | { |
| 851 | mogrify_image=TransverseImage(*image,exception); |
| 852 | break; |
| 853 | } |
| 854 | case LeftBottomOrientation: |
| 855 | { |
| 856 | mogrify_image=RotateImage(*image,270.0,exception); |
| 857 | break; |
| 858 | } |
| 859 | default: |
| 860 | break; |
| 861 | } |
| 862 | if (mogrify_image != (Image *) NULL) |
| 863 | mogrify_image->orientation=TopLeftOrientation; |
| 864 | break; |
| 865 | } |
| 866 | break; |
| 867 | } |
| 868 | case 'b': |
| 869 | { |
| 870 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 871 | { |
| 872 | /* |
| 873 | Black threshold image. |
| 874 | */ |
| 875 | (void) SyncImageSettings(mogrify_info,*image); |
| 876 | (void) BlackThresholdImageChannel(*image,channel,argv[i+1], |
| 877 | exception); |
| 878 | InheritException(exception,&(*image)->exception); |
| 879 | break; |
| 880 | } |
| 881 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 882 | { |
| 883 | /* |
| 884 | Blue shift image. |
| 885 | */ |
| 886 | (void) SyncImageSettings(mogrify_info,*image); |
| 887 | geometry_info.rho=1.5; |
| 888 | if (*option == '-') |
| 889 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 890 | mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception); |
| 891 | break; |
| 892 | } |
| 893 | if (LocaleCompare("blur",option+1) == 0) |
| 894 | { |
| 895 | /* |
| 896 | Gaussian blur image. |
| 897 | */ |
| 898 | (void) SyncImageSettings(mogrify_info,*image); |
| 899 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 900 | if ((flags & SigmaValue) == 0) |
| 901 | geometry_info.sigma=1.0; |
| 902 | mogrify_image=BlurImageChannel(*image,channel,geometry_info.rho, |
| 903 | geometry_info.sigma,exception); |
| 904 | break; |
| 905 | } |
| 906 | if (LocaleCompare("border",option+1) == 0) |
| 907 | { |
| 908 | /* |
| 909 | Surround image with a border of solid color. |
| 910 | */ |
| 911 | (void) SyncImageSettings(mogrify_info,*image); |
| 912 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 913 | if ((flags & SigmaValue) == 0) |
| 914 | geometry.height=geometry.width; |
| 915 | mogrify_image=BorderImage(*image,&geometry,exception); |
| 916 | break; |
| 917 | } |
| 918 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 919 | { |
| 920 | if (*option == '+') |
| 921 | { |
| 922 | (void) QueryColorDatabase(BorderColor,&draw_info->border_color, |
| 923 | exception); |
| 924 | break; |
| 925 | } |
| 926 | (void) QueryColorDatabase(argv[i+1],&draw_info->border_color, |
| 927 | exception); |
| 928 | break; |
| 929 | } |
| 930 | if (LocaleCompare("box",option+1) == 0) |
| 931 | { |
| 932 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 933 | exception); |
| 934 | break; |
| 935 | } |
| 936 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 937 | { |
| 938 | double |
| 939 | brightness, |
| 940 | contrast; |
| 941 | |
| 942 | GeometryInfo |
| 943 | geometry_info; |
| 944 | |
| 945 | MagickStatusType |
| 946 | flags; |
| 947 | |
| 948 | /* |
| 949 | Brightness / contrast image. |
| 950 | */ |
| 951 | (void) SyncImageSettings(mogrify_info,*image); |
| 952 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 953 | brightness=geometry_info.rho; |
| 954 | contrast=0.0; |
| 955 | if ((flags & SigmaValue) != 0) |
| 956 | contrast=geometry_info.sigma; |
| 957 | (void) BrightnessContrastImageChannel(*image,channel,brightness, |
| 958 | contrast); |
| 959 | InheritException(exception,&(*image)->exception); |
| 960 | break; |
| 961 | } |
| 962 | break; |
| 963 | } |
| 964 | case 'c': |
| 965 | { |
| 966 | if (LocaleCompare("cdl",option+1) == 0) |
| 967 | { |
| 968 | char |
| 969 | *color_correction_collection; |
| 970 | |
| 971 | /* |
| 972 | Color correct with a color decision list. |
| 973 | */ |
| 974 | (void) SyncImageSettings(mogrify_info,*image); |
| 975 | color_correction_collection=FileToString(argv[i+1],~0,exception); |
| 976 | if (color_correction_collection == (char *) NULL) |
| 977 | break; |
| 978 | (void) ColorDecisionListImage(*image,color_correction_collection); |
| 979 | InheritException(exception,&(*image)->exception); |
| 980 | break; |
| 981 | } |
| 982 | if (LocaleCompare("channel",option+1) == 0) |
| 983 | { |
| 984 | if (*option == '+') |
| 985 | channel=DefaultChannels; |
| 986 | else |
| 987 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 988 | break; |
| 989 | } |
| 990 | if (LocaleCompare("charcoal",option+1) == 0) |
| 991 | { |
| 992 | /* |
| 993 | Charcoal image. |
| 994 | */ |
| 995 | (void) SyncImageSettings(mogrify_info,*image); |
| 996 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 997 | if ((flags & SigmaValue) == 0) |
| 998 | geometry_info.sigma=1.0; |
| 999 | mogrify_image=CharcoalImage(*image,geometry_info.rho, |
| 1000 | geometry_info.sigma,exception); |
| 1001 | break; |
| 1002 | } |
| 1003 | if (LocaleCompare("chop",option+1) == 0) |
| 1004 | { |
| 1005 | /* |
| 1006 | Chop the image. |
| 1007 | */ |
| 1008 | (void) SyncImageSettings(mogrify_info,*image); |
| 1009 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1010 | mogrify_image=ChopImage(*image,&geometry,exception); |
| 1011 | break; |
| 1012 | } |
| 1013 | if (LocaleCompare("clamp",option+1) == 0) |
| 1014 | { |
| 1015 | /* |
| 1016 | Clamp image. |
| 1017 | */ |
| 1018 | (void) SyncImageSettings(mogrify_info,*image); |
| 1019 | (void) ClampImageChannel(*image,channel); |
| 1020 | InheritException(exception,&(*image)->exception); |
| 1021 | break; |
| 1022 | } |
| 1023 | if (LocaleCompare("clip",option+1) == 0) |
| 1024 | { |
| 1025 | (void) SyncImageSettings(mogrify_info,*image); |
| 1026 | if (*option == '+') |
| 1027 | { |
| 1028 | (void) SetImageClipMask(*image,(Image *) NULL); |
| 1029 | InheritException(exception,&(*image)->exception); |
| 1030 | break; |
| 1031 | } |
| 1032 | (void) ClipImage(*image); |
| 1033 | InheritException(exception,&(*image)->exception); |
| 1034 | break; |
| 1035 | } |
| 1036 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1037 | { |
| 1038 | CacheView |
| 1039 | *mask_view; |
| 1040 | |
| 1041 | Image |
| 1042 | *mask_image; |
| 1043 | |
| 1044 | register PixelPacket |
| 1045 | *restrict q; |
| 1046 | |
| 1047 | register ssize_t |
| 1048 | x; |
| 1049 | |
| 1050 | ssize_t |
| 1051 | y; |
| 1052 | |
| 1053 | (void) SyncImageSettings(mogrify_info,*image); |
| 1054 | if (*option == '+') |
| 1055 | { |
| 1056 | /* |
| 1057 | Remove a mask. |
| 1058 | */ |
| 1059 | (void) SetImageMask(*image,(Image *) NULL); |
| 1060 | InheritException(exception,&(*image)->exception); |
| 1061 | break; |
| 1062 | } |
| 1063 | /* |
| 1064 | Set the image mask. |
| 1065 | FUTURE: This Should Be a SetImageAlphaChannel() call, Or two. |
| 1066 | */ |
| 1067 | mask_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1068 | if (mask_image == (Image *) NULL) |
| 1069 | break; |
| 1070 | if (SetImageStorageClass(mask_image,DirectClass) == MagickFalse) |
| 1071 | return(MagickFalse); |
| 1072 | mask_view=AcquireCacheView(mask_image); |
| 1073 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1074 | { |
| 1075 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1076 | exception); |
| 1077 | if (q == (PixelPacket *) NULL) |
| 1078 | break; |
| 1079 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1080 | { |
| 1081 | if (mask_image->matte == MagickFalse) |
cristy | 843c172 | 2011-05-04 23:47:02 +0000 | [diff] [blame] | 1082 | SetOpacityPixelComponent(q,PixelIntensityToQuantum(q)); |
| 1083 | SetRedPixelComponent(q,GetOpacityPixelComponent(q)); |
| 1084 | SetGreenPixelComponent(q,GetOpacityPixelComponent(q)); |
| 1085 | SetBluePixelComponent(q,GetOpacityPixelComponent(q)); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1086 | q++; |
| 1087 | } |
| 1088 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
| 1089 | break; |
| 1090 | } |
| 1091 | mask_view=DestroyCacheView(mask_view); |
| 1092 | mask_image->matte=MagickTrue; |
| 1093 | (void) SetImageClipMask(*image,mask_image); |
| 1094 | mask_image=DestroyImage(mask_image); |
| 1095 | InheritException(exception,&(*image)->exception); |
| 1096 | break; |
| 1097 | } |
| 1098 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1099 | { |
| 1100 | (void) SyncImageSettings(mogrify_info,*image); |
| 1101 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
| 1102 | MagickFalse); |
| 1103 | InheritException(exception,&(*image)->exception); |
| 1104 | break; |
| 1105 | } |
| 1106 | if (LocaleCompare("colorize",option+1) == 0) |
| 1107 | { |
| 1108 | /* |
| 1109 | Colorize the image. |
| 1110 | */ |
| 1111 | (void) SyncImageSettings(mogrify_info,*image); |
| 1112 | mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill, |
| 1113 | exception); |
| 1114 | break; |
| 1115 | } |
| 1116 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1117 | { |
| 1118 | KernelInfo |
| 1119 | *kernel; |
| 1120 | |
| 1121 | (void) SyncImageSettings(mogrify_info,*image); |
| 1122 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1123 | if (kernel == (KernelInfo *) NULL) |
| 1124 | break; |
| 1125 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 1126 | kernel=DestroyKernelInfo(kernel); |
| 1127 | break; |
| 1128 | } |
| 1129 | if (LocaleCompare("colors",option+1) == 0) |
| 1130 | { |
| 1131 | /* |
| 1132 | Reduce the number of colors in the image. |
| 1133 | */ |
| 1134 | (void) SyncImageSettings(mogrify_info,*image); |
| 1135 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
| 1136 | if (quantize_info->number_colors == 0) |
| 1137 | break; |
| 1138 | if (((*image)->storage_class == DirectClass) || |
| 1139 | (*image)->colors > quantize_info->number_colors) |
| 1140 | (void) QuantizeImage(quantize_info,*image); |
| 1141 | else |
| 1142 | (void) CompressImageColormap(*image); |
| 1143 | InheritException(exception,&(*image)->exception); |
| 1144 | break; |
| 1145 | } |
| 1146 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1147 | { |
| 1148 | ColorspaceType |
| 1149 | colorspace; |
| 1150 | |
| 1151 | (void) SyncImageSettings(mogrify_info,*image); |
| 1152 | if (*option == '+') |
| 1153 | { |
| 1154 | (void) TransformImageColorspace(*image,RGBColorspace); |
| 1155 | InheritException(exception,&(*image)->exception); |
| 1156 | break; |
| 1157 | } |
| 1158 | colorspace=(ColorspaceType) ParseCommandOption( |
| 1159 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 1160 | (void) TransformImageColorspace(*image,colorspace); |
| 1161 | InheritException(exception,&(*image)->exception); |
| 1162 | break; |
| 1163 | } |
| 1164 | if (LocaleCompare("contrast",option+1) == 0) |
| 1165 | { |
| 1166 | (void) SyncImageSettings(mogrify_info,*image); |
| 1167 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
| 1168 | MagickFalse); |
| 1169 | InheritException(exception,&(*image)->exception); |
| 1170 | break; |
| 1171 | } |
| 1172 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1173 | { |
| 1174 | double |
| 1175 | black_point, |
| 1176 | white_point; |
| 1177 | |
| 1178 | MagickStatusType |
| 1179 | flags; |
| 1180 | |
| 1181 | /* |
| 1182 | Contrast stretch image. |
| 1183 | */ |
| 1184 | (void) SyncImageSettings(mogrify_info,*image); |
| 1185 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1186 | black_point=geometry_info.rho; |
| 1187 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1188 | black_point; |
| 1189 | if ((flags & PercentValue) != 0) |
| 1190 | { |
| 1191 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1192 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1193 | } |
| 1194 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1195 | white_point; |
| 1196 | (void) ContrastStretchImageChannel(*image,channel,black_point, |
| 1197 | white_point); |
| 1198 | InheritException(exception,&(*image)->exception); |
| 1199 | break; |
| 1200 | } |
| 1201 | if (LocaleCompare("convolve",option+1) == 0) |
| 1202 | { |
| 1203 | double |
| 1204 | gamma; |
| 1205 | |
| 1206 | KernelInfo |
| 1207 | *kernel; |
| 1208 | |
| 1209 | register ssize_t |
| 1210 | j; |
| 1211 | |
| 1212 | (void) SyncImageSettings(mogrify_info,*image); |
| 1213 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1214 | if (kernel == (KernelInfo *) NULL) |
| 1215 | break; |
| 1216 | gamma=0.0; |
| 1217 | for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++) |
| 1218 | gamma+=kernel->values[j]; |
| 1219 | gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma); |
| 1220 | for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++) |
| 1221 | kernel->values[j]*=gamma; |
| 1222 | mogrify_image=FilterImageChannel(*image,channel,kernel,exception); |
| 1223 | kernel=DestroyKernelInfo(kernel); |
| 1224 | break; |
| 1225 | } |
| 1226 | if (LocaleCompare("crop",option+1) == 0) |
| 1227 | { |
| 1228 | /* |
| 1229 | Crop a image to a smaller size |
| 1230 | */ |
| 1231 | (void) SyncImageSettings(mogrify_info,*image); |
| 1232 | #if 0 |
| 1233 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1234 | if (((geometry.width != 0) || (geometry.height != 0)) && |
| 1235 | ((flags & XValue) == 0) && ((flags & YValue) == 0)) |
| 1236 | break; |
| 1237 | #endif |
| 1238 | #if 0 |
| 1239 | mogrify_image=CloneImage(*image,0,0,MagickTrue,&(*image)->exception); |
| 1240 | mogrify_image->next = mogrify_image->previous = (Image *)NULL; |
| 1241 | (void) TransformImage(&mogrify_image,argv[i+1],(char *) NULL); |
| 1242 | InheritException(exception,&mogrify_image->exception); |
| 1243 | #else |
| 1244 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
| 1245 | #endif |
| 1246 | break; |
| 1247 | } |
| 1248 | if (LocaleCompare("cycle",option+1) == 0) |
| 1249 | { |
| 1250 | /* |
| 1251 | Cycle an image colormap. |
| 1252 | */ |
| 1253 | (void) SyncImageSettings(mogrify_info,*image); |
| 1254 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1])); |
| 1255 | InheritException(exception,&(*image)->exception); |
| 1256 | break; |
| 1257 | } |
| 1258 | break; |
| 1259 | } |
| 1260 | case 'd': |
| 1261 | { |
| 1262 | if (LocaleCompare("decipher",option+1) == 0) |
| 1263 | { |
| 1264 | StringInfo |
| 1265 | *passkey; |
| 1266 | |
| 1267 | /* |
| 1268 | Decipher pixels. |
| 1269 | */ |
| 1270 | (void) SyncImageSettings(mogrify_info,*image); |
| 1271 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1272 | if (passkey != (StringInfo *) NULL) |
| 1273 | { |
| 1274 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1275 | passkey=DestroyStringInfo(passkey); |
| 1276 | } |
| 1277 | break; |
| 1278 | } |
| 1279 | if (LocaleCompare("density",option+1) == 0) |
| 1280 | { |
| 1281 | /* |
| 1282 | Set image density. |
| 1283 | */ |
| 1284 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1285 | break; |
| 1286 | } |
| 1287 | if (LocaleCompare("depth",option+1) == 0) |
| 1288 | { |
| 1289 | (void) SyncImageSettings(mogrify_info,*image); |
| 1290 | if (*option == '+') |
| 1291 | { |
| 1292 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH); |
| 1293 | break; |
| 1294 | } |
| 1295 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1])); |
| 1296 | break; |
| 1297 | } |
| 1298 | if (LocaleCompare("deskew",option+1) == 0) |
| 1299 | { |
| 1300 | double |
| 1301 | threshold; |
| 1302 | |
| 1303 | /* |
| 1304 | Straighten the image. |
| 1305 | */ |
| 1306 | (void) SyncImageSettings(mogrify_info,*image); |
| 1307 | if (*option == '+') |
| 1308 | threshold=40.0*QuantumRange/100.0; |
| 1309 | else |
| 1310 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 1311 | mogrify_image=DeskewImage(*image,threshold,exception); |
| 1312 | break; |
| 1313 | } |
| 1314 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1315 | { |
| 1316 | /* |
| 1317 | Reduce the speckles within an image. |
| 1318 | */ |
| 1319 | (void) SyncImageSettings(mogrify_info,*image); |
| 1320 | mogrify_image=DespeckleImage(*image,exception); |
| 1321 | break; |
| 1322 | } |
| 1323 | if (LocaleCompare("display",option+1) == 0) |
| 1324 | { |
| 1325 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1326 | break; |
| 1327 | } |
| 1328 | if (LocaleCompare("distort",option+1) == 0) |
| 1329 | { |
| 1330 | char |
| 1331 | *args, |
| 1332 | token[MaxTextExtent]; |
| 1333 | |
| 1334 | const char |
| 1335 | *p; |
| 1336 | |
| 1337 | DistortImageMethod |
| 1338 | method; |
| 1339 | |
| 1340 | double |
| 1341 | *arguments; |
| 1342 | |
| 1343 | register ssize_t |
| 1344 | x; |
| 1345 | |
| 1346 | size_t |
| 1347 | number_arguments; |
| 1348 | |
| 1349 | /* |
| 1350 | Distort image. |
| 1351 | */ |
| 1352 | (void) SyncImageSettings(mogrify_info,*image); |
| 1353 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, |
| 1354 | MagickFalse,argv[i+1]); |
| 1355 | if ( method == ResizeDistortion ) |
| 1356 | { |
| 1357 | /* Special Case - Argument is actually a resize geometry! |
| 1358 | ** Convert that to an appropriate distortion argument array. |
| 1359 | */ |
| 1360 | double |
| 1361 | resize_args[2]; |
| 1362 | (void) ParseRegionGeometry(*image,argv[i+2],&geometry, |
| 1363 | exception); |
| 1364 | resize_args[0]=(double)geometry.width; |
| 1365 | resize_args[1]=(double)geometry.height; |
| 1366 | mogrify_image=DistortImage(*image,method,(size_t)2, |
| 1367 | resize_args,MagickTrue,exception); |
| 1368 | break; |
| 1369 | } |
| 1370 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 1371 | InheritException(exception,&(*image)->exception); |
| 1372 | if (args == (char *) NULL) |
| 1373 | break; |
| 1374 | p=(char *) args; |
| 1375 | for (x=0; *p != '\0'; x++) |
| 1376 | { |
| 1377 | GetMagickToken(p,&p,token); |
| 1378 | if (*token == ',') |
| 1379 | GetMagickToken(p,&p,token); |
| 1380 | } |
| 1381 | number_arguments=(size_t) x; |
| 1382 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1383 | sizeof(*arguments)); |
| 1384 | if (arguments == (double *) NULL) |
| 1385 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1386 | "MemoryAllocationFailed",(*image)->filename); |
| 1387 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1388 | sizeof(*arguments)); |
| 1389 | p=(char *) args; |
| 1390 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 1391 | { |
| 1392 | GetMagickToken(p,&p,token); |
| 1393 | if (*token == ',') |
| 1394 | GetMagickToken(p,&p,token); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 1395 | arguments[x]=LocaleToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1396 | } |
| 1397 | args=DestroyString(args); |
| 1398 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
| 1399 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1400 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1401 | break; |
| 1402 | } |
| 1403 | if (LocaleCompare("dither",option+1) == 0) |
| 1404 | { |
| 1405 | if (*option == '+') |
| 1406 | { |
| 1407 | quantize_info->dither=MagickFalse; |
| 1408 | break; |
| 1409 | } |
| 1410 | quantize_info->dither=MagickTrue; |
| 1411 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
| 1412 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1413 | if (quantize_info->dither_method == NoDitherMethod) |
| 1414 | quantize_info->dither=MagickFalse; |
| 1415 | break; |
| 1416 | } |
| 1417 | if (LocaleCompare("draw",option+1) == 0) |
| 1418 | { |
| 1419 | /* |
| 1420 | Draw image. |
| 1421 | */ |
| 1422 | (void) SyncImageSettings(mogrify_info,*image); |
| 1423 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
| 1424 | (void) DrawImage(*image,draw_info); |
| 1425 | InheritException(exception,&(*image)->exception); |
| 1426 | break; |
| 1427 | } |
| 1428 | break; |
| 1429 | } |
| 1430 | case 'e': |
| 1431 | { |
| 1432 | if (LocaleCompare("edge",option+1) == 0) |
| 1433 | { |
| 1434 | /* |
| 1435 | Enhance edges in the image. |
| 1436 | */ |
| 1437 | (void) SyncImageSettings(mogrify_info,*image); |
| 1438 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1439 | if ((flags & SigmaValue) == 0) |
| 1440 | geometry_info.sigma=1.0; |
| 1441 | mogrify_image=EdgeImage(*image,geometry_info.rho,exception); |
| 1442 | break; |
| 1443 | } |
| 1444 | if (LocaleCompare("emboss",option+1) == 0) |
| 1445 | { |
| 1446 | /* |
| 1447 | Gaussian embossen image. |
| 1448 | */ |
| 1449 | (void) SyncImageSettings(mogrify_info,*image); |
| 1450 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1451 | if ((flags & SigmaValue) == 0) |
| 1452 | geometry_info.sigma=1.0; |
| 1453 | mogrify_image=EmbossImage(*image,geometry_info.rho, |
| 1454 | geometry_info.sigma,exception); |
| 1455 | break; |
| 1456 | } |
| 1457 | if (LocaleCompare("encipher",option+1) == 0) |
| 1458 | { |
| 1459 | StringInfo |
| 1460 | *passkey; |
| 1461 | |
| 1462 | /* |
| 1463 | Encipher pixels. |
| 1464 | */ |
| 1465 | (void) SyncImageSettings(mogrify_info,*image); |
| 1466 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1467 | if (passkey != (StringInfo *) NULL) |
| 1468 | { |
| 1469 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1470 | passkey=DestroyStringInfo(passkey); |
| 1471 | } |
| 1472 | break; |
| 1473 | } |
| 1474 | if (LocaleCompare("encoding",option+1) == 0) |
| 1475 | { |
| 1476 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1477 | break; |
| 1478 | } |
| 1479 | if (LocaleCompare("enhance",option+1) == 0) |
| 1480 | { |
| 1481 | /* |
| 1482 | Enhance image. |
| 1483 | */ |
| 1484 | (void) SyncImageSettings(mogrify_info,*image); |
| 1485 | mogrify_image=EnhanceImage(*image,exception); |
| 1486 | break; |
| 1487 | } |
| 1488 | if (LocaleCompare("equalize",option+1) == 0) |
| 1489 | { |
| 1490 | /* |
| 1491 | Equalize image. |
| 1492 | */ |
| 1493 | (void) SyncImageSettings(mogrify_info,*image); |
| 1494 | (void) EqualizeImageChannel(*image,channel); |
| 1495 | InheritException(exception,&(*image)->exception); |
| 1496 | break; |
| 1497 | } |
| 1498 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1499 | { |
| 1500 | double |
| 1501 | constant; |
| 1502 | |
| 1503 | MagickEvaluateOperator |
| 1504 | op; |
| 1505 | |
| 1506 | (void) SyncImageSettings(mogrify_info,*image); |
| 1507 | op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions, |
| 1508 | MagickFalse,argv[i+1]); |
| 1509 | constant=SiPrefixToDouble(argv[i+2],QuantumRange); |
| 1510 | (void) EvaluateImageChannel(*image,channel,op,constant,exception); |
| 1511 | break; |
| 1512 | } |
| 1513 | if (LocaleCompare("extent",option+1) == 0) |
| 1514 | { |
| 1515 | /* |
| 1516 | Set the image extent. |
| 1517 | */ |
| 1518 | (void) SyncImageSettings(mogrify_info,*image); |
| 1519 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1520 | if (geometry.width == 0) |
| 1521 | geometry.width=(*image)->columns; |
| 1522 | if (geometry.height == 0) |
| 1523 | geometry.height=(*image)->rows; |
| 1524 | mogrify_image=ExtentImage(*image,&geometry,exception); |
| 1525 | break; |
| 1526 | } |
| 1527 | break; |
| 1528 | } |
| 1529 | case 'f': |
| 1530 | { |
| 1531 | if (LocaleCompare("family",option+1) == 0) |
| 1532 | { |
| 1533 | if (*option == '+') |
| 1534 | { |
| 1535 | if (draw_info->family != (char *) NULL) |
| 1536 | draw_info->family=DestroyString(draw_info->family); |
| 1537 | break; |
| 1538 | } |
| 1539 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1540 | break; |
| 1541 | } |
| 1542 | if (LocaleCompare("features",option+1) == 0) |
| 1543 | { |
| 1544 | if (*option == '+') |
| 1545 | { |
| 1546 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1547 | break; |
| 1548 | } |
| 1549 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1550 | break; |
| 1551 | } |
| 1552 | if (LocaleCompare("fill",option+1) == 0) |
| 1553 | { |
| 1554 | ExceptionInfo |
| 1555 | *sans; |
| 1556 | |
| 1557 | GetMagickPixelPacket(*image,&fill); |
| 1558 | if (*option == '+') |
| 1559 | { |
| 1560 | (void) QueryMagickColor("none",&fill,exception); |
| 1561 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 1562 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1563 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1564 | break; |
| 1565 | } |
| 1566 | sans=AcquireExceptionInfo(); |
| 1567 | (void) QueryMagickColor(argv[i+1],&fill,sans); |
| 1568 | status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans); |
| 1569 | sans=DestroyExceptionInfo(sans); |
| 1570 | if (status == MagickFalse) |
| 1571 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 1572 | exception); |
| 1573 | break; |
| 1574 | } |
| 1575 | if (LocaleCompare("flip",option+1) == 0) |
| 1576 | { |
| 1577 | /* |
| 1578 | Flip image scanlines. |
| 1579 | */ |
| 1580 | (void) SyncImageSettings(mogrify_info,*image); |
| 1581 | mogrify_image=FlipImage(*image,exception); |
| 1582 | break; |
| 1583 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1584 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1585 | { |
| 1586 | MagickPixelPacket |
| 1587 | target; |
| 1588 | |
| 1589 | /* |
| 1590 | Floodfill image. |
| 1591 | */ |
| 1592 | (void) SyncImageSettings(mogrify_info,*image); |
| 1593 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1594 | (void) QueryMagickColor(argv[i+2],&target,exception); |
| 1595 | (void) FloodfillPaintImage(*image,channel,draw_info,&target, |
| 1596 | geometry.x,geometry.y,*option == '-' ? MagickFalse : MagickTrue); |
| 1597 | InheritException(exception,&(*image)->exception); |
| 1598 | break; |
| 1599 | } |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1600 | if (LocaleCompare("flop",option+1) == 0) |
| 1601 | { |
| 1602 | /* |
| 1603 | Flop image scanlines. |
| 1604 | */ |
| 1605 | (void) SyncImageSettings(mogrify_info,*image); |
| 1606 | mogrify_image=FlopImage(*image,exception); |
| 1607 | break; |
| 1608 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1609 | if (LocaleCompare("font",option+1) == 0) |
| 1610 | { |
| 1611 | if (*option == '+') |
| 1612 | { |
| 1613 | if (draw_info->font != (char *) NULL) |
| 1614 | draw_info->font=DestroyString(draw_info->font); |
| 1615 | break; |
| 1616 | } |
| 1617 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1618 | break; |
| 1619 | } |
| 1620 | if (LocaleCompare("format",option+1) == 0) |
| 1621 | { |
| 1622 | format=argv[i+1]; |
| 1623 | break; |
| 1624 | } |
| 1625 | if (LocaleCompare("frame",option+1) == 0) |
| 1626 | { |
| 1627 | FrameInfo |
| 1628 | frame_info; |
| 1629 | |
| 1630 | /* |
| 1631 | Surround image with an ornamental border. |
| 1632 | */ |
| 1633 | (void) SyncImageSettings(mogrify_info,*image); |
| 1634 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1635 | frame_info.width=geometry.width; |
| 1636 | frame_info.height=geometry.height; |
| 1637 | if ((flags & HeightValue) == 0) |
| 1638 | frame_info.height=geometry.width; |
| 1639 | frame_info.outer_bevel=geometry.x; |
| 1640 | frame_info.inner_bevel=geometry.y; |
| 1641 | frame_info.x=(ssize_t) frame_info.width; |
| 1642 | frame_info.y=(ssize_t) frame_info.height; |
| 1643 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1644 | frame_info.height=(*image)->rows+2*frame_info.height; |
| 1645 | mogrify_image=FrameImage(*image,&frame_info,exception); |
| 1646 | break; |
| 1647 | } |
| 1648 | if (LocaleCompare("function",option+1) == 0) |
| 1649 | { |
| 1650 | char |
| 1651 | *arguments, |
| 1652 | token[MaxTextExtent]; |
| 1653 | |
| 1654 | const char |
| 1655 | *p; |
| 1656 | |
| 1657 | double |
| 1658 | *parameters; |
| 1659 | |
| 1660 | MagickFunction |
| 1661 | function; |
| 1662 | |
| 1663 | register ssize_t |
| 1664 | x; |
| 1665 | |
| 1666 | size_t |
| 1667 | number_parameters; |
| 1668 | |
| 1669 | /* |
| 1670 | Function Modify Image Values |
| 1671 | */ |
| 1672 | (void) SyncImageSettings(mogrify_info,*image); |
| 1673 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, |
| 1674 | MagickFalse,argv[i+1]); |
| 1675 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 1676 | InheritException(exception,&(*image)->exception); |
| 1677 | if (arguments == (char *) NULL) |
| 1678 | break; |
| 1679 | p=(char *) arguments; |
| 1680 | for (x=0; *p != '\0'; x++) |
| 1681 | { |
| 1682 | GetMagickToken(p,&p,token); |
| 1683 | if (*token == ',') |
| 1684 | GetMagickToken(p,&p,token); |
| 1685 | } |
| 1686 | number_parameters=(size_t) x; |
| 1687 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1688 | sizeof(*parameters)); |
| 1689 | if (parameters == (double *) NULL) |
| 1690 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1691 | "MemoryAllocationFailed",(*image)->filename); |
| 1692 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1693 | sizeof(*parameters)); |
| 1694 | p=(char *) arguments; |
| 1695 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
| 1696 | { |
| 1697 | GetMagickToken(p,&p,token); |
| 1698 | if (*token == ',') |
| 1699 | GetMagickToken(p,&p,token); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 1700 | parameters[x]=LocaleToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1701 | } |
| 1702 | arguments=DestroyString(arguments); |
| 1703 | (void) FunctionImageChannel(*image,channel,function, |
| 1704 | number_parameters,parameters,exception); |
| 1705 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1706 | break; |
| 1707 | } |
| 1708 | break; |
| 1709 | } |
| 1710 | case 'g': |
| 1711 | { |
| 1712 | if (LocaleCompare("gamma",option+1) == 0) |
| 1713 | { |
| 1714 | /* |
| 1715 | Gamma image. |
| 1716 | */ |
| 1717 | (void) SyncImageSettings(mogrify_info,*image); |
| 1718 | if (*option == '+') |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 1719 | (*image)->gamma=LocaleToDouble(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1720 | else |
| 1721 | { |
| 1722 | if (strchr(argv[i+1],',') != (char *) NULL) |
| 1723 | (void) GammaImage(*image,argv[i+1]); |
| 1724 | else |
| 1725 | (void) GammaImageChannel(*image,channel, |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 1726 | LocaleToDouble(argv[i+1],(char **) NULL)); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1727 | InheritException(exception,&(*image)->exception); |
| 1728 | } |
| 1729 | break; |
| 1730 | } |
| 1731 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1732 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1733 | { |
| 1734 | /* |
| 1735 | Gaussian blur image. |
| 1736 | */ |
| 1737 | (void) SyncImageSettings(mogrify_info,*image); |
| 1738 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1739 | if ((flags & SigmaValue) == 0) |
| 1740 | geometry_info.sigma=1.0; |
| 1741 | mogrify_image=GaussianBlurImageChannel(*image,channel, |
| 1742 | geometry_info.rho,geometry_info.sigma,exception); |
| 1743 | break; |
| 1744 | } |
| 1745 | if (LocaleCompare("geometry",option+1) == 0) |
| 1746 | { |
| 1747 | /* |
| 1748 | Record Image offset, Resize last image. |
| 1749 | */ |
| 1750 | (void) SyncImageSettings(mogrify_info,*image); |
| 1751 | if (*option == '+') |
| 1752 | { |
| 1753 | if ((*image)->geometry != (char *) NULL) |
| 1754 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1755 | break; |
| 1756 | } |
| 1757 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1758 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1759 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1760 | else |
| 1761 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 1762 | (*image)->filter,(*image)->blur,exception); |
| 1763 | break; |
| 1764 | } |
| 1765 | if (LocaleCompare("gravity",option+1) == 0) |
| 1766 | { |
| 1767 | if (*option == '+') |
| 1768 | { |
| 1769 | draw_info->gravity=UndefinedGravity; |
| 1770 | break; |
| 1771 | } |
| 1772 | draw_info->gravity=(GravityType) ParseCommandOption( |
| 1773 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1774 | break; |
| 1775 | } |
| 1776 | break; |
| 1777 | } |
| 1778 | case 'h': |
| 1779 | { |
| 1780 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1781 | { |
| 1782 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1783 | break; |
| 1784 | } |
| 1785 | break; |
| 1786 | } |
| 1787 | case 'i': |
| 1788 | { |
| 1789 | if (LocaleCompare("identify",option+1) == 0) |
| 1790 | { |
| 1791 | char |
| 1792 | *text; |
| 1793 | |
| 1794 | (void) SyncImageSettings(mogrify_info,*image); |
| 1795 | if (format == (char *) NULL) |
| 1796 | { |
| 1797 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose); |
| 1798 | InheritException(exception,&(*image)->exception); |
| 1799 | break; |
| 1800 | } |
| 1801 | text=InterpretImageProperties(mogrify_info,*image,format); |
| 1802 | InheritException(exception,&(*image)->exception); |
| 1803 | if (text == (char *) NULL) |
| 1804 | break; |
| 1805 | (void) fputs(text,stdout); |
| 1806 | (void) fputc('\n',stdout); |
| 1807 | text=DestroyString(text); |
| 1808 | break; |
| 1809 | } |
| 1810 | if (LocaleCompare("implode",option+1) == 0) |
| 1811 | { |
| 1812 | /* |
| 1813 | Implode image. |
| 1814 | */ |
| 1815 | (void) SyncImageSettings(mogrify_info,*image); |
| 1816 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1817 | mogrify_image=ImplodeImage(*image,geometry_info.rho,exception); |
| 1818 | break; |
| 1819 | } |
| 1820 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1821 | { |
| 1822 | if (*option == '+') |
| 1823 | (void) ParseGeometry("0",&geometry_info); |
| 1824 | else |
| 1825 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1826 | draw_info->interline_spacing=geometry_info.rho; |
| 1827 | break; |
| 1828 | } |
| 1829 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1830 | { |
| 1831 | if (*option == '+') |
| 1832 | (void) ParseGeometry("0",&geometry_info); |
| 1833 | else |
| 1834 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1835 | draw_info->interword_spacing=geometry_info.rho; |
| 1836 | break; |
| 1837 | } |
| 1838 | break; |
| 1839 | } |
| 1840 | case 'k': |
| 1841 | { |
| 1842 | if (LocaleCompare("kerning",option+1) == 0) |
| 1843 | { |
| 1844 | if (*option == '+') |
| 1845 | (void) ParseGeometry("0",&geometry_info); |
| 1846 | else |
| 1847 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1848 | draw_info->kerning=geometry_info.rho; |
| 1849 | break; |
| 1850 | } |
| 1851 | break; |
| 1852 | } |
| 1853 | case 'l': |
| 1854 | { |
| 1855 | if (LocaleCompare("lat",option+1) == 0) |
| 1856 | { |
| 1857 | /* |
| 1858 | Local adaptive threshold image. |
| 1859 | */ |
| 1860 | (void) SyncImageSettings(mogrify_info,*image); |
| 1861 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1862 | if ((flags & PercentValue) != 0) |
| 1863 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 1864 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
| 1865 | geometry_info.rho,(size_t) geometry_info.sigma,(ssize_t) |
| 1866 | geometry_info.xi,exception); |
| 1867 | break; |
| 1868 | } |
| 1869 | if (LocaleCompare("level",option+1) == 0) |
| 1870 | { |
| 1871 | MagickRealType |
| 1872 | black_point, |
| 1873 | gamma, |
| 1874 | white_point; |
| 1875 | |
| 1876 | MagickStatusType |
| 1877 | flags; |
| 1878 | |
| 1879 | /* |
| 1880 | Parse levels. |
| 1881 | */ |
| 1882 | (void) SyncImageSettings(mogrify_info,*image); |
| 1883 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1884 | black_point=geometry_info.rho; |
| 1885 | white_point=(MagickRealType) QuantumRange; |
| 1886 | if ((flags & SigmaValue) != 0) |
| 1887 | white_point=geometry_info.sigma; |
| 1888 | gamma=1.0; |
| 1889 | if ((flags & XiValue) != 0) |
| 1890 | gamma=geometry_info.xi; |
| 1891 | if ((flags & PercentValue) != 0) |
| 1892 | { |
| 1893 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 1894 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 1895 | } |
| 1896 | if ((flags & SigmaValue) == 0) |
| 1897 | white_point=(MagickRealType) QuantumRange-black_point; |
| 1898 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
| 1899 | (void) LevelizeImageChannel(*image,channel,black_point, |
| 1900 | white_point,gamma); |
| 1901 | else |
| 1902 | (void) LevelImageChannel(*image,channel,black_point,white_point, |
| 1903 | gamma); |
| 1904 | InheritException(exception,&(*image)->exception); |
| 1905 | break; |
| 1906 | } |
| 1907 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1908 | { |
| 1909 | char |
| 1910 | token[MaxTextExtent]; |
| 1911 | |
| 1912 | const char |
| 1913 | *p; |
| 1914 | |
| 1915 | MagickPixelPacket |
| 1916 | black_point, |
| 1917 | white_point; |
| 1918 | |
| 1919 | p=(const char *) argv[i+1]; |
| 1920 | GetMagickToken(p,&p,token); /* get black point color */ |
| 1921 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1922 | (void) QueryMagickColor(token,&black_point,exception); |
| 1923 | else |
| 1924 | (void) QueryMagickColor("#000000",&black_point,exception); |
| 1925 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1926 | GetMagickToken(p,&p,token); |
| 1927 | if (*token == '\0') |
| 1928 | white_point=black_point; /* set everything to that color */ |
| 1929 | else |
| 1930 | { |
| 1931 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 1932 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 1933 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1934 | (void) QueryMagickColor(token,&white_point,exception); |
| 1935 | else |
| 1936 | (void) QueryMagickColor("#ffffff",&white_point,exception); |
| 1937 | } |
| 1938 | (void) LevelColorsImageChannel(*image,channel,&black_point, |
| 1939 | &white_point,*option == '+' ? MagickTrue : MagickFalse); |
| 1940 | break; |
| 1941 | } |
| 1942 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 1943 | { |
| 1944 | double |
| 1945 | black_point, |
| 1946 | white_point; |
| 1947 | |
| 1948 | MagickStatusType |
| 1949 | flags; |
| 1950 | |
| 1951 | (void) SyncImageSettings(mogrify_info,*image); |
| 1952 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1953 | black_point=geometry_info.rho; |
| 1954 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 1955 | if ((flags & SigmaValue) != 0) |
| 1956 | white_point=geometry_info.sigma; |
| 1957 | if ((flags & PercentValue) != 0) |
| 1958 | { |
| 1959 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1960 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1961 | } |
| 1962 | if ((flags & SigmaValue) == 0) |
| 1963 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1964 | black_point; |
| 1965 | (void) LinearStretchImage(*image,black_point,white_point); |
| 1966 | InheritException(exception,&(*image)->exception); |
| 1967 | break; |
| 1968 | } |
| 1969 | if (LocaleCompare("linewidth",option+1) == 0) |
| 1970 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 1971 | draw_info->stroke_width=LocaleToDouble(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1972 | break; |
| 1973 | } |
| 1974 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 1975 | { |
| 1976 | /* |
| 1977 | Liquid rescale image. |
| 1978 | */ |
| 1979 | (void) SyncImageSettings(mogrify_info,*image); |
| 1980 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1981 | if ((flags & XValue) == 0) |
| 1982 | geometry.x=1; |
| 1983 | if ((flags & YValue) == 0) |
| 1984 | geometry.y=0; |
| 1985 | mogrify_image=LiquidRescaleImage(*image,geometry.width, |
| 1986 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 1987 | break; |
| 1988 | } |
| 1989 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 1990 | { |
| 1991 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1992 | break; |
| 1993 | } |
| 1994 | break; |
| 1995 | } |
| 1996 | case 'm': |
| 1997 | { |
| 1998 | if (LocaleCompare("map",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1999 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2000 | Image |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2001 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2002 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2003 | /* |
| 2004 | Transform image colors to match this set of colors. |
| 2005 | */ |
| 2006 | (void) SyncImageSettings(mogrify_info,*image); |
| 2007 | if (*option == '+') |
| 2008 | break; |
| 2009 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2010 | if (remap_image == (Image *) NULL) |
| 2011 | break; |
| 2012 | (void) RemapImage(quantize_info,*image,remap_image); |
| 2013 | InheritException(exception,&(*image)->exception); |
| 2014 | remap_image=DestroyImage(remap_image); |
| 2015 | break; |
| 2016 | } |
| 2017 | if (LocaleCompare("mask",option+1) == 0) |
| 2018 | { |
| 2019 | Image |
| 2020 | *mask; |
| 2021 | |
| 2022 | (void) SyncImageSettings(mogrify_info,*image); |
| 2023 | if (*option == '+') |
| 2024 | { |
| 2025 | /* |
| 2026 | Remove a mask. |
| 2027 | */ |
| 2028 | (void) SetImageMask(*image,(Image *) NULL); |
| 2029 | InheritException(exception,&(*image)->exception); |
| 2030 | break; |
| 2031 | } |
| 2032 | /* |
| 2033 | Set the image mask. |
| 2034 | */ |
| 2035 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2036 | if (mask == (Image *) NULL) |
| 2037 | break; |
| 2038 | (void) SetImageMask(*image,mask); |
| 2039 | mask=DestroyImage(mask); |
| 2040 | InheritException(exception,&(*image)->exception); |
| 2041 | break; |
| 2042 | } |
| 2043 | if (LocaleCompare("matte",option+1) == 0) |
| 2044 | { |
| 2045 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
| 2046 | SetAlphaChannel : DeactivateAlphaChannel ); |
| 2047 | InheritException(exception,&(*image)->exception); |
| 2048 | break; |
| 2049 | } |
| 2050 | if (LocaleCompare("median",option+1) == 0) |
| 2051 | { |
| 2052 | /* |
| 2053 | Median filter image. |
| 2054 | */ |
| 2055 | (void) SyncImageSettings(mogrify_info,*image); |
| 2056 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2057 | mogrify_image=StatisticImageChannel(*image,channel,MedianStatistic, |
| 2058 | (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception); |
| 2059 | break; |
| 2060 | } |
| 2061 | if (LocaleCompare("mode",option+1) == 0) |
| 2062 | { |
| 2063 | /* |
| 2064 | Mode image. |
| 2065 | */ |
| 2066 | (void) SyncImageSettings(mogrify_info,*image); |
| 2067 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2068 | mogrify_image=StatisticImageChannel(*image,channel,ModeStatistic, |
| 2069 | (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception); |
| 2070 | break; |
| 2071 | } |
| 2072 | if (LocaleCompare("modulate",option+1) == 0) |
| 2073 | { |
| 2074 | (void) SyncImageSettings(mogrify_info,*image); |
| 2075 | (void) ModulateImage(*image,argv[i+1]); |
| 2076 | InheritException(exception,&(*image)->exception); |
| 2077 | break; |
| 2078 | } |
| 2079 | if (LocaleCompare("monitor",option+1) == 0) |
| 2080 | { |
| 2081 | if (*option == '+') |
| 2082 | { |
| 2083 | (void) SetImageProgressMonitor(*image, |
| 2084 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2085 | break; |
| 2086 | } |
| 2087 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2088 | (void *) NULL); |
| 2089 | break; |
| 2090 | } |
| 2091 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2092 | { |
| 2093 | (void) SyncImageSettings(mogrify_info,*image); |
| 2094 | (void) SetImageType(*image,BilevelType); |
| 2095 | InheritException(exception,&(*image)->exception); |
| 2096 | break; |
| 2097 | } |
| 2098 | if (LocaleCompare("morphology",option+1) == 0) |
| 2099 | { |
| 2100 | char |
| 2101 | token[MaxTextExtent]; |
| 2102 | |
| 2103 | const char |
| 2104 | *p; |
| 2105 | |
| 2106 | KernelInfo |
| 2107 | *kernel; |
| 2108 | |
| 2109 | MorphologyMethod |
| 2110 | method; |
| 2111 | |
| 2112 | ssize_t |
| 2113 | iterations; |
| 2114 | |
| 2115 | /* |
| 2116 | Morphological Image Operation |
| 2117 | */ |
| 2118 | (void) SyncImageSettings(mogrify_info,*image); |
| 2119 | p=argv[i+1]; |
| 2120 | GetMagickToken(p,&p,token); |
| 2121 | method=(MorphologyMethod) ParseCommandOption(MagickMorphologyOptions, |
| 2122 | MagickFalse,token); |
| 2123 | iterations=1L; |
| 2124 | GetMagickToken(p,&p,token); |
| 2125 | if ((*p == ':') || (*p == ',')) |
| 2126 | GetMagickToken(p,&p,token); |
| 2127 | if ((*p != '\0')) |
| 2128 | iterations=(ssize_t) StringToLong(p); |
| 2129 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2130 | if (kernel == (KernelInfo *) NULL) |
| 2131 | { |
| 2132 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2133 | OptionError,"UnabletoParseKernel","morphology"); |
| 2134 | status=MagickFalse; |
| 2135 | break; |
| 2136 | } |
| 2137 | mogrify_image=MorphologyImageChannel(*image,channel,method, |
| 2138 | iterations,kernel,exception); |
| 2139 | kernel=DestroyKernelInfo(kernel); |
| 2140 | break; |
| 2141 | } |
| 2142 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2143 | { |
| 2144 | /* |
| 2145 | Motion blur image. |
| 2146 | */ |
| 2147 | (void) SyncImageSettings(mogrify_info,*image); |
| 2148 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2149 | if ((flags & SigmaValue) == 0) |
| 2150 | geometry_info.sigma=1.0; |
| 2151 | mogrify_image=MotionBlurImageChannel(*image,channel, |
| 2152 | geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception); |
| 2153 | break; |
| 2154 | } |
| 2155 | break; |
| 2156 | } |
| 2157 | case 'n': |
| 2158 | { |
| 2159 | if (LocaleCompare("negate",option+1) == 0) |
| 2160 | { |
| 2161 | (void) SyncImageSettings(mogrify_info,*image); |
| 2162 | (void) NegateImageChannel(*image,channel,*option == '+' ? |
| 2163 | MagickTrue : MagickFalse); |
| 2164 | InheritException(exception,&(*image)->exception); |
| 2165 | break; |
| 2166 | } |
| 2167 | if (LocaleCompare("noise",option+1) == 0) |
| 2168 | { |
| 2169 | (void) SyncImageSettings(mogrify_info,*image); |
| 2170 | if (*option == '-') |
| 2171 | { |
| 2172 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2173 | mogrify_image=StatisticImageChannel(*image,channel, |
| 2174 | NonpeakStatistic,(size_t) geometry_info.rho,(size_t) |
| 2175 | geometry_info.rho,exception); |
| 2176 | } |
| 2177 | else |
| 2178 | { |
| 2179 | NoiseType |
| 2180 | noise; |
| 2181 | |
| 2182 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
| 2183 | MagickFalse,argv[i+1]); |
| 2184 | mogrify_image=AddNoiseImageChannel(*image,channel,noise, |
| 2185 | exception); |
| 2186 | } |
| 2187 | break; |
| 2188 | } |
| 2189 | if (LocaleCompare("normalize",option+1) == 0) |
| 2190 | { |
| 2191 | (void) SyncImageSettings(mogrify_info,*image); |
| 2192 | (void) NormalizeImageChannel(*image,channel); |
| 2193 | InheritException(exception,&(*image)->exception); |
| 2194 | break; |
| 2195 | } |
| 2196 | break; |
| 2197 | } |
| 2198 | case 'o': |
| 2199 | { |
| 2200 | if (LocaleCompare("opaque",option+1) == 0) |
| 2201 | { |
| 2202 | MagickPixelPacket |
| 2203 | target; |
| 2204 | |
| 2205 | (void) SyncImageSettings(mogrify_info,*image); |
| 2206 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2207 | (void) OpaquePaintImageChannel(*image,channel,&target,&fill, |
| 2208 | *option == '-' ? MagickFalse : MagickTrue); |
| 2209 | break; |
| 2210 | } |
| 2211 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2212 | { |
| 2213 | (void) SyncImageSettings(mogrify_info,*image); |
| 2214 | (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1], |
| 2215 | exception); |
| 2216 | break; |
| 2217 | } |
| 2218 | break; |
| 2219 | } |
| 2220 | case 'p': |
| 2221 | { |
| 2222 | if (LocaleCompare("paint",option+1) == 0) |
| 2223 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2224 | (void) SyncImageSettings(mogrify_info,*image); |
| 2225 | (void) ParseGeometry(argv[i+1],&geometry_info); |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 2226 | mogrify_image=OilPaintImage(*image,geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2227 | break; |
| 2228 | } |
| 2229 | if (LocaleCompare("pen",option+1) == 0) |
| 2230 | { |
| 2231 | if (*option == '+') |
| 2232 | { |
| 2233 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 2234 | break; |
| 2235 | } |
| 2236 | (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception); |
| 2237 | break; |
| 2238 | } |
| 2239 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2240 | { |
| 2241 | if (*option == '+') |
| 2242 | (void) ParseGeometry("12",&geometry_info); |
| 2243 | else |
| 2244 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2245 | draw_info->pointsize=geometry_info.rho; |
| 2246 | break; |
| 2247 | } |
| 2248 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2249 | { |
| 2250 | double |
| 2251 | angle; |
| 2252 | |
| 2253 | RandomInfo |
| 2254 | *random_info; |
| 2255 | |
| 2256 | /* |
| 2257 | Simulate a Polaroid picture. |
| 2258 | */ |
| 2259 | (void) SyncImageSettings(mogrify_info,*image); |
| 2260 | random_info=AcquireRandomInfo(); |
| 2261 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2262 | random_info=DestroyRandomInfo(random_info); |
| 2263 | if (*option == '-') |
| 2264 | { |
| 2265 | SetGeometryInfo(&geometry_info); |
| 2266 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2267 | angle=geometry_info.rho; |
| 2268 | } |
| 2269 | mogrify_image=PolaroidImage(*image,draw_info,angle,exception); |
| 2270 | break; |
| 2271 | } |
| 2272 | if (LocaleCompare("posterize",option+1) == 0) |
| 2273 | { |
| 2274 | /* |
| 2275 | Posterize image. |
| 2276 | */ |
| 2277 | (void) SyncImageSettings(mogrify_info,*image); |
| 2278 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
| 2279 | quantize_info->dither); |
| 2280 | InheritException(exception,&(*image)->exception); |
| 2281 | break; |
| 2282 | } |
| 2283 | if (LocaleCompare("preview",option+1) == 0) |
| 2284 | { |
| 2285 | PreviewType |
| 2286 | preview_type; |
| 2287 | |
| 2288 | /* |
| 2289 | Preview image. |
| 2290 | */ |
| 2291 | (void) SyncImageSettings(mogrify_info,*image); |
| 2292 | if (*option == '+') |
| 2293 | preview_type=UndefinedPreview; |
| 2294 | else |
| 2295 | preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions, |
| 2296 | MagickFalse,argv[i+1]); |
| 2297 | mogrify_image=PreviewImage(*image,preview_type,exception); |
| 2298 | break; |
| 2299 | } |
| 2300 | if (LocaleCompare("profile",option+1) == 0) |
| 2301 | { |
| 2302 | const char |
| 2303 | *name; |
| 2304 | |
| 2305 | const StringInfo |
| 2306 | *profile; |
| 2307 | |
| 2308 | Image |
| 2309 | *profile_image; |
| 2310 | |
| 2311 | ImageInfo |
| 2312 | *profile_info; |
| 2313 | |
| 2314 | (void) SyncImageSettings(mogrify_info,*image); |
| 2315 | if (*option == '+') |
| 2316 | { |
| 2317 | /* |
| 2318 | Remove a profile from the image. |
| 2319 | */ |
| 2320 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
| 2321 | NULL,0,MagickTrue); |
| 2322 | InheritException(exception,&(*image)->exception); |
| 2323 | break; |
| 2324 | } |
| 2325 | /* |
| 2326 | Associate a profile with the image. |
| 2327 | */ |
| 2328 | profile_info=CloneImageInfo(mogrify_info); |
| 2329 | profile=GetImageProfile(*image,"iptc"); |
| 2330 | if (profile != (StringInfo *) NULL) |
| 2331 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2332 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2333 | profile_info=DestroyImageInfo(profile_info); |
| 2334 | if (profile_image == (Image *) NULL) |
| 2335 | { |
| 2336 | StringInfo |
| 2337 | *profile; |
| 2338 | |
| 2339 | profile_info=CloneImageInfo(mogrify_info); |
| 2340 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2341 | MaxTextExtent); |
| 2342 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
| 2343 | if (profile != (StringInfo *) NULL) |
| 2344 | { |
| 2345 | (void) ProfileImage(*image,profile_info->magick, |
| 2346 | GetStringInfoDatum(profile),(size_t) |
| 2347 | GetStringInfoLength(profile),MagickFalse); |
| 2348 | profile=DestroyStringInfo(profile); |
| 2349 | } |
| 2350 | profile_info=DestroyImageInfo(profile_info); |
| 2351 | break; |
| 2352 | } |
| 2353 | ResetImageProfileIterator(profile_image); |
| 2354 | name=GetNextImageProfile(profile_image); |
| 2355 | while (name != (const char *) NULL) |
| 2356 | { |
| 2357 | profile=GetImageProfile(profile_image,name); |
| 2358 | if (profile != (StringInfo *) NULL) |
| 2359 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
| 2360 | (size_t) GetStringInfoLength(profile),MagickFalse); |
| 2361 | name=GetNextImageProfile(profile_image); |
| 2362 | } |
| 2363 | profile_image=DestroyImage(profile_image); |
| 2364 | break; |
| 2365 | } |
| 2366 | break; |
| 2367 | } |
| 2368 | case 'q': |
| 2369 | { |
| 2370 | if (LocaleCompare("quantize",option+1) == 0) |
| 2371 | { |
| 2372 | if (*option == '+') |
| 2373 | { |
| 2374 | quantize_info->colorspace=UndefinedColorspace; |
| 2375 | break; |
| 2376 | } |
| 2377 | quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
| 2378 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2379 | break; |
| 2380 | } |
| 2381 | break; |
| 2382 | } |
| 2383 | case 'r': |
| 2384 | { |
| 2385 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2386 | { |
| 2387 | /* |
| 2388 | Radial blur image. |
| 2389 | */ |
| 2390 | (void) SyncImageSettings(mogrify_info,*image); |
| 2391 | mogrify_image=RadialBlurImageChannel(*image,channel, |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 2392 | LocaleToDouble(argv[i+1],(char **) NULL),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2393 | break; |
| 2394 | } |
| 2395 | if (LocaleCompare("raise",option+1) == 0) |
| 2396 | { |
| 2397 | /* |
| 2398 | Surround image with a raise of solid color. |
| 2399 | */ |
| 2400 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2401 | if ((flags & SigmaValue) == 0) |
| 2402 | geometry.height=geometry.width; |
| 2403 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
| 2404 | MagickFalse); |
| 2405 | InheritException(exception,&(*image)->exception); |
| 2406 | break; |
| 2407 | } |
| 2408 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2409 | { |
| 2410 | /* |
| 2411 | Threshold image. |
| 2412 | */ |
| 2413 | (void) SyncImageSettings(mogrify_info,*image); |
| 2414 | (void) RandomThresholdImageChannel(*image,channel,argv[i+1], |
| 2415 | exception); |
| 2416 | break; |
| 2417 | } |
| 2418 | if (LocaleCompare("recolor",option+1) == 0) |
| 2419 | { |
| 2420 | KernelInfo |
| 2421 | *kernel; |
| 2422 | |
| 2423 | (void) SyncImageSettings(mogrify_info,*image); |
| 2424 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2425 | if (kernel == (KernelInfo *) NULL) |
| 2426 | break; |
| 2427 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 2428 | kernel=DestroyKernelInfo(kernel); |
| 2429 | break; |
| 2430 | } |
| 2431 | if (LocaleCompare("region",option+1) == 0) |
| 2432 | { |
| 2433 | (void) SyncImageSettings(mogrify_info,*image); |
| 2434 | if (region_image != (Image *) NULL) |
| 2435 | { |
| 2436 | /* |
| 2437 | Composite region. |
| 2438 | */ |
| 2439 | (void) CompositeImage(region_image,region_image->matte != |
| 2440 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 2441 | region_geometry.x,region_geometry.y); |
| 2442 | InheritException(exception,®ion_image->exception); |
| 2443 | *image=DestroyImage(*image); |
| 2444 | *image=region_image; |
| 2445 | region_image = (Image *) NULL; |
| 2446 | } |
| 2447 | if (*option == '+') |
| 2448 | break; |
| 2449 | /* |
| 2450 | Apply transformations to a selected region of the image. |
| 2451 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2452 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2453 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2454 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2455 | if (mogrify_image == (Image *) NULL) |
| 2456 | break; |
| 2457 | region_image=(*image); |
| 2458 | *image=mogrify_image; |
| 2459 | mogrify_image=(Image *) NULL; |
| 2460 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2461 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2462 | if (LocaleCompare("render",option+1) == 0) |
| 2463 | { |
| 2464 | (void) SyncImageSettings(mogrify_info,*image); |
| 2465 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2466 | break; |
| 2467 | } |
| 2468 | if (LocaleCompare("remap",option+1) == 0) |
| 2469 | { |
| 2470 | Image |
| 2471 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2472 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2473 | /* |
| 2474 | Transform image colors to match this set of colors. |
| 2475 | */ |
| 2476 | (void) SyncImageSettings(mogrify_info,*image); |
| 2477 | if (*option == '+') |
| 2478 | break; |
| 2479 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2480 | if (remap_image == (Image *) NULL) |
| 2481 | break; |
| 2482 | (void) RemapImage(quantize_info,*image,remap_image); |
| 2483 | InheritException(exception,&(*image)->exception); |
| 2484 | remap_image=DestroyImage(remap_image); |
| 2485 | break; |
| 2486 | } |
| 2487 | if (LocaleCompare("repage",option+1) == 0) |
| 2488 | { |
| 2489 | if (*option == '+') |
| 2490 | { |
| 2491 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2492 | break; |
| 2493 | } |
| 2494 | (void) ResetImagePage(*image,argv[i+1]); |
| 2495 | InheritException(exception,&(*image)->exception); |
| 2496 | break; |
| 2497 | } |
| 2498 | if (LocaleCompare("resample",option+1) == 0) |
| 2499 | { |
| 2500 | /* |
| 2501 | Resample image. |
| 2502 | */ |
| 2503 | (void) SyncImageSettings(mogrify_info,*image); |
| 2504 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2505 | if ((flags & SigmaValue) == 0) |
| 2506 | geometry_info.sigma=geometry_info.rho; |
| 2507 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
| 2508 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2509 | break; |
| 2510 | } |
| 2511 | if (LocaleCompare("resize",option+1) == 0) |
| 2512 | { |
| 2513 | /* |
| 2514 | Resize image. |
| 2515 | */ |
| 2516 | (void) SyncImageSettings(mogrify_info,*image); |
| 2517 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2518 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2519 | (*image)->filter,(*image)->blur,exception); |
| 2520 | break; |
| 2521 | } |
| 2522 | if (LocaleCompare("roll",option+1) == 0) |
| 2523 | { |
| 2524 | /* |
| 2525 | Roll image. |
| 2526 | */ |
| 2527 | (void) SyncImageSettings(mogrify_info,*image); |
| 2528 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2529 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2530 | break; |
| 2531 | } |
| 2532 | if (LocaleCompare("rotate",option+1) == 0) |
| 2533 | { |
| 2534 | char |
| 2535 | *geometry; |
| 2536 | |
| 2537 | /* |
| 2538 | Check for conditional image rotation. |
| 2539 | */ |
| 2540 | (void) SyncImageSettings(mogrify_info,*image); |
| 2541 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2542 | if ((*image)->columns <= (*image)->rows) |
| 2543 | break; |
| 2544 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2545 | if ((*image)->columns >= (*image)->rows) |
| 2546 | break; |
| 2547 | /* |
| 2548 | Rotate image. |
| 2549 | */ |
| 2550 | geometry=ConstantString(argv[i+1]); |
| 2551 | (void) SubstituteString(&geometry,">",""); |
| 2552 | (void) SubstituteString(&geometry,"<",""); |
| 2553 | (void) ParseGeometry(geometry,&geometry_info); |
| 2554 | geometry=DestroyString(geometry); |
| 2555 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
| 2556 | break; |
| 2557 | } |
| 2558 | break; |
| 2559 | } |
| 2560 | case 's': |
| 2561 | { |
| 2562 | if (LocaleCompare("sample",option+1) == 0) |
| 2563 | { |
| 2564 | /* |
| 2565 | Sample image with pixel replication. |
| 2566 | */ |
| 2567 | (void) SyncImageSettings(mogrify_info,*image); |
| 2568 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2569 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
| 2570 | exception); |
| 2571 | break; |
| 2572 | } |
| 2573 | if (LocaleCompare("scale",option+1) == 0) |
| 2574 | { |
| 2575 | /* |
| 2576 | Resize image. |
| 2577 | */ |
| 2578 | (void) SyncImageSettings(mogrify_info,*image); |
| 2579 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2580 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2581 | exception); |
| 2582 | break; |
| 2583 | } |
| 2584 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2585 | { |
| 2586 | /* |
| 2587 | Selectively blur pixels within a contrast threshold. |
| 2588 | */ |
| 2589 | (void) SyncImageSettings(mogrify_info,*image); |
| 2590 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2591 | if ((flags & PercentValue) != 0) |
| 2592 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 2593 | mogrify_image=SelectiveBlurImageChannel(*image,channel, |
| 2594 | geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception); |
| 2595 | break; |
| 2596 | } |
| 2597 | if (LocaleCompare("separate",option+1) == 0) |
| 2598 | { |
| 2599 | /* |
| 2600 | Break channels into separate images. |
| 2601 | WARNING: This can generate multiple images! |
| 2602 | */ |
| 2603 | (void) SyncImageSettings(mogrify_info,*image); |
| 2604 | mogrify_image=SeparateImages(*image,channel,exception); |
| 2605 | break; |
| 2606 | } |
| 2607 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2608 | { |
| 2609 | double |
| 2610 | threshold; |
| 2611 | |
| 2612 | /* |
| 2613 | Sepia-tone image. |
| 2614 | */ |
| 2615 | (void) SyncImageSettings(mogrify_info,*image); |
| 2616 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2617 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
| 2618 | break; |
| 2619 | } |
| 2620 | if (LocaleCompare("segment",option+1) == 0) |
| 2621 | { |
| 2622 | /* |
| 2623 | Segment image. |
| 2624 | */ |
| 2625 | (void) SyncImageSettings(mogrify_info,*image); |
| 2626 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2627 | if ((flags & SigmaValue) == 0) |
| 2628 | geometry_info.sigma=1.0; |
| 2629 | (void) SegmentImage(*image,(*image)->colorspace, |
| 2630 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma); |
| 2631 | InheritException(exception,&(*image)->exception); |
| 2632 | break; |
| 2633 | } |
| 2634 | if (LocaleCompare("set",option+1) == 0) |
| 2635 | { |
| 2636 | char |
| 2637 | *value; |
| 2638 | |
| 2639 | /* |
| 2640 | Set image option. |
| 2641 | */ |
| 2642 | if (*option == '+') |
| 2643 | { |
| 2644 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2645 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2646 | else |
| 2647 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2648 | { |
| 2649 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
| 2650 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2651 | } |
| 2652 | else |
| 2653 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2654 | break; |
| 2655 | } |
| 2656 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 2657 | if (value == (char *) NULL) |
| 2658 | break; |
| 2659 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2660 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2661 | exception); |
| 2662 | else |
| 2663 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2664 | { |
| 2665 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
| 2666 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
| 2667 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2668 | } |
| 2669 | else |
| 2670 | (void) SetImageProperty(*image,argv[i+1],value); |
| 2671 | value=DestroyString(value); |
| 2672 | break; |
| 2673 | } |
| 2674 | if (LocaleCompare("shade",option+1) == 0) |
| 2675 | { |
| 2676 | /* |
| 2677 | Shade image. |
| 2678 | */ |
| 2679 | (void) SyncImageSettings(mogrify_info,*image); |
| 2680 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2681 | if ((flags & SigmaValue) == 0) |
| 2682 | geometry_info.sigma=1.0; |
| 2683 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2684 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2685 | break; |
| 2686 | } |
| 2687 | if (LocaleCompare("shadow",option+1) == 0) |
| 2688 | { |
| 2689 | /* |
| 2690 | Shadow image. |
| 2691 | */ |
| 2692 | (void) SyncImageSettings(mogrify_info,*image); |
| 2693 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2694 | if ((flags & SigmaValue) == 0) |
| 2695 | geometry_info.sigma=1.0; |
| 2696 | if ((flags & XiValue) == 0) |
| 2697 | geometry_info.xi=4.0; |
| 2698 | if ((flags & PsiValue) == 0) |
| 2699 | geometry_info.psi=4.0; |
| 2700 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
| 2701 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 2702 | ceil(geometry_info.psi-0.5),exception); |
| 2703 | break; |
| 2704 | } |
| 2705 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2706 | { |
| 2707 | /* |
| 2708 | Sharpen image. |
| 2709 | */ |
| 2710 | (void) SyncImageSettings(mogrify_info,*image); |
| 2711 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2712 | if ((flags & SigmaValue) == 0) |
| 2713 | geometry_info.sigma=1.0; |
| 2714 | mogrify_image=SharpenImageChannel(*image,channel,geometry_info.rho, |
| 2715 | geometry_info.sigma,exception); |
| 2716 | break; |
| 2717 | } |
| 2718 | if (LocaleCompare("shave",option+1) == 0) |
| 2719 | { |
| 2720 | /* |
| 2721 | Shave the image edges. |
| 2722 | */ |
| 2723 | (void) SyncImageSettings(mogrify_info,*image); |
| 2724 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2725 | mogrify_image=ShaveImage(*image,&geometry,exception); |
| 2726 | break; |
| 2727 | } |
| 2728 | if (LocaleCompare("shear",option+1) == 0) |
| 2729 | { |
| 2730 | /* |
| 2731 | Shear image. |
| 2732 | */ |
| 2733 | (void) SyncImageSettings(mogrify_info,*image); |
| 2734 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2735 | if ((flags & SigmaValue) == 0) |
| 2736 | geometry_info.sigma=geometry_info.rho; |
| 2737 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2738 | geometry_info.sigma,exception); |
| 2739 | break; |
| 2740 | } |
| 2741 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2742 | { |
| 2743 | /* |
| 2744 | Sigmoidal non-linearity contrast control. |
| 2745 | */ |
| 2746 | (void) SyncImageSettings(mogrify_info,*image); |
| 2747 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2748 | if ((flags & SigmaValue) == 0) |
| 2749 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 2750 | if ((flags & PercentValue) != 0) |
| 2751 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2752 | 100.0; |
| 2753 | (void) SigmoidalContrastImageChannel(*image,channel, |
| 2754 | (*option == '-') ? MagickTrue : MagickFalse,geometry_info.rho, |
| 2755 | geometry_info.sigma); |
| 2756 | InheritException(exception,&(*image)->exception); |
| 2757 | break; |
| 2758 | } |
| 2759 | if (LocaleCompare("sketch",option+1) == 0) |
| 2760 | { |
| 2761 | /* |
| 2762 | Sketch image. |
| 2763 | */ |
| 2764 | (void) SyncImageSettings(mogrify_info,*image); |
| 2765 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2766 | if ((flags & SigmaValue) == 0) |
| 2767 | geometry_info.sigma=1.0; |
| 2768 | mogrify_image=SketchImage(*image,geometry_info.rho, |
| 2769 | geometry_info.sigma,geometry_info.xi,exception); |
| 2770 | break; |
| 2771 | } |
| 2772 | if (LocaleCompare("solarize",option+1) == 0) |
| 2773 | { |
| 2774 | double |
| 2775 | threshold; |
| 2776 | |
| 2777 | (void) SyncImageSettings(mogrify_info,*image); |
| 2778 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2779 | (void) SolarizeImage(*image,threshold); |
| 2780 | InheritException(exception,&(*image)->exception); |
| 2781 | break; |
| 2782 | } |
| 2783 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2784 | { |
| 2785 | SparseColorMethod |
| 2786 | method; |
| 2787 | |
| 2788 | char |
| 2789 | *arguments; |
| 2790 | |
| 2791 | /* |
| 2792 | Sparse Color Interpolated Gradient |
| 2793 | */ |
| 2794 | (void) SyncImageSettings(mogrify_info,*image); |
| 2795 | method=(SparseColorMethod) ParseCommandOption( |
| 2796 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
| 2797 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 2798 | InheritException(exception,&(*image)->exception); |
| 2799 | if (arguments == (char *) NULL) |
| 2800 | break; |
| 2801 | mogrify_image=SparseColorOption(*image,channel,method,arguments, |
| 2802 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2803 | arguments=DestroyString(arguments); |
| 2804 | break; |
| 2805 | } |
| 2806 | if (LocaleCompare("splice",option+1) == 0) |
| 2807 | { |
| 2808 | /* |
| 2809 | Splice a solid color into the image. |
| 2810 | */ |
| 2811 | (void) SyncImageSettings(mogrify_info,*image); |
| 2812 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 2813 | mogrify_image=SpliceImage(*image,&geometry,exception); |
| 2814 | break; |
| 2815 | } |
| 2816 | if (LocaleCompare("spread",option+1) == 0) |
| 2817 | { |
| 2818 | /* |
| 2819 | Spread an image. |
| 2820 | */ |
| 2821 | (void) SyncImageSettings(mogrify_info,*image); |
| 2822 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2823 | mogrify_image=SpreadImage(*image,geometry_info.rho,exception); |
| 2824 | break; |
| 2825 | } |
| 2826 | if (LocaleCompare("statistic",option+1) == 0) |
| 2827 | { |
| 2828 | StatisticType |
| 2829 | type; |
| 2830 | |
| 2831 | (void) SyncImageSettings(mogrify_info,*image); |
| 2832 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
| 2833 | MagickFalse,argv[i+1]); |
| 2834 | (void) ParseGeometry(argv[i+2],&geometry_info); |
| 2835 | mogrify_image=StatisticImageChannel(*image,channel,type,(size_t) |
| 2836 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
| 2837 | break; |
| 2838 | } |
| 2839 | if (LocaleCompare("stretch",option+1) == 0) |
| 2840 | { |
| 2841 | if (*option == '+') |
| 2842 | { |
| 2843 | draw_info->stretch=UndefinedStretch; |
| 2844 | break; |
| 2845 | } |
| 2846 | draw_info->stretch=(StretchType) ParseCommandOption( |
| 2847 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2848 | break; |
| 2849 | } |
| 2850 | if (LocaleCompare("strip",option+1) == 0) |
| 2851 | { |
| 2852 | /* |
| 2853 | Strip image of profiles and comments. |
| 2854 | */ |
| 2855 | (void) SyncImageSettings(mogrify_info,*image); |
| 2856 | (void) StripImage(*image); |
| 2857 | InheritException(exception,&(*image)->exception); |
| 2858 | break; |
| 2859 | } |
| 2860 | if (LocaleCompare("stroke",option+1) == 0) |
| 2861 | { |
| 2862 | ExceptionInfo |
| 2863 | *sans; |
| 2864 | |
| 2865 | if (*option == '+') |
| 2866 | { |
| 2867 | (void) QueryColorDatabase("none",&draw_info->stroke,exception); |
| 2868 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2869 | draw_info->stroke_pattern=DestroyImage( |
| 2870 | draw_info->stroke_pattern); |
| 2871 | break; |
| 2872 | } |
| 2873 | sans=AcquireExceptionInfo(); |
| 2874 | status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans); |
| 2875 | sans=DestroyExceptionInfo(sans); |
| 2876 | if (status == MagickFalse) |
| 2877 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2878 | exception); |
| 2879 | break; |
| 2880 | } |
| 2881 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2882 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 2883 | draw_info->stroke_width=LocaleToDouble(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2884 | break; |
| 2885 | } |
| 2886 | if (LocaleCompare("style",option+1) == 0) |
| 2887 | { |
| 2888 | if (*option == '+') |
| 2889 | { |
| 2890 | draw_info->style=UndefinedStyle; |
| 2891 | break; |
| 2892 | } |
| 2893 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 2894 | MagickFalse,argv[i+1]); |
| 2895 | break; |
| 2896 | } |
| 2897 | if (LocaleCompare("swirl",option+1) == 0) |
| 2898 | { |
| 2899 | /* |
| 2900 | Swirl image. |
| 2901 | */ |
| 2902 | (void) SyncImageSettings(mogrify_info,*image); |
| 2903 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2904 | mogrify_image=SwirlImage(*image,geometry_info.rho,exception); |
| 2905 | break; |
| 2906 | } |
| 2907 | break; |
| 2908 | } |
| 2909 | case 't': |
| 2910 | { |
| 2911 | if (LocaleCompare("threshold",option+1) == 0) |
| 2912 | { |
| 2913 | double |
| 2914 | threshold; |
| 2915 | |
| 2916 | /* |
| 2917 | Threshold image. |
| 2918 | */ |
| 2919 | (void) SyncImageSettings(mogrify_info,*image); |
| 2920 | if (*option == '+') |
anthony | 247a86d | 2011-05-03 13:18:18 +0000 | [diff] [blame] | 2921 | threshold=(double) QuantumRange/2; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2922 | else |
| 2923 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2924 | (void) BilevelImageChannel(*image,channel,threshold); |
| 2925 | InheritException(exception,&(*image)->exception); |
| 2926 | break; |
| 2927 | } |
| 2928 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2929 | { |
| 2930 | /* |
| 2931 | Thumbnail image. |
| 2932 | */ |
| 2933 | (void) SyncImageSettings(mogrify_info,*image); |
| 2934 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2935 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2936 | exception); |
| 2937 | break; |
| 2938 | } |
| 2939 | if (LocaleCompare("tile",option+1) == 0) |
| 2940 | { |
| 2941 | if (*option == '+') |
| 2942 | { |
| 2943 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2944 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2945 | break; |
| 2946 | } |
| 2947 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2948 | exception); |
| 2949 | break; |
| 2950 | } |
| 2951 | if (LocaleCompare("tint",option+1) == 0) |
| 2952 | { |
| 2953 | /* |
| 2954 | Tint the image. |
| 2955 | */ |
| 2956 | (void) SyncImageSettings(mogrify_info,*image); |
| 2957 | mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception); |
| 2958 | break; |
| 2959 | } |
| 2960 | if (LocaleCompare("transform",option+1) == 0) |
| 2961 | { |
| 2962 | /* |
| 2963 | Affine transform image. |
| 2964 | */ |
| 2965 | (void) SyncImageSettings(mogrify_info,*image); |
| 2966 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
| 2967 | exception); |
| 2968 | break; |
| 2969 | } |
| 2970 | if (LocaleCompare("transparent",option+1) == 0) |
| 2971 | { |
| 2972 | MagickPixelPacket |
| 2973 | target; |
| 2974 | |
| 2975 | (void) SyncImageSettings(mogrify_info,*image); |
| 2976 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2977 | (void) TransparentPaintImage(*image,&target,(Quantum) |
| 2978 | TransparentOpacity,*option == '-' ? MagickFalse : MagickTrue); |
| 2979 | InheritException(exception,&(*image)->exception); |
| 2980 | break; |
| 2981 | } |
| 2982 | if (LocaleCompare("transpose",option+1) == 0) |
| 2983 | { |
| 2984 | /* |
| 2985 | Transpose image scanlines. |
| 2986 | */ |
| 2987 | (void) SyncImageSettings(mogrify_info,*image); |
| 2988 | mogrify_image=TransposeImage(*image,exception); |
| 2989 | break; |
| 2990 | } |
| 2991 | if (LocaleCompare("transverse",option+1) == 0) |
| 2992 | { |
| 2993 | /* |
| 2994 | Transverse image scanlines. |
| 2995 | */ |
| 2996 | (void) SyncImageSettings(mogrify_info,*image); |
| 2997 | mogrify_image=TransverseImage(*image,exception); |
| 2998 | break; |
| 2999 | } |
| 3000 | if (LocaleCompare("treedepth",option+1) == 0) |
| 3001 | { |
| 3002 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
| 3003 | break; |
| 3004 | } |
| 3005 | if (LocaleCompare("trim",option+1) == 0) |
| 3006 | { |
| 3007 | /* |
| 3008 | Trim image. |
| 3009 | */ |
| 3010 | (void) SyncImageSettings(mogrify_info,*image); |
| 3011 | mogrify_image=TrimImage(*image,exception); |
| 3012 | break; |
| 3013 | } |
| 3014 | if (LocaleCompare("type",option+1) == 0) |
| 3015 | { |
| 3016 | ImageType |
| 3017 | type; |
| 3018 | |
| 3019 | (void) SyncImageSettings(mogrify_info,*image); |
| 3020 | if (*option == '+') |
| 3021 | type=UndefinedType; |
| 3022 | else |
| 3023 | type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 3024 | argv[i+1]); |
| 3025 | (*image)->type=UndefinedType; |
| 3026 | (void) SetImageType(*image,type); |
| 3027 | InheritException(exception,&(*image)->exception); |
| 3028 | break; |
| 3029 | } |
| 3030 | break; |
| 3031 | } |
| 3032 | case 'u': |
| 3033 | { |
| 3034 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3035 | { |
| 3036 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 3037 | exception); |
| 3038 | break; |
| 3039 | } |
| 3040 | if (LocaleCompare("unique",option+1) == 0) |
| 3041 | { |
| 3042 | if (*option == '+') |
| 3043 | { |
| 3044 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
| 3045 | break; |
| 3046 | } |
| 3047 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
| 3048 | (void) SetImageArtifact(*image,"verbose","true"); |
| 3049 | break; |
| 3050 | } |
| 3051 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3052 | { |
| 3053 | /* |
| 3054 | Unique image colors. |
| 3055 | */ |
| 3056 | (void) SyncImageSettings(mogrify_info,*image); |
| 3057 | mogrify_image=UniqueImageColors(*image,exception); |
| 3058 | break; |
| 3059 | } |
| 3060 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3061 | { |
| 3062 | /* |
| 3063 | Unsharp mask image. |
| 3064 | */ |
| 3065 | (void) SyncImageSettings(mogrify_info,*image); |
| 3066 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3067 | if ((flags & SigmaValue) == 0) |
| 3068 | geometry_info.sigma=1.0; |
| 3069 | if ((flags & XiValue) == 0) |
| 3070 | geometry_info.xi=1.0; |
| 3071 | if ((flags & PsiValue) == 0) |
| 3072 | geometry_info.psi=0.05; |
| 3073 | mogrify_image=UnsharpMaskImageChannel(*image,channel, |
| 3074 | geometry_info.rho,geometry_info.sigma,geometry_info.xi, |
| 3075 | geometry_info.psi,exception); |
| 3076 | break; |
| 3077 | } |
| 3078 | break; |
| 3079 | } |
| 3080 | case 'v': |
| 3081 | { |
| 3082 | if (LocaleCompare("verbose",option+1) == 0) |
| 3083 | { |
| 3084 | (void) SetImageArtifact(*image,option+1, |
| 3085 | *option == '+' ? "false" : "true"); |
| 3086 | break; |
| 3087 | } |
| 3088 | if (LocaleCompare("vignette",option+1) == 0) |
| 3089 | { |
| 3090 | /* |
| 3091 | Vignette 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 | if ((flags & XiValue) == 0) |
| 3098 | geometry_info.xi=0.1*(*image)->columns; |
| 3099 | if ((flags & PsiValue) == 0) |
| 3100 | geometry_info.psi=0.1*(*image)->rows; |
| 3101 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
| 3102 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3103 | ceil(geometry_info.psi-0.5),exception); |
| 3104 | break; |
| 3105 | } |
| 3106 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3107 | { |
| 3108 | if (*option == '+') |
| 3109 | { |
| 3110 | (void) SetImageVirtualPixelMethod(*image, |
| 3111 | UndefinedVirtualPixelMethod); |
| 3112 | break; |
| 3113 | } |
| 3114 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3115 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 3116 | argv[i+1])); |
| 3117 | break; |
| 3118 | } |
| 3119 | break; |
| 3120 | } |
| 3121 | case 'w': |
| 3122 | { |
| 3123 | if (LocaleCompare("wave",option+1) == 0) |
| 3124 | { |
| 3125 | /* |
| 3126 | Wave image. |
| 3127 | */ |
| 3128 | (void) SyncImageSettings(mogrify_info,*image); |
| 3129 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3130 | if ((flags & SigmaValue) == 0) |
| 3131 | geometry_info.sigma=1.0; |
| 3132 | mogrify_image=WaveImage(*image,geometry_info.rho, |
| 3133 | geometry_info.sigma,exception); |
| 3134 | break; |
| 3135 | } |
| 3136 | if (LocaleCompare("weight",option+1) == 0) |
| 3137 | { |
| 3138 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
| 3139 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3140 | draw_info->weight=0; |
| 3141 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3142 | draw_info->weight=700; |
| 3143 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3144 | if (draw_info->weight <= 800) |
| 3145 | draw_info->weight+=100; |
| 3146 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3147 | if (draw_info->weight >= 100) |
| 3148 | draw_info->weight-=100; |
| 3149 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3150 | draw_info->weight=400; |
| 3151 | break; |
| 3152 | } |
| 3153 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3154 | { |
| 3155 | /* |
| 3156 | White threshold image. |
| 3157 | */ |
| 3158 | (void) SyncImageSettings(mogrify_info,*image); |
| 3159 | (void) WhiteThresholdImageChannel(*image,channel,argv[i+1], |
| 3160 | exception); |
| 3161 | InheritException(exception,&(*image)->exception); |
| 3162 | break; |
| 3163 | } |
| 3164 | break; |
| 3165 | } |
| 3166 | default: |
| 3167 | break; |
| 3168 | } |
| 3169 | /* |
| 3170 | Replace current image with any image that was generated |
| 3171 | */ |
| 3172 | if (mogrify_image != (Image *) NULL) |
| 3173 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3174 | i+=count; |
| 3175 | } |
| 3176 | if (region_image != (Image *) NULL) |
| 3177 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3178 | /* |
| 3179 | Composite transformed region onto image. |
| 3180 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3181 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3182 | (void) CompositeImage(region_image,region_image->matte != |
| 3183 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3184 | region_geometry.x,region_geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3185 | InheritException(exception,®ion_image->exception); |
| 3186 | *image=DestroyImage(*image); |
| 3187 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3188 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3189 | } |
| 3190 | /* |
| 3191 | Free resources. |
| 3192 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3193 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3194 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3195 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3196 | status=(*image)->exception.severity == UndefinedException ? 1 : 0; |
| 3197 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3198 | } |
| 3199 | |
| 3200 | /* |
| 3201 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3202 | % % |
| 3203 | % % |
| 3204 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3205 | + 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] | 3206 | % % |
| 3207 | % % |
| 3208 | % % |
| 3209 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3210 | % |
| 3211 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3212 | % transforms include image scaling, image rotation, color reduction, and |
| 3213 | % others. The transmogrified image overwrites the original image. |
| 3214 | % |
| 3215 | % The format of the MogrifyImageCommand method is: |
| 3216 | % |
| 3217 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3218 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3219 | % |
| 3220 | % A description of each parameter follows: |
| 3221 | % |
| 3222 | % o image_info: the image info. |
| 3223 | % |
| 3224 | % o argc: the number of elements in the argument vector. |
| 3225 | % |
| 3226 | % o argv: A text array containing the command line arguments. |
| 3227 | % |
| 3228 | % o metadata: any metadata is returned here. |
| 3229 | % |
| 3230 | % o exception: return any errors or warnings in this structure. |
| 3231 | % |
| 3232 | */ |
| 3233 | |
| 3234 | static MagickBooleanType MogrifyUsage(void) |
| 3235 | { |
| 3236 | static const char |
| 3237 | *miscellaneous[]= |
| 3238 | { |
| 3239 | "-debug events display copious debugging information", |
| 3240 | "-help print program options", |
| 3241 | "-list type print a list of supported option arguments", |
| 3242 | "-log format format of debugging information", |
| 3243 | "-version print version information", |
| 3244 | (char *) NULL |
| 3245 | }, |
| 3246 | *operators[]= |
| 3247 | { |
| 3248 | "-adaptive-blur geometry", |
| 3249 | " adaptively blur pixels; decrease effect near edges", |
| 3250 | "-adaptive-resize geometry", |
| 3251 | " adaptively resize image using 'mesh' interpolation", |
| 3252 | "-adaptive-sharpen geometry", |
| 3253 | " adaptively sharpen pixels; increase effect near edges", |
| 3254 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3255 | " transparent, extract, background, or shape", |
| 3256 | "-annotate geometry text", |
| 3257 | " annotate the image with text", |
| 3258 | "-auto-gamma automagically adjust gamma level of image", |
| 3259 | "-auto-level automagically adjust color levels of image", |
| 3260 | "-auto-orient automagically orient (rotate) image", |
| 3261 | "-bench iterations measure performance", |
| 3262 | "-black-threshold value", |
| 3263 | " force all pixels below the threshold into black", |
| 3264 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3265 | "-blur geometry reduce image noise and reduce detail levels", |
| 3266 | "-border geometry surround image with a border of color", |
| 3267 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3268 | "-brightness-contrast geometry", |
| 3269 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3270 | "-cdl filename color correct with a color decision list", |
| 3271 | "-charcoal radius simulate a charcoal drawing", |
| 3272 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3273 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3274 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3275 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3276 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3277 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3278 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3279 | "-contrast enhance or reduce the image contrast", |
| 3280 | "-contrast-stretch geometry", |
| 3281 | " improve contrast by `stretching' the intensity range", |
| 3282 | "-convolve coefficients", |
| 3283 | " apply a convolution kernel to the image", |
| 3284 | "-cycle amount cycle the image colormap", |
| 3285 | "-decipher filename convert cipher pixels to plain pixels", |
| 3286 | "-deskew threshold straighten an image", |
| 3287 | "-despeckle reduce the speckles within an image", |
| 3288 | "-distort method args", |
| 3289 | " distort images according to given method ad args", |
| 3290 | "-draw string annotate the image with a graphic primitive", |
| 3291 | "-edge radius apply a filter to detect edges in the image", |
| 3292 | "-encipher filename convert plain pixels to cipher pixels", |
| 3293 | "-emboss radius emboss an image", |
| 3294 | "-enhance apply a digital filter to enhance a noisy image", |
| 3295 | "-equalize perform histogram equalization to an image", |
| 3296 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3297 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3298 | "-extent geometry set the image size", |
| 3299 | "-extract geometry extract area from image", |
| 3300 | "-fft implements the discrete Fourier transform (DFT)", |
| 3301 | "-flip flip image vertically", |
| 3302 | "-floodfill geometry color", |
| 3303 | " floodfill the image with color", |
| 3304 | "-flop flop image horizontally", |
| 3305 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3306 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3307 | " apply function over image values", |
| 3308 | "-gamma value level of gamma correction", |
| 3309 | "-gaussian-blur geometry", |
| 3310 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3311 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3312 | "-identify identify the format and characteristics of the image", |
| 3313 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3314 | "-implode amount implode image pixels about the center", |
| 3315 | "-lat geometry local adaptive thresholding", |
| 3316 | "-layers method optimize, merge, or compare image layers", |
| 3317 | "-level value adjust the level of image contrast", |
| 3318 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3319 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3320 | "-linear-stretch geometry", |
| 3321 | " improve contrast by `stretching with saturation'", |
| 3322 | "-liquid-rescale geometry", |
| 3323 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3324 | "-median geometry apply a median filter to the image", |
| 3325 | "-mode geometry make each pixel the 'predominate color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3326 | "-modulate value vary the brightness, saturation, and hue", |
| 3327 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3328 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3329 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3330 | "-motion-blur geometry", |
| 3331 | " simulate motion blur", |
| 3332 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3333 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3334 | "-normalize transform image to span the full range of colors", |
| 3335 | "-opaque color change this color to the fill color", |
| 3336 | "-ordered-dither NxN", |
| 3337 | " add a noise pattern to the image with specific", |
| 3338 | " amplitudes", |
| 3339 | "-paint radius simulate an oil painting", |
| 3340 | "-polaroid angle simulate a Polaroid picture", |
| 3341 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3342 | "-profile filename add, delete, or apply an image profile", |
| 3343 | "-quantize colorspace reduce colors in this colorspace", |
| 3344 | "-radial-blur angle radial blur the image", |
| 3345 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3346 | "-random-threshold low,high", |
| 3347 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3348 | "-region geometry apply options to a portion of the image", |
| 3349 | "-render render vector graphics", |
| 3350 | "-repage geometry size and location of an image canvas", |
| 3351 | "-resample geometry change the resolution of an image", |
| 3352 | "-resize geometry resize the image", |
| 3353 | "-roll geometry roll an image vertically or horizontally", |
| 3354 | "-rotate degrees apply Paeth rotation to the image", |
| 3355 | "-sample geometry scale image with pixel sampling", |
| 3356 | "-scale geometry scale the image", |
| 3357 | "-segment values segment an image", |
| 3358 | "-selective-blur geometry", |
| 3359 | " selectively blur pixels within a contrast threshold", |
| 3360 | "-sepia-tone threshold", |
| 3361 | " simulate a sepia-toned photo", |
| 3362 | "-set property value set an image property", |
| 3363 | "-shade degrees shade the image using a distant light source", |
| 3364 | "-shadow geometry simulate an image shadow", |
| 3365 | "-sharpen geometry sharpen the image", |
| 3366 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3367 | "-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] | 3368 | "-sigmoidal-contrast geometry", |
| 3369 | " increase the contrast without saturating highlights or shadows", |
| 3370 | "-sketch geometry simulate a pencil sketch", |
| 3371 | "-solarize threshold negate all pixels above the threshold level", |
| 3372 | "-sparse-color method args", |
| 3373 | " fill in a image based on a few color points", |
| 3374 | "-splice geometry splice the background color into the image", |
| 3375 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3376 | "-statistic type radius", |
| 3377 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3378 | "-strip strip image of all profiles and comments", |
| 3379 | "-swirl degrees swirl image pixels about the center", |
| 3380 | "-threshold value threshold the image", |
| 3381 | "-thumbnail geometry create a thumbnail of the image", |
| 3382 | "-tile filename tile image when filling a graphic primitive", |
| 3383 | "-tint value tint the image with the fill color", |
| 3384 | "-transform affine transform image", |
| 3385 | "-transparent color make this color transparent within the image", |
| 3386 | "-transpose flip image vertically and rotate 90 degrees", |
| 3387 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3388 | "-trim trim image edges", |
| 3389 | "-type type image type", |
| 3390 | "-unique-colors discard all but one of any pixel color", |
| 3391 | "-unsharp geometry sharpen the image", |
| 3392 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3393 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3394 | "-white-threshold value", |
| 3395 | " force all pixels above the threshold into white", |
| 3396 | (char *) NULL |
| 3397 | }, |
| 3398 | *sequence_operators[]= |
| 3399 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3400 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3401 | "-clut apply a color lookup table to the image", |
| 3402 | "-coalesce merge a sequence of images", |
| 3403 | "-combine combine a sequence of images", |
| 3404 | "-composite composite image", |
| 3405 | "-crop geometry cut out a rectangular region of the image", |
| 3406 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3407 | "-evaluate-sequence operator", |
| 3408 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3409 | "-flatten flatten a sequence of images", |
| 3410 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3411 | "-hald-clut apply a Hald color lookup table to the image", |
| 3412 | "-morph value morph an image sequence", |
| 3413 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3414 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3415 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3416 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3417 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3418 | "-write filename write images to this file", |
| 3419 | (char *) NULL |
| 3420 | }, |
| 3421 | *settings[]= |
| 3422 | { |
| 3423 | "-adjoin join images into a single multi-image file", |
| 3424 | "-affine matrix affine transform matrix", |
| 3425 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3426 | "-antialias remove pixel-aliasing", |
| 3427 | "-authenticate password", |
| 3428 | " decipher image with this password", |
| 3429 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3430 | "-background color background color", |
| 3431 | "-bias value add bias when convolving an image", |
| 3432 | "-black-point-compensation", |
| 3433 | " use black point compensation", |
| 3434 | "-blue-primary point chromaticity blue primary point", |
| 3435 | "-bordercolor color border color", |
| 3436 | "-caption string assign a caption to an image", |
| 3437 | "-channel type apply option to select image channels", |
| 3438 | "-colors value preferred number of colors in the image", |
| 3439 | "-colorspace type alternate image colorspace", |
| 3440 | "-comment string annotate image with comment", |
| 3441 | "-compose operator set image composite operator", |
| 3442 | "-compress type type of pixel compression when writing the image", |
| 3443 | "-define format:option", |
| 3444 | " define one or more image format options", |
| 3445 | "-delay value display the next image after pausing", |
| 3446 | "-density geometry horizontal and vertical density of the image", |
| 3447 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3448 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3449 | "-display server get image or font from this X server", |
| 3450 | "-dispose method layer disposal method", |
| 3451 | "-dither method apply error diffusion to image", |
| 3452 | "-encoding type text encoding type", |
| 3453 | "-endian type endianness (MSB or LSB) of the image", |
| 3454 | "-family name render text with this font family", |
| 3455 | "-fill color color to use when filling a graphic primitive", |
| 3456 | "-filter type use this filter when resizing an image", |
| 3457 | "-font name render text with this font", |
| 3458 | "-format \"string\" output formatted image characteristics", |
| 3459 | "-fuzz distance colors within this distance are considered equal", |
| 3460 | "-gravity type horizontal and vertical text placement", |
| 3461 | "-green-primary point chromaticity green primary point", |
| 3462 | "-intent type type of rendering intent when managing the image color", |
| 3463 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3464 | "-interline-spacing value", |
| 3465 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3466 | "-interpolate method pixel color interpolation method", |
| 3467 | "-interword-spacing value", |
| 3468 | " set the space between two words", |
| 3469 | "-kerning value set the space between two letters", |
| 3470 | "-label string assign a label to an image", |
| 3471 | "-limit type value pixel cache resource limit", |
| 3472 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3473 | "-mask filename associate a mask with the image", |
| 3474 | "-mattecolor color frame color", |
| 3475 | "-monitor monitor progress", |
| 3476 | "-orient type image orientation", |
| 3477 | "-page geometry size and location of an image canvas (setting)", |
| 3478 | "-ping efficiently determine image attributes", |
| 3479 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3480 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3481 | "-preview type image preview type", |
| 3482 | "-quality value JPEG/MIFF/PNG compression level", |
| 3483 | "-quiet suppress all warning messages", |
| 3484 | "-red-primary point chromaticity red primary point", |
| 3485 | "-regard-warnings pay attention to warning messages", |
| 3486 | "-remap filename transform image colors to match this set of colors", |
| 3487 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3488 | "-sampling-factor geometry", |
| 3489 | " horizontal and vertical sampling factor", |
| 3490 | "-scene value image scene number", |
| 3491 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3492 | "-size geometry width and height of image", |
| 3493 | "-stretch type render text with this font stretch", |
| 3494 | "-stroke color graphic primitive stroke color", |
| 3495 | "-strokewidth value graphic primitive stroke width", |
| 3496 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3497 | "-synchronize synchronize image to storage device", |
| 3498 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3499 | "-texture filename name of texture to tile onto the image background", |
| 3500 | "-tile-offset geometry", |
| 3501 | " tile offset", |
| 3502 | "-treedepth value color tree depth", |
| 3503 | "-transparent-color color", |
| 3504 | " transparent color", |
| 3505 | "-undercolor color annotation bounding box color", |
| 3506 | "-units type the units of image resolution", |
| 3507 | "-verbose print detailed information about the image", |
| 3508 | "-view FlashPix viewing transforms", |
| 3509 | "-virtual-pixel method", |
| 3510 | " virtual pixel access method", |
| 3511 | "-weight type render text with this font weight", |
| 3512 | "-white-point point chromaticity white point", |
| 3513 | (char *) NULL |
| 3514 | }, |
| 3515 | *stack_operators[]= |
| 3516 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3517 | "-delete indexes delete the image from the image sequence", |
| 3518 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3519 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3520 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3521 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3522 | "-swap indexes swap two images in the image sequence", |
| 3523 | (char *) NULL |
| 3524 | }; |
| 3525 | |
| 3526 | const char |
| 3527 | **p; |
| 3528 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3529 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3530 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3531 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3532 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3533 | GetClientName()); |
| 3534 | (void) printf("\nImage Settings:\n"); |
| 3535 | for (p=settings; *p != (char *) NULL; p++) |
| 3536 | (void) printf(" %s\n",*p); |
| 3537 | (void) printf("\nImage Operators:\n"); |
| 3538 | for (p=operators; *p != (char *) NULL; p++) |
| 3539 | (void) printf(" %s\n",*p); |
| 3540 | (void) printf("\nImage Sequence Operators:\n"); |
| 3541 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3542 | (void) printf(" %s\n",*p); |
| 3543 | (void) printf("\nImage Stack Operators:\n"); |
| 3544 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3545 | (void) printf(" %s\n",*p); |
| 3546 | (void) printf("\nMiscellaneous Options:\n"); |
| 3547 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3548 | (void) printf(" %s\n",*p); |
| 3549 | (void) printf( |
| 3550 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3551 | (void) printf( |
| 3552 | "number. To specify a particular image format, precede the filename\n"); |
| 3553 | (void) printf( |
| 3554 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3555 | (void) printf( |
| 3556 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3557 | (void) printf("'-' for standard input or output.\n"); |
| 3558 | return(MagickFalse); |
| 3559 | } |
| 3560 | |
| 3561 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3562 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3563 | { |
| 3564 | #define DestroyMogrify() \ |
| 3565 | { \ |
| 3566 | if (format != (char *) NULL) \ |
| 3567 | format=DestroyString(format); \ |
| 3568 | if (path != (char *) NULL) \ |
| 3569 | path=DestroyString(path); \ |
| 3570 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3571 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3572 | argv[i]=DestroyString(argv[i]); \ |
| 3573 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3574 | } |
| 3575 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3576 | { \ |
| 3577 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3578 | option); \ |
| 3579 | DestroyMogrify(); \ |
| 3580 | return(MagickFalse); \ |
| 3581 | } |
| 3582 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3583 | { \ |
| 3584 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3585 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3586 | DestroyMogrify(); \ |
| 3587 | return(MagickFalse); \ |
| 3588 | } |
| 3589 | |
| 3590 | char |
| 3591 | *format, |
| 3592 | *option, |
| 3593 | *path; |
| 3594 | |
| 3595 | Image |
| 3596 | *image; |
| 3597 | |
| 3598 | ImageStack |
| 3599 | image_stack[MaxImageStackDepth+1]; |
| 3600 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3601 | MagickBooleanType |
| 3602 | global_colormap; |
| 3603 | |
| 3604 | MagickBooleanType |
| 3605 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3606 | pend, |
| 3607 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3608 | |
| 3609 | MagickStatusType |
| 3610 | status; |
| 3611 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3612 | register ssize_t |
| 3613 | i; |
| 3614 | |
| 3615 | ssize_t |
| 3616 | j, |
| 3617 | k; |
| 3618 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3619 | /* |
| 3620 | Set defaults. |
| 3621 | */ |
| 3622 | assert(image_info != (ImageInfo *) NULL); |
| 3623 | assert(image_info->signature == MagickSignature); |
| 3624 | if (image_info->debug != MagickFalse) |
| 3625 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3626 | assert(exception != (ExceptionInfo *) NULL); |
| 3627 | if (argc == 2) |
| 3628 | { |
| 3629 | option=argv[1]; |
| 3630 | if ((LocaleCompare("version",option+1) == 0) || |
| 3631 | (LocaleCompare("-version",option+1) == 0)) |
| 3632 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 3633 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3634 | GetMagickVersion((size_t *) NULL)); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 3635 | (void) FormatLocaleFile(stdout,"Copyright: %s\n",GetMagickCopyright()); |
| 3636 | (void) FormatLocaleFile(stdout,"Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3637 | return(MagickFalse); |
| 3638 | } |
| 3639 | } |
| 3640 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3641 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3642 | format=(char *) NULL; |
| 3643 | path=(char *) NULL; |
| 3644 | global_colormap=MagickFalse; |
| 3645 | k=0; |
| 3646 | j=1; |
| 3647 | NewImageStack(); |
| 3648 | option=(char *) NULL; |
| 3649 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3650 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3651 | status=MagickTrue; |
| 3652 | /* |
| 3653 | Parse command line. |
| 3654 | */ |
| 3655 | ReadCommandlLine(argc,&argv); |
| 3656 | status=ExpandFilenames(&argc,&argv); |
| 3657 | if (status == MagickFalse) |
| 3658 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3659 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3660 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3661 | { |
| 3662 | option=argv[i]; |
| 3663 | if (LocaleCompare(option,"(") == 0) |
| 3664 | { |
| 3665 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3666 | if (k == MaxImageStackDepth) |
| 3667 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3668 | option); |
| 3669 | PushImageStack(); |
| 3670 | continue; |
| 3671 | } |
| 3672 | if (LocaleCompare(option,")") == 0) |
| 3673 | { |
| 3674 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3675 | if (k == 0) |
| 3676 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3677 | PopImageStack(); |
| 3678 | continue; |
| 3679 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3680 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3681 | { |
| 3682 | char |
| 3683 | backup_filename[MaxTextExtent], |
| 3684 | *filename; |
| 3685 | |
| 3686 | Image |
| 3687 | *images; |
| 3688 | |
| 3689 | /* |
| 3690 | Option is a file name: begin by reading image from specified file. |
| 3691 | */ |
| 3692 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3693 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3694 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3695 | filename=argv[++i]; |
| 3696 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 3697 | images=ReadImages(image_info,exception); |
| 3698 | status&=(images != (Image *) NULL) && |
| 3699 | (exception->severity < ErrorException); |
| 3700 | if (images == (Image *) NULL) |
| 3701 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3702 | if (format != (char *) NULL) |
| 3703 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3704 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3705 | if (path != (char *) NULL) |
| 3706 | { |
| 3707 | GetPathComponent(option,TailPath,filename); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 3708 | (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3709 | path,*DirectorySeparator,filename); |
| 3710 | } |
| 3711 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3712 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3713 | AppendImageStack(images); |
| 3714 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3715 | if (global_colormap != MagickFalse) |
| 3716 | { |
| 3717 | QuantizeInfo |
| 3718 | *quantize_info; |
| 3719 | |
| 3720 | quantize_info=AcquireQuantizeInfo(image_info); |
| 3721 | (void) RemapImages(quantize_info,images,(Image *) NULL); |
| 3722 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3723 | } |
| 3724 | *backup_filename='\0'; |
| 3725 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3726 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3727 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3728 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3729 | i; |
| 3730 | |
| 3731 | /* |
| 3732 | Rename image file as backup. |
| 3733 | */ |
| 3734 | (void) CopyMagickString(backup_filename,image->filename, |
| 3735 | MaxTextExtent); |
| 3736 | for (i=0; i < 6; i++) |
| 3737 | { |
| 3738 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3739 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3740 | break; |
| 3741 | } |
| 3742 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
| 3743 | (rename(image->filename,backup_filename) != 0)) |
| 3744 | *backup_filename='\0'; |
| 3745 | } |
| 3746 | /* |
| 3747 | Write transmogrified image to disk. |
| 3748 | */ |
| 3749 | image_info->synchronize=MagickTrue; |
| 3750 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3751 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
| 3752 | (void) remove(backup_filename); |
| 3753 | RemoveAllImageStack(); |
| 3754 | continue; |
| 3755 | } |
| 3756 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3757 | switch (*(option+1)) |
| 3758 | { |
| 3759 | case 'a': |
| 3760 | { |
| 3761 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3762 | { |
| 3763 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3764 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3765 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3766 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3767 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3768 | break; |
| 3769 | } |
| 3770 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3771 | { |
| 3772 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3773 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3774 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3775 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3776 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3777 | break; |
| 3778 | } |
| 3779 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3780 | { |
| 3781 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3782 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3783 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3784 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3785 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3786 | break; |
| 3787 | } |
| 3788 | if (LocaleCompare("affine",option+1) == 0) |
| 3789 | { |
| 3790 | if (*option == '+') |
| 3791 | break; |
| 3792 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3793 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3794 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3795 | break; |
| 3796 | } |
| 3797 | if (LocaleCompare("alpha",option+1) == 0) |
| 3798 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3799 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3800 | type; |
| 3801 | |
| 3802 | if (*option == '+') |
| 3803 | break; |
| 3804 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3805 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3806 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3807 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3808 | if (type < 0) |
| 3809 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3810 | argv[i]); |
| 3811 | break; |
| 3812 | } |
| 3813 | if (LocaleCompare("annotate",option+1) == 0) |
| 3814 | { |
| 3815 | if (*option == '+') |
| 3816 | break; |
| 3817 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3818 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3819 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3820 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3821 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3822 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3823 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3824 | i++; |
| 3825 | break; |
| 3826 | } |
| 3827 | if (LocaleCompare("antialias",option+1) == 0) |
| 3828 | break; |
| 3829 | if (LocaleCompare("append",option+1) == 0) |
| 3830 | break; |
| 3831 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3832 | { |
| 3833 | if (*option == '+') |
| 3834 | break; |
| 3835 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3836 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3837 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3838 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3839 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3840 | break; |
| 3841 | } |
| 3842 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3843 | { |
| 3844 | if (*option == '+') |
| 3845 | break; |
| 3846 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3847 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3848 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3849 | break; |
| 3850 | } |
| 3851 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3852 | break; |
| 3853 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3854 | break; |
| 3855 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3856 | break; |
| 3857 | if (LocaleCompare("average",option+1) == 0) |
| 3858 | break; |
| 3859 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3860 | } |
| 3861 | case 'b': |
| 3862 | { |
| 3863 | if (LocaleCompare("background",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 | break; |
| 3871 | } |
| 3872 | if (LocaleCompare("bias",option+1) == 0) |
| 3873 | { |
| 3874 | if (*option == '+') |
| 3875 | break; |
| 3876 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3877 | if (i == (ssize_t) (argc-1)) |
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("black-point-compensation",option+1) == 0) |
| 3884 | break; |
| 3885 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 3886 | { |
| 3887 | if (*option == '+') |
| 3888 | break; |
| 3889 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3890 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3891 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3892 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3893 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3894 | break; |
| 3895 | } |
| 3896 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3897 | { |
| 3898 | if (*option == '+') |
| 3899 | break; |
| 3900 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3901 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3902 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3903 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3904 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3905 | break; |
| 3906 | } |
| 3907 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3908 | { |
| 3909 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3910 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3911 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3912 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3913 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3914 | break; |
| 3915 | } |
| 3916 | if (LocaleCompare("blur",option+1) == 0) |
| 3917 | { |
| 3918 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3919 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3920 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3921 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3922 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3923 | break; |
| 3924 | } |
| 3925 | if (LocaleCompare("border",option+1) == 0) |
| 3926 | { |
| 3927 | if (*option == '+') |
| 3928 | break; |
| 3929 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3930 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3931 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3932 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3933 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3934 | break; |
| 3935 | } |
| 3936 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3937 | { |
| 3938 | if (*option == '+') |
| 3939 | break; |
| 3940 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3941 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3942 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3943 | break; |
| 3944 | } |
| 3945 | if (LocaleCompare("box",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 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3954 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 3955 | { |
| 3956 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3957 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3958 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3959 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3960 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3961 | break; |
| 3962 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3963 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3964 | } |
| 3965 | case 'c': |
| 3966 | { |
| 3967 | if (LocaleCompare("cache",option+1) == 0) |
| 3968 | { |
| 3969 | if (*option == '+') |
| 3970 | break; |
| 3971 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3972 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3973 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3974 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3975 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3976 | break; |
| 3977 | } |
| 3978 | if (LocaleCompare("caption",option+1) == 0) |
| 3979 | { |
| 3980 | if (*option == '+') |
| 3981 | break; |
| 3982 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3983 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3984 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3985 | break; |
| 3986 | } |
| 3987 | if (LocaleCompare("channel",option+1) == 0) |
| 3988 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3989 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3990 | channel; |
| 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-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3996 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3997 | channel=ParseChannelOption(argv[i]); |
| 3998 | if (channel < 0) |
| 3999 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 4000 | argv[i]); |
| 4001 | break; |
| 4002 | } |
| 4003 | if (LocaleCompare("cdl",option+1) == 0) |
| 4004 | { |
| 4005 | if (*option == '+') |
| 4006 | break; |
| 4007 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4008 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4009 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4010 | break; |
| 4011 | } |
| 4012 | if (LocaleCompare("charcoal",option+1) == 0) |
| 4013 | { |
| 4014 | if (*option == '+') |
| 4015 | break; |
| 4016 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4017 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4018 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4019 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4020 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4021 | break; |
| 4022 | } |
| 4023 | if (LocaleCompare("chop",option+1) == 0) |
| 4024 | { |
| 4025 | if (*option == '+') |
| 4026 | break; |
| 4027 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4028 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4029 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4030 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4031 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4032 | break; |
| 4033 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4034 | if (LocaleCompare("clamp",option+1) == 0) |
| 4035 | break; |
| 4036 | if (LocaleCompare("clip",option+1) == 0) |
| 4037 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4038 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4039 | { |
| 4040 | if (*option == '+') |
| 4041 | break; |
| 4042 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4043 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4044 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4045 | break; |
| 4046 | } |
| 4047 | if (LocaleCompare("clut",option+1) == 0) |
| 4048 | break; |
| 4049 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4050 | break; |
| 4051 | if (LocaleCompare("colorize",option+1) == 0) |
| 4052 | { |
| 4053 | if (*option == '+') |
| 4054 | break; |
| 4055 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4056 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4057 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4058 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4059 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4060 | break; |
| 4061 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4062 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4063 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4064 | KernelInfo |
| 4065 | *kernel_info; |
| 4066 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4067 | if (*option == '+') |
| 4068 | break; |
| 4069 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4070 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4071 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4072 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4073 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4074 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4075 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4076 | break; |
| 4077 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4078 | if (LocaleCompare("colors",option+1) == 0) |
| 4079 | { |
| 4080 | if (*option == '+') |
| 4081 | break; |
| 4082 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4083 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4084 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4085 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4086 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4087 | break; |
| 4088 | } |
| 4089 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4090 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4091 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4092 | colorspace; |
| 4093 | |
| 4094 | if (*option == '+') |
| 4095 | break; |
| 4096 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4097 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4098 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4099 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4100 | argv[i]); |
| 4101 | if (colorspace < 0) |
| 4102 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4103 | argv[i]); |
| 4104 | break; |
| 4105 | } |
| 4106 | if (LocaleCompare("combine",option+1) == 0) |
| 4107 | break; |
| 4108 | if (LocaleCompare("comment",option+1) == 0) |
| 4109 | { |
| 4110 | if (*option == '+') |
| 4111 | break; |
| 4112 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4113 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4114 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4115 | break; |
| 4116 | } |
| 4117 | if (LocaleCompare("composite",option+1) == 0) |
| 4118 | break; |
| 4119 | if (LocaleCompare("compress",option+1) == 0) |
| 4120 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4121 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4122 | compress; |
| 4123 | |
| 4124 | if (*option == '+') |
| 4125 | break; |
| 4126 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4127 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4128 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4129 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4130 | argv[i]); |
| 4131 | if (compress < 0) |
| 4132 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4133 | argv[i]); |
| 4134 | break; |
| 4135 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4136 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4137 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4138 | if (LocaleCompare("contrast",option+1) == 0) |
| 4139 | break; |
| 4140 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4141 | { |
| 4142 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4143 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4144 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4145 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4146 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4147 | break; |
| 4148 | } |
| 4149 | if (LocaleCompare("convolve",option+1) == 0) |
| 4150 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4151 | KernelInfo |
| 4152 | *kernel_info; |
| 4153 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4154 | if (*option == '+') |
| 4155 | break; |
| 4156 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4157 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4158 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4159 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4160 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4161 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4162 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4163 | break; |
| 4164 | } |
| 4165 | if (LocaleCompare("crop",option+1) == 0) |
| 4166 | { |
| 4167 | if (*option == '+') |
| 4168 | break; |
| 4169 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4170 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4171 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4172 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4173 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4174 | break; |
| 4175 | } |
| 4176 | if (LocaleCompare("cycle",option+1) == 0) |
| 4177 | { |
| 4178 | if (*option == '+') |
| 4179 | break; |
| 4180 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4181 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4182 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4183 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4184 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4185 | break; |
| 4186 | } |
| 4187 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4188 | } |
| 4189 | case 'd': |
| 4190 | { |
| 4191 | if (LocaleCompare("decipher",option+1) == 0) |
| 4192 | { |
| 4193 | if (*option == '+') |
| 4194 | break; |
| 4195 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4196 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4197 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4198 | break; |
| 4199 | } |
| 4200 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4201 | break; |
| 4202 | if (LocaleCompare("debug",option+1) == 0) |
| 4203 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4204 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4205 | event; |
| 4206 | |
| 4207 | if (*option == '+') |
| 4208 | break; |
| 4209 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4210 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4211 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4212 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4213 | if (event < 0) |
| 4214 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4215 | argv[i]); |
| 4216 | (void) SetLogEventMask(argv[i]); |
| 4217 | break; |
| 4218 | } |
| 4219 | if (LocaleCompare("define",option+1) == 0) |
| 4220 | { |
| 4221 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4222 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4223 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4224 | if (*option == '+') |
| 4225 | { |
| 4226 | const char |
| 4227 | *define; |
| 4228 | |
| 4229 | define=GetImageOption(image_info,argv[i]); |
| 4230 | if (define == (const char *) NULL) |
| 4231 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4232 | break; |
| 4233 | } |
| 4234 | break; |
| 4235 | } |
| 4236 | if (LocaleCompare("delay",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 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4247 | if (LocaleCompare("delete",option+1) == 0) |
| 4248 | { |
| 4249 | if (*option == '+') |
| 4250 | break; |
| 4251 | i++; |
| 4252 | if (i == (ssize_t) (argc-1)) |
| 4253 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4254 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4255 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4256 | break; |
| 4257 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4258 | if (LocaleCompare("density",option+1) == 0) |
| 4259 | { |
| 4260 | if (*option == '+') |
| 4261 | break; |
| 4262 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4263 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4264 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4265 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4266 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4267 | break; |
| 4268 | } |
| 4269 | if (LocaleCompare("depth",option+1) == 0) |
| 4270 | { |
| 4271 | if (*option == '+') |
| 4272 | break; |
| 4273 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4274 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4275 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4276 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4277 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4278 | break; |
| 4279 | } |
| 4280 | if (LocaleCompare("deskew",option+1) == 0) |
| 4281 | { |
| 4282 | if (*option == '+') |
| 4283 | break; |
| 4284 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4285 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4286 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4287 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4288 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4289 | break; |
| 4290 | } |
| 4291 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4292 | break; |
| 4293 | if (LocaleCompare("dft",option+1) == 0) |
| 4294 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4295 | if (LocaleCompare("direction",option+1) == 0) |
| 4296 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4297 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4298 | direction; |
| 4299 | |
| 4300 | if (*option == '+') |
| 4301 | break; |
| 4302 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4303 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4304 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4305 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4306 | argv[i]); |
| 4307 | if (direction < 0) |
| 4308 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4309 | argv[i]); |
| 4310 | break; |
| 4311 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4312 | if (LocaleCompare("display",option+1) == 0) |
| 4313 | { |
| 4314 | if (*option == '+') |
| 4315 | break; |
| 4316 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4317 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4318 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4319 | break; |
| 4320 | } |
| 4321 | if (LocaleCompare("dispose",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 | dispose; |
| 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 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4332 | if (dispose < 0) |
| 4333 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4334 | argv[i]); |
| 4335 | break; |
| 4336 | } |
| 4337 | if (LocaleCompare("distort",option+1) == 0) |
| 4338 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4339 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4340 | op; |
| 4341 | |
| 4342 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4343 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4344 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4345 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4346 | if (op < 0) |
| 4347 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4348 | argv[i]); |
| 4349 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4350 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4351 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4352 | break; |
| 4353 | } |
| 4354 | if (LocaleCompare("dither",option+1) == 0) |
| 4355 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4356 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4357 | method; |
| 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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4363 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4364 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4365 | if (method < 0) |
| 4366 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4367 | argv[i]); |
| 4368 | break; |
| 4369 | } |
| 4370 | if (LocaleCompare("draw",option+1) == 0) |
| 4371 | { |
| 4372 | if (*option == '+') |
| 4373 | break; |
| 4374 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4375 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4376 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4377 | break; |
| 4378 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4379 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4380 | { |
| 4381 | if (*option == '+') |
| 4382 | break; |
| 4383 | i++; |
| 4384 | if (i == (ssize_t) (argc-1)) |
| 4385 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4386 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4387 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4388 | break; |
| 4389 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4390 | if (LocaleCompare("duration",option+1) == 0) |
| 4391 | { |
| 4392 | if (*option == '+') |
| 4393 | break; |
| 4394 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4395 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4396 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4397 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4398 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4399 | break; |
| 4400 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4401 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4402 | } |
| 4403 | case 'e': |
| 4404 | { |
| 4405 | if (LocaleCompare("edge",option+1) == 0) |
| 4406 | { |
| 4407 | if (*option == '+') |
| 4408 | break; |
| 4409 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4410 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4411 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4412 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4413 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4414 | break; |
| 4415 | } |
| 4416 | if (LocaleCompare("emboss",option+1) == 0) |
| 4417 | { |
| 4418 | if (*option == '+') |
| 4419 | break; |
| 4420 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4421 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4422 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4423 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4424 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4425 | break; |
| 4426 | } |
| 4427 | if (LocaleCompare("encipher",option+1) == 0) |
| 4428 | { |
| 4429 | if (*option == '+') |
| 4430 | break; |
| 4431 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4432 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4433 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4434 | break; |
| 4435 | } |
| 4436 | if (LocaleCompare("encoding",option+1) == 0) |
| 4437 | { |
| 4438 | if (*option == '+') |
| 4439 | break; |
| 4440 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4441 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4442 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4443 | break; |
| 4444 | } |
| 4445 | if (LocaleCompare("endian",option+1) == 0) |
| 4446 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4447 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4448 | endian; |
| 4449 | |
| 4450 | if (*option == '+') |
| 4451 | break; |
| 4452 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4453 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4454 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4455 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4456 | if (endian < 0) |
| 4457 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4458 | argv[i]); |
| 4459 | break; |
| 4460 | } |
| 4461 | if (LocaleCompare("enhance",option+1) == 0) |
| 4462 | break; |
| 4463 | if (LocaleCompare("equalize",option+1) == 0) |
| 4464 | break; |
| 4465 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4466 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4467 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4468 | op; |
| 4469 | |
| 4470 | if (*option == '+') |
| 4471 | break; |
| 4472 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4473 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4474 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4475 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4476 | if (op < 0) |
| 4477 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4478 | argv[i]); |
| 4479 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4480 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4481 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4482 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4483 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4484 | break; |
| 4485 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4486 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4487 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4488 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4489 | op; |
| 4490 | |
| 4491 | if (*option == '+') |
| 4492 | break; |
| 4493 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4494 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4495 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4496 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4497 | if (op < 0) |
| 4498 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4499 | argv[i]); |
| 4500 | break; |
| 4501 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4502 | if (LocaleCompare("extent",option+1) == 0) |
| 4503 | { |
| 4504 | if (*option == '+') |
| 4505 | break; |
| 4506 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4507 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4508 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4509 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4510 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4511 | break; |
| 4512 | } |
| 4513 | if (LocaleCompare("extract",option+1) == 0) |
| 4514 | { |
| 4515 | if (*option == '+') |
| 4516 | break; |
| 4517 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4518 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4519 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4520 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4521 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4522 | break; |
| 4523 | } |
| 4524 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4525 | } |
| 4526 | case 'f': |
| 4527 | { |
| 4528 | if (LocaleCompare("family",option+1) == 0) |
| 4529 | { |
| 4530 | if (*option == '+') |
| 4531 | break; |
| 4532 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4533 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4534 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4535 | break; |
| 4536 | } |
| 4537 | if (LocaleCompare("fill",option+1) == 0) |
| 4538 | { |
| 4539 | if (*option == '+') |
| 4540 | break; |
| 4541 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4542 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4543 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4544 | break; |
| 4545 | } |
| 4546 | if (LocaleCompare("filter",option+1) == 0) |
| 4547 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4548 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4549 | filter; |
| 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); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4556 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4557 | if (filter < 0) |
| 4558 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4559 | argv[i]); |
| 4560 | break; |
| 4561 | } |
| 4562 | if (LocaleCompare("flatten",option+1) == 0) |
| 4563 | break; |
| 4564 | if (LocaleCompare("flip",option+1) == 0) |
| 4565 | break; |
| 4566 | if (LocaleCompare("flop",option+1) == 0) |
| 4567 | break; |
| 4568 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4569 | { |
| 4570 | if (*option == '+') |
| 4571 | break; |
| 4572 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4573 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4574 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4575 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4576 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4577 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4578 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4579 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4580 | break; |
| 4581 | } |
| 4582 | if (LocaleCompare("font",option+1) == 0) |
| 4583 | { |
| 4584 | if (*option == '+') |
| 4585 | break; |
| 4586 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4587 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4588 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4589 | break; |
| 4590 | } |
| 4591 | if (LocaleCompare("format",option+1) == 0) |
| 4592 | { |
| 4593 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4594 | (void) CloneString(&format,(char *) NULL); |
| 4595 | if (*option == '+') |
| 4596 | break; |
| 4597 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4598 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4599 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4600 | (void) CloneString(&format,argv[i]); |
| 4601 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4602 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4603 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4604 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4605 | if (*image_info->magick == '\0') |
| 4606 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4607 | format); |
| 4608 | break; |
| 4609 | } |
| 4610 | if (LocaleCompare("frame",option+1) == 0) |
| 4611 | { |
| 4612 | if (*option == '+') |
| 4613 | break; |
| 4614 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4615 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4616 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4617 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4618 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4619 | break; |
| 4620 | } |
| 4621 | if (LocaleCompare("function",option+1) == 0) |
| 4622 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4623 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4624 | op; |
| 4625 | |
| 4626 | if (*option == '+') |
| 4627 | break; |
| 4628 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4629 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4630 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4631 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4632 | if (op < 0) |
| 4633 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4634 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4635 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4636 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4637 | break; |
| 4638 | } |
| 4639 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4640 | { |
| 4641 | if (*option == '+') |
| 4642 | break; |
| 4643 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4644 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4645 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4646 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4647 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4648 | break; |
| 4649 | } |
| 4650 | if (LocaleCompare("fx",option+1) == 0) |
| 4651 | { |
| 4652 | if (*option == '+') |
| 4653 | break; |
| 4654 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4655 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4656 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4657 | break; |
| 4658 | } |
| 4659 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4660 | } |
| 4661 | case 'g': |
| 4662 | { |
| 4663 | if (LocaleCompare("gamma",option+1) == 0) |
| 4664 | { |
| 4665 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4666 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4667 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4668 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4669 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4670 | break; |
| 4671 | } |
| 4672 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4673 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4674 | { |
| 4675 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4676 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4677 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4678 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4679 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4680 | break; |
| 4681 | } |
| 4682 | if (LocaleCompare("geometry",option+1) == 0) |
| 4683 | { |
| 4684 | if (*option == '+') |
| 4685 | break; |
| 4686 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4687 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4688 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4689 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4690 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4691 | break; |
| 4692 | } |
| 4693 | if (LocaleCompare("gravity",option+1) == 0) |
| 4694 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4695 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4696 | gravity; |
| 4697 | |
| 4698 | if (*option == '+') |
| 4699 | break; |
| 4700 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4701 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4702 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4703 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4704 | if (gravity < 0) |
| 4705 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4706 | argv[i]); |
| 4707 | break; |
| 4708 | } |
| 4709 | if (LocaleCompare("green-primary",option+1) == 0) |
| 4710 | { |
| 4711 | if (*option == '+') |
| 4712 | break; |
| 4713 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4714 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4715 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4716 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4717 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4718 | break; |
| 4719 | } |
| 4720 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4721 | } |
| 4722 | case 'h': |
| 4723 | { |
| 4724 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4725 | break; |
| 4726 | if ((LocaleCompare("help",option+1) == 0) || |
| 4727 | (LocaleCompare("-help",option+1) == 0)) |
| 4728 | return(MogrifyUsage()); |
| 4729 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4730 | } |
| 4731 | case 'i': |
| 4732 | { |
| 4733 | if (LocaleCompare("identify",option+1) == 0) |
| 4734 | break; |
| 4735 | if (LocaleCompare("idft",option+1) == 0) |
| 4736 | break; |
| 4737 | if (LocaleCompare("implode",option+1) == 0) |
| 4738 | { |
| 4739 | if (*option == '+') |
| 4740 | break; |
| 4741 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4742 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4743 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4744 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4745 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4746 | break; |
| 4747 | } |
| 4748 | if (LocaleCompare("intent",option+1) == 0) |
| 4749 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4750 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4751 | intent; |
| 4752 | |
| 4753 | if (*option == '+') |
| 4754 | break; |
| 4755 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4756 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4757 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4758 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4759 | if (intent < 0) |
| 4760 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4761 | argv[i]); |
| 4762 | break; |
| 4763 | } |
| 4764 | if (LocaleCompare("interlace",option+1) == 0) |
| 4765 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4766 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4767 | interlace; |
| 4768 | |
| 4769 | if (*option == '+') |
| 4770 | break; |
| 4771 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4772 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4773 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4774 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4775 | argv[i]); |
| 4776 | if (interlace < 0) |
| 4777 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4778 | argv[i]); |
| 4779 | break; |
| 4780 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4781 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4782 | { |
| 4783 | if (*option == '+') |
| 4784 | break; |
| 4785 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4786 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4787 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4788 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4789 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4790 | break; |
| 4791 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4792 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4793 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4794 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4795 | interpolate; |
| 4796 | |
| 4797 | if (*option == '+') |
| 4798 | break; |
| 4799 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4800 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4801 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4802 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4803 | argv[i]); |
| 4804 | if (interpolate < 0) |
| 4805 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4806 | argv[i]); |
| 4807 | break; |
| 4808 | } |
| 4809 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4810 | { |
| 4811 | if (*option == '+') |
| 4812 | break; |
| 4813 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4814 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4815 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4816 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4817 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4818 | break; |
| 4819 | } |
| 4820 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4821 | } |
| 4822 | case 'k': |
| 4823 | { |
| 4824 | if (LocaleCompare("kerning",option+1) == 0) |
| 4825 | { |
| 4826 | if (*option == '+') |
| 4827 | break; |
| 4828 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4829 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4830 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4831 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4832 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4833 | break; |
| 4834 | } |
| 4835 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4836 | } |
| 4837 | case 'l': |
| 4838 | { |
| 4839 | if (LocaleCompare("label",option+1) == 0) |
| 4840 | { |
| 4841 | if (*option == '+') |
| 4842 | break; |
| 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 | break; |
| 4847 | } |
| 4848 | if (LocaleCompare("lat",option+1) == 0) |
| 4849 | { |
| 4850 | if (*option == '+') |
| 4851 | break; |
| 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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4856 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4857 | } |
| 4858 | if (LocaleCompare("layers",option+1) == 0) |
| 4859 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4860 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4861 | type; |
| 4862 | |
| 4863 | if (*option == '+') |
| 4864 | break; |
| 4865 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4866 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4867 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4868 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4869 | if (type < 0) |
| 4870 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4871 | argv[i]); |
| 4872 | break; |
| 4873 | } |
| 4874 | if (LocaleCompare("level",option+1) == 0) |
| 4875 | { |
| 4876 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4877 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4878 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4879 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4880 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4881 | break; |
| 4882 | } |
| 4883 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4884 | { |
| 4885 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4886 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4887 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4888 | break; |
| 4889 | } |
| 4890 | if (LocaleCompare("linewidth",option+1) == 0) |
| 4891 | { |
| 4892 | if (*option == '+') |
| 4893 | break; |
| 4894 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4895 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4896 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4897 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4898 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4899 | break; |
| 4900 | } |
| 4901 | if (LocaleCompare("limit",option+1) == 0) |
| 4902 | { |
| 4903 | char |
| 4904 | *p; |
| 4905 | |
| 4906 | double |
| 4907 | value; |
| 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 | resource; |
| 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 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4918 | argv[i]); |
| 4919 | if (resource < 0) |
| 4920 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4921 | argv[i]); |
| 4922 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4923 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4924 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 4925 | value=LocaleToDouble(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4926 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4927 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4928 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4929 | break; |
| 4930 | } |
| 4931 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4932 | { |
| 4933 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4934 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4935 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4936 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4937 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4938 | break; |
| 4939 | } |
| 4940 | if (LocaleCompare("list",option+1) == 0) |
| 4941 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4942 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4943 | list; |
| 4944 | |
| 4945 | if (*option == '+') |
| 4946 | break; |
| 4947 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4948 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4949 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4950 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4951 | if (list < 0) |
| 4952 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4953 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4954 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4955 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4956 | } |
| 4957 | if (LocaleCompare("log",option+1) == 0) |
| 4958 | { |
| 4959 | if (*option == '+') |
| 4960 | break; |
| 4961 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4962 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4963 | (strchr(argv[i],'%') == (char *) NULL)) |
| 4964 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4965 | break; |
| 4966 | } |
| 4967 | if (LocaleCompare("loop",option+1) == 0) |
| 4968 | { |
| 4969 | if (*option == '+') |
| 4970 | break; |
| 4971 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4972 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4973 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4974 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4975 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4976 | break; |
| 4977 | } |
| 4978 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4979 | } |
| 4980 | case 'm': |
| 4981 | { |
| 4982 | if (LocaleCompare("map",option+1) == 0) |
| 4983 | { |
| 4984 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 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 | break; |
| 4991 | } |
| 4992 | if (LocaleCompare("mask",option+1) == 0) |
| 4993 | { |
| 4994 | if (*option == '+') |
| 4995 | break; |
| 4996 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4997 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4998 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4999 | break; |
| 5000 | } |
| 5001 | if (LocaleCompare("matte",option+1) == 0) |
| 5002 | break; |
| 5003 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 5004 | { |
| 5005 | if (*option == '+') |
| 5006 | break; |
| 5007 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5008 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5009 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5010 | break; |
| 5011 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5012 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5013 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5014 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5015 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5016 | if (LocaleCompare("modulate",option+1) == 0) |
| 5017 | { |
| 5018 | if (*option == '+') |
| 5019 | break; |
| 5020 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5021 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5022 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5023 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5024 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5025 | break; |
| 5026 | } |
| 5027 | if (LocaleCompare("median",option+1) == 0) |
| 5028 | { |
| 5029 | if (*option == '+') |
| 5030 | break; |
| 5031 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5032 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5033 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5034 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5035 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5036 | break; |
| 5037 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5038 | if (LocaleCompare("mode",option+1) == 0) |
| 5039 | { |
| 5040 | if (*option == '+') |
| 5041 | break; |
| 5042 | i++; |
| 5043 | if (i == (ssize_t) argc) |
| 5044 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5045 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5046 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5047 | break; |
| 5048 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5049 | if (LocaleCompare("monitor",option+1) == 0) |
| 5050 | break; |
| 5051 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5052 | break; |
| 5053 | if (LocaleCompare("morph",option+1) == 0) |
| 5054 | { |
| 5055 | if (*option == '+') |
| 5056 | break; |
| 5057 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5058 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5059 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5060 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5061 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5062 | break; |
| 5063 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5064 | if (LocaleCompare("morphology",option+1) == 0) |
| 5065 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5066 | char |
| 5067 | token[MaxTextExtent]; |
| 5068 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5069 | KernelInfo |
| 5070 | *kernel_info; |
| 5071 | |
| 5072 | ssize_t |
| 5073 | op; |
| 5074 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5075 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5076 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5077 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5078 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5079 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5080 | if (op < 0) |
| 5081 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5082 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5083 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5084 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5085 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5086 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5087 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5088 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5089 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5090 | break; |
| 5091 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5092 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5093 | break; |
| 5094 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5095 | { |
| 5096 | if (*option == '+') |
| 5097 | break; |
| 5098 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5099 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5100 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5101 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5102 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5103 | break; |
| 5104 | } |
| 5105 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5106 | } |
| 5107 | case 'n': |
| 5108 | { |
| 5109 | if (LocaleCompare("negate",option+1) == 0) |
| 5110 | break; |
| 5111 | if (LocaleCompare("noise",option+1) == 0) |
| 5112 | { |
| 5113 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5114 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5115 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5116 | if (*option == '+') |
| 5117 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5118 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5119 | noise; |
| 5120 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5121 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5122 | if (noise < 0) |
| 5123 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5124 | argv[i]); |
| 5125 | break; |
| 5126 | } |
| 5127 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5128 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5129 | break; |
| 5130 | } |
| 5131 | if (LocaleCompare("noop",option+1) == 0) |
| 5132 | break; |
| 5133 | if (LocaleCompare("normalize",option+1) == 0) |
| 5134 | break; |
| 5135 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5136 | } |
| 5137 | case 'o': |
| 5138 | { |
| 5139 | if (LocaleCompare("opaque",option+1) == 0) |
| 5140 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5141 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5142 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5143 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5144 | break; |
| 5145 | } |
| 5146 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5147 | { |
| 5148 | if (*option == '+') |
| 5149 | break; |
| 5150 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5151 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5152 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5153 | break; |
| 5154 | } |
| 5155 | if (LocaleCompare("orient",option+1) == 0) |
| 5156 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5157 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5158 | orientation; |
| 5159 | |
| 5160 | orientation=UndefinedOrientation; |
| 5161 | if (*option == '+') |
| 5162 | break; |
| 5163 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5164 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5165 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5166 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5167 | argv[i]); |
| 5168 | if (orientation < 0) |
| 5169 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5170 | argv[i]); |
| 5171 | break; |
| 5172 | } |
| 5173 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5174 | } |
| 5175 | case 'p': |
| 5176 | { |
| 5177 | if (LocaleCompare("page",option+1) == 0) |
| 5178 | { |
| 5179 | if (*option == '+') |
| 5180 | break; |
| 5181 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5182 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5183 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5184 | break; |
| 5185 | } |
| 5186 | if (LocaleCompare("paint",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("path",option+1) == 0) |
| 5198 | { |
| 5199 | (void) CloneString(&path,(char *) NULL); |
| 5200 | if (*option == '+') |
| 5201 | break; |
| 5202 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5203 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5204 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5205 | (void) CloneString(&path,argv[i]); |
| 5206 | break; |
| 5207 | } |
| 5208 | if (LocaleCompare("pointsize",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 | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5214 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5215 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5216 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5217 | break; |
| 5218 | } |
| 5219 | if (LocaleCompare("polaroid",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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5227 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5228 | break; |
| 5229 | } |
| 5230 | if (LocaleCompare("posterize",option+1) == 0) |
| 5231 | { |
| 5232 | if (*option == '+') |
| 5233 | break; |
| 5234 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5235 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5236 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5237 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5238 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5239 | break; |
| 5240 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5241 | if (LocaleCompare("precision",option+1) == 0) |
| 5242 | { |
| 5243 | if (*option == '+') |
| 5244 | break; |
| 5245 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5246 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5247 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5248 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5249 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5250 | break; |
| 5251 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5252 | if (LocaleCompare("print",option+1) == 0) |
| 5253 | { |
| 5254 | if (*option == '+') |
| 5255 | break; |
| 5256 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5257 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5258 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5259 | break; |
| 5260 | } |
| 5261 | if (LocaleCompare("process",option+1) == 0) |
| 5262 | { |
| 5263 | if (*option == '+') |
| 5264 | break; |
| 5265 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5266 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5267 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5268 | break; |
| 5269 | } |
| 5270 | if (LocaleCompare("profile",option+1) == 0) |
| 5271 | { |
| 5272 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5273 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5274 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5275 | break; |
| 5276 | } |
| 5277 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5278 | } |
| 5279 | case 'q': |
| 5280 | { |
| 5281 | if (LocaleCompare("quality",option+1) == 0) |
| 5282 | { |
| 5283 | if (*option == '+') |
| 5284 | break; |
| 5285 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5286 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5287 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5288 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5289 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5290 | break; |
| 5291 | } |
| 5292 | if (LocaleCompare("quantize",option+1) == 0) |
| 5293 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5294 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5295 | colorspace; |
| 5296 | |
| 5297 | if (*option == '+') |
| 5298 | break; |
| 5299 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5300 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5301 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5302 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5303 | argv[i]); |
| 5304 | if (colorspace < 0) |
| 5305 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5306 | argv[i]); |
| 5307 | break; |
| 5308 | } |
| 5309 | if (LocaleCompare("quiet",option+1) == 0) |
| 5310 | break; |
| 5311 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5312 | } |
| 5313 | case 'r': |
| 5314 | { |
| 5315 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5316 | { |
| 5317 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5318 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5319 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5320 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5321 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5322 | break; |
| 5323 | } |
| 5324 | if (LocaleCompare("raise",option+1) == 0) |
| 5325 | { |
| 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 | break; |
| 5332 | } |
| 5333 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5334 | { |
| 5335 | if (*option == '+') |
| 5336 | break; |
| 5337 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5338 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5339 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5340 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5341 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5342 | break; |
| 5343 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5344 | if (LocaleCompare("recolor",option+1) == 0) |
| 5345 | { |
| 5346 | if (*option == '+') |
| 5347 | break; |
| 5348 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5349 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5350 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5351 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5352 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5353 | break; |
| 5354 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5355 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5356 | { |
| 5357 | if (*option == '+') |
| 5358 | break; |
| 5359 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5360 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5361 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5362 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5363 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5364 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5365 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5366 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5367 | if (LocaleCompare("region",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 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5378 | if (LocaleCompare("remap",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-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5384 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5385 | break; |
| 5386 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5387 | if (LocaleCompare("render",option+1) == 0) |
| 5388 | break; |
| 5389 | if (LocaleCompare("repage",option+1) == 0) |
| 5390 | { |
| 5391 | if (*option == '+') |
| 5392 | break; |
| 5393 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5394 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5395 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5396 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5397 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5398 | break; |
| 5399 | } |
| 5400 | if (LocaleCompare("resample",option+1) == 0) |
| 5401 | { |
| 5402 | if (*option == '+') |
| 5403 | break; |
| 5404 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5405 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5406 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5407 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5408 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5409 | break; |
| 5410 | } |
| 5411 | if (LocaleCompare("resize",option+1) == 0) |
| 5412 | { |
| 5413 | if (*option == '+') |
| 5414 | break; |
| 5415 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5416 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5417 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5418 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5419 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5420 | break; |
| 5421 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5422 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5423 | { |
| 5424 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5425 | break; |
| 5426 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5427 | if (LocaleCompare("reverse",option+1) == 0) |
| 5428 | break; |
| 5429 | if (LocaleCompare("roll",option+1) == 0) |
| 5430 | { |
| 5431 | if (*option == '+') |
| 5432 | break; |
| 5433 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5434 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5435 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5436 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5437 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5438 | break; |
| 5439 | } |
| 5440 | if (LocaleCompare("rotate",option+1) == 0) |
| 5441 | { |
| 5442 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5443 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5444 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5445 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5446 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5447 | break; |
| 5448 | } |
| 5449 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5450 | } |
| 5451 | case 's': |
| 5452 | { |
| 5453 | if (LocaleCompare("sample",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("sampling-factor",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("scale",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("scene",option+1) == 0) |
| 5487 | { |
| 5488 | if (*option == '+') |
| 5489 | break; |
| 5490 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5491 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5492 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5493 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5494 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5495 | break; |
| 5496 | } |
| 5497 | if (LocaleCompare("seed",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("segment",option+1) == 0) |
| 5509 | { |
| 5510 | if (*option == '+') |
| 5511 | break; |
| 5512 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5513 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5514 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5515 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5516 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5517 | break; |
| 5518 | } |
| 5519 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5520 | { |
| 5521 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5522 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5523 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5524 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5525 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5526 | break; |
| 5527 | } |
| 5528 | if (LocaleCompare("separate",option+1) == 0) |
| 5529 | break; |
| 5530 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5531 | { |
| 5532 | if (*option == '+') |
| 5533 | break; |
| 5534 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5535 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5536 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5537 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5538 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5539 | break; |
| 5540 | } |
| 5541 | if (LocaleCompare("set",option+1) == 0) |
| 5542 | { |
| 5543 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5544 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5545 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5546 | if (*option == '+') |
| 5547 | break; |
| 5548 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5549 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5550 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5551 | break; |
| 5552 | } |
| 5553 | if (LocaleCompare("shade",option+1) == 0) |
| 5554 | { |
| 5555 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5556 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5557 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5558 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5559 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5560 | break; |
| 5561 | } |
| 5562 | if (LocaleCompare("shadow",option+1) == 0) |
| 5563 | { |
| 5564 | if (*option == '+') |
| 5565 | break; |
| 5566 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5567 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5568 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5569 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5570 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5571 | break; |
| 5572 | } |
| 5573 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5574 | { |
| 5575 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5576 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5577 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5578 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5579 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5580 | break; |
| 5581 | } |
| 5582 | if (LocaleCompare("shave",option+1) == 0) |
| 5583 | { |
| 5584 | if (*option == '+') |
| 5585 | break; |
| 5586 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5587 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5588 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5589 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5590 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5591 | break; |
| 5592 | } |
| 5593 | if (LocaleCompare("shear",option+1) == 0) |
| 5594 | { |
| 5595 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5596 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5597 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5598 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5599 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5600 | break; |
| 5601 | } |
| 5602 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5603 | { |
| 5604 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5605 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5606 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5607 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5608 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5609 | break; |
| 5610 | } |
| 5611 | if (LocaleCompare("size",option+1) == 0) |
| 5612 | { |
| 5613 | if (*option == '+') |
| 5614 | break; |
| 5615 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5616 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5617 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5618 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5619 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5620 | break; |
| 5621 | } |
| 5622 | if (LocaleCompare("sketch",option+1) == 0) |
| 5623 | { |
| 5624 | if (*option == '+') |
| 5625 | break; |
| 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); |
| 5629 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5630 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5631 | break; |
| 5632 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5633 | if (LocaleCompare("smush",option+1) == 0) |
| 5634 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5635 | i++; |
| 5636 | if (i == (ssize_t) argc) |
| 5637 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5638 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5639 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5640 | i++; |
| 5641 | break; |
| 5642 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5643 | if (LocaleCompare("solarize",option+1) == 0) |
| 5644 | { |
| 5645 | if (*option == '+') |
| 5646 | break; |
| 5647 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5648 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5649 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5650 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5651 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5652 | break; |
| 5653 | } |
| 5654 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5655 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5656 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5657 | op; |
| 5658 | |
| 5659 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5660 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5661 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5662 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5663 | if (op < 0) |
| 5664 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5665 | argv[i]); |
| 5666 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5667 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5668 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5669 | break; |
| 5670 | } |
| 5671 | if (LocaleCompare("spread",option+1) == 0) |
| 5672 | { |
| 5673 | if (*option == '+') |
| 5674 | break; |
| 5675 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5676 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5677 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5678 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5679 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5680 | break; |
| 5681 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5682 | if (LocaleCompare("statistic",option+1) == 0) |
| 5683 | { |
| 5684 | ssize_t |
| 5685 | op; |
| 5686 | |
| 5687 | if (*option == '+') |
| 5688 | break; |
| 5689 | i++; |
| 5690 | if (i == (ssize_t) argc) |
| 5691 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5692 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5693 | if (op < 0) |
| 5694 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5695 | argv[i]); |
| 5696 | i++; |
| 5697 | if (i == (ssize_t) (argc-1)) |
| 5698 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5699 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5700 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5701 | break; |
| 5702 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5703 | if (LocaleCompare("stretch",option+1) == 0) |
| 5704 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5705 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5706 | stretch; |
| 5707 | |
| 5708 | if (*option == '+') |
| 5709 | break; |
| 5710 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5711 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5712 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5713 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5714 | if (stretch < 0) |
| 5715 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5716 | argv[i]); |
| 5717 | break; |
| 5718 | } |
| 5719 | if (LocaleCompare("strip",option+1) == 0) |
| 5720 | break; |
| 5721 | if (LocaleCompare("stroke",option+1) == 0) |
| 5722 | { |
| 5723 | if (*option == '+') |
| 5724 | break; |
| 5725 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5726 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5727 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5728 | break; |
| 5729 | } |
| 5730 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5731 | { |
| 5732 | if (*option == '+') |
| 5733 | break; |
| 5734 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5735 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5736 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5737 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5738 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5739 | break; |
| 5740 | } |
| 5741 | if (LocaleCompare("style",option+1) == 0) |
| 5742 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5743 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5744 | style; |
| 5745 | |
| 5746 | if (*option == '+') |
| 5747 | break; |
| 5748 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5749 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5750 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5751 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5752 | if (style < 0) |
| 5753 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5754 | argv[i]); |
| 5755 | break; |
| 5756 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5757 | if (LocaleCompare("swap",option+1) == 0) |
| 5758 | { |
| 5759 | if (*option == '+') |
| 5760 | break; |
| 5761 | i++; |
| 5762 | if (i == (ssize_t) (argc-1)) |
| 5763 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5764 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5765 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5766 | break; |
| 5767 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5768 | if (LocaleCompare("swirl",option+1) == 0) |
| 5769 | { |
| 5770 | if (*option == '+') |
| 5771 | break; |
| 5772 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5773 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5774 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5775 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5776 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5777 | break; |
| 5778 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5779 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5780 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5781 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5782 | } |
| 5783 | case 't': |
| 5784 | { |
| 5785 | if (LocaleCompare("taint",option+1) == 0) |
| 5786 | break; |
| 5787 | if (LocaleCompare("texture",option+1) == 0) |
| 5788 | { |
| 5789 | if (*option == '+') |
| 5790 | break; |
| 5791 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5792 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5793 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5794 | break; |
| 5795 | } |
| 5796 | if (LocaleCompare("tile",option+1) == 0) |
| 5797 | { |
| 5798 | if (*option == '+') |
| 5799 | break; |
| 5800 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5801 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5802 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5803 | break; |
| 5804 | } |
| 5805 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5806 | { |
| 5807 | if (*option == '+') |
| 5808 | break; |
| 5809 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5810 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5811 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5812 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5813 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5814 | break; |
| 5815 | } |
| 5816 | if (LocaleCompare("tint",option+1) == 0) |
| 5817 | { |
| 5818 | if (*option == '+') |
| 5819 | break; |
| 5820 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5821 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5822 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5823 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5824 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5825 | break; |
| 5826 | } |
| 5827 | if (LocaleCompare("transform",option+1) == 0) |
| 5828 | break; |
| 5829 | if (LocaleCompare("transpose",option+1) == 0) |
| 5830 | break; |
| 5831 | if (LocaleCompare("transverse",option+1) == 0) |
| 5832 | break; |
| 5833 | if (LocaleCompare("threshold",option+1) == 0) |
| 5834 | { |
| 5835 | if (*option == '+') |
| 5836 | break; |
| 5837 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5838 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5839 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5840 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5841 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5842 | break; |
| 5843 | } |
| 5844 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5845 | { |
| 5846 | if (*option == '+') |
| 5847 | break; |
| 5848 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5849 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5850 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5851 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5852 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5853 | break; |
| 5854 | } |
| 5855 | if (LocaleCompare("transparent",option+1) == 0) |
| 5856 | { |
| 5857 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5858 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5859 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5860 | break; |
| 5861 | } |
| 5862 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 5863 | { |
| 5864 | if (*option == '+') |
| 5865 | break; |
| 5866 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5867 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5868 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5869 | break; |
| 5870 | } |
| 5871 | if (LocaleCompare("treedepth",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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5879 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5880 | break; |
| 5881 | } |
| 5882 | if (LocaleCompare("trim",option+1) == 0) |
| 5883 | break; |
| 5884 | if (LocaleCompare("type",option+1) == 0) |
| 5885 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5886 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5887 | type; |
| 5888 | |
| 5889 | if (*option == '+') |
| 5890 | break; |
| 5891 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5892 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5893 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5894 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5895 | if (type < 0) |
| 5896 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5897 | argv[i]); |
| 5898 | break; |
| 5899 | } |
| 5900 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5901 | } |
| 5902 | case 'u': |
| 5903 | { |
| 5904 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5905 | { |
| 5906 | if (*option == '+') |
| 5907 | break; |
| 5908 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5909 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5910 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5911 | break; |
| 5912 | } |
| 5913 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5914 | break; |
| 5915 | if (LocaleCompare("units",option+1) == 0) |
| 5916 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5917 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5918 | units; |
| 5919 | |
| 5920 | if (*option == '+') |
| 5921 | break; |
| 5922 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5923 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5924 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5925 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5926 | argv[i]); |
| 5927 | if (units < 0) |
| 5928 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5929 | argv[i]); |
| 5930 | break; |
| 5931 | } |
| 5932 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5933 | { |
| 5934 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5935 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5936 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5937 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5938 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5939 | break; |
| 5940 | } |
| 5941 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5942 | } |
| 5943 | case 'v': |
| 5944 | { |
| 5945 | if (LocaleCompare("verbose",option+1) == 0) |
| 5946 | { |
| 5947 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 5948 | break; |
| 5949 | } |
| 5950 | if ((LocaleCompare("version",option+1) == 0) || |
| 5951 | (LocaleCompare("-version",option+1) == 0)) |
| 5952 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 5953 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5954 | GetMagickVersion((size_t *) NULL)); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 5955 | (void) FormatLocaleFile(stdout,"Copyright: %s\n",GetMagickCopyright()); |
| 5956 | (void) FormatLocaleFile(stdout,"Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5957 | break; |
| 5958 | } |
| 5959 | if (LocaleCompare("view",option+1) == 0) |
| 5960 | { |
| 5961 | if (*option == '+') |
| 5962 | break; |
| 5963 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5964 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5965 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5966 | break; |
| 5967 | } |
| 5968 | if (LocaleCompare("vignette",option+1) == 0) |
| 5969 | { |
| 5970 | if (*option == '+') |
| 5971 | break; |
| 5972 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5973 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5974 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5975 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5976 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5977 | break; |
| 5978 | } |
| 5979 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 5980 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5981 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5982 | method; |
| 5983 | |
| 5984 | if (*option == '+') |
| 5985 | break; |
| 5986 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5987 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5988 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5989 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5990 | argv[i]); |
| 5991 | if (method < 0) |
| 5992 | ThrowMogrifyException(OptionError, |
| 5993 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 5994 | break; |
| 5995 | } |
| 5996 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5997 | } |
| 5998 | case 'w': |
| 5999 | { |
| 6000 | if (LocaleCompare("wave",option+1) == 0) |
| 6001 | { |
| 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("weight",option+1) == 0) |
| 6010 | { |
| 6011 | if (*option == '+') |
| 6012 | break; |
| 6013 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6014 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6015 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6016 | break; |
| 6017 | } |
| 6018 | if (LocaleCompare("white-point",option+1) == 0) |
| 6019 | { |
| 6020 | if (*option == '+') |
| 6021 | break; |
| 6022 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6023 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6024 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6025 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6026 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6027 | break; |
| 6028 | } |
| 6029 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6030 | { |
| 6031 | if (*option == '+') |
| 6032 | break; |
| 6033 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6034 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6035 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6036 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6037 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6038 | break; |
| 6039 | } |
| 6040 | if (LocaleCompare("write",option+1) == 0) |
| 6041 | { |
| 6042 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6043 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6044 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6045 | break; |
| 6046 | } |
| 6047 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6048 | } |
| 6049 | case '?': |
| 6050 | break; |
| 6051 | default: |
| 6052 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6053 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6054 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 6055 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6056 | if (fire != MagickFalse) |
| 6057 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6058 | } |
| 6059 | if (k != 0) |
| 6060 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6061 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6062 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6063 | DestroyMogrify(); |
| 6064 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6065 | } |
| 6066 | |
| 6067 | /* |
| 6068 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6069 | % % |
| 6070 | % % |
| 6071 | % % |
| 6072 | + M o g r i f y I m a g e I n f o % |
| 6073 | % % |
| 6074 | % % |
| 6075 | % % |
| 6076 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6077 | % |
| 6078 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6079 | % prescribed by command line options. |
| 6080 | % |
| 6081 | % The format of the MogrifyImageInfo method is: |
| 6082 | % |
| 6083 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6084 | % const char **argv,ExceptionInfo *exception) |
| 6085 | % |
| 6086 | % A description of each parameter follows: |
| 6087 | % |
| 6088 | % o image_info: the image info.. |
| 6089 | % |
| 6090 | % o argc: Specifies a pointer to an integer describing the number of |
| 6091 | % elements in the argument vector. |
| 6092 | % |
| 6093 | % o argv: Specifies a pointer to a text array containing the command line |
| 6094 | % arguments. |
| 6095 | % |
| 6096 | % o exception: return any errors or warnings in this structure. |
| 6097 | % |
| 6098 | */ |
| 6099 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6100 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6101 | { |
| 6102 | const char |
| 6103 | *option; |
| 6104 | |
| 6105 | GeometryInfo |
| 6106 | geometry_info; |
| 6107 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6108 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6109 | count; |
| 6110 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6111 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6112 | i; |
| 6113 | |
| 6114 | /* |
| 6115 | Initialize method variables. |
| 6116 | */ |
| 6117 | assert(image_info != (ImageInfo *) NULL); |
| 6118 | assert(image_info->signature == MagickSignature); |
| 6119 | if (image_info->debug != MagickFalse) |
| 6120 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6121 | image_info->filename); |
| 6122 | if (argc < 0) |
| 6123 | return(MagickTrue); |
| 6124 | /* |
| 6125 | Set the image settings. |
| 6126 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6127 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6128 | { |
| 6129 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6130 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6131 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6132 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6133 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6134 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6135 | break; |
| 6136 | switch (*(option+1)) |
| 6137 | { |
| 6138 | case 'a': |
| 6139 | { |
| 6140 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6141 | { |
| 6142 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6143 | break; |
| 6144 | } |
| 6145 | if (LocaleCompare("antialias",option+1) == 0) |
| 6146 | { |
| 6147 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6148 | break; |
| 6149 | } |
| 6150 | if (LocaleCompare("attenuate",option+1) == 0) |
| 6151 | { |
| 6152 | if (*option == '+') |
| 6153 | { |
| 6154 | (void) DeleteImageOption(image_info,option+1); |
| 6155 | break; |
| 6156 | } |
| 6157 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6158 | break; |
| 6159 | } |
| 6160 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6161 | { |
| 6162 | if (*option == '+') |
| 6163 | (void) CloneString(&image_info->authenticate,(char *) NULL); |
| 6164 | else |
| 6165 | (void) CloneString(&image_info->authenticate,argv[i+1]); |
| 6166 | break; |
| 6167 | } |
| 6168 | break; |
| 6169 | } |
| 6170 | case 'b': |
| 6171 | { |
| 6172 | if (LocaleCompare("background",option+1) == 0) |
| 6173 | { |
| 6174 | if (*option == '+') |
| 6175 | { |
| 6176 | (void) DeleteImageOption(image_info,option+1); |
| 6177 | (void) QueryColorDatabase(BackgroundColor, |
| 6178 | &image_info->background_color,exception); |
| 6179 | break; |
| 6180 | } |
| 6181 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6182 | (void) QueryColorDatabase(argv[i+1],&image_info->background_color, |
| 6183 | exception); |
| 6184 | break; |
| 6185 | } |
| 6186 | if (LocaleCompare("bias",option+1) == 0) |
| 6187 | { |
| 6188 | if (*option == '+') |
| 6189 | { |
| 6190 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6191 | break; |
| 6192 | } |
| 6193 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6194 | break; |
| 6195 | } |
| 6196 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6197 | { |
| 6198 | if (*option == '+') |
| 6199 | { |
| 6200 | (void) SetImageOption(image_info,option+1,"false"); |
| 6201 | break; |
| 6202 | } |
| 6203 | (void) SetImageOption(image_info,option+1,"true"); |
| 6204 | break; |
| 6205 | } |
| 6206 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6207 | { |
| 6208 | if (*option == '+') |
| 6209 | { |
| 6210 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6211 | break; |
| 6212 | } |
| 6213 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6214 | break; |
| 6215 | } |
| 6216 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6217 | { |
| 6218 | if (*option == '+') |
| 6219 | { |
| 6220 | (void) DeleteImageOption(image_info,option+1); |
| 6221 | (void) QueryColorDatabase(BorderColor,&image_info->border_color, |
| 6222 | exception); |
| 6223 | break; |
| 6224 | } |
| 6225 | (void) QueryColorDatabase(argv[i+1],&image_info->border_color, |
| 6226 | exception); |
| 6227 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6228 | break; |
| 6229 | } |
| 6230 | if (LocaleCompare("box",option+1) == 0) |
| 6231 | { |
| 6232 | if (*option == '+') |
| 6233 | { |
| 6234 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6235 | break; |
| 6236 | } |
| 6237 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6238 | break; |
| 6239 | } |
| 6240 | break; |
| 6241 | } |
| 6242 | case 'c': |
| 6243 | { |
| 6244 | if (LocaleCompare("cache",option+1) == 0) |
| 6245 | { |
| 6246 | MagickSizeType |
| 6247 | limit; |
| 6248 | |
| 6249 | limit=MagickResourceInfinity; |
| 6250 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6251 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6252 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6253 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6254 | break; |
| 6255 | } |
| 6256 | if (LocaleCompare("caption",option+1) == 0) |
| 6257 | { |
| 6258 | if (*option == '+') |
| 6259 | { |
| 6260 | (void) DeleteImageOption(image_info,option+1); |
| 6261 | break; |
| 6262 | } |
| 6263 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6264 | break; |
| 6265 | } |
| 6266 | if (LocaleCompare("channel",option+1) == 0) |
| 6267 | { |
| 6268 | if (*option == '+') |
| 6269 | { |
| 6270 | image_info->channel=DefaultChannels; |
| 6271 | break; |
| 6272 | } |
| 6273 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6274 | break; |
| 6275 | } |
| 6276 | if (LocaleCompare("colors",option+1) == 0) |
| 6277 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6278 | image_info->colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6279 | break; |
| 6280 | } |
| 6281 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6282 | { |
| 6283 | if (*option == '+') |
| 6284 | { |
| 6285 | image_info->colorspace=UndefinedColorspace; |
| 6286 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6287 | break; |
| 6288 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6289 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6290 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6291 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6292 | break; |
| 6293 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6294 | if (LocaleCompare("comment",option+1) == 0) |
| 6295 | { |
| 6296 | if (*option == '+') |
| 6297 | { |
| 6298 | (void) DeleteImageOption(image_info,option+1); |
| 6299 | break; |
| 6300 | } |
| 6301 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6302 | break; |
| 6303 | } |
| 6304 | if (LocaleCompare("compose",option+1) == 0) |
| 6305 | { |
| 6306 | if (*option == '+') |
| 6307 | { |
| 6308 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6309 | break; |
| 6310 | } |
| 6311 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6312 | break; |
| 6313 | } |
| 6314 | if (LocaleCompare("compress",option+1) == 0) |
| 6315 | { |
| 6316 | if (*option == '+') |
| 6317 | { |
| 6318 | image_info->compression=UndefinedCompression; |
| 6319 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6320 | break; |
| 6321 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6322 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6323 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6324 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6325 | break; |
| 6326 | } |
| 6327 | break; |
| 6328 | } |
| 6329 | case 'd': |
| 6330 | { |
| 6331 | if (LocaleCompare("debug",option+1) == 0) |
| 6332 | { |
| 6333 | if (*option == '+') |
| 6334 | (void) SetLogEventMask("none"); |
| 6335 | else |
| 6336 | (void) SetLogEventMask(argv[i+1]); |
| 6337 | image_info->debug=IsEventLogging(); |
| 6338 | break; |
| 6339 | } |
| 6340 | if (LocaleCompare("define",option+1) == 0) |
| 6341 | { |
| 6342 | if (*option == '+') |
| 6343 | { |
| 6344 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6345 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6346 | else |
| 6347 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6348 | break; |
| 6349 | } |
| 6350 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6351 | { |
| 6352 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6353 | exception); |
| 6354 | break; |
| 6355 | } |
| 6356 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6357 | break; |
| 6358 | } |
| 6359 | if (LocaleCompare("delay",option+1) == 0) |
| 6360 | { |
| 6361 | if (*option == '+') |
| 6362 | { |
| 6363 | (void) SetImageOption(image_info,option+1,"0"); |
| 6364 | break; |
| 6365 | } |
| 6366 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6367 | break; |
| 6368 | } |
| 6369 | if (LocaleCompare("density",option+1) == 0) |
| 6370 | { |
| 6371 | /* |
| 6372 | Set image density. |
| 6373 | */ |
| 6374 | if (*option == '+') |
| 6375 | { |
| 6376 | if (image_info->density != (char *) NULL) |
| 6377 | image_info->density=DestroyString(image_info->density); |
| 6378 | (void) SetImageOption(image_info,option+1,"72"); |
| 6379 | break; |
| 6380 | } |
| 6381 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6382 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6383 | break; |
| 6384 | } |
| 6385 | if (LocaleCompare("depth",option+1) == 0) |
| 6386 | { |
| 6387 | if (*option == '+') |
| 6388 | { |
| 6389 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6390 | break; |
| 6391 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6392 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6393 | break; |
| 6394 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6395 | if (LocaleCompare("direction",option+1) == 0) |
| 6396 | { |
| 6397 | if (*option == '+') |
| 6398 | { |
| 6399 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6400 | break; |
| 6401 | } |
| 6402 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6403 | break; |
| 6404 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6405 | if (LocaleCompare("display",option+1) == 0) |
| 6406 | { |
| 6407 | if (*option == '+') |
| 6408 | { |
| 6409 | if (image_info->server_name != (char *) NULL) |
| 6410 | image_info->server_name=DestroyString( |
| 6411 | image_info->server_name); |
| 6412 | break; |
| 6413 | } |
| 6414 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6415 | break; |
| 6416 | } |
| 6417 | if (LocaleCompare("dispose",option+1) == 0) |
| 6418 | { |
| 6419 | if (*option == '+') |
| 6420 | { |
| 6421 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6422 | break; |
| 6423 | } |
| 6424 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6425 | break; |
| 6426 | } |
| 6427 | if (LocaleCompare("dither",option+1) == 0) |
| 6428 | { |
| 6429 | if (*option == '+') |
| 6430 | { |
| 6431 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6432 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6433 | break; |
| 6434 | } |
| 6435 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6436 | image_info->dither=MagickTrue; |
| 6437 | break; |
| 6438 | } |
| 6439 | break; |
| 6440 | } |
| 6441 | case 'e': |
| 6442 | { |
| 6443 | if (LocaleCompare("encoding",option+1) == 0) |
| 6444 | { |
| 6445 | if (*option == '+') |
| 6446 | { |
| 6447 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6448 | break; |
| 6449 | } |
| 6450 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6451 | break; |
| 6452 | } |
| 6453 | if (LocaleCompare("endian",option+1) == 0) |
| 6454 | { |
| 6455 | if (*option == '+') |
| 6456 | { |
| 6457 | image_info->endian=UndefinedEndian; |
| 6458 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6459 | break; |
| 6460 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6461 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6462 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6463 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6464 | break; |
| 6465 | } |
| 6466 | if (LocaleCompare("extract",option+1) == 0) |
| 6467 | { |
| 6468 | /* |
| 6469 | Set image extract geometry. |
| 6470 | */ |
| 6471 | if (*option == '+') |
| 6472 | { |
| 6473 | if (image_info->extract != (char *) NULL) |
| 6474 | image_info->extract=DestroyString(image_info->extract); |
| 6475 | break; |
| 6476 | } |
| 6477 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6478 | break; |
| 6479 | } |
| 6480 | break; |
| 6481 | } |
| 6482 | case 'f': |
| 6483 | { |
| 6484 | if (LocaleCompare("fill",option+1) == 0) |
| 6485 | { |
| 6486 | if (*option == '+') |
| 6487 | { |
| 6488 | (void) SetImageOption(image_info,option+1,"none"); |
| 6489 | break; |
| 6490 | } |
| 6491 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6492 | break; |
| 6493 | } |
| 6494 | if (LocaleCompare("filter",option+1) == 0) |
| 6495 | { |
| 6496 | if (*option == '+') |
| 6497 | { |
| 6498 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6499 | break; |
| 6500 | } |
| 6501 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6502 | break; |
| 6503 | } |
| 6504 | if (LocaleCompare("font",option+1) == 0) |
| 6505 | { |
| 6506 | if (*option == '+') |
| 6507 | { |
| 6508 | if (image_info->font != (char *) NULL) |
| 6509 | image_info->font=DestroyString(image_info->font); |
| 6510 | break; |
| 6511 | } |
| 6512 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6513 | break; |
| 6514 | } |
| 6515 | if (LocaleCompare("format",option+1) == 0) |
| 6516 | { |
| 6517 | register const char |
| 6518 | *q; |
| 6519 | |
| 6520 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6521 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6522 | image_info->ping=MagickFalse; |
| 6523 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6524 | break; |
| 6525 | } |
| 6526 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6527 | { |
| 6528 | if (*option == '+') |
| 6529 | { |
| 6530 | image_info->fuzz=0.0; |
| 6531 | (void) SetImageOption(image_info,option+1,"0"); |
| 6532 | break; |
| 6533 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6534 | image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6535 | 1.0); |
| 6536 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6537 | break; |
| 6538 | } |
| 6539 | break; |
| 6540 | } |
| 6541 | case 'g': |
| 6542 | { |
| 6543 | if (LocaleCompare("gravity",option+1) == 0) |
| 6544 | { |
| 6545 | if (*option == '+') |
| 6546 | { |
| 6547 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6548 | break; |
| 6549 | } |
| 6550 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6551 | break; |
| 6552 | } |
| 6553 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6554 | { |
| 6555 | if (*option == '+') |
| 6556 | { |
| 6557 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6558 | break; |
| 6559 | } |
| 6560 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6561 | break; |
| 6562 | } |
| 6563 | break; |
| 6564 | } |
| 6565 | case 'i': |
| 6566 | { |
| 6567 | if (LocaleCompare("intent",option+1) == 0) |
| 6568 | { |
| 6569 | if (*option == '+') |
| 6570 | { |
| 6571 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6572 | break; |
| 6573 | } |
| 6574 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6575 | break; |
| 6576 | } |
| 6577 | if (LocaleCompare("interlace",option+1) == 0) |
| 6578 | { |
| 6579 | if (*option == '+') |
| 6580 | { |
| 6581 | image_info->interlace=UndefinedInterlace; |
| 6582 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6583 | break; |
| 6584 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6585 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6586 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6587 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6588 | break; |
| 6589 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6590 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6591 | { |
| 6592 | if (*option == '+') |
| 6593 | { |
| 6594 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6595 | break; |
| 6596 | } |
| 6597 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6598 | break; |
| 6599 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6600 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6601 | { |
| 6602 | if (*option == '+') |
| 6603 | { |
| 6604 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6605 | break; |
| 6606 | } |
| 6607 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6608 | break; |
| 6609 | } |
| 6610 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6611 | { |
| 6612 | if (*option == '+') |
| 6613 | { |
| 6614 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6615 | break; |
| 6616 | } |
| 6617 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6618 | break; |
| 6619 | } |
| 6620 | break; |
| 6621 | } |
| 6622 | case 'k': |
| 6623 | { |
| 6624 | if (LocaleCompare("kerning",option+1) == 0) |
| 6625 | { |
| 6626 | if (*option == '+') |
| 6627 | { |
| 6628 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6629 | break; |
| 6630 | } |
| 6631 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6632 | break; |
| 6633 | } |
| 6634 | break; |
| 6635 | } |
| 6636 | case 'l': |
| 6637 | { |
| 6638 | if (LocaleCompare("label",option+1) == 0) |
| 6639 | { |
| 6640 | if (*option == '+') |
| 6641 | { |
| 6642 | (void) DeleteImageOption(image_info,option+1); |
| 6643 | break; |
| 6644 | } |
| 6645 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6646 | break; |
| 6647 | } |
| 6648 | if (LocaleCompare("limit",option+1) == 0) |
| 6649 | { |
| 6650 | MagickSizeType |
| 6651 | limit; |
| 6652 | |
| 6653 | ResourceType |
| 6654 | type; |
| 6655 | |
| 6656 | if (*option == '+') |
| 6657 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6658 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6659 | MagickFalse,argv[i+1]); |
| 6660 | limit=MagickResourceInfinity; |
| 6661 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6662 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6663 | (void) SetMagickResourceLimit(type,limit); |
| 6664 | break; |
| 6665 | } |
| 6666 | if (LocaleCompare("list",option+1) == 0) |
| 6667 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6668 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6669 | list; |
| 6670 | |
| 6671 | /* |
| 6672 | Display configuration list. |
| 6673 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6674 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6675 | switch (list) |
| 6676 | { |
| 6677 | case MagickCoderOptions: |
| 6678 | { |
| 6679 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6680 | break; |
| 6681 | } |
| 6682 | case MagickColorOptions: |
| 6683 | { |
| 6684 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6685 | break; |
| 6686 | } |
| 6687 | case MagickConfigureOptions: |
| 6688 | { |
| 6689 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6690 | break; |
| 6691 | } |
| 6692 | case MagickDelegateOptions: |
| 6693 | { |
| 6694 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6695 | break; |
| 6696 | } |
| 6697 | case MagickFontOptions: |
| 6698 | { |
| 6699 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6700 | break; |
| 6701 | } |
| 6702 | case MagickFormatOptions: |
| 6703 | { |
| 6704 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6705 | break; |
| 6706 | } |
| 6707 | case MagickLocaleOptions: |
| 6708 | { |
| 6709 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6710 | break; |
| 6711 | } |
| 6712 | case MagickLogOptions: |
| 6713 | { |
| 6714 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6715 | break; |
| 6716 | } |
| 6717 | case MagickMagicOptions: |
| 6718 | { |
| 6719 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6720 | break; |
| 6721 | } |
| 6722 | case MagickMimeOptions: |
| 6723 | { |
| 6724 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6725 | break; |
| 6726 | } |
| 6727 | case MagickModuleOptions: |
| 6728 | { |
| 6729 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6730 | break; |
| 6731 | } |
| 6732 | case MagickPolicyOptions: |
| 6733 | { |
| 6734 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6735 | break; |
| 6736 | } |
| 6737 | case MagickResourceOptions: |
| 6738 | { |
| 6739 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6740 | break; |
| 6741 | } |
| 6742 | case MagickThresholdOptions: |
| 6743 | { |
| 6744 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6745 | break; |
| 6746 | } |
| 6747 | default: |
| 6748 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6749 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6750 | exception); |
| 6751 | break; |
| 6752 | } |
| 6753 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6754 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6755 | } |
| 6756 | if (LocaleCompare("log",option+1) == 0) |
| 6757 | { |
| 6758 | if (*option == '+') |
| 6759 | break; |
| 6760 | (void) SetLogFormat(argv[i+1]); |
| 6761 | break; |
| 6762 | } |
| 6763 | if (LocaleCompare("loop",option+1) == 0) |
| 6764 | { |
| 6765 | if (*option == '+') |
| 6766 | { |
| 6767 | (void) SetImageOption(image_info,option+1,"0"); |
| 6768 | break; |
| 6769 | } |
| 6770 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6771 | break; |
| 6772 | } |
| 6773 | break; |
| 6774 | } |
| 6775 | case 'm': |
| 6776 | { |
| 6777 | if (LocaleCompare("matte",option+1) == 0) |
| 6778 | { |
| 6779 | if (*option == '+') |
| 6780 | { |
| 6781 | (void) SetImageOption(image_info,option+1,"false"); |
| 6782 | break; |
| 6783 | } |
| 6784 | (void) SetImageOption(image_info,option+1,"true"); |
| 6785 | break; |
| 6786 | } |
| 6787 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6788 | { |
| 6789 | if (*option == '+') |
| 6790 | { |
| 6791 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6792 | (void) QueryColorDatabase(MatteColor,&image_info->matte_color, |
| 6793 | exception); |
| 6794 | break; |
| 6795 | } |
| 6796 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6797 | (void) QueryColorDatabase(argv[i+1],&image_info->matte_color, |
| 6798 | exception); |
| 6799 | break; |
| 6800 | } |
| 6801 | if (LocaleCompare("monitor",option+1) == 0) |
| 6802 | { |
| 6803 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6804 | (void *) NULL); |
| 6805 | break; |
| 6806 | } |
| 6807 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6808 | { |
| 6809 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6810 | break; |
| 6811 | } |
| 6812 | break; |
| 6813 | } |
| 6814 | case 'o': |
| 6815 | { |
| 6816 | if (LocaleCompare("orient",option+1) == 0) |
| 6817 | { |
| 6818 | if (*option == '+') |
| 6819 | { |
| 6820 | image_info->orientation=UndefinedOrientation; |
| 6821 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6822 | break; |
| 6823 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6824 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6825 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6826 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6827 | break; |
| 6828 | } |
| 6829 | } |
| 6830 | case 'p': |
| 6831 | { |
| 6832 | if (LocaleCompare("page",option+1) == 0) |
| 6833 | { |
| 6834 | char |
| 6835 | *canonical_page, |
| 6836 | page[MaxTextExtent]; |
| 6837 | |
| 6838 | const char |
| 6839 | *image_option; |
| 6840 | |
| 6841 | MagickStatusType |
| 6842 | flags; |
| 6843 | |
| 6844 | RectangleInfo |
| 6845 | geometry; |
| 6846 | |
| 6847 | if (*option == '+') |
| 6848 | { |
| 6849 | (void) DeleteImageOption(image_info,option+1); |
| 6850 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6851 | break; |
| 6852 | } |
| 6853 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6854 | image_option=GetImageOption(image_info,"page"); |
| 6855 | if (image_option != (const char *) NULL) |
| 6856 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6857 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6858 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6859 | canonical_page=DestroyString(canonical_page); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 6860 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6861 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6862 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 6863 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6864 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6865 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6866 | (void) SetImageOption(image_info,option+1,page); |
| 6867 | (void) CloneString(&image_info->page,page); |
| 6868 | break; |
| 6869 | } |
| 6870 | if (LocaleCompare("pen",option+1) == 0) |
| 6871 | { |
| 6872 | if (*option == '+') |
| 6873 | { |
| 6874 | (void) SetImageOption(image_info,option+1,"none"); |
| 6875 | break; |
| 6876 | } |
| 6877 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6878 | break; |
| 6879 | } |
| 6880 | if (LocaleCompare("ping",option+1) == 0) |
| 6881 | { |
| 6882 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6883 | break; |
| 6884 | } |
| 6885 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6886 | { |
| 6887 | if (*option == '+') |
| 6888 | geometry_info.rho=0.0; |
| 6889 | else |
| 6890 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6891 | image_info->pointsize=geometry_info.rho; |
| 6892 | break; |
| 6893 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6894 | if (LocaleCompare("precision",option+1) == 0) |
| 6895 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6896 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6897 | break; |
| 6898 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6899 | if (LocaleCompare("preview",option+1) == 0) |
| 6900 | { |
| 6901 | /* |
| 6902 | Preview image. |
| 6903 | */ |
| 6904 | if (*option == '+') |
| 6905 | { |
| 6906 | image_info->preview_type=UndefinedPreview; |
| 6907 | break; |
| 6908 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6909 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6910 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6911 | break; |
| 6912 | } |
| 6913 | break; |
| 6914 | } |
| 6915 | case 'q': |
| 6916 | { |
| 6917 | if (LocaleCompare("quality",option+1) == 0) |
| 6918 | { |
| 6919 | /* |
| 6920 | Set image compression quality. |
| 6921 | */ |
| 6922 | if (*option == '+') |
| 6923 | { |
| 6924 | image_info->quality=UndefinedCompressionQuality; |
| 6925 | (void) SetImageOption(image_info,option+1,"0"); |
| 6926 | break; |
| 6927 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6928 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6929 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6930 | break; |
| 6931 | } |
| 6932 | if (LocaleCompare("quiet",option+1) == 0) |
| 6933 | { |
| 6934 | static WarningHandler |
| 6935 | warning_handler = (WarningHandler) NULL; |
| 6936 | |
| 6937 | if (*option == '+') |
| 6938 | { |
| 6939 | /* |
| 6940 | Restore error or warning messages. |
| 6941 | */ |
| 6942 | warning_handler=SetWarningHandler(warning_handler); |
| 6943 | break; |
| 6944 | } |
| 6945 | /* |
| 6946 | Suppress error or warning messages. |
| 6947 | */ |
| 6948 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6949 | break; |
| 6950 | } |
| 6951 | break; |
| 6952 | } |
| 6953 | case 'r': |
| 6954 | { |
| 6955 | if (LocaleCompare("red-primary",option+1) == 0) |
| 6956 | { |
| 6957 | if (*option == '+') |
| 6958 | { |
| 6959 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6960 | break; |
| 6961 | } |
| 6962 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6963 | break; |
| 6964 | } |
| 6965 | break; |
| 6966 | } |
| 6967 | case 's': |
| 6968 | { |
| 6969 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 6970 | { |
| 6971 | /* |
| 6972 | Set image sampling factor. |
| 6973 | */ |
| 6974 | if (*option == '+') |
| 6975 | { |
| 6976 | if (image_info->sampling_factor != (char *) NULL) |
| 6977 | image_info->sampling_factor=DestroyString( |
| 6978 | image_info->sampling_factor); |
| 6979 | break; |
| 6980 | } |
| 6981 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 6982 | break; |
| 6983 | } |
| 6984 | if (LocaleCompare("scene",option+1) == 0) |
| 6985 | { |
| 6986 | /* |
| 6987 | Set image scene. |
| 6988 | */ |
| 6989 | if (*option == '+') |
| 6990 | { |
| 6991 | image_info->scene=0; |
| 6992 | (void) SetImageOption(image_info,option+1,"0"); |
| 6993 | break; |
| 6994 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6995 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6996 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6997 | break; |
| 6998 | } |
| 6999 | if (LocaleCompare("seed",option+1) == 0) |
| 7000 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7001 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7002 | seed; |
| 7003 | |
| 7004 | if (*option == '+') |
| 7005 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7006 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7007 | SeedPseudoRandomGenerator(seed); |
| 7008 | break; |
| 7009 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7010 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7011 | SeedPseudoRandomGenerator(seed); |
| 7012 | break; |
| 7013 | } |
| 7014 | if (LocaleCompare("size",option+1) == 0) |
| 7015 | { |
| 7016 | if (*option == '+') |
| 7017 | { |
| 7018 | if (image_info->size != (char *) NULL) |
| 7019 | image_info->size=DestroyString(image_info->size); |
| 7020 | break; |
| 7021 | } |
| 7022 | (void) CloneString(&image_info->size,argv[i+1]); |
| 7023 | break; |
| 7024 | } |
| 7025 | if (LocaleCompare("stroke",option+1) == 0) |
| 7026 | { |
| 7027 | if (*option == '+') |
| 7028 | { |
| 7029 | (void) SetImageOption(image_info,option+1,"none"); |
| 7030 | break; |
| 7031 | } |
| 7032 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7033 | break; |
| 7034 | } |
| 7035 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7036 | { |
| 7037 | if (*option == '+') |
| 7038 | { |
| 7039 | (void) SetImageOption(image_info,option+1,"0"); |
| 7040 | break; |
| 7041 | } |
| 7042 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7043 | break; |
| 7044 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7045 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7046 | { |
| 7047 | if (*option == '+') |
| 7048 | { |
| 7049 | image_info->synchronize=MagickFalse; |
| 7050 | break; |
| 7051 | } |
| 7052 | image_info->synchronize=MagickTrue; |
| 7053 | break; |
| 7054 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7055 | break; |
| 7056 | } |
| 7057 | case 't': |
| 7058 | { |
| 7059 | if (LocaleCompare("taint",option+1) == 0) |
| 7060 | { |
| 7061 | if (*option == '+') |
| 7062 | { |
| 7063 | (void) SetImageOption(image_info,option+1,"false"); |
| 7064 | break; |
| 7065 | } |
| 7066 | (void) SetImageOption(image_info,option+1,"true"); |
| 7067 | break; |
| 7068 | } |
| 7069 | if (LocaleCompare("texture",option+1) == 0) |
| 7070 | { |
| 7071 | if (*option == '+') |
| 7072 | { |
| 7073 | if (image_info->texture != (char *) NULL) |
| 7074 | image_info->texture=DestroyString(image_info->texture); |
| 7075 | break; |
| 7076 | } |
| 7077 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7078 | break; |
| 7079 | } |
| 7080 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7081 | { |
| 7082 | if (*option == '+') |
| 7083 | { |
| 7084 | (void) SetImageOption(image_info,option+1,"0"); |
| 7085 | break; |
| 7086 | } |
| 7087 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7088 | break; |
| 7089 | } |
| 7090 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7091 | { |
| 7092 | if (*option == '+') |
| 7093 | { |
| 7094 | (void) QueryColorDatabase("none",&image_info->transparent_color, exception); |
| 7095 | (void) SetImageOption(image_info,option+1,"none"); |
| 7096 | break; |
| 7097 | } |
| 7098 | (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color, |
| 7099 | exception); |
| 7100 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7101 | break; |
| 7102 | } |
| 7103 | if (LocaleCompare("type",option+1) == 0) |
| 7104 | { |
| 7105 | if (*option == '+') |
| 7106 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7107 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7108 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7109 | break; |
| 7110 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7111 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7112 | MagickFalse,argv[i+1]); |
| 7113 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7114 | break; |
| 7115 | } |
| 7116 | break; |
| 7117 | } |
| 7118 | case 'u': |
| 7119 | { |
| 7120 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7121 | { |
| 7122 | if (*option == '+') |
| 7123 | { |
| 7124 | (void) DeleteImageOption(image_info,option+1); |
| 7125 | break; |
| 7126 | } |
| 7127 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7128 | break; |
| 7129 | } |
| 7130 | if (LocaleCompare("units",option+1) == 0) |
| 7131 | { |
| 7132 | if (*option == '+') |
| 7133 | { |
| 7134 | image_info->units=UndefinedResolution; |
| 7135 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7136 | break; |
| 7137 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7138 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7139 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7140 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7141 | break; |
| 7142 | } |
| 7143 | break; |
| 7144 | } |
| 7145 | case 'v': |
| 7146 | { |
| 7147 | if (LocaleCompare("verbose",option+1) == 0) |
| 7148 | { |
| 7149 | if (*option == '+') |
| 7150 | { |
| 7151 | image_info->verbose=MagickFalse; |
| 7152 | break; |
| 7153 | } |
| 7154 | image_info->verbose=MagickTrue; |
| 7155 | image_info->ping=MagickFalse; |
| 7156 | break; |
| 7157 | } |
| 7158 | if (LocaleCompare("view",option+1) == 0) |
| 7159 | { |
| 7160 | if (*option == '+') |
| 7161 | { |
| 7162 | if (image_info->view != (char *) NULL) |
| 7163 | image_info->view=DestroyString(image_info->view); |
| 7164 | break; |
| 7165 | } |
| 7166 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7167 | break; |
| 7168 | } |
| 7169 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7170 | { |
| 7171 | if (*option == '+') |
| 7172 | { |
| 7173 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7174 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7175 | break; |
| 7176 | } |
| 7177 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7178 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7179 | argv[i+1]); |
| 7180 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7181 | break; |
| 7182 | } |
| 7183 | break; |
| 7184 | } |
| 7185 | case 'w': |
| 7186 | { |
| 7187 | if (LocaleCompare("white-point",option+1) == 0) |
| 7188 | { |
| 7189 | if (*option == '+') |
| 7190 | { |
| 7191 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7192 | break; |
| 7193 | } |
| 7194 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7195 | break; |
| 7196 | } |
| 7197 | break; |
| 7198 | } |
| 7199 | default: |
| 7200 | break; |
| 7201 | } |
| 7202 | i+=count; |
| 7203 | } |
| 7204 | return(MagickTrue); |
| 7205 | } |
| 7206 | |
| 7207 | /* |
| 7208 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7209 | % % |
| 7210 | % % |
| 7211 | % % |
| 7212 | + M o g r i f y I m a g e L i s t % |
| 7213 | % % |
| 7214 | % % |
| 7215 | % % |
| 7216 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7217 | % |
| 7218 | % MogrifyImageList() applies any command line options that might affect the |
| 7219 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7220 | % |
| 7221 | % The format of the MogrifyImage method is: |
| 7222 | % |
| 7223 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7224 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7225 | % |
| 7226 | % A description of each parameter follows: |
| 7227 | % |
| 7228 | % o image_info: the image info.. |
| 7229 | % |
| 7230 | % o argc: Specifies a pointer to an integer describing the number of |
| 7231 | % elements in the argument vector. |
| 7232 | % |
| 7233 | % o argv: Specifies a pointer to a text array containing the command line |
| 7234 | % arguments. |
| 7235 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7236 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7237 | % |
| 7238 | % o exception: return any errors or warnings in this structure. |
| 7239 | % |
| 7240 | */ |
| 7241 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7242 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7243 | { |
| 7244 | ChannelType |
| 7245 | channel; |
| 7246 | |
| 7247 | const char |
| 7248 | *option; |
| 7249 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7250 | ImageInfo |
| 7251 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7252 | |
| 7253 | MagickStatusType |
| 7254 | status; |
| 7255 | |
| 7256 | QuantizeInfo |
| 7257 | *quantize_info; |
| 7258 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7259 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7260 | i; |
| 7261 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7262 | ssize_t |
| 7263 | count, |
| 7264 | index; |
| 7265 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7266 | /* |
| 7267 | Apply options to the image list. |
| 7268 | */ |
| 7269 | assert(image_info != (ImageInfo *) NULL); |
| 7270 | assert(image_info->signature == MagickSignature); |
| 7271 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7272 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7273 | assert((*images)->signature == MagickSignature); |
| 7274 | if ((*images)->debug != MagickFalse) |
| 7275 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7276 | (*images)->filename); |
| 7277 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7278 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7279 | mogrify_info=CloneImageInfo(image_info); |
| 7280 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 7281 | channel=mogrify_info->channel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7282 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7283 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7284 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7285 | if (*images == (Image *) NULL) |
| 7286 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7287 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7288 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7289 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7290 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7291 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7292 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7293 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7294 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7295 | switch (*(option+1)) |
| 7296 | { |
| 7297 | case 'a': |
| 7298 | { |
| 7299 | if (LocaleCompare("affinity",option+1) == 0) |
| 7300 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7301 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7302 | if (*option == '+') |
| 7303 | { |
| 7304 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7305 | InheritException(exception,&(*images)->exception); |
| 7306 | break; |
| 7307 | } |
| 7308 | i++; |
| 7309 | break; |
| 7310 | } |
| 7311 | if (LocaleCompare("append",option+1) == 0) |
| 7312 | { |
| 7313 | Image |
| 7314 | *append_image; |
| 7315 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7316 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7317 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7318 | MagickFalse,exception); |
| 7319 | if (append_image == (Image *) NULL) |
| 7320 | { |
| 7321 | status=MagickFalse; |
| 7322 | break; |
| 7323 | } |
| 7324 | *images=DestroyImageList(*images); |
| 7325 | *images=append_image; |
| 7326 | break; |
| 7327 | } |
| 7328 | if (LocaleCompare("average",option+1) == 0) |
| 7329 | { |
| 7330 | Image |
| 7331 | *average_image; |
| 7332 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7333 | /* |
| 7334 | Average an image sequence (deprecated). |
| 7335 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7336 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7337 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7338 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7339 | if (average_image == (Image *) NULL) |
| 7340 | { |
| 7341 | status=MagickFalse; |
| 7342 | break; |
| 7343 | } |
| 7344 | *images=DestroyImageList(*images); |
| 7345 | *images=average_image; |
| 7346 | break; |
| 7347 | } |
| 7348 | break; |
| 7349 | } |
| 7350 | case 'c': |
| 7351 | { |
| 7352 | if (LocaleCompare("channel",option+1) == 0) |
| 7353 | { |
| 7354 | if (*option == '+') |
| 7355 | { |
| 7356 | channel=DefaultChannels; |
| 7357 | break; |
| 7358 | } |
| 7359 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 7360 | break; |
| 7361 | } |
| 7362 | if (LocaleCompare("clut",option+1) == 0) |
| 7363 | { |
| 7364 | Image |
| 7365 | *clut_image, |
| 7366 | *image; |
| 7367 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7368 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7369 | image=RemoveFirstImageFromList(images); |
| 7370 | clut_image=RemoveFirstImageFromList(images); |
| 7371 | if (clut_image == (Image *) NULL) |
| 7372 | { |
| 7373 | status=MagickFalse; |
| 7374 | break; |
| 7375 | } |
| 7376 | (void) ClutImageChannel(image,channel,clut_image); |
| 7377 | clut_image=DestroyImage(clut_image); |
| 7378 | InheritException(exception,&image->exception); |
| 7379 | *images=DestroyImageList(*images); |
| 7380 | *images=image; |
| 7381 | break; |
| 7382 | } |
| 7383 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7384 | { |
| 7385 | Image |
| 7386 | *coalesce_image; |
| 7387 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7388 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7389 | coalesce_image=CoalesceImages(*images,exception); |
| 7390 | if (coalesce_image == (Image *) NULL) |
| 7391 | { |
| 7392 | status=MagickFalse; |
| 7393 | break; |
| 7394 | } |
| 7395 | *images=DestroyImageList(*images); |
| 7396 | *images=coalesce_image; |
| 7397 | break; |
| 7398 | } |
| 7399 | if (LocaleCompare("combine",option+1) == 0) |
| 7400 | { |
| 7401 | Image |
| 7402 | *combine_image; |
| 7403 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7404 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7405 | combine_image=CombineImages(*images,channel,exception); |
| 7406 | if (combine_image == (Image *) NULL) |
| 7407 | { |
| 7408 | status=MagickFalse; |
| 7409 | break; |
| 7410 | } |
| 7411 | *images=DestroyImageList(*images); |
| 7412 | *images=combine_image; |
| 7413 | break; |
| 7414 | } |
| 7415 | if (LocaleCompare("composite",option+1) == 0) |
| 7416 | { |
| 7417 | Image |
| 7418 | *mask_image, |
| 7419 | *composite_image, |
| 7420 | *image; |
| 7421 | |
| 7422 | RectangleInfo |
| 7423 | geometry; |
| 7424 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7425 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7426 | image=RemoveFirstImageFromList(images); |
| 7427 | composite_image=RemoveFirstImageFromList(images); |
| 7428 | if (composite_image == (Image *) NULL) |
| 7429 | { |
| 7430 | status=MagickFalse; |
| 7431 | break; |
| 7432 | } |
| 7433 | (void) TransformImage(&composite_image,(char *) NULL, |
| 7434 | composite_image->geometry); |
| 7435 | SetGeometry(composite_image,&geometry); |
| 7436 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7437 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7438 | &geometry); |
| 7439 | mask_image=RemoveFirstImageFromList(images); |
| 7440 | if (mask_image != (Image *) NULL) |
| 7441 | { |
| 7442 | if ((image->compose == DisplaceCompositeOp) || |
| 7443 | (image->compose == DistortCompositeOp)) |
| 7444 | { |
| 7445 | /* |
| 7446 | Merge Y displacement into X displacement image. |
| 7447 | */ |
| 7448 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
| 7449 | mask_image,0,0); |
| 7450 | mask_image=DestroyImage(mask_image); |
| 7451 | } |
| 7452 | else |
| 7453 | { |
| 7454 | /* |
| 7455 | Set a blending mask for the composition. |
| 7456 | */ |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7457 | /* POSIBLE ERROR; what if image->mask already set */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7458 | image->mask=mask_image; |
| 7459 | (void) NegateImage(image->mask,MagickFalse); |
| 7460 | } |
| 7461 | } |
| 7462 | (void) CompositeImageChannel(image,channel,image->compose, |
| 7463 | composite_image,geometry.x,geometry.y); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7464 | if (mask_image != (Image *) NULL) |
| 7465 | mask_image=image->mask=DestroyImage(image->mask); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7466 | composite_image=DestroyImage(composite_image); |
| 7467 | InheritException(exception,&image->exception); |
| 7468 | *images=DestroyImageList(*images); |
| 7469 | *images=image; |
| 7470 | break; |
| 7471 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7472 | #if 0 |
| 7473 | This has been merged completely into MogrifyImage() |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7474 | if (LocaleCompare("crop",option+1) == 0) |
| 7475 | { |
| 7476 | MagickStatusType |
| 7477 | flags; |
| 7478 | |
| 7479 | RectangleInfo |
| 7480 | geometry; |
| 7481 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7482 | /* |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7483 | Crop Image. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7484 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7485 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7486 | flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception); |
| 7487 | if (((geometry.width == 0) && (geometry.height == 0)) || |
| 7488 | ((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 7489 | break; |
| 7490 | (void) TransformImages(images,argv[i+1],(char *) NULL); |
| 7491 | InheritException(exception,&(*images)->exception); |
| 7492 | break; |
| 7493 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7494 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7495 | break; |
| 7496 | } |
| 7497 | case 'd': |
| 7498 | { |
| 7499 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7500 | { |
| 7501 | Image |
| 7502 | *deconstruct_image; |
| 7503 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7504 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7505 | deconstruct_image=DeconstructImages(*images,exception); |
| 7506 | if (deconstruct_image == (Image *) NULL) |
| 7507 | { |
| 7508 | status=MagickFalse; |
| 7509 | break; |
| 7510 | } |
| 7511 | *images=DestroyImageList(*images); |
| 7512 | *images=deconstruct_image; |
| 7513 | break; |
| 7514 | } |
| 7515 | if (LocaleCompare("delete",option+1) == 0) |
| 7516 | { |
| 7517 | if (*option == '+') |
| 7518 | DeleteImages(images,"-1",exception); |
| 7519 | else |
| 7520 | DeleteImages(images,argv[i+1],exception); |
| 7521 | break; |
| 7522 | } |
| 7523 | if (LocaleCompare("dither",option+1) == 0) |
| 7524 | { |
| 7525 | if (*option == '+') |
| 7526 | { |
| 7527 | quantize_info->dither=MagickFalse; |
| 7528 | break; |
| 7529 | } |
| 7530 | quantize_info->dither=MagickTrue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7531 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7532 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7533 | break; |
| 7534 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7535 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7536 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7537 | Image |
| 7538 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7539 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7540 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7541 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7542 | else |
| 7543 | { |
| 7544 | const char |
| 7545 | *p; |
| 7546 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7547 | size_t |
| 7548 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7549 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7550 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7551 | p=strchr(argv[i+1],','); |
| 7552 | if (p == (const char *) NULL) |
| 7553 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7554 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7555 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7556 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7557 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7558 | } |
| 7559 | AppendImageToList(images, duplicate_images); |
| 7560 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7561 | break; |
| 7562 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7563 | break; |
| 7564 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7565 | case 'e': |
| 7566 | { |
| 7567 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7568 | { |
| 7569 | Image |
| 7570 | *evaluate_image; |
| 7571 | |
| 7572 | MagickEvaluateOperator |
| 7573 | op; |
| 7574 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7575 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7576 | op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions, |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7577 | MagickFalse,argv[i+1]); |
| 7578 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7579 | if (evaluate_image == (Image *) NULL) |
| 7580 | { |
| 7581 | status=MagickFalse; |
| 7582 | break; |
| 7583 | } |
| 7584 | *images=DestroyImageList(*images); |
| 7585 | *images=evaluate_image; |
| 7586 | break; |
| 7587 | } |
| 7588 | break; |
| 7589 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7590 | case 'f': |
| 7591 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7592 | if (LocaleCompare("fft",option+1) == 0) |
| 7593 | { |
| 7594 | Image |
| 7595 | *fourier_image; |
| 7596 | |
| 7597 | /* |
| 7598 | Implements the discrete Fourier transform (DFT). |
| 7599 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7600 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7601 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7602 | MagickTrue : MagickFalse,exception); |
| 7603 | if (fourier_image == (Image *) NULL) |
| 7604 | break; |
| 7605 | *images=DestroyImage(*images); |
| 7606 | *images=fourier_image; |
| 7607 | break; |
| 7608 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7609 | if (LocaleCompare("flatten",option+1) == 0) |
| 7610 | { |
| 7611 | Image |
| 7612 | *flatten_image; |
| 7613 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7614 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7615 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7616 | if (flatten_image == (Image *) NULL) |
| 7617 | break; |
| 7618 | *images=DestroyImageList(*images); |
| 7619 | *images=flatten_image; |
| 7620 | break; |
| 7621 | } |
| 7622 | if (LocaleCompare("fx",option+1) == 0) |
| 7623 | { |
| 7624 | Image |
| 7625 | *fx_image; |
| 7626 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7627 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7628 | fx_image=FxImageChannel(*images,channel,argv[i+1],exception); |
| 7629 | if (fx_image == (Image *) NULL) |
| 7630 | { |
| 7631 | status=MagickFalse; |
| 7632 | break; |
| 7633 | } |
| 7634 | *images=DestroyImageList(*images); |
| 7635 | *images=fx_image; |
| 7636 | break; |
| 7637 | } |
| 7638 | break; |
| 7639 | } |
| 7640 | case 'h': |
| 7641 | { |
| 7642 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7643 | { |
| 7644 | Image |
| 7645 | *hald_image, |
| 7646 | *image; |
| 7647 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7648 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7649 | image=RemoveFirstImageFromList(images); |
| 7650 | hald_image=RemoveFirstImageFromList(images); |
| 7651 | if (hald_image == (Image *) NULL) |
| 7652 | { |
| 7653 | status=MagickFalse; |
| 7654 | break; |
| 7655 | } |
| 7656 | (void) HaldClutImageChannel(image,channel,hald_image); |
| 7657 | hald_image=DestroyImage(hald_image); |
| 7658 | InheritException(exception,&image->exception); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7659 | if (*images != (Image *) NULL) |
| 7660 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7661 | *images=image; |
| 7662 | break; |
| 7663 | } |
| 7664 | break; |
| 7665 | } |
| 7666 | case 'i': |
| 7667 | { |
| 7668 | if (LocaleCompare("ift",option+1) == 0) |
| 7669 | { |
| 7670 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7671 | *fourier_image, |
| 7672 | *magnitude_image, |
| 7673 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7674 | |
| 7675 | /* |
| 7676 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7677 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7678 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7679 | magnitude_image=RemoveFirstImageFromList(images); |
| 7680 | phase_image=RemoveFirstImageFromList(images); |
| 7681 | if (phase_image == (Image *) NULL) |
| 7682 | { |
| 7683 | status=MagickFalse; |
| 7684 | break; |
| 7685 | } |
| 7686 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7687 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7688 | if (fourier_image == (Image *) NULL) |
| 7689 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7690 | if (*images != (Image *) NULL) |
| 7691 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7692 | *images=fourier_image; |
| 7693 | break; |
| 7694 | } |
| 7695 | if (LocaleCompare("insert",option+1) == 0) |
| 7696 | { |
| 7697 | Image |
| 7698 | *p, |
| 7699 | *q; |
| 7700 | |
| 7701 | index=0; |
| 7702 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7703 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7704 | p=RemoveLastImageFromList(images); |
| 7705 | if (p == (Image *) NULL) |
| 7706 | { |
| 7707 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7708 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7709 | status=MagickFalse; |
| 7710 | break; |
| 7711 | } |
| 7712 | q=p; |
| 7713 | if (index == 0) |
| 7714 | PrependImageToList(images,q); |
| 7715 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7716 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7717 | AppendImageToList(images,q); |
| 7718 | else |
| 7719 | { |
| 7720 | q=GetImageFromList(*images,index-1); |
| 7721 | if (q == (Image *) NULL) |
| 7722 | { |
| 7723 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7724 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7725 | status=MagickFalse; |
| 7726 | break; |
| 7727 | } |
| 7728 | InsertImageInList(&q,p); |
| 7729 | } |
| 7730 | *images=GetFirstImageInList(q); |
| 7731 | break; |
| 7732 | } |
| 7733 | break; |
| 7734 | } |
| 7735 | case 'l': |
| 7736 | { |
| 7737 | if (LocaleCompare("layers",option+1) == 0) |
| 7738 | { |
| 7739 | Image |
| 7740 | *layers; |
| 7741 | |
| 7742 | ImageLayerMethod |
| 7743 | method; |
| 7744 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7745 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7746 | layers=(Image *) NULL; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7747 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7748 | MagickFalse,argv[i+1]); |
| 7749 | switch (method) |
| 7750 | { |
| 7751 | case CoalesceLayer: |
| 7752 | { |
| 7753 | layers=CoalesceImages(*images,exception); |
| 7754 | break; |
| 7755 | } |
| 7756 | case CompareAnyLayer: |
| 7757 | case CompareClearLayer: |
| 7758 | case CompareOverlayLayer: |
| 7759 | default: |
| 7760 | { |
| 7761 | layers=CompareImageLayers(*images,method,exception); |
| 7762 | break; |
| 7763 | } |
| 7764 | case MergeLayer: |
| 7765 | case FlattenLayer: |
| 7766 | case MosaicLayer: |
| 7767 | case TrimBoundsLayer: |
| 7768 | { |
| 7769 | layers=MergeImageLayers(*images,method,exception); |
| 7770 | break; |
| 7771 | } |
| 7772 | case DisposeLayer: |
| 7773 | { |
| 7774 | layers=DisposeImages(*images,exception); |
| 7775 | break; |
| 7776 | } |
| 7777 | case OptimizeImageLayer: |
| 7778 | { |
| 7779 | layers=OptimizeImageLayers(*images,exception); |
| 7780 | break; |
| 7781 | } |
| 7782 | case OptimizePlusLayer: |
| 7783 | { |
| 7784 | layers=OptimizePlusImageLayers(*images,exception); |
| 7785 | break; |
| 7786 | } |
| 7787 | case OptimizeTransLayer: |
| 7788 | { |
| 7789 | OptimizeImageTransparency(*images,exception); |
| 7790 | break; |
| 7791 | } |
| 7792 | case RemoveDupsLayer: |
| 7793 | { |
| 7794 | RemoveDuplicateLayers(images,exception); |
| 7795 | break; |
| 7796 | } |
| 7797 | case RemoveZeroLayer: |
| 7798 | { |
| 7799 | RemoveZeroDelayLayers(images,exception); |
| 7800 | break; |
| 7801 | } |
| 7802 | case OptimizeLayer: |
| 7803 | { |
| 7804 | /* |
| 7805 | General Purpose, GIF Animation Optimizer. |
| 7806 | */ |
| 7807 | layers=CoalesceImages(*images,exception); |
| 7808 | if (layers == (Image *) NULL) |
| 7809 | { |
| 7810 | status=MagickFalse; |
| 7811 | break; |
| 7812 | } |
| 7813 | InheritException(exception,&layers->exception); |
| 7814 | *images=DestroyImageList(*images); |
| 7815 | *images=layers; |
| 7816 | layers=OptimizeImageLayers(*images,exception); |
| 7817 | if (layers == (Image *) NULL) |
| 7818 | { |
| 7819 | status=MagickFalse; |
| 7820 | break; |
| 7821 | } |
| 7822 | InheritException(exception,&layers->exception); |
| 7823 | *images=DestroyImageList(*images); |
| 7824 | *images=layers; |
| 7825 | layers=(Image *) NULL; |
| 7826 | OptimizeImageTransparency(*images,exception); |
| 7827 | InheritException(exception,&(*images)->exception); |
| 7828 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7829 | break; |
| 7830 | } |
| 7831 | case CompositeLayer: |
| 7832 | { |
| 7833 | CompositeOperator |
| 7834 | compose; |
| 7835 | |
| 7836 | Image |
| 7837 | *source; |
| 7838 | |
| 7839 | RectangleInfo |
| 7840 | geometry; |
| 7841 | |
| 7842 | /* |
| 7843 | Split image sequence at the first 'NULL:' image. |
| 7844 | */ |
| 7845 | source=(*images); |
| 7846 | while (source != (Image *) NULL) |
| 7847 | { |
| 7848 | source=GetNextImageInList(source); |
| 7849 | if ((source != (Image *) NULL) && |
| 7850 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7851 | break; |
| 7852 | } |
| 7853 | if (source != (Image *) NULL) |
| 7854 | { |
| 7855 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7856 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7857 | source=(Image *) NULL; |
| 7858 | else |
| 7859 | { |
| 7860 | /* |
| 7861 | Separate the two lists, junk the null: image. |
| 7862 | */ |
| 7863 | source=SplitImageList(source->previous); |
| 7864 | DeleteImageFromList(&source); |
| 7865 | } |
| 7866 | } |
| 7867 | if (source == (Image *) NULL) |
| 7868 | { |
| 7869 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7870 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7871 | status=MagickFalse; |
| 7872 | break; |
| 7873 | } |
| 7874 | /* |
| 7875 | Adjust offset with gravity and virtual canvas. |
| 7876 | */ |
| 7877 | SetGeometry(*images,&geometry); |
| 7878 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7879 | geometry.width=source->page.width != 0 ? |
| 7880 | source->page.width : source->columns; |
| 7881 | geometry.height=source->page.height != 0 ? |
| 7882 | source->page.height : source->rows; |
| 7883 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7884 | (*images)->page.width : (*images)->columns, |
| 7885 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7886 | (*images)->rows,(*images)->gravity,&geometry); |
| 7887 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7888 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7889 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7890 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7891 | MagickComposeOptions,MagickFalse,option); |
| 7892 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7893 | exception); |
| 7894 | source=DestroyImageList(source); |
| 7895 | break; |
| 7896 | } |
| 7897 | } |
| 7898 | if (layers == (Image *) NULL) |
| 7899 | break; |
| 7900 | InheritException(exception,&layers->exception); |
| 7901 | *images=DestroyImageList(*images); |
| 7902 | *images=layers; |
| 7903 | break; |
| 7904 | } |
| 7905 | break; |
| 7906 | } |
| 7907 | case 'm': |
| 7908 | { |
| 7909 | if (LocaleCompare("map",option+1) == 0) |
| 7910 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7911 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7912 | if (*option == '+') |
| 7913 | { |
| 7914 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7915 | InheritException(exception,&(*images)->exception); |
| 7916 | break; |
| 7917 | } |
| 7918 | i++; |
| 7919 | break; |
| 7920 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7921 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7922 | { |
| 7923 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7924 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7925 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7926 | /* |
| 7927 | Maximum image sequence (deprecated). |
| 7928 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7929 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7930 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7931 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7932 | { |
| 7933 | status=MagickFalse; |
| 7934 | break; |
| 7935 | } |
| 7936 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7937 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7938 | break; |
| 7939 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7940 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7941 | { |
| 7942 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7943 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7944 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7945 | /* |
| 7946 | Minimum image sequence (deprecated). |
| 7947 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7948 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7949 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7950 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7951 | { |
| 7952 | status=MagickFalse; |
| 7953 | break; |
| 7954 | } |
| 7955 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7956 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7957 | break; |
| 7958 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7959 | if (LocaleCompare("morph",option+1) == 0) |
| 7960 | { |
| 7961 | Image |
| 7962 | *morph_image; |
| 7963 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7964 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7965 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7966 | exception); |
| 7967 | if (morph_image == (Image *) NULL) |
| 7968 | { |
| 7969 | status=MagickFalse; |
| 7970 | break; |
| 7971 | } |
| 7972 | *images=DestroyImageList(*images); |
| 7973 | *images=morph_image; |
| 7974 | break; |
| 7975 | } |
| 7976 | if (LocaleCompare("mosaic",option+1) == 0) |
| 7977 | { |
| 7978 | Image |
| 7979 | *mosaic_image; |
| 7980 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7981 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7982 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 7983 | if (mosaic_image == (Image *) NULL) |
| 7984 | { |
| 7985 | status=MagickFalse; |
| 7986 | break; |
| 7987 | } |
| 7988 | *images=DestroyImageList(*images); |
| 7989 | *images=mosaic_image; |
| 7990 | break; |
| 7991 | } |
| 7992 | break; |
| 7993 | } |
| 7994 | case 'p': |
| 7995 | { |
| 7996 | if (LocaleCompare("print",option+1) == 0) |
| 7997 | { |
| 7998 | char |
| 7999 | *string; |
| 8000 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8001 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8002 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8003 | if (string == (char *) NULL) |
| 8004 | break; |
| 8005 | InheritException(exception,&(*images)->exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 8006 | (void) FormatLocaleFile(stdout,"%s",string); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8007 | string=DestroyString(string); |
| 8008 | } |
| 8009 | if (LocaleCompare("process",option+1) == 0) |
| 8010 | { |
| 8011 | char |
| 8012 | **arguments; |
| 8013 | |
| 8014 | int |
| 8015 | j, |
| 8016 | number_arguments; |
| 8017 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8018 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8019 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 8020 | if (arguments == (char **) NULL) |
| 8021 | break; |
| 8022 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 8023 | { |
| 8024 | char |
| 8025 | breaker, |
| 8026 | quote, |
| 8027 | *token; |
| 8028 | |
| 8029 | const char |
| 8030 | *arguments; |
| 8031 | |
| 8032 | int |
| 8033 | next, |
| 8034 | status; |
| 8035 | |
| 8036 | size_t |
| 8037 | length; |
| 8038 | |
| 8039 | TokenInfo |
| 8040 | *token_info; |
| 8041 | |
| 8042 | /* |
| 8043 | Support old style syntax, filter="-option arg". |
| 8044 | */ |
| 8045 | length=strlen(argv[i+1]); |
| 8046 | token=(char *) NULL; |
| 8047 | if (~length >= MaxTextExtent) |
| 8048 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8049 | sizeof(*token)); |
| 8050 | if (token == (char *) NULL) |
| 8051 | break; |
| 8052 | next=0; |
| 8053 | arguments=argv[i+1]; |
| 8054 | token_info=AcquireTokenInfo(); |
| 8055 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8056 | "\"",'\0',&breaker,&next,"e); |
| 8057 | token_info=DestroyTokenInfo(token_info); |
| 8058 | if (status == 0) |
| 8059 | { |
| 8060 | const char |
| 8061 | *argv; |
| 8062 | |
| 8063 | argv=(&(arguments[next])); |
| 8064 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8065 | exception); |
| 8066 | } |
| 8067 | token=DestroyString(token); |
| 8068 | break; |
| 8069 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8070 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8071 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8072 | number_arguments-2,(const char **) arguments+2,exception); |
| 8073 | for (j=0; j < number_arguments; j++) |
| 8074 | arguments[j]=DestroyString(arguments[j]); |
| 8075 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8076 | break; |
| 8077 | } |
| 8078 | break; |
| 8079 | } |
| 8080 | case 'r': |
| 8081 | { |
| 8082 | if (LocaleCompare("reverse",option+1) == 0) |
| 8083 | { |
| 8084 | ReverseImageList(images); |
| 8085 | InheritException(exception,&(*images)->exception); |
| 8086 | break; |
| 8087 | } |
| 8088 | break; |
| 8089 | } |
| 8090 | case 's': |
| 8091 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8092 | if (LocaleCompare("smush",option+1) == 0) |
| 8093 | { |
| 8094 | Image |
| 8095 | *smush_image; |
| 8096 | |
| 8097 | ssize_t |
| 8098 | offset; |
| 8099 | |
| 8100 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8101 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8102 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8103 | MagickFalse,offset,exception); |
| 8104 | if (smush_image == (Image *) NULL) |
| 8105 | { |
| 8106 | status=MagickFalse; |
| 8107 | break; |
| 8108 | } |
| 8109 | *images=DestroyImageList(*images); |
| 8110 | *images=smush_image; |
| 8111 | break; |
| 8112 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8113 | if (LocaleCompare("swap",option+1) == 0) |
| 8114 | { |
| 8115 | Image |
| 8116 | *p, |
| 8117 | *q, |
| 8118 | *swap; |
| 8119 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8120 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8121 | swap_index; |
| 8122 | |
| 8123 | index=(-1); |
| 8124 | swap_index=(-2); |
| 8125 | if (*option != '+') |
| 8126 | { |
| 8127 | GeometryInfo |
| 8128 | geometry_info; |
| 8129 | |
| 8130 | MagickStatusType |
| 8131 | flags; |
| 8132 | |
| 8133 | swap_index=(-1); |
| 8134 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8135 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8136 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8137 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8138 | } |
| 8139 | p=GetImageFromList(*images,index); |
| 8140 | q=GetImageFromList(*images,swap_index); |
| 8141 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8142 | { |
| 8143 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8144 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8145 | status=MagickFalse; |
| 8146 | break; |
| 8147 | } |
| 8148 | if (p == q) |
| 8149 | break; |
| 8150 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8151 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8152 | ReplaceImageInList(&q,swap); |
| 8153 | *images=GetFirstImageInList(q); |
| 8154 | break; |
| 8155 | } |
| 8156 | break; |
| 8157 | } |
| 8158 | case 'w': |
| 8159 | { |
| 8160 | if (LocaleCompare("write",option+1) == 0) |
| 8161 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8162 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8163 | key[MaxTextExtent]; |
| 8164 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8165 | Image |
| 8166 | *write_images; |
| 8167 | |
| 8168 | ImageInfo |
| 8169 | *write_info; |
| 8170 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8171 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 8172 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8173 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8174 | write_images=(*images); |
| 8175 | if (*option == '+') |
| 8176 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8177 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8178 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8179 | write_info=DestroyImageInfo(write_info); |
| 8180 | if (*option == '+') |
| 8181 | write_images=DestroyImageList(write_images); |
| 8182 | break; |
| 8183 | } |
| 8184 | break; |
| 8185 | } |
| 8186 | default: |
| 8187 | break; |
| 8188 | } |
| 8189 | i+=count; |
| 8190 | } |
| 8191 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8192 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8193 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8194 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8195 | } |
| 8196 | |
| 8197 | /* |
| 8198 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8199 | % % |
| 8200 | % % |
| 8201 | % % |
| 8202 | + M o g r i f y I m a g e s % |
| 8203 | % % |
| 8204 | % % |
| 8205 | % % |
| 8206 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8207 | % |
| 8208 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8209 | % prescribed by command line options. |
| 8210 | % |
| 8211 | % The format of the MogrifyImage method is: |
| 8212 | % |
| 8213 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8214 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8215 | % Image **images,Exceptioninfo *exception) |
| 8216 | % |
| 8217 | % A description of each parameter follows: |
| 8218 | % |
| 8219 | % o image_info: the image info.. |
| 8220 | % |
| 8221 | % o post: If true, post process image list operators otherwise pre-process. |
| 8222 | % |
| 8223 | % o argc: Specifies a pointer to an integer describing the number of |
| 8224 | % elements in the argument vector. |
| 8225 | % |
| 8226 | % o argv: Specifies a pointer to a text array containing the command line |
| 8227 | % arguments. |
| 8228 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8229 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8230 | % |
| 8231 | % o exception: return any errors or warnings in this structure. |
| 8232 | % |
| 8233 | */ |
| 8234 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8235 | const MagickBooleanType post,const int argc,const char **argv, |
| 8236 | Image **images,ExceptionInfo *exception) |
| 8237 | { |
| 8238 | #define MogrifyImageTag "Mogrify/Image" |
| 8239 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8240 | MagickStatusType |
| 8241 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8242 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8243 | MagickBooleanType |
| 8244 | proceed; |
| 8245 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8246 | size_t |
| 8247 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8248 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8249 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8250 | i; |
| 8251 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8252 | assert(image_info != (ImageInfo *) NULL); |
| 8253 | assert(image_info->signature == MagickSignature); |
| 8254 | if (images == (Image **) NULL) |
| 8255 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8256 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8257 | assert((*images)->signature == MagickSignature); |
| 8258 | if ((*images)->debug != MagickFalse) |
| 8259 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8260 | (*images)->filename); |
| 8261 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8262 | return(MagickTrue); |
| 8263 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8264 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8265 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8266 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8267 | #if 0 |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 8268 | FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,post?"post":"pre"); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8269 | #endif |
| 8270 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8271 | /* |
| 8272 | Pre-process multi-image sequence operators |
| 8273 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8274 | if (post == MagickFalse) |
| 8275 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8276 | |
| 8277 | /* |
| 8278 | For each image, process simple single image operators |
| 8279 | */ |
| 8280 | i=0; |
| 8281 | n=GetImageListLength(*images); |
| 8282 | for (;;) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8283 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8284 | #if 0 |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 8285 | FormatLocaleFile(stderr, "mogrify %ld of %ld\n", |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8286 | (long)GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
| 8287 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8288 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8289 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8290 | if (proceed == MagickFalse) |
| 8291 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8292 | if ( (*images)->next == (Image *) NULL ) |
| 8293 | break; |
| 8294 | *images=(*images)->next; |
| 8295 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8296 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8297 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8298 | #if 0 |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame^] | 8299 | FormatLocaleFile(stderr, "mogrify end %ld of %ld\n", |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8300 | (long)GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
| 8301 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8302 | |
| 8303 | /* |
| 8304 | Post-process, multi-image sequence operators |
| 8305 | */ |
| 8306 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8307 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8308 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8309 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8310 | } |