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 | /* |
| 60 | Constant declaration. |
| 61 | */ |
| 62 | static const char |
cristy | 7138c59 | 2009-09-08 13:58:52 +0000 | [diff] [blame] | 63 | BackgroundColor[] = "#fff", /* white */ |
| 64 | BorderColor[] = "#dfdfdf", /* gray */ |
| 65 | MatteColor[] = "#bdbdbd"; /* gray */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 66 | |
| 67 | /* |
| 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 | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 152 | duration=StringToDouble(argv[++i]); |
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 | 8cd5b31 | 2010-01-07 01:10:24 +0000 | [diff] [blame] | 226 | (void) fprintf(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 |
| 249 | % image. That image however may be part of a longer list of images. |
| 250 | % |
| 251 | % The image in the list may be modified in three different ways... |
| 252 | % |
| 253 | % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 254 | % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 255 | % * replace by a list of images (only the -separate option!) |
| 256 | % |
| 257 | % In each case the result is returned into the list, and a pointer to the |
| 258 | % modified image (last image added if replaced by a list of images) is |
| 259 | % returned. |
| 260 | % |
| 261 | % ASIDE: The -crop is present but restricted to non-tile single image crops |
| 262 | % |
| 263 | % This means if all the images are being processed (such as by |
| 264 | % MogrifyImages(), next image to be processed will be as per the pointer |
| 265 | % (*image)->next. Also the image list may grow as a result of some specific |
| 266 | % operations but as images are never merged or deleted, it will never shrink |
| 267 | % in length. Typically the list will remain the same length. |
| 268 | % |
| 269 | % WARNING: As the image pointed to may be replaced, the first image in the |
| 270 | % list may also change. GetFirstImageInList() should be used by caller if |
| 271 | % they wish return the Image pointer to the first image in list. |
| 272 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 273 | % |
| 274 | % The format of the MogrifyImage method is: |
| 275 | % |
| 276 | % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 277 | % const char **argv,Image **image) |
| 278 | % |
| 279 | % A description of each parameter follows: |
| 280 | % |
| 281 | % o image_info: the image info.. |
| 282 | % |
| 283 | % o argc: Specifies a pointer to an integer describing the number of |
| 284 | % elements in the argument vector. |
| 285 | % |
| 286 | % o argv: Specifies a pointer to a text array containing the command line |
| 287 | % arguments. |
| 288 | % |
| 289 | % o image: the image. |
| 290 | % |
| 291 | % o exception: return any errors or warnings in this structure. |
| 292 | % |
| 293 | */ |
| 294 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 295 | /* |
| 296 | ** GetImageCache() will read an image into a image cache if not already |
| 297 | ** present then return the image that is in the cache under that filename. |
| 298 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 299 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 300 | ExceptionInfo *exception) |
| 301 | { |
| 302 | char |
| 303 | key[MaxTextExtent]; |
| 304 | |
| 305 | ExceptionInfo |
| 306 | *sans_exception; |
| 307 | |
| 308 | Image |
| 309 | *image; |
| 310 | |
| 311 | ImageInfo |
| 312 | *read_info; |
| 313 | |
| 314 | (void) FormatMagickString(key,MaxTextExtent,"cache:%s",path); |
| 315 | sans_exception=AcquireExceptionInfo(); |
| 316 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 317 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 318 | if (image != (Image *) NULL) |
| 319 | return(image); |
| 320 | read_info=CloneImageInfo(image_info); |
| 321 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 322 | image=ReadImage(read_info,exception); |
| 323 | read_info=DestroyImageInfo(read_info); |
| 324 | if (image != (Image *) NULL) |
| 325 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 326 | return(image); |
| 327 | } |
| 328 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 329 | static MagickBooleanType IsPathWritable(const char *path) |
| 330 | { |
| 331 | if (IsPathAccessible(path) == MagickFalse) |
| 332 | return(MagickFalse); |
| 333 | if (access(path,W_OK) != 0) |
| 334 | return(MagickFalse); |
| 335 | return(MagickTrue); |
| 336 | } |
| 337 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 338 | static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 339 | { |
| 340 | if (x > y) |
| 341 | return(x); |
| 342 | return(y); |
| 343 | } |
| 344 | |
| 345 | static MagickBooleanType MonitorProgress(const char *text, |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 346 | const MagickOffsetType offset,const MagickSizeType extent, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 347 | void *wand_unused(client_data)) |
| 348 | { |
| 349 | char |
| 350 | message[MaxTextExtent], |
| 351 | tag[MaxTextExtent]; |
| 352 | |
| 353 | const char |
| 354 | *locale_message; |
| 355 | |
| 356 | register char |
| 357 | *p; |
| 358 | |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 359 | if (extent < 2) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 360 | return(MagickTrue); |
| 361 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 362 | p=strrchr(tag,'/'); |
| 363 | if (p != (char *) NULL) |
| 364 | *p='\0'; |
| 365 | (void) FormatMagickString(message,MaxTextExtent,"Monitor/%s",tag); |
| 366 | locale_message=GetLocaleMessage(message); |
| 367 | if (locale_message == message) |
| 368 | locale_message=tag; |
| 369 | if (p == (char *) NULL) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 370 | (void) fprintf(stderr,"%s: %ld of %lu, %02ld%% complete\r",locale_message, |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 371 | (long) offset,(unsigned long) extent,(long) (100L*offset/(extent-1))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 372 | else |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 373 | (void) fprintf(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 374 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 375 | (100L*offset/(extent-1))); |
| 376 | if (offset == (MagickOffsetType) (extent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 377 | (void) fprintf(stderr,"\n"); |
| 378 | (void) fflush(stderr); |
| 379 | return(MagickTrue); |
| 380 | } |
| 381 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 382 | /* |
| 383 | ** SparseColorOption() parse the complex -sparse-color argument into an |
| 384 | ** an array of floating point values than call SparseColorImage(). |
| 385 | ** Argument is a complex mix of floating-point pixel coodinates, and color |
| 386 | ** specifications (or direct floating point numbers). The number of floats |
| 387 | ** needed to represent a color varies depending on teh current channel |
| 388 | ** setting. |
| 389 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 390 | static Image *SparseColorOption(const Image *image,const ChannelType channel, |
| 391 | const SparseColorMethod method,const char *arguments, |
| 392 | const MagickBooleanType color_from_image,ExceptionInfo *exception) |
| 393 | { |
| 394 | ChannelType |
| 395 | channels; |
| 396 | |
| 397 | char |
| 398 | token[MaxTextExtent]; |
| 399 | |
| 400 | const char |
| 401 | *p; |
| 402 | |
| 403 | double |
| 404 | *sparse_arguments; |
| 405 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 406 | register size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 407 | x; |
| 408 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 409 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 410 | number_arguments; |
| 411 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 412 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 413 | number_colors; |
| 414 | |
| 415 | Image |
| 416 | *sparse_image; |
| 417 | |
| 418 | MagickPixelPacket |
| 419 | color; |
| 420 | |
| 421 | MagickBooleanType |
| 422 | error; |
| 423 | |
| 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++; |
anthony | 1e4df87 | 2011-03-19 14:10:59 +0000 | [diff] [blame] | 449 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 513 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +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 | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 524 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +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 { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 558 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +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 | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 565 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +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 | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 572 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +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 | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 579 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +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 | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 586 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 587 | token[0] = ','; /* used this token - get another */ |
| 588 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 | |
| 608 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 609 | const char **argv,Image **image,ExceptionInfo *exception) |
| 610 | { |
| 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 | |
| 624 | Image |
| 625 | *region_image; |
| 626 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +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 | |
| 633 | MagickPixelPacket |
| 634 | fill; |
| 635 | |
| 636 | MagickStatusType |
| 637 | flags; |
| 638 | |
| 639 | QuantizeInfo |
| 640 | *quantize_info; |
| 641 | |
| 642 | RectangleInfo |
| 643 | geometry, |
| 644 | region_geometry; |
| 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); |
| 661 | draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL); |
| 662 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 663 | SetGeometryInfo(&geometry_info); |
| 664 | GetMagickPixelPacket(*image,&fill); |
| 665 | SetMagickPixelPacket(*image,&(*image)->background_color,(IndexPacket *) NULL, |
| 666 | &fill); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 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 | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 676 | Image |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 677 | *mogrify_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 678 | |
| 679 | ssize_t |
| 680 | count; |
| 681 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 682 | option=argv[i]; |
| 683 | if (IsMagickOption(option) == MagickFalse) |
| 684 | continue; |
| 685 | count=MagickMax(ParseMagickOption(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); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 690 | mogrify_image=(Image *)NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 691 | switch (*(option+1)) |
| 692 | { |
| 693 | case 'a': |
| 694 | { |
| 695 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 696 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 697 | /* |
| 698 | Adaptive blur image. |
| 699 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 700 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 701 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 702 | if ((flags & SigmaValue) == 0) |
| 703 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 704 | mogrify_image=AdaptiveBlurImageChannel(*image,channel, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 705 | geometry_info.rho,geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 706 | break; |
| 707 | } |
| 708 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 709 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 710 | /* |
| 711 | Adaptive resize image. |
| 712 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 713 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 714 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 715 | mogrify_image=AdaptiveResizeImage(*image,geometry.width, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 716 | geometry.height,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 717 | break; |
| 718 | } |
| 719 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 720 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 721 | /* |
| 722 | Adaptive sharpen image. |
| 723 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 724 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 725 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 726 | if ((flags & SigmaValue) == 0) |
| 727 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 728 | mogrify_image=AdaptiveSharpenImageChannel(*image,channel, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 729 | geometry_info.rho,geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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; |
| 749 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 750 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 751 | alpha_type=(AlphaChannelType) ParseMagickOption(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 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 766 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 767 | SetGeometryInfo(&geometry_info); |
| 768 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 769 | if ((flags & SigmaValue) == 0) |
| 770 | geometry_info.sigma=geometry_info.rho; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 771 | text=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 772 | InheritException(exception,&(*image)->exception); |
| 773 | if (text == (char *) NULL) |
| 774 | break; |
| 775 | (void) CloneString(&draw_info->text,text); |
| 776 | text=DestroyString(text); |
| 777 | (void) FormatMagickString(geometry,MaxTextExtent,"%+f%+f", |
| 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 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 805 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 814 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 815 | (void) AutoLevelImageChannel(*image,channel); |
| 816 | break; |
| 817 | } |
| 818 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 819 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 820 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 821 | switch ((*image)->orientation) |
| 822 | { |
| 823 | case TopRightOrientation: |
| 824 | { |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 825 | mogrify_image=FlopImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 826 | break; |
| 827 | } |
| 828 | case BottomRightOrientation: |
| 829 | { |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 830 | mogrify_image=RotateImage(*image,180.0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 831 | break; |
| 832 | } |
| 833 | case BottomLeftOrientation: |
| 834 | { |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 835 | mogrify_image=FlipImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 836 | break; |
| 837 | } |
| 838 | case LeftTopOrientation: |
| 839 | { |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 840 | mogrify_image=TransposeImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 841 | break; |
| 842 | } |
| 843 | case RightTopOrientation: |
| 844 | { |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 845 | mogrify_image=RotateImage(*image,90.0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 846 | break; |
| 847 | } |
| 848 | case RightBottomOrientation: |
| 849 | { |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 850 | mogrify_image=TransverseImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 851 | break; |
| 852 | } |
| 853 | case LeftBottomOrientation: |
| 854 | { |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 855 | mogrify_image=RotateImage(*image,270.0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 856 | break; |
| 857 | } |
| 858 | default: |
| 859 | break; |
| 860 | } |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 861 | if (mogrify_image != (Image *) NULL) |
| 862 | mogrify_image->orientation=TopLeftOrientation; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 874 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 882 | /* |
| 883 | Blue shift image. |
| 884 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 885 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 886 | geometry_info.rho=1.5; |
| 887 | if (*option == '-') |
| 888 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 889 | mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 890 | break; |
| 891 | } |
| 892 | if (LocaleCompare("blur",option+1) == 0) |
| 893 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 894 | /* |
| 895 | Gaussian blur image. |
| 896 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 897 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 898 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 899 | if ((flags & SigmaValue) == 0) |
| 900 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 901 | mogrify_image=BlurImageChannel(*image,channel,geometry_info.rho, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 902 | geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 903 | break; |
| 904 | } |
| 905 | if (LocaleCompare("border",option+1) == 0) |
| 906 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 907 | /* |
| 908 | Surround image with a border of solid color. |
| 909 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 910 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 911 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 912 | if ((flags & SigmaValue) == 0) |
| 913 | geometry.height=geometry.width; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 914 | mogrify_image=BorderImage(*image,&geometry,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 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 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 950 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 951 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 952 | brightness=geometry_info.rho; |
cristy | 81fbc8b | 2010-01-11 20:04:07 +0000 | [diff] [blame] | 953 | contrast=0.0; |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 954 | if ((flags & SigmaValue) != 0) |
| 955 | contrast=geometry_info.sigma; |
cristy | 02cc0f2 | 2010-01-12 00:02:32 +0000 | [diff] [blame] | 956 | (void) BrightnessContrastImageChannel(*image,channel,brightness, |
| 957 | contrast); |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 958 | InheritException(exception,&(*image)->exception); |
| 959 | break; |
| 960 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 973 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 == '+') |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 984 | channel=DefaultChannels; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 985 | else |
| 986 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 987 | break; |
| 988 | } |
| 989 | if (LocaleCompare("charcoal",option+1) == 0) |
| 990 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 991 | /* |
| 992 | Charcoal image. |
| 993 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 994 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 995 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 996 | if ((flags & SigmaValue) == 0) |
| 997 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 998 | mogrify_image=CharcoalImage(*image,geometry_info.rho, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 999 | geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1000 | break; |
| 1001 | } |
| 1002 | if (LocaleCompare("chop",option+1) == 0) |
| 1003 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1004 | /* |
| 1005 | Chop the image. |
| 1006 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1007 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1008 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1009 | mogrify_image=ChopImage(*image,&geometry,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1010 | break; |
| 1011 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 1012 | if (LocaleCompare("clamp",option+1) == 0) |
| 1013 | { |
| 1014 | /* |
| 1015 | Clamp image. |
| 1016 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1017 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 1018 | (void) ClampImageChannel(*image,channel); |
| 1019 | InheritException(exception,&(*image)->exception); |
| 1020 | break; |
| 1021 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1022 | if (LocaleCompare("clip",option+1) == 0) |
| 1023 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1024 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 | { |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1037 | CacheView |
| 1038 | *mask_view; |
cristy | a01cbea | 2010-11-03 16:33:33 +0000 | [diff] [blame] | 1039 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1040 | Image |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1041 | *mask_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1042 | |
cristy | 9d314ff | 2011-03-09 01:30:28 +0000 | [diff] [blame] | 1043 | register PixelPacket |
| 1044 | *restrict q; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1045 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1046 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1047 | x; |
| 1048 | |
cristy | 9d314ff | 2011-03-09 01:30:28 +0000 | [diff] [blame] | 1049 | ssize_t |
| 1050 | y; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1051 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1052 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 | */ |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1065 | mask_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1066 | if (mask_image == (Image *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1067 | break; |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1068 | if (SetImageStorageClass(mask_image,DirectClass) == MagickFalse) |
| 1069 | return(MagickFalse); |
| 1070 | mask_view=AcquireCacheView(mask_image); |
| 1071 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1072 | { |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1073 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1074 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1075 | if (q == (PixelPacket *) NULL) |
| 1076 | break; |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1077 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1078 | { |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1079 | if (mask_image->matte == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1080 | q->opacity=PixelIntensityToQuantum(q); |
| 1081 | q->red=q->opacity; |
| 1082 | q->green=q->opacity; |
| 1083 | q->blue=q->opacity; |
| 1084 | q++; |
| 1085 | } |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1086 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1087 | break; |
| 1088 | } |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1089 | mask_view=DestroyCacheView(mask_view); |
| 1090 | mask_image->matte=MagickTrue; |
| 1091 | (void) SetImageClipMask(*image,mask_image); |
| 1092 | mask_image=DestroyImage(mask_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1093 | InheritException(exception,&(*image)->exception); |
| 1094 | break; |
| 1095 | } |
| 1096 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1097 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1098 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1099 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
| 1100 | MagickFalse); |
| 1101 | InheritException(exception,&(*image)->exception); |
| 1102 | break; |
| 1103 | } |
| 1104 | if (LocaleCompare("colorize",option+1) == 0) |
| 1105 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1106 | /* |
| 1107 | Colorize the image. |
| 1108 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1109 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1110 | mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1111 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1112 | break; |
| 1113 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 1114 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1115 | { |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 1116 | KernelInfo |
| 1117 | *kernel; |
| 1118 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1119 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 1120 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1121 | if (kernel == (KernelInfo *) NULL) |
| 1122 | break; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1123 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 1124 | kernel=DestroyKernelInfo(kernel); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 1125 | break; |
| 1126 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1127 | if (LocaleCompare("colors",option+1) == 0) |
| 1128 | { |
| 1129 | /* |
| 1130 | Reduce the number of colors in the image. |
| 1131 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1132 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 1133 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1134 | if (quantize_info->number_colors == 0) |
| 1135 | break; |
| 1136 | if (((*image)->storage_class == DirectClass) || |
| 1137 | (*image)->colors > quantize_info->number_colors) |
| 1138 | (void) QuantizeImage(quantize_info,*image); |
| 1139 | else |
| 1140 | (void) CompressImageColormap(*image); |
| 1141 | InheritException(exception,&(*image)->exception); |
| 1142 | break; |
| 1143 | } |
| 1144 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1145 | { |
| 1146 | ColorspaceType |
| 1147 | colorspace; |
| 1148 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1149 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1150 | if (*option == '+') |
| 1151 | { |
| 1152 | (void) TransformImageColorspace(*image,RGBColorspace); |
| 1153 | InheritException(exception,&(*image)->exception); |
| 1154 | break; |
| 1155 | } |
| 1156 | colorspace=(ColorspaceType) ParseMagickOption( |
| 1157 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 1158 | (void) TransformImageColorspace(*image,colorspace); |
| 1159 | InheritException(exception,&(*image)->exception); |
| 1160 | break; |
| 1161 | } |
| 1162 | if (LocaleCompare("contrast",option+1) == 0) |
| 1163 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1164 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1165 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
| 1166 | MagickFalse); |
| 1167 | InheritException(exception,&(*image)->exception); |
| 1168 | break; |
| 1169 | } |
| 1170 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1171 | { |
| 1172 | double |
| 1173 | black_point, |
| 1174 | white_point; |
| 1175 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1176 | MagickStatusType |
| 1177 | flags; |
| 1178 | |
| 1179 | /* |
| 1180 | Contrast stretch image. |
| 1181 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1182 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1183 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1184 | black_point=geometry_info.rho; |
| 1185 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1186 | black_point; |
| 1187 | if ((flags & PercentValue) != 0) |
| 1188 | { |
| 1189 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1190 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1191 | } |
| 1192 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1193 | white_point; |
| 1194 | (void) ContrastStretchImageChannel(*image,channel,black_point, |
| 1195 | white_point); |
| 1196 | InheritException(exception,&(*image)->exception); |
| 1197 | break; |
| 1198 | } |
| 1199 | if (LocaleCompare("convolve",option+1) == 0) |
| 1200 | { |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1201 | double |
| 1202 | gamma; |
| 1203 | |
cristy | 2be1538 | 2010-01-21 02:38:03 +0000 | [diff] [blame] | 1204 | KernelInfo |
cristy | 56a9e51 | 2010-01-06 18:18:55 +0000 | [diff] [blame] | 1205 | *kernel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1206 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1207 | register ssize_t |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1208 | j; |
| 1209 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1210 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 2be1538 | 2010-01-21 02:38:03 +0000 | [diff] [blame] | 1211 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1212 | if (kernel == (KernelInfo *) NULL) |
cristy | 56a9e51 | 2010-01-06 18:18:55 +0000 | [diff] [blame] | 1213 | break; |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1214 | gamma=0.0; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1215 | for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++) |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1216 | gamma+=kernel->values[j]; |
| 1217 | gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1218 | for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++) |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1219 | kernel->values[j]*=gamma; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1220 | mogrify_image=FilterImageChannel(*image,channel,kernel,exception); |
anthony | 83ba99b | 2010-01-24 08:48:15 +0000 | [diff] [blame] | 1221 | kernel=DestroyKernelInfo(kernel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1222 | break; |
| 1223 | } |
| 1224 | if (LocaleCompare("crop",option+1) == 0) |
| 1225 | { |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 1226 | /* |
| 1227 | Crop a image to a smaller size |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 1228 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1229 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 1230 | #if 0 |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1231 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1232 | if (((geometry.width != 0) || (geometry.height != 0)) && |
| 1233 | ((flags & XValue) == 0) && ((flags & YValue) == 0)) |
| 1234 | break; |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 1235 | #endif |
| 1236 | #if 0 |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1237 | mogrify_image=CloneImage(*image,0,0,MagickTrue,&(*image)->exception); |
| 1238 | mogrify_image->next = mogrify_image->previous = (Image *)NULL; |
| 1239 | (void) TransformImage(&mogrify_image,argv[i+1],(char *) NULL); |
| 1240 | InheritException(exception,&mogrify_image->exception); |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 1241 | #else |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1242 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 1243 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1244 | break; |
| 1245 | } |
| 1246 | if (LocaleCompare("cycle",option+1) == 0) |
| 1247 | { |
| 1248 | /* |
| 1249 | Cycle an image colormap. |
| 1250 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1251 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 1252 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1])); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1253 | InheritException(exception,&(*image)->exception); |
| 1254 | break; |
| 1255 | } |
| 1256 | break; |
| 1257 | } |
| 1258 | case 'd': |
| 1259 | { |
| 1260 | if (LocaleCompare("decipher",option+1) == 0) |
| 1261 | { |
| 1262 | StringInfo |
| 1263 | *passkey; |
| 1264 | |
| 1265 | /* |
| 1266 | Decipher pixels. |
| 1267 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1268 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1269 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1270 | if (passkey != (StringInfo *) NULL) |
| 1271 | { |
| 1272 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1273 | passkey=DestroyStringInfo(passkey); |
| 1274 | } |
| 1275 | break; |
| 1276 | } |
| 1277 | if (LocaleCompare("density",option+1) == 0) |
| 1278 | { |
| 1279 | /* |
| 1280 | Set image density. |
| 1281 | */ |
| 1282 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1283 | break; |
| 1284 | } |
| 1285 | if (LocaleCompare("depth",option+1) == 0) |
| 1286 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1287 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1288 | if (*option == '+') |
| 1289 | { |
| 1290 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH); |
| 1291 | break; |
| 1292 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 1293 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1])); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1294 | break; |
| 1295 | } |
| 1296 | if (LocaleCompare("deskew",option+1) == 0) |
| 1297 | { |
| 1298 | double |
| 1299 | threshold; |
| 1300 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1301 | /* |
| 1302 | Straighten the image. |
| 1303 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1304 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1305 | if (*option == '+') |
| 1306 | threshold=40.0*QuantumRange/100.0; |
| 1307 | else |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1308 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1309 | mogrify_image=DeskewImage(*image,threshold,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1310 | break; |
| 1311 | } |
| 1312 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1313 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1314 | /* |
| 1315 | Reduce the speckles within an image. |
| 1316 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1317 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1318 | mogrify_image=DespeckleImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1319 | break; |
| 1320 | } |
| 1321 | if (LocaleCompare("display",option+1) == 0) |
| 1322 | { |
| 1323 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1324 | break; |
| 1325 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1326 | if (LocaleCompare("distort",option+1) == 0) |
| 1327 | { |
| 1328 | char |
| 1329 | *args, |
| 1330 | token[MaxTextExtent]; |
| 1331 | |
| 1332 | const char |
| 1333 | *p; |
| 1334 | |
| 1335 | DistortImageMethod |
| 1336 | method; |
| 1337 | |
| 1338 | double |
| 1339 | *arguments; |
| 1340 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1341 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1342 | x; |
| 1343 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1344 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1345 | number_arguments; |
| 1346 | |
| 1347 | /* |
| 1348 | Distort image. |
| 1349 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1350 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1351 | method=(DistortImageMethod) ParseMagickOption(MagickDistortOptions, |
| 1352 | MagickFalse,argv[i+1]); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1353 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1354 | InheritException(exception,&(*image)->exception); |
| 1355 | if (args == (char *) NULL) |
| 1356 | break; |
| 1357 | p=(char *) args; |
| 1358 | for (x=0; *p != '\0'; x++) |
| 1359 | { |
| 1360 | GetMagickToken(p,&p,token); |
| 1361 | if (*token == ',') |
| 1362 | GetMagickToken(p,&p,token); |
| 1363 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1364 | number_arguments=(size_t) x; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1365 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1366 | sizeof(*arguments)); |
| 1367 | if (arguments == (double *) NULL) |
| 1368 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1369 | "MemoryAllocationFailed",(*image)->filename); |
| 1370 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1371 | sizeof(*arguments)); |
| 1372 | p=(char *) args; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1373 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1374 | { |
| 1375 | GetMagickToken(p,&p,token); |
| 1376 | if (*token == ',') |
| 1377 | GetMagickToken(p,&p,token); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1378 | arguments[x]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1379 | } |
| 1380 | args=DestroyString(args); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1381 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1382 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1383 | arguments=(double *) RelinquishMagickMemory(arguments); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1384 | break; |
| 1385 | } |
| 1386 | if (LocaleCompare("dither",option+1) == 0) |
| 1387 | { |
| 1388 | if (*option == '+') |
| 1389 | { |
| 1390 | quantize_info->dither=MagickFalse; |
| 1391 | break; |
| 1392 | } |
| 1393 | quantize_info->dither=MagickTrue; |
| 1394 | quantize_info->dither_method=(DitherMethod) ParseMagickOption( |
| 1395 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1396 | if (quantize_info->dither_method == NoDitherMethod) |
| 1397 | quantize_info->dither=MagickFalse; |
| 1398 | break; |
| 1399 | } |
| 1400 | if (LocaleCompare("draw",option+1) == 0) |
| 1401 | { |
| 1402 | /* |
| 1403 | Draw image. |
| 1404 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1405 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1406 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
| 1407 | (void) DrawImage(*image,draw_info); |
| 1408 | InheritException(exception,&(*image)->exception); |
| 1409 | break; |
| 1410 | } |
| 1411 | break; |
| 1412 | } |
| 1413 | case 'e': |
| 1414 | { |
| 1415 | if (LocaleCompare("edge",option+1) == 0) |
| 1416 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1417 | /* |
| 1418 | Enhance edges in the image. |
| 1419 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1420 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1421 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1422 | if ((flags & SigmaValue) == 0) |
| 1423 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1424 | mogrify_image=EdgeImage(*image,geometry_info.rho,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1425 | break; |
| 1426 | } |
| 1427 | if (LocaleCompare("emboss",option+1) == 0) |
| 1428 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1429 | /* |
| 1430 | Gaussian embossen image. |
| 1431 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1432 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1433 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1434 | if ((flags & SigmaValue) == 0) |
| 1435 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1436 | mogrify_image=EmbossImage(*image,geometry_info.rho, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1437 | geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1438 | break; |
| 1439 | } |
| 1440 | if (LocaleCompare("encipher",option+1) == 0) |
| 1441 | { |
| 1442 | StringInfo |
| 1443 | *passkey; |
| 1444 | |
| 1445 | /* |
| 1446 | Encipher pixels. |
| 1447 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1448 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1449 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1450 | if (passkey != (StringInfo *) NULL) |
| 1451 | { |
| 1452 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1453 | passkey=DestroyStringInfo(passkey); |
| 1454 | } |
| 1455 | break; |
| 1456 | } |
| 1457 | if (LocaleCompare("encoding",option+1) == 0) |
| 1458 | { |
| 1459 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1460 | break; |
| 1461 | } |
| 1462 | if (LocaleCompare("enhance",option+1) == 0) |
| 1463 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1464 | /* |
| 1465 | Enhance image. |
| 1466 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1467 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1468 | mogrify_image=EnhanceImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1469 | break; |
| 1470 | } |
| 1471 | if (LocaleCompare("equalize",option+1) == 0) |
| 1472 | { |
| 1473 | /* |
| 1474 | Equalize image. |
| 1475 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1476 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1477 | (void) EqualizeImageChannel(*image,channel); |
| 1478 | InheritException(exception,&(*image)->exception); |
| 1479 | break; |
| 1480 | } |
| 1481 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1482 | { |
| 1483 | double |
| 1484 | constant; |
| 1485 | |
| 1486 | MagickEvaluateOperator |
| 1487 | op; |
| 1488 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1489 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1490 | op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions, |
| 1491 | MagickFalse,argv[i+1]); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1492 | constant=SiPrefixToDouble(argv[i+2],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1493 | (void) EvaluateImageChannel(*image,channel,op,constant,exception); |
| 1494 | break; |
| 1495 | } |
| 1496 | if (LocaleCompare("extent",option+1) == 0) |
| 1497 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1498 | /* |
| 1499 | Set the image extent. |
| 1500 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1501 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1502 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
cristy | f0bbfd9 | 2009-11-25 14:12:31 +0000 | [diff] [blame] | 1503 | if (geometry.width == 0) |
cristy | 2ea9a4e | 2009-11-25 14:30:22 +0000 | [diff] [blame] | 1504 | geometry.width=(*image)->columns; |
cristy | f0bbfd9 | 2009-11-25 14:12:31 +0000 | [diff] [blame] | 1505 | if (geometry.height == 0) |
cristy | 2ea9a4e | 2009-11-25 14:30:22 +0000 | [diff] [blame] | 1506 | geometry.height=(*image)->rows; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1507 | mogrify_image=ExtentImage(*image,&geometry,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1508 | break; |
| 1509 | } |
| 1510 | break; |
| 1511 | } |
| 1512 | case 'f': |
| 1513 | { |
| 1514 | if (LocaleCompare("family",option+1) == 0) |
| 1515 | { |
| 1516 | if (*option == '+') |
| 1517 | { |
| 1518 | if (draw_info->family != (char *) NULL) |
| 1519 | draw_info->family=DestroyString(draw_info->family); |
| 1520 | break; |
| 1521 | } |
| 1522 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1523 | break; |
| 1524 | } |
cristy | 0fe961c | 2010-01-30 03:09:54 +0000 | [diff] [blame] | 1525 | if (LocaleCompare("features",option+1) == 0) |
| 1526 | { |
| 1527 | if (*option == '+') |
| 1528 | { |
| 1529 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1530 | break; |
| 1531 | } |
| 1532 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1533 | break; |
| 1534 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1535 | if (LocaleCompare("fill",option+1) == 0) |
| 1536 | { |
| 1537 | ExceptionInfo |
| 1538 | *sans; |
| 1539 | |
| 1540 | GetMagickPixelPacket(*image,&fill); |
| 1541 | if (*option == '+') |
| 1542 | { |
| 1543 | (void) QueryMagickColor("none",&fill,exception); |
| 1544 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 1545 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1546 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1547 | break; |
| 1548 | } |
| 1549 | sans=AcquireExceptionInfo(); |
| 1550 | (void) QueryMagickColor(argv[i+1],&fill,sans); |
| 1551 | status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans); |
| 1552 | sans=DestroyExceptionInfo(sans); |
| 1553 | if (status == MagickFalse) |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1554 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1555 | exception); |
| 1556 | break; |
| 1557 | } |
| 1558 | if (LocaleCompare("flip",option+1) == 0) |
| 1559 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1560 | /* |
| 1561 | Flip image scanlines. |
| 1562 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1563 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1564 | mogrify_image=FlipImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1565 | break; |
| 1566 | } |
| 1567 | if (LocaleCompare("flop",option+1) == 0) |
| 1568 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1569 | /* |
| 1570 | Flop image scanlines. |
| 1571 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1572 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1573 | mogrify_image=FlopImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1574 | break; |
| 1575 | } |
| 1576 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1577 | { |
| 1578 | MagickPixelPacket |
| 1579 | target; |
| 1580 | |
| 1581 | /* |
| 1582 | Floodfill image. |
| 1583 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1584 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1585 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1586 | (void) QueryMagickColor(argv[i+2],&target,exception); |
| 1587 | (void) FloodfillPaintImage(*image,channel,draw_info,&target, |
| 1588 | geometry.x,geometry.y,*option == '-' ? MagickFalse : MagickTrue); |
| 1589 | InheritException(exception,&(*image)->exception); |
| 1590 | break; |
| 1591 | } |
| 1592 | if (LocaleCompare("font",option+1) == 0) |
| 1593 | { |
| 1594 | if (*option == '+') |
| 1595 | { |
| 1596 | if (draw_info->font != (char *) NULL) |
| 1597 | draw_info->font=DestroyString(draw_info->font); |
| 1598 | break; |
| 1599 | } |
| 1600 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1601 | break; |
| 1602 | } |
| 1603 | if (LocaleCompare("format",option+1) == 0) |
| 1604 | { |
| 1605 | format=argv[i+1]; |
| 1606 | break; |
| 1607 | } |
| 1608 | if (LocaleCompare("frame",option+1) == 0) |
| 1609 | { |
| 1610 | FrameInfo |
| 1611 | frame_info; |
| 1612 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1613 | /* |
| 1614 | Surround image with an ornamental border. |
| 1615 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1616 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1617 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1618 | frame_info.width=geometry.width; |
| 1619 | frame_info.height=geometry.height; |
| 1620 | if ((flags & HeightValue) == 0) |
| 1621 | frame_info.height=geometry.width; |
| 1622 | frame_info.outer_bevel=geometry.x; |
| 1623 | frame_info.inner_bevel=geometry.y; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1624 | frame_info.x=(ssize_t) frame_info.width; |
| 1625 | frame_info.y=(ssize_t) frame_info.height; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1626 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1627 | frame_info.height=(*image)->rows+2*frame_info.height; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1628 | mogrify_image=FrameImage(*image,&frame_info,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1629 | break; |
| 1630 | } |
| 1631 | if (LocaleCompare("function",option+1) == 0) |
| 1632 | { |
| 1633 | char |
| 1634 | *arguments, |
| 1635 | token[MaxTextExtent]; |
| 1636 | |
| 1637 | const char |
| 1638 | *p; |
| 1639 | |
| 1640 | double |
| 1641 | *parameters; |
| 1642 | |
| 1643 | MagickFunction |
| 1644 | function; |
| 1645 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1646 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1647 | x; |
| 1648 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1649 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1650 | number_parameters; |
| 1651 | |
| 1652 | /* |
| 1653 | Function Modify Image Values |
| 1654 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1655 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1656 | function=(MagickFunction) ParseMagickOption(MagickFunctionOptions, |
| 1657 | MagickFalse,argv[i+1]); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1658 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1659 | InheritException(exception,&(*image)->exception); |
| 1660 | if (arguments == (char *) NULL) |
| 1661 | break; |
| 1662 | p=(char *) arguments; |
| 1663 | for (x=0; *p != '\0'; x++) |
| 1664 | { |
| 1665 | GetMagickToken(p,&p,token); |
| 1666 | if (*token == ',') |
| 1667 | GetMagickToken(p,&p,token); |
| 1668 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1669 | number_parameters=(size_t) x; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1670 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1671 | sizeof(*parameters)); |
| 1672 | if (parameters == (double *) NULL) |
| 1673 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1674 | "MemoryAllocationFailed",(*image)->filename); |
| 1675 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1676 | sizeof(*parameters)); |
| 1677 | p=(char *) arguments; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1678 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1679 | { |
| 1680 | GetMagickToken(p,&p,token); |
| 1681 | if (*token == ',') |
| 1682 | GetMagickToken(p,&p,token); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1683 | parameters[x]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1684 | } |
| 1685 | arguments=DestroyString(arguments); |
| 1686 | (void) FunctionImageChannel(*image,channel,function, |
| 1687 | number_parameters,parameters,exception); |
| 1688 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1689 | break; |
| 1690 | } |
| 1691 | break; |
| 1692 | } |
| 1693 | case 'g': |
| 1694 | { |
| 1695 | if (LocaleCompare("gamma",option+1) == 0) |
| 1696 | { |
| 1697 | /* |
| 1698 | Gamma image. |
| 1699 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1700 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1701 | if (*option == '+') |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1702 | (*image)->gamma=StringToDouble(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1703 | else |
| 1704 | { |
| 1705 | if (strchr(argv[i+1],',') != (char *) NULL) |
| 1706 | (void) GammaImage(*image,argv[i+1]); |
| 1707 | else |
cristy | a5447be | 2010-01-11 00:20:51 +0000 | [diff] [blame] | 1708 | (void) GammaImageChannel(*image,channel, |
| 1709 | StringToDouble(argv[i+1])); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1710 | InheritException(exception,&(*image)->exception); |
| 1711 | } |
| 1712 | break; |
| 1713 | } |
| 1714 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1715 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1716 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1717 | /* |
| 1718 | Gaussian blur image. |
| 1719 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1720 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1721 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1722 | if ((flags & SigmaValue) == 0) |
| 1723 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1724 | mogrify_image=GaussianBlurImageChannel(*image,channel, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1725 | geometry_info.rho,geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1726 | break; |
| 1727 | } |
| 1728 | if (LocaleCompare("geometry",option+1) == 0) |
| 1729 | { |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 1730 | /* |
| 1731 | Record Image offset, Resize last image. |
| 1732 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1733 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1734 | if (*option == '+') |
| 1735 | { |
| 1736 | if ((*image)->geometry != (char *) NULL) |
| 1737 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1738 | break; |
| 1739 | } |
| 1740 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1741 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1742 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1743 | else |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1744 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 1745 | (*image)->filter,(*image)->blur,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1746 | break; |
| 1747 | } |
| 1748 | if (LocaleCompare("gravity",option+1) == 0) |
| 1749 | { |
| 1750 | if (*option == '+') |
| 1751 | { |
| 1752 | draw_info->gravity=UndefinedGravity; |
| 1753 | break; |
| 1754 | } |
| 1755 | draw_info->gravity=(GravityType) ParseMagickOption( |
| 1756 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1757 | break; |
| 1758 | } |
| 1759 | break; |
| 1760 | } |
| 1761 | case 'h': |
| 1762 | { |
| 1763 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1764 | { |
| 1765 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1766 | break; |
| 1767 | } |
| 1768 | break; |
| 1769 | } |
| 1770 | case 'i': |
| 1771 | { |
| 1772 | if (LocaleCompare("identify",option+1) == 0) |
| 1773 | { |
| 1774 | char |
| 1775 | *text; |
| 1776 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1777 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1778 | if (format == (char *) NULL) |
| 1779 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1780 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1781 | InheritException(exception,&(*image)->exception); |
| 1782 | break; |
| 1783 | } |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1784 | text=InterpretImageProperties(mogrify_info,*image,format); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1785 | InheritException(exception,&(*image)->exception); |
| 1786 | if (text == (char *) NULL) |
| 1787 | break; |
| 1788 | (void) fputs(text,stdout); |
| 1789 | (void) fputc('\n',stdout); |
| 1790 | text=DestroyString(text); |
| 1791 | break; |
| 1792 | } |
| 1793 | if (LocaleCompare("implode",option+1) == 0) |
| 1794 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1795 | /* |
| 1796 | Implode image. |
| 1797 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1798 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1799 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1800 | mogrify_image=ImplodeImage(*image,geometry_info.rho,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1801 | break; |
| 1802 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 1803 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1804 | { |
| 1805 | if (*option == '+') |
| 1806 | (void) ParseGeometry("0",&geometry_info); |
| 1807 | else |
| 1808 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1809 | draw_info->interline_spacing=geometry_info.rho; |
| 1810 | break; |
| 1811 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1812 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1813 | { |
| 1814 | if (*option == '+') |
| 1815 | (void) ParseGeometry("0",&geometry_info); |
| 1816 | else |
| 1817 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1818 | draw_info->interword_spacing=geometry_info.rho; |
| 1819 | break; |
| 1820 | } |
| 1821 | break; |
| 1822 | } |
| 1823 | case 'k': |
| 1824 | { |
| 1825 | if (LocaleCompare("kerning",option+1) == 0) |
| 1826 | { |
| 1827 | if (*option == '+') |
| 1828 | (void) ParseGeometry("0",&geometry_info); |
| 1829 | else |
| 1830 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1831 | draw_info->kerning=geometry_info.rho; |
| 1832 | break; |
| 1833 | } |
| 1834 | break; |
| 1835 | } |
| 1836 | case 'l': |
| 1837 | { |
| 1838 | if (LocaleCompare("lat",option+1) == 0) |
| 1839 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1840 | /* |
| 1841 | Local adaptive threshold image. |
| 1842 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1843 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1844 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1845 | if ((flags & PercentValue) != 0) |
| 1846 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1847 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
| 1848 | geometry_info.rho,(size_t) geometry_info.sigma,(ssize_t) |
| 1849 | geometry_info.xi,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1850 | break; |
| 1851 | } |
| 1852 | if (LocaleCompare("level",option+1) == 0) |
| 1853 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1854 | MagickRealType |
| 1855 | black_point, |
| 1856 | gamma, |
| 1857 | white_point; |
| 1858 | |
| 1859 | MagickStatusType |
| 1860 | flags; |
| 1861 | |
| 1862 | /* |
| 1863 | Parse levels. |
| 1864 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1865 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1866 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1867 | black_point=geometry_info.rho; |
| 1868 | white_point=(MagickRealType) QuantumRange; |
| 1869 | if ((flags & SigmaValue) != 0) |
| 1870 | white_point=geometry_info.sigma; |
| 1871 | gamma=1.0; |
| 1872 | if ((flags & XiValue) != 0) |
| 1873 | gamma=geometry_info.xi; |
| 1874 | if ((flags & PercentValue) != 0) |
| 1875 | { |
| 1876 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 1877 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 1878 | } |
| 1879 | if ((flags & SigmaValue) == 0) |
| 1880 | white_point=(MagickRealType) QuantumRange-black_point; |
| 1881 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
| 1882 | (void) LevelizeImageChannel(*image,channel,black_point, |
| 1883 | white_point,gamma); |
| 1884 | else |
| 1885 | (void) LevelImageChannel(*image,channel,black_point,white_point, |
| 1886 | gamma); |
| 1887 | InheritException(exception,&(*image)->exception); |
| 1888 | break; |
| 1889 | } |
| 1890 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1891 | { |
| 1892 | char |
| 1893 | token[MaxTextExtent]; |
| 1894 | |
| 1895 | const char |
| 1896 | *p; |
| 1897 | |
| 1898 | MagickPixelPacket |
| 1899 | black_point, |
| 1900 | white_point; |
| 1901 | |
| 1902 | p=(const char *) argv[i+1]; |
| 1903 | GetMagickToken(p,&p,token); /* get black point color */ |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 1904 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1905 | (void) QueryMagickColor(token,&black_point,exception); |
| 1906 | else |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 1907 | (void) QueryMagickColor("#000000",&black_point,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1908 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1909 | GetMagickToken(p,&p,token); |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 1910 | if (*token == '\0') |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1911 | white_point=black_point; /* set everything to that color */ |
| 1912 | else |
| 1913 | { |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 1914 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 1915 | GetMagickToken(p,&p,token); /* Get white point color. */ |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 1916 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1917 | (void) QueryMagickColor(token,&white_point,exception); |
| 1918 | else |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 1919 | (void) QueryMagickColor("#ffffff",&white_point,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1920 | } |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 1921 | (void) LevelColorsImageChannel(*image,channel,&black_point, |
| 1922 | &white_point,*option == '+' ? MagickTrue : MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1923 | break; |
| 1924 | } |
| 1925 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 1926 | { |
| 1927 | double |
| 1928 | black_point, |
| 1929 | white_point; |
| 1930 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1931 | MagickStatusType |
| 1932 | flags; |
| 1933 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1934 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1935 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1936 | black_point=geometry_info.rho; |
| 1937 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 1938 | if ((flags & SigmaValue) != 0) |
| 1939 | white_point=geometry_info.sigma; |
| 1940 | if ((flags & PercentValue) != 0) |
| 1941 | { |
| 1942 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1943 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1944 | } |
| 1945 | if ((flags & SigmaValue) == 0) |
| 1946 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1947 | black_point; |
| 1948 | (void) LinearStretchImage(*image,black_point,white_point); |
| 1949 | InheritException(exception,&(*image)->exception); |
| 1950 | break; |
| 1951 | } |
| 1952 | if (LocaleCompare("linewidth",option+1) == 0) |
| 1953 | { |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1954 | draw_info->stroke_width=StringToDouble(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1955 | break; |
| 1956 | } |
| 1957 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 1958 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1959 | /* |
| 1960 | Liquid rescale image. |
| 1961 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1962 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1963 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1964 | if ((flags & XValue) == 0) |
| 1965 | geometry.x=1; |
| 1966 | if ((flags & YValue) == 0) |
| 1967 | geometry.y=0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1968 | mogrify_image=LiquidRescaleImage(*image,geometry.width, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1969 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1970 | break; |
| 1971 | } |
| 1972 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 1973 | { |
| 1974 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1975 | break; |
| 1976 | } |
| 1977 | break; |
| 1978 | } |
| 1979 | case 'm': |
| 1980 | { |
| 1981 | if (LocaleCompare("map",option+1) == 0) |
| 1982 | { |
| 1983 | Image |
| 1984 | *remap_image; |
| 1985 | |
| 1986 | /* |
| 1987 | Transform image colors to match this set of colors. |
| 1988 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1989 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1990 | if (*option == '+') |
| 1991 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1992 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1993 | if (remap_image == (Image *) NULL) |
| 1994 | break; |
| 1995 | (void) RemapImage(quantize_info,*image,remap_image); |
| 1996 | InheritException(exception,&(*image)->exception); |
| 1997 | remap_image=DestroyImage(remap_image); |
| 1998 | break; |
| 1999 | } |
| 2000 | if (LocaleCompare("mask",option+1) == 0) |
| 2001 | { |
| 2002 | Image |
| 2003 | *mask; |
| 2004 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2005 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2006 | if (*option == '+') |
| 2007 | { |
| 2008 | /* |
| 2009 | Remove a mask. |
| 2010 | */ |
| 2011 | (void) SetImageMask(*image,(Image *) NULL); |
| 2012 | InheritException(exception,&(*image)->exception); |
| 2013 | break; |
| 2014 | } |
| 2015 | /* |
| 2016 | Set the image mask. |
| 2017 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2018 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2019 | if (mask == (Image *) NULL) |
| 2020 | break; |
| 2021 | (void) SetImageMask(*image,mask); |
| 2022 | mask=DestroyImage(mask); |
| 2023 | InheritException(exception,&(*image)->exception); |
| 2024 | break; |
| 2025 | } |
| 2026 | if (LocaleCompare("matte",option+1) == 0) |
| 2027 | { |
| 2028 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
| 2029 | SetAlphaChannel : DeactivateAlphaChannel ); |
| 2030 | InheritException(exception,&(*image)->exception); |
| 2031 | break; |
| 2032 | } |
| 2033 | if (LocaleCompare("median",option+1) == 0) |
| 2034 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2035 | /* |
| 2036 | Median filter image. |
| 2037 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2038 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2039 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2040 | mogrify_image=StatisticImageChannel(*image,channel,MedianStatistic, |
cristy | 95c3834 | 2011-03-18 22:39:51 +0000 | [diff] [blame] | 2041 | (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2042 | break; |
| 2043 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 2044 | if (LocaleCompare("mode",option+1) == 0) |
| 2045 | { |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 2046 | /* |
| 2047 | Mode image. |
| 2048 | */ |
| 2049 | (void) SyncImageSettings(mogrify_info,*image); |
| 2050 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2051 | mogrify_image=StatisticImageChannel(*image,channel,ModeStatistic, |
cristy | 95c3834 | 2011-03-18 22:39:51 +0000 | [diff] [blame] | 2052 | (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception); |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 2053 | break; |
| 2054 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2055 | if (LocaleCompare("modulate",option+1) == 0) |
| 2056 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2057 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2058 | (void) ModulateImage(*image,argv[i+1]); |
| 2059 | InheritException(exception,&(*image)->exception); |
| 2060 | break; |
| 2061 | } |
| 2062 | if (LocaleCompare("monitor",option+1) == 0) |
| 2063 | { |
cristy | 7d34ef2 | 2010-03-25 01:11:22 +0000 | [diff] [blame] | 2064 | if (*option == '+') |
| 2065 | { |
| 2066 | (void) SetImageProgressMonitor(*image, |
| 2067 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2068 | break; |
| 2069 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2070 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2071 | (void *) NULL); |
| 2072 | break; |
| 2073 | } |
| 2074 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2075 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2076 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2077 | (void) SetImageType(*image,BilevelType); |
| 2078 | InheritException(exception,&(*image)->exception); |
| 2079 | break; |
| 2080 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2081 | if (LocaleCompare("morphology",option+1) == 0) |
| 2082 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2083 | char |
| 2084 | token[MaxTextExtent]; |
| 2085 | |
| 2086 | const char |
| 2087 | *p; |
| 2088 | |
cristy | e96405a | 2010-05-19 02:24:31 +0000 | [diff] [blame] | 2089 | KernelInfo |
| 2090 | *kernel; |
| 2091 | |
cristy | e96405a | 2010-05-19 02:24:31 +0000 | [diff] [blame] | 2092 | MorphologyMethod |
| 2093 | method; |
| 2094 | |
cristy | 9d314ff | 2011-03-09 01:30:28 +0000 | [diff] [blame] | 2095 | ssize_t |
| 2096 | iterations; |
| 2097 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2098 | /* |
| 2099 | Morphological Image Operation |
| 2100 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2101 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2102 | p=argv[i+1]; |
| 2103 | GetMagickToken(p,&p,token); |
| 2104 | method=(MorphologyMethod) ParseMagickOption(MagickMorphologyOptions, |
cristy | d2c1e1e | 2010-05-08 01:05:44 +0000 | [diff] [blame] | 2105 | MagickFalse,token); |
cristy | ef65691 | 2010-03-05 19:54:59 +0000 | [diff] [blame] | 2106 | iterations=1L; |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2107 | GetMagickToken(p,&p,token); |
cristy | ef65691 | 2010-03-05 19:54:59 +0000 | [diff] [blame] | 2108 | if ((*p == ':') || (*p == ',')) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2109 | GetMagickToken(p,&p,token); |
cristy | ef65691 | 2010-03-05 19:54:59 +0000 | [diff] [blame] | 2110 | if ((*p != '\0')) |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 2111 | iterations=(ssize_t) StringToLong(p); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2112 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2113 | if (kernel == (KernelInfo *) NULL) |
cristy | e96405a | 2010-05-19 02:24:31 +0000 | [diff] [blame] | 2114 | { |
| 2115 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2116 | OptionError,"UnabletoParseKernel","morphology"); |
| 2117 | status=MagickFalse; |
| 2118 | break; |
| 2119 | } |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2120 | mogrify_image=MorphologyImageChannel(*image,channel,method, |
cristy | 02d5b4f | 2010-02-01 01:08:27 +0000 | [diff] [blame] | 2121 | iterations,kernel,exception); |
anthony | 83ba99b | 2010-01-24 08:48:15 +0000 | [diff] [blame] | 2122 | kernel=DestroyKernelInfo(kernel); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2123 | break; |
| 2124 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2125 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2126 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2127 | /* |
| 2128 | Motion blur image. |
| 2129 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2130 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2131 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2132 | if ((flags & SigmaValue) == 0) |
| 2133 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2134 | mogrify_image=MotionBlurImageChannel(*image,channel, |
| 2135 | geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2136 | break; |
| 2137 | } |
| 2138 | break; |
| 2139 | } |
| 2140 | case 'n': |
| 2141 | { |
| 2142 | if (LocaleCompare("negate",option+1) == 0) |
| 2143 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2144 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2145 | (void) NegateImageChannel(*image,channel,*option == '+' ? |
| 2146 | MagickTrue : MagickFalse); |
| 2147 | InheritException(exception,&(*image)->exception); |
| 2148 | break; |
| 2149 | } |
| 2150 | if (LocaleCompare("noise",option+1) == 0) |
| 2151 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2152 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2153 | if (*option == '-') |
| 2154 | { |
| 2155 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2156 | mogrify_image=StatisticImageChannel(*image,channel, |
cristy | 95c3834 | 2011-03-18 22:39:51 +0000 | [diff] [blame] | 2157 | NonpeakStatistic,(size_t) geometry_info.rho,(size_t) |
| 2158 | geometry_info.rho,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2159 | } |
| 2160 | else |
| 2161 | { |
| 2162 | NoiseType |
| 2163 | noise; |
| 2164 | |
| 2165 | noise=(NoiseType) ParseMagickOption(MagickNoiseOptions, |
| 2166 | MagickFalse,argv[i+1]); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2167 | mogrify_image=AddNoiseImageChannel(*image,channel,noise, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2168 | exception); |
| 2169 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2170 | break; |
| 2171 | } |
| 2172 | if (LocaleCompare("normalize",option+1) == 0) |
| 2173 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2174 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2175 | (void) NormalizeImageChannel(*image,channel); |
| 2176 | InheritException(exception,&(*image)->exception); |
| 2177 | break; |
| 2178 | } |
| 2179 | break; |
| 2180 | } |
| 2181 | case 'o': |
| 2182 | { |
| 2183 | if (LocaleCompare("opaque",option+1) == 0) |
| 2184 | { |
| 2185 | MagickPixelPacket |
| 2186 | target; |
| 2187 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2188 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2189 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2190 | (void) OpaquePaintImageChannel(*image,channel,&target,&fill, |
| 2191 | *option == '-' ? MagickFalse : MagickTrue); |
| 2192 | break; |
| 2193 | } |
| 2194 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2195 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2196 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2197 | (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1], |
| 2198 | exception); |
| 2199 | break; |
| 2200 | } |
| 2201 | break; |
| 2202 | } |
| 2203 | case 'p': |
| 2204 | { |
| 2205 | if (LocaleCompare("paint",option+1) == 0) |
| 2206 | { |
| 2207 | Image |
| 2208 | *paint_image; |
| 2209 | |
| 2210 | /* |
| 2211 | Oil paint image. |
| 2212 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2213 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2214 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2215 | paint_image=OilPaintImage(*image,geometry_info.rho,exception); |
| 2216 | if (paint_image == (Image *) NULL) |
| 2217 | break; |
| 2218 | *image=DestroyImage(*image); |
| 2219 | *image=paint_image; |
| 2220 | break; |
| 2221 | } |
| 2222 | if (LocaleCompare("pen",option+1) == 0) |
| 2223 | { |
| 2224 | if (*option == '+') |
| 2225 | { |
| 2226 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 2227 | break; |
| 2228 | } |
| 2229 | (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception); |
| 2230 | break; |
| 2231 | } |
| 2232 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2233 | { |
| 2234 | if (*option == '+') |
| 2235 | (void) ParseGeometry("12",&geometry_info); |
| 2236 | else |
| 2237 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2238 | draw_info->pointsize=geometry_info.rho; |
| 2239 | break; |
| 2240 | } |
| 2241 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2242 | { |
| 2243 | double |
| 2244 | angle; |
| 2245 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2246 | RandomInfo |
| 2247 | *random_info; |
| 2248 | |
| 2249 | /* |
| 2250 | Simulate a Polaroid picture. |
| 2251 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2252 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2253 | random_info=AcquireRandomInfo(); |
| 2254 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2255 | random_info=DestroyRandomInfo(random_info); |
| 2256 | if (*option == '-') |
| 2257 | { |
| 2258 | SetGeometryInfo(&geometry_info); |
| 2259 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2260 | angle=geometry_info.rho; |
| 2261 | } |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2262 | mogrify_image=PolaroidImage(*image,draw_info,angle,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2263 | break; |
| 2264 | } |
| 2265 | if (LocaleCompare("posterize",option+1) == 0) |
| 2266 | { |
| 2267 | /* |
| 2268 | Posterize image. |
| 2269 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2270 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 2271 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2272 | quantize_info->dither); |
| 2273 | InheritException(exception,&(*image)->exception); |
| 2274 | break; |
| 2275 | } |
| 2276 | if (LocaleCompare("preview",option+1) == 0) |
| 2277 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2278 | PreviewType |
| 2279 | preview_type; |
| 2280 | |
| 2281 | /* |
| 2282 | Preview image. |
| 2283 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2284 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2285 | if (*option == '+') |
| 2286 | preview_type=UndefinedPreview; |
| 2287 | else |
| 2288 | preview_type=(PreviewType) ParseMagickOption(MagickPreviewOptions, |
| 2289 | MagickFalse,argv[i+1]); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2290 | mogrify_image=PreviewImage(*image,preview_type,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2291 | break; |
| 2292 | } |
| 2293 | if (LocaleCompare("profile",option+1) == 0) |
| 2294 | { |
| 2295 | const char |
| 2296 | *name; |
| 2297 | |
| 2298 | const StringInfo |
| 2299 | *profile; |
| 2300 | |
| 2301 | Image |
| 2302 | *profile_image; |
| 2303 | |
| 2304 | ImageInfo |
| 2305 | *profile_info; |
| 2306 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2307 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2308 | if (*option == '+') |
| 2309 | { |
| 2310 | /* |
| 2311 | Remove a profile from the image. |
| 2312 | */ |
| 2313 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
| 2314 | NULL,0,MagickTrue); |
| 2315 | InheritException(exception,&(*image)->exception); |
| 2316 | break; |
| 2317 | } |
| 2318 | /* |
| 2319 | Associate a profile with the image. |
| 2320 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2321 | profile_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2322 | profile=GetImageProfile(*image,"iptc"); |
| 2323 | if (profile != (StringInfo *) NULL) |
| 2324 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2325 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2326 | profile_info=DestroyImageInfo(profile_info); |
| 2327 | if (profile_image == (Image *) NULL) |
| 2328 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2329 | StringInfo |
| 2330 | *profile; |
| 2331 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2332 | profile_info=CloneImageInfo(mogrify_info); |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2333 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2334 | MaxTextExtent); |
| 2335 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2336 | if (profile != (StringInfo *) NULL) |
| 2337 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2338 | (void) ProfileImage(*image,profile_info->magick, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2339 | GetStringInfoDatum(profile),(size_t) |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2340 | GetStringInfoLength(profile),MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2341 | profile=DestroyStringInfo(profile); |
| 2342 | } |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2343 | profile_info=DestroyImageInfo(profile_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2344 | break; |
| 2345 | } |
| 2346 | ResetImageProfileIterator(profile_image); |
| 2347 | name=GetNextImageProfile(profile_image); |
| 2348 | while (name != (const char *) NULL) |
| 2349 | { |
| 2350 | profile=GetImageProfile(profile_image,name); |
| 2351 | if (profile != (StringInfo *) NULL) |
| 2352 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2353 | (size_t) GetStringInfoLength(profile),MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2354 | name=GetNextImageProfile(profile_image); |
| 2355 | } |
| 2356 | profile_image=DestroyImage(profile_image); |
| 2357 | break; |
| 2358 | } |
| 2359 | break; |
| 2360 | } |
| 2361 | case 'q': |
| 2362 | { |
| 2363 | if (LocaleCompare("quantize",option+1) == 0) |
| 2364 | { |
| 2365 | if (*option == '+') |
| 2366 | { |
| 2367 | quantize_info->colorspace=UndefinedColorspace; |
| 2368 | break; |
| 2369 | } |
| 2370 | quantize_info->colorspace=(ColorspaceType) ParseMagickOption( |
| 2371 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2372 | break; |
| 2373 | } |
| 2374 | break; |
| 2375 | } |
| 2376 | case 'r': |
| 2377 | { |
| 2378 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2379 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2380 | /* |
| 2381 | Radial blur image. |
| 2382 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2383 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2384 | mogrify_image=RadialBlurImageChannel(*image,channel, |
cristy | a5447be | 2010-01-11 00:20:51 +0000 | [diff] [blame] | 2385 | StringToDouble(argv[i+1]),exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2386 | break; |
| 2387 | } |
| 2388 | if (LocaleCompare("raise",option+1) == 0) |
| 2389 | { |
| 2390 | /* |
| 2391 | Surround image with a raise of solid color. |
| 2392 | */ |
| 2393 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2394 | if ((flags & SigmaValue) == 0) |
| 2395 | geometry.height=geometry.width; |
| 2396 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
| 2397 | MagickFalse); |
| 2398 | InheritException(exception,&(*image)->exception); |
| 2399 | break; |
| 2400 | } |
| 2401 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2402 | { |
| 2403 | /* |
| 2404 | Threshold image. |
| 2405 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2406 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2407 | (void) RandomThresholdImageChannel(*image,channel,argv[i+1], |
| 2408 | exception); |
| 2409 | break; |
| 2410 | } |
| 2411 | if (LocaleCompare("recolor",option+1) == 0) |
| 2412 | { |
cristy | f055ae4 | 2010-04-02 23:01:38 +0000 | [diff] [blame] | 2413 | KernelInfo |
| 2414 | *kernel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2415 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2416 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f055ae4 | 2010-04-02 23:01:38 +0000 | [diff] [blame] | 2417 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2418 | if (kernel == (KernelInfo *) NULL) |
| 2419 | break; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2420 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
cristy | f055ae4 | 2010-04-02 23:01:38 +0000 | [diff] [blame] | 2421 | kernel=DestroyKernelInfo(kernel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2422 | break; |
| 2423 | } |
| 2424 | if (LocaleCompare("region",option+1) == 0) |
| 2425 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2426 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2427 | if (region_image != (Image *) NULL) |
| 2428 | { |
| 2429 | /* |
| 2430 | Composite region. |
| 2431 | */ |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 2432 | (void) CompositeImage(region_image, CopyCompositeOp,*image, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2433 | region_geometry.x,region_geometry.y); |
| 2434 | InheritException(exception,®ion_image->exception); |
| 2435 | *image=DestroyImage(*image); |
| 2436 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 2437 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2438 | } |
| 2439 | if (*option == '+') |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 2440 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2441 | /* |
| 2442 | Apply transformations to a selected region of the image. |
| 2443 | */ |
| 2444 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2445 | exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2446 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2447 | if (mogrify_image == (Image *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2448 | break; |
| 2449 | region_image=(*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2450 | *image=mogrify_image; |
| 2451 | mogrify_image=(Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2452 | break; |
| 2453 | } |
| 2454 | if (LocaleCompare("render",option+1) == 0) |
| 2455 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2456 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2457 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2458 | break; |
| 2459 | } |
| 2460 | if (LocaleCompare("remap",option+1) == 0) |
| 2461 | { |
| 2462 | Image |
| 2463 | *remap_image; |
| 2464 | |
| 2465 | /* |
| 2466 | Transform image colors to match this set of colors. |
| 2467 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2468 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2469 | if (*option == '+') |
| 2470 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2471 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2472 | if (remap_image == (Image *) NULL) |
| 2473 | break; |
| 2474 | (void) RemapImage(quantize_info,*image,remap_image); |
| 2475 | InheritException(exception,&(*image)->exception); |
| 2476 | remap_image=DestroyImage(remap_image); |
| 2477 | break; |
| 2478 | } |
| 2479 | if (LocaleCompare("repage",option+1) == 0) |
| 2480 | { |
| 2481 | if (*option == '+') |
| 2482 | { |
| 2483 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2484 | break; |
| 2485 | } |
| 2486 | (void) ResetImagePage(*image,argv[i+1]); |
| 2487 | InheritException(exception,&(*image)->exception); |
| 2488 | break; |
| 2489 | } |
| 2490 | if (LocaleCompare("resample",option+1) == 0) |
| 2491 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2492 | /* |
| 2493 | Resample image. |
| 2494 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2495 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2496 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2497 | if ((flags & SigmaValue) == 0) |
| 2498 | geometry_info.sigma=geometry_info.rho; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2499 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2500 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2501 | break; |
| 2502 | } |
| 2503 | if (LocaleCompare("resize",option+1) == 0) |
| 2504 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2505 | /* |
| 2506 | Resize image. |
| 2507 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2508 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2509 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2510 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2511 | (*image)->filter,(*image)->blur,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2512 | break; |
| 2513 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2514 | if (LocaleCompare("roll",option+1) == 0) |
| 2515 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2516 | /* |
| 2517 | Roll image. |
| 2518 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2519 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2520 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2521 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2522 | break; |
| 2523 | } |
| 2524 | if (LocaleCompare("rotate",option+1) == 0) |
| 2525 | { |
| 2526 | char |
| 2527 | *geometry; |
| 2528 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2529 | /* |
| 2530 | Check for conditional image rotation. |
| 2531 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2532 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2533 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2534 | if ((*image)->columns <= (*image)->rows) |
| 2535 | break; |
| 2536 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2537 | if ((*image)->columns >= (*image)->rows) |
| 2538 | break; |
| 2539 | /* |
| 2540 | Rotate image. |
| 2541 | */ |
| 2542 | geometry=ConstantString(argv[i+1]); |
| 2543 | (void) SubstituteString(&geometry,">",""); |
| 2544 | (void) SubstituteString(&geometry,"<",""); |
| 2545 | (void) ParseGeometry(geometry,&geometry_info); |
| 2546 | geometry=DestroyString(geometry); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2547 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2548 | break; |
| 2549 | } |
| 2550 | break; |
| 2551 | } |
| 2552 | case 's': |
| 2553 | { |
| 2554 | if (LocaleCompare("sample",option+1) == 0) |
| 2555 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2556 | /* |
| 2557 | Sample image with pixel replication. |
| 2558 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2559 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2560 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2561 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2562 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2563 | break; |
| 2564 | } |
| 2565 | if (LocaleCompare("scale",option+1) == 0) |
| 2566 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2567 | /* |
| 2568 | Resize image. |
| 2569 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2570 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2571 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2572 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2573 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2574 | break; |
| 2575 | } |
| 2576 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2577 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2578 | /* |
| 2579 | Selectively blur pixels within a contrast threshold. |
| 2580 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2581 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2582 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2583 | if ((flags & PercentValue) != 0) |
| 2584 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2585 | mogrify_image=SelectiveBlurImageChannel(*image,channel, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2586 | geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2587 | break; |
| 2588 | } |
| 2589 | if (LocaleCompare("separate",option+1) == 0) |
| 2590 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2591 | /* |
| 2592 | Break channels into separate images. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 2593 | WARNING: This can generate multiple images! |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2594 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2595 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2596 | mogrify_image=SeparateImages(*image,channel,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2597 | break; |
| 2598 | } |
| 2599 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2600 | { |
| 2601 | double |
| 2602 | threshold; |
| 2603 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2604 | /* |
| 2605 | Sepia-tone image. |
| 2606 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2607 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 2608 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2609 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2610 | break; |
| 2611 | } |
| 2612 | if (LocaleCompare("segment",option+1) == 0) |
| 2613 | { |
| 2614 | /* |
| 2615 | Segment image. |
| 2616 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2617 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2618 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2619 | if ((flags & SigmaValue) == 0) |
| 2620 | geometry_info.sigma=1.0; |
cristy | 7e6164a | 2010-07-22 20:43:57 +0000 | [diff] [blame] | 2621 | (void) SegmentImage(*image,(*image)->colorspace, |
| 2622 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2623 | InheritException(exception,&(*image)->exception); |
| 2624 | break; |
| 2625 | } |
| 2626 | if (LocaleCompare("set",option+1) == 0) |
| 2627 | { |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2628 | char |
| 2629 | *value; |
| 2630 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2631 | /* |
| 2632 | Set image option. |
| 2633 | */ |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2634 | if (*option == '+') |
| 2635 | { |
| 2636 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2637 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2638 | else |
| 2639 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
cristy | 7e10958 | 2010-06-01 12:56:44 +0000 | [diff] [blame] | 2640 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2641 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
cristy | 7e10958 | 2010-06-01 12:56:44 +0000 | [diff] [blame] | 2642 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2643 | } |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2644 | else |
| 2645 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2646 | break; |
| 2647 | } |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2648 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2649 | if (value == (char *) NULL) |
| 2650 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2651 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2652 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2653 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2654 | else |
| 2655 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2656 | { |
cristy | 7f02ba1 | 2010-09-21 12:39:28 +0000 | [diff] [blame] | 2657 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2658 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2659 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2660 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2661 | else |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2662 | (void) SetImageProperty(*image,argv[i+1],value); |
| 2663 | value=DestroyString(value); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2664 | break; |
| 2665 | } |
| 2666 | if (LocaleCompare("shade",option+1) == 0) |
| 2667 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2668 | /* |
| 2669 | Shade image. |
| 2670 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2671 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2672 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2673 | if ((flags & SigmaValue) == 0) |
| 2674 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2675 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2676 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2677 | break; |
| 2678 | } |
| 2679 | if (LocaleCompare("shadow",option+1) == 0) |
| 2680 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2681 | /* |
| 2682 | Shadow image. |
| 2683 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2684 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2685 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2686 | if ((flags & SigmaValue) == 0) |
| 2687 | geometry_info.sigma=1.0; |
| 2688 | if ((flags & XiValue) == 0) |
| 2689 | geometry_info.xi=4.0; |
| 2690 | if ((flags & PsiValue) == 0) |
| 2691 | geometry_info.psi=4.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2692 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
| 2693 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 2694 | ceil(geometry_info.psi-0.5),exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2695 | break; |
| 2696 | } |
| 2697 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2698 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2699 | /* |
| 2700 | Sharpen image. |
| 2701 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2702 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2703 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2704 | if ((flags & SigmaValue) == 0) |
| 2705 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2706 | mogrify_image=SharpenImageChannel(*image,channel,geometry_info.rho, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2707 | geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2708 | break; |
| 2709 | } |
| 2710 | if (LocaleCompare("shave",option+1) == 0) |
| 2711 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2712 | /* |
| 2713 | Shave the image edges. |
| 2714 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2715 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2716 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2717 | mogrify_image=ShaveImage(*image,&geometry,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2718 | break; |
| 2719 | } |
| 2720 | if (LocaleCompare("shear",option+1) == 0) |
| 2721 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2722 | /* |
| 2723 | Shear image. |
| 2724 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2725 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2726 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2727 | if ((flags & SigmaValue) == 0) |
| 2728 | geometry_info.sigma=geometry_info.rho; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2729 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2730 | geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2731 | break; |
| 2732 | } |
| 2733 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2734 | { |
| 2735 | /* |
| 2736 | Sigmoidal non-linearity contrast control. |
| 2737 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2738 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2739 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2740 | if ((flags & SigmaValue) == 0) |
| 2741 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 2742 | if ((flags & PercentValue) != 0) |
| 2743 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2744 | 100.0; |
| 2745 | (void) SigmoidalContrastImageChannel(*image,channel, |
| 2746 | (*option == '-') ? MagickTrue : MagickFalse,geometry_info.rho, |
| 2747 | geometry_info.sigma); |
| 2748 | InheritException(exception,&(*image)->exception); |
| 2749 | break; |
| 2750 | } |
| 2751 | if (LocaleCompare("sketch",option+1) == 0) |
| 2752 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2753 | /* |
| 2754 | Sketch image. |
| 2755 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2756 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2757 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2758 | if ((flags & SigmaValue) == 0) |
| 2759 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2760 | mogrify_image=SketchImage(*image,geometry_info.rho, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2761 | geometry_info.sigma,geometry_info.xi,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2762 | break; |
| 2763 | } |
| 2764 | if (LocaleCompare("solarize",option+1) == 0) |
| 2765 | { |
| 2766 | double |
| 2767 | threshold; |
| 2768 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2769 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 2770 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2771 | (void) SolarizeImage(*image,threshold); |
| 2772 | InheritException(exception,&(*image)->exception); |
| 2773 | break; |
| 2774 | } |
| 2775 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2776 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2777 | SparseColorMethod |
| 2778 | method; |
| 2779 | |
| 2780 | char |
| 2781 | *arguments; |
| 2782 | |
| 2783 | /* |
| 2784 | Sparse Color Interpolated Gradient |
| 2785 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2786 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2787 | method=(SparseColorMethod) ParseMagickOption( |
| 2788 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2789 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2790 | InheritException(exception,&(*image)->exception); |
| 2791 | if (arguments == (char *) NULL) |
| 2792 | break; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2793 | mogrify_image=SparseColorOption(*image,channel,method,arguments, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2794 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2795 | arguments=DestroyString(arguments); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2796 | break; |
| 2797 | } |
| 2798 | if (LocaleCompare("splice",option+1) == 0) |
| 2799 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2800 | /* |
| 2801 | Splice a solid color into the image. |
| 2802 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2803 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2804 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2805 | mogrify_image=SpliceImage(*image,&geometry,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2806 | break; |
| 2807 | } |
| 2808 | if (LocaleCompare("spread",option+1) == 0) |
| 2809 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2810 | /* |
| 2811 | Spread an image. |
| 2812 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2813 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2814 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2815 | mogrify_image=SpreadImage(*image,geometry_info.rho,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2816 | break; |
| 2817 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 2818 | if (LocaleCompare("statistic",option+1) == 0) |
| 2819 | { |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 2820 | StatisticType |
| 2821 | type; |
| 2822 | |
| 2823 | (void) SyncImageSettings(mogrify_info,*image); |
| 2824 | type=(StatisticType) ParseMagickOption(MagickStatisticOptions, |
| 2825 | MagickFalse,argv[i+1]); |
| 2826 | (void) ParseGeometry(argv[i+2],&geometry_info); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2827 | mogrify_image=StatisticImageChannel(*image,channel,type,(size_t) |
| 2828 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 2829 | break; |
| 2830 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2831 | if (LocaleCompare("stretch",option+1) == 0) |
| 2832 | { |
| 2833 | if (*option == '+') |
| 2834 | { |
| 2835 | draw_info->stretch=UndefinedStretch; |
| 2836 | break; |
| 2837 | } |
| 2838 | draw_info->stretch=(StretchType) ParseMagickOption( |
| 2839 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2840 | break; |
| 2841 | } |
| 2842 | if (LocaleCompare("strip",option+1) == 0) |
| 2843 | { |
| 2844 | /* |
| 2845 | Strip image of profiles and comments. |
| 2846 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2847 | (void) SyncImageSettings(mogrify_info,*image); |
glennrp | 3dae5ae | 2010-12-23 22:42:52 +0000 | [diff] [blame] | 2848 | (void) StripImage(*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2849 | InheritException(exception,&(*image)->exception); |
| 2850 | break; |
| 2851 | } |
| 2852 | if (LocaleCompare("stroke",option+1) == 0) |
| 2853 | { |
| 2854 | ExceptionInfo |
| 2855 | *sans; |
| 2856 | |
| 2857 | if (*option == '+') |
| 2858 | { |
| 2859 | (void) QueryColorDatabase("none",&draw_info->stroke,exception); |
| 2860 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2861 | draw_info->stroke_pattern=DestroyImage( |
| 2862 | draw_info->stroke_pattern); |
| 2863 | break; |
| 2864 | } |
| 2865 | sans=AcquireExceptionInfo(); |
| 2866 | status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans); |
| 2867 | sans=DestroyExceptionInfo(sans); |
| 2868 | if (status == MagickFalse) |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2869 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2870 | exception); |
| 2871 | break; |
| 2872 | } |
| 2873 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2874 | { |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 2875 | draw_info->stroke_width=StringToDouble(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2876 | break; |
| 2877 | } |
| 2878 | if (LocaleCompare("style",option+1) == 0) |
| 2879 | { |
| 2880 | if (*option == '+') |
| 2881 | { |
| 2882 | draw_info->style=UndefinedStyle; |
| 2883 | break; |
| 2884 | } |
| 2885 | draw_info->style=(StyleType) ParseMagickOption(MagickStyleOptions, |
| 2886 | MagickFalse,argv[i+1]); |
| 2887 | break; |
| 2888 | } |
| 2889 | if (LocaleCompare("swirl",option+1) == 0) |
| 2890 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2891 | /* |
| 2892 | Swirl image. |
| 2893 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2894 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2895 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2896 | mogrify_image=SwirlImage(*image,geometry_info.rho,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2897 | break; |
| 2898 | } |
| 2899 | break; |
| 2900 | } |
| 2901 | case 't': |
| 2902 | { |
| 2903 | if (LocaleCompare("threshold",option+1) == 0) |
| 2904 | { |
| 2905 | double |
| 2906 | threshold; |
| 2907 | |
| 2908 | /* |
| 2909 | Threshold image. |
| 2910 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2911 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2912 | if (*option == '+') |
| 2913 | threshold=(double) QuantumRange/2.5; |
| 2914 | else |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 2915 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2916 | (void) BilevelImageChannel(*image,channel,threshold); |
| 2917 | InheritException(exception,&(*image)->exception); |
| 2918 | break; |
| 2919 | } |
| 2920 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2921 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2922 | /* |
| 2923 | Thumbnail image. |
| 2924 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2925 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2926 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2927 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2928 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2929 | break; |
| 2930 | } |
| 2931 | if (LocaleCompare("tile",option+1) == 0) |
| 2932 | { |
| 2933 | if (*option == '+') |
| 2934 | { |
| 2935 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2936 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2937 | break; |
| 2938 | } |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2939 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2940 | exception); |
| 2941 | break; |
| 2942 | } |
| 2943 | if (LocaleCompare("tint",option+1) == 0) |
| 2944 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2945 | /* |
| 2946 | Tint the image. |
| 2947 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2948 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2949 | mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2950 | break; |
| 2951 | } |
| 2952 | if (LocaleCompare("transform",option+1) == 0) |
| 2953 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2954 | /* |
| 2955 | Affine transform image. |
| 2956 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2957 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2958 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2959 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2960 | break; |
| 2961 | } |
| 2962 | if (LocaleCompare("transparent",option+1) == 0) |
| 2963 | { |
| 2964 | MagickPixelPacket |
| 2965 | target; |
| 2966 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2967 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2968 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2969 | (void) TransparentPaintImage(*image,&target,(Quantum) |
| 2970 | TransparentOpacity,*option == '-' ? MagickFalse : MagickTrue); |
| 2971 | InheritException(exception,&(*image)->exception); |
| 2972 | break; |
| 2973 | } |
| 2974 | if (LocaleCompare("transpose",option+1) == 0) |
| 2975 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2976 | /* |
| 2977 | Transpose image scanlines. |
| 2978 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2979 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2980 | mogrify_image=TransposeImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2981 | break; |
| 2982 | } |
| 2983 | if (LocaleCompare("transverse",option+1) == 0) |
| 2984 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2985 | /* |
| 2986 | Transverse image scanlines. |
| 2987 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2988 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2989 | mogrify_image=TransverseImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2990 | break; |
| 2991 | } |
| 2992 | if (LocaleCompare("treedepth",option+1) == 0) |
| 2993 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 2994 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2995 | break; |
| 2996 | } |
| 2997 | if (LocaleCompare("trim",option+1) == 0) |
| 2998 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2999 | /* |
| 3000 | Trim image. |
| 3001 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3002 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 3003 | mogrify_image=TrimImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3004 | break; |
| 3005 | } |
| 3006 | if (LocaleCompare("type",option+1) == 0) |
| 3007 | { |
| 3008 | ImageType |
| 3009 | type; |
| 3010 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3011 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3012 | if (*option == '+') |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 3013 | type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3014 | else |
| 3015 | type=(ImageType) ParseMagickOption(MagickTypeOptions,MagickFalse, |
| 3016 | argv[i+1]); |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 3017 | (*image)->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3018 | (void) SetImageType(*image,type); |
| 3019 | InheritException(exception,&(*image)->exception); |
| 3020 | break; |
| 3021 | } |
| 3022 | break; |
| 3023 | } |
| 3024 | case 'u': |
| 3025 | { |
| 3026 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3027 | { |
| 3028 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 3029 | exception); |
| 3030 | break; |
| 3031 | } |
cristy | 045bd90 | 2010-01-30 18:56:24 +0000 | [diff] [blame] | 3032 | if (LocaleCompare("unique",option+1) == 0) |
| 3033 | { |
| 3034 | if (*option == '+') |
| 3035 | { |
cristy | 83fae87 | 2010-04-22 15:04:16 +0000 | [diff] [blame] | 3036 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
cristy | 045bd90 | 2010-01-30 18:56:24 +0000 | [diff] [blame] | 3037 | break; |
| 3038 | } |
cristy | 83fae87 | 2010-04-22 15:04:16 +0000 | [diff] [blame] | 3039 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
cristy | a01cbea | 2010-11-03 16:33:33 +0000 | [diff] [blame] | 3040 | (void) SetImageArtifact(*image,"verbose","true"); |
cristy | 045bd90 | 2010-01-30 18:56:24 +0000 | [diff] [blame] | 3041 | break; |
| 3042 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3043 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3044 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3045 | /* |
| 3046 | Unique image colors. |
| 3047 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3048 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 3049 | mogrify_image=UniqueImageColors(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3050 | break; |
| 3051 | } |
| 3052 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3053 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3054 | /* |
| 3055 | Unsharp mask image. |
| 3056 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3057 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3058 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3059 | if ((flags & SigmaValue) == 0) |
| 3060 | geometry_info.sigma=1.0; |
| 3061 | if ((flags & XiValue) == 0) |
| 3062 | geometry_info.xi=1.0; |
| 3063 | if ((flags & PsiValue) == 0) |
| 3064 | geometry_info.psi=0.05; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 3065 | mogrify_image=UnsharpMaskImageChannel(*image,channel, |
| 3066 | geometry_info.rho,geometry_info.sigma,geometry_info.xi, |
| 3067 | geometry_info.psi,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3068 | break; |
| 3069 | } |
| 3070 | break; |
| 3071 | } |
| 3072 | case 'v': |
| 3073 | { |
| 3074 | if (LocaleCompare("verbose",option+1) == 0) |
| 3075 | { |
| 3076 | (void) SetImageArtifact(*image,option+1, |
| 3077 | *option == '+' ? "false" : "true"); |
| 3078 | break; |
| 3079 | } |
| 3080 | if (LocaleCompare("vignette",option+1) == 0) |
| 3081 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3082 | /* |
| 3083 | Vignette image. |
| 3084 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3085 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3086 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3087 | if ((flags & SigmaValue) == 0) |
| 3088 | geometry_info.sigma=1.0; |
| 3089 | if ((flags & XiValue) == 0) |
| 3090 | geometry_info.xi=0.1*(*image)->columns; |
| 3091 | if ((flags & PsiValue) == 0) |
| 3092 | geometry_info.psi=0.1*(*image)->rows; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 3093 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3094 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
cristy | 0534a6b | 2010-03-18 01:19:38 +0000 | [diff] [blame] | 3095 | ceil(geometry_info.psi-0.5),exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3096 | break; |
| 3097 | } |
| 3098 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3099 | { |
| 3100 | if (*option == '+') |
| 3101 | { |
| 3102 | (void) SetImageVirtualPixelMethod(*image, |
| 3103 | UndefinedVirtualPixelMethod); |
| 3104 | break; |
| 3105 | } |
| 3106 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3107 | ParseMagickOption(MagickVirtualPixelOptions,MagickFalse, |
| 3108 | argv[i+1])); |
| 3109 | break; |
| 3110 | } |
| 3111 | break; |
| 3112 | } |
| 3113 | case 'w': |
| 3114 | { |
| 3115 | if (LocaleCompare("wave",option+1) == 0) |
| 3116 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3117 | /* |
| 3118 | Wave image. |
| 3119 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3120 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3121 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3122 | if ((flags & SigmaValue) == 0) |
| 3123 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 3124 | mogrify_image=WaveImage(*image,geometry_info.rho, |
| 3125 | geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3126 | break; |
| 3127 | } |
| 3128 | if (LocaleCompare("weight",option+1) == 0) |
| 3129 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 3130 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3131 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3132 | draw_info->weight=0; |
| 3133 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3134 | draw_info->weight=700; |
| 3135 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3136 | if (draw_info->weight <= 800) |
| 3137 | draw_info->weight+=100; |
| 3138 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3139 | if (draw_info->weight >= 100) |
| 3140 | draw_info->weight-=100; |
| 3141 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3142 | draw_info->weight=400; |
| 3143 | break; |
| 3144 | } |
| 3145 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3146 | { |
| 3147 | /* |
| 3148 | White threshold image. |
| 3149 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3150 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3151 | (void) WhiteThresholdImageChannel(*image,channel,argv[i+1], |
| 3152 | exception); |
| 3153 | InheritException(exception,&(*image)->exception); |
| 3154 | break; |
| 3155 | } |
| 3156 | break; |
| 3157 | } |
| 3158 | default: |
| 3159 | break; |
| 3160 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3161 | /* |
| 3162 | Replace current image with any image that was generated |
| 3163 | */ |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 3164 | if (mogrify_image != (Image *) NULL) |
| 3165 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3166 | i+=count; |
| 3167 | } |
| 3168 | if (region_image != (Image *) NULL) |
| 3169 | { |
| 3170 | /* |
| 3171 | Composite transformed region onto image. |
| 3172 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3173 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3174 | (void) CompositeImage(region_image,CopyCompositeOp,*image, |
| 3175 | region_geometry.x,region_geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3176 | InheritException(exception,®ion_image->exception); |
| 3177 | *image=DestroyImage(*image); |
| 3178 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3179 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3180 | } |
| 3181 | /* |
| 3182 | Free resources. |
| 3183 | */ |
| 3184 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3185 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3186 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame^] | 3187 | status=(*image)->exception.severity == UndefinedException ? 1 : 0; |
| 3188 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3189 | } |
| 3190 | |
| 3191 | /* |
| 3192 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3193 | % % |
| 3194 | % % |
| 3195 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3196 | + 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] | 3197 | % % |
| 3198 | % % |
| 3199 | % % |
| 3200 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3201 | % |
| 3202 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3203 | % transforms include image scaling, image rotation, color reduction, and |
| 3204 | % others. The transmogrified image overwrites the original image. |
| 3205 | % |
| 3206 | % The format of the MogrifyImageCommand method is: |
| 3207 | % |
| 3208 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3209 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3210 | % |
| 3211 | % A description of each parameter follows: |
| 3212 | % |
| 3213 | % o image_info: the image info. |
| 3214 | % |
| 3215 | % o argc: the number of elements in the argument vector. |
| 3216 | % |
| 3217 | % o argv: A text array containing the command line arguments. |
| 3218 | % |
| 3219 | % o metadata: any metadata is returned here. |
| 3220 | % |
| 3221 | % o exception: return any errors or warnings in this structure. |
| 3222 | % |
| 3223 | */ |
| 3224 | |
| 3225 | static MagickBooleanType MogrifyUsage(void) |
| 3226 | { |
| 3227 | static const char |
| 3228 | *miscellaneous[]= |
| 3229 | { |
| 3230 | "-debug events display copious debugging information", |
| 3231 | "-help print program options", |
| 3232 | "-list type print a list of supported option arguments", |
| 3233 | "-log format format of debugging information", |
| 3234 | "-version print version information", |
| 3235 | (char *) NULL |
| 3236 | }, |
| 3237 | *operators[]= |
| 3238 | { |
| 3239 | "-adaptive-blur geometry", |
| 3240 | " adaptively blur pixels; decrease effect near edges", |
| 3241 | "-adaptive-resize geometry", |
| 3242 | " adaptively resize image using 'mesh' interpolation", |
| 3243 | "-adaptive-sharpen geometry", |
| 3244 | " adaptively sharpen pixels; increase effect near edges", |
| 3245 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3246 | " transparent, extract, background, or shape", |
| 3247 | "-annotate geometry text", |
| 3248 | " annotate the image with text", |
| 3249 | "-auto-gamma automagically adjust gamma level of image", |
| 3250 | "-auto-level automagically adjust color levels of image", |
| 3251 | "-auto-orient automagically orient (rotate) image", |
| 3252 | "-bench iterations measure performance", |
| 3253 | "-black-threshold value", |
| 3254 | " force all pixels below the threshold into black", |
| 3255 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3256 | "-blur geometry reduce image noise and reduce detail levels", |
| 3257 | "-border geometry surround image with a border of color", |
| 3258 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3259 | "-brightness-contrast geometry", |
| 3260 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3261 | "-cdl filename color correct with a color decision list", |
| 3262 | "-charcoal radius simulate a charcoal drawing", |
| 3263 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3264 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3265 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3266 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3267 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3268 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3269 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3270 | "-contrast enhance or reduce the image contrast", |
| 3271 | "-contrast-stretch geometry", |
| 3272 | " improve contrast by `stretching' the intensity range", |
| 3273 | "-convolve coefficients", |
| 3274 | " apply a convolution kernel to the image", |
| 3275 | "-cycle amount cycle the image colormap", |
| 3276 | "-decipher filename convert cipher pixels to plain pixels", |
| 3277 | "-deskew threshold straighten an image", |
| 3278 | "-despeckle reduce the speckles within an image", |
| 3279 | "-distort method args", |
| 3280 | " distort images according to given method ad args", |
| 3281 | "-draw string annotate the image with a graphic primitive", |
| 3282 | "-edge radius apply a filter to detect edges in the image", |
| 3283 | "-encipher filename convert plain pixels to cipher pixels", |
| 3284 | "-emboss radius emboss an image", |
| 3285 | "-enhance apply a digital filter to enhance a noisy image", |
| 3286 | "-equalize perform histogram equalization to an image", |
| 3287 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3288 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3289 | "-extent geometry set the image size", |
| 3290 | "-extract geometry extract area from image", |
| 3291 | "-fft implements the discrete Fourier transform (DFT)", |
| 3292 | "-flip flip image vertically", |
| 3293 | "-floodfill geometry color", |
| 3294 | " floodfill the image with color", |
| 3295 | "-flop flop image horizontally", |
| 3296 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3297 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3298 | " apply function over image values", |
| 3299 | "-gamma value level of gamma correction", |
| 3300 | "-gaussian-blur geometry", |
| 3301 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3302 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3303 | "-identify identify the format and characteristics of the image", |
| 3304 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3305 | "-implode amount implode image pixels about the center", |
| 3306 | "-lat geometry local adaptive thresholding", |
| 3307 | "-layers method optimize, merge, or compare image layers", |
| 3308 | "-level value adjust the level of image contrast", |
| 3309 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3310 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3311 | "-linear-stretch geometry", |
| 3312 | " improve contrast by `stretching with saturation'", |
| 3313 | "-liquid-rescale geometry", |
| 3314 | " rescale image with seam-carving", |
| 3315 | "-median radius apply a median filter to the image", |
cristy | 2ecd9be | 2011-02-28 01:17:26 +0000 | [diff] [blame] | 3316 | "-mode radius make each pixel the 'predominate color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3317 | "-modulate value vary the brightness, saturation, and hue", |
| 3318 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3319 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3320 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3321 | "-motion-blur geometry", |
| 3322 | " simulate motion blur", |
| 3323 | "-negate replace every pixel with its complementary color ", |
| 3324 | "-noise radius add or reduce noise in an image", |
| 3325 | "-normalize transform image to span the full range of colors", |
| 3326 | "-opaque color change this color to the fill color", |
| 3327 | "-ordered-dither NxN", |
| 3328 | " add a noise pattern to the image with specific", |
| 3329 | " amplitudes", |
| 3330 | "-paint radius simulate an oil painting", |
| 3331 | "-polaroid angle simulate a Polaroid picture", |
| 3332 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3333 | "-profile filename add, delete, or apply an image profile", |
| 3334 | "-quantize colorspace reduce colors in this colorspace", |
| 3335 | "-radial-blur angle radial blur the image", |
| 3336 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3337 | "-random-threshold low,high", |
| 3338 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3339 | "-region geometry apply options to a portion of the image", |
| 3340 | "-render render vector graphics", |
| 3341 | "-repage geometry size and location of an image canvas", |
| 3342 | "-resample geometry change the resolution of an image", |
| 3343 | "-resize geometry resize the image", |
| 3344 | "-roll geometry roll an image vertically or horizontally", |
| 3345 | "-rotate degrees apply Paeth rotation to the image", |
| 3346 | "-sample geometry scale image with pixel sampling", |
| 3347 | "-scale geometry scale the image", |
| 3348 | "-segment values segment an image", |
| 3349 | "-selective-blur geometry", |
| 3350 | " selectively blur pixels within a contrast threshold", |
| 3351 | "-sepia-tone threshold", |
| 3352 | " simulate a sepia-toned photo", |
| 3353 | "-set property value set an image property", |
| 3354 | "-shade degrees shade the image using a distant light source", |
| 3355 | "-shadow geometry simulate an image shadow", |
| 3356 | "-sharpen geometry sharpen the image", |
| 3357 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3358 | "-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] | 3359 | "-sigmoidal-contrast geometry", |
| 3360 | " increase the contrast without saturating highlights or shadows", |
| 3361 | "-sketch geometry simulate a pencil sketch", |
| 3362 | "-solarize threshold negate all pixels above the threshold level", |
| 3363 | "-sparse-color method args", |
| 3364 | " fill in a image based on a few color points", |
| 3365 | "-splice geometry splice the background color into the image", |
| 3366 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3367 | "-statistic type radius", |
| 3368 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3369 | "-strip strip image of all profiles and comments", |
| 3370 | "-swirl degrees swirl image pixels about the center", |
| 3371 | "-threshold value threshold the image", |
| 3372 | "-thumbnail geometry create a thumbnail of the image", |
| 3373 | "-tile filename tile image when filling a graphic primitive", |
| 3374 | "-tint value tint the image with the fill color", |
| 3375 | "-transform affine transform image", |
| 3376 | "-transparent color make this color transparent within the image", |
| 3377 | "-transpose flip image vertically and rotate 90 degrees", |
| 3378 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3379 | "-trim trim image edges", |
| 3380 | "-type type image type", |
| 3381 | "-unique-colors discard all but one of any pixel color", |
| 3382 | "-unsharp geometry sharpen the image", |
| 3383 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3384 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3385 | "-white-threshold value", |
| 3386 | " force all pixels above the threshold into white", |
| 3387 | (char *) NULL |
| 3388 | }, |
| 3389 | *sequence_operators[]= |
| 3390 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3391 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3392 | "-clut apply a color lookup table to the image", |
| 3393 | "-coalesce merge a sequence of images", |
| 3394 | "-combine combine a sequence of images", |
| 3395 | "-composite composite image", |
| 3396 | "-crop geometry cut out a rectangular region of the image", |
| 3397 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3398 | "-evaluate-sequence operator", |
| 3399 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3400 | "-flatten flatten a sequence of images", |
| 3401 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3402 | "-hald-clut apply a Hald color lookup table to the image", |
| 3403 | "-morph value morph an image sequence", |
| 3404 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3405 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3406 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3407 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3408 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3409 | "-write filename write images to this file", |
| 3410 | (char *) NULL |
| 3411 | }, |
| 3412 | *settings[]= |
| 3413 | { |
| 3414 | "-adjoin join images into a single multi-image file", |
| 3415 | "-affine matrix affine transform matrix", |
| 3416 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3417 | "-antialias remove pixel-aliasing", |
| 3418 | "-authenticate password", |
| 3419 | " decipher image with this password", |
| 3420 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3421 | "-background color background color", |
| 3422 | "-bias value add bias when convolving an image", |
| 3423 | "-black-point-compensation", |
| 3424 | " use black point compensation", |
| 3425 | "-blue-primary point chromaticity blue primary point", |
| 3426 | "-bordercolor color border color", |
| 3427 | "-caption string assign a caption to an image", |
| 3428 | "-channel type apply option to select image channels", |
| 3429 | "-colors value preferred number of colors in the image", |
| 3430 | "-colorspace type alternate image colorspace", |
| 3431 | "-comment string annotate image with comment", |
| 3432 | "-compose operator set image composite operator", |
| 3433 | "-compress type type of pixel compression when writing the image", |
| 3434 | "-define format:option", |
| 3435 | " define one or more image format options", |
| 3436 | "-delay value display the next image after pausing", |
| 3437 | "-density geometry horizontal and vertical density of the image", |
| 3438 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3439 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3440 | "-display server get image or font from this X server", |
| 3441 | "-dispose method layer disposal method", |
| 3442 | "-dither method apply error diffusion to image", |
| 3443 | "-encoding type text encoding type", |
| 3444 | "-endian type endianness (MSB or LSB) of the image", |
| 3445 | "-family name render text with this font family", |
| 3446 | "-fill color color to use when filling a graphic primitive", |
| 3447 | "-filter type use this filter when resizing an image", |
| 3448 | "-font name render text with this font", |
| 3449 | "-format \"string\" output formatted image characteristics", |
| 3450 | "-fuzz distance colors within this distance are considered equal", |
| 3451 | "-gravity type horizontal and vertical text placement", |
| 3452 | "-green-primary point chromaticity green primary point", |
| 3453 | "-intent type type of rendering intent when managing the image color", |
| 3454 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3455 | "-interline-spacing value", |
| 3456 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3457 | "-interpolate method pixel color interpolation method", |
| 3458 | "-interword-spacing value", |
| 3459 | " set the space between two words", |
| 3460 | "-kerning value set the space between two letters", |
| 3461 | "-label string assign a label to an image", |
| 3462 | "-limit type value pixel cache resource limit", |
| 3463 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3464 | "-mask filename associate a mask with the image", |
| 3465 | "-mattecolor color frame color", |
| 3466 | "-monitor monitor progress", |
| 3467 | "-orient type image orientation", |
| 3468 | "-page geometry size and location of an image canvas (setting)", |
| 3469 | "-ping efficiently determine image attributes", |
| 3470 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3471 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3472 | "-preview type image preview type", |
| 3473 | "-quality value JPEG/MIFF/PNG compression level", |
| 3474 | "-quiet suppress all warning messages", |
| 3475 | "-red-primary point chromaticity red primary point", |
| 3476 | "-regard-warnings pay attention to warning messages", |
| 3477 | "-remap filename transform image colors to match this set of colors", |
| 3478 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3479 | "-sampling-factor geometry", |
| 3480 | " horizontal and vertical sampling factor", |
| 3481 | "-scene value image scene number", |
| 3482 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3483 | "-size geometry width and height of image", |
| 3484 | "-stretch type render text with this font stretch", |
| 3485 | "-stroke color graphic primitive stroke color", |
| 3486 | "-strokewidth value graphic primitive stroke width", |
| 3487 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3488 | "-synchronize synchronize image to storage device", |
| 3489 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3490 | "-texture filename name of texture to tile onto the image background", |
| 3491 | "-tile-offset geometry", |
| 3492 | " tile offset", |
| 3493 | "-treedepth value color tree depth", |
| 3494 | "-transparent-color color", |
| 3495 | " transparent color", |
| 3496 | "-undercolor color annotation bounding box color", |
| 3497 | "-units type the units of image resolution", |
| 3498 | "-verbose print detailed information about the image", |
| 3499 | "-view FlashPix viewing transforms", |
| 3500 | "-virtual-pixel method", |
| 3501 | " virtual pixel access method", |
| 3502 | "-weight type render text with this font weight", |
| 3503 | "-white-point point chromaticity white point", |
| 3504 | (char *) NULL |
| 3505 | }, |
| 3506 | *stack_operators[]= |
| 3507 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3508 | "-delete indexes delete the image from the image sequence", |
| 3509 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3510 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3511 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3512 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3513 | "-swap indexes swap two images in the image sequence", |
| 3514 | (char *) NULL |
| 3515 | }; |
| 3516 | |
| 3517 | const char |
| 3518 | **p; |
| 3519 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3520 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3521 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3522 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3523 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3524 | GetClientName()); |
| 3525 | (void) printf("\nImage Settings:\n"); |
| 3526 | for (p=settings; *p != (char *) NULL; p++) |
| 3527 | (void) printf(" %s\n",*p); |
| 3528 | (void) printf("\nImage Operators:\n"); |
| 3529 | for (p=operators; *p != (char *) NULL; p++) |
| 3530 | (void) printf(" %s\n",*p); |
| 3531 | (void) printf("\nImage Sequence Operators:\n"); |
| 3532 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3533 | (void) printf(" %s\n",*p); |
| 3534 | (void) printf("\nImage Stack Operators:\n"); |
| 3535 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3536 | (void) printf(" %s\n",*p); |
| 3537 | (void) printf("\nMiscellaneous Options:\n"); |
| 3538 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3539 | (void) printf(" %s\n",*p); |
| 3540 | (void) printf( |
| 3541 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3542 | (void) printf( |
| 3543 | "number. To specify a particular image format, precede the filename\n"); |
| 3544 | (void) printf( |
| 3545 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3546 | (void) printf( |
| 3547 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3548 | (void) printf("'-' for standard input or output.\n"); |
| 3549 | return(MagickFalse); |
| 3550 | } |
| 3551 | |
| 3552 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3553 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3554 | { |
| 3555 | #define DestroyMogrify() \ |
| 3556 | { \ |
| 3557 | if (format != (char *) NULL) \ |
| 3558 | format=DestroyString(format); \ |
| 3559 | if (path != (char *) NULL) \ |
| 3560 | path=DestroyString(path); \ |
| 3561 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3562 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3563 | argv[i]=DestroyString(argv[i]); \ |
| 3564 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3565 | } |
| 3566 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3567 | { \ |
| 3568 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3569 | option); \ |
| 3570 | DestroyMogrify(); \ |
| 3571 | return(MagickFalse); \ |
| 3572 | } |
| 3573 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3574 | { \ |
| 3575 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3576 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3577 | DestroyMogrify(); \ |
| 3578 | return(MagickFalse); \ |
| 3579 | } |
| 3580 | |
| 3581 | char |
| 3582 | *format, |
| 3583 | *option, |
| 3584 | *path; |
| 3585 | |
| 3586 | Image |
| 3587 | *image; |
| 3588 | |
| 3589 | ImageStack |
| 3590 | image_stack[MaxImageStackDepth+1]; |
| 3591 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3592 | MagickBooleanType |
| 3593 | global_colormap; |
| 3594 | |
| 3595 | MagickBooleanType |
| 3596 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3597 | pend, |
| 3598 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3599 | |
| 3600 | MagickStatusType |
| 3601 | status; |
| 3602 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3603 | register ssize_t |
| 3604 | i; |
| 3605 | |
| 3606 | ssize_t |
| 3607 | j, |
| 3608 | k; |
| 3609 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3610 | /* |
| 3611 | Set defaults. |
| 3612 | */ |
| 3613 | assert(image_info != (ImageInfo *) NULL); |
| 3614 | assert(image_info->signature == MagickSignature); |
| 3615 | if (image_info->debug != MagickFalse) |
| 3616 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3617 | assert(exception != (ExceptionInfo *) NULL); |
| 3618 | if (argc == 2) |
| 3619 | { |
| 3620 | option=argv[1]; |
| 3621 | if ((LocaleCompare("version",option+1) == 0) || |
| 3622 | (LocaleCompare("-version",option+1) == 0)) |
| 3623 | { |
| 3624 | (void) fprintf(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3625 | GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3626 | (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright()); |
| 3627 | (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3628 | return(MagickFalse); |
| 3629 | } |
| 3630 | } |
| 3631 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3632 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3633 | format=(char *) NULL; |
| 3634 | path=(char *) NULL; |
| 3635 | global_colormap=MagickFalse; |
| 3636 | k=0; |
| 3637 | j=1; |
| 3638 | NewImageStack(); |
| 3639 | option=(char *) NULL; |
| 3640 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3641 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3642 | status=MagickTrue; |
| 3643 | /* |
| 3644 | Parse command line. |
| 3645 | */ |
| 3646 | ReadCommandlLine(argc,&argv); |
| 3647 | status=ExpandFilenames(&argc,&argv); |
| 3648 | if (status == MagickFalse) |
| 3649 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3650 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3651 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3652 | { |
| 3653 | option=argv[i]; |
| 3654 | if (LocaleCompare(option,"(") == 0) |
| 3655 | { |
| 3656 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3657 | if (k == MaxImageStackDepth) |
| 3658 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3659 | option); |
| 3660 | PushImageStack(); |
| 3661 | continue; |
| 3662 | } |
| 3663 | if (LocaleCompare(option,")") == 0) |
| 3664 | { |
| 3665 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3666 | if (k == 0) |
| 3667 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3668 | PopImageStack(); |
| 3669 | continue; |
| 3670 | } |
| 3671 | if (IsMagickOption(option) == MagickFalse) |
| 3672 | { |
| 3673 | char |
| 3674 | backup_filename[MaxTextExtent], |
| 3675 | *filename; |
| 3676 | |
| 3677 | Image |
| 3678 | *images; |
| 3679 | |
| 3680 | /* |
| 3681 | Option is a file name: begin by reading image from specified file. |
| 3682 | */ |
| 3683 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3684 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3685 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3686 | filename=argv[++i]; |
| 3687 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 3688 | images=ReadImages(image_info,exception); |
| 3689 | status&=(images != (Image *) NULL) && |
| 3690 | (exception->severity < ErrorException); |
| 3691 | if (images == (Image *) NULL) |
| 3692 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3693 | if (format != (char *) NULL) |
| 3694 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3695 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3696 | if (path != (char *) NULL) |
| 3697 | { |
| 3698 | GetPathComponent(option,TailPath,filename); |
| 3699 | (void) FormatMagickString(images->filename,MaxTextExtent,"%s%c%s", |
| 3700 | path,*DirectorySeparator,filename); |
| 3701 | } |
| 3702 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3703 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3704 | AppendImageStack(images); |
| 3705 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3706 | if (global_colormap != MagickFalse) |
| 3707 | { |
| 3708 | QuantizeInfo |
| 3709 | *quantize_info; |
| 3710 | |
| 3711 | quantize_info=AcquireQuantizeInfo(image_info); |
| 3712 | (void) RemapImages(quantize_info,images,(Image *) NULL); |
| 3713 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3714 | } |
| 3715 | *backup_filename='\0'; |
| 3716 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3717 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3718 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3719 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3720 | i; |
| 3721 | |
| 3722 | /* |
| 3723 | Rename image file as backup. |
| 3724 | */ |
| 3725 | (void) CopyMagickString(backup_filename,image->filename, |
| 3726 | MaxTextExtent); |
| 3727 | for (i=0; i < 6; i++) |
| 3728 | { |
| 3729 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3730 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3731 | break; |
| 3732 | } |
| 3733 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
| 3734 | (rename(image->filename,backup_filename) != 0)) |
| 3735 | *backup_filename='\0'; |
| 3736 | } |
| 3737 | /* |
| 3738 | Write transmogrified image to disk. |
| 3739 | */ |
| 3740 | image_info->synchronize=MagickTrue; |
| 3741 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3742 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
| 3743 | (void) remove(backup_filename); |
| 3744 | RemoveAllImageStack(); |
| 3745 | continue; |
| 3746 | } |
| 3747 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3748 | switch (*(option+1)) |
| 3749 | { |
| 3750 | case 'a': |
| 3751 | { |
| 3752 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3753 | { |
| 3754 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3755 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3756 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3757 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3758 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3759 | break; |
| 3760 | } |
| 3761 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3762 | { |
| 3763 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3764 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3765 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3766 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3767 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3768 | break; |
| 3769 | } |
| 3770 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3771 | { |
| 3772 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3773 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3774 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3775 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3776 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3777 | break; |
| 3778 | } |
| 3779 | if (LocaleCompare("affine",option+1) == 0) |
| 3780 | { |
| 3781 | if (*option == '+') |
| 3782 | break; |
| 3783 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3784 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3785 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3786 | break; |
| 3787 | } |
| 3788 | if (LocaleCompare("alpha",option+1) == 0) |
| 3789 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3790 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3791 | type; |
| 3792 | |
| 3793 | if (*option == '+') |
| 3794 | break; |
| 3795 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3796 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3797 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3798 | type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]); |
| 3799 | if (type < 0) |
| 3800 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3801 | argv[i]); |
| 3802 | break; |
| 3803 | } |
| 3804 | if (LocaleCompare("annotate",option+1) == 0) |
| 3805 | { |
| 3806 | if (*option == '+') |
| 3807 | break; |
| 3808 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3809 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3810 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3811 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3812 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3813 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3814 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3815 | i++; |
| 3816 | break; |
| 3817 | } |
| 3818 | if (LocaleCompare("antialias",option+1) == 0) |
| 3819 | break; |
| 3820 | if (LocaleCompare("append",option+1) == 0) |
| 3821 | break; |
| 3822 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3823 | { |
| 3824 | if (*option == '+') |
| 3825 | break; |
| 3826 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3827 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3828 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3829 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3830 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3831 | break; |
| 3832 | } |
| 3833 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3834 | { |
| 3835 | if (*option == '+') |
| 3836 | break; |
| 3837 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3838 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3839 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3840 | break; |
| 3841 | } |
| 3842 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3843 | break; |
| 3844 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3845 | break; |
| 3846 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3847 | break; |
| 3848 | if (LocaleCompare("average",option+1) == 0) |
| 3849 | break; |
| 3850 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3851 | } |
| 3852 | case 'b': |
| 3853 | { |
| 3854 | if (LocaleCompare("background",option+1) == 0) |
| 3855 | { |
| 3856 | if (*option == '+') |
| 3857 | break; |
| 3858 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3859 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3860 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3861 | break; |
| 3862 | } |
| 3863 | if (LocaleCompare("bias",option+1) == 0) |
| 3864 | { |
| 3865 | if (*option == '+') |
| 3866 | break; |
| 3867 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3868 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3869 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3870 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3871 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3872 | break; |
| 3873 | } |
| 3874 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 3875 | break; |
| 3876 | if (LocaleCompare("black-threshold",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) |
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("blue-primary",option+1) == 0) |
| 3888 | { |
| 3889 | if (*option == '+') |
| 3890 | break; |
| 3891 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3892 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3893 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3894 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3895 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3896 | break; |
| 3897 | } |
| 3898 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3899 | { |
| 3900 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3901 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3902 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3903 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3904 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3905 | break; |
| 3906 | } |
| 3907 | if (LocaleCompare("blur",option+1) == 0) |
| 3908 | { |
| 3909 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3910 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3911 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3912 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3913 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3914 | break; |
| 3915 | } |
| 3916 | if (LocaleCompare("border",option+1) == 0) |
| 3917 | { |
| 3918 | if (*option == '+') |
| 3919 | break; |
| 3920 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3921 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3922 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3923 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3924 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3925 | break; |
| 3926 | } |
| 3927 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3928 | { |
| 3929 | if (*option == '+') |
| 3930 | break; |
| 3931 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3932 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3933 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3934 | break; |
| 3935 | } |
| 3936 | if (LocaleCompare("box",option+1) == 0) |
| 3937 | { |
| 3938 | if (*option == '+') |
| 3939 | break; |
| 3940 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3941 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3942 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3943 | break; |
| 3944 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3945 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 3946 | { |
| 3947 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3948 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3949 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3950 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3951 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3952 | break; |
| 3953 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3954 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3955 | } |
| 3956 | case 'c': |
| 3957 | { |
| 3958 | if (LocaleCompare("cache",option+1) == 0) |
| 3959 | { |
| 3960 | if (*option == '+') |
| 3961 | break; |
| 3962 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3963 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3964 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3965 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3966 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3967 | break; |
| 3968 | } |
| 3969 | if (LocaleCompare("caption",option+1) == 0) |
| 3970 | { |
| 3971 | if (*option == '+') |
| 3972 | break; |
| 3973 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3974 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3975 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3976 | break; |
| 3977 | } |
| 3978 | if (LocaleCompare("channel",option+1) == 0) |
| 3979 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3980 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3981 | channel; |
| 3982 | |
| 3983 | if (*option == '+') |
| 3984 | break; |
| 3985 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3986 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3987 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3988 | channel=ParseChannelOption(argv[i]); |
| 3989 | if (channel < 0) |
| 3990 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 3991 | argv[i]); |
| 3992 | break; |
| 3993 | } |
| 3994 | if (LocaleCompare("cdl",option+1) == 0) |
| 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 | break; |
| 4002 | } |
| 4003 | if (LocaleCompare("charcoal",option+1) == 0) |
| 4004 | { |
| 4005 | if (*option == '+') |
| 4006 | break; |
| 4007 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4008 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4009 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4010 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4011 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4012 | break; |
| 4013 | } |
| 4014 | if (LocaleCompare("chop",option+1) == 0) |
| 4015 | { |
| 4016 | if (*option == '+') |
| 4017 | break; |
| 4018 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4019 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4020 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4021 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4022 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4023 | break; |
| 4024 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4025 | if (LocaleCompare("clamp",option+1) == 0) |
| 4026 | break; |
| 4027 | if (LocaleCompare("clip",option+1) == 0) |
| 4028 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4029 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4030 | { |
| 4031 | if (*option == '+') |
| 4032 | break; |
| 4033 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4034 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4035 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4036 | break; |
| 4037 | } |
| 4038 | if (LocaleCompare("clut",option+1) == 0) |
| 4039 | break; |
| 4040 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4041 | break; |
| 4042 | if (LocaleCompare("colorize",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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4050 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4051 | break; |
| 4052 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4053 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4054 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4055 | KernelInfo |
| 4056 | *kernel_info; |
| 4057 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4058 | if (*option == '+') |
| 4059 | break; |
| 4060 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4061 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4062 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4063 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4064 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4065 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4066 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4067 | break; |
| 4068 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4069 | if (LocaleCompare("colors",option+1) == 0) |
| 4070 | { |
| 4071 | if (*option == '+') |
| 4072 | break; |
| 4073 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4074 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4075 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4076 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4077 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4078 | break; |
| 4079 | } |
| 4080 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4081 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4082 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4083 | colorspace; |
| 4084 | |
| 4085 | if (*option == '+') |
| 4086 | break; |
| 4087 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4088 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4089 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4090 | colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse, |
| 4091 | argv[i]); |
| 4092 | if (colorspace < 0) |
| 4093 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4094 | argv[i]); |
| 4095 | break; |
| 4096 | } |
| 4097 | if (LocaleCompare("combine",option+1) == 0) |
| 4098 | break; |
| 4099 | if (LocaleCompare("comment",option+1) == 0) |
| 4100 | { |
| 4101 | if (*option == '+') |
| 4102 | break; |
| 4103 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4104 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4105 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4106 | break; |
| 4107 | } |
| 4108 | if (LocaleCompare("composite",option+1) == 0) |
| 4109 | break; |
| 4110 | if (LocaleCompare("compress",option+1) == 0) |
| 4111 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4112 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4113 | compress; |
| 4114 | |
| 4115 | if (*option == '+') |
| 4116 | break; |
| 4117 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4118 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4119 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4120 | compress=ParseMagickOption(MagickCompressOptions,MagickFalse, |
| 4121 | argv[i]); |
| 4122 | if (compress < 0) |
| 4123 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4124 | argv[i]); |
| 4125 | break; |
| 4126 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4127 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4128 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4129 | if (LocaleCompare("contrast",option+1) == 0) |
| 4130 | break; |
| 4131 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4132 | { |
| 4133 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4134 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4135 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4136 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4137 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4138 | break; |
| 4139 | } |
| 4140 | if (LocaleCompare("convolve",option+1) == 0) |
| 4141 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4142 | KernelInfo |
| 4143 | *kernel_info; |
| 4144 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4145 | if (*option == '+') |
| 4146 | break; |
| 4147 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4148 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4149 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4150 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4151 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4152 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4153 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4154 | break; |
| 4155 | } |
| 4156 | if (LocaleCompare("crop",option+1) == 0) |
| 4157 | { |
| 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); |
| 4163 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4164 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4165 | break; |
| 4166 | } |
| 4167 | if (LocaleCompare("cycle",option+1) == 0) |
| 4168 | { |
| 4169 | if (*option == '+') |
| 4170 | break; |
| 4171 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4172 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4173 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4174 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4175 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4176 | break; |
| 4177 | } |
| 4178 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4179 | } |
| 4180 | case 'd': |
| 4181 | { |
| 4182 | if (LocaleCompare("decipher",option+1) == 0) |
| 4183 | { |
| 4184 | if (*option == '+') |
| 4185 | break; |
| 4186 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4187 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4188 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4189 | break; |
| 4190 | } |
| 4191 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4192 | break; |
| 4193 | if (LocaleCompare("debug",option+1) == 0) |
| 4194 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4195 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4196 | event; |
| 4197 | |
| 4198 | if (*option == '+') |
| 4199 | break; |
| 4200 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4201 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4202 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4203 | event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]); |
| 4204 | if (event < 0) |
| 4205 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4206 | argv[i]); |
| 4207 | (void) SetLogEventMask(argv[i]); |
| 4208 | break; |
| 4209 | } |
| 4210 | if (LocaleCompare("define",option+1) == 0) |
| 4211 | { |
| 4212 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4213 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4214 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4215 | if (*option == '+') |
| 4216 | { |
| 4217 | const char |
| 4218 | *define; |
| 4219 | |
| 4220 | define=GetImageOption(image_info,argv[i]); |
| 4221 | if (define == (const char *) NULL) |
| 4222 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4223 | break; |
| 4224 | } |
| 4225 | break; |
| 4226 | } |
| 4227 | if (LocaleCompare("delay",option+1) == 0) |
| 4228 | { |
| 4229 | if (*option == '+') |
| 4230 | break; |
| 4231 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4232 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4233 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4234 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4235 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4236 | break; |
| 4237 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4238 | if (LocaleCompare("delete",option+1) == 0) |
| 4239 | { |
| 4240 | if (*option == '+') |
| 4241 | break; |
| 4242 | i++; |
| 4243 | if (i == (ssize_t) (argc-1)) |
| 4244 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4245 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4246 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4247 | break; |
| 4248 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4249 | if (LocaleCompare("density",option+1) == 0) |
| 4250 | { |
| 4251 | if (*option == '+') |
| 4252 | break; |
| 4253 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4254 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4255 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4256 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4257 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4258 | break; |
| 4259 | } |
| 4260 | if (LocaleCompare("depth",option+1) == 0) |
| 4261 | { |
| 4262 | if (*option == '+') |
| 4263 | break; |
| 4264 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4265 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4266 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4267 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4268 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4269 | break; |
| 4270 | } |
| 4271 | if (LocaleCompare("deskew",option+1) == 0) |
| 4272 | { |
| 4273 | if (*option == '+') |
| 4274 | break; |
| 4275 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4276 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4277 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4278 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4279 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4280 | break; |
| 4281 | } |
| 4282 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4283 | break; |
| 4284 | if (LocaleCompare("dft",option+1) == 0) |
| 4285 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4286 | if (LocaleCompare("direction",option+1) == 0) |
| 4287 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4288 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4289 | direction; |
| 4290 | |
| 4291 | if (*option == '+') |
| 4292 | break; |
| 4293 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4294 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4295 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4296 | direction=ParseMagickOption(MagickDirectionOptions,MagickFalse, |
| 4297 | argv[i]); |
| 4298 | if (direction < 0) |
| 4299 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4300 | argv[i]); |
| 4301 | break; |
| 4302 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4303 | if (LocaleCompare("display",option+1) == 0) |
| 4304 | { |
| 4305 | if (*option == '+') |
| 4306 | break; |
| 4307 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4308 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4309 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4310 | break; |
| 4311 | } |
| 4312 | if (LocaleCompare("dispose",option+1) == 0) |
| 4313 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4314 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4315 | dispose; |
| 4316 | |
| 4317 | if (*option == '+') |
| 4318 | break; |
| 4319 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4320 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4321 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4322 | dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]); |
| 4323 | if (dispose < 0) |
| 4324 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4325 | argv[i]); |
| 4326 | break; |
| 4327 | } |
| 4328 | if (LocaleCompare("distort",option+1) == 0) |
| 4329 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4330 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4331 | op; |
| 4332 | |
| 4333 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4334 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4335 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4336 | op=ParseMagickOption(MagickDistortOptions,MagickFalse,argv[i]); |
| 4337 | if (op < 0) |
| 4338 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4339 | argv[i]); |
| 4340 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4341 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4342 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4343 | break; |
| 4344 | } |
| 4345 | if (LocaleCompare("dither",option+1) == 0) |
| 4346 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4347 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4348 | method; |
| 4349 | |
| 4350 | if (*option == '+') |
| 4351 | break; |
| 4352 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4353 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4354 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4355 | method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]); |
| 4356 | if (method < 0) |
| 4357 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4358 | argv[i]); |
| 4359 | break; |
| 4360 | } |
| 4361 | if (LocaleCompare("draw",option+1) == 0) |
| 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); |
| 4368 | break; |
| 4369 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4370 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4371 | { |
| 4372 | if (*option == '+') |
| 4373 | break; |
| 4374 | i++; |
| 4375 | if (i == (ssize_t) (argc-1)) |
| 4376 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4377 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4378 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4379 | break; |
| 4380 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4381 | if (LocaleCompare("duration",option+1) == 0) |
| 4382 | { |
| 4383 | if (*option == '+') |
| 4384 | break; |
| 4385 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4386 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4387 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4388 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4389 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4390 | break; |
| 4391 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4392 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4393 | } |
| 4394 | case 'e': |
| 4395 | { |
| 4396 | if (LocaleCompare("edge",option+1) == 0) |
| 4397 | { |
| 4398 | if (*option == '+') |
| 4399 | break; |
| 4400 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4401 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4402 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4403 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4404 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4405 | break; |
| 4406 | } |
| 4407 | if (LocaleCompare("emboss",option+1) == 0) |
| 4408 | { |
| 4409 | if (*option == '+') |
| 4410 | break; |
| 4411 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4412 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4413 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4414 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4415 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4416 | break; |
| 4417 | } |
| 4418 | if (LocaleCompare("encipher",option+1) == 0) |
| 4419 | { |
| 4420 | if (*option == '+') |
| 4421 | break; |
| 4422 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4423 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4424 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4425 | break; |
| 4426 | } |
| 4427 | if (LocaleCompare("encoding",option+1) == 0) |
| 4428 | { |
| 4429 | if (*option == '+') |
| 4430 | break; |
| 4431 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4432 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4433 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4434 | break; |
| 4435 | } |
| 4436 | if (LocaleCompare("endian",option+1) == 0) |
| 4437 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4438 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4439 | endian; |
| 4440 | |
| 4441 | if (*option == '+') |
| 4442 | break; |
| 4443 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4444 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4445 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4446 | endian=ParseMagickOption(MagickEndianOptions,MagickFalse,argv[i]); |
| 4447 | if (endian < 0) |
| 4448 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4449 | argv[i]); |
| 4450 | break; |
| 4451 | } |
| 4452 | if (LocaleCompare("enhance",option+1) == 0) |
| 4453 | break; |
| 4454 | if (LocaleCompare("equalize",option+1) == 0) |
| 4455 | break; |
| 4456 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4457 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4458 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4459 | op; |
| 4460 | |
| 4461 | if (*option == '+') |
| 4462 | break; |
| 4463 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4464 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4465 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4466 | op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
| 4467 | if (op < 0) |
| 4468 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4469 | argv[i]); |
| 4470 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4471 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4472 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4473 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4474 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4475 | break; |
| 4476 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4477 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4478 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4479 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4480 | op; |
| 4481 | |
| 4482 | if (*option == '+') |
| 4483 | break; |
| 4484 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4485 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4486 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4487 | op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
| 4488 | if (op < 0) |
| 4489 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4490 | argv[i]); |
| 4491 | break; |
| 4492 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4493 | if (LocaleCompare("extent",option+1) == 0) |
| 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 | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4499 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4500 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4501 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4502 | break; |
| 4503 | } |
| 4504 | if (LocaleCompare("extract",option+1) == 0) |
| 4505 | { |
| 4506 | if (*option == '+') |
| 4507 | break; |
| 4508 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4509 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4510 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4511 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4512 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4513 | break; |
| 4514 | } |
| 4515 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4516 | } |
| 4517 | case 'f': |
| 4518 | { |
| 4519 | if (LocaleCompare("family",option+1) == 0) |
| 4520 | { |
| 4521 | if (*option == '+') |
| 4522 | break; |
| 4523 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4524 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4525 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4526 | break; |
| 4527 | } |
| 4528 | if (LocaleCompare("fill",option+1) == 0) |
| 4529 | { |
| 4530 | if (*option == '+') |
| 4531 | break; |
| 4532 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4533 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4534 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4535 | break; |
| 4536 | } |
| 4537 | if (LocaleCompare("filter",option+1) == 0) |
| 4538 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4539 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4540 | filter; |
| 4541 | |
| 4542 | if (*option == '+') |
| 4543 | break; |
| 4544 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4545 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4546 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4547 | filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]); |
| 4548 | if (filter < 0) |
| 4549 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4550 | argv[i]); |
| 4551 | break; |
| 4552 | } |
| 4553 | if (LocaleCompare("flatten",option+1) == 0) |
| 4554 | break; |
| 4555 | if (LocaleCompare("flip",option+1) == 0) |
| 4556 | break; |
| 4557 | if (LocaleCompare("flop",option+1) == 0) |
| 4558 | break; |
| 4559 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4560 | { |
| 4561 | if (*option == '+') |
| 4562 | break; |
| 4563 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4564 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4565 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4566 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4567 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4568 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4569 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4570 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4571 | break; |
| 4572 | } |
| 4573 | if (LocaleCompare("font",option+1) == 0) |
| 4574 | { |
| 4575 | if (*option == '+') |
| 4576 | break; |
| 4577 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4578 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4579 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4580 | break; |
| 4581 | } |
| 4582 | if (LocaleCompare("format",option+1) == 0) |
| 4583 | { |
| 4584 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4585 | (void) CloneString(&format,(char *) NULL); |
| 4586 | if (*option == '+') |
| 4587 | break; |
| 4588 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4589 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4590 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4591 | (void) CloneString(&format,argv[i]); |
| 4592 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4593 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4594 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4595 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4596 | if (*image_info->magick == '\0') |
| 4597 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4598 | format); |
| 4599 | break; |
| 4600 | } |
| 4601 | if (LocaleCompare("frame",option+1) == 0) |
| 4602 | { |
| 4603 | if (*option == '+') |
| 4604 | break; |
| 4605 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4606 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4607 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4608 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4609 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4610 | break; |
| 4611 | } |
| 4612 | if (LocaleCompare("function",option+1) == 0) |
| 4613 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4614 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4615 | op; |
| 4616 | |
| 4617 | if (*option == '+') |
| 4618 | break; |
| 4619 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4620 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4621 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4622 | op=ParseMagickOption(MagickFunctionOptions,MagickFalse,argv[i]); |
| 4623 | if (op < 0) |
| 4624 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4625 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4626 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4627 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4628 | break; |
| 4629 | } |
| 4630 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4631 | { |
| 4632 | if (*option == '+') |
| 4633 | break; |
| 4634 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4635 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4636 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4637 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4638 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4639 | break; |
| 4640 | } |
| 4641 | if (LocaleCompare("fx",option+1) == 0) |
| 4642 | { |
| 4643 | if (*option == '+') |
| 4644 | break; |
| 4645 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4646 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4647 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4648 | break; |
| 4649 | } |
| 4650 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4651 | } |
| 4652 | case 'g': |
| 4653 | { |
| 4654 | if (LocaleCompare("gamma",option+1) == 0) |
| 4655 | { |
| 4656 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4657 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4658 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4659 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4660 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4661 | break; |
| 4662 | } |
| 4663 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4664 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4665 | { |
| 4666 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4667 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4668 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4669 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4670 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4671 | break; |
| 4672 | } |
| 4673 | if (LocaleCompare("geometry",option+1) == 0) |
| 4674 | { |
| 4675 | if (*option == '+') |
| 4676 | break; |
| 4677 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4678 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4679 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4680 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4681 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4682 | break; |
| 4683 | } |
| 4684 | if (LocaleCompare("gravity",option+1) == 0) |
| 4685 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4686 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4687 | gravity; |
| 4688 | |
| 4689 | if (*option == '+') |
| 4690 | break; |
| 4691 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4692 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4693 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4694 | gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,argv[i]); |
| 4695 | if (gravity < 0) |
| 4696 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4697 | argv[i]); |
| 4698 | break; |
| 4699 | } |
| 4700 | if (LocaleCompare("green-primary",option+1) == 0) |
| 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); |
| 4707 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4708 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4709 | break; |
| 4710 | } |
| 4711 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4712 | } |
| 4713 | case 'h': |
| 4714 | { |
| 4715 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4716 | break; |
| 4717 | if ((LocaleCompare("help",option+1) == 0) || |
| 4718 | (LocaleCompare("-help",option+1) == 0)) |
| 4719 | return(MogrifyUsage()); |
| 4720 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4721 | } |
| 4722 | case 'i': |
| 4723 | { |
| 4724 | if (LocaleCompare("identify",option+1) == 0) |
| 4725 | break; |
| 4726 | if (LocaleCompare("idft",option+1) == 0) |
| 4727 | break; |
| 4728 | if (LocaleCompare("implode",option+1) == 0) |
| 4729 | { |
| 4730 | if (*option == '+') |
| 4731 | break; |
| 4732 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4733 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4734 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4735 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4736 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4737 | break; |
| 4738 | } |
| 4739 | if (LocaleCompare("intent",option+1) == 0) |
| 4740 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4741 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4742 | intent; |
| 4743 | |
| 4744 | if (*option == '+') |
| 4745 | break; |
| 4746 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4747 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4748 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4749 | intent=ParseMagickOption(MagickIntentOptions,MagickFalse,argv[i]); |
| 4750 | if (intent < 0) |
| 4751 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4752 | argv[i]); |
| 4753 | break; |
| 4754 | } |
| 4755 | if (LocaleCompare("interlace",option+1) == 0) |
| 4756 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4757 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4758 | interlace; |
| 4759 | |
| 4760 | if (*option == '+') |
| 4761 | break; |
| 4762 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4763 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4764 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4765 | interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse, |
| 4766 | argv[i]); |
| 4767 | if (interlace < 0) |
| 4768 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4769 | argv[i]); |
| 4770 | break; |
| 4771 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4772 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4773 | { |
| 4774 | if (*option == '+') |
| 4775 | break; |
| 4776 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4777 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4778 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4779 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4780 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4781 | break; |
| 4782 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4783 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4784 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4785 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4786 | interpolate; |
| 4787 | |
| 4788 | if (*option == '+') |
| 4789 | break; |
| 4790 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4791 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4792 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4793 | interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse, |
| 4794 | argv[i]); |
| 4795 | if (interpolate < 0) |
| 4796 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4797 | argv[i]); |
| 4798 | break; |
| 4799 | } |
| 4800 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4801 | { |
| 4802 | if (*option == '+') |
| 4803 | break; |
| 4804 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4805 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4806 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4807 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4808 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4809 | break; |
| 4810 | } |
| 4811 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4812 | } |
| 4813 | case 'k': |
| 4814 | { |
| 4815 | if (LocaleCompare("kerning",option+1) == 0) |
| 4816 | { |
| 4817 | if (*option == '+') |
| 4818 | break; |
| 4819 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4820 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4821 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4822 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4823 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4824 | break; |
| 4825 | } |
| 4826 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4827 | } |
| 4828 | case 'l': |
| 4829 | { |
| 4830 | if (LocaleCompare("label",option+1) == 0) |
| 4831 | { |
| 4832 | if (*option == '+') |
| 4833 | break; |
| 4834 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4835 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4836 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4837 | break; |
| 4838 | } |
| 4839 | if (LocaleCompare("lat",option+1) == 0) |
| 4840 | { |
| 4841 | if (*option == '+') |
| 4842 | break; |
| 4843 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4844 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4845 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4846 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4847 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4848 | } |
| 4849 | if (LocaleCompare("layers",option+1) == 0) |
| 4850 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4851 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4852 | type; |
| 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-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4858 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4859 | type=ParseMagickOption(MagickLayerOptions,MagickFalse,argv[i]); |
| 4860 | if (type < 0) |
| 4861 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4862 | argv[i]); |
| 4863 | break; |
| 4864 | } |
| 4865 | if (LocaleCompare("level",option+1) == 0) |
| 4866 | { |
| 4867 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4868 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4869 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4870 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4871 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4872 | break; |
| 4873 | } |
| 4874 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4875 | { |
| 4876 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4877 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4878 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4879 | break; |
| 4880 | } |
| 4881 | if (LocaleCompare("linewidth",option+1) == 0) |
| 4882 | { |
| 4883 | if (*option == '+') |
| 4884 | break; |
| 4885 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4886 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4887 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4888 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4889 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4890 | break; |
| 4891 | } |
| 4892 | if (LocaleCompare("limit",option+1) == 0) |
| 4893 | { |
| 4894 | char |
| 4895 | *p; |
| 4896 | |
| 4897 | double |
| 4898 | value; |
| 4899 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4900 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4901 | resource; |
| 4902 | |
| 4903 | if (*option == '+') |
| 4904 | break; |
| 4905 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4906 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4907 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4908 | resource=ParseMagickOption(MagickResourceOptions,MagickFalse, |
| 4909 | argv[i]); |
| 4910 | if (resource < 0) |
| 4911 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4912 | argv[i]); |
| 4913 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4914 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4915 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4916 | value=strtod(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4917 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4918 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4919 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4920 | break; |
| 4921 | } |
| 4922 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4923 | { |
| 4924 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4925 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4926 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4927 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4928 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4929 | break; |
| 4930 | } |
| 4931 | if (LocaleCompare("list",option+1) == 0) |
| 4932 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4933 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4934 | list; |
| 4935 | |
| 4936 | if (*option == '+') |
| 4937 | break; |
| 4938 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4939 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4940 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4941 | list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]); |
| 4942 | if (list < 0) |
| 4943 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4944 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4945 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4946 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4947 | } |
| 4948 | if (LocaleCompare("log",option+1) == 0) |
| 4949 | { |
| 4950 | if (*option == '+') |
| 4951 | break; |
| 4952 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4953 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4954 | (strchr(argv[i],'%') == (char *) NULL)) |
| 4955 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4956 | break; |
| 4957 | } |
| 4958 | if (LocaleCompare("loop",option+1) == 0) |
| 4959 | { |
| 4960 | if (*option == '+') |
| 4961 | break; |
| 4962 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4963 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4964 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4965 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4966 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4967 | break; |
| 4968 | } |
| 4969 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4970 | } |
| 4971 | case 'm': |
| 4972 | { |
| 4973 | if (LocaleCompare("map",option+1) == 0) |
| 4974 | { |
| 4975 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 4976 | if (*option == '+') |
| 4977 | break; |
| 4978 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4979 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4980 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4981 | break; |
| 4982 | } |
| 4983 | if (LocaleCompare("mask",option+1) == 0) |
| 4984 | { |
| 4985 | if (*option == '+') |
| 4986 | break; |
| 4987 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4988 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4989 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4990 | break; |
| 4991 | } |
| 4992 | if (LocaleCompare("matte",option+1) == 0) |
| 4993 | break; |
| 4994 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 4995 | { |
| 4996 | if (*option == '+') |
| 4997 | break; |
| 4998 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4999 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5000 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5001 | break; |
| 5002 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5003 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5004 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5005 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5006 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5007 | if (LocaleCompare("modulate",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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5015 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5016 | break; |
| 5017 | } |
| 5018 | if (LocaleCompare("median",option+1) == 0) |
| 5019 | { |
| 5020 | if (*option == '+') |
| 5021 | break; |
| 5022 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5023 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5024 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5025 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5026 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5027 | break; |
| 5028 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5029 | if (LocaleCompare("mode",option+1) == 0) |
| 5030 | { |
| 5031 | if (*option == '+') |
| 5032 | break; |
| 5033 | i++; |
| 5034 | if (i == (ssize_t) argc) |
| 5035 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5036 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5037 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5038 | break; |
| 5039 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5040 | if (LocaleCompare("monitor",option+1) == 0) |
| 5041 | break; |
| 5042 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5043 | break; |
| 5044 | if (LocaleCompare("morph",option+1) == 0) |
| 5045 | { |
| 5046 | if (*option == '+') |
| 5047 | break; |
| 5048 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5049 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5050 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5051 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5052 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5053 | break; |
| 5054 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5055 | if (LocaleCompare("morphology",option+1) == 0) |
| 5056 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5057 | char |
| 5058 | token[MaxTextExtent]; |
| 5059 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5060 | KernelInfo |
| 5061 | *kernel_info; |
| 5062 | |
| 5063 | ssize_t |
| 5064 | op; |
| 5065 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5066 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5067 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5068 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5069 | GetMagickToken(argv[i],NULL,token); |
| 5070 | op=ParseMagickOption(MagickMorphologyOptions,MagickFalse,token); |
| 5071 | if (op < 0) |
| 5072 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5073 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5074 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5075 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5076 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5077 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5078 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5079 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5080 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5081 | break; |
| 5082 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5083 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5084 | break; |
| 5085 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5086 | { |
| 5087 | if (*option == '+') |
| 5088 | break; |
| 5089 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5090 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5091 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5092 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5093 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5094 | break; |
| 5095 | } |
| 5096 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5097 | } |
| 5098 | case 'n': |
| 5099 | { |
| 5100 | if (LocaleCompare("negate",option+1) == 0) |
| 5101 | break; |
| 5102 | if (LocaleCompare("noise",option+1) == 0) |
| 5103 | { |
| 5104 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5105 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5106 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5107 | if (*option == '+') |
| 5108 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5109 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5110 | noise; |
| 5111 | |
| 5112 | noise=ParseMagickOption(MagickNoiseOptions,MagickFalse,argv[i]); |
| 5113 | if (noise < 0) |
| 5114 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5115 | argv[i]); |
| 5116 | break; |
| 5117 | } |
| 5118 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5119 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5120 | break; |
| 5121 | } |
| 5122 | if (LocaleCompare("noop",option+1) == 0) |
| 5123 | break; |
| 5124 | if (LocaleCompare("normalize",option+1) == 0) |
| 5125 | break; |
| 5126 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5127 | } |
| 5128 | case 'o': |
| 5129 | { |
| 5130 | if (LocaleCompare("opaque",option+1) == 0) |
| 5131 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5132 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5133 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5134 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5135 | break; |
| 5136 | } |
| 5137 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5138 | { |
| 5139 | if (*option == '+') |
| 5140 | break; |
| 5141 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5142 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5143 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5144 | break; |
| 5145 | } |
| 5146 | if (LocaleCompare("orient",option+1) == 0) |
| 5147 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5148 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5149 | orientation; |
| 5150 | |
| 5151 | orientation=UndefinedOrientation; |
| 5152 | if (*option == '+') |
| 5153 | break; |
| 5154 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5155 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5156 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5157 | orientation=ParseMagickOption(MagickOrientationOptions,MagickFalse, |
| 5158 | argv[i]); |
| 5159 | if (orientation < 0) |
| 5160 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5161 | argv[i]); |
| 5162 | break; |
| 5163 | } |
| 5164 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5165 | } |
| 5166 | case 'p': |
| 5167 | { |
| 5168 | if (LocaleCompare("page",option+1) == 0) |
| 5169 | { |
| 5170 | if (*option == '+') |
| 5171 | break; |
| 5172 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5173 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5174 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5175 | break; |
| 5176 | } |
| 5177 | if (LocaleCompare("paint",option+1) == 0) |
| 5178 | { |
| 5179 | if (*option == '+') |
| 5180 | break; |
| 5181 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5182 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5183 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5184 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5185 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5186 | break; |
| 5187 | } |
| 5188 | if (LocaleCompare("path",option+1) == 0) |
| 5189 | { |
| 5190 | (void) CloneString(&path,(char *) NULL); |
| 5191 | if (*option == '+') |
| 5192 | break; |
| 5193 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5194 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5195 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5196 | (void) CloneString(&path,argv[i]); |
| 5197 | break; |
| 5198 | } |
| 5199 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5200 | { |
| 5201 | if (*option == '+') |
| 5202 | break; |
| 5203 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5204 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5205 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5206 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5207 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5208 | break; |
| 5209 | } |
| 5210 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5211 | { |
| 5212 | if (*option == '+') |
| 5213 | break; |
| 5214 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5215 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5216 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5217 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5218 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5219 | break; |
| 5220 | } |
| 5221 | if (LocaleCompare("posterize",option+1) == 0) |
| 5222 | { |
| 5223 | if (*option == '+') |
| 5224 | break; |
| 5225 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5226 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5227 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5228 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5229 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5230 | break; |
| 5231 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5232 | if (LocaleCompare("precision",option+1) == 0) |
| 5233 | { |
| 5234 | if (*option == '+') |
| 5235 | break; |
| 5236 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5237 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5238 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5239 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5240 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5241 | break; |
| 5242 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5243 | if (LocaleCompare("print",option+1) == 0) |
| 5244 | { |
| 5245 | if (*option == '+') |
| 5246 | break; |
| 5247 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5248 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5249 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5250 | break; |
| 5251 | } |
| 5252 | if (LocaleCompare("process",option+1) == 0) |
| 5253 | { |
| 5254 | if (*option == '+') |
| 5255 | break; |
| 5256 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5257 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5258 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5259 | break; |
| 5260 | } |
| 5261 | if (LocaleCompare("profile",option+1) == 0) |
| 5262 | { |
| 5263 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5264 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5265 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5266 | break; |
| 5267 | } |
| 5268 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5269 | } |
| 5270 | case 'q': |
| 5271 | { |
| 5272 | if (LocaleCompare("quality",option+1) == 0) |
| 5273 | { |
| 5274 | if (*option == '+') |
| 5275 | break; |
| 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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5280 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5281 | break; |
| 5282 | } |
| 5283 | if (LocaleCompare("quantize",option+1) == 0) |
| 5284 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5285 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5286 | colorspace; |
| 5287 | |
| 5288 | if (*option == '+') |
| 5289 | break; |
| 5290 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5291 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5292 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5293 | colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse, |
| 5294 | argv[i]); |
| 5295 | if (colorspace < 0) |
| 5296 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5297 | argv[i]); |
| 5298 | break; |
| 5299 | } |
| 5300 | if (LocaleCompare("quiet",option+1) == 0) |
| 5301 | break; |
| 5302 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5303 | } |
| 5304 | case 'r': |
| 5305 | { |
| 5306 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5307 | { |
| 5308 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5309 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5310 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5311 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5312 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5313 | break; |
| 5314 | } |
| 5315 | if (LocaleCompare("raise",option+1) == 0) |
| 5316 | { |
| 5317 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5318 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5319 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5320 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5321 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5322 | break; |
| 5323 | } |
| 5324 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5325 | { |
| 5326 | if (*option == '+') |
| 5327 | break; |
| 5328 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5329 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5330 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5331 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5332 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5333 | break; |
| 5334 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5335 | if (LocaleCompare("recolor",option+1) == 0) |
| 5336 | { |
| 5337 | if (*option == '+') |
| 5338 | break; |
| 5339 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5340 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5341 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5342 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5343 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5344 | break; |
| 5345 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5346 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5347 | { |
| 5348 | if (*option == '+') |
| 5349 | break; |
| 5350 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5351 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5352 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5353 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5354 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5355 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5356 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5357 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5358 | if (LocaleCompare("region",option+1) == 0) |
| 5359 | { |
| 5360 | if (*option == '+') |
| 5361 | break; |
| 5362 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5363 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5364 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5365 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5366 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5367 | break; |
| 5368 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5369 | if (LocaleCompare("remap",option+1) == 0) |
| 5370 | { |
| 5371 | if (*option == '+') |
| 5372 | break; |
| 5373 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5374 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5375 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5376 | break; |
| 5377 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5378 | if (LocaleCompare("render",option+1) == 0) |
| 5379 | break; |
| 5380 | if (LocaleCompare("repage",option+1) == 0) |
| 5381 | { |
| 5382 | if (*option == '+') |
| 5383 | break; |
| 5384 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5385 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5386 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5387 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5388 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5389 | break; |
| 5390 | } |
| 5391 | if (LocaleCompare("resample",option+1) == 0) |
| 5392 | { |
| 5393 | if (*option == '+') |
| 5394 | break; |
| 5395 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5396 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5397 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5398 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5399 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5400 | break; |
| 5401 | } |
| 5402 | if (LocaleCompare("resize",option+1) == 0) |
| 5403 | { |
| 5404 | if (*option == '+') |
| 5405 | break; |
| 5406 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5407 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5408 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5409 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5410 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5411 | break; |
| 5412 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5413 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5414 | { |
| 5415 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5416 | break; |
| 5417 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5418 | if (LocaleCompare("reverse",option+1) == 0) |
| 5419 | break; |
| 5420 | if (LocaleCompare("roll",option+1) == 0) |
| 5421 | { |
| 5422 | if (*option == '+') |
| 5423 | break; |
| 5424 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5425 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5426 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5427 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5428 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5429 | break; |
| 5430 | } |
| 5431 | if (LocaleCompare("rotate",option+1) == 0) |
| 5432 | { |
| 5433 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5434 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5435 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5436 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5437 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5438 | break; |
| 5439 | } |
| 5440 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5441 | } |
| 5442 | case 's': |
| 5443 | { |
| 5444 | if (LocaleCompare("sample",option+1) == 0) |
| 5445 | { |
| 5446 | if (*option == '+') |
| 5447 | break; |
| 5448 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5449 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5450 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5451 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5452 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5453 | break; |
| 5454 | } |
| 5455 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5456 | { |
| 5457 | if (*option == '+') |
| 5458 | break; |
| 5459 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5460 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5461 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5462 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5463 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5464 | break; |
| 5465 | } |
| 5466 | if (LocaleCompare("scale",option+1) == 0) |
| 5467 | { |
| 5468 | if (*option == '+') |
| 5469 | break; |
| 5470 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5471 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5472 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5473 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5474 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5475 | break; |
| 5476 | } |
| 5477 | if (LocaleCompare("scene",option+1) == 0) |
| 5478 | { |
| 5479 | if (*option == '+') |
| 5480 | break; |
| 5481 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5482 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5483 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5484 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5485 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5486 | break; |
| 5487 | } |
| 5488 | if (LocaleCompare("seed",option+1) == 0) |
| 5489 | { |
| 5490 | if (*option == '+') |
| 5491 | break; |
| 5492 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5493 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5494 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5495 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5496 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5497 | break; |
| 5498 | } |
| 5499 | if (LocaleCompare("segment",option+1) == 0) |
| 5500 | { |
| 5501 | if (*option == '+') |
| 5502 | break; |
| 5503 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5504 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5505 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5506 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5507 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5508 | break; |
| 5509 | } |
| 5510 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5511 | { |
| 5512 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5513 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5514 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5515 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5516 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5517 | break; |
| 5518 | } |
| 5519 | if (LocaleCompare("separate",option+1) == 0) |
| 5520 | break; |
| 5521 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5522 | { |
| 5523 | if (*option == '+') |
| 5524 | break; |
| 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("set",option+1) == 0) |
| 5533 | { |
| 5534 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5535 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5536 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5537 | if (*option == '+') |
| 5538 | break; |
| 5539 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5540 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5541 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5542 | break; |
| 5543 | } |
| 5544 | if (LocaleCompare("shade",option+1) == 0) |
| 5545 | { |
| 5546 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5547 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5548 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5549 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5550 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5551 | break; |
| 5552 | } |
| 5553 | if (LocaleCompare("shadow",option+1) == 0) |
| 5554 | { |
| 5555 | if (*option == '+') |
| 5556 | break; |
| 5557 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5558 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5559 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5560 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5561 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5562 | break; |
| 5563 | } |
| 5564 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5565 | { |
| 5566 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5567 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5568 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5569 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5570 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5571 | break; |
| 5572 | } |
| 5573 | if (LocaleCompare("shave",option+1) == 0) |
| 5574 | { |
| 5575 | if (*option == '+') |
| 5576 | break; |
| 5577 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5578 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5579 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5580 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5581 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5582 | break; |
| 5583 | } |
| 5584 | if (LocaleCompare("shear",option+1) == 0) |
| 5585 | { |
| 5586 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5587 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5588 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5589 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5590 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5591 | break; |
| 5592 | } |
| 5593 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5594 | { |
| 5595 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5596 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5597 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5598 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5599 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5600 | break; |
| 5601 | } |
| 5602 | if (LocaleCompare("size",option+1) == 0) |
| 5603 | { |
| 5604 | if (*option == '+') |
| 5605 | break; |
| 5606 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5607 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5608 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5609 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5610 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5611 | break; |
| 5612 | } |
| 5613 | if (LocaleCompare("sketch",option+1) == 0) |
| 5614 | { |
| 5615 | if (*option == '+') |
| 5616 | break; |
| 5617 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5618 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5619 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5620 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5621 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5622 | break; |
| 5623 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5624 | if (LocaleCompare("smush",option+1) == 0) |
| 5625 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5626 | i++; |
| 5627 | if (i == (ssize_t) argc) |
| 5628 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5629 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5630 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5631 | i++; |
| 5632 | break; |
| 5633 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5634 | if (LocaleCompare("solarize",option+1) == 0) |
| 5635 | { |
| 5636 | if (*option == '+') |
| 5637 | break; |
| 5638 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5639 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5640 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5641 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5642 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5643 | break; |
| 5644 | } |
| 5645 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5646 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5647 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5648 | op; |
| 5649 | |
| 5650 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5651 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5652 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5653 | op=ParseMagickOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
| 5654 | if (op < 0) |
| 5655 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5656 | argv[i]); |
| 5657 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5658 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5659 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5660 | break; |
| 5661 | } |
| 5662 | if (LocaleCompare("spread",option+1) == 0) |
| 5663 | { |
| 5664 | if (*option == '+') |
| 5665 | break; |
| 5666 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5667 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5668 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5669 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5670 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5671 | break; |
| 5672 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5673 | if (LocaleCompare("statistic",option+1) == 0) |
| 5674 | { |
| 5675 | ssize_t |
| 5676 | op; |
| 5677 | |
| 5678 | if (*option == '+') |
| 5679 | break; |
| 5680 | i++; |
| 5681 | if (i == (ssize_t) argc) |
| 5682 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5683 | op=ParseMagickOption(MagickStatisticOptions,MagickFalse,argv[i]); |
| 5684 | if (op < 0) |
| 5685 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5686 | argv[i]); |
| 5687 | i++; |
| 5688 | if (i == (ssize_t) (argc-1)) |
| 5689 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5690 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5691 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5692 | break; |
| 5693 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5694 | if (LocaleCompare("stretch",option+1) == 0) |
| 5695 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5696 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5697 | stretch; |
| 5698 | |
| 5699 | if (*option == '+') |
| 5700 | break; |
| 5701 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5702 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5703 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5704 | stretch=ParseMagickOption(MagickStretchOptions,MagickFalse,argv[i]); |
| 5705 | if (stretch < 0) |
| 5706 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5707 | argv[i]); |
| 5708 | break; |
| 5709 | } |
| 5710 | if (LocaleCompare("strip",option+1) == 0) |
| 5711 | break; |
| 5712 | if (LocaleCompare("stroke",option+1) == 0) |
| 5713 | { |
| 5714 | if (*option == '+') |
| 5715 | break; |
| 5716 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5717 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5718 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5719 | break; |
| 5720 | } |
| 5721 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5722 | { |
| 5723 | if (*option == '+') |
| 5724 | break; |
| 5725 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5726 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5727 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5728 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5729 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5730 | break; |
| 5731 | } |
| 5732 | if (LocaleCompare("style",option+1) == 0) |
| 5733 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5734 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5735 | style; |
| 5736 | |
| 5737 | if (*option == '+') |
| 5738 | break; |
| 5739 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5740 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5741 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5742 | style=ParseMagickOption(MagickStyleOptions,MagickFalse,argv[i]); |
| 5743 | if (style < 0) |
| 5744 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5745 | argv[i]); |
| 5746 | break; |
| 5747 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5748 | if (LocaleCompare("swap",option+1) == 0) |
| 5749 | { |
| 5750 | if (*option == '+') |
| 5751 | break; |
| 5752 | i++; |
| 5753 | if (i == (ssize_t) (argc-1)) |
| 5754 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5755 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5756 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5757 | break; |
| 5758 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5759 | if (LocaleCompare("swirl",option+1) == 0) |
| 5760 | { |
| 5761 | if (*option == '+') |
| 5762 | break; |
| 5763 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5764 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5765 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5766 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5767 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5768 | break; |
| 5769 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5770 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5771 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5772 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5773 | } |
| 5774 | case 't': |
| 5775 | { |
| 5776 | if (LocaleCompare("taint",option+1) == 0) |
| 5777 | break; |
| 5778 | if (LocaleCompare("texture",option+1) == 0) |
| 5779 | { |
| 5780 | if (*option == '+') |
| 5781 | break; |
| 5782 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5783 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5784 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5785 | break; |
| 5786 | } |
| 5787 | if (LocaleCompare("tile",option+1) == 0) |
| 5788 | { |
| 5789 | if (*option == '+') |
| 5790 | break; |
| 5791 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5792 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5793 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5794 | break; |
| 5795 | } |
| 5796 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5797 | { |
| 5798 | if (*option == '+') |
| 5799 | break; |
| 5800 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5801 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5802 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5803 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5804 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5805 | break; |
| 5806 | } |
| 5807 | if (LocaleCompare("tint",option+1) == 0) |
| 5808 | { |
| 5809 | if (*option == '+') |
| 5810 | break; |
| 5811 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5812 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5813 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5814 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5815 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5816 | break; |
| 5817 | } |
| 5818 | if (LocaleCompare("transform",option+1) == 0) |
| 5819 | break; |
| 5820 | if (LocaleCompare("transpose",option+1) == 0) |
| 5821 | break; |
| 5822 | if (LocaleCompare("transverse",option+1) == 0) |
| 5823 | break; |
| 5824 | if (LocaleCompare("threshold",option+1) == 0) |
| 5825 | { |
| 5826 | if (*option == '+') |
| 5827 | break; |
| 5828 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5829 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5830 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5831 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5832 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5833 | break; |
| 5834 | } |
| 5835 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5836 | { |
| 5837 | if (*option == '+') |
| 5838 | break; |
| 5839 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5840 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5841 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5842 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5843 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5844 | break; |
| 5845 | } |
| 5846 | if (LocaleCompare("transparent",option+1) == 0) |
| 5847 | { |
| 5848 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5849 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5850 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5851 | break; |
| 5852 | } |
| 5853 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 5854 | { |
| 5855 | if (*option == '+') |
| 5856 | break; |
| 5857 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5858 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5859 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5860 | break; |
| 5861 | } |
| 5862 | if (LocaleCompare("treedepth",option+1) == 0) |
| 5863 | { |
| 5864 | if (*option == '+') |
| 5865 | break; |
| 5866 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5867 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5868 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5869 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5870 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5871 | break; |
| 5872 | } |
| 5873 | if (LocaleCompare("trim",option+1) == 0) |
| 5874 | break; |
| 5875 | if (LocaleCompare("type",option+1) == 0) |
| 5876 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5877 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5878 | type; |
| 5879 | |
| 5880 | if (*option == '+') |
| 5881 | break; |
| 5882 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5883 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5884 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5885 | type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]); |
| 5886 | if (type < 0) |
| 5887 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5888 | argv[i]); |
| 5889 | break; |
| 5890 | } |
| 5891 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5892 | } |
| 5893 | case 'u': |
| 5894 | { |
| 5895 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5896 | { |
| 5897 | if (*option == '+') |
| 5898 | break; |
| 5899 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5900 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5901 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5902 | break; |
| 5903 | } |
| 5904 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5905 | break; |
| 5906 | if (LocaleCompare("units",option+1) == 0) |
| 5907 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5908 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5909 | units; |
| 5910 | |
| 5911 | if (*option == '+') |
| 5912 | break; |
| 5913 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5914 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5915 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5916 | units=ParseMagickOption(MagickResolutionOptions,MagickFalse, |
| 5917 | argv[i]); |
| 5918 | if (units < 0) |
| 5919 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5920 | argv[i]); |
| 5921 | break; |
| 5922 | } |
| 5923 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5924 | { |
| 5925 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5926 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5927 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5928 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5929 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5930 | break; |
| 5931 | } |
| 5932 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5933 | } |
| 5934 | case 'v': |
| 5935 | { |
| 5936 | if (LocaleCompare("verbose",option+1) == 0) |
| 5937 | { |
| 5938 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 5939 | break; |
| 5940 | } |
| 5941 | if ((LocaleCompare("version",option+1) == 0) || |
| 5942 | (LocaleCompare("-version",option+1) == 0)) |
| 5943 | { |
| 5944 | (void) fprintf(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5945 | GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 5946 | (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright()); |
| 5947 | (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5948 | break; |
| 5949 | } |
| 5950 | if (LocaleCompare("view",option+1) == 0) |
| 5951 | { |
| 5952 | if (*option == '+') |
| 5953 | break; |
| 5954 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5955 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5956 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5957 | break; |
| 5958 | } |
| 5959 | if (LocaleCompare("vignette",option+1) == 0) |
| 5960 | { |
| 5961 | if (*option == '+') |
| 5962 | break; |
| 5963 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5964 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5965 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5966 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5967 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5968 | break; |
| 5969 | } |
| 5970 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 5971 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5972 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5973 | method; |
| 5974 | |
| 5975 | if (*option == '+') |
| 5976 | break; |
| 5977 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5978 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5979 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5980 | method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse, |
| 5981 | argv[i]); |
| 5982 | if (method < 0) |
| 5983 | ThrowMogrifyException(OptionError, |
| 5984 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 5985 | break; |
| 5986 | } |
| 5987 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5988 | } |
| 5989 | case 'w': |
| 5990 | { |
| 5991 | if (LocaleCompare("wave",option+1) == 0) |
| 5992 | { |
| 5993 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5994 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5995 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5996 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5997 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5998 | break; |
| 5999 | } |
| 6000 | if (LocaleCompare("weight",option+1) == 0) |
| 6001 | { |
| 6002 | if (*option == '+') |
| 6003 | break; |
| 6004 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6005 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6006 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6007 | break; |
| 6008 | } |
| 6009 | if (LocaleCompare("white-point",option+1) == 0) |
| 6010 | { |
| 6011 | if (*option == '+') |
| 6012 | break; |
| 6013 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6014 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6015 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6016 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6017 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6018 | break; |
| 6019 | } |
| 6020 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6021 | { |
| 6022 | if (*option == '+') |
| 6023 | break; |
| 6024 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6025 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6026 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6027 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6028 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6029 | break; |
| 6030 | } |
| 6031 | if (LocaleCompare("write",option+1) == 0) |
| 6032 | { |
| 6033 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6034 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6035 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6036 | break; |
| 6037 | } |
| 6038 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6039 | } |
| 6040 | case '?': |
| 6041 | break; |
| 6042 | default: |
| 6043 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6044 | } |
| 6045 | fire=ParseMagickOption(MagickImageListOptions,MagickFalse,option+1) < 0 ? |
| 6046 | MagickFalse : MagickTrue; |
| 6047 | if (fire != MagickFalse) |
| 6048 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6049 | } |
| 6050 | if (k != 0) |
| 6051 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6052 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6053 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6054 | DestroyMogrify(); |
| 6055 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6056 | } |
| 6057 | |
| 6058 | /* |
| 6059 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6060 | % % |
| 6061 | % % |
| 6062 | % % |
| 6063 | + M o g r i f y I m a g e I n f o % |
| 6064 | % % |
| 6065 | % % |
| 6066 | % % |
| 6067 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6068 | % |
| 6069 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6070 | % prescribed by command line options. |
| 6071 | % |
| 6072 | % The format of the MogrifyImageInfo method is: |
| 6073 | % |
| 6074 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6075 | % const char **argv,ExceptionInfo *exception) |
| 6076 | % |
| 6077 | % A description of each parameter follows: |
| 6078 | % |
| 6079 | % o image_info: the image info.. |
| 6080 | % |
| 6081 | % o argc: Specifies a pointer to an integer describing the number of |
| 6082 | % elements in the argument vector. |
| 6083 | % |
| 6084 | % o argv: Specifies a pointer to a text array containing the command line |
| 6085 | % arguments. |
| 6086 | % |
| 6087 | % o exception: return any errors or warnings in this structure. |
| 6088 | % |
| 6089 | */ |
| 6090 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6091 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6092 | { |
| 6093 | const char |
| 6094 | *option; |
| 6095 | |
| 6096 | GeometryInfo |
| 6097 | geometry_info; |
| 6098 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6099 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6100 | count; |
| 6101 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6102 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6103 | i; |
| 6104 | |
| 6105 | /* |
| 6106 | Initialize method variables. |
| 6107 | */ |
| 6108 | assert(image_info != (ImageInfo *) NULL); |
| 6109 | assert(image_info->signature == MagickSignature); |
| 6110 | if (image_info->debug != MagickFalse) |
| 6111 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6112 | image_info->filename); |
| 6113 | if (argc < 0) |
| 6114 | return(MagickTrue); |
| 6115 | /* |
| 6116 | Set the image settings. |
| 6117 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6118 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6119 | { |
| 6120 | option=argv[i]; |
| 6121 | if (IsMagickOption(option) == MagickFalse) |
| 6122 | continue; |
| 6123 | count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option), |
| 6124 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6125 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6126 | break; |
| 6127 | switch (*(option+1)) |
| 6128 | { |
| 6129 | case 'a': |
| 6130 | { |
| 6131 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6132 | { |
| 6133 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6134 | break; |
| 6135 | } |
| 6136 | if (LocaleCompare("antialias",option+1) == 0) |
| 6137 | { |
| 6138 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6139 | break; |
| 6140 | } |
| 6141 | if (LocaleCompare("attenuate",option+1) == 0) |
| 6142 | { |
| 6143 | if (*option == '+') |
| 6144 | { |
| 6145 | (void) DeleteImageOption(image_info,option+1); |
| 6146 | break; |
| 6147 | } |
| 6148 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6149 | break; |
| 6150 | } |
| 6151 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6152 | { |
| 6153 | if (*option == '+') |
| 6154 | (void) CloneString(&image_info->authenticate,(char *) NULL); |
| 6155 | else |
| 6156 | (void) CloneString(&image_info->authenticate,argv[i+1]); |
| 6157 | break; |
| 6158 | } |
| 6159 | break; |
| 6160 | } |
| 6161 | case 'b': |
| 6162 | { |
| 6163 | if (LocaleCompare("background",option+1) == 0) |
| 6164 | { |
| 6165 | if (*option == '+') |
| 6166 | { |
| 6167 | (void) DeleteImageOption(image_info,option+1); |
| 6168 | (void) QueryColorDatabase(BackgroundColor, |
| 6169 | &image_info->background_color,exception); |
| 6170 | break; |
| 6171 | } |
| 6172 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6173 | (void) QueryColorDatabase(argv[i+1],&image_info->background_color, |
| 6174 | exception); |
| 6175 | break; |
| 6176 | } |
| 6177 | if (LocaleCompare("bias",option+1) == 0) |
| 6178 | { |
| 6179 | if (*option == '+') |
| 6180 | { |
| 6181 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6182 | break; |
| 6183 | } |
| 6184 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6185 | break; |
| 6186 | } |
| 6187 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6188 | { |
| 6189 | if (*option == '+') |
| 6190 | { |
| 6191 | (void) SetImageOption(image_info,option+1,"false"); |
| 6192 | break; |
| 6193 | } |
| 6194 | (void) SetImageOption(image_info,option+1,"true"); |
| 6195 | break; |
| 6196 | } |
| 6197 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6198 | { |
| 6199 | if (*option == '+') |
| 6200 | { |
| 6201 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6202 | break; |
| 6203 | } |
| 6204 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6205 | break; |
| 6206 | } |
| 6207 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6208 | { |
| 6209 | if (*option == '+') |
| 6210 | { |
| 6211 | (void) DeleteImageOption(image_info,option+1); |
| 6212 | (void) QueryColorDatabase(BorderColor,&image_info->border_color, |
| 6213 | exception); |
| 6214 | break; |
| 6215 | } |
| 6216 | (void) QueryColorDatabase(argv[i+1],&image_info->border_color, |
| 6217 | exception); |
| 6218 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6219 | break; |
| 6220 | } |
| 6221 | if (LocaleCompare("box",option+1) == 0) |
| 6222 | { |
| 6223 | if (*option == '+') |
| 6224 | { |
| 6225 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6226 | break; |
| 6227 | } |
| 6228 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6229 | break; |
| 6230 | } |
| 6231 | break; |
| 6232 | } |
| 6233 | case 'c': |
| 6234 | { |
| 6235 | if (LocaleCompare("cache",option+1) == 0) |
| 6236 | { |
| 6237 | MagickSizeType |
| 6238 | limit; |
| 6239 | |
| 6240 | limit=MagickResourceInfinity; |
| 6241 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6242 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6243 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6244 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6245 | break; |
| 6246 | } |
| 6247 | if (LocaleCompare("caption",option+1) == 0) |
| 6248 | { |
| 6249 | if (*option == '+') |
| 6250 | { |
| 6251 | (void) DeleteImageOption(image_info,option+1); |
| 6252 | break; |
| 6253 | } |
| 6254 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6255 | break; |
| 6256 | } |
| 6257 | if (LocaleCompare("channel",option+1) == 0) |
| 6258 | { |
| 6259 | if (*option == '+') |
| 6260 | { |
| 6261 | image_info->channel=DefaultChannels; |
| 6262 | break; |
| 6263 | } |
| 6264 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6265 | break; |
| 6266 | } |
| 6267 | if (LocaleCompare("colors",option+1) == 0) |
| 6268 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6269 | image_info->colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6270 | break; |
| 6271 | } |
| 6272 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6273 | { |
| 6274 | if (*option == '+') |
| 6275 | { |
| 6276 | image_info->colorspace=UndefinedColorspace; |
| 6277 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6278 | break; |
| 6279 | } |
| 6280 | image_info->colorspace=(ColorspaceType) ParseMagickOption( |
| 6281 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6282 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6283 | break; |
| 6284 | } |
| 6285 | if (LocaleCompare("compress",option+1) == 0) |
| 6286 | { |
| 6287 | if (*option == '+') |
| 6288 | { |
| 6289 | image_info->compression=UndefinedCompression; |
| 6290 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6291 | break; |
| 6292 | } |
| 6293 | image_info->compression=(CompressionType) ParseMagickOption( |
| 6294 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6295 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6296 | break; |
| 6297 | } |
| 6298 | if (LocaleCompare("comment",option+1) == 0) |
| 6299 | { |
| 6300 | if (*option == '+') |
| 6301 | { |
| 6302 | (void) DeleteImageOption(image_info,option+1); |
| 6303 | break; |
| 6304 | } |
| 6305 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6306 | break; |
| 6307 | } |
| 6308 | if (LocaleCompare("compose",option+1) == 0) |
| 6309 | { |
| 6310 | if (*option == '+') |
| 6311 | { |
| 6312 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6313 | break; |
| 6314 | } |
| 6315 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6316 | break; |
| 6317 | } |
| 6318 | if (LocaleCompare("compress",option+1) == 0) |
| 6319 | { |
| 6320 | if (*option == '+') |
| 6321 | { |
| 6322 | image_info->compression=UndefinedCompression; |
| 6323 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6324 | break; |
| 6325 | } |
| 6326 | image_info->compression=(CompressionType) ParseMagickOption( |
| 6327 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6328 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6329 | break; |
| 6330 | } |
| 6331 | break; |
| 6332 | } |
| 6333 | case 'd': |
| 6334 | { |
| 6335 | if (LocaleCompare("debug",option+1) == 0) |
| 6336 | { |
| 6337 | if (*option == '+') |
| 6338 | (void) SetLogEventMask("none"); |
| 6339 | else |
| 6340 | (void) SetLogEventMask(argv[i+1]); |
| 6341 | image_info->debug=IsEventLogging(); |
| 6342 | break; |
| 6343 | } |
| 6344 | if (LocaleCompare("define",option+1) == 0) |
| 6345 | { |
| 6346 | if (*option == '+') |
| 6347 | { |
| 6348 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6349 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6350 | else |
| 6351 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6352 | break; |
| 6353 | } |
| 6354 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6355 | { |
| 6356 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6357 | exception); |
| 6358 | break; |
| 6359 | } |
| 6360 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6361 | break; |
| 6362 | } |
| 6363 | if (LocaleCompare("delay",option+1) == 0) |
| 6364 | { |
| 6365 | if (*option == '+') |
| 6366 | { |
| 6367 | (void) SetImageOption(image_info,option+1,"0"); |
| 6368 | break; |
| 6369 | } |
| 6370 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6371 | break; |
| 6372 | } |
| 6373 | if (LocaleCompare("density",option+1) == 0) |
| 6374 | { |
| 6375 | /* |
| 6376 | Set image density. |
| 6377 | */ |
| 6378 | if (*option == '+') |
| 6379 | { |
| 6380 | if (image_info->density != (char *) NULL) |
| 6381 | image_info->density=DestroyString(image_info->density); |
| 6382 | (void) SetImageOption(image_info,option+1,"72"); |
| 6383 | break; |
| 6384 | } |
| 6385 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6386 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6387 | break; |
| 6388 | } |
| 6389 | if (LocaleCompare("depth",option+1) == 0) |
| 6390 | { |
| 6391 | if (*option == '+') |
| 6392 | { |
| 6393 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6394 | break; |
| 6395 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6396 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6397 | break; |
| 6398 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6399 | if (LocaleCompare("direction",option+1) == 0) |
| 6400 | { |
| 6401 | if (*option == '+') |
| 6402 | { |
| 6403 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6404 | break; |
| 6405 | } |
| 6406 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6407 | break; |
| 6408 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6409 | if (LocaleCompare("display",option+1) == 0) |
| 6410 | { |
| 6411 | if (*option == '+') |
| 6412 | { |
| 6413 | if (image_info->server_name != (char *) NULL) |
| 6414 | image_info->server_name=DestroyString( |
| 6415 | image_info->server_name); |
| 6416 | break; |
| 6417 | } |
| 6418 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6419 | break; |
| 6420 | } |
| 6421 | if (LocaleCompare("dispose",option+1) == 0) |
| 6422 | { |
| 6423 | if (*option == '+') |
| 6424 | { |
| 6425 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6426 | break; |
| 6427 | } |
| 6428 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6429 | break; |
| 6430 | } |
| 6431 | if (LocaleCompare("dither",option+1) == 0) |
| 6432 | { |
| 6433 | if (*option == '+') |
| 6434 | { |
| 6435 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6436 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6437 | break; |
| 6438 | } |
| 6439 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6440 | image_info->dither=MagickTrue; |
| 6441 | break; |
| 6442 | } |
| 6443 | break; |
| 6444 | } |
| 6445 | case 'e': |
| 6446 | { |
| 6447 | if (LocaleCompare("encoding",option+1) == 0) |
| 6448 | { |
| 6449 | if (*option == '+') |
| 6450 | { |
| 6451 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6452 | break; |
| 6453 | } |
| 6454 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6455 | break; |
| 6456 | } |
| 6457 | if (LocaleCompare("endian",option+1) == 0) |
| 6458 | { |
| 6459 | if (*option == '+') |
| 6460 | { |
| 6461 | image_info->endian=UndefinedEndian; |
| 6462 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6463 | break; |
| 6464 | } |
| 6465 | image_info->endian=(EndianType) ParseMagickOption( |
| 6466 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6467 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6468 | break; |
| 6469 | } |
| 6470 | if (LocaleCompare("extract",option+1) == 0) |
| 6471 | { |
| 6472 | /* |
| 6473 | Set image extract geometry. |
| 6474 | */ |
| 6475 | if (*option == '+') |
| 6476 | { |
| 6477 | if (image_info->extract != (char *) NULL) |
| 6478 | image_info->extract=DestroyString(image_info->extract); |
| 6479 | break; |
| 6480 | } |
| 6481 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6482 | break; |
| 6483 | } |
| 6484 | break; |
| 6485 | } |
| 6486 | case 'f': |
| 6487 | { |
| 6488 | if (LocaleCompare("fill",option+1) == 0) |
| 6489 | { |
| 6490 | if (*option == '+') |
| 6491 | { |
| 6492 | (void) SetImageOption(image_info,option+1,"none"); |
| 6493 | break; |
| 6494 | } |
| 6495 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6496 | break; |
| 6497 | } |
| 6498 | if (LocaleCompare("filter",option+1) == 0) |
| 6499 | { |
| 6500 | if (*option == '+') |
| 6501 | { |
| 6502 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6503 | break; |
| 6504 | } |
| 6505 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6506 | break; |
| 6507 | } |
| 6508 | if (LocaleCompare("font",option+1) == 0) |
| 6509 | { |
| 6510 | if (*option == '+') |
| 6511 | { |
| 6512 | if (image_info->font != (char *) NULL) |
| 6513 | image_info->font=DestroyString(image_info->font); |
| 6514 | break; |
| 6515 | } |
| 6516 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6517 | break; |
| 6518 | } |
| 6519 | if (LocaleCompare("format",option+1) == 0) |
| 6520 | { |
| 6521 | register const char |
| 6522 | *q; |
| 6523 | |
| 6524 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6525 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6526 | image_info->ping=MagickFalse; |
| 6527 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6528 | break; |
| 6529 | } |
| 6530 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6531 | { |
| 6532 | if (*option == '+') |
| 6533 | { |
| 6534 | image_info->fuzz=0.0; |
| 6535 | (void) SetImageOption(image_info,option+1,"0"); |
| 6536 | break; |
| 6537 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6538 | image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6539 | 1.0); |
| 6540 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6541 | break; |
| 6542 | } |
| 6543 | break; |
| 6544 | } |
| 6545 | case 'g': |
| 6546 | { |
| 6547 | if (LocaleCompare("gravity",option+1) == 0) |
| 6548 | { |
| 6549 | if (*option == '+') |
| 6550 | { |
| 6551 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6552 | break; |
| 6553 | } |
| 6554 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6555 | break; |
| 6556 | } |
| 6557 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6558 | { |
| 6559 | if (*option == '+') |
| 6560 | { |
| 6561 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6562 | break; |
| 6563 | } |
| 6564 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6565 | break; |
| 6566 | } |
| 6567 | break; |
| 6568 | } |
| 6569 | case 'i': |
| 6570 | { |
| 6571 | if (LocaleCompare("intent",option+1) == 0) |
| 6572 | { |
| 6573 | if (*option == '+') |
| 6574 | { |
| 6575 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6576 | break; |
| 6577 | } |
| 6578 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6579 | break; |
| 6580 | } |
| 6581 | if (LocaleCompare("interlace",option+1) == 0) |
| 6582 | { |
| 6583 | if (*option == '+') |
| 6584 | { |
| 6585 | image_info->interlace=UndefinedInterlace; |
| 6586 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6587 | break; |
| 6588 | } |
| 6589 | image_info->interlace=(InterlaceType) ParseMagickOption( |
| 6590 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6591 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6592 | break; |
| 6593 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6594 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6595 | { |
| 6596 | if (*option == '+') |
| 6597 | { |
| 6598 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6599 | break; |
| 6600 | } |
| 6601 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6602 | break; |
| 6603 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6604 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6605 | { |
| 6606 | if (*option == '+') |
| 6607 | { |
| 6608 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6609 | break; |
| 6610 | } |
| 6611 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6612 | break; |
| 6613 | } |
| 6614 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6615 | { |
| 6616 | if (*option == '+') |
| 6617 | { |
| 6618 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6619 | break; |
| 6620 | } |
| 6621 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6622 | break; |
| 6623 | } |
| 6624 | break; |
| 6625 | } |
| 6626 | case 'k': |
| 6627 | { |
| 6628 | if (LocaleCompare("kerning",option+1) == 0) |
| 6629 | { |
| 6630 | if (*option == '+') |
| 6631 | { |
| 6632 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6633 | break; |
| 6634 | } |
| 6635 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6636 | break; |
| 6637 | } |
| 6638 | break; |
| 6639 | } |
| 6640 | case 'l': |
| 6641 | { |
| 6642 | if (LocaleCompare("label",option+1) == 0) |
| 6643 | { |
| 6644 | if (*option == '+') |
| 6645 | { |
| 6646 | (void) DeleteImageOption(image_info,option+1); |
| 6647 | break; |
| 6648 | } |
| 6649 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6650 | break; |
| 6651 | } |
| 6652 | if (LocaleCompare("limit",option+1) == 0) |
| 6653 | { |
| 6654 | MagickSizeType |
| 6655 | limit; |
| 6656 | |
| 6657 | ResourceType |
| 6658 | type; |
| 6659 | |
| 6660 | if (*option == '+') |
| 6661 | break; |
| 6662 | type=(ResourceType) ParseMagickOption(MagickResourceOptions, |
| 6663 | MagickFalse,argv[i+1]); |
| 6664 | limit=MagickResourceInfinity; |
| 6665 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6666 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6667 | (void) SetMagickResourceLimit(type,limit); |
| 6668 | break; |
| 6669 | } |
| 6670 | if (LocaleCompare("list",option+1) == 0) |
| 6671 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6672 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6673 | list; |
| 6674 | |
| 6675 | /* |
| 6676 | Display configuration list. |
| 6677 | */ |
| 6678 | list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i+1]); |
| 6679 | switch (list) |
| 6680 | { |
| 6681 | case MagickCoderOptions: |
| 6682 | { |
| 6683 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6684 | break; |
| 6685 | } |
| 6686 | case MagickColorOptions: |
| 6687 | { |
| 6688 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6689 | break; |
| 6690 | } |
| 6691 | case MagickConfigureOptions: |
| 6692 | { |
| 6693 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6694 | break; |
| 6695 | } |
| 6696 | case MagickDelegateOptions: |
| 6697 | { |
| 6698 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6699 | break; |
| 6700 | } |
| 6701 | case MagickFontOptions: |
| 6702 | { |
| 6703 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6704 | break; |
| 6705 | } |
| 6706 | case MagickFormatOptions: |
| 6707 | { |
| 6708 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6709 | break; |
| 6710 | } |
| 6711 | case MagickLocaleOptions: |
| 6712 | { |
| 6713 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6714 | break; |
| 6715 | } |
| 6716 | case MagickLogOptions: |
| 6717 | { |
| 6718 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6719 | break; |
| 6720 | } |
| 6721 | case MagickMagicOptions: |
| 6722 | { |
| 6723 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6724 | break; |
| 6725 | } |
| 6726 | case MagickMimeOptions: |
| 6727 | { |
| 6728 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6729 | break; |
| 6730 | } |
| 6731 | case MagickModuleOptions: |
| 6732 | { |
| 6733 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6734 | break; |
| 6735 | } |
| 6736 | case MagickPolicyOptions: |
| 6737 | { |
| 6738 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6739 | break; |
| 6740 | } |
| 6741 | case MagickResourceOptions: |
| 6742 | { |
| 6743 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6744 | break; |
| 6745 | } |
| 6746 | case MagickThresholdOptions: |
| 6747 | { |
| 6748 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6749 | break; |
| 6750 | } |
| 6751 | default: |
| 6752 | { |
| 6753 | (void) ListMagickOptions((FILE *) NULL,(MagickOption) list, |
| 6754 | exception); |
| 6755 | break; |
| 6756 | } |
| 6757 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6758 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6759 | } |
| 6760 | if (LocaleCompare("log",option+1) == 0) |
| 6761 | { |
| 6762 | if (*option == '+') |
| 6763 | break; |
| 6764 | (void) SetLogFormat(argv[i+1]); |
| 6765 | break; |
| 6766 | } |
| 6767 | if (LocaleCompare("loop",option+1) == 0) |
| 6768 | { |
| 6769 | if (*option == '+') |
| 6770 | { |
| 6771 | (void) SetImageOption(image_info,option+1,"0"); |
| 6772 | break; |
| 6773 | } |
| 6774 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6775 | break; |
| 6776 | } |
| 6777 | break; |
| 6778 | } |
| 6779 | case 'm': |
| 6780 | { |
| 6781 | if (LocaleCompare("matte",option+1) == 0) |
| 6782 | { |
| 6783 | if (*option == '+') |
| 6784 | { |
| 6785 | (void) SetImageOption(image_info,option+1,"false"); |
| 6786 | break; |
| 6787 | } |
| 6788 | (void) SetImageOption(image_info,option+1,"true"); |
| 6789 | break; |
| 6790 | } |
| 6791 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6792 | { |
| 6793 | if (*option == '+') |
| 6794 | { |
| 6795 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6796 | (void) QueryColorDatabase(MatteColor,&image_info->matte_color, |
| 6797 | exception); |
| 6798 | break; |
| 6799 | } |
| 6800 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6801 | (void) QueryColorDatabase(argv[i+1],&image_info->matte_color, |
| 6802 | exception); |
| 6803 | break; |
| 6804 | } |
| 6805 | if (LocaleCompare("monitor",option+1) == 0) |
| 6806 | { |
| 6807 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6808 | (void *) NULL); |
| 6809 | break; |
| 6810 | } |
| 6811 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6812 | { |
| 6813 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6814 | break; |
| 6815 | } |
| 6816 | break; |
| 6817 | } |
| 6818 | case 'o': |
| 6819 | { |
| 6820 | if (LocaleCompare("orient",option+1) == 0) |
| 6821 | { |
| 6822 | if (*option == '+') |
| 6823 | { |
| 6824 | image_info->orientation=UndefinedOrientation; |
| 6825 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6826 | break; |
| 6827 | } |
| 6828 | image_info->orientation=(OrientationType) ParseMagickOption( |
| 6829 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6830 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6831 | break; |
| 6832 | } |
| 6833 | } |
| 6834 | case 'p': |
| 6835 | { |
| 6836 | if (LocaleCompare("page",option+1) == 0) |
| 6837 | { |
| 6838 | char |
| 6839 | *canonical_page, |
| 6840 | page[MaxTextExtent]; |
| 6841 | |
| 6842 | const char |
| 6843 | *image_option; |
| 6844 | |
| 6845 | MagickStatusType |
| 6846 | flags; |
| 6847 | |
| 6848 | RectangleInfo |
| 6849 | geometry; |
| 6850 | |
| 6851 | if (*option == '+') |
| 6852 | { |
| 6853 | (void) DeleteImageOption(image_info,option+1); |
| 6854 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6855 | break; |
| 6856 | } |
| 6857 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6858 | image_option=GetImageOption(image_info,"page"); |
| 6859 | if (image_option != (const char *) NULL) |
| 6860 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6861 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6862 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6863 | canonical_page=DestroyString(canonical_page); |
| 6864 | (void) FormatMagickString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6865 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6866 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 6867 | (void) FormatMagickString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6868 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6869 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6870 | (void) SetImageOption(image_info,option+1,page); |
| 6871 | (void) CloneString(&image_info->page,page); |
| 6872 | break; |
| 6873 | } |
| 6874 | if (LocaleCompare("pen",option+1) == 0) |
| 6875 | { |
| 6876 | if (*option == '+') |
| 6877 | { |
| 6878 | (void) SetImageOption(image_info,option+1,"none"); |
| 6879 | break; |
| 6880 | } |
| 6881 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6882 | break; |
| 6883 | } |
| 6884 | if (LocaleCompare("ping",option+1) == 0) |
| 6885 | { |
| 6886 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6887 | break; |
| 6888 | } |
| 6889 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6890 | { |
| 6891 | if (*option == '+') |
| 6892 | geometry_info.rho=0.0; |
| 6893 | else |
| 6894 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6895 | image_info->pointsize=geometry_info.rho; |
| 6896 | break; |
| 6897 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6898 | if (LocaleCompare("precision",option+1) == 0) |
| 6899 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6900 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6901 | break; |
| 6902 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6903 | if (LocaleCompare("preview",option+1) == 0) |
| 6904 | { |
| 6905 | /* |
| 6906 | Preview image. |
| 6907 | */ |
| 6908 | if (*option == '+') |
| 6909 | { |
| 6910 | image_info->preview_type=UndefinedPreview; |
| 6911 | break; |
| 6912 | } |
| 6913 | image_info->preview_type=(PreviewType) ParseMagickOption( |
| 6914 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6915 | break; |
| 6916 | } |
| 6917 | break; |
| 6918 | } |
| 6919 | case 'q': |
| 6920 | { |
| 6921 | if (LocaleCompare("quality",option+1) == 0) |
| 6922 | { |
| 6923 | /* |
| 6924 | Set image compression quality. |
| 6925 | */ |
| 6926 | if (*option == '+') |
| 6927 | { |
| 6928 | image_info->quality=UndefinedCompressionQuality; |
| 6929 | (void) SetImageOption(image_info,option+1,"0"); |
| 6930 | break; |
| 6931 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6932 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6933 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6934 | break; |
| 6935 | } |
| 6936 | if (LocaleCompare("quiet",option+1) == 0) |
| 6937 | { |
| 6938 | static WarningHandler |
| 6939 | warning_handler = (WarningHandler) NULL; |
| 6940 | |
| 6941 | if (*option == '+') |
| 6942 | { |
| 6943 | /* |
| 6944 | Restore error or warning messages. |
| 6945 | */ |
| 6946 | warning_handler=SetWarningHandler(warning_handler); |
| 6947 | break; |
| 6948 | } |
| 6949 | /* |
| 6950 | Suppress error or warning messages. |
| 6951 | */ |
| 6952 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6953 | break; |
| 6954 | } |
| 6955 | break; |
| 6956 | } |
| 6957 | case 'r': |
| 6958 | { |
| 6959 | if (LocaleCompare("red-primary",option+1) == 0) |
| 6960 | { |
| 6961 | if (*option == '+') |
| 6962 | { |
| 6963 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6964 | break; |
| 6965 | } |
| 6966 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6967 | break; |
| 6968 | } |
| 6969 | break; |
| 6970 | } |
| 6971 | case 's': |
| 6972 | { |
| 6973 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 6974 | { |
| 6975 | /* |
| 6976 | Set image sampling factor. |
| 6977 | */ |
| 6978 | if (*option == '+') |
| 6979 | { |
| 6980 | if (image_info->sampling_factor != (char *) NULL) |
| 6981 | image_info->sampling_factor=DestroyString( |
| 6982 | image_info->sampling_factor); |
| 6983 | break; |
| 6984 | } |
| 6985 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 6986 | break; |
| 6987 | } |
| 6988 | if (LocaleCompare("scene",option+1) == 0) |
| 6989 | { |
| 6990 | /* |
| 6991 | Set image scene. |
| 6992 | */ |
| 6993 | if (*option == '+') |
| 6994 | { |
| 6995 | image_info->scene=0; |
| 6996 | (void) SetImageOption(image_info,option+1,"0"); |
| 6997 | break; |
| 6998 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6999 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7000 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7001 | break; |
| 7002 | } |
| 7003 | if (LocaleCompare("seed",option+1) == 0) |
| 7004 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7005 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7006 | seed; |
| 7007 | |
| 7008 | if (*option == '+') |
| 7009 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7010 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7011 | SeedPseudoRandomGenerator(seed); |
| 7012 | break; |
| 7013 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7014 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7015 | SeedPseudoRandomGenerator(seed); |
| 7016 | break; |
| 7017 | } |
| 7018 | if (LocaleCompare("size",option+1) == 0) |
| 7019 | { |
| 7020 | if (*option == '+') |
| 7021 | { |
| 7022 | if (image_info->size != (char *) NULL) |
| 7023 | image_info->size=DestroyString(image_info->size); |
| 7024 | break; |
| 7025 | } |
| 7026 | (void) CloneString(&image_info->size,argv[i+1]); |
| 7027 | break; |
| 7028 | } |
| 7029 | if (LocaleCompare("stroke",option+1) == 0) |
| 7030 | { |
| 7031 | if (*option == '+') |
| 7032 | { |
| 7033 | (void) SetImageOption(image_info,option+1,"none"); |
| 7034 | break; |
| 7035 | } |
| 7036 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7037 | break; |
| 7038 | } |
| 7039 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7040 | { |
| 7041 | if (*option == '+') |
| 7042 | { |
| 7043 | (void) SetImageOption(image_info,option+1,"0"); |
| 7044 | break; |
| 7045 | } |
| 7046 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7047 | break; |
| 7048 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7049 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7050 | { |
| 7051 | if (*option == '+') |
| 7052 | { |
| 7053 | image_info->synchronize=MagickFalse; |
| 7054 | break; |
| 7055 | } |
| 7056 | image_info->synchronize=MagickTrue; |
| 7057 | break; |
| 7058 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7059 | break; |
| 7060 | } |
| 7061 | case 't': |
| 7062 | { |
| 7063 | if (LocaleCompare("taint",option+1) == 0) |
| 7064 | { |
| 7065 | if (*option == '+') |
| 7066 | { |
| 7067 | (void) SetImageOption(image_info,option+1,"false"); |
| 7068 | break; |
| 7069 | } |
| 7070 | (void) SetImageOption(image_info,option+1,"true"); |
| 7071 | break; |
| 7072 | } |
| 7073 | if (LocaleCompare("texture",option+1) == 0) |
| 7074 | { |
| 7075 | if (*option == '+') |
| 7076 | { |
| 7077 | if (image_info->texture != (char *) NULL) |
| 7078 | image_info->texture=DestroyString(image_info->texture); |
| 7079 | break; |
| 7080 | } |
| 7081 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7082 | break; |
| 7083 | } |
| 7084 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7085 | { |
| 7086 | if (*option == '+') |
| 7087 | { |
| 7088 | (void) SetImageOption(image_info,option+1,"0"); |
| 7089 | break; |
| 7090 | } |
| 7091 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7092 | break; |
| 7093 | } |
| 7094 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7095 | { |
| 7096 | if (*option == '+') |
| 7097 | { |
| 7098 | (void) QueryColorDatabase("none",&image_info->transparent_color, exception); |
| 7099 | (void) SetImageOption(image_info,option+1,"none"); |
| 7100 | break; |
| 7101 | } |
| 7102 | (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color, |
| 7103 | exception); |
| 7104 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7105 | break; |
| 7106 | } |
| 7107 | if (LocaleCompare("type",option+1) == 0) |
| 7108 | { |
| 7109 | if (*option == '+') |
| 7110 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7111 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7112 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7113 | break; |
| 7114 | } |
| 7115 | image_info->type=(ImageType) ParseMagickOption(MagickTypeOptions, |
| 7116 | MagickFalse,argv[i+1]); |
| 7117 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7118 | break; |
| 7119 | } |
| 7120 | break; |
| 7121 | } |
| 7122 | case 'u': |
| 7123 | { |
| 7124 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7125 | { |
| 7126 | if (*option == '+') |
| 7127 | { |
| 7128 | (void) DeleteImageOption(image_info,option+1); |
| 7129 | break; |
| 7130 | } |
| 7131 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7132 | break; |
| 7133 | } |
| 7134 | if (LocaleCompare("units",option+1) == 0) |
| 7135 | { |
| 7136 | if (*option == '+') |
| 7137 | { |
| 7138 | image_info->units=UndefinedResolution; |
| 7139 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7140 | break; |
| 7141 | } |
| 7142 | image_info->units=(ResolutionType) ParseMagickOption( |
| 7143 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7144 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7145 | break; |
| 7146 | } |
| 7147 | break; |
| 7148 | } |
| 7149 | case 'v': |
| 7150 | { |
| 7151 | if (LocaleCompare("verbose",option+1) == 0) |
| 7152 | { |
| 7153 | if (*option == '+') |
| 7154 | { |
| 7155 | image_info->verbose=MagickFalse; |
| 7156 | break; |
| 7157 | } |
| 7158 | image_info->verbose=MagickTrue; |
| 7159 | image_info->ping=MagickFalse; |
| 7160 | break; |
| 7161 | } |
| 7162 | if (LocaleCompare("view",option+1) == 0) |
| 7163 | { |
| 7164 | if (*option == '+') |
| 7165 | { |
| 7166 | if (image_info->view != (char *) NULL) |
| 7167 | image_info->view=DestroyString(image_info->view); |
| 7168 | break; |
| 7169 | } |
| 7170 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7171 | break; |
| 7172 | } |
| 7173 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7174 | { |
| 7175 | if (*option == '+') |
| 7176 | { |
| 7177 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7178 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7179 | break; |
| 7180 | } |
| 7181 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
| 7182 | ParseMagickOption(MagickVirtualPixelOptions,MagickFalse, |
| 7183 | argv[i+1]); |
| 7184 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7185 | break; |
| 7186 | } |
| 7187 | break; |
| 7188 | } |
| 7189 | case 'w': |
| 7190 | { |
| 7191 | if (LocaleCompare("white-point",option+1) == 0) |
| 7192 | { |
| 7193 | if (*option == '+') |
| 7194 | { |
| 7195 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7196 | break; |
| 7197 | } |
| 7198 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7199 | break; |
| 7200 | } |
| 7201 | break; |
| 7202 | } |
| 7203 | default: |
| 7204 | break; |
| 7205 | } |
| 7206 | i+=count; |
| 7207 | } |
| 7208 | return(MagickTrue); |
| 7209 | } |
| 7210 | |
| 7211 | /* |
| 7212 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7213 | % % |
| 7214 | % % |
| 7215 | % % |
| 7216 | + M o g r i f y I m a g e L i s t % |
| 7217 | % % |
| 7218 | % % |
| 7219 | % % |
| 7220 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7221 | % |
| 7222 | % MogrifyImageList() applies any command line options that might affect the |
| 7223 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7224 | % |
| 7225 | % The format of the MogrifyImage method is: |
| 7226 | % |
| 7227 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7228 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7229 | % |
| 7230 | % A description of each parameter follows: |
| 7231 | % |
| 7232 | % o image_info: the image info.. |
| 7233 | % |
| 7234 | % o argc: Specifies a pointer to an integer describing the number of |
| 7235 | % elements in the argument vector. |
| 7236 | % |
| 7237 | % o argv: Specifies a pointer to a text array containing the command line |
| 7238 | % arguments. |
| 7239 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7240 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7241 | % |
| 7242 | % o exception: return any errors or warnings in this structure. |
| 7243 | % |
| 7244 | */ |
| 7245 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7246 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7247 | { |
| 7248 | ChannelType |
| 7249 | channel; |
| 7250 | |
| 7251 | const char |
| 7252 | *option; |
| 7253 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7254 | ImageInfo |
| 7255 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7256 | |
| 7257 | MagickStatusType |
| 7258 | status; |
| 7259 | |
| 7260 | QuantizeInfo |
| 7261 | *quantize_info; |
| 7262 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7263 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7264 | i; |
| 7265 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7266 | ssize_t |
| 7267 | count, |
| 7268 | index; |
| 7269 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7270 | /* |
| 7271 | Apply options to the image list. |
| 7272 | */ |
| 7273 | assert(image_info != (ImageInfo *) NULL); |
| 7274 | assert(image_info->signature == MagickSignature); |
| 7275 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7276 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7277 | assert((*images)->signature == MagickSignature); |
| 7278 | if ((*images)->debug != MagickFalse) |
| 7279 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7280 | (*images)->filename); |
| 7281 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7282 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7283 | mogrify_info=CloneImageInfo(image_info); |
| 7284 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 7285 | channel=mogrify_info->channel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7286 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7287 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7288 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7289 | if (*images == (Image *) NULL) |
| 7290 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7291 | option=argv[i]; |
| 7292 | if (IsMagickOption(option) == MagickFalse) |
| 7293 | continue; |
| 7294 | count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option), |
| 7295 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7296 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7297 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7298 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7299 | switch (*(option+1)) |
| 7300 | { |
| 7301 | case 'a': |
| 7302 | { |
| 7303 | if (LocaleCompare("affinity",option+1) == 0) |
| 7304 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7305 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7306 | if (*option == '+') |
| 7307 | { |
| 7308 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7309 | InheritException(exception,&(*images)->exception); |
| 7310 | break; |
| 7311 | } |
| 7312 | i++; |
| 7313 | break; |
| 7314 | } |
| 7315 | if (LocaleCompare("append",option+1) == 0) |
| 7316 | { |
| 7317 | Image |
| 7318 | *append_image; |
| 7319 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7320 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7321 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7322 | MagickFalse,exception); |
| 7323 | if (append_image == (Image *) NULL) |
| 7324 | { |
| 7325 | status=MagickFalse; |
| 7326 | break; |
| 7327 | } |
| 7328 | *images=DestroyImageList(*images); |
| 7329 | *images=append_image; |
| 7330 | break; |
| 7331 | } |
| 7332 | if (LocaleCompare("average",option+1) == 0) |
| 7333 | { |
| 7334 | Image |
| 7335 | *average_image; |
| 7336 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7337 | /* |
| 7338 | Average an image sequence (deprecated). |
| 7339 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7340 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7341 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7342 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7343 | if (average_image == (Image *) NULL) |
| 7344 | { |
| 7345 | status=MagickFalse; |
| 7346 | break; |
| 7347 | } |
| 7348 | *images=DestroyImageList(*images); |
| 7349 | *images=average_image; |
| 7350 | break; |
| 7351 | } |
| 7352 | break; |
| 7353 | } |
| 7354 | case 'c': |
| 7355 | { |
| 7356 | if (LocaleCompare("channel",option+1) == 0) |
| 7357 | { |
| 7358 | if (*option == '+') |
| 7359 | { |
| 7360 | channel=DefaultChannels; |
| 7361 | break; |
| 7362 | } |
| 7363 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 7364 | break; |
| 7365 | } |
| 7366 | if (LocaleCompare("clut",option+1) == 0) |
| 7367 | { |
| 7368 | Image |
| 7369 | *clut_image, |
| 7370 | *image; |
| 7371 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7372 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7373 | image=RemoveFirstImageFromList(images); |
| 7374 | clut_image=RemoveFirstImageFromList(images); |
| 7375 | if (clut_image == (Image *) NULL) |
| 7376 | { |
| 7377 | status=MagickFalse; |
| 7378 | break; |
| 7379 | } |
| 7380 | (void) ClutImageChannel(image,channel,clut_image); |
| 7381 | clut_image=DestroyImage(clut_image); |
| 7382 | InheritException(exception,&image->exception); |
| 7383 | *images=DestroyImageList(*images); |
| 7384 | *images=image; |
| 7385 | break; |
| 7386 | } |
| 7387 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7388 | { |
| 7389 | Image |
| 7390 | *coalesce_image; |
| 7391 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7392 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7393 | coalesce_image=CoalesceImages(*images,exception); |
| 7394 | if (coalesce_image == (Image *) NULL) |
| 7395 | { |
| 7396 | status=MagickFalse; |
| 7397 | break; |
| 7398 | } |
| 7399 | *images=DestroyImageList(*images); |
| 7400 | *images=coalesce_image; |
| 7401 | break; |
| 7402 | } |
| 7403 | if (LocaleCompare("combine",option+1) == 0) |
| 7404 | { |
| 7405 | Image |
| 7406 | *combine_image; |
| 7407 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7408 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7409 | combine_image=CombineImages(*images,channel,exception); |
| 7410 | if (combine_image == (Image *) NULL) |
| 7411 | { |
| 7412 | status=MagickFalse; |
| 7413 | break; |
| 7414 | } |
| 7415 | *images=DestroyImageList(*images); |
| 7416 | *images=combine_image; |
| 7417 | break; |
| 7418 | } |
| 7419 | if (LocaleCompare("composite",option+1) == 0) |
| 7420 | { |
| 7421 | Image |
| 7422 | *mask_image, |
| 7423 | *composite_image, |
| 7424 | *image; |
| 7425 | |
| 7426 | RectangleInfo |
| 7427 | geometry; |
| 7428 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7429 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7430 | image=RemoveFirstImageFromList(images); |
| 7431 | composite_image=RemoveFirstImageFromList(images); |
| 7432 | if (composite_image == (Image *) NULL) |
| 7433 | { |
| 7434 | status=MagickFalse; |
| 7435 | break; |
| 7436 | } |
| 7437 | (void) TransformImage(&composite_image,(char *) NULL, |
| 7438 | composite_image->geometry); |
| 7439 | SetGeometry(composite_image,&geometry); |
| 7440 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7441 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7442 | &geometry); |
| 7443 | mask_image=RemoveFirstImageFromList(images); |
| 7444 | if (mask_image != (Image *) NULL) |
| 7445 | { |
| 7446 | if ((image->compose == DisplaceCompositeOp) || |
| 7447 | (image->compose == DistortCompositeOp)) |
| 7448 | { |
| 7449 | /* |
| 7450 | Merge Y displacement into X displacement image. |
| 7451 | */ |
| 7452 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
| 7453 | mask_image,0,0); |
| 7454 | mask_image=DestroyImage(mask_image); |
| 7455 | } |
| 7456 | else |
| 7457 | { |
| 7458 | /* |
| 7459 | Set a blending mask for the composition. |
| 7460 | */ |
| 7461 | image->mask=mask_image; |
| 7462 | (void) NegateImage(image->mask,MagickFalse); |
| 7463 | } |
| 7464 | } |
| 7465 | (void) CompositeImageChannel(image,channel,image->compose, |
| 7466 | composite_image,geometry.x,geometry.y); |
| 7467 | if (image->mask != (Image *) NULL) |
| 7468 | image->mask=DestroyImage(image->mask); |
| 7469 | composite_image=DestroyImage(composite_image); |
| 7470 | InheritException(exception,&image->exception); |
| 7471 | *images=DestroyImageList(*images); |
| 7472 | *images=image; |
| 7473 | break; |
| 7474 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7475 | #if 0 |
| 7476 | This has been merged completely into MogrifyImage() |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7477 | if (LocaleCompare("crop",option+1) == 0) |
| 7478 | { |
| 7479 | MagickStatusType |
| 7480 | flags; |
| 7481 | |
| 7482 | RectangleInfo |
| 7483 | geometry; |
| 7484 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7485 | /* |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7486 | Crop Image. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7487 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7488 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7489 | flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception); |
| 7490 | if (((geometry.width == 0) && (geometry.height == 0)) || |
| 7491 | ((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 7492 | break; |
| 7493 | (void) TransformImages(images,argv[i+1],(char *) NULL); |
| 7494 | InheritException(exception,&(*images)->exception); |
| 7495 | break; |
| 7496 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7497 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7498 | break; |
| 7499 | } |
| 7500 | case 'd': |
| 7501 | { |
| 7502 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7503 | { |
| 7504 | Image |
| 7505 | *deconstruct_image; |
| 7506 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7507 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7508 | deconstruct_image=DeconstructImages(*images,exception); |
| 7509 | if (deconstruct_image == (Image *) NULL) |
| 7510 | { |
| 7511 | status=MagickFalse; |
| 7512 | break; |
| 7513 | } |
| 7514 | *images=DestroyImageList(*images); |
| 7515 | *images=deconstruct_image; |
| 7516 | break; |
| 7517 | } |
| 7518 | if (LocaleCompare("delete",option+1) == 0) |
| 7519 | { |
| 7520 | if (*option == '+') |
| 7521 | DeleteImages(images,"-1",exception); |
| 7522 | else |
| 7523 | DeleteImages(images,argv[i+1],exception); |
| 7524 | break; |
| 7525 | } |
| 7526 | if (LocaleCompare("dither",option+1) == 0) |
| 7527 | { |
| 7528 | if (*option == '+') |
| 7529 | { |
| 7530 | quantize_info->dither=MagickFalse; |
| 7531 | break; |
| 7532 | } |
| 7533 | quantize_info->dither=MagickTrue; |
| 7534 | quantize_info->dither_method=(DitherMethod) ParseMagickOption( |
| 7535 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7536 | break; |
| 7537 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7538 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7539 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame^] | 7540 | Image |
| 7541 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7542 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7543 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame^] | 7544 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7545 | else |
| 7546 | { |
| 7547 | const char |
| 7548 | *p; |
| 7549 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7550 | size_t |
| 7551 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7552 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7553 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame^] | 7554 | p=strchr(argv[i+1],','); |
| 7555 | if (p == (const char *) NULL) |
| 7556 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7557 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7558 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame^] | 7559 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7560 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7561 | } |
| 7562 | AppendImageToList(images, duplicate_images); |
| 7563 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7564 | break; |
| 7565 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7566 | break; |
| 7567 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7568 | case 'e': |
| 7569 | { |
| 7570 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7571 | { |
| 7572 | Image |
| 7573 | *evaluate_image; |
| 7574 | |
| 7575 | MagickEvaluateOperator |
| 7576 | op; |
| 7577 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7578 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7579 | op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions, |
| 7580 | MagickFalse,argv[i+1]); |
| 7581 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7582 | if (evaluate_image == (Image *) NULL) |
| 7583 | { |
| 7584 | status=MagickFalse; |
| 7585 | break; |
| 7586 | } |
| 7587 | *images=DestroyImageList(*images); |
| 7588 | *images=evaluate_image; |
| 7589 | break; |
| 7590 | } |
| 7591 | break; |
| 7592 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7593 | case 'f': |
| 7594 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7595 | if (LocaleCompare("fft",option+1) == 0) |
| 7596 | { |
| 7597 | Image |
| 7598 | *fourier_image; |
| 7599 | |
| 7600 | /* |
| 7601 | Implements the discrete Fourier transform (DFT). |
| 7602 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7603 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7604 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7605 | MagickTrue : MagickFalse,exception); |
| 7606 | if (fourier_image == (Image *) NULL) |
| 7607 | break; |
| 7608 | *images=DestroyImage(*images); |
| 7609 | *images=fourier_image; |
| 7610 | break; |
| 7611 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7612 | if (LocaleCompare("flatten",option+1) == 0) |
| 7613 | { |
| 7614 | Image |
| 7615 | *flatten_image; |
| 7616 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7617 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7618 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7619 | if (flatten_image == (Image *) NULL) |
| 7620 | break; |
| 7621 | *images=DestroyImageList(*images); |
| 7622 | *images=flatten_image; |
| 7623 | break; |
| 7624 | } |
| 7625 | if (LocaleCompare("fx",option+1) == 0) |
| 7626 | { |
| 7627 | Image |
| 7628 | *fx_image; |
| 7629 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7630 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7631 | fx_image=FxImageChannel(*images,channel,argv[i+1],exception); |
| 7632 | if (fx_image == (Image *) NULL) |
| 7633 | { |
| 7634 | status=MagickFalse; |
| 7635 | break; |
| 7636 | } |
| 7637 | *images=DestroyImageList(*images); |
| 7638 | *images=fx_image; |
| 7639 | break; |
| 7640 | } |
| 7641 | break; |
| 7642 | } |
| 7643 | case 'h': |
| 7644 | { |
| 7645 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7646 | { |
| 7647 | Image |
| 7648 | *hald_image, |
| 7649 | *image; |
| 7650 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7651 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7652 | image=RemoveFirstImageFromList(images); |
| 7653 | hald_image=RemoveFirstImageFromList(images); |
| 7654 | if (hald_image == (Image *) NULL) |
| 7655 | { |
| 7656 | status=MagickFalse; |
| 7657 | break; |
| 7658 | } |
| 7659 | (void) HaldClutImageChannel(image,channel,hald_image); |
| 7660 | hald_image=DestroyImage(hald_image); |
| 7661 | InheritException(exception,&image->exception); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7662 | if (*images != (Image *) NULL) |
| 7663 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7664 | *images=image; |
| 7665 | break; |
| 7666 | } |
| 7667 | break; |
| 7668 | } |
| 7669 | case 'i': |
| 7670 | { |
| 7671 | if (LocaleCompare("ift",option+1) == 0) |
| 7672 | { |
| 7673 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7674 | *fourier_image, |
| 7675 | *magnitude_image, |
| 7676 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7677 | |
| 7678 | /* |
| 7679 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7680 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7681 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7682 | magnitude_image=RemoveFirstImageFromList(images); |
| 7683 | phase_image=RemoveFirstImageFromList(images); |
| 7684 | if (phase_image == (Image *) NULL) |
| 7685 | { |
| 7686 | status=MagickFalse; |
| 7687 | break; |
| 7688 | } |
| 7689 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7690 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7691 | if (fourier_image == (Image *) NULL) |
| 7692 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7693 | if (*images != (Image *) NULL) |
| 7694 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7695 | *images=fourier_image; |
| 7696 | break; |
| 7697 | } |
| 7698 | if (LocaleCompare("insert",option+1) == 0) |
| 7699 | { |
| 7700 | Image |
| 7701 | *p, |
| 7702 | *q; |
| 7703 | |
| 7704 | index=0; |
| 7705 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7706 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7707 | p=RemoveLastImageFromList(images); |
| 7708 | if (p == (Image *) NULL) |
| 7709 | { |
| 7710 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7711 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7712 | status=MagickFalse; |
| 7713 | break; |
| 7714 | } |
| 7715 | q=p; |
| 7716 | if (index == 0) |
| 7717 | PrependImageToList(images,q); |
| 7718 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7719 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7720 | AppendImageToList(images,q); |
| 7721 | else |
| 7722 | { |
| 7723 | q=GetImageFromList(*images,index-1); |
| 7724 | if (q == (Image *) NULL) |
| 7725 | { |
| 7726 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7727 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7728 | status=MagickFalse; |
| 7729 | break; |
| 7730 | } |
| 7731 | InsertImageInList(&q,p); |
| 7732 | } |
| 7733 | *images=GetFirstImageInList(q); |
| 7734 | break; |
| 7735 | } |
| 7736 | break; |
| 7737 | } |
| 7738 | case 'l': |
| 7739 | { |
| 7740 | if (LocaleCompare("layers",option+1) == 0) |
| 7741 | { |
| 7742 | Image |
| 7743 | *layers; |
| 7744 | |
| 7745 | ImageLayerMethod |
| 7746 | method; |
| 7747 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7748 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7749 | layers=(Image *) NULL; |
| 7750 | method=(ImageLayerMethod) ParseMagickOption(MagickLayerOptions, |
| 7751 | MagickFalse,argv[i+1]); |
| 7752 | switch (method) |
| 7753 | { |
| 7754 | case CoalesceLayer: |
| 7755 | { |
| 7756 | layers=CoalesceImages(*images,exception); |
| 7757 | break; |
| 7758 | } |
| 7759 | case CompareAnyLayer: |
| 7760 | case CompareClearLayer: |
| 7761 | case CompareOverlayLayer: |
| 7762 | default: |
| 7763 | { |
| 7764 | layers=CompareImageLayers(*images,method,exception); |
| 7765 | break; |
| 7766 | } |
| 7767 | case MergeLayer: |
| 7768 | case FlattenLayer: |
| 7769 | case MosaicLayer: |
| 7770 | case TrimBoundsLayer: |
| 7771 | { |
| 7772 | layers=MergeImageLayers(*images,method,exception); |
| 7773 | break; |
| 7774 | } |
| 7775 | case DisposeLayer: |
| 7776 | { |
| 7777 | layers=DisposeImages(*images,exception); |
| 7778 | break; |
| 7779 | } |
| 7780 | case OptimizeImageLayer: |
| 7781 | { |
| 7782 | layers=OptimizeImageLayers(*images,exception); |
| 7783 | break; |
| 7784 | } |
| 7785 | case OptimizePlusLayer: |
| 7786 | { |
| 7787 | layers=OptimizePlusImageLayers(*images,exception); |
| 7788 | break; |
| 7789 | } |
| 7790 | case OptimizeTransLayer: |
| 7791 | { |
| 7792 | OptimizeImageTransparency(*images,exception); |
| 7793 | break; |
| 7794 | } |
| 7795 | case RemoveDupsLayer: |
| 7796 | { |
| 7797 | RemoveDuplicateLayers(images,exception); |
| 7798 | break; |
| 7799 | } |
| 7800 | case RemoveZeroLayer: |
| 7801 | { |
| 7802 | RemoveZeroDelayLayers(images,exception); |
| 7803 | break; |
| 7804 | } |
| 7805 | case OptimizeLayer: |
| 7806 | { |
| 7807 | /* |
| 7808 | General Purpose, GIF Animation Optimizer. |
| 7809 | */ |
| 7810 | layers=CoalesceImages(*images,exception); |
| 7811 | if (layers == (Image *) NULL) |
| 7812 | { |
| 7813 | status=MagickFalse; |
| 7814 | break; |
| 7815 | } |
| 7816 | InheritException(exception,&layers->exception); |
| 7817 | *images=DestroyImageList(*images); |
| 7818 | *images=layers; |
| 7819 | layers=OptimizeImageLayers(*images,exception); |
| 7820 | if (layers == (Image *) NULL) |
| 7821 | { |
| 7822 | status=MagickFalse; |
| 7823 | break; |
| 7824 | } |
| 7825 | InheritException(exception,&layers->exception); |
| 7826 | *images=DestroyImageList(*images); |
| 7827 | *images=layers; |
| 7828 | layers=(Image *) NULL; |
| 7829 | OptimizeImageTransparency(*images,exception); |
| 7830 | InheritException(exception,&(*images)->exception); |
| 7831 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7832 | break; |
| 7833 | } |
| 7834 | case CompositeLayer: |
| 7835 | { |
| 7836 | CompositeOperator |
| 7837 | compose; |
| 7838 | |
| 7839 | Image |
| 7840 | *source; |
| 7841 | |
| 7842 | RectangleInfo |
| 7843 | geometry; |
| 7844 | |
| 7845 | /* |
| 7846 | Split image sequence at the first 'NULL:' image. |
| 7847 | */ |
| 7848 | source=(*images); |
| 7849 | while (source != (Image *) NULL) |
| 7850 | { |
| 7851 | source=GetNextImageInList(source); |
| 7852 | if ((source != (Image *) NULL) && |
| 7853 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7854 | break; |
| 7855 | } |
| 7856 | if (source != (Image *) NULL) |
| 7857 | { |
| 7858 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7859 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7860 | source=(Image *) NULL; |
| 7861 | else |
| 7862 | { |
| 7863 | /* |
| 7864 | Separate the two lists, junk the null: image. |
| 7865 | */ |
| 7866 | source=SplitImageList(source->previous); |
| 7867 | DeleteImageFromList(&source); |
| 7868 | } |
| 7869 | } |
| 7870 | if (source == (Image *) NULL) |
| 7871 | { |
| 7872 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7873 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7874 | status=MagickFalse; |
| 7875 | break; |
| 7876 | } |
| 7877 | /* |
| 7878 | Adjust offset with gravity and virtual canvas. |
| 7879 | */ |
| 7880 | SetGeometry(*images,&geometry); |
| 7881 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7882 | geometry.width=source->page.width != 0 ? |
| 7883 | source->page.width : source->columns; |
| 7884 | geometry.height=source->page.height != 0 ? |
| 7885 | source->page.height : source->rows; |
| 7886 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7887 | (*images)->page.width : (*images)->columns, |
| 7888 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7889 | (*images)->rows,(*images)->gravity,&geometry); |
| 7890 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7891 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7892 | if (option != (const char *) NULL) |
| 7893 | compose=(CompositeOperator) ParseMagickOption( |
| 7894 | MagickComposeOptions,MagickFalse,option); |
| 7895 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7896 | exception); |
| 7897 | source=DestroyImageList(source); |
| 7898 | break; |
| 7899 | } |
| 7900 | } |
| 7901 | if (layers == (Image *) NULL) |
| 7902 | break; |
| 7903 | InheritException(exception,&layers->exception); |
| 7904 | *images=DestroyImageList(*images); |
| 7905 | *images=layers; |
| 7906 | break; |
| 7907 | } |
| 7908 | break; |
| 7909 | } |
| 7910 | case 'm': |
| 7911 | { |
| 7912 | if (LocaleCompare("map",option+1) == 0) |
| 7913 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7914 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7915 | if (*option == '+') |
| 7916 | { |
| 7917 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7918 | InheritException(exception,&(*images)->exception); |
| 7919 | break; |
| 7920 | } |
| 7921 | i++; |
| 7922 | break; |
| 7923 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7924 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7925 | { |
| 7926 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7927 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7928 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7929 | /* |
| 7930 | Maximum image sequence (deprecated). |
| 7931 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7932 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7933 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7934 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7935 | { |
| 7936 | status=MagickFalse; |
| 7937 | break; |
| 7938 | } |
| 7939 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7940 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7941 | break; |
| 7942 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7943 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7944 | { |
| 7945 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7946 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7947 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7948 | /* |
| 7949 | Minimum image sequence (deprecated). |
| 7950 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7951 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7952 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7953 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7954 | { |
| 7955 | status=MagickFalse; |
| 7956 | break; |
| 7957 | } |
| 7958 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7959 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7960 | break; |
| 7961 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7962 | if (LocaleCompare("morph",option+1) == 0) |
| 7963 | { |
| 7964 | Image |
| 7965 | *morph_image; |
| 7966 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7967 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7968 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7969 | exception); |
| 7970 | if (morph_image == (Image *) NULL) |
| 7971 | { |
| 7972 | status=MagickFalse; |
| 7973 | break; |
| 7974 | } |
| 7975 | *images=DestroyImageList(*images); |
| 7976 | *images=morph_image; |
| 7977 | break; |
| 7978 | } |
| 7979 | if (LocaleCompare("mosaic",option+1) == 0) |
| 7980 | { |
| 7981 | Image |
| 7982 | *mosaic_image; |
| 7983 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7984 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7985 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 7986 | if (mosaic_image == (Image *) NULL) |
| 7987 | { |
| 7988 | status=MagickFalse; |
| 7989 | break; |
| 7990 | } |
| 7991 | *images=DestroyImageList(*images); |
| 7992 | *images=mosaic_image; |
| 7993 | break; |
| 7994 | } |
| 7995 | break; |
| 7996 | } |
| 7997 | case 'p': |
| 7998 | { |
| 7999 | if (LocaleCompare("print",option+1) == 0) |
| 8000 | { |
| 8001 | char |
| 8002 | *string; |
| 8003 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8004 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8005 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8006 | if (string == (char *) NULL) |
| 8007 | break; |
| 8008 | InheritException(exception,&(*images)->exception); |
| 8009 | (void) fprintf(stdout,"%s",string); |
| 8010 | string=DestroyString(string); |
| 8011 | } |
| 8012 | if (LocaleCompare("process",option+1) == 0) |
| 8013 | { |
| 8014 | char |
| 8015 | **arguments; |
| 8016 | |
| 8017 | int |
| 8018 | j, |
| 8019 | number_arguments; |
| 8020 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8021 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8022 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 8023 | if (arguments == (char **) NULL) |
| 8024 | break; |
| 8025 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 8026 | { |
| 8027 | char |
| 8028 | breaker, |
| 8029 | quote, |
| 8030 | *token; |
| 8031 | |
| 8032 | const char |
| 8033 | *arguments; |
| 8034 | |
| 8035 | int |
| 8036 | next, |
| 8037 | status; |
| 8038 | |
| 8039 | size_t |
| 8040 | length; |
| 8041 | |
| 8042 | TokenInfo |
| 8043 | *token_info; |
| 8044 | |
| 8045 | /* |
| 8046 | Support old style syntax, filter="-option arg". |
| 8047 | */ |
| 8048 | length=strlen(argv[i+1]); |
| 8049 | token=(char *) NULL; |
| 8050 | if (~length >= MaxTextExtent) |
| 8051 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8052 | sizeof(*token)); |
| 8053 | if (token == (char *) NULL) |
| 8054 | break; |
| 8055 | next=0; |
| 8056 | arguments=argv[i+1]; |
| 8057 | token_info=AcquireTokenInfo(); |
| 8058 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8059 | "\"",'\0',&breaker,&next,"e); |
| 8060 | token_info=DestroyTokenInfo(token_info); |
| 8061 | if (status == 0) |
| 8062 | { |
| 8063 | const char |
| 8064 | *argv; |
| 8065 | |
| 8066 | argv=(&(arguments[next])); |
| 8067 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8068 | exception); |
| 8069 | } |
| 8070 | token=DestroyString(token); |
| 8071 | break; |
| 8072 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8073 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8074 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8075 | number_arguments-2,(const char **) arguments+2,exception); |
| 8076 | for (j=0; j < number_arguments; j++) |
| 8077 | arguments[j]=DestroyString(arguments[j]); |
| 8078 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8079 | break; |
| 8080 | } |
| 8081 | break; |
| 8082 | } |
| 8083 | case 'r': |
| 8084 | { |
| 8085 | if (LocaleCompare("reverse",option+1) == 0) |
| 8086 | { |
| 8087 | ReverseImageList(images); |
| 8088 | InheritException(exception,&(*images)->exception); |
| 8089 | break; |
| 8090 | } |
| 8091 | break; |
| 8092 | } |
| 8093 | case 's': |
| 8094 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8095 | if (LocaleCompare("smush",option+1) == 0) |
| 8096 | { |
| 8097 | Image |
| 8098 | *smush_image; |
| 8099 | |
| 8100 | ssize_t |
| 8101 | offset; |
| 8102 | |
| 8103 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8104 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8105 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8106 | MagickFalse,offset,exception); |
| 8107 | if (smush_image == (Image *) NULL) |
| 8108 | { |
| 8109 | status=MagickFalse; |
| 8110 | break; |
| 8111 | } |
| 8112 | *images=DestroyImageList(*images); |
| 8113 | *images=smush_image; |
| 8114 | break; |
| 8115 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8116 | if (LocaleCompare("swap",option+1) == 0) |
| 8117 | { |
| 8118 | Image |
| 8119 | *p, |
| 8120 | *q, |
| 8121 | *swap; |
| 8122 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8123 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8124 | swap_index; |
| 8125 | |
| 8126 | index=(-1); |
| 8127 | swap_index=(-2); |
| 8128 | if (*option != '+') |
| 8129 | { |
| 8130 | GeometryInfo |
| 8131 | geometry_info; |
| 8132 | |
| 8133 | MagickStatusType |
| 8134 | flags; |
| 8135 | |
| 8136 | swap_index=(-1); |
| 8137 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8138 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8139 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8140 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8141 | } |
| 8142 | p=GetImageFromList(*images,index); |
| 8143 | q=GetImageFromList(*images,swap_index); |
| 8144 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8145 | { |
| 8146 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8147 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8148 | status=MagickFalse; |
| 8149 | break; |
| 8150 | } |
| 8151 | if (p == q) |
| 8152 | break; |
| 8153 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8154 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8155 | ReplaceImageInList(&q,swap); |
| 8156 | *images=GetFirstImageInList(q); |
| 8157 | break; |
| 8158 | } |
| 8159 | break; |
| 8160 | } |
| 8161 | case 'w': |
| 8162 | { |
| 8163 | if (LocaleCompare("write",option+1) == 0) |
| 8164 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8165 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8166 | key[MaxTextExtent]; |
| 8167 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8168 | Image |
| 8169 | *write_images; |
| 8170 | |
| 8171 | ImageInfo |
| 8172 | *write_info; |
| 8173 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8174 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8175 | (void) FormatMagickString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
| 8176 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8177 | write_images=(*images); |
| 8178 | if (*option == '+') |
| 8179 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8180 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8181 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8182 | write_info=DestroyImageInfo(write_info); |
| 8183 | if (*option == '+') |
| 8184 | write_images=DestroyImageList(write_images); |
| 8185 | break; |
| 8186 | } |
| 8187 | break; |
| 8188 | } |
| 8189 | default: |
| 8190 | break; |
| 8191 | } |
| 8192 | i+=count; |
| 8193 | } |
| 8194 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8195 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8196 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8197 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8198 | } |
| 8199 | |
| 8200 | /* |
| 8201 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8202 | % % |
| 8203 | % % |
| 8204 | % % |
| 8205 | + M o g r i f y I m a g e s % |
| 8206 | % % |
| 8207 | % % |
| 8208 | % % |
| 8209 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8210 | % |
| 8211 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8212 | % prescribed by command line options. |
| 8213 | % |
| 8214 | % The format of the MogrifyImage method is: |
| 8215 | % |
| 8216 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8217 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8218 | % Image **images,Exceptioninfo *exception) |
| 8219 | % |
| 8220 | % A description of each parameter follows: |
| 8221 | % |
| 8222 | % o image_info: the image info.. |
| 8223 | % |
| 8224 | % o post: If true, post process image list operators otherwise pre-process. |
| 8225 | % |
| 8226 | % o argc: Specifies a pointer to an integer describing the number of |
| 8227 | % elements in the argument vector. |
| 8228 | % |
| 8229 | % o argv: Specifies a pointer to a text array containing the command line |
| 8230 | % arguments. |
| 8231 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8232 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8233 | % |
| 8234 | % o exception: return any errors or warnings in this structure. |
| 8235 | % |
| 8236 | */ |
| 8237 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8238 | const MagickBooleanType post,const int argc,const char **argv, |
| 8239 | Image **images,ExceptionInfo *exception) |
| 8240 | { |
| 8241 | #define MogrifyImageTag "Mogrify/Image" |
| 8242 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8243 | MagickStatusType |
| 8244 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8245 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8246 | MagickBooleanType |
| 8247 | proceed; |
| 8248 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8249 | size_t |
| 8250 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8251 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8252 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8253 | i; |
| 8254 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8255 | assert(image_info != (ImageInfo *) NULL); |
| 8256 | assert(image_info->signature == MagickSignature); |
| 8257 | if (images == (Image **) NULL) |
| 8258 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8259 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8260 | assert((*images)->signature == MagickSignature); |
| 8261 | if ((*images)->debug != MagickFalse) |
| 8262 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8263 | (*images)->filename); |
| 8264 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8265 | return(MagickTrue); |
| 8266 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8267 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8268 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8269 | |
| 8270 | /* |
| 8271 | Pre-process multi-image sequence operators |
| 8272 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8273 | if (post == MagickFalse) |
| 8274 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8275 | |
| 8276 | /* |
| 8277 | For each image, process simple single image operators |
| 8278 | */ |
| 8279 | i=0; |
| 8280 | n=GetImageListLength(*images); |
| 8281 | for (;;) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8282 | { |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8283 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8284 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8285 | if (proceed == MagickFalse) |
| 8286 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8287 | if ( (*images)->next == (Image *) NULL ) |
| 8288 | break; |
| 8289 | *images=(*images)->next; |
| 8290 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8291 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8292 | assert( *images != (Image *) NULL ); |
| 8293 | |
| 8294 | /* |
| 8295 | Post-process, multi-image sequence operators |
| 8296 | */ |
| 8297 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8298 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8299 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8300 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8301 | } |