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 | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 152 | duration=InterpretLocaleValue(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 | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 371 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", |
| 372 | locale_message,(long) offset,(unsigned long) extent,(long) |
| 373 | (100L*offset/(extent-1))); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 374 | else |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 375 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 376 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 377 | (100L*offset/(extent-1))); |
| 378 | if (offset == (MagickOffsetType) (extent-1)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 379 | (void) FormatLocaleFile(stderr,"\n"); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 380 | (void) fflush(stderr); |
| 381 | return(MagickTrue); |
| 382 | } |
| 383 | |
| 384 | /* |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 385 | ** SparseColorOption() parses the complex -sparse-color argument into an |
| 386 | ** an array of floating point values then calls SparseColorImage(). |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 387 | ** Argument is a complex mix of floating-point pixel coodinates, and color |
| 388 | ** specifications (or direct floating point numbers). The number of floats |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 389 | ** needed to represent a color varies depending on the current channel |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 390 | ** setting. |
| 391 | */ |
| 392 | static Image *SparseColorOption(const Image *image,const ChannelType channel, |
| 393 | const SparseColorMethod method,const char *arguments, |
| 394 | const MagickBooleanType color_from_image,ExceptionInfo *exception) |
| 395 | { |
| 396 | ChannelType |
| 397 | channels; |
| 398 | |
| 399 | char |
| 400 | token[MaxTextExtent]; |
| 401 | |
| 402 | const char |
| 403 | *p; |
| 404 | |
| 405 | double |
| 406 | *sparse_arguments; |
| 407 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 408 | Image |
| 409 | *sparse_image; |
| 410 | |
| 411 | MagickPixelPacket |
| 412 | color; |
| 413 | |
| 414 | MagickBooleanType |
| 415 | error; |
| 416 | |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 417 | register size_t |
| 418 | x; |
| 419 | |
| 420 | size_t |
| 421 | number_arguments, |
| 422 | number_colors; |
| 423 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 424 | assert(image != (Image *) NULL); |
| 425 | assert(image->signature == MagickSignature); |
| 426 | if (image->debug != MagickFalse) |
| 427 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 428 | assert(exception != (ExceptionInfo *) NULL); |
| 429 | assert(exception->signature == MagickSignature); |
| 430 | /* |
| 431 | Limit channels according to image - and add up number of color channel. |
| 432 | */ |
| 433 | channels=channel; |
| 434 | if (image->colorspace != CMYKColorspace) |
| 435 | channels=(ChannelType) (channels & ~IndexChannel); /* no index channel */ |
| 436 | if (image->matte == MagickFalse) |
| 437 | channels=(ChannelType) (channels & ~OpacityChannel); /* no alpha channel */ |
| 438 | number_colors=0; |
| 439 | if ((channels & RedChannel) != 0) |
| 440 | number_colors++; |
| 441 | if ((channels & GreenChannel) != 0) |
| 442 | number_colors++; |
| 443 | if ((channels & BlueChannel) != 0) |
| 444 | number_colors++; |
| 445 | if ((channels & IndexChannel) != 0) |
| 446 | number_colors++; |
| 447 | if ((channels & OpacityChannel) != 0) |
| 448 | number_colors++; |
| 449 | |
| 450 | /* |
| 451 | Read string, to determine number of arguments needed, |
| 452 | */ |
| 453 | p=arguments; |
| 454 | x=0; |
| 455 | while( *p != '\0' ) |
| 456 | { |
| 457 | GetMagickToken(p,&p,token); |
| 458 | if ( token[0] == ',' ) continue; |
| 459 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 460 | if ( color_from_image ) { |
| 461 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 462 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 463 | "Color arg given, when colors are coming from image"); |
| 464 | return( (Image *)NULL); |
| 465 | } |
| 466 | x += number_colors; /* color argument */ |
| 467 | } |
| 468 | else { |
| 469 | x++; /* floating point argument */ |
| 470 | } |
| 471 | } |
| 472 | error=MagickTrue; |
| 473 | if ( color_from_image ) { |
| 474 | /* just the control points are being given */ |
| 475 | error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; |
| 476 | number_arguments=(x/2)*(2+number_colors); |
| 477 | } |
| 478 | else { |
| 479 | /* control points and color values */ |
| 480 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; |
| 481 | number_arguments=x; |
| 482 | } |
| 483 | if ( error ) { |
| 484 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 485 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 486 | "Invalid number of Arguments"); |
| 487 | return( (Image *)NULL); |
| 488 | } |
| 489 | |
| 490 | /* Allocate and fill in the floating point arguments */ |
| 491 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 492 | sizeof(*sparse_arguments)); |
| 493 | if (sparse_arguments == (double *) NULL) { |
| 494 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 495 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 496 | return( (Image *)NULL); |
| 497 | } |
| 498 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 499 | sizeof(*sparse_arguments)); |
| 500 | p=arguments; |
| 501 | x=0; |
| 502 | while( *p != '\0' && x < number_arguments ) { |
| 503 | /* X coordinate */ |
| 504 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 505 | if ( token[0] == '\0' ) break; |
| 506 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 507 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 508 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 509 | "Color found, instead of X-coord"); |
| 510 | error = MagickTrue; |
| 511 | break; |
| 512 | } |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 513 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 514 | /* Y coordinate */ |
| 515 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 516 | if ( token[0] == '\0' ) break; |
| 517 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 518 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 519 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 520 | "Color found, instead of Y-coord"); |
| 521 | error = MagickTrue; |
| 522 | break; |
| 523 | } |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 524 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 525 | /* color values for this control point */ |
| 526 | #if 0 |
| 527 | if ( (color_from_image ) { |
| 528 | /* get color from image */ |
| 529 | /* HOW??? */ |
| 530 | } |
| 531 | else |
| 532 | #endif |
| 533 | { |
| 534 | /* color name or function given in string argument */ |
| 535 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 536 | if ( token[0] == '\0' ) break; |
| 537 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 538 | /* Color string given */ |
| 539 | (void) QueryMagickColor(token,&color,exception); |
| 540 | if ( channels & RedChannel ) |
| 541 | sparse_arguments[x++] = QuantumScale*color.red; |
| 542 | if ( channels & GreenChannel ) |
| 543 | sparse_arguments[x++] = QuantumScale*color.green; |
| 544 | if ( channels & BlueChannel ) |
| 545 | sparse_arguments[x++] = QuantumScale*color.blue; |
| 546 | if ( channels & IndexChannel ) |
| 547 | sparse_arguments[x++] = QuantumScale*color.index; |
| 548 | if ( channels & OpacityChannel ) |
| 549 | sparse_arguments[x++] = QuantumScale*color.opacity; |
| 550 | } |
| 551 | else { |
| 552 | /* Colors given as a set of floating point values - experimental */ |
| 553 | /* NB: token contains the first floating point value to use! */ |
| 554 | if ( channels & RedChannel ) { |
| 555 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 556 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 557 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 558 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 559 | token[0] = ','; /* used this token - get another */ |
| 560 | } |
| 561 | if ( channels & GreenChannel ) { |
| 562 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 563 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 564 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 565 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 566 | token[0] = ','; /* used this token - get another */ |
| 567 | } |
| 568 | if ( channels & BlueChannel ) { |
| 569 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 570 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 571 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 572 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 573 | token[0] = ','; /* used this token - get another */ |
| 574 | } |
| 575 | if ( channels & IndexChannel ) { |
| 576 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 577 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 578 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 579 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 580 | token[0] = ','; /* used this token - get another */ |
| 581 | } |
| 582 | if ( channels & OpacityChannel ) { |
| 583 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 584 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 585 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 586 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 587 | token[0] = ','; /* used this token - get another */ |
| 588 | } |
| 589 | } |
| 590 | } |
| 591 | } |
| 592 | if ( number_arguments != x && !error ) { |
| 593 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
| 594 | "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error"); |
| 595 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 596 | return( (Image *)NULL); |
| 597 | } |
| 598 | if ( error ) |
| 599 | return( (Image *)NULL); |
| 600 | |
| 601 | /* Call the Interpolation function with the parsed arguments */ |
| 602 | sparse_image=SparseColorImage(image,channels,method,number_arguments, |
| 603 | sparse_arguments,exception); |
| 604 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 605 | return( sparse_image ); |
| 606 | } |
| 607 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 608 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 609 | const char **argv,Image **image,ExceptionInfo *exception) |
| 610 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 611 | ChannelType |
| 612 | channel; |
| 613 | |
| 614 | const char |
| 615 | *format, |
| 616 | *option; |
| 617 | |
| 618 | DrawInfo |
| 619 | *draw_info; |
| 620 | |
| 621 | GeometryInfo |
| 622 | geometry_info; |
| 623 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 624 | Image |
| 625 | *region_image; |
| 626 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 627 | ImageInfo |
| 628 | *mogrify_info; |
| 629 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 630 | MagickStatusType |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 631 | status; |
| 632 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 633 | MagickPixelPacket |
| 634 | fill; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 635 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 636 | MagickStatusType |
| 637 | flags; |
| 638 | |
| 639 | QuantizeInfo |
| 640 | *quantize_info; |
| 641 | |
| 642 | RectangleInfo |
| 643 | geometry, |
| 644 | region_geometry; |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame] | 645 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 646 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 647 | i; |
| 648 | |
| 649 | /* |
| 650 | Initialize method variables. |
| 651 | */ |
| 652 | assert(image_info != (const ImageInfo *) NULL); |
| 653 | assert(image_info->signature == MagickSignature); |
| 654 | assert(image != (Image **) NULL); |
| 655 | assert((*image)->signature == MagickSignature); |
| 656 | if ((*image)->debug != MagickFalse) |
| 657 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); |
| 658 | if (argc < 0) |
| 659 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 660 | mogrify_info=CloneImageInfo(image_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 661 | draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL); |
| 662 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 663 | SetGeometryInfo(&geometry_info); |
| 664 | GetMagickPixelPacket(*image,&fill); |
| 665 | SetMagickPixelPacket(*image,&(*image)->background_color,(IndexPacket *) NULL, |
| 666 | &fill); |
| 667 | channel=mogrify_info->channel; |
| 668 | format=GetImageOption(mogrify_info,"format"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 669 | SetGeometry(*image,®ion_geometry); |
| 670 | region_image=NewImageList(); |
| 671 | /* |
| 672 | Transmogrify the image. |
| 673 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 674 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 675 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 676 | Image |
| 677 | *mogrify_image; |
| 678 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 679 | ssize_t |
| 680 | count; |
| 681 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 682 | option=argv[i]; |
| 683 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 684 | continue; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 685 | count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option), |
| 686 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 687 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 688 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 689 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 690 | mogrify_image=(Image *)NULL; |
| 691 | switch (*(option+1)) |
| 692 | { |
| 693 | case 'a': |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 694 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 695 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 696 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 697 | /* |
| 698 | Adaptive blur image. |
| 699 | */ |
| 700 | (void) SyncImageSettings(mogrify_info,*image); |
| 701 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 702 | if ((flags & SigmaValue) == 0) |
| 703 | geometry_info.sigma=1.0; |
| 704 | mogrify_image=AdaptiveBlurImageChannel(*image,channel, |
| 705 | geometry_info.rho,geometry_info.sigma,exception); |
| 706 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 707 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 708 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 709 | { |
| 710 | /* |
| 711 | Adaptive resize image. |
| 712 | */ |
| 713 | (void) SyncImageSettings(mogrify_info,*image); |
| 714 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 715 | mogrify_image=AdaptiveResizeImage(*image,geometry.width, |
| 716 | geometry.height,exception); |
| 717 | break; |
| 718 | } |
| 719 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 720 | { |
| 721 | /* |
| 722 | Adaptive sharpen image. |
| 723 | */ |
| 724 | (void) SyncImageSettings(mogrify_info,*image); |
| 725 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 726 | if ((flags & SigmaValue) == 0) |
| 727 | geometry_info.sigma=1.0; |
| 728 | mogrify_image=AdaptiveSharpenImageChannel(*image,channel, |
| 729 | geometry_info.rho,geometry_info.sigma,exception); |
| 730 | break; |
| 731 | } |
| 732 | if (LocaleCompare("affine",option+1) == 0) |
| 733 | { |
| 734 | /* |
| 735 | Affine matrix. |
| 736 | */ |
| 737 | if (*option == '+') |
| 738 | { |
| 739 | GetAffineMatrix(&draw_info->affine); |
| 740 | break; |
| 741 | } |
| 742 | (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); |
| 743 | break; |
| 744 | } |
| 745 | if (LocaleCompare("alpha",option+1) == 0) |
| 746 | { |
| 747 | AlphaChannelType |
| 748 | alpha_type; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 749 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 750 | (void) SyncImageSettings(mogrify_info,*image); |
| 751 | alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions, |
| 752 | MagickFalse,argv[i+1]); |
| 753 | (void) SetImageAlphaChannel(*image,alpha_type); |
| 754 | InheritException(exception,&(*image)->exception); |
| 755 | break; |
| 756 | } |
| 757 | if (LocaleCompare("annotate",option+1) == 0) |
| 758 | { |
| 759 | char |
| 760 | *text, |
| 761 | geometry[MaxTextExtent]; |
| 762 | |
| 763 | /* |
| 764 | Annotate image. |
| 765 | */ |
| 766 | (void) SyncImageSettings(mogrify_info,*image); |
| 767 | SetGeometryInfo(&geometry_info); |
| 768 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 769 | if ((flags & SigmaValue) == 0) |
| 770 | geometry_info.sigma=geometry_info.rho; |
| 771 | text=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 772 | InheritException(exception,&(*image)->exception); |
| 773 | if (text == (char *) NULL) |
| 774 | break; |
| 775 | (void) CloneString(&draw_info->text,text); |
| 776 | text=DestroyString(text); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 777 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 778 | geometry_info.xi,geometry_info.psi); |
| 779 | (void) CloneString(&draw_info->geometry,geometry); |
| 780 | draw_info->affine.sx=cos(DegreesToRadians( |
| 781 | fmod(geometry_info.rho,360.0))); |
| 782 | draw_info->affine.rx=sin(DegreesToRadians( |
| 783 | fmod(geometry_info.rho,360.0))); |
| 784 | draw_info->affine.ry=(-sin(DegreesToRadians( |
| 785 | fmod(geometry_info.sigma,360.0)))); |
| 786 | draw_info->affine.sy=cos(DegreesToRadians( |
| 787 | fmod(geometry_info.sigma,360.0))); |
| 788 | (void) AnnotateImage(*image,draw_info); |
| 789 | InheritException(exception,&(*image)->exception); |
| 790 | break; |
| 791 | } |
| 792 | if (LocaleCompare("antialias",option+1) == 0) |
| 793 | { |
| 794 | draw_info->stroke_antialias=(*option == '-') ? MagickTrue : |
| 795 | MagickFalse; |
| 796 | draw_info->text_antialias=(*option == '-') ? MagickTrue : |
| 797 | MagickFalse; |
| 798 | break; |
| 799 | } |
| 800 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 801 | { |
| 802 | /* |
| 803 | Auto Adjust Gamma of image based on its mean |
| 804 | */ |
| 805 | (void) SyncImageSettings(mogrify_info,*image); |
| 806 | (void) AutoGammaImageChannel(*image,channel); |
| 807 | break; |
| 808 | } |
| 809 | if (LocaleCompare("auto-level",option+1) == 0) |
| 810 | { |
| 811 | /* |
| 812 | Perfectly Normalize (max/min stretch) the image |
| 813 | */ |
| 814 | (void) SyncImageSettings(mogrify_info,*image); |
| 815 | (void) AutoLevelImageChannel(*image,channel); |
| 816 | break; |
| 817 | } |
| 818 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 819 | { |
| 820 | (void) SyncImageSettings(mogrify_info,*image); |
| 821 | switch ((*image)->orientation) |
| 822 | { |
| 823 | case TopRightOrientation: |
| 824 | { |
| 825 | mogrify_image=FlopImage(*image,exception); |
| 826 | break; |
| 827 | } |
| 828 | case BottomRightOrientation: |
| 829 | { |
| 830 | mogrify_image=RotateImage(*image,180.0,exception); |
| 831 | break; |
| 832 | } |
| 833 | case BottomLeftOrientation: |
| 834 | { |
| 835 | mogrify_image=FlipImage(*image,exception); |
| 836 | break; |
| 837 | } |
| 838 | case LeftTopOrientation: |
| 839 | { |
| 840 | mogrify_image=TransposeImage(*image,exception); |
| 841 | break; |
| 842 | } |
| 843 | case RightTopOrientation: |
| 844 | { |
| 845 | mogrify_image=RotateImage(*image,90.0,exception); |
| 846 | break; |
| 847 | } |
| 848 | case RightBottomOrientation: |
| 849 | { |
| 850 | mogrify_image=TransverseImage(*image,exception); |
| 851 | break; |
| 852 | } |
| 853 | case LeftBottomOrientation: |
| 854 | { |
| 855 | mogrify_image=RotateImage(*image,270.0,exception); |
| 856 | break; |
| 857 | } |
| 858 | default: |
| 859 | break; |
| 860 | } |
| 861 | if (mogrify_image != (Image *) NULL) |
| 862 | mogrify_image->orientation=TopLeftOrientation; |
| 863 | break; |
| 864 | } |
| 865 | break; |
| 866 | } |
| 867 | case 'b': |
| 868 | { |
| 869 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 870 | { |
| 871 | /* |
| 872 | Black threshold image. |
| 873 | */ |
| 874 | (void) SyncImageSettings(mogrify_info,*image); |
| 875 | (void) BlackThresholdImageChannel(*image,channel,argv[i+1], |
| 876 | exception); |
| 877 | InheritException(exception,&(*image)->exception); |
| 878 | break; |
| 879 | } |
| 880 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 881 | { |
| 882 | /* |
| 883 | Blue shift image. |
| 884 | */ |
| 885 | (void) SyncImageSettings(mogrify_info,*image); |
| 886 | geometry_info.rho=1.5; |
| 887 | if (*option == '-') |
| 888 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 889 | mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception); |
| 890 | break; |
| 891 | } |
| 892 | if (LocaleCompare("blur",option+1) == 0) |
| 893 | { |
| 894 | /* |
| 895 | Gaussian blur image. |
| 896 | */ |
| 897 | (void) SyncImageSettings(mogrify_info,*image); |
| 898 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 899 | if ((flags & SigmaValue) == 0) |
| 900 | geometry_info.sigma=1.0; |
| 901 | mogrify_image=BlurImageChannel(*image,channel,geometry_info.rho, |
| 902 | geometry_info.sigma,exception); |
| 903 | break; |
| 904 | } |
| 905 | if (LocaleCompare("border",option+1) == 0) |
| 906 | { |
| 907 | /* |
| 908 | Surround image with a border of solid color. |
| 909 | */ |
| 910 | (void) SyncImageSettings(mogrify_info,*image); |
| 911 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 912 | if ((flags & SigmaValue) == 0) |
| 913 | geometry.height=geometry.width; |
| 914 | mogrify_image=BorderImage(*image,&geometry,exception); |
| 915 | break; |
| 916 | } |
| 917 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 918 | { |
| 919 | if (*option == '+') |
| 920 | { |
| 921 | (void) QueryColorDatabase(BorderColor,&draw_info->border_color, |
| 922 | exception); |
| 923 | break; |
| 924 | } |
| 925 | (void) QueryColorDatabase(argv[i+1],&draw_info->border_color, |
| 926 | exception); |
| 927 | break; |
| 928 | } |
| 929 | if (LocaleCompare("box",option+1) == 0) |
| 930 | { |
| 931 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 932 | exception); |
| 933 | break; |
| 934 | } |
| 935 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 936 | { |
| 937 | double |
| 938 | brightness, |
| 939 | contrast; |
| 940 | |
| 941 | GeometryInfo |
| 942 | geometry_info; |
| 943 | |
| 944 | MagickStatusType |
| 945 | flags; |
| 946 | |
| 947 | /* |
| 948 | Brightness / contrast image. |
| 949 | */ |
| 950 | (void) SyncImageSettings(mogrify_info,*image); |
| 951 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 952 | brightness=geometry_info.rho; |
| 953 | contrast=0.0; |
| 954 | if ((flags & SigmaValue) != 0) |
| 955 | contrast=geometry_info.sigma; |
| 956 | (void) BrightnessContrastImageChannel(*image,channel,brightness, |
| 957 | contrast); |
| 958 | InheritException(exception,&(*image)->exception); |
| 959 | break; |
| 960 | } |
| 961 | break; |
| 962 | } |
| 963 | case 'c': |
| 964 | { |
| 965 | if (LocaleCompare("cdl",option+1) == 0) |
| 966 | { |
| 967 | char |
| 968 | *color_correction_collection; |
| 969 | |
| 970 | /* |
| 971 | Color correct with a color decision list. |
| 972 | */ |
| 973 | (void) SyncImageSettings(mogrify_info,*image); |
| 974 | color_correction_collection=FileToString(argv[i+1],~0,exception); |
| 975 | if (color_correction_collection == (char *) NULL) |
| 976 | break; |
| 977 | (void) ColorDecisionListImage(*image,color_correction_collection); |
| 978 | InheritException(exception,&(*image)->exception); |
| 979 | break; |
| 980 | } |
| 981 | if (LocaleCompare("channel",option+1) == 0) |
| 982 | { |
| 983 | if (*option == '+') |
| 984 | channel=DefaultChannels; |
| 985 | else |
| 986 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 987 | break; |
| 988 | } |
| 989 | if (LocaleCompare("charcoal",option+1) == 0) |
| 990 | { |
| 991 | /* |
| 992 | Charcoal image. |
| 993 | */ |
| 994 | (void) SyncImageSettings(mogrify_info,*image); |
| 995 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 996 | if ((flags & SigmaValue) == 0) |
| 997 | geometry_info.sigma=1.0; |
| 998 | mogrify_image=CharcoalImage(*image,geometry_info.rho, |
| 999 | geometry_info.sigma,exception); |
| 1000 | break; |
| 1001 | } |
| 1002 | if (LocaleCompare("chop",option+1) == 0) |
| 1003 | { |
| 1004 | /* |
| 1005 | Chop the image. |
| 1006 | */ |
| 1007 | (void) SyncImageSettings(mogrify_info,*image); |
| 1008 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1009 | mogrify_image=ChopImage(*image,&geometry,exception); |
| 1010 | break; |
| 1011 | } |
| 1012 | if (LocaleCompare("clamp",option+1) == 0) |
| 1013 | { |
| 1014 | /* |
| 1015 | Clamp image. |
| 1016 | */ |
| 1017 | (void) SyncImageSettings(mogrify_info,*image); |
| 1018 | (void) ClampImageChannel(*image,channel); |
| 1019 | InheritException(exception,&(*image)->exception); |
| 1020 | break; |
| 1021 | } |
| 1022 | if (LocaleCompare("clip",option+1) == 0) |
| 1023 | { |
| 1024 | (void) SyncImageSettings(mogrify_info,*image); |
| 1025 | if (*option == '+') |
| 1026 | { |
| 1027 | (void) SetImageClipMask(*image,(Image *) NULL); |
| 1028 | InheritException(exception,&(*image)->exception); |
| 1029 | break; |
| 1030 | } |
| 1031 | (void) ClipImage(*image); |
| 1032 | InheritException(exception,&(*image)->exception); |
| 1033 | break; |
| 1034 | } |
| 1035 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1036 | { |
| 1037 | CacheView |
| 1038 | *mask_view; |
| 1039 | |
| 1040 | Image |
| 1041 | *mask_image; |
| 1042 | |
| 1043 | register PixelPacket |
| 1044 | *restrict q; |
| 1045 | |
| 1046 | register ssize_t |
| 1047 | x; |
| 1048 | |
| 1049 | ssize_t |
| 1050 | y; |
| 1051 | |
| 1052 | (void) SyncImageSettings(mogrify_info,*image); |
| 1053 | if (*option == '+') |
| 1054 | { |
| 1055 | /* |
| 1056 | Remove a mask. |
| 1057 | */ |
| 1058 | (void) SetImageMask(*image,(Image *) NULL); |
| 1059 | InheritException(exception,&(*image)->exception); |
| 1060 | break; |
| 1061 | } |
| 1062 | /* |
| 1063 | Set the image mask. |
| 1064 | FUTURE: This Should Be a SetImageAlphaChannel() call, Or two. |
| 1065 | */ |
| 1066 | mask_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1067 | if (mask_image == (Image *) NULL) |
| 1068 | break; |
| 1069 | if (SetImageStorageClass(mask_image,DirectClass) == MagickFalse) |
| 1070 | return(MagickFalse); |
| 1071 | mask_view=AcquireCacheView(mask_image); |
| 1072 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1073 | { |
| 1074 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1075 | exception); |
| 1076 | if (q == (PixelPacket *) NULL) |
| 1077 | break; |
| 1078 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1079 | { |
| 1080 | if (mask_image->matte == MagickFalse) |
cristy | 843c172 | 2011-05-04 23:47:02 +0000 | [diff] [blame] | 1081 | SetOpacityPixelComponent(q,PixelIntensityToQuantum(q)); |
| 1082 | SetRedPixelComponent(q,GetOpacityPixelComponent(q)); |
| 1083 | SetGreenPixelComponent(q,GetOpacityPixelComponent(q)); |
| 1084 | SetBluePixelComponent(q,GetOpacityPixelComponent(q)); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1085 | q++; |
| 1086 | } |
| 1087 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
| 1088 | break; |
| 1089 | } |
| 1090 | mask_view=DestroyCacheView(mask_view); |
| 1091 | mask_image->matte=MagickTrue; |
| 1092 | (void) SetImageClipMask(*image,mask_image); |
| 1093 | mask_image=DestroyImage(mask_image); |
| 1094 | InheritException(exception,&(*image)->exception); |
| 1095 | break; |
| 1096 | } |
| 1097 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1098 | { |
| 1099 | (void) SyncImageSettings(mogrify_info,*image); |
| 1100 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
| 1101 | MagickFalse); |
| 1102 | InheritException(exception,&(*image)->exception); |
| 1103 | break; |
| 1104 | } |
| 1105 | if (LocaleCompare("colorize",option+1) == 0) |
| 1106 | { |
| 1107 | /* |
| 1108 | Colorize the image. |
| 1109 | */ |
| 1110 | (void) SyncImageSettings(mogrify_info,*image); |
| 1111 | mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill, |
| 1112 | exception); |
| 1113 | break; |
| 1114 | } |
| 1115 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1116 | { |
| 1117 | KernelInfo |
| 1118 | *kernel; |
| 1119 | |
| 1120 | (void) SyncImageSettings(mogrify_info,*image); |
| 1121 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1122 | if (kernel == (KernelInfo *) NULL) |
| 1123 | break; |
| 1124 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 1125 | kernel=DestroyKernelInfo(kernel); |
| 1126 | break; |
| 1127 | } |
| 1128 | if (LocaleCompare("colors",option+1) == 0) |
| 1129 | { |
| 1130 | /* |
| 1131 | Reduce the number of colors in the image. |
| 1132 | */ |
| 1133 | (void) SyncImageSettings(mogrify_info,*image); |
| 1134 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
| 1135 | if (quantize_info->number_colors == 0) |
| 1136 | break; |
| 1137 | if (((*image)->storage_class == DirectClass) || |
| 1138 | (*image)->colors > quantize_info->number_colors) |
| 1139 | (void) QuantizeImage(quantize_info,*image); |
| 1140 | else |
| 1141 | (void) CompressImageColormap(*image); |
| 1142 | InheritException(exception,&(*image)->exception); |
| 1143 | break; |
| 1144 | } |
| 1145 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1146 | { |
| 1147 | ColorspaceType |
| 1148 | colorspace; |
| 1149 | |
| 1150 | (void) SyncImageSettings(mogrify_info,*image); |
| 1151 | if (*option == '+') |
| 1152 | { |
| 1153 | (void) TransformImageColorspace(*image,RGBColorspace); |
| 1154 | InheritException(exception,&(*image)->exception); |
| 1155 | break; |
| 1156 | } |
| 1157 | colorspace=(ColorspaceType) ParseCommandOption( |
| 1158 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 1159 | (void) TransformImageColorspace(*image,colorspace); |
| 1160 | InheritException(exception,&(*image)->exception); |
| 1161 | break; |
| 1162 | } |
| 1163 | if (LocaleCompare("contrast",option+1) == 0) |
| 1164 | { |
| 1165 | (void) SyncImageSettings(mogrify_info,*image); |
| 1166 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
| 1167 | MagickFalse); |
| 1168 | InheritException(exception,&(*image)->exception); |
| 1169 | break; |
| 1170 | } |
| 1171 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1172 | { |
| 1173 | double |
| 1174 | black_point, |
| 1175 | white_point; |
| 1176 | |
| 1177 | MagickStatusType |
| 1178 | flags; |
| 1179 | |
| 1180 | /* |
| 1181 | Contrast stretch image. |
| 1182 | */ |
| 1183 | (void) SyncImageSettings(mogrify_info,*image); |
| 1184 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1185 | black_point=geometry_info.rho; |
| 1186 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1187 | black_point; |
| 1188 | if ((flags & PercentValue) != 0) |
| 1189 | { |
| 1190 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1191 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1192 | } |
| 1193 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1194 | white_point; |
| 1195 | (void) ContrastStretchImageChannel(*image,channel,black_point, |
| 1196 | white_point); |
| 1197 | InheritException(exception,&(*image)->exception); |
| 1198 | break; |
| 1199 | } |
| 1200 | if (LocaleCompare("convolve",option+1) == 0) |
| 1201 | { |
| 1202 | double |
| 1203 | gamma; |
| 1204 | |
| 1205 | KernelInfo |
| 1206 | *kernel; |
| 1207 | |
| 1208 | register ssize_t |
| 1209 | j; |
| 1210 | |
| 1211 | (void) SyncImageSettings(mogrify_info,*image); |
| 1212 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1213 | if (kernel == (KernelInfo *) NULL) |
| 1214 | break; |
| 1215 | gamma=0.0; |
| 1216 | for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++) |
| 1217 | gamma+=kernel->values[j]; |
| 1218 | gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma); |
| 1219 | for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++) |
| 1220 | kernel->values[j]*=gamma; |
| 1221 | mogrify_image=FilterImageChannel(*image,channel,kernel,exception); |
| 1222 | kernel=DestroyKernelInfo(kernel); |
| 1223 | break; |
| 1224 | } |
| 1225 | if (LocaleCompare("crop",option+1) == 0) |
| 1226 | { |
| 1227 | /* |
| 1228 | Crop a image to a smaller size |
| 1229 | */ |
| 1230 | (void) SyncImageSettings(mogrify_info,*image); |
| 1231 | #if 0 |
| 1232 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1233 | if (((geometry.width != 0) || (geometry.height != 0)) && |
| 1234 | ((flags & XValue) == 0) && ((flags & YValue) == 0)) |
| 1235 | break; |
| 1236 | #endif |
| 1237 | #if 0 |
| 1238 | mogrify_image=CloneImage(*image,0,0,MagickTrue,&(*image)->exception); |
| 1239 | mogrify_image->next = mogrify_image->previous = (Image *)NULL; |
| 1240 | (void) TransformImage(&mogrify_image,argv[i+1],(char *) NULL); |
| 1241 | InheritException(exception,&mogrify_image->exception); |
| 1242 | #else |
| 1243 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
| 1244 | #endif |
| 1245 | break; |
| 1246 | } |
| 1247 | if (LocaleCompare("cycle",option+1) == 0) |
| 1248 | { |
| 1249 | /* |
| 1250 | Cycle an image colormap. |
| 1251 | */ |
| 1252 | (void) SyncImageSettings(mogrify_info,*image); |
| 1253 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1])); |
| 1254 | InheritException(exception,&(*image)->exception); |
| 1255 | break; |
| 1256 | } |
| 1257 | break; |
| 1258 | } |
| 1259 | case 'd': |
| 1260 | { |
| 1261 | if (LocaleCompare("decipher",option+1) == 0) |
| 1262 | { |
| 1263 | StringInfo |
| 1264 | *passkey; |
| 1265 | |
| 1266 | /* |
| 1267 | Decipher pixels. |
| 1268 | */ |
| 1269 | (void) SyncImageSettings(mogrify_info,*image); |
| 1270 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1271 | if (passkey != (StringInfo *) NULL) |
| 1272 | { |
| 1273 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1274 | passkey=DestroyStringInfo(passkey); |
| 1275 | } |
| 1276 | break; |
| 1277 | } |
| 1278 | if (LocaleCompare("density",option+1) == 0) |
| 1279 | { |
| 1280 | /* |
| 1281 | Set image density. |
| 1282 | */ |
| 1283 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1284 | break; |
| 1285 | } |
| 1286 | if (LocaleCompare("depth",option+1) == 0) |
| 1287 | { |
| 1288 | (void) SyncImageSettings(mogrify_info,*image); |
| 1289 | if (*option == '+') |
| 1290 | { |
| 1291 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH); |
| 1292 | break; |
| 1293 | } |
| 1294 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1])); |
| 1295 | break; |
| 1296 | } |
| 1297 | if (LocaleCompare("deskew",option+1) == 0) |
| 1298 | { |
| 1299 | double |
| 1300 | threshold; |
| 1301 | |
| 1302 | /* |
| 1303 | Straighten the image. |
| 1304 | */ |
| 1305 | (void) SyncImageSettings(mogrify_info,*image); |
| 1306 | if (*option == '+') |
| 1307 | threshold=40.0*QuantumRange/100.0; |
| 1308 | else |
| 1309 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 1310 | mogrify_image=DeskewImage(*image,threshold,exception); |
| 1311 | break; |
| 1312 | } |
| 1313 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1314 | { |
| 1315 | /* |
| 1316 | Reduce the speckles within an image. |
| 1317 | */ |
| 1318 | (void) SyncImageSettings(mogrify_info,*image); |
| 1319 | mogrify_image=DespeckleImage(*image,exception); |
| 1320 | break; |
| 1321 | } |
| 1322 | if (LocaleCompare("display",option+1) == 0) |
| 1323 | { |
| 1324 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1325 | break; |
| 1326 | } |
| 1327 | if (LocaleCompare("distort",option+1) == 0) |
| 1328 | { |
| 1329 | char |
| 1330 | *args, |
| 1331 | token[MaxTextExtent]; |
| 1332 | |
| 1333 | const char |
| 1334 | *p; |
| 1335 | |
| 1336 | DistortImageMethod |
| 1337 | method; |
| 1338 | |
| 1339 | double |
| 1340 | *arguments; |
| 1341 | |
| 1342 | register ssize_t |
| 1343 | x; |
| 1344 | |
| 1345 | size_t |
| 1346 | number_arguments; |
| 1347 | |
| 1348 | /* |
| 1349 | Distort image. |
| 1350 | */ |
| 1351 | (void) SyncImageSettings(mogrify_info,*image); |
| 1352 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, |
| 1353 | MagickFalse,argv[i+1]); |
| 1354 | if ( method == ResizeDistortion ) |
| 1355 | { |
| 1356 | /* Special Case - Argument is actually a resize geometry! |
| 1357 | ** Convert that to an appropriate distortion argument array. |
| 1358 | */ |
| 1359 | double |
| 1360 | resize_args[2]; |
| 1361 | (void) ParseRegionGeometry(*image,argv[i+2],&geometry, |
| 1362 | exception); |
| 1363 | resize_args[0]=(double)geometry.width; |
| 1364 | resize_args[1]=(double)geometry.height; |
| 1365 | mogrify_image=DistortImage(*image,method,(size_t)2, |
| 1366 | resize_args,MagickTrue,exception); |
| 1367 | break; |
| 1368 | } |
| 1369 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 1370 | InheritException(exception,&(*image)->exception); |
| 1371 | if (args == (char *) NULL) |
| 1372 | break; |
| 1373 | p=(char *) args; |
| 1374 | for (x=0; *p != '\0'; x++) |
| 1375 | { |
| 1376 | GetMagickToken(p,&p,token); |
| 1377 | if (*token == ',') |
| 1378 | GetMagickToken(p,&p,token); |
| 1379 | } |
| 1380 | number_arguments=(size_t) x; |
| 1381 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1382 | sizeof(*arguments)); |
| 1383 | if (arguments == (double *) NULL) |
| 1384 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1385 | "MemoryAllocationFailed",(*image)->filename); |
| 1386 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1387 | sizeof(*arguments)); |
| 1388 | p=(char *) args; |
| 1389 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 1390 | { |
| 1391 | GetMagickToken(p,&p,token); |
| 1392 | if (*token == ',') |
| 1393 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1394 | arguments[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1395 | } |
| 1396 | args=DestroyString(args); |
| 1397 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
| 1398 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1399 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1400 | break; |
| 1401 | } |
| 1402 | if (LocaleCompare("dither",option+1) == 0) |
| 1403 | { |
| 1404 | if (*option == '+') |
| 1405 | { |
| 1406 | quantize_info->dither=MagickFalse; |
| 1407 | break; |
| 1408 | } |
| 1409 | quantize_info->dither=MagickTrue; |
| 1410 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
| 1411 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1412 | if (quantize_info->dither_method == NoDitherMethod) |
| 1413 | quantize_info->dither=MagickFalse; |
| 1414 | break; |
| 1415 | } |
| 1416 | if (LocaleCompare("draw",option+1) == 0) |
| 1417 | { |
| 1418 | /* |
| 1419 | Draw image. |
| 1420 | */ |
| 1421 | (void) SyncImageSettings(mogrify_info,*image); |
| 1422 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
| 1423 | (void) DrawImage(*image,draw_info); |
| 1424 | InheritException(exception,&(*image)->exception); |
| 1425 | break; |
| 1426 | } |
| 1427 | break; |
| 1428 | } |
| 1429 | case 'e': |
| 1430 | { |
| 1431 | if (LocaleCompare("edge",option+1) == 0) |
| 1432 | { |
| 1433 | /* |
| 1434 | Enhance edges in the image. |
| 1435 | */ |
| 1436 | (void) SyncImageSettings(mogrify_info,*image); |
| 1437 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1438 | if ((flags & SigmaValue) == 0) |
| 1439 | geometry_info.sigma=1.0; |
| 1440 | mogrify_image=EdgeImage(*image,geometry_info.rho,exception); |
| 1441 | break; |
| 1442 | } |
| 1443 | if (LocaleCompare("emboss",option+1) == 0) |
| 1444 | { |
| 1445 | /* |
| 1446 | Gaussian embossen image. |
| 1447 | */ |
| 1448 | (void) SyncImageSettings(mogrify_info,*image); |
| 1449 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1450 | if ((flags & SigmaValue) == 0) |
| 1451 | geometry_info.sigma=1.0; |
| 1452 | mogrify_image=EmbossImage(*image,geometry_info.rho, |
| 1453 | geometry_info.sigma,exception); |
| 1454 | break; |
| 1455 | } |
| 1456 | if (LocaleCompare("encipher",option+1) == 0) |
| 1457 | { |
| 1458 | StringInfo |
| 1459 | *passkey; |
| 1460 | |
| 1461 | /* |
| 1462 | Encipher pixels. |
| 1463 | */ |
| 1464 | (void) SyncImageSettings(mogrify_info,*image); |
| 1465 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1466 | if (passkey != (StringInfo *) NULL) |
| 1467 | { |
| 1468 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1469 | passkey=DestroyStringInfo(passkey); |
| 1470 | } |
| 1471 | break; |
| 1472 | } |
| 1473 | if (LocaleCompare("encoding",option+1) == 0) |
| 1474 | { |
| 1475 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1476 | break; |
| 1477 | } |
| 1478 | if (LocaleCompare("enhance",option+1) == 0) |
| 1479 | { |
| 1480 | /* |
| 1481 | Enhance image. |
| 1482 | */ |
| 1483 | (void) SyncImageSettings(mogrify_info,*image); |
| 1484 | mogrify_image=EnhanceImage(*image,exception); |
| 1485 | break; |
| 1486 | } |
| 1487 | if (LocaleCompare("equalize",option+1) == 0) |
| 1488 | { |
| 1489 | /* |
| 1490 | Equalize image. |
| 1491 | */ |
| 1492 | (void) SyncImageSettings(mogrify_info,*image); |
| 1493 | (void) EqualizeImageChannel(*image,channel); |
| 1494 | InheritException(exception,&(*image)->exception); |
| 1495 | break; |
| 1496 | } |
| 1497 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1498 | { |
| 1499 | double |
| 1500 | constant; |
| 1501 | |
| 1502 | MagickEvaluateOperator |
| 1503 | op; |
| 1504 | |
| 1505 | (void) SyncImageSettings(mogrify_info,*image); |
| 1506 | op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions, |
| 1507 | MagickFalse,argv[i+1]); |
| 1508 | constant=SiPrefixToDouble(argv[i+2],QuantumRange); |
| 1509 | (void) EvaluateImageChannel(*image,channel,op,constant,exception); |
| 1510 | break; |
| 1511 | } |
| 1512 | if (LocaleCompare("extent",option+1) == 0) |
| 1513 | { |
| 1514 | /* |
| 1515 | Set the image extent. |
| 1516 | */ |
| 1517 | (void) SyncImageSettings(mogrify_info,*image); |
| 1518 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1519 | if (geometry.width == 0) |
| 1520 | geometry.width=(*image)->columns; |
| 1521 | if (geometry.height == 0) |
| 1522 | geometry.height=(*image)->rows; |
| 1523 | mogrify_image=ExtentImage(*image,&geometry,exception); |
| 1524 | break; |
| 1525 | } |
| 1526 | break; |
| 1527 | } |
| 1528 | case 'f': |
| 1529 | { |
| 1530 | if (LocaleCompare("family",option+1) == 0) |
| 1531 | { |
| 1532 | if (*option == '+') |
| 1533 | { |
| 1534 | if (draw_info->family != (char *) NULL) |
| 1535 | draw_info->family=DestroyString(draw_info->family); |
| 1536 | break; |
| 1537 | } |
| 1538 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1539 | break; |
| 1540 | } |
| 1541 | if (LocaleCompare("features",option+1) == 0) |
| 1542 | { |
| 1543 | if (*option == '+') |
| 1544 | { |
| 1545 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1546 | break; |
| 1547 | } |
| 1548 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1549 | break; |
| 1550 | } |
| 1551 | if (LocaleCompare("fill",option+1) == 0) |
| 1552 | { |
| 1553 | ExceptionInfo |
| 1554 | *sans; |
| 1555 | |
| 1556 | GetMagickPixelPacket(*image,&fill); |
| 1557 | if (*option == '+') |
| 1558 | { |
| 1559 | (void) QueryMagickColor("none",&fill,exception); |
| 1560 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 1561 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1562 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1563 | break; |
| 1564 | } |
| 1565 | sans=AcquireExceptionInfo(); |
| 1566 | (void) QueryMagickColor(argv[i+1],&fill,sans); |
| 1567 | status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans); |
| 1568 | sans=DestroyExceptionInfo(sans); |
| 1569 | if (status == MagickFalse) |
| 1570 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 1571 | exception); |
| 1572 | break; |
| 1573 | } |
| 1574 | if (LocaleCompare("flip",option+1) == 0) |
| 1575 | { |
| 1576 | /* |
| 1577 | Flip image scanlines. |
| 1578 | */ |
| 1579 | (void) SyncImageSettings(mogrify_info,*image); |
| 1580 | mogrify_image=FlipImage(*image,exception); |
| 1581 | break; |
| 1582 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1583 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1584 | { |
| 1585 | MagickPixelPacket |
| 1586 | target; |
| 1587 | |
| 1588 | /* |
| 1589 | Floodfill image. |
| 1590 | */ |
| 1591 | (void) SyncImageSettings(mogrify_info,*image); |
| 1592 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1593 | (void) QueryMagickColor(argv[i+2],&target,exception); |
| 1594 | (void) FloodfillPaintImage(*image,channel,draw_info,&target, |
| 1595 | geometry.x,geometry.y,*option == '-' ? MagickFalse : MagickTrue); |
| 1596 | InheritException(exception,&(*image)->exception); |
| 1597 | break; |
| 1598 | } |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1599 | if (LocaleCompare("flop",option+1) == 0) |
| 1600 | { |
| 1601 | /* |
| 1602 | Flop image scanlines. |
| 1603 | */ |
| 1604 | (void) SyncImageSettings(mogrify_info,*image); |
| 1605 | mogrify_image=FlopImage(*image,exception); |
| 1606 | break; |
| 1607 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1608 | if (LocaleCompare("font",option+1) == 0) |
| 1609 | { |
| 1610 | if (*option == '+') |
| 1611 | { |
| 1612 | if (draw_info->font != (char *) NULL) |
| 1613 | draw_info->font=DestroyString(draw_info->font); |
| 1614 | break; |
| 1615 | } |
| 1616 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1617 | break; |
| 1618 | } |
| 1619 | if (LocaleCompare("format",option+1) == 0) |
| 1620 | { |
| 1621 | format=argv[i+1]; |
| 1622 | break; |
| 1623 | } |
| 1624 | if (LocaleCompare("frame",option+1) == 0) |
| 1625 | { |
| 1626 | FrameInfo |
| 1627 | frame_info; |
| 1628 | |
| 1629 | /* |
| 1630 | Surround image with an ornamental border. |
| 1631 | */ |
| 1632 | (void) SyncImageSettings(mogrify_info,*image); |
| 1633 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1634 | frame_info.width=geometry.width; |
| 1635 | frame_info.height=geometry.height; |
| 1636 | if ((flags & HeightValue) == 0) |
| 1637 | frame_info.height=geometry.width; |
| 1638 | frame_info.outer_bevel=geometry.x; |
| 1639 | frame_info.inner_bevel=geometry.y; |
| 1640 | frame_info.x=(ssize_t) frame_info.width; |
| 1641 | frame_info.y=(ssize_t) frame_info.height; |
| 1642 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1643 | frame_info.height=(*image)->rows+2*frame_info.height; |
| 1644 | mogrify_image=FrameImage(*image,&frame_info,exception); |
| 1645 | break; |
| 1646 | } |
| 1647 | if (LocaleCompare("function",option+1) == 0) |
| 1648 | { |
| 1649 | char |
| 1650 | *arguments, |
| 1651 | token[MaxTextExtent]; |
| 1652 | |
| 1653 | const char |
| 1654 | *p; |
| 1655 | |
| 1656 | double |
| 1657 | *parameters; |
| 1658 | |
| 1659 | MagickFunction |
| 1660 | function; |
| 1661 | |
| 1662 | register ssize_t |
| 1663 | x; |
| 1664 | |
| 1665 | size_t |
| 1666 | number_parameters; |
| 1667 | |
| 1668 | /* |
| 1669 | Function Modify Image Values |
| 1670 | */ |
| 1671 | (void) SyncImageSettings(mogrify_info,*image); |
| 1672 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, |
| 1673 | MagickFalse,argv[i+1]); |
| 1674 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 1675 | InheritException(exception,&(*image)->exception); |
| 1676 | if (arguments == (char *) NULL) |
| 1677 | break; |
| 1678 | p=(char *) arguments; |
| 1679 | for (x=0; *p != '\0'; x++) |
| 1680 | { |
| 1681 | GetMagickToken(p,&p,token); |
| 1682 | if (*token == ',') |
| 1683 | GetMagickToken(p,&p,token); |
| 1684 | } |
| 1685 | number_parameters=(size_t) x; |
| 1686 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1687 | sizeof(*parameters)); |
| 1688 | if (parameters == (double *) NULL) |
| 1689 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1690 | "MemoryAllocationFailed",(*image)->filename); |
| 1691 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1692 | sizeof(*parameters)); |
| 1693 | p=(char *) arguments; |
| 1694 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
| 1695 | { |
| 1696 | GetMagickToken(p,&p,token); |
| 1697 | if (*token == ',') |
| 1698 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1699 | parameters[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1700 | } |
| 1701 | arguments=DestroyString(arguments); |
| 1702 | (void) FunctionImageChannel(*image,channel,function, |
| 1703 | number_parameters,parameters,exception); |
| 1704 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1705 | break; |
| 1706 | } |
| 1707 | break; |
| 1708 | } |
| 1709 | case 'g': |
| 1710 | { |
| 1711 | if (LocaleCompare("gamma",option+1) == 0) |
| 1712 | { |
| 1713 | /* |
| 1714 | Gamma image. |
| 1715 | */ |
| 1716 | (void) SyncImageSettings(mogrify_info,*image); |
| 1717 | if (*option == '+') |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1718 | (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1719 | else |
| 1720 | { |
| 1721 | if (strchr(argv[i+1],',') != (char *) NULL) |
| 1722 | (void) GammaImage(*image,argv[i+1]); |
| 1723 | else |
| 1724 | (void) GammaImageChannel(*image,channel, |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1725 | InterpretLocaleValue(argv[i+1],(char **) NULL)); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1726 | InheritException(exception,&(*image)->exception); |
| 1727 | } |
| 1728 | break; |
| 1729 | } |
| 1730 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1731 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1732 | { |
| 1733 | /* |
| 1734 | Gaussian blur image. |
| 1735 | */ |
| 1736 | (void) SyncImageSettings(mogrify_info,*image); |
| 1737 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1738 | if ((flags & SigmaValue) == 0) |
| 1739 | geometry_info.sigma=1.0; |
| 1740 | mogrify_image=GaussianBlurImageChannel(*image,channel, |
| 1741 | geometry_info.rho,geometry_info.sigma,exception); |
| 1742 | break; |
| 1743 | } |
| 1744 | if (LocaleCompare("geometry",option+1) == 0) |
| 1745 | { |
| 1746 | /* |
| 1747 | Record Image offset, Resize last image. |
| 1748 | */ |
| 1749 | (void) SyncImageSettings(mogrify_info,*image); |
| 1750 | if (*option == '+') |
| 1751 | { |
| 1752 | if ((*image)->geometry != (char *) NULL) |
| 1753 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1754 | break; |
| 1755 | } |
| 1756 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1757 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1758 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1759 | else |
| 1760 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 1761 | (*image)->filter,(*image)->blur,exception); |
| 1762 | break; |
| 1763 | } |
| 1764 | if (LocaleCompare("gravity",option+1) == 0) |
| 1765 | { |
| 1766 | if (*option == '+') |
| 1767 | { |
| 1768 | draw_info->gravity=UndefinedGravity; |
| 1769 | break; |
| 1770 | } |
| 1771 | draw_info->gravity=(GravityType) ParseCommandOption( |
| 1772 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1773 | break; |
| 1774 | } |
| 1775 | break; |
| 1776 | } |
| 1777 | case 'h': |
| 1778 | { |
| 1779 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1780 | { |
| 1781 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1782 | break; |
| 1783 | } |
| 1784 | break; |
| 1785 | } |
| 1786 | case 'i': |
| 1787 | { |
| 1788 | if (LocaleCompare("identify",option+1) == 0) |
| 1789 | { |
| 1790 | char |
| 1791 | *text; |
| 1792 | |
| 1793 | (void) SyncImageSettings(mogrify_info,*image); |
| 1794 | if (format == (char *) NULL) |
| 1795 | { |
| 1796 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose); |
| 1797 | InheritException(exception,&(*image)->exception); |
| 1798 | break; |
| 1799 | } |
| 1800 | text=InterpretImageProperties(mogrify_info,*image,format); |
| 1801 | InheritException(exception,&(*image)->exception); |
| 1802 | if (text == (char *) NULL) |
| 1803 | break; |
| 1804 | (void) fputs(text,stdout); |
| 1805 | (void) fputc('\n',stdout); |
| 1806 | text=DestroyString(text); |
| 1807 | break; |
| 1808 | } |
| 1809 | if (LocaleCompare("implode",option+1) == 0) |
| 1810 | { |
| 1811 | /* |
| 1812 | Implode image. |
| 1813 | */ |
| 1814 | (void) SyncImageSettings(mogrify_info,*image); |
| 1815 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1816 | mogrify_image=ImplodeImage(*image,geometry_info.rho,exception); |
| 1817 | break; |
| 1818 | } |
| 1819 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1820 | { |
| 1821 | if (*option == '+') |
| 1822 | (void) ParseGeometry("0",&geometry_info); |
| 1823 | else |
| 1824 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1825 | draw_info->interline_spacing=geometry_info.rho; |
| 1826 | break; |
| 1827 | } |
| 1828 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1829 | { |
| 1830 | if (*option == '+') |
| 1831 | (void) ParseGeometry("0",&geometry_info); |
| 1832 | else |
| 1833 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1834 | draw_info->interword_spacing=geometry_info.rho; |
| 1835 | break; |
| 1836 | } |
| 1837 | break; |
| 1838 | } |
| 1839 | case 'k': |
| 1840 | { |
| 1841 | if (LocaleCompare("kerning",option+1) == 0) |
| 1842 | { |
| 1843 | if (*option == '+') |
| 1844 | (void) ParseGeometry("0",&geometry_info); |
| 1845 | else |
| 1846 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1847 | draw_info->kerning=geometry_info.rho; |
| 1848 | break; |
| 1849 | } |
| 1850 | break; |
| 1851 | } |
| 1852 | case 'l': |
| 1853 | { |
| 1854 | if (LocaleCompare("lat",option+1) == 0) |
| 1855 | { |
| 1856 | /* |
| 1857 | Local adaptive threshold image. |
| 1858 | */ |
| 1859 | (void) SyncImageSettings(mogrify_info,*image); |
| 1860 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1861 | if ((flags & PercentValue) != 0) |
| 1862 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 1863 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
| 1864 | geometry_info.rho,(size_t) geometry_info.sigma,(ssize_t) |
| 1865 | geometry_info.xi,exception); |
| 1866 | break; |
| 1867 | } |
| 1868 | if (LocaleCompare("level",option+1) == 0) |
| 1869 | { |
| 1870 | MagickRealType |
| 1871 | black_point, |
| 1872 | gamma, |
| 1873 | white_point; |
| 1874 | |
| 1875 | MagickStatusType |
| 1876 | flags; |
| 1877 | |
| 1878 | /* |
| 1879 | Parse levels. |
| 1880 | */ |
| 1881 | (void) SyncImageSettings(mogrify_info,*image); |
| 1882 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1883 | black_point=geometry_info.rho; |
| 1884 | white_point=(MagickRealType) QuantumRange; |
| 1885 | if ((flags & SigmaValue) != 0) |
| 1886 | white_point=geometry_info.sigma; |
| 1887 | gamma=1.0; |
| 1888 | if ((flags & XiValue) != 0) |
| 1889 | gamma=geometry_info.xi; |
| 1890 | if ((flags & PercentValue) != 0) |
| 1891 | { |
| 1892 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 1893 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 1894 | } |
| 1895 | if ((flags & SigmaValue) == 0) |
| 1896 | white_point=(MagickRealType) QuantumRange-black_point; |
| 1897 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
| 1898 | (void) LevelizeImageChannel(*image,channel,black_point, |
| 1899 | white_point,gamma); |
| 1900 | else |
| 1901 | (void) LevelImageChannel(*image,channel,black_point,white_point, |
| 1902 | gamma); |
| 1903 | InheritException(exception,&(*image)->exception); |
| 1904 | break; |
| 1905 | } |
| 1906 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1907 | { |
| 1908 | char |
| 1909 | token[MaxTextExtent]; |
| 1910 | |
| 1911 | const char |
| 1912 | *p; |
| 1913 | |
| 1914 | MagickPixelPacket |
| 1915 | black_point, |
| 1916 | white_point; |
| 1917 | |
| 1918 | p=(const char *) argv[i+1]; |
| 1919 | GetMagickToken(p,&p,token); /* get black point color */ |
| 1920 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1921 | (void) QueryMagickColor(token,&black_point,exception); |
| 1922 | else |
| 1923 | (void) QueryMagickColor("#000000",&black_point,exception); |
| 1924 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1925 | GetMagickToken(p,&p,token); |
| 1926 | if (*token == '\0') |
| 1927 | white_point=black_point; /* set everything to that color */ |
| 1928 | else |
| 1929 | { |
| 1930 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 1931 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 1932 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1933 | (void) QueryMagickColor(token,&white_point,exception); |
| 1934 | else |
| 1935 | (void) QueryMagickColor("#ffffff",&white_point,exception); |
| 1936 | } |
| 1937 | (void) LevelColorsImageChannel(*image,channel,&black_point, |
| 1938 | &white_point,*option == '+' ? MagickTrue : MagickFalse); |
| 1939 | break; |
| 1940 | } |
| 1941 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 1942 | { |
| 1943 | double |
| 1944 | black_point, |
| 1945 | white_point; |
| 1946 | |
| 1947 | MagickStatusType |
| 1948 | flags; |
| 1949 | |
| 1950 | (void) SyncImageSettings(mogrify_info,*image); |
| 1951 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1952 | black_point=geometry_info.rho; |
| 1953 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 1954 | if ((flags & SigmaValue) != 0) |
| 1955 | white_point=geometry_info.sigma; |
| 1956 | if ((flags & PercentValue) != 0) |
| 1957 | { |
| 1958 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1959 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1960 | } |
| 1961 | if ((flags & SigmaValue) == 0) |
| 1962 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1963 | black_point; |
| 1964 | (void) LinearStretchImage(*image,black_point,white_point); |
| 1965 | InheritException(exception,&(*image)->exception); |
| 1966 | break; |
| 1967 | } |
| 1968 | if (LocaleCompare("linewidth",option+1) == 0) |
| 1969 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1970 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 1971 | (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 | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 2392 | InterpretLocaleValue(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 | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 2883 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 2884 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2885 | break; |
| 2886 | } |
| 2887 | if (LocaleCompare("style",option+1) == 0) |
| 2888 | { |
| 2889 | if (*option == '+') |
| 2890 | { |
| 2891 | draw_info->style=UndefinedStyle; |
| 2892 | break; |
| 2893 | } |
| 2894 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 2895 | MagickFalse,argv[i+1]); |
| 2896 | break; |
| 2897 | } |
| 2898 | if (LocaleCompare("swirl",option+1) == 0) |
| 2899 | { |
| 2900 | /* |
| 2901 | Swirl image. |
| 2902 | */ |
| 2903 | (void) SyncImageSettings(mogrify_info,*image); |
| 2904 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2905 | mogrify_image=SwirlImage(*image,geometry_info.rho,exception); |
| 2906 | break; |
| 2907 | } |
| 2908 | break; |
| 2909 | } |
| 2910 | case 't': |
| 2911 | { |
| 2912 | if (LocaleCompare("threshold",option+1) == 0) |
| 2913 | { |
| 2914 | double |
| 2915 | threshold; |
| 2916 | |
| 2917 | /* |
| 2918 | Threshold image. |
| 2919 | */ |
| 2920 | (void) SyncImageSettings(mogrify_info,*image); |
| 2921 | if (*option == '+') |
anthony | 247a86d | 2011-05-03 13:18:18 +0000 | [diff] [blame] | 2922 | threshold=(double) QuantumRange/2; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2923 | else |
| 2924 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2925 | (void) BilevelImageChannel(*image,channel,threshold); |
| 2926 | InheritException(exception,&(*image)->exception); |
| 2927 | break; |
| 2928 | } |
| 2929 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2930 | { |
| 2931 | /* |
| 2932 | Thumbnail image. |
| 2933 | */ |
| 2934 | (void) SyncImageSettings(mogrify_info,*image); |
| 2935 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2936 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2937 | exception); |
| 2938 | break; |
| 2939 | } |
| 2940 | if (LocaleCompare("tile",option+1) == 0) |
| 2941 | { |
| 2942 | if (*option == '+') |
| 2943 | { |
| 2944 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2945 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2946 | break; |
| 2947 | } |
| 2948 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2949 | exception); |
| 2950 | break; |
| 2951 | } |
| 2952 | if (LocaleCompare("tint",option+1) == 0) |
| 2953 | { |
| 2954 | /* |
| 2955 | Tint the image. |
| 2956 | */ |
| 2957 | (void) SyncImageSettings(mogrify_info,*image); |
| 2958 | mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception); |
| 2959 | break; |
| 2960 | } |
| 2961 | if (LocaleCompare("transform",option+1) == 0) |
| 2962 | { |
| 2963 | /* |
| 2964 | Affine transform image. |
| 2965 | */ |
| 2966 | (void) SyncImageSettings(mogrify_info,*image); |
| 2967 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
| 2968 | exception); |
| 2969 | break; |
| 2970 | } |
| 2971 | if (LocaleCompare("transparent",option+1) == 0) |
| 2972 | { |
| 2973 | MagickPixelPacket |
| 2974 | target; |
| 2975 | |
| 2976 | (void) SyncImageSettings(mogrify_info,*image); |
| 2977 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2978 | (void) TransparentPaintImage(*image,&target,(Quantum) |
| 2979 | TransparentOpacity,*option == '-' ? MagickFalse : MagickTrue); |
| 2980 | InheritException(exception,&(*image)->exception); |
| 2981 | break; |
| 2982 | } |
| 2983 | if (LocaleCompare("transpose",option+1) == 0) |
| 2984 | { |
| 2985 | /* |
| 2986 | Transpose image scanlines. |
| 2987 | */ |
| 2988 | (void) SyncImageSettings(mogrify_info,*image); |
| 2989 | mogrify_image=TransposeImage(*image,exception); |
| 2990 | break; |
| 2991 | } |
| 2992 | if (LocaleCompare("transverse",option+1) == 0) |
| 2993 | { |
| 2994 | /* |
| 2995 | Transverse image scanlines. |
| 2996 | */ |
| 2997 | (void) SyncImageSettings(mogrify_info,*image); |
| 2998 | mogrify_image=TransverseImage(*image,exception); |
| 2999 | break; |
| 3000 | } |
| 3001 | if (LocaleCompare("treedepth",option+1) == 0) |
| 3002 | { |
| 3003 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
| 3004 | break; |
| 3005 | } |
| 3006 | if (LocaleCompare("trim",option+1) == 0) |
| 3007 | { |
| 3008 | /* |
| 3009 | Trim image. |
| 3010 | */ |
| 3011 | (void) SyncImageSettings(mogrify_info,*image); |
| 3012 | mogrify_image=TrimImage(*image,exception); |
| 3013 | break; |
| 3014 | } |
| 3015 | if (LocaleCompare("type",option+1) == 0) |
| 3016 | { |
| 3017 | ImageType |
| 3018 | type; |
| 3019 | |
| 3020 | (void) SyncImageSettings(mogrify_info,*image); |
| 3021 | if (*option == '+') |
| 3022 | type=UndefinedType; |
| 3023 | else |
| 3024 | type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 3025 | argv[i+1]); |
| 3026 | (*image)->type=UndefinedType; |
| 3027 | (void) SetImageType(*image,type); |
| 3028 | InheritException(exception,&(*image)->exception); |
| 3029 | break; |
| 3030 | } |
| 3031 | break; |
| 3032 | } |
| 3033 | case 'u': |
| 3034 | { |
| 3035 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3036 | { |
| 3037 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 3038 | exception); |
| 3039 | break; |
| 3040 | } |
| 3041 | if (LocaleCompare("unique",option+1) == 0) |
| 3042 | { |
| 3043 | if (*option == '+') |
| 3044 | { |
| 3045 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
| 3046 | break; |
| 3047 | } |
| 3048 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
| 3049 | (void) SetImageArtifact(*image,"verbose","true"); |
| 3050 | break; |
| 3051 | } |
| 3052 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3053 | { |
| 3054 | /* |
| 3055 | Unique image colors. |
| 3056 | */ |
| 3057 | (void) SyncImageSettings(mogrify_info,*image); |
| 3058 | mogrify_image=UniqueImageColors(*image,exception); |
| 3059 | break; |
| 3060 | } |
| 3061 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3062 | { |
| 3063 | /* |
| 3064 | Unsharp mask image. |
| 3065 | */ |
| 3066 | (void) SyncImageSettings(mogrify_info,*image); |
| 3067 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3068 | if ((flags & SigmaValue) == 0) |
| 3069 | geometry_info.sigma=1.0; |
| 3070 | if ((flags & XiValue) == 0) |
| 3071 | geometry_info.xi=1.0; |
| 3072 | if ((flags & PsiValue) == 0) |
| 3073 | geometry_info.psi=0.05; |
| 3074 | mogrify_image=UnsharpMaskImageChannel(*image,channel, |
| 3075 | geometry_info.rho,geometry_info.sigma,geometry_info.xi, |
| 3076 | geometry_info.psi,exception); |
| 3077 | break; |
| 3078 | } |
| 3079 | break; |
| 3080 | } |
| 3081 | case 'v': |
| 3082 | { |
| 3083 | if (LocaleCompare("verbose",option+1) == 0) |
| 3084 | { |
| 3085 | (void) SetImageArtifact(*image,option+1, |
| 3086 | *option == '+' ? "false" : "true"); |
| 3087 | break; |
| 3088 | } |
| 3089 | if (LocaleCompare("vignette",option+1) == 0) |
| 3090 | { |
| 3091 | /* |
| 3092 | Vignette image. |
| 3093 | */ |
| 3094 | (void) SyncImageSettings(mogrify_info,*image); |
| 3095 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3096 | if ((flags & SigmaValue) == 0) |
| 3097 | geometry_info.sigma=1.0; |
| 3098 | if ((flags & XiValue) == 0) |
| 3099 | geometry_info.xi=0.1*(*image)->columns; |
| 3100 | if ((flags & PsiValue) == 0) |
| 3101 | geometry_info.psi=0.1*(*image)->rows; |
| 3102 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
| 3103 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3104 | ceil(geometry_info.psi-0.5),exception); |
| 3105 | break; |
| 3106 | } |
| 3107 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3108 | { |
| 3109 | if (*option == '+') |
| 3110 | { |
| 3111 | (void) SetImageVirtualPixelMethod(*image, |
| 3112 | UndefinedVirtualPixelMethod); |
| 3113 | break; |
| 3114 | } |
| 3115 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3116 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 3117 | argv[i+1])); |
| 3118 | break; |
| 3119 | } |
| 3120 | break; |
| 3121 | } |
| 3122 | case 'w': |
| 3123 | { |
| 3124 | if (LocaleCompare("wave",option+1) == 0) |
| 3125 | { |
| 3126 | /* |
| 3127 | Wave image. |
| 3128 | */ |
| 3129 | (void) SyncImageSettings(mogrify_info,*image); |
| 3130 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3131 | if ((flags & SigmaValue) == 0) |
| 3132 | geometry_info.sigma=1.0; |
| 3133 | mogrify_image=WaveImage(*image,geometry_info.rho, |
| 3134 | geometry_info.sigma,exception); |
| 3135 | break; |
| 3136 | } |
| 3137 | if (LocaleCompare("weight",option+1) == 0) |
| 3138 | { |
| 3139 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
| 3140 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3141 | draw_info->weight=0; |
| 3142 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3143 | draw_info->weight=700; |
| 3144 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3145 | if (draw_info->weight <= 800) |
| 3146 | draw_info->weight+=100; |
| 3147 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3148 | if (draw_info->weight >= 100) |
| 3149 | draw_info->weight-=100; |
| 3150 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3151 | draw_info->weight=400; |
| 3152 | break; |
| 3153 | } |
| 3154 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3155 | { |
| 3156 | /* |
| 3157 | White threshold image. |
| 3158 | */ |
| 3159 | (void) SyncImageSettings(mogrify_info,*image); |
| 3160 | (void) WhiteThresholdImageChannel(*image,channel,argv[i+1], |
| 3161 | exception); |
| 3162 | InheritException(exception,&(*image)->exception); |
| 3163 | break; |
| 3164 | } |
| 3165 | break; |
| 3166 | } |
| 3167 | default: |
| 3168 | break; |
| 3169 | } |
| 3170 | /* |
| 3171 | Replace current image with any image that was generated |
| 3172 | */ |
| 3173 | if (mogrify_image != (Image *) NULL) |
| 3174 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3175 | i+=count; |
| 3176 | } |
| 3177 | if (region_image != (Image *) NULL) |
| 3178 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3179 | /* |
| 3180 | Composite transformed region onto image. |
| 3181 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3182 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3183 | (void) CompositeImage(region_image,region_image->matte != |
| 3184 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3185 | region_geometry.x,region_geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3186 | InheritException(exception,®ion_image->exception); |
| 3187 | *image=DestroyImage(*image); |
| 3188 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3189 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3190 | } |
| 3191 | /* |
| 3192 | Free resources. |
| 3193 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3194 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3195 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3196 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 3197 | status=(MagickStatusType) ((*image)->exception.severity == |
| 3198 | UndefinedException ? 1 : 0); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3199 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3200 | } |
| 3201 | |
| 3202 | /* |
| 3203 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3204 | % % |
| 3205 | % % |
| 3206 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3207 | + 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] | 3208 | % % |
| 3209 | % % |
| 3210 | % % |
| 3211 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3212 | % |
| 3213 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3214 | % transforms include image scaling, image rotation, color reduction, and |
| 3215 | % others. The transmogrified image overwrites the original image. |
| 3216 | % |
| 3217 | % The format of the MogrifyImageCommand method is: |
| 3218 | % |
| 3219 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3220 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3221 | % |
| 3222 | % A description of each parameter follows: |
| 3223 | % |
| 3224 | % o image_info: the image info. |
| 3225 | % |
| 3226 | % o argc: the number of elements in the argument vector. |
| 3227 | % |
| 3228 | % o argv: A text array containing the command line arguments. |
| 3229 | % |
| 3230 | % o metadata: any metadata is returned here. |
| 3231 | % |
| 3232 | % o exception: return any errors or warnings in this structure. |
| 3233 | % |
| 3234 | */ |
| 3235 | |
| 3236 | static MagickBooleanType MogrifyUsage(void) |
| 3237 | { |
| 3238 | static const char |
| 3239 | *miscellaneous[]= |
| 3240 | { |
| 3241 | "-debug events display copious debugging information", |
| 3242 | "-help print program options", |
| 3243 | "-list type print a list of supported option arguments", |
| 3244 | "-log format format of debugging information", |
| 3245 | "-version print version information", |
| 3246 | (char *) NULL |
| 3247 | }, |
| 3248 | *operators[]= |
| 3249 | { |
| 3250 | "-adaptive-blur geometry", |
| 3251 | " adaptively blur pixels; decrease effect near edges", |
| 3252 | "-adaptive-resize geometry", |
| 3253 | " adaptively resize image using 'mesh' interpolation", |
| 3254 | "-adaptive-sharpen geometry", |
| 3255 | " adaptively sharpen pixels; increase effect near edges", |
| 3256 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3257 | " transparent, extract, background, or shape", |
| 3258 | "-annotate geometry text", |
| 3259 | " annotate the image with text", |
| 3260 | "-auto-gamma automagically adjust gamma level of image", |
| 3261 | "-auto-level automagically adjust color levels of image", |
| 3262 | "-auto-orient automagically orient (rotate) image", |
| 3263 | "-bench iterations measure performance", |
| 3264 | "-black-threshold value", |
| 3265 | " force all pixels below the threshold into black", |
| 3266 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3267 | "-blur geometry reduce image noise and reduce detail levels", |
| 3268 | "-border geometry surround image with a border of color", |
| 3269 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3270 | "-brightness-contrast geometry", |
| 3271 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3272 | "-cdl filename color correct with a color decision list", |
| 3273 | "-charcoal radius simulate a charcoal drawing", |
| 3274 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3275 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3276 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3277 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3278 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3279 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3280 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3281 | "-contrast enhance or reduce the image contrast", |
| 3282 | "-contrast-stretch geometry", |
| 3283 | " improve contrast by `stretching' the intensity range", |
| 3284 | "-convolve coefficients", |
| 3285 | " apply a convolution kernel to the image", |
| 3286 | "-cycle amount cycle the image colormap", |
| 3287 | "-decipher filename convert cipher pixels to plain pixels", |
| 3288 | "-deskew threshold straighten an image", |
| 3289 | "-despeckle reduce the speckles within an image", |
| 3290 | "-distort method args", |
| 3291 | " distort images according to given method ad args", |
| 3292 | "-draw string annotate the image with a graphic primitive", |
| 3293 | "-edge radius apply a filter to detect edges in the image", |
| 3294 | "-encipher filename convert plain pixels to cipher pixels", |
| 3295 | "-emboss radius emboss an image", |
| 3296 | "-enhance apply a digital filter to enhance a noisy image", |
| 3297 | "-equalize perform histogram equalization to an image", |
| 3298 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3299 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3300 | "-extent geometry set the image size", |
| 3301 | "-extract geometry extract area from image", |
| 3302 | "-fft implements the discrete Fourier transform (DFT)", |
| 3303 | "-flip flip image vertically", |
| 3304 | "-floodfill geometry color", |
| 3305 | " floodfill the image with color", |
| 3306 | "-flop flop image horizontally", |
| 3307 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3308 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3309 | " apply function over image values", |
| 3310 | "-gamma value level of gamma correction", |
| 3311 | "-gaussian-blur geometry", |
| 3312 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3313 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3314 | "-identify identify the format and characteristics of the image", |
| 3315 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3316 | "-implode amount implode image pixels about the center", |
| 3317 | "-lat geometry local adaptive thresholding", |
| 3318 | "-layers method optimize, merge, or compare image layers", |
| 3319 | "-level value adjust the level of image contrast", |
| 3320 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3321 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3322 | "-linear-stretch geometry", |
| 3323 | " improve contrast by `stretching with saturation'", |
| 3324 | "-liquid-rescale geometry", |
| 3325 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3326 | "-median geometry apply a median filter to the image", |
glennrp | 30d2dc6 | 2011-06-25 03:17:16 +0000 | [diff] [blame^] | 3327 | "-mode geometry make each pixel the 'predominant color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3328 | "-modulate value vary the brightness, saturation, and hue", |
| 3329 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3330 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3331 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3332 | "-motion-blur geometry", |
| 3333 | " simulate motion blur", |
| 3334 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3335 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3336 | "-normalize transform image to span the full range of colors", |
| 3337 | "-opaque color change this color to the fill color", |
| 3338 | "-ordered-dither NxN", |
| 3339 | " add a noise pattern to the image with specific", |
| 3340 | " amplitudes", |
| 3341 | "-paint radius simulate an oil painting", |
| 3342 | "-polaroid angle simulate a Polaroid picture", |
| 3343 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3344 | "-profile filename add, delete, or apply an image profile", |
| 3345 | "-quantize colorspace reduce colors in this colorspace", |
| 3346 | "-radial-blur angle radial blur the image", |
| 3347 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3348 | "-random-threshold low,high", |
| 3349 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3350 | "-region geometry apply options to a portion of the image", |
| 3351 | "-render render vector graphics", |
| 3352 | "-repage geometry size and location of an image canvas", |
| 3353 | "-resample geometry change the resolution of an image", |
| 3354 | "-resize geometry resize the image", |
| 3355 | "-roll geometry roll an image vertically or horizontally", |
| 3356 | "-rotate degrees apply Paeth rotation to the image", |
| 3357 | "-sample geometry scale image with pixel sampling", |
| 3358 | "-scale geometry scale the image", |
| 3359 | "-segment values segment an image", |
| 3360 | "-selective-blur geometry", |
| 3361 | " selectively blur pixels within a contrast threshold", |
| 3362 | "-sepia-tone threshold", |
| 3363 | " simulate a sepia-toned photo", |
| 3364 | "-set property value set an image property", |
| 3365 | "-shade degrees shade the image using a distant light source", |
| 3366 | "-shadow geometry simulate an image shadow", |
| 3367 | "-sharpen geometry sharpen the image", |
| 3368 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3369 | "-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] | 3370 | "-sigmoidal-contrast geometry", |
| 3371 | " increase the contrast without saturating highlights or shadows", |
| 3372 | "-sketch geometry simulate a pencil sketch", |
| 3373 | "-solarize threshold negate all pixels above the threshold level", |
| 3374 | "-sparse-color method args", |
| 3375 | " fill in a image based on a few color points", |
| 3376 | "-splice geometry splice the background color into the image", |
| 3377 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3378 | "-statistic type radius", |
| 3379 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3380 | "-strip strip image of all profiles and comments", |
| 3381 | "-swirl degrees swirl image pixels about the center", |
| 3382 | "-threshold value threshold the image", |
| 3383 | "-thumbnail geometry create a thumbnail of the image", |
| 3384 | "-tile filename tile image when filling a graphic primitive", |
| 3385 | "-tint value tint the image with the fill color", |
| 3386 | "-transform affine transform image", |
| 3387 | "-transparent color make this color transparent within the image", |
| 3388 | "-transpose flip image vertically and rotate 90 degrees", |
| 3389 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3390 | "-trim trim image edges", |
| 3391 | "-type type image type", |
| 3392 | "-unique-colors discard all but one of any pixel color", |
| 3393 | "-unsharp geometry sharpen the image", |
| 3394 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3395 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3396 | "-white-threshold value", |
| 3397 | " force all pixels above the threshold into white", |
| 3398 | (char *) NULL |
| 3399 | }, |
| 3400 | *sequence_operators[]= |
| 3401 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3402 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3403 | "-clut apply a color lookup table to the image", |
| 3404 | "-coalesce merge a sequence of images", |
| 3405 | "-combine combine a sequence of images", |
| 3406 | "-composite composite image", |
| 3407 | "-crop geometry cut out a rectangular region of the image", |
| 3408 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3409 | "-evaluate-sequence operator", |
| 3410 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3411 | "-flatten flatten a sequence of images", |
| 3412 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3413 | "-hald-clut apply a Hald color lookup table to the image", |
| 3414 | "-morph value morph an image sequence", |
| 3415 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3416 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3417 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3418 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3419 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3420 | "-write filename write images to this file", |
| 3421 | (char *) NULL |
| 3422 | }, |
| 3423 | *settings[]= |
| 3424 | { |
| 3425 | "-adjoin join images into a single multi-image file", |
| 3426 | "-affine matrix affine transform matrix", |
| 3427 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3428 | "-antialias remove pixel-aliasing", |
| 3429 | "-authenticate password", |
| 3430 | " decipher image with this password", |
| 3431 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3432 | "-background color background color", |
| 3433 | "-bias value add bias when convolving an image", |
| 3434 | "-black-point-compensation", |
| 3435 | " use black point compensation", |
| 3436 | "-blue-primary point chromaticity blue primary point", |
| 3437 | "-bordercolor color border color", |
| 3438 | "-caption string assign a caption to an image", |
| 3439 | "-channel type apply option to select image channels", |
| 3440 | "-colors value preferred number of colors in the image", |
| 3441 | "-colorspace type alternate image colorspace", |
| 3442 | "-comment string annotate image with comment", |
| 3443 | "-compose operator set image composite operator", |
| 3444 | "-compress type type of pixel compression when writing the image", |
| 3445 | "-define format:option", |
| 3446 | " define one or more image format options", |
| 3447 | "-delay value display the next image after pausing", |
| 3448 | "-density geometry horizontal and vertical density of the image", |
| 3449 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3450 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3451 | "-display server get image or font from this X server", |
| 3452 | "-dispose method layer disposal method", |
| 3453 | "-dither method apply error diffusion to image", |
| 3454 | "-encoding type text encoding type", |
| 3455 | "-endian type endianness (MSB or LSB) of the image", |
| 3456 | "-family name render text with this font family", |
| 3457 | "-fill color color to use when filling a graphic primitive", |
| 3458 | "-filter type use this filter when resizing an image", |
| 3459 | "-font name render text with this font", |
| 3460 | "-format \"string\" output formatted image characteristics", |
| 3461 | "-fuzz distance colors within this distance are considered equal", |
| 3462 | "-gravity type horizontal and vertical text placement", |
| 3463 | "-green-primary point chromaticity green primary point", |
| 3464 | "-intent type type of rendering intent when managing the image color", |
| 3465 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3466 | "-interline-spacing value", |
| 3467 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3468 | "-interpolate method pixel color interpolation method", |
| 3469 | "-interword-spacing value", |
| 3470 | " set the space between two words", |
| 3471 | "-kerning value set the space between two letters", |
| 3472 | "-label string assign a label to an image", |
| 3473 | "-limit type value pixel cache resource limit", |
| 3474 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3475 | "-mask filename associate a mask with the image", |
| 3476 | "-mattecolor color frame color", |
| 3477 | "-monitor monitor progress", |
| 3478 | "-orient type image orientation", |
| 3479 | "-page geometry size and location of an image canvas (setting)", |
| 3480 | "-ping efficiently determine image attributes", |
| 3481 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3482 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3483 | "-preview type image preview type", |
| 3484 | "-quality value JPEG/MIFF/PNG compression level", |
| 3485 | "-quiet suppress all warning messages", |
| 3486 | "-red-primary point chromaticity red primary point", |
| 3487 | "-regard-warnings pay attention to warning messages", |
| 3488 | "-remap filename transform image colors to match this set of colors", |
| 3489 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3490 | "-sampling-factor geometry", |
| 3491 | " horizontal and vertical sampling factor", |
| 3492 | "-scene value image scene number", |
| 3493 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3494 | "-size geometry width and height of image", |
| 3495 | "-stretch type render text with this font stretch", |
| 3496 | "-stroke color graphic primitive stroke color", |
| 3497 | "-strokewidth value graphic primitive stroke width", |
| 3498 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3499 | "-synchronize synchronize image to storage device", |
| 3500 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3501 | "-texture filename name of texture to tile onto the image background", |
| 3502 | "-tile-offset geometry", |
| 3503 | " tile offset", |
| 3504 | "-treedepth value color tree depth", |
| 3505 | "-transparent-color color", |
| 3506 | " transparent color", |
| 3507 | "-undercolor color annotation bounding box color", |
| 3508 | "-units type the units of image resolution", |
| 3509 | "-verbose print detailed information about the image", |
| 3510 | "-view FlashPix viewing transforms", |
| 3511 | "-virtual-pixel method", |
| 3512 | " virtual pixel access method", |
| 3513 | "-weight type render text with this font weight", |
| 3514 | "-white-point point chromaticity white point", |
| 3515 | (char *) NULL |
| 3516 | }, |
| 3517 | *stack_operators[]= |
| 3518 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3519 | "-delete indexes delete the image from the image sequence", |
| 3520 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3521 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3522 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3523 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3524 | "-swap indexes swap two images in the image sequence", |
| 3525 | (char *) NULL |
| 3526 | }; |
| 3527 | |
| 3528 | const char |
| 3529 | **p; |
| 3530 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3531 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3532 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3533 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3534 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3535 | GetClientName()); |
| 3536 | (void) printf("\nImage Settings:\n"); |
| 3537 | for (p=settings; *p != (char *) NULL; p++) |
| 3538 | (void) printf(" %s\n",*p); |
| 3539 | (void) printf("\nImage Operators:\n"); |
| 3540 | for (p=operators; *p != (char *) NULL; p++) |
| 3541 | (void) printf(" %s\n",*p); |
| 3542 | (void) printf("\nImage Sequence Operators:\n"); |
| 3543 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3544 | (void) printf(" %s\n",*p); |
| 3545 | (void) printf("\nImage Stack Operators:\n"); |
| 3546 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3547 | (void) printf(" %s\n",*p); |
| 3548 | (void) printf("\nMiscellaneous Options:\n"); |
| 3549 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3550 | (void) printf(" %s\n",*p); |
| 3551 | (void) printf( |
| 3552 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3553 | (void) printf( |
| 3554 | "number. To specify a particular image format, precede the filename\n"); |
| 3555 | (void) printf( |
| 3556 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3557 | (void) printf( |
| 3558 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3559 | (void) printf("'-' for standard input or output.\n"); |
| 3560 | return(MagickFalse); |
| 3561 | } |
| 3562 | |
| 3563 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3564 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3565 | { |
| 3566 | #define DestroyMogrify() \ |
| 3567 | { \ |
| 3568 | if (format != (char *) NULL) \ |
| 3569 | format=DestroyString(format); \ |
| 3570 | if (path != (char *) NULL) \ |
| 3571 | path=DestroyString(path); \ |
| 3572 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3573 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3574 | argv[i]=DestroyString(argv[i]); \ |
| 3575 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3576 | } |
| 3577 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3578 | { \ |
| 3579 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3580 | option); \ |
| 3581 | DestroyMogrify(); \ |
| 3582 | return(MagickFalse); \ |
| 3583 | } |
| 3584 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3585 | { \ |
| 3586 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3587 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3588 | DestroyMogrify(); \ |
| 3589 | return(MagickFalse); \ |
| 3590 | } |
| 3591 | |
| 3592 | char |
| 3593 | *format, |
| 3594 | *option, |
| 3595 | *path; |
| 3596 | |
| 3597 | Image |
| 3598 | *image; |
| 3599 | |
| 3600 | ImageStack |
| 3601 | image_stack[MaxImageStackDepth+1]; |
| 3602 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3603 | MagickBooleanType |
| 3604 | global_colormap; |
| 3605 | |
| 3606 | MagickBooleanType |
| 3607 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3608 | pend, |
| 3609 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3610 | |
| 3611 | MagickStatusType |
| 3612 | status; |
| 3613 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3614 | register ssize_t |
| 3615 | i; |
| 3616 | |
| 3617 | ssize_t |
| 3618 | j, |
| 3619 | k; |
| 3620 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3621 | /* |
| 3622 | Set defaults. |
| 3623 | */ |
| 3624 | assert(image_info != (ImageInfo *) NULL); |
| 3625 | assert(image_info->signature == MagickSignature); |
| 3626 | if (image_info->debug != MagickFalse) |
| 3627 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3628 | assert(exception != (ExceptionInfo *) NULL); |
| 3629 | if (argc == 2) |
| 3630 | { |
| 3631 | option=argv[1]; |
| 3632 | if ((LocaleCompare("version",option+1) == 0) || |
| 3633 | (LocaleCompare("-version",option+1) == 0)) |
| 3634 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3635 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3636 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 3637 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 3638 | GetMagickCopyright()); |
| 3639 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 3640 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3641 | return(MagickFalse); |
| 3642 | } |
| 3643 | } |
| 3644 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3645 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3646 | format=(char *) NULL; |
| 3647 | path=(char *) NULL; |
| 3648 | global_colormap=MagickFalse; |
| 3649 | k=0; |
| 3650 | j=1; |
| 3651 | NewImageStack(); |
| 3652 | option=(char *) NULL; |
| 3653 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3654 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3655 | status=MagickTrue; |
| 3656 | /* |
| 3657 | Parse command line. |
| 3658 | */ |
| 3659 | ReadCommandlLine(argc,&argv); |
| 3660 | status=ExpandFilenames(&argc,&argv); |
| 3661 | if (status == MagickFalse) |
| 3662 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3663 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3664 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3665 | { |
| 3666 | option=argv[i]; |
| 3667 | if (LocaleCompare(option,"(") == 0) |
| 3668 | { |
| 3669 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3670 | if (k == MaxImageStackDepth) |
| 3671 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3672 | option); |
| 3673 | PushImageStack(); |
| 3674 | continue; |
| 3675 | } |
| 3676 | if (LocaleCompare(option,")") == 0) |
| 3677 | { |
| 3678 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3679 | if (k == 0) |
| 3680 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3681 | PopImageStack(); |
| 3682 | continue; |
| 3683 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3684 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3685 | { |
| 3686 | char |
| 3687 | backup_filename[MaxTextExtent], |
| 3688 | *filename; |
| 3689 | |
| 3690 | Image |
| 3691 | *images; |
| 3692 | |
| 3693 | /* |
| 3694 | Option is a file name: begin by reading image from specified file. |
| 3695 | */ |
| 3696 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3697 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3698 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3699 | filename=argv[++i]; |
| 3700 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 3701 | images=ReadImages(image_info,exception); |
| 3702 | status&=(images != (Image *) NULL) && |
| 3703 | (exception->severity < ErrorException); |
| 3704 | if (images == (Image *) NULL) |
| 3705 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3706 | if (format != (char *) NULL) |
| 3707 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3708 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3709 | if (path != (char *) NULL) |
| 3710 | { |
| 3711 | GetPathComponent(option,TailPath,filename); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3712 | (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3713 | path,*DirectorySeparator,filename); |
| 3714 | } |
| 3715 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3716 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3717 | AppendImageStack(images); |
| 3718 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3719 | if (global_colormap != MagickFalse) |
| 3720 | { |
| 3721 | QuantizeInfo |
| 3722 | *quantize_info; |
| 3723 | |
| 3724 | quantize_info=AcquireQuantizeInfo(image_info); |
| 3725 | (void) RemapImages(quantize_info,images,(Image *) NULL); |
| 3726 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3727 | } |
| 3728 | *backup_filename='\0'; |
| 3729 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3730 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3731 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3732 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3733 | i; |
| 3734 | |
| 3735 | /* |
| 3736 | Rename image file as backup. |
| 3737 | */ |
| 3738 | (void) CopyMagickString(backup_filename,image->filename, |
| 3739 | MaxTextExtent); |
| 3740 | for (i=0; i < 6; i++) |
| 3741 | { |
| 3742 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3743 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3744 | break; |
| 3745 | } |
| 3746 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
| 3747 | (rename(image->filename,backup_filename) != 0)) |
| 3748 | *backup_filename='\0'; |
| 3749 | } |
| 3750 | /* |
| 3751 | Write transmogrified image to disk. |
| 3752 | */ |
| 3753 | image_info->synchronize=MagickTrue; |
| 3754 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3755 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
| 3756 | (void) remove(backup_filename); |
| 3757 | RemoveAllImageStack(); |
| 3758 | continue; |
| 3759 | } |
| 3760 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3761 | switch (*(option+1)) |
| 3762 | { |
| 3763 | case 'a': |
| 3764 | { |
| 3765 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3766 | { |
| 3767 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3768 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3769 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3770 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3771 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3772 | break; |
| 3773 | } |
| 3774 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3775 | { |
| 3776 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3777 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3778 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3779 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3780 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3781 | break; |
| 3782 | } |
| 3783 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3784 | { |
| 3785 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3786 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3787 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3788 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3789 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3790 | break; |
| 3791 | } |
| 3792 | if (LocaleCompare("affine",option+1) == 0) |
| 3793 | { |
| 3794 | if (*option == '+') |
| 3795 | break; |
| 3796 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3797 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3798 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3799 | break; |
| 3800 | } |
| 3801 | if (LocaleCompare("alpha",option+1) == 0) |
| 3802 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3803 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3804 | type; |
| 3805 | |
| 3806 | if (*option == '+') |
| 3807 | break; |
| 3808 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3809 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3810 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3811 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3812 | if (type < 0) |
| 3813 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3814 | argv[i]); |
| 3815 | break; |
| 3816 | } |
| 3817 | if (LocaleCompare("annotate",option+1) == 0) |
| 3818 | { |
| 3819 | if (*option == '+') |
| 3820 | break; |
| 3821 | 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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3825 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3826 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3827 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3828 | i++; |
| 3829 | break; |
| 3830 | } |
| 3831 | if (LocaleCompare("antialias",option+1) == 0) |
| 3832 | break; |
| 3833 | if (LocaleCompare("append",option+1) == 0) |
| 3834 | break; |
| 3835 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3836 | { |
| 3837 | if (*option == '+') |
| 3838 | break; |
| 3839 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3840 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3841 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3842 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3843 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3844 | break; |
| 3845 | } |
| 3846 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3847 | { |
| 3848 | if (*option == '+') |
| 3849 | break; |
| 3850 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3851 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3852 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3853 | break; |
| 3854 | } |
| 3855 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3856 | break; |
| 3857 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3858 | break; |
| 3859 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3860 | break; |
| 3861 | if (LocaleCompare("average",option+1) == 0) |
| 3862 | break; |
| 3863 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3864 | } |
| 3865 | case 'b': |
| 3866 | { |
| 3867 | if (LocaleCompare("background",option+1) == 0) |
| 3868 | { |
| 3869 | if (*option == '+') |
| 3870 | break; |
| 3871 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3872 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3873 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3874 | break; |
| 3875 | } |
| 3876 | if (LocaleCompare("bias",option+1) == 0) |
| 3877 | { |
| 3878 | if (*option == '+') |
| 3879 | break; |
| 3880 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3881 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3882 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3883 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3884 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3885 | break; |
| 3886 | } |
| 3887 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 3888 | break; |
| 3889 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 3890 | { |
| 3891 | if (*option == '+') |
| 3892 | break; |
| 3893 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3894 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3895 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3896 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3897 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3898 | break; |
| 3899 | } |
| 3900 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3901 | { |
| 3902 | if (*option == '+') |
| 3903 | break; |
| 3904 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3905 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3906 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3907 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3908 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3909 | break; |
| 3910 | } |
| 3911 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3912 | { |
| 3913 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3914 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3915 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3916 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3917 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3918 | break; |
| 3919 | } |
| 3920 | if (LocaleCompare("blur",option+1) == 0) |
| 3921 | { |
| 3922 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3923 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3924 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3925 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3926 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3927 | break; |
| 3928 | } |
| 3929 | if (LocaleCompare("border",option+1) == 0) |
| 3930 | { |
| 3931 | if (*option == '+') |
| 3932 | break; |
| 3933 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3934 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3935 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3936 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3937 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3938 | break; |
| 3939 | } |
| 3940 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3941 | { |
| 3942 | if (*option == '+') |
| 3943 | break; |
| 3944 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3945 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3946 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3947 | break; |
| 3948 | } |
| 3949 | if (LocaleCompare("box",option+1) == 0) |
| 3950 | { |
| 3951 | if (*option == '+') |
| 3952 | break; |
| 3953 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3954 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3955 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3956 | break; |
| 3957 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3958 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 3959 | { |
| 3960 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3961 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3962 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3963 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3964 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3965 | break; |
| 3966 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3967 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3968 | } |
| 3969 | case 'c': |
| 3970 | { |
| 3971 | if (LocaleCompare("cache",option+1) == 0) |
| 3972 | { |
| 3973 | if (*option == '+') |
| 3974 | break; |
| 3975 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3976 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3977 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3978 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3979 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3980 | break; |
| 3981 | } |
| 3982 | if (LocaleCompare("caption",option+1) == 0) |
| 3983 | { |
| 3984 | if (*option == '+') |
| 3985 | break; |
| 3986 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3987 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3988 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3989 | break; |
| 3990 | } |
| 3991 | if (LocaleCompare("channel",option+1) == 0) |
| 3992 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3993 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3994 | channel; |
| 3995 | |
| 3996 | if (*option == '+') |
| 3997 | break; |
| 3998 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3999 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4000 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4001 | channel=ParseChannelOption(argv[i]); |
| 4002 | if (channel < 0) |
| 4003 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 4004 | argv[i]); |
| 4005 | break; |
| 4006 | } |
| 4007 | if (LocaleCompare("cdl",option+1) == 0) |
| 4008 | { |
| 4009 | if (*option == '+') |
| 4010 | break; |
| 4011 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4012 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4013 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4014 | break; |
| 4015 | } |
| 4016 | if (LocaleCompare("charcoal",option+1) == 0) |
| 4017 | { |
| 4018 | if (*option == '+') |
| 4019 | break; |
| 4020 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4021 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4022 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4023 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4024 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4025 | break; |
| 4026 | } |
| 4027 | if (LocaleCompare("chop",option+1) == 0) |
| 4028 | { |
| 4029 | if (*option == '+') |
| 4030 | break; |
| 4031 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4032 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4033 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4034 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4035 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4036 | break; |
| 4037 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4038 | if (LocaleCompare("clamp",option+1) == 0) |
| 4039 | break; |
| 4040 | if (LocaleCompare("clip",option+1) == 0) |
| 4041 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4042 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4043 | { |
| 4044 | if (*option == '+') |
| 4045 | break; |
| 4046 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4047 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4048 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4049 | break; |
| 4050 | } |
| 4051 | if (LocaleCompare("clut",option+1) == 0) |
| 4052 | break; |
| 4053 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4054 | break; |
| 4055 | if (LocaleCompare("colorize",option+1) == 0) |
| 4056 | { |
| 4057 | if (*option == '+') |
| 4058 | break; |
| 4059 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4060 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4061 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4062 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4063 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4064 | break; |
| 4065 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4066 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4067 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4068 | KernelInfo |
| 4069 | *kernel_info; |
| 4070 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4071 | if (*option == '+') |
| 4072 | break; |
| 4073 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4074 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4075 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4076 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4077 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4078 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4079 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4080 | break; |
| 4081 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4082 | if (LocaleCompare("colors",option+1) == 0) |
| 4083 | { |
| 4084 | if (*option == '+') |
| 4085 | break; |
| 4086 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4087 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4088 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4089 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4090 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4091 | break; |
| 4092 | } |
| 4093 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4094 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4095 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4096 | colorspace; |
| 4097 | |
| 4098 | if (*option == '+') |
| 4099 | break; |
| 4100 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4101 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4102 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4103 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4104 | argv[i]); |
| 4105 | if (colorspace < 0) |
| 4106 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4107 | argv[i]); |
| 4108 | break; |
| 4109 | } |
| 4110 | if (LocaleCompare("combine",option+1) == 0) |
| 4111 | break; |
| 4112 | if (LocaleCompare("comment",option+1) == 0) |
| 4113 | { |
| 4114 | if (*option == '+') |
| 4115 | break; |
| 4116 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4117 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4118 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4119 | break; |
| 4120 | } |
| 4121 | if (LocaleCompare("composite",option+1) == 0) |
| 4122 | break; |
| 4123 | if (LocaleCompare("compress",option+1) == 0) |
| 4124 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4125 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4126 | compress; |
| 4127 | |
| 4128 | if (*option == '+') |
| 4129 | break; |
| 4130 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4131 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4132 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4133 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4134 | argv[i]); |
| 4135 | if (compress < 0) |
| 4136 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4137 | argv[i]); |
| 4138 | break; |
| 4139 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4140 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4141 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4142 | if (LocaleCompare("contrast",option+1) == 0) |
| 4143 | break; |
| 4144 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4145 | { |
| 4146 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4147 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4148 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4149 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4150 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4151 | break; |
| 4152 | } |
| 4153 | if (LocaleCompare("convolve",option+1) == 0) |
| 4154 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4155 | KernelInfo |
| 4156 | *kernel_info; |
| 4157 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4158 | if (*option == '+') |
| 4159 | break; |
| 4160 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4161 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4162 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4163 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4164 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4165 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4166 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4167 | break; |
| 4168 | } |
| 4169 | if (LocaleCompare("crop",option+1) == 0) |
| 4170 | { |
| 4171 | if (*option == '+') |
| 4172 | break; |
| 4173 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4174 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4175 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4176 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4177 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4178 | break; |
| 4179 | } |
| 4180 | if (LocaleCompare("cycle",option+1) == 0) |
| 4181 | { |
| 4182 | if (*option == '+') |
| 4183 | break; |
| 4184 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4185 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4186 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4187 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4188 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4189 | break; |
| 4190 | } |
| 4191 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4192 | } |
| 4193 | case 'd': |
| 4194 | { |
| 4195 | if (LocaleCompare("decipher",option+1) == 0) |
| 4196 | { |
| 4197 | if (*option == '+') |
| 4198 | break; |
| 4199 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4200 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4201 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4202 | break; |
| 4203 | } |
| 4204 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4205 | break; |
| 4206 | if (LocaleCompare("debug",option+1) == 0) |
| 4207 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4208 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4209 | event; |
| 4210 | |
| 4211 | if (*option == '+') |
| 4212 | break; |
| 4213 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4214 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4215 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4216 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4217 | if (event < 0) |
| 4218 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4219 | argv[i]); |
| 4220 | (void) SetLogEventMask(argv[i]); |
| 4221 | break; |
| 4222 | } |
| 4223 | if (LocaleCompare("define",option+1) == 0) |
| 4224 | { |
| 4225 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4226 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4227 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4228 | if (*option == '+') |
| 4229 | { |
| 4230 | const char |
| 4231 | *define; |
| 4232 | |
| 4233 | define=GetImageOption(image_info,argv[i]); |
| 4234 | if (define == (const char *) NULL) |
| 4235 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4236 | break; |
| 4237 | } |
| 4238 | break; |
| 4239 | } |
| 4240 | if (LocaleCompare("delay",option+1) == 0) |
| 4241 | { |
| 4242 | if (*option == '+') |
| 4243 | break; |
| 4244 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4245 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4246 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4247 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4248 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4249 | break; |
| 4250 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4251 | if (LocaleCompare("delete",option+1) == 0) |
| 4252 | { |
| 4253 | if (*option == '+') |
| 4254 | break; |
| 4255 | i++; |
| 4256 | if (i == (ssize_t) (argc-1)) |
| 4257 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4258 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4259 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4260 | break; |
| 4261 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4262 | if (LocaleCompare("density",option+1) == 0) |
| 4263 | { |
| 4264 | if (*option == '+') |
| 4265 | break; |
| 4266 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4267 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4268 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4269 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4270 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4271 | break; |
| 4272 | } |
| 4273 | if (LocaleCompare("depth",option+1) == 0) |
| 4274 | { |
| 4275 | if (*option == '+') |
| 4276 | break; |
| 4277 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4278 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4279 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4280 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4281 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4282 | break; |
| 4283 | } |
| 4284 | if (LocaleCompare("deskew",option+1) == 0) |
| 4285 | { |
| 4286 | if (*option == '+') |
| 4287 | break; |
| 4288 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4289 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4290 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4291 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4292 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4293 | break; |
| 4294 | } |
| 4295 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4296 | break; |
| 4297 | if (LocaleCompare("dft",option+1) == 0) |
| 4298 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4299 | if (LocaleCompare("direction",option+1) == 0) |
| 4300 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4301 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4302 | direction; |
| 4303 | |
| 4304 | if (*option == '+') |
| 4305 | break; |
| 4306 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4307 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4308 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4309 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4310 | argv[i]); |
| 4311 | if (direction < 0) |
| 4312 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4313 | argv[i]); |
| 4314 | break; |
| 4315 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4316 | if (LocaleCompare("display",option+1) == 0) |
| 4317 | { |
| 4318 | if (*option == '+') |
| 4319 | break; |
| 4320 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4321 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4322 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4323 | break; |
| 4324 | } |
| 4325 | if (LocaleCompare("dispose",option+1) == 0) |
| 4326 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4327 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4328 | dispose; |
| 4329 | |
| 4330 | if (*option == '+') |
| 4331 | break; |
| 4332 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4333 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4334 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4335 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4336 | if (dispose < 0) |
| 4337 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4338 | argv[i]); |
| 4339 | break; |
| 4340 | } |
| 4341 | if (LocaleCompare("distort",option+1) == 0) |
| 4342 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4343 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4344 | op; |
| 4345 | |
| 4346 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4347 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4348 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4349 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4350 | if (op < 0) |
| 4351 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4352 | argv[i]); |
| 4353 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4354 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4355 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4356 | break; |
| 4357 | } |
| 4358 | if (LocaleCompare("dither",option+1) == 0) |
| 4359 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4360 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4361 | method; |
| 4362 | |
| 4363 | if (*option == '+') |
| 4364 | break; |
| 4365 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4366 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4367 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4368 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4369 | if (method < 0) |
| 4370 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4371 | argv[i]); |
| 4372 | break; |
| 4373 | } |
| 4374 | if (LocaleCompare("draw",option+1) == 0) |
| 4375 | { |
| 4376 | if (*option == '+') |
| 4377 | break; |
| 4378 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4379 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4380 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4381 | break; |
| 4382 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4383 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4384 | { |
| 4385 | if (*option == '+') |
| 4386 | break; |
| 4387 | i++; |
| 4388 | if (i == (ssize_t) (argc-1)) |
| 4389 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4390 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4391 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4392 | break; |
| 4393 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4394 | if (LocaleCompare("duration",option+1) == 0) |
| 4395 | { |
| 4396 | if (*option == '+') |
| 4397 | break; |
| 4398 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4399 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4400 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4401 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4402 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4403 | break; |
| 4404 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4405 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4406 | } |
| 4407 | case 'e': |
| 4408 | { |
| 4409 | if (LocaleCompare("edge",option+1) == 0) |
| 4410 | { |
| 4411 | if (*option == '+') |
| 4412 | break; |
| 4413 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4414 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4415 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4416 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4417 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4418 | break; |
| 4419 | } |
| 4420 | if (LocaleCompare("emboss",option+1) == 0) |
| 4421 | { |
| 4422 | if (*option == '+') |
| 4423 | break; |
| 4424 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4425 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4426 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4427 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4428 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4429 | break; |
| 4430 | } |
| 4431 | if (LocaleCompare("encipher",option+1) == 0) |
| 4432 | { |
| 4433 | if (*option == '+') |
| 4434 | break; |
| 4435 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4436 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4437 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4438 | break; |
| 4439 | } |
| 4440 | if (LocaleCompare("encoding",option+1) == 0) |
| 4441 | { |
| 4442 | if (*option == '+') |
| 4443 | break; |
| 4444 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4445 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4446 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4447 | break; |
| 4448 | } |
| 4449 | if (LocaleCompare("endian",option+1) == 0) |
| 4450 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4451 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4452 | endian; |
| 4453 | |
| 4454 | if (*option == '+') |
| 4455 | break; |
| 4456 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4457 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4458 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4459 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4460 | if (endian < 0) |
| 4461 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4462 | argv[i]); |
| 4463 | break; |
| 4464 | } |
| 4465 | if (LocaleCompare("enhance",option+1) == 0) |
| 4466 | break; |
| 4467 | if (LocaleCompare("equalize",option+1) == 0) |
| 4468 | break; |
| 4469 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4470 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4471 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4472 | op; |
| 4473 | |
| 4474 | if (*option == '+') |
| 4475 | break; |
| 4476 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4477 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4478 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4479 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4480 | if (op < 0) |
| 4481 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4482 | argv[i]); |
| 4483 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4484 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4485 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4486 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4487 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4488 | break; |
| 4489 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4490 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4491 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4492 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4493 | op; |
| 4494 | |
| 4495 | if (*option == '+') |
| 4496 | break; |
| 4497 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4498 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4499 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4500 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4501 | if (op < 0) |
| 4502 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4503 | argv[i]); |
| 4504 | break; |
| 4505 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4506 | if (LocaleCompare("extent",option+1) == 0) |
| 4507 | { |
| 4508 | if (*option == '+') |
| 4509 | break; |
| 4510 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4511 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4512 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4513 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4514 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4515 | break; |
| 4516 | } |
| 4517 | if (LocaleCompare("extract",option+1) == 0) |
| 4518 | { |
| 4519 | if (*option == '+') |
| 4520 | break; |
| 4521 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4522 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4523 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4524 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4525 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4526 | break; |
| 4527 | } |
| 4528 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4529 | } |
| 4530 | case 'f': |
| 4531 | { |
| 4532 | if (LocaleCompare("family",option+1) == 0) |
| 4533 | { |
| 4534 | if (*option == '+') |
| 4535 | break; |
| 4536 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4537 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4538 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4539 | break; |
| 4540 | } |
| 4541 | if (LocaleCompare("fill",option+1) == 0) |
| 4542 | { |
| 4543 | if (*option == '+') |
| 4544 | break; |
| 4545 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4546 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4547 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4548 | break; |
| 4549 | } |
| 4550 | if (LocaleCompare("filter",option+1) == 0) |
| 4551 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4552 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4553 | filter; |
| 4554 | |
| 4555 | if (*option == '+') |
| 4556 | break; |
| 4557 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4558 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4559 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4560 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4561 | if (filter < 0) |
| 4562 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4563 | argv[i]); |
| 4564 | break; |
| 4565 | } |
| 4566 | if (LocaleCompare("flatten",option+1) == 0) |
| 4567 | break; |
| 4568 | if (LocaleCompare("flip",option+1) == 0) |
| 4569 | break; |
| 4570 | if (LocaleCompare("flop",option+1) == 0) |
| 4571 | break; |
| 4572 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4573 | { |
| 4574 | if (*option == '+') |
| 4575 | break; |
| 4576 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4577 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4578 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4579 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4580 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4581 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4582 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4583 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4584 | break; |
| 4585 | } |
| 4586 | if (LocaleCompare("font",option+1) == 0) |
| 4587 | { |
| 4588 | if (*option == '+') |
| 4589 | break; |
| 4590 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4591 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4592 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4593 | break; |
| 4594 | } |
| 4595 | if (LocaleCompare("format",option+1) == 0) |
| 4596 | { |
| 4597 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4598 | (void) CloneString(&format,(char *) NULL); |
| 4599 | if (*option == '+') |
| 4600 | break; |
| 4601 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4602 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4603 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4604 | (void) CloneString(&format,argv[i]); |
| 4605 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4606 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4607 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4608 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4609 | if (*image_info->magick == '\0') |
| 4610 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4611 | format); |
| 4612 | break; |
| 4613 | } |
| 4614 | if (LocaleCompare("frame",option+1) == 0) |
| 4615 | { |
| 4616 | if (*option == '+') |
| 4617 | break; |
| 4618 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4619 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4620 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4621 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4622 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4623 | break; |
| 4624 | } |
| 4625 | if (LocaleCompare("function",option+1) == 0) |
| 4626 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4627 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4628 | op; |
| 4629 | |
| 4630 | if (*option == '+') |
| 4631 | break; |
| 4632 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4633 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4634 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4635 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4636 | if (op < 0) |
| 4637 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4638 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4639 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4640 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4641 | break; |
| 4642 | } |
| 4643 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4644 | { |
| 4645 | if (*option == '+') |
| 4646 | break; |
| 4647 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4648 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4649 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4650 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4651 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4652 | break; |
| 4653 | } |
| 4654 | if (LocaleCompare("fx",option+1) == 0) |
| 4655 | { |
| 4656 | if (*option == '+') |
| 4657 | break; |
| 4658 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4659 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4660 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4661 | break; |
| 4662 | } |
| 4663 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4664 | } |
| 4665 | case 'g': |
| 4666 | { |
| 4667 | if (LocaleCompare("gamma",option+1) == 0) |
| 4668 | { |
| 4669 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4670 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4671 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4672 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4673 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4674 | break; |
| 4675 | } |
| 4676 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4677 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4678 | { |
| 4679 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4680 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4681 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4682 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4683 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4684 | break; |
| 4685 | } |
| 4686 | if (LocaleCompare("geometry",option+1) == 0) |
| 4687 | { |
| 4688 | if (*option == '+') |
| 4689 | break; |
| 4690 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4691 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4692 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4693 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4694 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4695 | break; |
| 4696 | } |
| 4697 | if (LocaleCompare("gravity",option+1) == 0) |
| 4698 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4699 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4700 | gravity; |
| 4701 | |
| 4702 | if (*option == '+') |
| 4703 | break; |
| 4704 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4705 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4706 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4707 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4708 | if (gravity < 0) |
| 4709 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4710 | argv[i]); |
| 4711 | break; |
| 4712 | } |
| 4713 | if (LocaleCompare("green-primary",option+1) == 0) |
| 4714 | { |
| 4715 | if (*option == '+') |
| 4716 | break; |
| 4717 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4718 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4719 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4720 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4721 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4722 | break; |
| 4723 | } |
| 4724 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4725 | } |
| 4726 | case 'h': |
| 4727 | { |
| 4728 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4729 | break; |
| 4730 | if ((LocaleCompare("help",option+1) == 0) || |
| 4731 | (LocaleCompare("-help",option+1) == 0)) |
| 4732 | return(MogrifyUsage()); |
| 4733 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4734 | } |
| 4735 | case 'i': |
| 4736 | { |
| 4737 | if (LocaleCompare("identify",option+1) == 0) |
| 4738 | break; |
| 4739 | if (LocaleCompare("idft",option+1) == 0) |
| 4740 | break; |
| 4741 | if (LocaleCompare("implode",option+1) == 0) |
| 4742 | { |
| 4743 | if (*option == '+') |
| 4744 | break; |
| 4745 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4746 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4747 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4748 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4749 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4750 | break; |
| 4751 | } |
| 4752 | if (LocaleCompare("intent",option+1) == 0) |
| 4753 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4754 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4755 | intent; |
| 4756 | |
| 4757 | if (*option == '+') |
| 4758 | break; |
| 4759 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4760 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4761 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4762 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4763 | if (intent < 0) |
| 4764 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4765 | argv[i]); |
| 4766 | break; |
| 4767 | } |
| 4768 | if (LocaleCompare("interlace",option+1) == 0) |
| 4769 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4770 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4771 | interlace; |
| 4772 | |
| 4773 | if (*option == '+') |
| 4774 | break; |
| 4775 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4776 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4777 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4778 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4779 | argv[i]); |
| 4780 | if (interlace < 0) |
| 4781 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4782 | argv[i]); |
| 4783 | break; |
| 4784 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4785 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4786 | { |
| 4787 | if (*option == '+') |
| 4788 | break; |
| 4789 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4790 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4791 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4792 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4793 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4794 | break; |
| 4795 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4796 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4797 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4798 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4799 | interpolate; |
| 4800 | |
| 4801 | if (*option == '+') |
| 4802 | break; |
| 4803 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4804 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4805 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4806 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4807 | argv[i]); |
| 4808 | if (interpolate < 0) |
| 4809 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4810 | argv[i]); |
| 4811 | break; |
| 4812 | } |
| 4813 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4814 | { |
| 4815 | if (*option == '+') |
| 4816 | break; |
| 4817 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4818 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4819 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4820 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4821 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4822 | break; |
| 4823 | } |
| 4824 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4825 | } |
| 4826 | case 'k': |
| 4827 | { |
| 4828 | if (LocaleCompare("kerning",option+1) == 0) |
| 4829 | { |
| 4830 | if (*option == '+') |
| 4831 | break; |
| 4832 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4833 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4834 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4835 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4836 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4837 | break; |
| 4838 | } |
| 4839 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4840 | } |
| 4841 | case 'l': |
| 4842 | { |
| 4843 | if (LocaleCompare("label",option+1) == 0) |
| 4844 | { |
| 4845 | if (*option == '+') |
| 4846 | break; |
| 4847 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4848 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4849 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4850 | break; |
| 4851 | } |
| 4852 | if (LocaleCompare("lat",option+1) == 0) |
| 4853 | { |
| 4854 | if (*option == '+') |
| 4855 | break; |
| 4856 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4857 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4858 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4859 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4860 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4861 | } |
| 4862 | if (LocaleCompare("layers",option+1) == 0) |
| 4863 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4864 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4865 | type; |
| 4866 | |
| 4867 | if (*option == '+') |
| 4868 | break; |
| 4869 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4870 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4871 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4872 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4873 | if (type < 0) |
| 4874 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4875 | argv[i]); |
| 4876 | break; |
| 4877 | } |
| 4878 | if (LocaleCompare("level",option+1) == 0) |
| 4879 | { |
| 4880 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4881 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4882 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4883 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4884 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4885 | break; |
| 4886 | } |
| 4887 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4888 | { |
| 4889 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4890 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4891 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4892 | break; |
| 4893 | } |
| 4894 | if (LocaleCompare("linewidth",option+1) == 0) |
| 4895 | { |
| 4896 | if (*option == '+') |
| 4897 | break; |
| 4898 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4899 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4900 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4901 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4902 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4903 | break; |
| 4904 | } |
| 4905 | if (LocaleCompare("limit",option+1) == 0) |
| 4906 | { |
| 4907 | char |
| 4908 | *p; |
| 4909 | |
| 4910 | double |
| 4911 | value; |
| 4912 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4913 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4914 | resource; |
| 4915 | |
| 4916 | if (*option == '+') |
| 4917 | break; |
| 4918 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4919 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4920 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4921 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4922 | argv[i]); |
| 4923 | if (resource < 0) |
| 4924 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4925 | argv[i]); |
| 4926 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4927 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4928 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 4929 | value=InterpretLocaleValue(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4930 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4931 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4932 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4933 | break; |
| 4934 | } |
| 4935 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4936 | { |
| 4937 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4938 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4939 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4940 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4941 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4942 | break; |
| 4943 | } |
| 4944 | if (LocaleCompare("list",option+1) == 0) |
| 4945 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4946 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4947 | list; |
| 4948 | |
| 4949 | if (*option == '+') |
| 4950 | break; |
| 4951 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4952 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4953 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4954 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4955 | if (list < 0) |
| 4956 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4957 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4958 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4959 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4960 | } |
| 4961 | if (LocaleCompare("log",option+1) == 0) |
| 4962 | { |
| 4963 | if (*option == '+') |
| 4964 | break; |
| 4965 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4966 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4967 | (strchr(argv[i],'%') == (char *) NULL)) |
| 4968 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4969 | break; |
| 4970 | } |
| 4971 | if (LocaleCompare("loop",option+1) == 0) |
| 4972 | { |
| 4973 | if (*option == '+') |
| 4974 | break; |
| 4975 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4976 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4977 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4978 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4979 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4980 | break; |
| 4981 | } |
| 4982 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4983 | } |
| 4984 | case 'm': |
| 4985 | { |
| 4986 | if (LocaleCompare("map",option+1) == 0) |
| 4987 | { |
| 4988 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 4989 | if (*option == '+') |
| 4990 | break; |
| 4991 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4992 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4993 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4994 | break; |
| 4995 | } |
| 4996 | if (LocaleCompare("mask",option+1) == 0) |
| 4997 | { |
| 4998 | if (*option == '+') |
| 4999 | break; |
| 5000 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5001 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5002 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5003 | break; |
| 5004 | } |
| 5005 | if (LocaleCompare("matte",option+1) == 0) |
| 5006 | break; |
| 5007 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 5008 | { |
| 5009 | if (*option == '+') |
| 5010 | break; |
| 5011 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5012 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5013 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5014 | break; |
| 5015 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5016 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5017 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5018 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5019 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5020 | if (LocaleCompare("modulate",option+1) == 0) |
| 5021 | { |
| 5022 | if (*option == '+') |
| 5023 | break; |
| 5024 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5025 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5026 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5027 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5028 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5029 | break; |
| 5030 | } |
| 5031 | if (LocaleCompare("median",option+1) == 0) |
| 5032 | { |
| 5033 | if (*option == '+') |
| 5034 | break; |
| 5035 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5036 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5037 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5038 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5039 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5040 | break; |
| 5041 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5042 | if (LocaleCompare("mode",option+1) == 0) |
| 5043 | { |
| 5044 | if (*option == '+') |
| 5045 | break; |
| 5046 | i++; |
| 5047 | if (i == (ssize_t) argc) |
| 5048 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5049 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5050 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5051 | break; |
| 5052 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5053 | if (LocaleCompare("monitor",option+1) == 0) |
| 5054 | break; |
| 5055 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5056 | break; |
| 5057 | if (LocaleCompare("morph",option+1) == 0) |
| 5058 | { |
| 5059 | if (*option == '+') |
| 5060 | break; |
| 5061 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5062 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5063 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5064 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5065 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5066 | break; |
| 5067 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5068 | if (LocaleCompare("morphology",option+1) == 0) |
| 5069 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5070 | char |
| 5071 | token[MaxTextExtent]; |
| 5072 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5073 | KernelInfo |
| 5074 | *kernel_info; |
| 5075 | |
| 5076 | ssize_t |
| 5077 | op; |
| 5078 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5079 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5080 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5081 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5082 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5083 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5084 | if (op < 0) |
| 5085 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5086 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5087 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5088 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5089 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5090 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5091 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5092 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5093 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5094 | break; |
| 5095 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5096 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5097 | break; |
| 5098 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5099 | { |
| 5100 | if (*option == '+') |
| 5101 | break; |
| 5102 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5103 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5104 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5105 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5106 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5107 | break; |
| 5108 | } |
| 5109 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5110 | } |
| 5111 | case 'n': |
| 5112 | { |
| 5113 | if (LocaleCompare("negate",option+1) == 0) |
| 5114 | break; |
| 5115 | if (LocaleCompare("noise",option+1) == 0) |
| 5116 | { |
| 5117 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5118 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5119 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5120 | if (*option == '+') |
| 5121 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5122 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5123 | noise; |
| 5124 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5125 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5126 | if (noise < 0) |
| 5127 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5128 | argv[i]); |
| 5129 | break; |
| 5130 | } |
| 5131 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5132 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5133 | break; |
| 5134 | } |
| 5135 | if (LocaleCompare("noop",option+1) == 0) |
| 5136 | break; |
| 5137 | if (LocaleCompare("normalize",option+1) == 0) |
| 5138 | break; |
| 5139 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5140 | } |
| 5141 | case 'o': |
| 5142 | { |
| 5143 | if (LocaleCompare("opaque",option+1) == 0) |
| 5144 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5145 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5146 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5147 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5148 | break; |
| 5149 | } |
| 5150 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5151 | { |
| 5152 | if (*option == '+') |
| 5153 | break; |
| 5154 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5155 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5156 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5157 | break; |
| 5158 | } |
| 5159 | if (LocaleCompare("orient",option+1) == 0) |
| 5160 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5161 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5162 | orientation; |
| 5163 | |
| 5164 | orientation=UndefinedOrientation; |
| 5165 | if (*option == '+') |
| 5166 | break; |
| 5167 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5168 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5169 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5170 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5171 | argv[i]); |
| 5172 | if (orientation < 0) |
| 5173 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5174 | argv[i]); |
| 5175 | break; |
| 5176 | } |
| 5177 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5178 | } |
| 5179 | case 'p': |
| 5180 | { |
| 5181 | if (LocaleCompare("page",option+1) == 0) |
| 5182 | { |
| 5183 | if (*option == '+') |
| 5184 | break; |
| 5185 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5186 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5187 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5188 | break; |
| 5189 | } |
| 5190 | if (LocaleCompare("paint",option+1) == 0) |
| 5191 | { |
| 5192 | if (*option == '+') |
| 5193 | break; |
| 5194 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5195 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5196 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5197 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5198 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5199 | break; |
| 5200 | } |
| 5201 | if (LocaleCompare("path",option+1) == 0) |
| 5202 | { |
| 5203 | (void) CloneString(&path,(char *) NULL); |
| 5204 | if (*option == '+') |
| 5205 | break; |
| 5206 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5207 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5208 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5209 | (void) CloneString(&path,argv[i]); |
| 5210 | break; |
| 5211 | } |
| 5212 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5213 | { |
| 5214 | if (*option == '+') |
| 5215 | break; |
| 5216 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5217 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5218 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5219 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5220 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5221 | break; |
| 5222 | } |
| 5223 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5224 | { |
| 5225 | if (*option == '+') |
| 5226 | break; |
| 5227 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5228 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5229 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5230 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5231 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5232 | break; |
| 5233 | } |
| 5234 | if (LocaleCompare("posterize",option+1) == 0) |
| 5235 | { |
| 5236 | if (*option == '+') |
| 5237 | break; |
| 5238 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5239 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5240 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5241 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5242 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5243 | break; |
| 5244 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5245 | if (LocaleCompare("precision",option+1) == 0) |
| 5246 | { |
| 5247 | if (*option == '+') |
| 5248 | break; |
| 5249 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5250 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5251 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5252 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5253 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5254 | break; |
| 5255 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5256 | if (LocaleCompare("print",option+1) == 0) |
| 5257 | { |
| 5258 | if (*option == '+') |
| 5259 | break; |
| 5260 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5261 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5262 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5263 | break; |
| 5264 | } |
| 5265 | if (LocaleCompare("process",option+1) == 0) |
| 5266 | { |
| 5267 | if (*option == '+') |
| 5268 | break; |
| 5269 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5270 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5271 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5272 | break; |
| 5273 | } |
| 5274 | if (LocaleCompare("profile",option+1) == 0) |
| 5275 | { |
| 5276 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5277 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5278 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5279 | break; |
| 5280 | } |
| 5281 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5282 | } |
| 5283 | case 'q': |
| 5284 | { |
| 5285 | if (LocaleCompare("quality",option+1) == 0) |
| 5286 | { |
| 5287 | if (*option == '+') |
| 5288 | break; |
| 5289 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5290 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5291 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5292 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5293 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5294 | break; |
| 5295 | } |
| 5296 | if (LocaleCompare("quantize",option+1) == 0) |
| 5297 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5298 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5299 | colorspace; |
| 5300 | |
| 5301 | if (*option == '+') |
| 5302 | break; |
| 5303 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5304 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5305 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5306 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5307 | argv[i]); |
| 5308 | if (colorspace < 0) |
| 5309 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5310 | argv[i]); |
| 5311 | break; |
| 5312 | } |
| 5313 | if (LocaleCompare("quiet",option+1) == 0) |
| 5314 | break; |
| 5315 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5316 | } |
| 5317 | case 'r': |
| 5318 | { |
| 5319 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5320 | { |
| 5321 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5322 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5323 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5324 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5325 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5326 | break; |
| 5327 | } |
| 5328 | if (LocaleCompare("raise",option+1) == 0) |
| 5329 | { |
| 5330 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5331 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5332 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5333 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5334 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5335 | break; |
| 5336 | } |
| 5337 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5338 | { |
| 5339 | if (*option == '+') |
| 5340 | break; |
| 5341 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5342 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5343 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5344 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5345 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5346 | break; |
| 5347 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5348 | if (LocaleCompare("recolor",option+1) == 0) |
| 5349 | { |
| 5350 | if (*option == '+') |
| 5351 | break; |
| 5352 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5353 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5354 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5355 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5356 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5357 | break; |
| 5358 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5359 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5360 | { |
| 5361 | if (*option == '+') |
| 5362 | break; |
| 5363 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5364 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5365 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5366 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5367 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5368 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5369 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5370 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5371 | if (LocaleCompare("region",option+1) == 0) |
| 5372 | { |
| 5373 | if (*option == '+') |
| 5374 | break; |
| 5375 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5376 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5377 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5378 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5379 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5380 | break; |
| 5381 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5382 | if (LocaleCompare("remap",option+1) == 0) |
| 5383 | { |
| 5384 | if (*option == '+') |
| 5385 | break; |
| 5386 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5387 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5388 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5389 | break; |
| 5390 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5391 | if (LocaleCompare("render",option+1) == 0) |
| 5392 | break; |
| 5393 | if (LocaleCompare("repage",option+1) == 0) |
| 5394 | { |
| 5395 | if (*option == '+') |
| 5396 | break; |
| 5397 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5398 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5399 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5400 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5401 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5402 | break; |
| 5403 | } |
| 5404 | if (LocaleCompare("resample",option+1) == 0) |
| 5405 | { |
| 5406 | if (*option == '+') |
| 5407 | break; |
| 5408 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5409 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5410 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5411 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5412 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5413 | break; |
| 5414 | } |
| 5415 | if (LocaleCompare("resize",option+1) == 0) |
| 5416 | { |
| 5417 | if (*option == '+') |
| 5418 | break; |
| 5419 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5420 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5421 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5422 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5423 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5424 | break; |
| 5425 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5426 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5427 | { |
| 5428 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5429 | break; |
| 5430 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5431 | if (LocaleCompare("reverse",option+1) == 0) |
| 5432 | break; |
| 5433 | if (LocaleCompare("roll",option+1) == 0) |
| 5434 | { |
| 5435 | if (*option == '+') |
| 5436 | break; |
| 5437 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5438 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5439 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5440 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5441 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5442 | break; |
| 5443 | } |
| 5444 | if (LocaleCompare("rotate",option+1) == 0) |
| 5445 | { |
| 5446 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5447 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5448 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5449 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5450 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5451 | break; |
| 5452 | } |
| 5453 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5454 | } |
| 5455 | case 's': |
| 5456 | { |
| 5457 | if (LocaleCompare("sample",option+1) == 0) |
| 5458 | { |
| 5459 | if (*option == '+') |
| 5460 | break; |
| 5461 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5462 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5463 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5464 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5465 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5466 | break; |
| 5467 | } |
| 5468 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5469 | { |
| 5470 | if (*option == '+') |
| 5471 | break; |
| 5472 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5473 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5474 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5475 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5476 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5477 | break; |
| 5478 | } |
| 5479 | if (LocaleCompare("scale",option+1) == 0) |
| 5480 | { |
| 5481 | if (*option == '+') |
| 5482 | break; |
| 5483 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5484 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5485 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5486 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5487 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5488 | break; |
| 5489 | } |
| 5490 | if (LocaleCompare("scene",option+1) == 0) |
| 5491 | { |
| 5492 | if (*option == '+') |
| 5493 | break; |
| 5494 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5495 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5496 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5497 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5498 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5499 | break; |
| 5500 | } |
| 5501 | if (LocaleCompare("seed",option+1) == 0) |
| 5502 | { |
| 5503 | if (*option == '+') |
| 5504 | break; |
| 5505 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5506 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5507 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5508 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5509 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5510 | break; |
| 5511 | } |
| 5512 | if (LocaleCompare("segment",option+1) == 0) |
| 5513 | { |
| 5514 | if (*option == '+') |
| 5515 | break; |
| 5516 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5517 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5518 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5519 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5520 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5521 | break; |
| 5522 | } |
| 5523 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5524 | { |
| 5525 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5526 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5527 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5528 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5529 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5530 | break; |
| 5531 | } |
| 5532 | if (LocaleCompare("separate",option+1) == 0) |
| 5533 | break; |
| 5534 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5535 | { |
| 5536 | if (*option == '+') |
| 5537 | break; |
| 5538 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5539 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5540 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5541 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5542 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5543 | break; |
| 5544 | } |
| 5545 | if (LocaleCompare("set",option+1) == 0) |
| 5546 | { |
| 5547 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5548 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5549 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5550 | if (*option == '+') |
| 5551 | break; |
| 5552 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5553 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5554 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5555 | break; |
| 5556 | } |
| 5557 | if (LocaleCompare("shade",option+1) == 0) |
| 5558 | { |
| 5559 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5560 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5561 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5562 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5563 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5564 | break; |
| 5565 | } |
| 5566 | if (LocaleCompare("shadow",option+1) == 0) |
| 5567 | { |
| 5568 | if (*option == '+') |
| 5569 | break; |
| 5570 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5571 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5572 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5573 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5574 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5575 | break; |
| 5576 | } |
| 5577 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5578 | { |
| 5579 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5580 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5581 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5582 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5583 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5584 | break; |
| 5585 | } |
| 5586 | if (LocaleCompare("shave",option+1) == 0) |
| 5587 | { |
| 5588 | if (*option == '+') |
| 5589 | break; |
| 5590 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5591 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5592 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5593 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5594 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5595 | break; |
| 5596 | } |
| 5597 | if (LocaleCompare("shear",option+1) == 0) |
| 5598 | { |
| 5599 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5600 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5601 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5602 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5603 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5604 | break; |
| 5605 | } |
| 5606 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5607 | { |
| 5608 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5609 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5610 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5611 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5612 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5613 | break; |
| 5614 | } |
| 5615 | if (LocaleCompare("size",option+1) == 0) |
| 5616 | { |
| 5617 | if (*option == '+') |
| 5618 | break; |
| 5619 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5620 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5621 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5622 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5623 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5624 | break; |
| 5625 | } |
| 5626 | if (LocaleCompare("sketch",option+1) == 0) |
| 5627 | { |
| 5628 | if (*option == '+') |
| 5629 | break; |
| 5630 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5631 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5632 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5633 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5634 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5635 | break; |
| 5636 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5637 | if (LocaleCompare("smush",option+1) == 0) |
| 5638 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5639 | i++; |
| 5640 | if (i == (ssize_t) argc) |
| 5641 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5642 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5643 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5644 | i++; |
| 5645 | break; |
| 5646 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5647 | if (LocaleCompare("solarize",option+1) == 0) |
| 5648 | { |
| 5649 | if (*option == '+') |
| 5650 | break; |
| 5651 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5652 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5653 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5654 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5655 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5656 | break; |
| 5657 | } |
| 5658 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5659 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5660 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5661 | op; |
| 5662 | |
| 5663 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5664 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5665 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5666 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5667 | if (op < 0) |
| 5668 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5669 | argv[i]); |
| 5670 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5671 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5672 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5673 | break; |
| 5674 | } |
| 5675 | if (LocaleCompare("spread",option+1) == 0) |
| 5676 | { |
| 5677 | if (*option == '+') |
| 5678 | break; |
| 5679 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5680 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5681 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5682 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5683 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5684 | break; |
| 5685 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5686 | if (LocaleCompare("statistic",option+1) == 0) |
| 5687 | { |
| 5688 | ssize_t |
| 5689 | op; |
| 5690 | |
| 5691 | if (*option == '+') |
| 5692 | break; |
| 5693 | i++; |
| 5694 | if (i == (ssize_t) argc) |
| 5695 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5696 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5697 | if (op < 0) |
| 5698 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5699 | argv[i]); |
| 5700 | i++; |
| 5701 | if (i == (ssize_t) (argc-1)) |
| 5702 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5703 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5704 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5705 | break; |
| 5706 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5707 | if (LocaleCompare("stretch",option+1) == 0) |
| 5708 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5709 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5710 | stretch; |
| 5711 | |
| 5712 | if (*option == '+') |
| 5713 | break; |
| 5714 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5715 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5716 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5717 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5718 | if (stretch < 0) |
| 5719 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5720 | argv[i]); |
| 5721 | break; |
| 5722 | } |
| 5723 | if (LocaleCompare("strip",option+1) == 0) |
| 5724 | break; |
| 5725 | if (LocaleCompare("stroke",option+1) == 0) |
| 5726 | { |
| 5727 | if (*option == '+') |
| 5728 | break; |
| 5729 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5730 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5731 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5732 | break; |
| 5733 | } |
| 5734 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5735 | { |
| 5736 | if (*option == '+') |
| 5737 | break; |
| 5738 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5739 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5740 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5741 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5742 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5743 | break; |
| 5744 | } |
| 5745 | if (LocaleCompare("style",option+1) == 0) |
| 5746 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5747 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5748 | style; |
| 5749 | |
| 5750 | if (*option == '+') |
| 5751 | break; |
| 5752 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5753 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5754 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5755 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5756 | if (style < 0) |
| 5757 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5758 | argv[i]); |
| 5759 | break; |
| 5760 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5761 | if (LocaleCompare("swap",option+1) == 0) |
| 5762 | { |
| 5763 | if (*option == '+') |
| 5764 | break; |
| 5765 | i++; |
| 5766 | if (i == (ssize_t) (argc-1)) |
| 5767 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5768 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5769 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5770 | break; |
| 5771 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5772 | if (LocaleCompare("swirl",option+1) == 0) |
| 5773 | { |
| 5774 | if (*option == '+') |
| 5775 | break; |
| 5776 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5777 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5778 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5779 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5780 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5781 | break; |
| 5782 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5783 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5784 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5785 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5786 | } |
| 5787 | case 't': |
| 5788 | { |
| 5789 | if (LocaleCompare("taint",option+1) == 0) |
| 5790 | break; |
| 5791 | if (LocaleCompare("texture",option+1) == 0) |
| 5792 | { |
| 5793 | if (*option == '+') |
| 5794 | break; |
| 5795 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5796 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5797 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5798 | break; |
| 5799 | } |
| 5800 | if (LocaleCompare("tile",option+1) == 0) |
| 5801 | { |
| 5802 | if (*option == '+') |
| 5803 | break; |
| 5804 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5805 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5806 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5807 | break; |
| 5808 | } |
| 5809 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5810 | { |
| 5811 | if (*option == '+') |
| 5812 | break; |
| 5813 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5814 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5815 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5816 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5817 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5818 | break; |
| 5819 | } |
| 5820 | if (LocaleCompare("tint",option+1) == 0) |
| 5821 | { |
| 5822 | if (*option == '+') |
| 5823 | break; |
| 5824 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5825 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5826 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5827 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5828 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5829 | break; |
| 5830 | } |
| 5831 | if (LocaleCompare("transform",option+1) == 0) |
| 5832 | break; |
| 5833 | if (LocaleCompare("transpose",option+1) == 0) |
| 5834 | break; |
| 5835 | if (LocaleCompare("transverse",option+1) == 0) |
| 5836 | break; |
| 5837 | if (LocaleCompare("threshold",option+1) == 0) |
| 5838 | { |
| 5839 | if (*option == '+') |
| 5840 | break; |
| 5841 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5842 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5843 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5844 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5845 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5846 | break; |
| 5847 | } |
| 5848 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5849 | { |
| 5850 | if (*option == '+') |
| 5851 | break; |
| 5852 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5853 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5854 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5855 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5856 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5857 | break; |
| 5858 | } |
| 5859 | if (LocaleCompare("transparent",option+1) == 0) |
| 5860 | { |
| 5861 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5862 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5863 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5864 | break; |
| 5865 | } |
| 5866 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 5867 | { |
| 5868 | if (*option == '+') |
| 5869 | break; |
| 5870 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5871 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5872 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5873 | break; |
| 5874 | } |
| 5875 | if (LocaleCompare("treedepth",option+1) == 0) |
| 5876 | { |
| 5877 | if (*option == '+') |
| 5878 | break; |
| 5879 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5880 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5881 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5882 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5883 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5884 | break; |
| 5885 | } |
| 5886 | if (LocaleCompare("trim",option+1) == 0) |
| 5887 | break; |
| 5888 | if (LocaleCompare("type",option+1) == 0) |
| 5889 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5890 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5891 | type; |
| 5892 | |
| 5893 | if (*option == '+') |
| 5894 | break; |
| 5895 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5896 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5897 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5898 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5899 | if (type < 0) |
| 5900 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5901 | argv[i]); |
| 5902 | break; |
| 5903 | } |
| 5904 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5905 | } |
| 5906 | case 'u': |
| 5907 | { |
| 5908 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5909 | { |
| 5910 | if (*option == '+') |
| 5911 | break; |
| 5912 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5913 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5914 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5915 | break; |
| 5916 | } |
| 5917 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5918 | break; |
| 5919 | if (LocaleCompare("units",option+1) == 0) |
| 5920 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5921 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5922 | units; |
| 5923 | |
| 5924 | if (*option == '+') |
| 5925 | break; |
| 5926 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5927 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5928 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5929 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5930 | argv[i]); |
| 5931 | if (units < 0) |
| 5932 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5933 | argv[i]); |
| 5934 | break; |
| 5935 | } |
| 5936 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5937 | { |
| 5938 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5939 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5940 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5941 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5942 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5943 | break; |
| 5944 | } |
| 5945 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5946 | } |
| 5947 | case 'v': |
| 5948 | { |
| 5949 | if (LocaleCompare("verbose",option+1) == 0) |
| 5950 | { |
| 5951 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 5952 | break; |
| 5953 | } |
| 5954 | if ((LocaleCompare("version",option+1) == 0) || |
| 5955 | (LocaleCompare("-version",option+1) == 0)) |
| 5956 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 5957 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5958 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 5959 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 5960 | GetMagickCopyright()); |
| 5961 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 5962 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5963 | break; |
| 5964 | } |
| 5965 | if (LocaleCompare("view",option+1) == 0) |
| 5966 | { |
| 5967 | if (*option == '+') |
| 5968 | break; |
| 5969 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5970 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5971 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5972 | break; |
| 5973 | } |
| 5974 | if (LocaleCompare("vignette",option+1) == 0) |
| 5975 | { |
| 5976 | if (*option == '+') |
| 5977 | break; |
| 5978 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5979 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5980 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5981 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5982 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5983 | break; |
| 5984 | } |
| 5985 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 5986 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5987 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5988 | method; |
| 5989 | |
| 5990 | if (*option == '+') |
| 5991 | break; |
| 5992 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5993 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5994 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5995 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5996 | argv[i]); |
| 5997 | if (method < 0) |
| 5998 | ThrowMogrifyException(OptionError, |
| 5999 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 6000 | break; |
| 6001 | } |
| 6002 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6003 | } |
| 6004 | case 'w': |
| 6005 | { |
| 6006 | if (LocaleCompare("wave",option+1) == 0) |
| 6007 | { |
| 6008 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6009 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6010 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6011 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6012 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6013 | break; |
| 6014 | } |
| 6015 | if (LocaleCompare("weight",option+1) == 0) |
| 6016 | { |
| 6017 | if (*option == '+') |
| 6018 | break; |
| 6019 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6020 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6021 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6022 | break; |
| 6023 | } |
| 6024 | if (LocaleCompare("white-point",option+1) == 0) |
| 6025 | { |
| 6026 | if (*option == '+') |
| 6027 | break; |
| 6028 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6029 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6030 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6031 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6032 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6033 | break; |
| 6034 | } |
| 6035 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6036 | { |
| 6037 | if (*option == '+') |
| 6038 | break; |
| 6039 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6040 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6041 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6042 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6043 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6044 | break; |
| 6045 | } |
| 6046 | if (LocaleCompare("write",option+1) == 0) |
| 6047 | { |
| 6048 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6049 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6050 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6051 | break; |
| 6052 | } |
| 6053 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6054 | } |
| 6055 | case '?': |
| 6056 | break; |
| 6057 | default: |
| 6058 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6059 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6060 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 6061 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6062 | if (fire != MagickFalse) |
| 6063 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6064 | } |
| 6065 | if (k != 0) |
| 6066 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6067 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6068 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6069 | DestroyMogrify(); |
| 6070 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6071 | } |
| 6072 | |
| 6073 | /* |
| 6074 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6075 | % % |
| 6076 | % % |
| 6077 | % % |
| 6078 | + M o g r i f y I m a g e I n f o % |
| 6079 | % % |
| 6080 | % % |
| 6081 | % % |
| 6082 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6083 | % |
| 6084 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6085 | % prescribed by command line options. |
| 6086 | % |
| 6087 | % The format of the MogrifyImageInfo method is: |
| 6088 | % |
| 6089 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6090 | % const char **argv,ExceptionInfo *exception) |
| 6091 | % |
| 6092 | % A description of each parameter follows: |
| 6093 | % |
| 6094 | % o image_info: the image info.. |
| 6095 | % |
| 6096 | % o argc: Specifies a pointer to an integer describing the number of |
| 6097 | % elements in the argument vector. |
| 6098 | % |
| 6099 | % o argv: Specifies a pointer to a text array containing the command line |
| 6100 | % arguments. |
| 6101 | % |
| 6102 | % o exception: return any errors or warnings in this structure. |
| 6103 | % |
| 6104 | */ |
| 6105 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6106 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6107 | { |
| 6108 | const char |
| 6109 | *option; |
| 6110 | |
| 6111 | GeometryInfo |
| 6112 | geometry_info; |
| 6113 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6114 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6115 | count; |
| 6116 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6117 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6118 | i; |
| 6119 | |
| 6120 | /* |
| 6121 | Initialize method variables. |
| 6122 | */ |
| 6123 | assert(image_info != (ImageInfo *) NULL); |
| 6124 | assert(image_info->signature == MagickSignature); |
| 6125 | if (image_info->debug != MagickFalse) |
| 6126 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6127 | image_info->filename); |
| 6128 | if (argc < 0) |
| 6129 | return(MagickTrue); |
| 6130 | /* |
| 6131 | Set the image settings. |
| 6132 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6133 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6134 | { |
| 6135 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6136 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6137 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6138 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6139 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6140 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6141 | break; |
| 6142 | switch (*(option+1)) |
| 6143 | { |
| 6144 | case 'a': |
| 6145 | { |
| 6146 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6147 | { |
| 6148 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6149 | break; |
| 6150 | } |
| 6151 | if (LocaleCompare("antialias",option+1) == 0) |
| 6152 | { |
| 6153 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6154 | break; |
| 6155 | } |
| 6156 | if (LocaleCompare("attenuate",option+1) == 0) |
| 6157 | { |
| 6158 | if (*option == '+') |
| 6159 | { |
| 6160 | (void) DeleteImageOption(image_info,option+1); |
| 6161 | break; |
| 6162 | } |
| 6163 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6164 | break; |
| 6165 | } |
| 6166 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6167 | { |
| 6168 | if (*option == '+') |
| 6169 | (void) CloneString(&image_info->authenticate,(char *) NULL); |
| 6170 | else |
| 6171 | (void) CloneString(&image_info->authenticate,argv[i+1]); |
| 6172 | break; |
| 6173 | } |
| 6174 | break; |
| 6175 | } |
| 6176 | case 'b': |
| 6177 | { |
| 6178 | if (LocaleCompare("background",option+1) == 0) |
| 6179 | { |
| 6180 | if (*option == '+') |
| 6181 | { |
| 6182 | (void) DeleteImageOption(image_info,option+1); |
| 6183 | (void) QueryColorDatabase(BackgroundColor, |
| 6184 | &image_info->background_color,exception); |
| 6185 | break; |
| 6186 | } |
| 6187 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6188 | (void) QueryColorDatabase(argv[i+1],&image_info->background_color, |
| 6189 | exception); |
| 6190 | break; |
| 6191 | } |
| 6192 | if (LocaleCompare("bias",option+1) == 0) |
| 6193 | { |
| 6194 | if (*option == '+') |
| 6195 | { |
| 6196 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6197 | break; |
| 6198 | } |
| 6199 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6200 | break; |
| 6201 | } |
| 6202 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6203 | { |
| 6204 | if (*option == '+') |
| 6205 | { |
| 6206 | (void) SetImageOption(image_info,option+1,"false"); |
| 6207 | break; |
| 6208 | } |
| 6209 | (void) SetImageOption(image_info,option+1,"true"); |
| 6210 | break; |
| 6211 | } |
| 6212 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6213 | { |
| 6214 | if (*option == '+') |
| 6215 | { |
| 6216 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6217 | break; |
| 6218 | } |
| 6219 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6220 | break; |
| 6221 | } |
| 6222 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6223 | { |
| 6224 | if (*option == '+') |
| 6225 | { |
| 6226 | (void) DeleteImageOption(image_info,option+1); |
| 6227 | (void) QueryColorDatabase(BorderColor,&image_info->border_color, |
| 6228 | exception); |
| 6229 | break; |
| 6230 | } |
| 6231 | (void) QueryColorDatabase(argv[i+1],&image_info->border_color, |
| 6232 | exception); |
| 6233 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6234 | break; |
| 6235 | } |
| 6236 | if (LocaleCompare("box",option+1) == 0) |
| 6237 | { |
| 6238 | if (*option == '+') |
| 6239 | { |
| 6240 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6241 | break; |
| 6242 | } |
| 6243 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6244 | break; |
| 6245 | } |
| 6246 | break; |
| 6247 | } |
| 6248 | case 'c': |
| 6249 | { |
| 6250 | if (LocaleCompare("cache",option+1) == 0) |
| 6251 | { |
| 6252 | MagickSizeType |
| 6253 | limit; |
| 6254 | |
| 6255 | limit=MagickResourceInfinity; |
| 6256 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6257 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6258 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6259 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6260 | break; |
| 6261 | } |
| 6262 | if (LocaleCompare("caption",option+1) == 0) |
| 6263 | { |
| 6264 | if (*option == '+') |
| 6265 | { |
| 6266 | (void) DeleteImageOption(image_info,option+1); |
| 6267 | break; |
| 6268 | } |
| 6269 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6270 | break; |
| 6271 | } |
| 6272 | if (LocaleCompare("channel",option+1) == 0) |
| 6273 | { |
| 6274 | if (*option == '+') |
| 6275 | { |
| 6276 | image_info->channel=DefaultChannels; |
| 6277 | break; |
| 6278 | } |
| 6279 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6280 | break; |
| 6281 | } |
| 6282 | if (LocaleCompare("colors",option+1) == 0) |
| 6283 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6284 | image_info->colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6285 | break; |
| 6286 | } |
| 6287 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6288 | { |
| 6289 | if (*option == '+') |
| 6290 | { |
| 6291 | image_info->colorspace=UndefinedColorspace; |
| 6292 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6293 | break; |
| 6294 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6295 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6296 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6297 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6298 | break; |
| 6299 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6300 | if (LocaleCompare("comment",option+1) == 0) |
| 6301 | { |
| 6302 | if (*option == '+') |
| 6303 | { |
| 6304 | (void) DeleteImageOption(image_info,option+1); |
| 6305 | break; |
| 6306 | } |
| 6307 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6308 | break; |
| 6309 | } |
| 6310 | if (LocaleCompare("compose",option+1) == 0) |
| 6311 | { |
| 6312 | if (*option == '+') |
| 6313 | { |
| 6314 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6315 | break; |
| 6316 | } |
| 6317 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6318 | break; |
| 6319 | } |
| 6320 | if (LocaleCompare("compress",option+1) == 0) |
| 6321 | { |
| 6322 | if (*option == '+') |
| 6323 | { |
| 6324 | image_info->compression=UndefinedCompression; |
| 6325 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6326 | break; |
| 6327 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6328 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6329 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6330 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6331 | break; |
| 6332 | } |
| 6333 | break; |
| 6334 | } |
| 6335 | case 'd': |
| 6336 | { |
| 6337 | if (LocaleCompare("debug",option+1) == 0) |
| 6338 | { |
| 6339 | if (*option == '+') |
| 6340 | (void) SetLogEventMask("none"); |
| 6341 | else |
| 6342 | (void) SetLogEventMask(argv[i+1]); |
| 6343 | image_info->debug=IsEventLogging(); |
| 6344 | break; |
| 6345 | } |
| 6346 | if (LocaleCompare("define",option+1) == 0) |
| 6347 | { |
| 6348 | if (*option == '+') |
| 6349 | { |
| 6350 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6351 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6352 | else |
| 6353 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6354 | break; |
| 6355 | } |
| 6356 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6357 | { |
| 6358 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6359 | exception); |
| 6360 | break; |
| 6361 | } |
| 6362 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6363 | break; |
| 6364 | } |
| 6365 | if (LocaleCompare("delay",option+1) == 0) |
| 6366 | { |
| 6367 | if (*option == '+') |
| 6368 | { |
| 6369 | (void) SetImageOption(image_info,option+1,"0"); |
| 6370 | break; |
| 6371 | } |
| 6372 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6373 | break; |
| 6374 | } |
| 6375 | if (LocaleCompare("density",option+1) == 0) |
| 6376 | { |
| 6377 | /* |
| 6378 | Set image density. |
| 6379 | */ |
| 6380 | if (*option == '+') |
| 6381 | { |
| 6382 | if (image_info->density != (char *) NULL) |
| 6383 | image_info->density=DestroyString(image_info->density); |
| 6384 | (void) SetImageOption(image_info,option+1,"72"); |
| 6385 | break; |
| 6386 | } |
| 6387 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6388 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6389 | break; |
| 6390 | } |
| 6391 | if (LocaleCompare("depth",option+1) == 0) |
| 6392 | { |
| 6393 | if (*option == '+') |
| 6394 | { |
| 6395 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6396 | break; |
| 6397 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6398 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6399 | break; |
| 6400 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6401 | if (LocaleCompare("direction",option+1) == 0) |
| 6402 | { |
| 6403 | if (*option == '+') |
| 6404 | { |
| 6405 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6406 | break; |
| 6407 | } |
| 6408 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6409 | break; |
| 6410 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6411 | if (LocaleCompare("display",option+1) == 0) |
| 6412 | { |
| 6413 | if (*option == '+') |
| 6414 | { |
| 6415 | if (image_info->server_name != (char *) NULL) |
| 6416 | image_info->server_name=DestroyString( |
| 6417 | image_info->server_name); |
| 6418 | break; |
| 6419 | } |
| 6420 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6421 | break; |
| 6422 | } |
| 6423 | if (LocaleCompare("dispose",option+1) == 0) |
| 6424 | { |
| 6425 | if (*option == '+') |
| 6426 | { |
| 6427 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6428 | break; |
| 6429 | } |
| 6430 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6431 | break; |
| 6432 | } |
| 6433 | if (LocaleCompare("dither",option+1) == 0) |
| 6434 | { |
| 6435 | if (*option == '+') |
| 6436 | { |
| 6437 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6438 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6439 | break; |
| 6440 | } |
| 6441 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6442 | image_info->dither=MagickTrue; |
| 6443 | break; |
| 6444 | } |
| 6445 | break; |
| 6446 | } |
| 6447 | case 'e': |
| 6448 | { |
| 6449 | if (LocaleCompare("encoding",option+1) == 0) |
| 6450 | { |
| 6451 | if (*option == '+') |
| 6452 | { |
| 6453 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6454 | break; |
| 6455 | } |
| 6456 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6457 | break; |
| 6458 | } |
| 6459 | if (LocaleCompare("endian",option+1) == 0) |
| 6460 | { |
| 6461 | if (*option == '+') |
| 6462 | { |
| 6463 | image_info->endian=UndefinedEndian; |
| 6464 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6465 | break; |
| 6466 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6467 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6468 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6469 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6470 | break; |
| 6471 | } |
| 6472 | if (LocaleCompare("extract",option+1) == 0) |
| 6473 | { |
| 6474 | /* |
| 6475 | Set image extract geometry. |
| 6476 | */ |
| 6477 | if (*option == '+') |
| 6478 | { |
| 6479 | if (image_info->extract != (char *) NULL) |
| 6480 | image_info->extract=DestroyString(image_info->extract); |
| 6481 | break; |
| 6482 | } |
| 6483 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6484 | break; |
| 6485 | } |
| 6486 | break; |
| 6487 | } |
| 6488 | case 'f': |
| 6489 | { |
| 6490 | if (LocaleCompare("fill",option+1) == 0) |
| 6491 | { |
| 6492 | if (*option == '+') |
| 6493 | { |
| 6494 | (void) SetImageOption(image_info,option+1,"none"); |
| 6495 | break; |
| 6496 | } |
| 6497 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6498 | break; |
| 6499 | } |
| 6500 | if (LocaleCompare("filter",option+1) == 0) |
| 6501 | { |
| 6502 | if (*option == '+') |
| 6503 | { |
| 6504 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6505 | break; |
| 6506 | } |
| 6507 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6508 | break; |
| 6509 | } |
| 6510 | if (LocaleCompare("font",option+1) == 0) |
| 6511 | { |
| 6512 | if (*option == '+') |
| 6513 | { |
| 6514 | if (image_info->font != (char *) NULL) |
| 6515 | image_info->font=DestroyString(image_info->font); |
| 6516 | break; |
| 6517 | } |
| 6518 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6519 | break; |
| 6520 | } |
| 6521 | if (LocaleCompare("format",option+1) == 0) |
| 6522 | { |
| 6523 | register const char |
| 6524 | *q; |
| 6525 | |
| 6526 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6527 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6528 | image_info->ping=MagickFalse; |
| 6529 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6530 | break; |
| 6531 | } |
| 6532 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6533 | { |
| 6534 | if (*option == '+') |
| 6535 | { |
| 6536 | image_info->fuzz=0.0; |
| 6537 | (void) SetImageOption(image_info,option+1,"0"); |
| 6538 | break; |
| 6539 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6540 | image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6541 | 1.0); |
| 6542 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6543 | break; |
| 6544 | } |
| 6545 | break; |
| 6546 | } |
| 6547 | case 'g': |
| 6548 | { |
| 6549 | if (LocaleCompare("gravity",option+1) == 0) |
| 6550 | { |
| 6551 | if (*option == '+') |
| 6552 | { |
| 6553 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6554 | break; |
| 6555 | } |
| 6556 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6557 | break; |
| 6558 | } |
| 6559 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6560 | { |
| 6561 | if (*option == '+') |
| 6562 | { |
| 6563 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6564 | break; |
| 6565 | } |
| 6566 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6567 | break; |
| 6568 | } |
| 6569 | break; |
| 6570 | } |
| 6571 | case 'i': |
| 6572 | { |
| 6573 | if (LocaleCompare("intent",option+1) == 0) |
| 6574 | { |
| 6575 | if (*option == '+') |
| 6576 | { |
| 6577 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6578 | break; |
| 6579 | } |
| 6580 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6581 | break; |
| 6582 | } |
| 6583 | if (LocaleCompare("interlace",option+1) == 0) |
| 6584 | { |
| 6585 | if (*option == '+') |
| 6586 | { |
| 6587 | image_info->interlace=UndefinedInterlace; |
| 6588 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6589 | break; |
| 6590 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6591 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6592 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6593 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6594 | break; |
| 6595 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6596 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6597 | { |
| 6598 | if (*option == '+') |
| 6599 | { |
| 6600 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6601 | break; |
| 6602 | } |
| 6603 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6604 | break; |
| 6605 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6606 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6607 | { |
| 6608 | if (*option == '+') |
| 6609 | { |
| 6610 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6611 | break; |
| 6612 | } |
| 6613 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6614 | break; |
| 6615 | } |
| 6616 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6617 | { |
| 6618 | if (*option == '+') |
| 6619 | { |
| 6620 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6621 | break; |
| 6622 | } |
| 6623 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6624 | break; |
| 6625 | } |
| 6626 | break; |
| 6627 | } |
| 6628 | case 'k': |
| 6629 | { |
| 6630 | if (LocaleCompare("kerning",option+1) == 0) |
| 6631 | { |
| 6632 | if (*option == '+') |
| 6633 | { |
| 6634 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6635 | break; |
| 6636 | } |
| 6637 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6638 | break; |
| 6639 | } |
| 6640 | break; |
| 6641 | } |
| 6642 | case 'l': |
| 6643 | { |
| 6644 | if (LocaleCompare("label",option+1) == 0) |
| 6645 | { |
| 6646 | if (*option == '+') |
| 6647 | { |
| 6648 | (void) DeleteImageOption(image_info,option+1); |
| 6649 | break; |
| 6650 | } |
| 6651 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6652 | break; |
| 6653 | } |
| 6654 | if (LocaleCompare("limit",option+1) == 0) |
| 6655 | { |
| 6656 | MagickSizeType |
| 6657 | limit; |
| 6658 | |
| 6659 | ResourceType |
| 6660 | type; |
| 6661 | |
| 6662 | if (*option == '+') |
| 6663 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6664 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6665 | MagickFalse,argv[i+1]); |
| 6666 | limit=MagickResourceInfinity; |
| 6667 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6668 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6669 | (void) SetMagickResourceLimit(type,limit); |
| 6670 | break; |
| 6671 | } |
| 6672 | if (LocaleCompare("list",option+1) == 0) |
| 6673 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6674 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6675 | list; |
| 6676 | |
| 6677 | /* |
| 6678 | Display configuration list. |
| 6679 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6680 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6681 | switch (list) |
| 6682 | { |
| 6683 | case MagickCoderOptions: |
| 6684 | { |
| 6685 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6686 | break; |
| 6687 | } |
| 6688 | case MagickColorOptions: |
| 6689 | { |
| 6690 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6691 | break; |
| 6692 | } |
| 6693 | case MagickConfigureOptions: |
| 6694 | { |
| 6695 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6696 | break; |
| 6697 | } |
| 6698 | case MagickDelegateOptions: |
| 6699 | { |
| 6700 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6701 | break; |
| 6702 | } |
| 6703 | case MagickFontOptions: |
| 6704 | { |
| 6705 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6706 | break; |
| 6707 | } |
| 6708 | case MagickFormatOptions: |
| 6709 | { |
| 6710 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6711 | break; |
| 6712 | } |
| 6713 | case MagickLocaleOptions: |
| 6714 | { |
| 6715 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6716 | break; |
| 6717 | } |
| 6718 | case MagickLogOptions: |
| 6719 | { |
| 6720 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6721 | break; |
| 6722 | } |
| 6723 | case MagickMagicOptions: |
| 6724 | { |
| 6725 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6726 | break; |
| 6727 | } |
| 6728 | case MagickMimeOptions: |
| 6729 | { |
| 6730 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6731 | break; |
| 6732 | } |
| 6733 | case MagickModuleOptions: |
| 6734 | { |
| 6735 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6736 | break; |
| 6737 | } |
| 6738 | case MagickPolicyOptions: |
| 6739 | { |
| 6740 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6741 | break; |
| 6742 | } |
| 6743 | case MagickResourceOptions: |
| 6744 | { |
| 6745 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6746 | break; |
| 6747 | } |
| 6748 | case MagickThresholdOptions: |
| 6749 | { |
| 6750 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6751 | break; |
| 6752 | } |
| 6753 | default: |
| 6754 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6755 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6756 | exception); |
| 6757 | break; |
| 6758 | } |
| 6759 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6760 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6761 | } |
| 6762 | if (LocaleCompare("log",option+1) == 0) |
| 6763 | { |
| 6764 | if (*option == '+') |
| 6765 | break; |
| 6766 | (void) SetLogFormat(argv[i+1]); |
| 6767 | break; |
| 6768 | } |
| 6769 | if (LocaleCompare("loop",option+1) == 0) |
| 6770 | { |
| 6771 | if (*option == '+') |
| 6772 | { |
| 6773 | (void) SetImageOption(image_info,option+1,"0"); |
| 6774 | break; |
| 6775 | } |
| 6776 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6777 | break; |
| 6778 | } |
| 6779 | break; |
| 6780 | } |
| 6781 | case 'm': |
| 6782 | { |
| 6783 | if (LocaleCompare("matte",option+1) == 0) |
| 6784 | { |
| 6785 | if (*option == '+') |
| 6786 | { |
| 6787 | (void) SetImageOption(image_info,option+1,"false"); |
| 6788 | break; |
| 6789 | } |
| 6790 | (void) SetImageOption(image_info,option+1,"true"); |
| 6791 | break; |
| 6792 | } |
| 6793 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6794 | { |
| 6795 | if (*option == '+') |
| 6796 | { |
| 6797 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6798 | (void) QueryColorDatabase(MatteColor,&image_info->matte_color, |
| 6799 | exception); |
| 6800 | break; |
| 6801 | } |
| 6802 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6803 | (void) QueryColorDatabase(argv[i+1],&image_info->matte_color, |
| 6804 | exception); |
| 6805 | break; |
| 6806 | } |
| 6807 | if (LocaleCompare("monitor",option+1) == 0) |
| 6808 | { |
| 6809 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6810 | (void *) NULL); |
| 6811 | break; |
| 6812 | } |
| 6813 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6814 | { |
| 6815 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6816 | break; |
| 6817 | } |
| 6818 | break; |
| 6819 | } |
| 6820 | case 'o': |
| 6821 | { |
| 6822 | if (LocaleCompare("orient",option+1) == 0) |
| 6823 | { |
| 6824 | if (*option == '+') |
| 6825 | { |
| 6826 | image_info->orientation=UndefinedOrientation; |
| 6827 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6828 | break; |
| 6829 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6830 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6831 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6832 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6833 | break; |
| 6834 | } |
| 6835 | } |
| 6836 | case 'p': |
| 6837 | { |
| 6838 | if (LocaleCompare("page",option+1) == 0) |
| 6839 | { |
| 6840 | char |
| 6841 | *canonical_page, |
| 6842 | page[MaxTextExtent]; |
| 6843 | |
| 6844 | const char |
| 6845 | *image_option; |
| 6846 | |
| 6847 | MagickStatusType |
| 6848 | flags; |
| 6849 | |
| 6850 | RectangleInfo |
| 6851 | geometry; |
| 6852 | |
| 6853 | if (*option == '+') |
| 6854 | { |
| 6855 | (void) DeleteImageOption(image_info,option+1); |
| 6856 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6857 | break; |
| 6858 | } |
| 6859 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6860 | image_option=GetImageOption(image_info,"page"); |
| 6861 | if (image_option != (const char *) NULL) |
| 6862 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6863 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6864 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6865 | canonical_page=DestroyString(canonical_page); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6866 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6867 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6868 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6869 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6870 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6871 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6872 | (void) SetImageOption(image_info,option+1,page); |
| 6873 | (void) CloneString(&image_info->page,page); |
| 6874 | break; |
| 6875 | } |
| 6876 | if (LocaleCompare("pen",option+1) == 0) |
| 6877 | { |
| 6878 | if (*option == '+') |
| 6879 | { |
| 6880 | (void) SetImageOption(image_info,option+1,"none"); |
| 6881 | break; |
| 6882 | } |
| 6883 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6884 | break; |
| 6885 | } |
| 6886 | if (LocaleCompare("ping",option+1) == 0) |
| 6887 | { |
| 6888 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6889 | break; |
| 6890 | } |
| 6891 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6892 | { |
| 6893 | if (*option == '+') |
| 6894 | geometry_info.rho=0.0; |
| 6895 | else |
| 6896 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6897 | image_info->pointsize=geometry_info.rho; |
| 6898 | break; |
| 6899 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6900 | if (LocaleCompare("precision",option+1) == 0) |
| 6901 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6902 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6903 | break; |
| 6904 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6905 | if (LocaleCompare("preview",option+1) == 0) |
| 6906 | { |
| 6907 | /* |
| 6908 | Preview image. |
| 6909 | */ |
| 6910 | if (*option == '+') |
| 6911 | { |
| 6912 | image_info->preview_type=UndefinedPreview; |
| 6913 | break; |
| 6914 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6915 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6916 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6917 | break; |
| 6918 | } |
| 6919 | break; |
| 6920 | } |
| 6921 | case 'q': |
| 6922 | { |
| 6923 | if (LocaleCompare("quality",option+1) == 0) |
| 6924 | { |
| 6925 | /* |
| 6926 | Set image compression quality. |
| 6927 | */ |
| 6928 | if (*option == '+') |
| 6929 | { |
| 6930 | image_info->quality=UndefinedCompressionQuality; |
| 6931 | (void) SetImageOption(image_info,option+1,"0"); |
| 6932 | break; |
| 6933 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6934 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6935 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6936 | break; |
| 6937 | } |
| 6938 | if (LocaleCompare("quiet",option+1) == 0) |
| 6939 | { |
| 6940 | static WarningHandler |
| 6941 | warning_handler = (WarningHandler) NULL; |
| 6942 | |
| 6943 | if (*option == '+') |
| 6944 | { |
| 6945 | /* |
| 6946 | Restore error or warning messages. |
| 6947 | */ |
| 6948 | warning_handler=SetWarningHandler(warning_handler); |
| 6949 | break; |
| 6950 | } |
| 6951 | /* |
| 6952 | Suppress error or warning messages. |
| 6953 | */ |
| 6954 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6955 | break; |
| 6956 | } |
| 6957 | break; |
| 6958 | } |
| 6959 | case 'r': |
| 6960 | { |
| 6961 | if (LocaleCompare("red-primary",option+1) == 0) |
| 6962 | { |
| 6963 | if (*option == '+') |
| 6964 | { |
| 6965 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6966 | break; |
| 6967 | } |
| 6968 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6969 | break; |
| 6970 | } |
| 6971 | break; |
| 6972 | } |
| 6973 | case 's': |
| 6974 | { |
| 6975 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 6976 | { |
| 6977 | /* |
| 6978 | Set image sampling factor. |
| 6979 | */ |
| 6980 | if (*option == '+') |
| 6981 | { |
| 6982 | if (image_info->sampling_factor != (char *) NULL) |
| 6983 | image_info->sampling_factor=DestroyString( |
| 6984 | image_info->sampling_factor); |
| 6985 | break; |
| 6986 | } |
| 6987 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 6988 | break; |
| 6989 | } |
| 6990 | if (LocaleCompare("scene",option+1) == 0) |
| 6991 | { |
| 6992 | /* |
| 6993 | Set image scene. |
| 6994 | */ |
| 6995 | if (*option == '+') |
| 6996 | { |
| 6997 | image_info->scene=0; |
| 6998 | (void) SetImageOption(image_info,option+1,"0"); |
| 6999 | break; |
| 7000 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7001 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7002 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7003 | break; |
| 7004 | } |
| 7005 | if (LocaleCompare("seed",option+1) == 0) |
| 7006 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7007 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7008 | seed; |
| 7009 | |
| 7010 | if (*option == '+') |
| 7011 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7012 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7013 | SeedPseudoRandomGenerator(seed); |
| 7014 | break; |
| 7015 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7016 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7017 | SeedPseudoRandomGenerator(seed); |
| 7018 | break; |
| 7019 | } |
| 7020 | if (LocaleCompare("size",option+1) == 0) |
| 7021 | { |
| 7022 | if (*option == '+') |
| 7023 | { |
| 7024 | if (image_info->size != (char *) NULL) |
| 7025 | image_info->size=DestroyString(image_info->size); |
| 7026 | break; |
| 7027 | } |
| 7028 | (void) CloneString(&image_info->size,argv[i+1]); |
| 7029 | break; |
| 7030 | } |
| 7031 | if (LocaleCompare("stroke",option+1) == 0) |
| 7032 | { |
| 7033 | if (*option == '+') |
| 7034 | { |
| 7035 | (void) SetImageOption(image_info,option+1,"none"); |
| 7036 | break; |
| 7037 | } |
| 7038 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7039 | break; |
| 7040 | } |
| 7041 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7042 | { |
| 7043 | if (*option == '+') |
| 7044 | { |
| 7045 | (void) SetImageOption(image_info,option+1,"0"); |
| 7046 | break; |
| 7047 | } |
| 7048 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7049 | break; |
| 7050 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7051 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7052 | { |
| 7053 | if (*option == '+') |
| 7054 | { |
| 7055 | image_info->synchronize=MagickFalse; |
| 7056 | break; |
| 7057 | } |
| 7058 | image_info->synchronize=MagickTrue; |
| 7059 | break; |
| 7060 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7061 | break; |
| 7062 | } |
| 7063 | case 't': |
| 7064 | { |
| 7065 | if (LocaleCompare("taint",option+1) == 0) |
| 7066 | { |
| 7067 | if (*option == '+') |
| 7068 | { |
| 7069 | (void) SetImageOption(image_info,option+1,"false"); |
| 7070 | break; |
| 7071 | } |
| 7072 | (void) SetImageOption(image_info,option+1,"true"); |
| 7073 | break; |
| 7074 | } |
| 7075 | if (LocaleCompare("texture",option+1) == 0) |
| 7076 | { |
| 7077 | if (*option == '+') |
| 7078 | { |
| 7079 | if (image_info->texture != (char *) NULL) |
| 7080 | image_info->texture=DestroyString(image_info->texture); |
| 7081 | break; |
| 7082 | } |
| 7083 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7084 | break; |
| 7085 | } |
| 7086 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7087 | { |
| 7088 | if (*option == '+') |
| 7089 | { |
| 7090 | (void) SetImageOption(image_info,option+1,"0"); |
| 7091 | break; |
| 7092 | } |
| 7093 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7094 | break; |
| 7095 | } |
| 7096 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7097 | { |
| 7098 | if (*option == '+') |
| 7099 | { |
| 7100 | (void) QueryColorDatabase("none",&image_info->transparent_color, exception); |
| 7101 | (void) SetImageOption(image_info,option+1,"none"); |
| 7102 | break; |
| 7103 | } |
| 7104 | (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color, |
| 7105 | exception); |
| 7106 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7107 | break; |
| 7108 | } |
| 7109 | if (LocaleCompare("type",option+1) == 0) |
| 7110 | { |
| 7111 | if (*option == '+') |
| 7112 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7113 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7114 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7115 | break; |
| 7116 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7117 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7118 | MagickFalse,argv[i+1]); |
| 7119 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7120 | break; |
| 7121 | } |
| 7122 | break; |
| 7123 | } |
| 7124 | case 'u': |
| 7125 | { |
| 7126 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7127 | { |
| 7128 | if (*option == '+') |
| 7129 | { |
| 7130 | (void) DeleteImageOption(image_info,option+1); |
| 7131 | break; |
| 7132 | } |
| 7133 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7134 | break; |
| 7135 | } |
| 7136 | if (LocaleCompare("units",option+1) == 0) |
| 7137 | { |
| 7138 | if (*option == '+') |
| 7139 | { |
| 7140 | image_info->units=UndefinedResolution; |
| 7141 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7142 | break; |
| 7143 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7144 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7145 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7146 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7147 | break; |
| 7148 | } |
| 7149 | break; |
| 7150 | } |
| 7151 | case 'v': |
| 7152 | { |
| 7153 | if (LocaleCompare("verbose",option+1) == 0) |
| 7154 | { |
| 7155 | if (*option == '+') |
| 7156 | { |
| 7157 | image_info->verbose=MagickFalse; |
| 7158 | break; |
| 7159 | } |
| 7160 | image_info->verbose=MagickTrue; |
| 7161 | image_info->ping=MagickFalse; |
| 7162 | break; |
| 7163 | } |
| 7164 | if (LocaleCompare("view",option+1) == 0) |
| 7165 | { |
| 7166 | if (*option == '+') |
| 7167 | { |
| 7168 | if (image_info->view != (char *) NULL) |
| 7169 | image_info->view=DestroyString(image_info->view); |
| 7170 | break; |
| 7171 | } |
| 7172 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7173 | break; |
| 7174 | } |
| 7175 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7176 | { |
| 7177 | if (*option == '+') |
| 7178 | { |
| 7179 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7180 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7181 | break; |
| 7182 | } |
| 7183 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7184 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7185 | argv[i+1]); |
| 7186 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7187 | break; |
| 7188 | } |
| 7189 | break; |
| 7190 | } |
| 7191 | case 'w': |
| 7192 | { |
| 7193 | if (LocaleCompare("white-point",option+1) == 0) |
| 7194 | { |
| 7195 | if (*option == '+') |
| 7196 | { |
| 7197 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7198 | break; |
| 7199 | } |
| 7200 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7201 | break; |
| 7202 | } |
| 7203 | break; |
| 7204 | } |
| 7205 | default: |
| 7206 | break; |
| 7207 | } |
| 7208 | i+=count; |
| 7209 | } |
| 7210 | return(MagickTrue); |
| 7211 | } |
| 7212 | |
| 7213 | /* |
| 7214 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7215 | % % |
| 7216 | % % |
| 7217 | % % |
| 7218 | + M o g r i f y I m a g e L i s t % |
| 7219 | % % |
| 7220 | % % |
| 7221 | % % |
| 7222 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7223 | % |
| 7224 | % MogrifyImageList() applies any command line options that might affect the |
| 7225 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7226 | % |
| 7227 | % The format of the MogrifyImage method is: |
| 7228 | % |
| 7229 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7230 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7231 | % |
| 7232 | % A description of each parameter follows: |
| 7233 | % |
| 7234 | % o image_info: the image info.. |
| 7235 | % |
| 7236 | % o argc: Specifies a pointer to an integer describing the number of |
| 7237 | % elements in the argument vector. |
| 7238 | % |
| 7239 | % o argv: Specifies a pointer to a text array containing the command line |
| 7240 | % arguments. |
| 7241 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7242 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7243 | % |
| 7244 | % o exception: return any errors or warnings in this structure. |
| 7245 | % |
| 7246 | */ |
| 7247 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7248 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7249 | { |
| 7250 | ChannelType |
| 7251 | channel; |
| 7252 | |
| 7253 | const char |
| 7254 | *option; |
| 7255 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7256 | ImageInfo |
| 7257 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7258 | |
| 7259 | MagickStatusType |
| 7260 | status; |
| 7261 | |
| 7262 | QuantizeInfo |
| 7263 | *quantize_info; |
| 7264 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7265 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7266 | i; |
| 7267 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7268 | ssize_t |
| 7269 | count, |
| 7270 | index; |
| 7271 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7272 | /* |
| 7273 | Apply options to the image list. |
| 7274 | */ |
| 7275 | assert(image_info != (ImageInfo *) NULL); |
| 7276 | assert(image_info->signature == MagickSignature); |
| 7277 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7278 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7279 | assert((*images)->signature == MagickSignature); |
| 7280 | if ((*images)->debug != MagickFalse) |
| 7281 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7282 | (*images)->filename); |
| 7283 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7284 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7285 | mogrify_info=CloneImageInfo(image_info); |
| 7286 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 7287 | channel=mogrify_info->channel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7288 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7289 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7290 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7291 | if (*images == (Image *) NULL) |
| 7292 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7293 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7294 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7295 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7296 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7297 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7298 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7299 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7300 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7301 | switch (*(option+1)) |
| 7302 | { |
| 7303 | case 'a': |
| 7304 | { |
| 7305 | if (LocaleCompare("affinity",option+1) == 0) |
| 7306 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7307 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7308 | if (*option == '+') |
| 7309 | { |
| 7310 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7311 | InheritException(exception,&(*images)->exception); |
| 7312 | break; |
| 7313 | } |
| 7314 | i++; |
| 7315 | break; |
| 7316 | } |
| 7317 | if (LocaleCompare("append",option+1) == 0) |
| 7318 | { |
| 7319 | Image |
| 7320 | *append_image; |
| 7321 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7322 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7323 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7324 | MagickFalse,exception); |
| 7325 | if (append_image == (Image *) NULL) |
| 7326 | { |
| 7327 | status=MagickFalse; |
| 7328 | break; |
| 7329 | } |
| 7330 | *images=DestroyImageList(*images); |
| 7331 | *images=append_image; |
| 7332 | break; |
| 7333 | } |
| 7334 | if (LocaleCompare("average",option+1) == 0) |
| 7335 | { |
| 7336 | Image |
| 7337 | *average_image; |
| 7338 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7339 | /* |
| 7340 | Average an image sequence (deprecated). |
| 7341 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7342 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7343 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7344 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7345 | if (average_image == (Image *) NULL) |
| 7346 | { |
| 7347 | status=MagickFalse; |
| 7348 | break; |
| 7349 | } |
| 7350 | *images=DestroyImageList(*images); |
| 7351 | *images=average_image; |
| 7352 | break; |
| 7353 | } |
| 7354 | break; |
| 7355 | } |
| 7356 | case 'c': |
| 7357 | { |
| 7358 | if (LocaleCompare("channel",option+1) == 0) |
| 7359 | { |
| 7360 | if (*option == '+') |
| 7361 | { |
| 7362 | channel=DefaultChannels; |
| 7363 | break; |
| 7364 | } |
| 7365 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 7366 | break; |
| 7367 | } |
| 7368 | if (LocaleCompare("clut",option+1) == 0) |
| 7369 | { |
| 7370 | Image |
| 7371 | *clut_image, |
| 7372 | *image; |
| 7373 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7374 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7375 | image=RemoveFirstImageFromList(images); |
| 7376 | clut_image=RemoveFirstImageFromList(images); |
| 7377 | if (clut_image == (Image *) NULL) |
| 7378 | { |
| 7379 | status=MagickFalse; |
| 7380 | break; |
| 7381 | } |
| 7382 | (void) ClutImageChannel(image,channel,clut_image); |
| 7383 | clut_image=DestroyImage(clut_image); |
| 7384 | InheritException(exception,&image->exception); |
| 7385 | *images=DestroyImageList(*images); |
| 7386 | *images=image; |
| 7387 | break; |
| 7388 | } |
| 7389 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7390 | { |
| 7391 | Image |
| 7392 | *coalesce_image; |
| 7393 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7394 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7395 | coalesce_image=CoalesceImages(*images,exception); |
| 7396 | if (coalesce_image == (Image *) NULL) |
| 7397 | { |
| 7398 | status=MagickFalse; |
| 7399 | break; |
| 7400 | } |
| 7401 | *images=DestroyImageList(*images); |
| 7402 | *images=coalesce_image; |
| 7403 | break; |
| 7404 | } |
| 7405 | if (LocaleCompare("combine",option+1) == 0) |
| 7406 | { |
| 7407 | Image |
| 7408 | *combine_image; |
| 7409 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7410 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7411 | combine_image=CombineImages(*images,channel,exception); |
| 7412 | if (combine_image == (Image *) NULL) |
| 7413 | { |
| 7414 | status=MagickFalse; |
| 7415 | break; |
| 7416 | } |
| 7417 | *images=DestroyImageList(*images); |
| 7418 | *images=combine_image; |
| 7419 | break; |
| 7420 | } |
| 7421 | if (LocaleCompare("composite",option+1) == 0) |
| 7422 | { |
| 7423 | Image |
| 7424 | *mask_image, |
| 7425 | *composite_image, |
| 7426 | *image; |
| 7427 | |
| 7428 | RectangleInfo |
| 7429 | geometry; |
| 7430 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7431 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7432 | image=RemoveFirstImageFromList(images); |
| 7433 | composite_image=RemoveFirstImageFromList(images); |
| 7434 | if (composite_image == (Image *) NULL) |
| 7435 | { |
| 7436 | status=MagickFalse; |
| 7437 | break; |
| 7438 | } |
| 7439 | (void) TransformImage(&composite_image,(char *) NULL, |
| 7440 | composite_image->geometry); |
| 7441 | SetGeometry(composite_image,&geometry); |
| 7442 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7443 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7444 | &geometry); |
| 7445 | mask_image=RemoveFirstImageFromList(images); |
| 7446 | if (mask_image != (Image *) NULL) |
| 7447 | { |
| 7448 | if ((image->compose == DisplaceCompositeOp) || |
| 7449 | (image->compose == DistortCompositeOp)) |
| 7450 | { |
| 7451 | /* |
| 7452 | Merge Y displacement into X displacement image. |
| 7453 | */ |
| 7454 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
| 7455 | mask_image,0,0); |
| 7456 | mask_image=DestroyImage(mask_image); |
| 7457 | } |
| 7458 | else |
| 7459 | { |
| 7460 | /* |
| 7461 | Set a blending mask for the composition. |
| 7462 | */ |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7463 | /* POSIBLE ERROR; what if image->mask already set */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7464 | image->mask=mask_image; |
| 7465 | (void) NegateImage(image->mask,MagickFalse); |
| 7466 | } |
| 7467 | } |
| 7468 | (void) CompositeImageChannel(image,channel,image->compose, |
| 7469 | composite_image,geometry.x,geometry.y); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7470 | if (mask_image != (Image *) NULL) |
| 7471 | mask_image=image->mask=DestroyImage(image->mask); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7472 | composite_image=DestroyImage(composite_image); |
| 7473 | InheritException(exception,&image->exception); |
| 7474 | *images=DestroyImageList(*images); |
| 7475 | *images=image; |
| 7476 | break; |
| 7477 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7478 | #if 0 |
| 7479 | This has been merged completely into MogrifyImage() |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7480 | if (LocaleCompare("crop",option+1) == 0) |
| 7481 | { |
| 7482 | MagickStatusType |
| 7483 | flags; |
| 7484 | |
| 7485 | RectangleInfo |
| 7486 | geometry; |
| 7487 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7488 | /* |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7489 | Crop Image. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7490 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7491 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7492 | flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception); |
| 7493 | if (((geometry.width == 0) && (geometry.height == 0)) || |
| 7494 | ((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 7495 | break; |
| 7496 | (void) TransformImages(images,argv[i+1],(char *) NULL); |
| 7497 | InheritException(exception,&(*images)->exception); |
| 7498 | break; |
| 7499 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7500 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7501 | break; |
| 7502 | } |
| 7503 | case 'd': |
| 7504 | { |
| 7505 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7506 | { |
| 7507 | Image |
| 7508 | *deconstruct_image; |
| 7509 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7510 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7511 | deconstruct_image=DeconstructImages(*images,exception); |
| 7512 | if (deconstruct_image == (Image *) NULL) |
| 7513 | { |
| 7514 | status=MagickFalse; |
| 7515 | break; |
| 7516 | } |
| 7517 | *images=DestroyImageList(*images); |
| 7518 | *images=deconstruct_image; |
| 7519 | break; |
| 7520 | } |
| 7521 | if (LocaleCompare("delete",option+1) == 0) |
| 7522 | { |
| 7523 | if (*option == '+') |
| 7524 | DeleteImages(images,"-1",exception); |
| 7525 | else |
| 7526 | DeleteImages(images,argv[i+1],exception); |
| 7527 | break; |
| 7528 | } |
| 7529 | if (LocaleCompare("dither",option+1) == 0) |
| 7530 | { |
| 7531 | if (*option == '+') |
| 7532 | { |
| 7533 | quantize_info->dither=MagickFalse; |
| 7534 | break; |
| 7535 | } |
| 7536 | quantize_info->dither=MagickTrue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7537 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7538 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7539 | break; |
| 7540 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7541 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7542 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7543 | Image |
| 7544 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7545 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7546 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7547 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7548 | else |
| 7549 | { |
| 7550 | const char |
| 7551 | *p; |
| 7552 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7553 | size_t |
| 7554 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7555 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7556 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7557 | p=strchr(argv[i+1],','); |
| 7558 | if (p == (const char *) NULL) |
| 7559 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7560 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7561 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7562 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7563 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7564 | } |
| 7565 | AppendImageToList(images, duplicate_images); |
| 7566 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7567 | break; |
| 7568 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7569 | break; |
| 7570 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7571 | case 'e': |
| 7572 | { |
| 7573 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7574 | { |
| 7575 | Image |
| 7576 | *evaluate_image; |
| 7577 | |
| 7578 | MagickEvaluateOperator |
| 7579 | op; |
| 7580 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7581 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7582 | op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions, |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7583 | MagickFalse,argv[i+1]); |
| 7584 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7585 | if (evaluate_image == (Image *) NULL) |
| 7586 | { |
| 7587 | status=MagickFalse; |
| 7588 | break; |
| 7589 | } |
| 7590 | *images=DestroyImageList(*images); |
| 7591 | *images=evaluate_image; |
| 7592 | break; |
| 7593 | } |
| 7594 | break; |
| 7595 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7596 | case 'f': |
| 7597 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7598 | if (LocaleCompare("fft",option+1) == 0) |
| 7599 | { |
| 7600 | Image |
| 7601 | *fourier_image; |
| 7602 | |
| 7603 | /* |
| 7604 | Implements the discrete Fourier transform (DFT). |
| 7605 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7606 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7607 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7608 | MagickTrue : MagickFalse,exception); |
| 7609 | if (fourier_image == (Image *) NULL) |
| 7610 | break; |
| 7611 | *images=DestroyImage(*images); |
| 7612 | *images=fourier_image; |
| 7613 | break; |
| 7614 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7615 | if (LocaleCompare("flatten",option+1) == 0) |
| 7616 | { |
| 7617 | Image |
| 7618 | *flatten_image; |
| 7619 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7620 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7621 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7622 | if (flatten_image == (Image *) NULL) |
| 7623 | break; |
| 7624 | *images=DestroyImageList(*images); |
| 7625 | *images=flatten_image; |
| 7626 | break; |
| 7627 | } |
| 7628 | if (LocaleCompare("fx",option+1) == 0) |
| 7629 | { |
| 7630 | Image |
| 7631 | *fx_image; |
| 7632 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7633 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7634 | fx_image=FxImageChannel(*images,channel,argv[i+1],exception); |
| 7635 | if (fx_image == (Image *) NULL) |
| 7636 | { |
| 7637 | status=MagickFalse; |
| 7638 | break; |
| 7639 | } |
| 7640 | *images=DestroyImageList(*images); |
| 7641 | *images=fx_image; |
| 7642 | break; |
| 7643 | } |
| 7644 | break; |
| 7645 | } |
| 7646 | case 'h': |
| 7647 | { |
| 7648 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7649 | { |
| 7650 | Image |
| 7651 | *hald_image, |
| 7652 | *image; |
| 7653 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7654 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7655 | image=RemoveFirstImageFromList(images); |
| 7656 | hald_image=RemoveFirstImageFromList(images); |
| 7657 | if (hald_image == (Image *) NULL) |
| 7658 | { |
| 7659 | status=MagickFalse; |
| 7660 | break; |
| 7661 | } |
| 7662 | (void) HaldClutImageChannel(image,channel,hald_image); |
| 7663 | hald_image=DestroyImage(hald_image); |
| 7664 | InheritException(exception,&image->exception); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7665 | if (*images != (Image *) NULL) |
| 7666 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7667 | *images=image; |
| 7668 | break; |
| 7669 | } |
| 7670 | break; |
| 7671 | } |
| 7672 | case 'i': |
| 7673 | { |
| 7674 | if (LocaleCompare("ift",option+1) == 0) |
| 7675 | { |
| 7676 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7677 | *fourier_image, |
| 7678 | *magnitude_image, |
| 7679 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7680 | |
| 7681 | /* |
| 7682 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7683 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7684 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7685 | magnitude_image=RemoveFirstImageFromList(images); |
| 7686 | phase_image=RemoveFirstImageFromList(images); |
| 7687 | if (phase_image == (Image *) NULL) |
| 7688 | { |
| 7689 | status=MagickFalse; |
| 7690 | break; |
| 7691 | } |
| 7692 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7693 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7694 | if (fourier_image == (Image *) NULL) |
| 7695 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7696 | if (*images != (Image *) NULL) |
| 7697 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7698 | *images=fourier_image; |
| 7699 | break; |
| 7700 | } |
| 7701 | if (LocaleCompare("insert",option+1) == 0) |
| 7702 | { |
| 7703 | Image |
| 7704 | *p, |
| 7705 | *q; |
| 7706 | |
| 7707 | index=0; |
| 7708 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7709 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7710 | p=RemoveLastImageFromList(images); |
| 7711 | if (p == (Image *) NULL) |
| 7712 | { |
| 7713 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7714 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7715 | status=MagickFalse; |
| 7716 | break; |
| 7717 | } |
| 7718 | q=p; |
| 7719 | if (index == 0) |
| 7720 | PrependImageToList(images,q); |
| 7721 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7722 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7723 | AppendImageToList(images,q); |
| 7724 | else |
| 7725 | { |
| 7726 | q=GetImageFromList(*images,index-1); |
| 7727 | if (q == (Image *) NULL) |
| 7728 | { |
| 7729 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7730 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7731 | status=MagickFalse; |
| 7732 | break; |
| 7733 | } |
| 7734 | InsertImageInList(&q,p); |
| 7735 | } |
| 7736 | *images=GetFirstImageInList(q); |
| 7737 | break; |
| 7738 | } |
| 7739 | break; |
| 7740 | } |
| 7741 | case 'l': |
| 7742 | { |
| 7743 | if (LocaleCompare("layers",option+1) == 0) |
| 7744 | { |
| 7745 | Image |
| 7746 | *layers; |
| 7747 | |
| 7748 | ImageLayerMethod |
| 7749 | method; |
| 7750 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7751 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7752 | layers=(Image *) NULL; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7753 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7754 | MagickFalse,argv[i+1]); |
| 7755 | switch (method) |
| 7756 | { |
| 7757 | case CoalesceLayer: |
| 7758 | { |
| 7759 | layers=CoalesceImages(*images,exception); |
| 7760 | break; |
| 7761 | } |
| 7762 | case CompareAnyLayer: |
| 7763 | case CompareClearLayer: |
| 7764 | case CompareOverlayLayer: |
| 7765 | default: |
| 7766 | { |
| 7767 | layers=CompareImageLayers(*images,method,exception); |
| 7768 | break; |
| 7769 | } |
| 7770 | case MergeLayer: |
| 7771 | case FlattenLayer: |
| 7772 | case MosaicLayer: |
| 7773 | case TrimBoundsLayer: |
| 7774 | { |
| 7775 | layers=MergeImageLayers(*images,method,exception); |
| 7776 | break; |
| 7777 | } |
| 7778 | case DisposeLayer: |
| 7779 | { |
| 7780 | layers=DisposeImages(*images,exception); |
| 7781 | break; |
| 7782 | } |
| 7783 | case OptimizeImageLayer: |
| 7784 | { |
| 7785 | layers=OptimizeImageLayers(*images,exception); |
| 7786 | break; |
| 7787 | } |
| 7788 | case OptimizePlusLayer: |
| 7789 | { |
| 7790 | layers=OptimizePlusImageLayers(*images,exception); |
| 7791 | break; |
| 7792 | } |
| 7793 | case OptimizeTransLayer: |
| 7794 | { |
| 7795 | OptimizeImageTransparency(*images,exception); |
| 7796 | break; |
| 7797 | } |
| 7798 | case RemoveDupsLayer: |
| 7799 | { |
| 7800 | RemoveDuplicateLayers(images,exception); |
| 7801 | break; |
| 7802 | } |
| 7803 | case RemoveZeroLayer: |
| 7804 | { |
| 7805 | RemoveZeroDelayLayers(images,exception); |
| 7806 | break; |
| 7807 | } |
| 7808 | case OptimizeLayer: |
| 7809 | { |
| 7810 | /* |
| 7811 | General Purpose, GIF Animation Optimizer. |
| 7812 | */ |
| 7813 | layers=CoalesceImages(*images,exception); |
| 7814 | if (layers == (Image *) NULL) |
| 7815 | { |
| 7816 | status=MagickFalse; |
| 7817 | break; |
| 7818 | } |
| 7819 | InheritException(exception,&layers->exception); |
| 7820 | *images=DestroyImageList(*images); |
| 7821 | *images=layers; |
| 7822 | layers=OptimizeImageLayers(*images,exception); |
| 7823 | if (layers == (Image *) NULL) |
| 7824 | { |
| 7825 | status=MagickFalse; |
| 7826 | break; |
| 7827 | } |
| 7828 | InheritException(exception,&layers->exception); |
| 7829 | *images=DestroyImageList(*images); |
| 7830 | *images=layers; |
| 7831 | layers=(Image *) NULL; |
| 7832 | OptimizeImageTransparency(*images,exception); |
| 7833 | InheritException(exception,&(*images)->exception); |
| 7834 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7835 | break; |
| 7836 | } |
| 7837 | case CompositeLayer: |
| 7838 | { |
| 7839 | CompositeOperator |
| 7840 | compose; |
| 7841 | |
| 7842 | Image |
| 7843 | *source; |
| 7844 | |
| 7845 | RectangleInfo |
| 7846 | geometry; |
| 7847 | |
| 7848 | /* |
| 7849 | Split image sequence at the first 'NULL:' image. |
| 7850 | */ |
| 7851 | source=(*images); |
| 7852 | while (source != (Image *) NULL) |
| 7853 | { |
| 7854 | source=GetNextImageInList(source); |
| 7855 | if ((source != (Image *) NULL) && |
| 7856 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7857 | break; |
| 7858 | } |
| 7859 | if (source != (Image *) NULL) |
| 7860 | { |
| 7861 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7862 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7863 | source=(Image *) NULL; |
| 7864 | else |
| 7865 | { |
| 7866 | /* |
| 7867 | Separate the two lists, junk the null: image. |
| 7868 | */ |
| 7869 | source=SplitImageList(source->previous); |
| 7870 | DeleteImageFromList(&source); |
| 7871 | } |
| 7872 | } |
| 7873 | if (source == (Image *) NULL) |
| 7874 | { |
| 7875 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7876 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7877 | status=MagickFalse; |
| 7878 | break; |
| 7879 | } |
| 7880 | /* |
| 7881 | Adjust offset with gravity and virtual canvas. |
| 7882 | */ |
| 7883 | SetGeometry(*images,&geometry); |
| 7884 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7885 | geometry.width=source->page.width != 0 ? |
| 7886 | source->page.width : source->columns; |
| 7887 | geometry.height=source->page.height != 0 ? |
| 7888 | source->page.height : source->rows; |
| 7889 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7890 | (*images)->page.width : (*images)->columns, |
| 7891 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7892 | (*images)->rows,(*images)->gravity,&geometry); |
| 7893 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7894 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7895 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7896 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7897 | MagickComposeOptions,MagickFalse,option); |
| 7898 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7899 | exception); |
| 7900 | source=DestroyImageList(source); |
| 7901 | break; |
| 7902 | } |
| 7903 | } |
| 7904 | if (layers == (Image *) NULL) |
| 7905 | break; |
| 7906 | InheritException(exception,&layers->exception); |
| 7907 | *images=DestroyImageList(*images); |
| 7908 | *images=layers; |
| 7909 | break; |
| 7910 | } |
| 7911 | break; |
| 7912 | } |
| 7913 | case 'm': |
| 7914 | { |
| 7915 | if (LocaleCompare("map",option+1) == 0) |
| 7916 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7917 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7918 | if (*option == '+') |
| 7919 | { |
| 7920 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7921 | InheritException(exception,&(*images)->exception); |
| 7922 | break; |
| 7923 | } |
| 7924 | i++; |
| 7925 | break; |
| 7926 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7927 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7928 | { |
| 7929 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7930 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7931 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7932 | /* |
| 7933 | Maximum image sequence (deprecated). |
| 7934 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7935 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7936 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7937 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7938 | { |
| 7939 | status=MagickFalse; |
| 7940 | break; |
| 7941 | } |
| 7942 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7943 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7944 | break; |
| 7945 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7946 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7947 | { |
| 7948 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7949 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7950 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7951 | /* |
| 7952 | Minimum image sequence (deprecated). |
| 7953 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7954 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7955 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7956 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7957 | { |
| 7958 | status=MagickFalse; |
| 7959 | break; |
| 7960 | } |
| 7961 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7962 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7963 | break; |
| 7964 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7965 | if (LocaleCompare("morph",option+1) == 0) |
| 7966 | { |
| 7967 | Image |
| 7968 | *morph_image; |
| 7969 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7970 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7971 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7972 | exception); |
| 7973 | if (morph_image == (Image *) NULL) |
| 7974 | { |
| 7975 | status=MagickFalse; |
| 7976 | break; |
| 7977 | } |
| 7978 | *images=DestroyImageList(*images); |
| 7979 | *images=morph_image; |
| 7980 | break; |
| 7981 | } |
| 7982 | if (LocaleCompare("mosaic",option+1) == 0) |
| 7983 | { |
| 7984 | Image |
| 7985 | *mosaic_image; |
| 7986 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7987 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7988 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 7989 | if (mosaic_image == (Image *) NULL) |
| 7990 | { |
| 7991 | status=MagickFalse; |
| 7992 | break; |
| 7993 | } |
| 7994 | *images=DestroyImageList(*images); |
| 7995 | *images=mosaic_image; |
| 7996 | break; |
| 7997 | } |
| 7998 | break; |
| 7999 | } |
| 8000 | case 'p': |
| 8001 | { |
| 8002 | if (LocaleCompare("print",option+1) == 0) |
| 8003 | { |
| 8004 | char |
| 8005 | *string; |
| 8006 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8007 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8008 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8009 | if (string == (char *) NULL) |
| 8010 | break; |
| 8011 | InheritException(exception,&(*images)->exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8012 | (void) FormatLocaleFile(stdout,"%s",string); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8013 | string=DestroyString(string); |
| 8014 | } |
| 8015 | if (LocaleCompare("process",option+1) == 0) |
| 8016 | { |
| 8017 | char |
| 8018 | **arguments; |
| 8019 | |
| 8020 | int |
| 8021 | j, |
| 8022 | number_arguments; |
| 8023 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8024 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8025 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 8026 | if (arguments == (char **) NULL) |
| 8027 | break; |
| 8028 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 8029 | { |
| 8030 | char |
| 8031 | breaker, |
| 8032 | quote, |
| 8033 | *token; |
| 8034 | |
| 8035 | const char |
| 8036 | *arguments; |
| 8037 | |
| 8038 | int |
| 8039 | next, |
| 8040 | status; |
| 8041 | |
| 8042 | size_t |
| 8043 | length; |
| 8044 | |
| 8045 | TokenInfo |
| 8046 | *token_info; |
| 8047 | |
| 8048 | /* |
| 8049 | Support old style syntax, filter="-option arg". |
| 8050 | */ |
| 8051 | length=strlen(argv[i+1]); |
| 8052 | token=(char *) NULL; |
cristy | 37e0b38 | 2011-06-07 13:31:21 +0000 | [diff] [blame] | 8053 | if (~length >= (MaxTextExtent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8054 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8055 | sizeof(*token)); |
| 8056 | if (token == (char *) NULL) |
| 8057 | break; |
| 8058 | next=0; |
| 8059 | arguments=argv[i+1]; |
| 8060 | token_info=AcquireTokenInfo(); |
| 8061 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8062 | "\"",'\0',&breaker,&next,"e); |
| 8063 | token_info=DestroyTokenInfo(token_info); |
| 8064 | if (status == 0) |
| 8065 | { |
| 8066 | const char |
| 8067 | *argv; |
| 8068 | |
| 8069 | argv=(&(arguments[next])); |
| 8070 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8071 | exception); |
| 8072 | } |
| 8073 | token=DestroyString(token); |
| 8074 | break; |
| 8075 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8076 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8077 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8078 | number_arguments-2,(const char **) arguments+2,exception); |
| 8079 | for (j=0; j < number_arguments; j++) |
| 8080 | arguments[j]=DestroyString(arguments[j]); |
| 8081 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8082 | break; |
| 8083 | } |
| 8084 | break; |
| 8085 | } |
| 8086 | case 'r': |
| 8087 | { |
| 8088 | if (LocaleCompare("reverse",option+1) == 0) |
| 8089 | { |
| 8090 | ReverseImageList(images); |
| 8091 | InheritException(exception,&(*images)->exception); |
| 8092 | break; |
| 8093 | } |
| 8094 | break; |
| 8095 | } |
| 8096 | case 's': |
| 8097 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8098 | if (LocaleCompare("smush",option+1) == 0) |
| 8099 | { |
| 8100 | Image |
| 8101 | *smush_image; |
| 8102 | |
| 8103 | ssize_t |
| 8104 | offset; |
| 8105 | |
| 8106 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8107 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8108 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8109 | MagickFalse,offset,exception); |
| 8110 | if (smush_image == (Image *) NULL) |
| 8111 | { |
| 8112 | status=MagickFalse; |
| 8113 | break; |
| 8114 | } |
| 8115 | *images=DestroyImageList(*images); |
| 8116 | *images=smush_image; |
| 8117 | break; |
| 8118 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8119 | if (LocaleCompare("swap",option+1) == 0) |
| 8120 | { |
| 8121 | Image |
| 8122 | *p, |
| 8123 | *q, |
| 8124 | *swap; |
| 8125 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8126 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8127 | swap_index; |
| 8128 | |
| 8129 | index=(-1); |
| 8130 | swap_index=(-2); |
| 8131 | if (*option != '+') |
| 8132 | { |
| 8133 | GeometryInfo |
| 8134 | geometry_info; |
| 8135 | |
| 8136 | MagickStatusType |
| 8137 | flags; |
| 8138 | |
| 8139 | swap_index=(-1); |
| 8140 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8141 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8142 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8143 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8144 | } |
| 8145 | p=GetImageFromList(*images,index); |
| 8146 | q=GetImageFromList(*images,swap_index); |
| 8147 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8148 | { |
| 8149 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8150 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8151 | status=MagickFalse; |
| 8152 | break; |
| 8153 | } |
| 8154 | if (p == q) |
| 8155 | break; |
| 8156 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8157 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8158 | ReplaceImageInList(&q,swap); |
| 8159 | *images=GetFirstImageInList(q); |
| 8160 | break; |
| 8161 | } |
| 8162 | break; |
| 8163 | } |
| 8164 | case 'w': |
| 8165 | { |
| 8166 | if (LocaleCompare("write",option+1) == 0) |
| 8167 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8168 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8169 | key[MaxTextExtent]; |
| 8170 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8171 | Image |
| 8172 | *write_images; |
| 8173 | |
| 8174 | ImageInfo |
| 8175 | *write_info; |
| 8176 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8177 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8178 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8179 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8180 | write_images=(*images); |
| 8181 | if (*option == '+') |
| 8182 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8183 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8184 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8185 | write_info=DestroyImageInfo(write_info); |
| 8186 | if (*option == '+') |
| 8187 | write_images=DestroyImageList(write_images); |
| 8188 | break; |
| 8189 | } |
| 8190 | break; |
| 8191 | } |
| 8192 | default: |
| 8193 | break; |
| 8194 | } |
| 8195 | i+=count; |
| 8196 | } |
| 8197 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8198 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8199 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8200 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8201 | } |
| 8202 | |
| 8203 | /* |
| 8204 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8205 | % % |
| 8206 | % % |
| 8207 | % % |
| 8208 | + M o g r i f y I m a g e s % |
| 8209 | % % |
| 8210 | % % |
| 8211 | % % |
| 8212 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8213 | % |
| 8214 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8215 | % prescribed by command line options. |
| 8216 | % |
| 8217 | % The format of the MogrifyImage method is: |
| 8218 | % |
| 8219 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8220 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8221 | % Image **images,Exceptioninfo *exception) |
| 8222 | % |
| 8223 | % A description of each parameter follows: |
| 8224 | % |
| 8225 | % o image_info: the image info.. |
| 8226 | % |
| 8227 | % o post: If true, post process image list operators otherwise pre-process. |
| 8228 | % |
| 8229 | % o argc: Specifies a pointer to an integer describing the number of |
| 8230 | % elements in the argument vector. |
| 8231 | % |
| 8232 | % o argv: Specifies a pointer to a text array containing the command line |
| 8233 | % arguments. |
| 8234 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8235 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8236 | % |
| 8237 | % o exception: return any errors or warnings in this structure. |
| 8238 | % |
| 8239 | */ |
| 8240 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8241 | const MagickBooleanType post,const int argc,const char **argv, |
| 8242 | Image **images,ExceptionInfo *exception) |
| 8243 | { |
| 8244 | #define MogrifyImageTag "Mogrify/Image" |
| 8245 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8246 | MagickStatusType |
| 8247 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8248 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8249 | MagickBooleanType |
| 8250 | proceed; |
| 8251 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8252 | size_t |
| 8253 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8254 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8255 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8256 | i; |
| 8257 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8258 | assert(image_info != (ImageInfo *) NULL); |
| 8259 | assert(image_info->signature == MagickSignature); |
| 8260 | if (images == (Image **) NULL) |
| 8261 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8262 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8263 | assert((*images)->signature == MagickSignature); |
| 8264 | if ((*images)->debug != MagickFalse) |
| 8265 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8266 | (*images)->filename); |
| 8267 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8268 | return(MagickTrue); |
| 8269 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8270 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8271 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8272 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8273 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8274 | (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc, |
| 8275 | post?"post":"pre"); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8276 | #endif |
| 8277 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8278 | /* |
| 8279 | Pre-process multi-image sequence operators |
| 8280 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8281 | if (post == MagickFalse) |
| 8282 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8283 | /* |
| 8284 | For each image, process simple single image operators |
| 8285 | */ |
| 8286 | i=0; |
| 8287 | n=GetImageListLength(*images); |
| 8288 | for (;;) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8289 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8290 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8291 | (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long) |
| 8292 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8293 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8294 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8295 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8296 | if (proceed == MagickFalse) |
| 8297 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8298 | if ( (*images)->next == (Image *) NULL ) |
| 8299 | break; |
| 8300 | *images=(*images)->next; |
| 8301 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8302 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8303 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8304 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8305 | (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long) |
| 8306 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8307 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8308 | |
| 8309 | /* |
| 8310 | Post-process, multi-image sequence operators |
| 8311 | */ |
| 8312 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8313 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8314 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8315 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8316 | } |