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; |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame^] | 685 | count=ParseMagickOption(MagickCommandOptions,MagickFalse,option); |
| 686 | count=MagickMax(count,0L); |
| 687 | count&=NumArgsOption; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 688 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 689 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 690 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 691 | mogrify_image=(Image *)NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 692 | switch (*(option+1)) |
| 693 | { |
| 694 | case 'a': |
| 695 | { |
| 696 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 697 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 698 | /* |
| 699 | Adaptive blur image. |
| 700 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 701 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 702 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 703 | if ((flags & SigmaValue) == 0) |
| 704 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 705 | mogrify_image=AdaptiveBlurImageChannel(*image,channel, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 706 | geometry_info.rho,geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 707 | break; |
| 708 | } |
| 709 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 710 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 711 | /* |
| 712 | Adaptive resize image. |
| 713 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 714 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 715 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 716 | mogrify_image=AdaptiveResizeImage(*image,geometry.width, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 717 | geometry.height,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 718 | break; |
| 719 | } |
| 720 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 721 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 722 | /* |
| 723 | Adaptive sharpen image. |
| 724 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 725 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 726 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 727 | if ((flags & SigmaValue) == 0) |
| 728 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 729 | mogrify_image=AdaptiveSharpenImageChannel(*image,channel, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 730 | geometry_info.rho,geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 731 | break; |
| 732 | } |
| 733 | if (LocaleCompare("affine",option+1) == 0) |
| 734 | { |
| 735 | /* |
| 736 | Affine matrix. |
| 737 | */ |
| 738 | if (*option == '+') |
| 739 | { |
| 740 | GetAffineMatrix(&draw_info->affine); |
| 741 | break; |
| 742 | } |
| 743 | (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); |
| 744 | break; |
| 745 | } |
| 746 | if (LocaleCompare("alpha",option+1) == 0) |
| 747 | { |
| 748 | AlphaChannelType |
| 749 | alpha_type; |
| 750 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 751 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 752 | alpha_type=(AlphaChannelType) ParseMagickOption(MagickAlphaOptions, |
| 753 | MagickFalse,argv[i+1]); |
| 754 | (void) SetImageAlphaChannel(*image,alpha_type); |
| 755 | InheritException(exception,&(*image)->exception); |
| 756 | break; |
| 757 | } |
| 758 | if (LocaleCompare("annotate",option+1) == 0) |
| 759 | { |
| 760 | char |
| 761 | *text, |
| 762 | geometry[MaxTextExtent]; |
| 763 | |
| 764 | /* |
| 765 | Annotate image. |
| 766 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 767 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 768 | SetGeometryInfo(&geometry_info); |
| 769 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 770 | if ((flags & SigmaValue) == 0) |
| 771 | geometry_info.sigma=geometry_info.rho; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 772 | text=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 773 | InheritException(exception,&(*image)->exception); |
| 774 | if (text == (char *) NULL) |
| 775 | break; |
| 776 | (void) CloneString(&draw_info->text,text); |
| 777 | text=DestroyString(text); |
| 778 | (void) FormatMagickString(geometry,MaxTextExtent,"%+f%+f", |
| 779 | geometry_info.xi,geometry_info.psi); |
| 780 | (void) CloneString(&draw_info->geometry,geometry); |
| 781 | draw_info->affine.sx=cos(DegreesToRadians( |
| 782 | fmod(geometry_info.rho,360.0))); |
| 783 | draw_info->affine.rx=sin(DegreesToRadians( |
| 784 | fmod(geometry_info.rho,360.0))); |
| 785 | draw_info->affine.ry=(-sin(DegreesToRadians( |
| 786 | fmod(geometry_info.sigma,360.0)))); |
| 787 | draw_info->affine.sy=cos(DegreesToRadians( |
| 788 | fmod(geometry_info.sigma,360.0))); |
| 789 | (void) AnnotateImage(*image,draw_info); |
| 790 | InheritException(exception,&(*image)->exception); |
| 791 | break; |
| 792 | } |
| 793 | if (LocaleCompare("antialias",option+1) == 0) |
| 794 | { |
| 795 | draw_info->stroke_antialias=(*option == '-') ? MagickTrue : |
| 796 | MagickFalse; |
| 797 | draw_info->text_antialias=(*option == '-') ? MagickTrue : |
| 798 | MagickFalse; |
| 799 | break; |
| 800 | } |
| 801 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 802 | { |
| 803 | /* |
| 804 | Auto Adjust Gamma of image based on its mean |
| 805 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 806 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 807 | (void) AutoGammaImageChannel(*image,channel); |
| 808 | break; |
| 809 | } |
| 810 | if (LocaleCompare("auto-level",option+1) == 0) |
| 811 | { |
| 812 | /* |
| 813 | Perfectly Normalize (max/min stretch) the image |
| 814 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 815 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 816 | (void) AutoLevelImageChannel(*image,channel); |
| 817 | break; |
| 818 | } |
| 819 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 820 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 821 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 822 | switch ((*image)->orientation) |
| 823 | { |
| 824 | case TopRightOrientation: |
| 825 | { |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 826 | mogrify_image=FlopImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 827 | break; |
| 828 | } |
| 829 | case BottomRightOrientation: |
| 830 | { |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 831 | mogrify_image=RotateImage(*image,180.0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 832 | break; |
| 833 | } |
| 834 | case BottomLeftOrientation: |
| 835 | { |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 836 | mogrify_image=FlipImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 837 | break; |
| 838 | } |
| 839 | case LeftTopOrientation: |
| 840 | { |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 841 | mogrify_image=TransposeImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 842 | break; |
| 843 | } |
| 844 | case RightTopOrientation: |
| 845 | { |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 846 | mogrify_image=RotateImage(*image,90.0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 847 | break; |
| 848 | } |
| 849 | case RightBottomOrientation: |
| 850 | { |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 851 | mogrify_image=TransverseImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 852 | break; |
| 853 | } |
| 854 | case LeftBottomOrientation: |
| 855 | { |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 856 | mogrify_image=RotateImage(*image,270.0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 857 | break; |
| 858 | } |
| 859 | default: |
| 860 | break; |
| 861 | } |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 862 | if (mogrify_image != (Image *) NULL) |
| 863 | mogrify_image->orientation=TopLeftOrientation; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 864 | break; |
| 865 | } |
| 866 | break; |
| 867 | } |
| 868 | case 'b': |
| 869 | { |
| 870 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 871 | { |
| 872 | /* |
| 873 | Black threshold image. |
| 874 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 875 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 876 | (void) BlackThresholdImageChannel(*image,channel,argv[i+1], |
| 877 | exception); |
| 878 | InheritException(exception,&(*image)->exception); |
| 879 | break; |
| 880 | } |
| 881 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 882 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 883 | /* |
| 884 | Blue shift image. |
| 885 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 886 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 887 | geometry_info.rho=1.5; |
| 888 | if (*option == '-') |
| 889 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 890 | mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 891 | break; |
| 892 | } |
| 893 | if (LocaleCompare("blur",option+1) == 0) |
| 894 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 895 | /* |
| 896 | Gaussian blur image. |
| 897 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 898 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 899 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 900 | if ((flags & SigmaValue) == 0) |
| 901 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 902 | mogrify_image=BlurImageChannel(*image,channel,geometry_info.rho, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 903 | geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 904 | break; |
| 905 | } |
| 906 | if (LocaleCompare("border",option+1) == 0) |
| 907 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 908 | /* |
| 909 | Surround image with a border of solid color. |
| 910 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 911 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 912 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 913 | if ((flags & SigmaValue) == 0) |
| 914 | geometry.height=geometry.width; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 915 | mogrify_image=BorderImage(*image,&geometry,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 916 | break; |
| 917 | } |
| 918 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 919 | { |
| 920 | if (*option == '+') |
| 921 | { |
| 922 | (void) QueryColorDatabase(BorderColor,&draw_info->border_color, |
| 923 | exception); |
| 924 | break; |
| 925 | } |
| 926 | (void) QueryColorDatabase(argv[i+1],&draw_info->border_color, |
| 927 | exception); |
| 928 | break; |
| 929 | } |
| 930 | if (LocaleCompare("box",option+1) == 0) |
| 931 | { |
| 932 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 933 | exception); |
| 934 | break; |
| 935 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 936 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 937 | { |
| 938 | double |
| 939 | brightness, |
| 940 | contrast; |
| 941 | |
| 942 | GeometryInfo |
| 943 | geometry_info; |
| 944 | |
| 945 | MagickStatusType |
| 946 | flags; |
| 947 | |
| 948 | /* |
| 949 | Brightness / contrast image. |
| 950 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 951 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 952 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 953 | brightness=geometry_info.rho; |
cristy | 81fbc8b | 2010-01-11 20:04:07 +0000 | [diff] [blame] | 954 | contrast=0.0; |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 955 | if ((flags & SigmaValue) != 0) |
| 956 | contrast=geometry_info.sigma; |
cristy | 02cc0f2 | 2010-01-12 00:02:32 +0000 | [diff] [blame] | 957 | (void) BrightnessContrastImageChannel(*image,channel,brightness, |
| 958 | contrast); |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 959 | InheritException(exception,&(*image)->exception); |
| 960 | break; |
| 961 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 962 | break; |
| 963 | } |
| 964 | case 'c': |
| 965 | { |
| 966 | if (LocaleCompare("cdl",option+1) == 0) |
| 967 | { |
| 968 | char |
| 969 | *color_correction_collection; |
| 970 | |
| 971 | /* |
| 972 | Color correct with a color decision list. |
| 973 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 974 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 975 | color_correction_collection=FileToString(argv[i+1],~0,exception); |
| 976 | if (color_correction_collection == (char *) NULL) |
| 977 | break; |
| 978 | (void) ColorDecisionListImage(*image,color_correction_collection); |
| 979 | InheritException(exception,&(*image)->exception); |
| 980 | break; |
| 981 | } |
| 982 | if (LocaleCompare("channel",option+1) == 0) |
| 983 | { |
| 984 | if (*option == '+') |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 985 | channel=DefaultChannels; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 986 | else |
| 987 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 988 | break; |
| 989 | } |
| 990 | if (LocaleCompare("charcoal",option+1) == 0) |
| 991 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 992 | /* |
| 993 | Charcoal image. |
| 994 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 995 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 996 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 997 | if ((flags & SigmaValue) == 0) |
| 998 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 999 | mogrify_image=CharcoalImage(*image,geometry_info.rho, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1000 | geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1001 | break; |
| 1002 | } |
| 1003 | if (LocaleCompare("chop",option+1) == 0) |
| 1004 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1005 | /* |
| 1006 | Chop the image. |
| 1007 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1008 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1009 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1010 | mogrify_image=ChopImage(*image,&geometry,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1011 | break; |
| 1012 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 1013 | if (LocaleCompare("clamp",option+1) == 0) |
| 1014 | { |
| 1015 | /* |
| 1016 | Clamp image. |
| 1017 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1018 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 1019 | (void) ClampImageChannel(*image,channel); |
| 1020 | InheritException(exception,&(*image)->exception); |
| 1021 | break; |
| 1022 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1023 | if (LocaleCompare("clip",option+1) == 0) |
| 1024 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1025 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1026 | if (*option == '+') |
| 1027 | { |
| 1028 | (void) SetImageClipMask(*image,(Image *) NULL); |
| 1029 | InheritException(exception,&(*image)->exception); |
| 1030 | break; |
| 1031 | } |
| 1032 | (void) ClipImage(*image); |
| 1033 | InheritException(exception,&(*image)->exception); |
| 1034 | break; |
| 1035 | } |
| 1036 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1037 | { |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1038 | CacheView |
| 1039 | *mask_view; |
cristy | a01cbea | 2010-11-03 16:33:33 +0000 | [diff] [blame] | 1040 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1041 | Image |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1042 | *mask_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1043 | |
cristy | 9d314ff | 2011-03-09 01:30:28 +0000 | [diff] [blame] | 1044 | register PixelPacket |
| 1045 | *restrict q; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1046 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1047 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1048 | x; |
| 1049 | |
cristy | 9d314ff | 2011-03-09 01:30:28 +0000 | [diff] [blame] | 1050 | ssize_t |
| 1051 | y; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1052 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1053 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1054 | if (*option == '+') |
| 1055 | { |
| 1056 | /* |
| 1057 | Remove a mask. |
| 1058 | */ |
| 1059 | (void) SetImageMask(*image,(Image *) NULL); |
| 1060 | InheritException(exception,&(*image)->exception); |
| 1061 | break; |
| 1062 | } |
| 1063 | /* |
| 1064 | Set the image mask. |
anthony | 77cc4a4 | 2011-04-14 02:59:06 +0000 | [diff] [blame] | 1065 | FUTURE: This Should Be a SetImageAlphaChannel() call, Or two. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1066 | */ |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1067 | mask_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1068 | if (mask_image == (Image *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1069 | break; |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1070 | if (SetImageStorageClass(mask_image,DirectClass) == MagickFalse) |
| 1071 | return(MagickFalse); |
| 1072 | mask_view=AcquireCacheView(mask_image); |
| 1073 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1074 | { |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1075 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1076 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1077 | if (q == (PixelPacket *) NULL) |
| 1078 | break; |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1079 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1080 | { |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1081 | if (mask_image->matte == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1082 | q->opacity=PixelIntensityToQuantum(q); |
| 1083 | q->red=q->opacity; |
| 1084 | q->green=q->opacity; |
| 1085 | q->blue=q->opacity; |
| 1086 | q++; |
| 1087 | } |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1088 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1089 | break; |
| 1090 | } |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1091 | mask_view=DestroyCacheView(mask_view); |
| 1092 | mask_image->matte=MagickTrue; |
| 1093 | (void) SetImageClipMask(*image,mask_image); |
| 1094 | mask_image=DestroyImage(mask_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1095 | InheritException(exception,&(*image)->exception); |
| 1096 | break; |
| 1097 | } |
| 1098 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1099 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1100 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1101 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
| 1102 | MagickFalse); |
| 1103 | InheritException(exception,&(*image)->exception); |
| 1104 | break; |
| 1105 | } |
| 1106 | if (LocaleCompare("colorize",option+1) == 0) |
| 1107 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1108 | /* |
| 1109 | Colorize the image. |
| 1110 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1111 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1112 | mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1113 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1114 | break; |
| 1115 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 1116 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1117 | { |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 1118 | KernelInfo |
| 1119 | *kernel; |
| 1120 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1121 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 1122 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1123 | if (kernel == (KernelInfo *) NULL) |
| 1124 | break; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1125 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 1126 | kernel=DestroyKernelInfo(kernel); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 1127 | break; |
| 1128 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1129 | if (LocaleCompare("colors",option+1) == 0) |
| 1130 | { |
| 1131 | /* |
| 1132 | Reduce the number of colors in the image. |
| 1133 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1134 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 1135 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1136 | if (quantize_info->number_colors == 0) |
| 1137 | break; |
| 1138 | if (((*image)->storage_class == DirectClass) || |
| 1139 | (*image)->colors > quantize_info->number_colors) |
| 1140 | (void) QuantizeImage(quantize_info,*image); |
| 1141 | else |
| 1142 | (void) CompressImageColormap(*image); |
| 1143 | InheritException(exception,&(*image)->exception); |
| 1144 | break; |
| 1145 | } |
| 1146 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1147 | { |
| 1148 | ColorspaceType |
| 1149 | colorspace; |
| 1150 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1151 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1152 | if (*option == '+') |
| 1153 | { |
| 1154 | (void) TransformImageColorspace(*image,RGBColorspace); |
| 1155 | InheritException(exception,&(*image)->exception); |
| 1156 | break; |
| 1157 | } |
| 1158 | colorspace=(ColorspaceType) ParseMagickOption( |
| 1159 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 1160 | (void) TransformImageColorspace(*image,colorspace); |
| 1161 | InheritException(exception,&(*image)->exception); |
| 1162 | break; |
| 1163 | } |
| 1164 | if (LocaleCompare("contrast",option+1) == 0) |
| 1165 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1166 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1167 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
| 1168 | MagickFalse); |
| 1169 | InheritException(exception,&(*image)->exception); |
| 1170 | break; |
| 1171 | } |
| 1172 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1173 | { |
| 1174 | double |
| 1175 | black_point, |
| 1176 | white_point; |
| 1177 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1178 | MagickStatusType |
| 1179 | flags; |
| 1180 | |
| 1181 | /* |
| 1182 | Contrast stretch image. |
| 1183 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1184 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1185 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1186 | black_point=geometry_info.rho; |
| 1187 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1188 | black_point; |
| 1189 | if ((flags & PercentValue) != 0) |
| 1190 | { |
| 1191 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1192 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1193 | } |
| 1194 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1195 | white_point; |
| 1196 | (void) ContrastStretchImageChannel(*image,channel,black_point, |
| 1197 | white_point); |
| 1198 | InheritException(exception,&(*image)->exception); |
| 1199 | break; |
| 1200 | } |
| 1201 | if (LocaleCompare("convolve",option+1) == 0) |
| 1202 | { |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1203 | double |
| 1204 | gamma; |
| 1205 | |
cristy | 2be1538 | 2010-01-21 02:38:03 +0000 | [diff] [blame] | 1206 | KernelInfo |
cristy | 56a9e51 | 2010-01-06 18:18:55 +0000 | [diff] [blame] | 1207 | *kernel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1208 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1209 | register ssize_t |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1210 | j; |
| 1211 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1212 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 2be1538 | 2010-01-21 02:38:03 +0000 | [diff] [blame] | 1213 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1214 | if (kernel == (KernelInfo *) NULL) |
cristy | 56a9e51 | 2010-01-06 18:18:55 +0000 | [diff] [blame] | 1215 | break; |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1216 | gamma=0.0; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1217 | for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++) |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1218 | gamma+=kernel->values[j]; |
| 1219 | gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1220 | for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++) |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1221 | kernel->values[j]*=gamma; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1222 | mogrify_image=FilterImageChannel(*image,channel,kernel,exception); |
anthony | 83ba99b | 2010-01-24 08:48:15 +0000 | [diff] [blame] | 1223 | kernel=DestroyKernelInfo(kernel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1224 | break; |
| 1225 | } |
| 1226 | if (LocaleCompare("crop",option+1) == 0) |
| 1227 | { |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 1228 | /* |
| 1229 | Crop a image to a smaller size |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 1230 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1231 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 1232 | #if 0 |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1233 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1234 | if (((geometry.width != 0) || (geometry.height != 0)) && |
| 1235 | ((flags & XValue) == 0) && ((flags & YValue) == 0)) |
| 1236 | break; |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 1237 | #endif |
| 1238 | #if 0 |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1239 | mogrify_image=CloneImage(*image,0,0,MagickTrue,&(*image)->exception); |
| 1240 | mogrify_image->next = mogrify_image->previous = (Image *)NULL; |
| 1241 | (void) TransformImage(&mogrify_image,argv[i+1],(char *) NULL); |
| 1242 | InheritException(exception,&mogrify_image->exception); |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 1243 | #else |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1244 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 1245 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1246 | break; |
| 1247 | } |
| 1248 | if (LocaleCompare("cycle",option+1) == 0) |
| 1249 | { |
| 1250 | /* |
| 1251 | Cycle an image colormap. |
| 1252 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1253 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 1254 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1])); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1255 | InheritException(exception,&(*image)->exception); |
| 1256 | break; |
| 1257 | } |
| 1258 | break; |
| 1259 | } |
| 1260 | case 'd': |
| 1261 | { |
| 1262 | if (LocaleCompare("decipher",option+1) == 0) |
| 1263 | { |
| 1264 | StringInfo |
| 1265 | *passkey; |
| 1266 | |
| 1267 | /* |
| 1268 | Decipher pixels. |
| 1269 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1270 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1271 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1272 | if (passkey != (StringInfo *) NULL) |
| 1273 | { |
| 1274 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1275 | passkey=DestroyStringInfo(passkey); |
| 1276 | } |
| 1277 | break; |
| 1278 | } |
| 1279 | if (LocaleCompare("density",option+1) == 0) |
| 1280 | { |
| 1281 | /* |
| 1282 | Set image density. |
| 1283 | */ |
| 1284 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1285 | break; |
| 1286 | } |
| 1287 | if (LocaleCompare("depth",option+1) == 0) |
| 1288 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1289 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1290 | if (*option == '+') |
| 1291 | { |
| 1292 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH); |
| 1293 | break; |
| 1294 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 1295 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1])); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1296 | break; |
| 1297 | } |
| 1298 | if (LocaleCompare("deskew",option+1) == 0) |
| 1299 | { |
| 1300 | double |
| 1301 | threshold; |
| 1302 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1303 | /* |
| 1304 | Straighten the image. |
| 1305 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1306 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1307 | if (*option == '+') |
| 1308 | threshold=40.0*QuantumRange/100.0; |
| 1309 | else |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1310 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1311 | mogrify_image=DeskewImage(*image,threshold,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1312 | break; |
| 1313 | } |
| 1314 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1315 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1316 | /* |
| 1317 | Reduce the speckles within an image. |
| 1318 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1319 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1320 | mogrify_image=DespeckleImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1321 | break; |
| 1322 | } |
| 1323 | if (LocaleCompare("display",option+1) == 0) |
| 1324 | { |
| 1325 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1326 | break; |
| 1327 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1328 | if (LocaleCompare("distort",option+1) == 0) |
| 1329 | { |
| 1330 | char |
| 1331 | *args, |
| 1332 | token[MaxTextExtent]; |
| 1333 | |
| 1334 | const char |
| 1335 | *p; |
| 1336 | |
| 1337 | DistortImageMethod |
| 1338 | method; |
| 1339 | |
| 1340 | double |
| 1341 | *arguments; |
| 1342 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1343 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1344 | x; |
| 1345 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1346 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1347 | number_arguments; |
| 1348 | |
| 1349 | /* |
| 1350 | Distort image. |
| 1351 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1352 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1353 | method=(DistortImageMethod) ParseMagickOption(MagickDistortOptions, |
| 1354 | MagickFalse,argv[i+1]); |
anthony | 2029ddc | 2011-03-30 12:13:27 +0000 | [diff] [blame] | 1355 | if ( method == ResizeDistortion ) |
| 1356 | { |
| 1357 | /* Special Case - Argument is actually a resize geometry! |
| 1358 | ** Convert that to an appropriate distortion argument array. |
| 1359 | */ |
| 1360 | double |
| 1361 | resize_args[2]; |
| 1362 | (void) ParseRegionGeometry(*image,argv[i+2],&geometry, |
| 1363 | exception); |
| 1364 | resize_args[0]=(double)geometry.width; |
| 1365 | resize_args[1]=(double)geometry.height; |
| 1366 | mogrify_image=DistortImage(*image,method,(size_t)2, |
| 1367 | resize_args,MagickTrue,exception); |
| 1368 | break; |
| 1369 | } |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1370 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1371 | InheritException(exception,&(*image)->exception); |
| 1372 | if (args == (char *) NULL) |
| 1373 | break; |
| 1374 | p=(char *) args; |
| 1375 | for (x=0; *p != '\0'; x++) |
| 1376 | { |
| 1377 | GetMagickToken(p,&p,token); |
| 1378 | if (*token == ',') |
| 1379 | GetMagickToken(p,&p,token); |
| 1380 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1381 | number_arguments=(size_t) x; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1382 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1383 | sizeof(*arguments)); |
| 1384 | if (arguments == (double *) NULL) |
| 1385 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1386 | "MemoryAllocationFailed",(*image)->filename); |
| 1387 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1388 | sizeof(*arguments)); |
| 1389 | p=(char *) args; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1390 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1391 | { |
| 1392 | GetMagickToken(p,&p,token); |
| 1393 | if (*token == ',') |
| 1394 | GetMagickToken(p,&p,token); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1395 | arguments[x]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1396 | } |
| 1397 | args=DestroyString(args); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1398 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1399 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1400 | arguments=(double *) RelinquishMagickMemory(arguments); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1401 | break; |
| 1402 | } |
| 1403 | if (LocaleCompare("dither",option+1) == 0) |
| 1404 | { |
| 1405 | if (*option == '+') |
| 1406 | { |
| 1407 | quantize_info->dither=MagickFalse; |
| 1408 | break; |
| 1409 | } |
| 1410 | quantize_info->dither=MagickTrue; |
| 1411 | quantize_info->dither_method=(DitherMethod) ParseMagickOption( |
| 1412 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1413 | if (quantize_info->dither_method == NoDitherMethod) |
| 1414 | quantize_info->dither=MagickFalse; |
| 1415 | break; |
| 1416 | } |
| 1417 | if (LocaleCompare("draw",option+1) == 0) |
| 1418 | { |
| 1419 | /* |
| 1420 | Draw image. |
| 1421 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1422 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1423 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
| 1424 | (void) DrawImage(*image,draw_info); |
| 1425 | InheritException(exception,&(*image)->exception); |
| 1426 | break; |
| 1427 | } |
| 1428 | break; |
| 1429 | } |
| 1430 | case 'e': |
| 1431 | { |
| 1432 | if (LocaleCompare("edge",option+1) == 0) |
| 1433 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1434 | /* |
| 1435 | Enhance edges in the image. |
| 1436 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1437 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1438 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1439 | if ((flags & SigmaValue) == 0) |
| 1440 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1441 | mogrify_image=EdgeImage(*image,geometry_info.rho,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1442 | break; |
| 1443 | } |
| 1444 | if (LocaleCompare("emboss",option+1) == 0) |
| 1445 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1446 | /* |
| 1447 | Gaussian embossen image. |
| 1448 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1449 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1450 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1451 | if ((flags & SigmaValue) == 0) |
| 1452 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1453 | mogrify_image=EmbossImage(*image,geometry_info.rho, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1454 | geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1455 | break; |
| 1456 | } |
| 1457 | if (LocaleCompare("encipher",option+1) == 0) |
| 1458 | { |
| 1459 | StringInfo |
| 1460 | *passkey; |
| 1461 | |
| 1462 | /* |
| 1463 | Encipher pixels. |
| 1464 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1465 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1466 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1467 | if (passkey != (StringInfo *) NULL) |
| 1468 | { |
| 1469 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1470 | passkey=DestroyStringInfo(passkey); |
| 1471 | } |
| 1472 | break; |
| 1473 | } |
| 1474 | if (LocaleCompare("encoding",option+1) == 0) |
| 1475 | { |
| 1476 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1477 | break; |
| 1478 | } |
| 1479 | if (LocaleCompare("enhance",option+1) == 0) |
| 1480 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1481 | /* |
| 1482 | Enhance image. |
| 1483 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1484 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1485 | mogrify_image=EnhanceImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1486 | break; |
| 1487 | } |
| 1488 | if (LocaleCompare("equalize",option+1) == 0) |
| 1489 | { |
| 1490 | /* |
| 1491 | Equalize image. |
| 1492 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1493 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1494 | (void) EqualizeImageChannel(*image,channel); |
| 1495 | InheritException(exception,&(*image)->exception); |
| 1496 | break; |
| 1497 | } |
| 1498 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1499 | { |
| 1500 | double |
| 1501 | constant; |
| 1502 | |
| 1503 | MagickEvaluateOperator |
| 1504 | op; |
| 1505 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1506 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1507 | op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions, |
| 1508 | MagickFalse,argv[i+1]); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1509 | constant=SiPrefixToDouble(argv[i+2],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1510 | (void) EvaluateImageChannel(*image,channel,op,constant,exception); |
| 1511 | break; |
| 1512 | } |
| 1513 | if (LocaleCompare("extent",option+1) == 0) |
| 1514 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1515 | /* |
| 1516 | Set the image extent. |
| 1517 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1518 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1519 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
cristy | f0bbfd9 | 2009-11-25 14:12:31 +0000 | [diff] [blame] | 1520 | if (geometry.width == 0) |
cristy | 2ea9a4e | 2009-11-25 14:30:22 +0000 | [diff] [blame] | 1521 | geometry.width=(*image)->columns; |
cristy | f0bbfd9 | 2009-11-25 14:12:31 +0000 | [diff] [blame] | 1522 | if (geometry.height == 0) |
cristy | 2ea9a4e | 2009-11-25 14:30:22 +0000 | [diff] [blame] | 1523 | geometry.height=(*image)->rows; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1524 | mogrify_image=ExtentImage(*image,&geometry,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1525 | break; |
| 1526 | } |
| 1527 | break; |
| 1528 | } |
| 1529 | case 'f': |
| 1530 | { |
| 1531 | if (LocaleCompare("family",option+1) == 0) |
| 1532 | { |
| 1533 | if (*option == '+') |
| 1534 | { |
| 1535 | if (draw_info->family != (char *) NULL) |
| 1536 | draw_info->family=DestroyString(draw_info->family); |
| 1537 | break; |
| 1538 | } |
| 1539 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1540 | break; |
| 1541 | } |
cristy | 0fe961c | 2010-01-30 03:09:54 +0000 | [diff] [blame] | 1542 | if (LocaleCompare("features",option+1) == 0) |
| 1543 | { |
| 1544 | if (*option == '+') |
| 1545 | { |
| 1546 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1547 | break; |
| 1548 | } |
| 1549 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1550 | break; |
| 1551 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1552 | if (LocaleCompare("fill",option+1) == 0) |
| 1553 | { |
| 1554 | ExceptionInfo |
| 1555 | *sans; |
| 1556 | |
| 1557 | GetMagickPixelPacket(*image,&fill); |
| 1558 | if (*option == '+') |
| 1559 | { |
| 1560 | (void) QueryMagickColor("none",&fill,exception); |
| 1561 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 1562 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1563 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1564 | break; |
| 1565 | } |
| 1566 | sans=AcquireExceptionInfo(); |
| 1567 | (void) QueryMagickColor(argv[i+1],&fill,sans); |
| 1568 | status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans); |
| 1569 | sans=DestroyExceptionInfo(sans); |
| 1570 | if (status == MagickFalse) |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1571 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1572 | exception); |
| 1573 | break; |
| 1574 | } |
| 1575 | if (LocaleCompare("flip",option+1) == 0) |
| 1576 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1577 | /* |
| 1578 | Flip image scanlines. |
| 1579 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1580 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1581 | mogrify_image=FlipImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1582 | break; |
| 1583 | } |
| 1584 | if (LocaleCompare("flop",option+1) == 0) |
| 1585 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1586 | /* |
| 1587 | Flop image scanlines. |
| 1588 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1589 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1590 | mogrify_image=FlopImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1591 | break; |
| 1592 | } |
| 1593 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1594 | { |
| 1595 | MagickPixelPacket |
| 1596 | target; |
| 1597 | |
| 1598 | /* |
| 1599 | Floodfill image. |
| 1600 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1601 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1602 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1603 | (void) QueryMagickColor(argv[i+2],&target,exception); |
| 1604 | (void) FloodfillPaintImage(*image,channel,draw_info,&target, |
| 1605 | geometry.x,geometry.y,*option == '-' ? MagickFalse : MagickTrue); |
| 1606 | InheritException(exception,&(*image)->exception); |
| 1607 | break; |
| 1608 | } |
| 1609 | if (LocaleCompare("font",option+1) == 0) |
| 1610 | { |
| 1611 | if (*option == '+') |
| 1612 | { |
| 1613 | if (draw_info->font != (char *) NULL) |
| 1614 | draw_info->font=DestroyString(draw_info->font); |
| 1615 | break; |
| 1616 | } |
| 1617 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1618 | break; |
| 1619 | } |
| 1620 | if (LocaleCompare("format",option+1) == 0) |
| 1621 | { |
| 1622 | format=argv[i+1]; |
| 1623 | break; |
| 1624 | } |
| 1625 | if (LocaleCompare("frame",option+1) == 0) |
| 1626 | { |
| 1627 | FrameInfo |
| 1628 | frame_info; |
| 1629 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1630 | /* |
| 1631 | Surround image with an ornamental border. |
| 1632 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1633 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1634 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1635 | frame_info.width=geometry.width; |
| 1636 | frame_info.height=geometry.height; |
| 1637 | if ((flags & HeightValue) == 0) |
| 1638 | frame_info.height=geometry.width; |
| 1639 | frame_info.outer_bevel=geometry.x; |
| 1640 | frame_info.inner_bevel=geometry.y; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1641 | frame_info.x=(ssize_t) frame_info.width; |
| 1642 | frame_info.y=(ssize_t) frame_info.height; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1643 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1644 | frame_info.height=(*image)->rows+2*frame_info.height; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1645 | mogrify_image=FrameImage(*image,&frame_info,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1646 | break; |
| 1647 | } |
| 1648 | if (LocaleCompare("function",option+1) == 0) |
| 1649 | { |
| 1650 | char |
| 1651 | *arguments, |
| 1652 | token[MaxTextExtent]; |
| 1653 | |
| 1654 | const char |
| 1655 | *p; |
| 1656 | |
| 1657 | double |
| 1658 | *parameters; |
| 1659 | |
| 1660 | MagickFunction |
| 1661 | function; |
| 1662 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1663 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1664 | x; |
| 1665 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1666 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1667 | number_parameters; |
| 1668 | |
| 1669 | /* |
| 1670 | Function Modify Image Values |
| 1671 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1672 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1673 | function=(MagickFunction) ParseMagickOption(MagickFunctionOptions, |
| 1674 | MagickFalse,argv[i+1]); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1675 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1676 | InheritException(exception,&(*image)->exception); |
| 1677 | if (arguments == (char *) NULL) |
| 1678 | break; |
| 1679 | p=(char *) arguments; |
| 1680 | for (x=0; *p != '\0'; x++) |
| 1681 | { |
| 1682 | GetMagickToken(p,&p,token); |
| 1683 | if (*token == ',') |
| 1684 | GetMagickToken(p,&p,token); |
| 1685 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1686 | number_parameters=(size_t) x; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1687 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1688 | sizeof(*parameters)); |
| 1689 | if (parameters == (double *) NULL) |
| 1690 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1691 | "MemoryAllocationFailed",(*image)->filename); |
| 1692 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1693 | sizeof(*parameters)); |
| 1694 | p=(char *) arguments; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1695 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1696 | { |
| 1697 | GetMagickToken(p,&p,token); |
| 1698 | if (*token == ',') |
| 1699 | GetMagickToken(p,&p,token); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1700 | parameters[x]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1701 | } |
| 1702 | arguments=DestroyString(arguments); |
| 1703 | (void) FunctionImageChannel(*image,channel,function, |
| 1704 | number_parameters,parameters,exception); |
| 1705 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1706 | break; |
| 1707 | } |
| 1708 | break; |
| 1709 | } |
| 1710 | case 'g': |
| 1711 | { |
| 1712 | if (LocaleCompare("gamma",option+1) == 0) |
| 1713 | { |
| 1714 | /* |
| 1715 | Gamma image. |
| 1716 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1717 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1718 | if (*option == '+') |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1719 | (*image)->gamma=StringToDouble(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1720 | else |
| 1721 | { |
| 1722 | if (strchr(argv[i+1],',') != (char *) NULL) |
| 1723 | (void) GammaImage(*image,argv[i+1]); |
| 1724 | else |
cristy | a5447be | 2010-01-11 00:20:51 +0000 | [diff] [blame] | 1725 | (void) GammaImageChannel(*image,channel, |
| 1726 | StringToDouble(argv[i+1])); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1727 | InheritException(exception,&(*image)->exception); |
| 1728 | } |
| 1729 | break; |
| 1730 | } |
| 1731 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1732 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1733 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1734 | /* |
| 1735 | Gaussian blur image. |
| 1736 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1737 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1738 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1739 | if ((flags & SigmaValue) == 0) |
| 1740 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1741 | mogrify_image=GaussianBlurImageChannel(*image,channel, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1742 | geometry_info.rho,geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1743 | break; |
| 1744 | } |
| 1745 | if (LocaleCompare("geometry",option+1) == 0) |
| 1746 | { |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 1747 | /* |
| 1748 | Record Image offset, Resize last image. |
| 1749 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1750 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1751 | if (*option == '+') |
| 1752 | { |
| 1753 | if ((*image)->geometry != (char *) NULL) |
| 1754 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1755 | break; |
| 1756 | } |
| 1757 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1758 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1759 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1760 | else |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1761 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 1762 | (*image)->filter,(*image)->blur,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1763 | break; |
| 1764 | } |
| 1765 | if (LocaleCompare("gravity",option+1) == 0) |
| 1766 | { |
| 1767 | if (*option == '+') |
| 1768 | { |
| 1769 | draw_info->gravity=UndefinedGravity; |
| 1770 | break; |
| 1771 | } |
| 1772 | draw_info->gravity=(GravityType) ParseMagickOption( |
| 1773 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1774 | break; |
| 1775 | } |
| 1776 | break; |
| 1777 | } |
| 1778 | case 'h': |
| 1779 | { |
| 1780 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1781 | { |
| 1782 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1783 | break; |
| 1784 | } |
| 1785 | break; |
| 1786 | } |
| 1787 | case 'i': |
| 1788 | { |
| 1789 | if (LocaleCompare("identify",option+1) == 0) |
| 1790 | { |
| 1791 | char |
| 1792 | *text; |
| 1793 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1794 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1795 | if (format == (char *) NULL) |
| 1796 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1797 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1798 | InheritException(exception,&(*image)->exception); |
| 1799 | break; |
| 1800 | } |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1801 | text=InterpretImageProperties(mogrify_info,*image,format); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1802 | InheritException(exception,&(*image)->exception); |
| 1803 | if (text == (char *) NULL) |
| 1804 | break; |
| 1805 | (void) fputs(text,stdout); |
| 1806 | (void) fputc('\n',stdout); |
| 1807 | text=DestroyString(text); |
| 1808 | break; |
| 1809 | } |
| 1810 | if (LocaleCompare("implode",option+1) == 0) |
| 1811 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1812 | /* |
| 1813 | Implode image. |
| 1814 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1815 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1816 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1817 | mogrify_image=ImplodeImage(*image,geometry_info.rho,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1818 | break; |
| 1819 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 1820 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1821 | { |
| 1822 | if (*option == '+') |
| 1823 | (void) ParseGeometry("0",&geometry_info); |
| 1824 | else |
| 1825 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1826 | draw_info->interline_spacing=geometry_info.rho; |
| 1827 | break; |
| 1828 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1829 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1830 | { |
| 1831 | if (*option == '+') |
| 1832 | (void) ParseGeometry("0",&geometry_info); |
| 1833 | else |
| 1834 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1835 | draw_info->interword_spacing=geometry_info.rho; |
| 1836 | break; |
| 1837 | } |
| 1838 | break; |
| 1839 | } |
| 1840 | case 'k': |
| 1841 | { |
| 1842 | if (LocaleCompare("kerning",option+1) == 0) |
| 1843 | { |
| 1844 | if (*option == '+') |
| 1845 | (void) ParseGeometry("0",&geometry_info); |
| 1846 | else |
| 1847 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1848 | draw_info->kerning=geometry_info.rho; |
| 1849 | break; |
| 1850 | } |
| 1851 | break; |
| 1852 | } |
| 1853 | case 'l': |
| 1854 | { |
| 1855 | if (LocaleCompare("lat",option+1) == 0) |
| 1856 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1857 | /* |
| 1858 | Local adaptive threshold image. |
| 1859 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1860 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1861 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1862 | if ((flags & PercentValue) != 0) |
| 1863 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1864 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
| 1865 | geometry_info.rho,(size_t) geometry_info.sigma,(ssize_t) |
| 1866 | geometry_info.xi,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1867 | break; |
| 1868 | } |
| 1869 | if (LocaleCompare("level",option+1) == 0) |
| 1870 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1871 | MagickRealType |
| 1872 | black_point, |
| 1873 | gamma, |
| 1874 | white_point; |
| 1875 | |
| 1876 | MagickStatusType |
| 1877 | flags; |
| 1878 | |
| 1879 | /* |
| 1880 | Parse levels. |
| 1881 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1882 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1883 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1884 | black_point=geometry_info.rho; |
| 1885 | white_point=(MagickRealType) QuantumRange; |
| 1886 | if ((flags & SigmaValue) != 0) |
| 1887 | white_point=geometry_info.sigma; |
| 1888 | gamma=1.0; |
| 1889 | if ((flags & XiValue) != 0) |
| 1890 | gamma=geometry_info.xi; |
| 1891 | if ((flags & PercentValue) != 0) |
| 1892 | { |
| 1893 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 1894 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 1895 | } |
| 1896 | if ((flags & SigmaValue) == 0) |
| 1897 | white_point=(MagickRealType) QuantumRange-black_point; |
| 1898 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
| 1899 | (void) LevelizeImageChannel(*image,channel,black_point, |
| 1900 | white_point,gamma); |
| 1901 | else |
| 1902 | (void) LevelImageChannel(*image,channel,black_point,white_point, |
| 1903 | gamma); |
| 1904 | InheritException(exception,&(*image)->exception); |
| 1905 | break; |
| 1906 | } |
| 1907 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1908 | { |
| 1909 | char |
| 1910 | token[MaxTextExtent]; |
| 1911 | |
| 1912 | const char |
| 1913 | *p; |
| 1914 | |
| 1915 | MagickPixelPacket |
| 1916 | black_point, |
| 1917 | white_point; |
| 1918 | |
| 1919 | p=(const char *) argv[i+1]; |
| 1920 | GetMagickToken(p,&p,token); /* get black point color */ |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 1921 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1922 | (void) QueryMagickColor(token,&black_point,exception); |
| 1923 | else |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 1924 | (void) QueryMagickColor("#000000",&black_point,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1925 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1926 | GetMagickToken(p,&p,token); |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 1927 | if (*token == '\0') |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1928 | white_point=black_point; /* set everything to that color */ |
| 1929 | else |
| 1930 | { |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 1931 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 1932 | GetMagickToken(p,&p,token); /* Get white point color. */ |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 1933 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1934 | (void) QueryMagickColor(token,&white_point,exception); |
| 1935 | else |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 1936 | (void) QueryMagickColor("#ffffff",&white_point,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1937 | } |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 1938 | (void) LevelColorsImageChannel(*image,channel,&black_point, |
| 1939 | &white_point,*option == '+' ? MagickTrue : MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1940 | break; |
| 1941 | } |
| 1942 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 1943 | { |
| 1944 | double |
| 1945 | black_point, |
| 1946 | white_point; |
| 1947 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1948 | MagickStatusType |
| 1949 | flags; |
| 1950 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1951 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1952 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1953 | black_point=geometry_info.rho; |
| 1954 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 1955 | if ((flags & SigmaValue) != 0) |
| 1956 | white_point=geometry_info.sigma; |
| 1957 | if ((flags & PercentValue) != 0) |
| 1958 | { |
| 1959 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1960 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1961 | } |
| 1962 | if ((flags & SigmaValue) == 0) |
| 1963 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1964 | black_point; |
| 1965 | (void) LinearStretchImage(*image,black_point,white_point); |
| 1966 | InheritException(exception,&(*image)->exception); |
| 1967 | break; |
| 1968 | } |
| 1969 | if (LocaleCompare("linewidth",option+1) == 0) |
| 1970 | { |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1971 | draw_info->stroke_width=StringToDouble(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1972 | break; |
| 1973 | } |
| 1974 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 1975 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1976 | /* |
| 1977 | Liquid rescale image. |
| 1978 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1979 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1980 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1981 | if ((flags & XValue) == 0) |
| 1982 | geometry.x=1; |
| 1983 | if ((flags & YValue) == 0) |
| 1984 | geometry.y=0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 1985 | mogrify_image=LiquidRescaleImage(*image,geometry.width, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1986 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1987 | break; |
| 1988 | } |
| 1989 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 1990 | { |
| 1991 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1992 | break; |
| 1993 | } |
| 1994 | break; |
| 1995 | } |
| 1996 | case 'm': |
| 1997 | { |
| 1998 | if (LocaleCompare("map",option+1) == 0) |
| 1999 | { |
| 2000 | Image |
| 2001 | *remap_image; |
| 2002 | |
| 2003 | /* |
| 2004 | Transform image colors to match this set of colors. |
| 2005 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2006 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2007 | if (*option == '+') |
| 2008 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2009 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2010 | if (remap_image == (Image *) NULL) |
| 2011 | break; |
| 2012 | (void) RemapImage(quantize_info,*image,remap_image); |
| 2013 | InheritException(exception,&(*image)->exception); |
| 2014 | remap_image=DestroyImage(remap_image); |
| 2015 | break; |
| 2016 | } |
| 2017 | if (LocaleCompare("mask",option+1) == 0) |
| 2018 | { |
| 2019 | Image |
| 2020 | *mask; |
| 2021 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2022 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2023 | if (*option == '+') |
| 2024 | { |
| 2025 | /* |
| 2026 | Remove a mask. |
| 2027 | */ |
| 2028 | (void) SetImageMask(*image,(Image *) NULL); |
| 2029 | InheritException(exception,&(*image)->exception); |
| 2030 | break; |
| 2031 | } |
| 2032 | /* |
| 2033 | Set the image mask. |
| 2034 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2035 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2036 | if (mask == (Image *) NULL) |
| 2037 | break; |
| 2038 | (void) SetImageMask(*image,mask); |
| 2039 | mask=DestroyImage(mask); |
| 2040 | InheritException(exception,&(*image)->exception); |
| 2041 | break; |
| 2042 | } |
| 2043 | if (LocaleCompare("matte",option+1) == 0) |
| 2044 | { |
| 2045 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
| 2046 | SetAlphaChannel : DeactivateAlphaChannel ); |
| 2047 | InheritException(exception,&(*image)->exception); |
| 2048 | break; |
| 2049 | } |
| 2050 | if (LocaleCompare("median",option+1) == 0) |
| 2051 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2052 | /* |
| 2053 | Median filter image. |
| 2054 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2055 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2056 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2057 | mogrify_image=StatisticImageChannel(*image,channel,MedianStatistic, |
cristy | 95c3834 | 2011-03-18 22:39:51 +0000 | [diff] [blame] | 2058 | (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2059 | break; |
| 2060 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 2061 | if (LocaleCompare("mode",option+1) == 0) |
| 2062 | { |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 2063 | /* |
| 2064 | Mode image. |
| 2065 | */ |
| 2066 | (void) SyncImageSettings(mogrify_info,*image); |
| 2067 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2068 | mogrify_image=StatisticImageChannel(*image,channel,ModeStatistic, |
cristy | 95c3834 | 2011-03-18 22:39:51 +0000 | [diff] [blame] | 2069 | (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception); |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 2070 | break; |
| 2071 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2072 | if (LocaleCompare("modulate",option+1) == 0) |
| 2073 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2074 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2075 | (void) ModulateImage(*image,argv[i+1]); |
| 2076 | InheritException(exception,&(*image)->exception); |
| 2077 | break; |
| 2078 | } |
| 2079 | if (LocaleCompare("monitor",option+1) == 0) |
| 2080 | { |
cristy | 7d34ef2 | 2010-03-25 01:11:22 +0000 | [diff] [blame] | 2081 | if (*option == '+') |
| 2082 | { |
| 2083 | (void) SetImageProgressMonitor(*image, |
| 2084 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2085 | break; |
| 2086 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2087 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2088 | (void *) NULL); |
| 2089 | break; |
| 2090 | } |
| 2091 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2092 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2093 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2094 | (void) SetImageType(*image,BilevelType); |
| 2095 | InheritException(exception,&(*image)->exception); |
| 2096 | break; |
| 2097 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2098 | if (LocaleCompare("morphology",option+1) == 0) |
| 2099 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2100 | char |
| 2101 | token[MaxTextExtent]; |
| 2102 | |
| 2103 | const char |
| 2104 | *p; |
| 2105 | |
cristy | e96405a | 2010-05-19 02:24:31 +0000 | [diff] [blame] | 2106 | KernelInfo |
| 2107 | *kernel; |
| 2108 | |
cristy | e96405a | 2010-05-19 02:24:31 +0000 | [diff] [blame] | 2109 | MorphologyMethod |
| 2110 | method; |
| 2111 | |
cristy | 9d314ff | 2011-03-09 01:30:28 +0000 | [diff] [blame] | 2112 | ssize_t |
| 2113 | iterations; |
| 2114 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2115 | /* |
| 2116 | Morphological Image Operation |
| 2117 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2118 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2119 | p=argv[i+1]; |
| 2120 | GetMagickToken(p,&p,token); |
| 2121 | method=(MorphologyMethod) ParseMagickOption(MagickMorphologyOptions, |
cristy | d2c1e1e | 2010-05-08 01:05:44 +0000 | [diff] [blame] | 2122 | MagickFalse,token); |
cristy | ef65691 | 2010-03-05 19:54:59 +0000 | [diff] [blame] | 2123 | iterations=1L; |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2124 | GetMagickToken(p,&p,token); |
cristy | ef65691 | 2010-03-05 19:54:59 +0000 | [diff] [blame] | 2125 | if ((*p == ':') || (*p == ',')) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2126 | GetMagickToken(p,&p,token); |
cristy | ef65691 | 2010-03-05 19:54:59 +0000 | [diff] [blame] | 2127 | if ((*p != '\0')) |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 2128 | iterations=(ssize_t) StringToLong(p); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2129 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2130 | if (kernel == (KernelInfo *) NULL) |
cristy | e96405a | 2010-05-19 02:24:31 +0000 | [diff] [blame] | 2131 | { |
| 2132 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2133 | OptionError,"UnabletoParseKernel","morphology"); |
| 2134 | status=MagickFalse; |
| 2135 | break; |
| 2136 | } |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2137 | mogrify_image=MorphologyImageChannel(*image,channel,method, |
cristy | 02d5b4f | 2010-02-01 01:08:27 +0000 | [diff] [blame] | 2138 | iterations,kernel,exception); |
anthony | 83ba99b | 2010-01-24 08:48:15 +0000 | [diff] [blame] | 2139 | kernel=DestroyKernelInfo(kernel); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2140 | break; |
| 2141 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2142 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2143 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2144 | /* |
| 2145 | Motion blur image. |
| 2146 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2147 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2148 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2149 | if ((flags & SigmaValue) == 0) |
| 2150 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2151 | mogrify_image=MotionBlurImageChannel(*image,channel, |
| 2152 | geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2153 | break; |
| 2154 | } |
| 2155 | break; |
| 2156 | } |
| 2157 | case 'n': |
| 2158 | { |
| 2159 | if (LocaleCompare("negate",option+1) == 0) |
| 2160 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2161 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2162 | (void) NegateImageChannel(*image,channel,*option == '+' ? |
| 2163 | MagickTrue : MagickFalse); |
| 2164 | InheritException(exception,&(*image)->exception); |
| 2165 | break; |
| 2166 | } |
| 2167 | if (LocaleCompare("noise",option+1) == 0) |
| 2168 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2169 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2170 | if (*option == '-') |
| 2171 | { |
| 2172 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2173 | mogrify_image=StatisticImageChannel(*image,channel, |
cristy | 95c3834 | 2011-03-18 22:39:51 +0000 | [diff] [blame] | 2174 | NonpeakStatistic,(size_t) geometry_info.rho,(size_t) |
| 2175 | geometry_info.rho,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2176 | } |
| 2177 | else |
| 2178 | { |
| 2179 | NoiseType |
| 2180 | noise; |
| 2181 | |
| 2182 | noise=(NoiseType) ParseMagickOption(MagickNoiseOptions, |
| 2183 | MagickFalse,argv[i+1]); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2184 | mogrify_image=AddNoiseImageChannel(*image,channel,noise, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2185 | exception); |
| 2186 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2187 | break; |
| 2188 | } |
| 2189 | if (LocaleCompare("normalize",option+1) == 0) |
| 2190 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2191 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2192 | (void) NormalizeImageChannel(*image,channel); |
| 2193 | InheritException(exception,&(*image)->exception); |
| 2194 | break; |
| 2195 | } |
| 2196 | break; |
| 2197 | } |
| 2198 | case 'o': |
| 2199 | { |
| 2200 | if (LocaleCompare("opaque",option+1) == 0) |
| 2201 | { |
| 2202 | MagickPixelPacket |
| 2203 | target; |
| 2204 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2205 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2206 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2207 | (void) OpaquePaintImageChannel(*image,channel,&target,&fill, |
| 2208 | *option == '-' ? MagickFalse : MagickTrue); |
| 2209 | break; |
| 2210 | } |
| 2211 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2212 | { |
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) OrderedPosterizeImageChannel(*image,channel,argv[i+1], |
| 2215 | exception); |
| 2216 | break; |
| 2217 | } |
| 2218 | break; |
| 2219 | } |
| 2220 | case 'p': |
| 2221 | { |
| 2222 | if (LocaleCompare("paint",option+1) == 0) |
| 2223 | { |
| 2224 | Image |
| 2225 | *paint_image; |
| 2226 | |
| 2227 | /* |
| 2228 | Oil paint image. |
| 2229 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2230 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2231 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2232 | paint_image=OilPaintImage(*image,geometry_info.rho,exception); |
| 2233 | if (paint_image == (Image *) NULL) |
| 2234 | break; |
| 2235 | *image=DestroyImage(*image); |
| 2236 | *image=paint_image; |
| 2237 | break; |
| 2238 | } |
| 2239 | if (LocaleCompare("pen",option+1) == 0) |
| 2240 | { |
| 2241 | if (*option == '+') |
| 2242 | { |
| 2243 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 2244 | break; |
| 2245 | } |
| 2246 | (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception); |
| 2247 | break; |
| 2248 | } |
| 2249 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2250 | { |
| 2251 | if (*option == '+') |
| 2252 | (void) ParseGeometry("12",&geometry_info); |
| 2253 | else |
| 2254 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2255 | draw_info->pointsize=geometry_info.rho; |
| 2256 | break; |
| 2257 | } |
| 2258 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2259 | { |
| 2260 | double |
| 2261 | angle; |
| 2262 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2263 | RandomInfo |
| 2264 | *random_info; |
| 2265 | |
| 2266 | /* |
| 2267 | Simulate a Polaroid picture. |
| 2268 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2269 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2270 | random_info=AcquireRandomInfo(); |
| 2271 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2272 | random_info=DestroyRandomInfo(random_info); |
| 2273 | if (*option == '-') |
| 2274 | { |
| 2275 | SetGeometryInfo(&geometry_info); |
| 2276 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2277 | angle=geometry_info.rho; |
| 2278 | } |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2279 | mogrify_image=PolaroidImage(*image,draw_info,angle,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2280 | break; |
| 2281 | } |
| 2282 | if (LocaleCompare("posterize",option+1) == 0) |
| 2283 | { |
| 2284 | /* |
| 2285 | Posterize image. |
| 2286 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2287 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 2288 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2289 | quantize_info->dither); |
| 2290 | InheritException(exception,&(*image)->exception); |
| 2291 | break; |
| 2292 | } |
| 2293 | if (LocaleCompare("preview",option+1) == 0) |
| 2294 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2295 | PreviewType |
| 2296 | preview_type; |
| 2297 | |
| 2298 | /* |
| 2299 | Preview image. |
| 2300 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2301 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2302 | if (*option == '+') |
| 2303 | preview_type=UndefinedPreview; |
| 2304 | else |
| 2305 | preview_type=(PreviewType) ParseMagickOption(MagickPreviewOptions, |
| 2306 | MagickFalse,argv[i+1]); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2307 | mogrify_image=PreviewImage(*image,preview_type,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2308 | break; |
| 2309 | } |
| 2310 | if (LocaleCompare("profile",option+1) == 0) |
| 2311 | { |
| 2312 | const char |
| 2313 | *name; |
| 2314 | |
| 2315 | const StringInfo |
| 2316 | *profile; |
| 2317 | |
| 2318 | Image |
| 2319 | *profile_image; |
| 2320 | |
| 2321 | ImageInfo |
| 2322 | *profile_info; |
| 2323 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2324 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2325 | if (*option == '+') |
| 2326 | { |
| 2327 | /* |
| 2328 | Remove a profile from the image. |
| 2329 | */ |
| 2330 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
| 2331 | NULL,0,MagickTrue); |
| 2332 | InheritException(exception,&(*image)->exception); |
| 2333 | break; |
| 2334 | } |
| 2335 | /* |
| 2336 | Associate a profile with the image. |
| 2337 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2338 | profile_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2339 | profile=GetImageProfile(*image,"iptc"); |
| 2340 | if (profile != (StringInfo *) NULL) |
| 2341 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2342 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2343 | profile_info=DestroyImageInfo(profile_info); |
| 2344 | if (profile_image == (Image *) NULL) |
| 2345 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2346 | StringInfo |
| 2347 | *profile; |
| 2348 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2349 | profile_info=CloneImageInfo(mogrify_info); |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2350 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2351 | MaxTextExtent); |
| 2352 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2353 | if (profile != (StringInfo *) NULL) |
| 2354 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2355 | (void) ProfileImage(*image,profile_info->magick, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2356 | GetStringInfoDatum(profile),(size_t) |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2357 | GetStringInfoLength(profile),MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2358 | profile=DestroyStringInfo(profile); |
| 2359 | } |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2360 | profile_info=DestroyImageInfo(profile_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2361 | break; |
| 2362 | } |
| 2363 | ResetImageProfileIterator(profile_image); |
| 2364 | name=GetNextImageProfile(profile_image); |
| 2365 | while (name != (const char *) NULL) |
| 2366 | { |
| 2367 | profile=GetImageProfile(profile_image,name); |
| 2368 | if (profile != (StringInfo *) NULL) |
| 2369 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2370 | (size_t) GetStringInfoLength(profile),MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2371 | name=GetNextImageProfile(profile_image); |
| 2372 | } |
| 2373 | profile_image=DestroyImage(profile_image); |
| 2374 | break; |
| 2375 | } |
| 2376 | break; |
| 2377 | } |
| 2378 | case 'q': |
| 2379 | { |
| 2380 | if (LocaleCompare("quantize",option+1) == 0) |
| 2381 | { |
| 2382 | if (*option == '+') |
| 2383 | { |
| 2384 | quantize_info->colorspace=UndefinedColorspace; |
| 2385 | break; |
| 2386 | } |
| 2387 | quantize_info->colorspace=(ColorspaceType) ParseMagickOption( |
| 2388 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2389 | break; |
| 2390 | } |
| 2391 | break; |
| 2392 | } |
| 2393 | case 'r': |
| 2394 | { |
| 2395 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2396 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2397 | /* |
| 2398 | Radial blur image. |
| 2399 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2400 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2401 | mogrify_image=RadialBlurImageChannel(*image,channel, |
cristy | a5447be | 2010-01-11 00:20:51 +0000 | [diff] [blame] | 2402 | StringToDouble(argv[i+1]),exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2403 | break; |
| 2404 | } |
| 2405 | if (LocaleCompare("raise",option+1) == 0) |
| 2406 | { |
| 2407 | /* |
| 2408 | Surround image with a raise of solid color. |
| 2409 | */ |
| 2410 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2411 | if ((flags & SigmaValue) == 0) |
| 2412 | geometry.height=geometry.width; |
| 2413 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
| 2414 | MagickFalse); |
| 2415 | InheritException(exception,&(*image)->exception); |
| 2416 | break; |
| 2417 | } |
| 2418 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2419 | { |
| 2420 | /* |
| 2421 | Threshold image. |
| 2422 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2423 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2424 | (void) RandomThresholdImageChannel(*image,channel,argv[i+1], |
| 2425 | exception); |
| 2426 | break; |
| 2427 | } |
| 2428 | if (LocaleCompare("recolor",option+1) == 0) |
| 2429 | { |
cristy | f055ae4 | 2010-04-02 23:01:38 +0000 | [diff] [blame] | 2430 | KernelInfo |
| 2431 | *kernel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2432 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2433 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f055ae4 | 2010-04-02 23:01:38 +0000 | [diff] [blame] | 2434 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2435 | if (kernel == (KernelInfo *) NULL) |
| 2436 | break; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2437 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
cristy | f055ae4 | 2010-04-02 23:01:38 +0000 | [diff] [blame] | 2438 | kernel=DestroyKernelInfo(kernel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2439 | break; |
| 2440 | } |
| 2441 | if (LocaleCompare("region",option+1) == 0) |
| 2442 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2443 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2444 | if (region_image != (Image *) NULL) |
| 2445 | { |
| 2446 | /* |
| 2447 | Composite region. |
| 2448 | */ |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 2449 | (void) CompositeImage(region_image,region_image->matte != |
| 2450 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 2451 | region_geometry.x,region_geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2452 | InheritException(exception,®ion_image->exception); |
| 2453 | *image=DestroyImage(*image); |
| 2454 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 2455 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2456 | } |
| 2457 | if (*option == '+') |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 2458 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2459 | /* |
| 2460 | Apply transformations to a selected region of the image. |
| 2461 | */ |
| 2462 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2463 | exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2464 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2465 | if (mogrify_image == (Image *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2466 | break; |
| 2467 | region_image=(*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2468 | *image=mogrify_image; |
| 2469 | mogrify_image=(Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2470 | break; |
| 2471 | } |
| 2472 | if (LocaleCompare("render",option+1) == 0) |
| 2473 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2474 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2475 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2476 | break; |
| 2477 | } |
| 2478 | if (LocaleCompare("remap",option+1) == 0) |
| 2479 | { |
| 2480 | Image |
| 2481 | *remap_image; |
| 2482 | |
| 2483 | /* |
| 2484 | Transform image colors to match this set of colors. |
| 2485 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2486 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2487 | if (*option == '+') |
| 2488 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2489 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2490 | if (remap_image == (Image *) NULL) |
| 2491 | break; |
| 2492 | (void) RemapImage(quantize_info,*image,remap_image); |
| 2493 | InheritException(exception,&(*image)->exception); |
| 2494 | remap_image=DestroyImage(remap_image); |
| 2495 | break; |
| 2496 | } |
| 2497 | if (LocaleCompare("repage",option+1) == 0) |
| 2498 | { |
| 2499 | if (*option == '+') |
| 2500 | { |
| 2501 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2502 | break; |
| 2503 | } |
| 2504 | (void) ResetImagePage(*image,argv[i+1]); |
| 2505 | InheritException(exception,&(*image)->exception); |
| 2506 | break; |
| 2507 | } |
| 2508 | if (LocaleCompare("resample",option+1) == 0) |
| 2509 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2510 | /* |
| 2511 | Resample image. |
| 2512 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2513 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2514 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2515 | if ((flags & SigmaValue) == 0) |
| 2516 | geometry_info.sigma=geometry_info.rho; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2517 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2518 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2519 | break; |
| 2520 | } |
| 2521 | if (LocaleCompare("resize",option+1) == 0) |
| 2522 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2523 | /* |
| 2524 | Resize image. |
| 2525 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2526 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2527 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2528 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2529 | (*image)->filter,(*image)->blur,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2530 | break; |
| 2531 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2532 | if (LocaleCompare("roll",option+1) == 0) |
| 2533 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2534 | /* |
| 2535 | Roll image. |
| 2536 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2537 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2538 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2539 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2540 | break; |
| 2541 | } |
| 2542 | if (LocaleCompare("rotate",option+1) == 0) |
| 2543 | { |
| 2544 | char |
| 2545 | *geometry; |
| 2546 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2547 | /* |
| 2548 | Check for conditional image rotation. |
| 2549 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2550 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2551 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2552 | if ((*image)->columns <= (*image)->rows) |
| 2553 | break; |
| 2554 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2555 | if ((*image)->columns >= (*image)->rows) |
| 2556 | break; |
| 2557 | /* |
| 2558 | Rotate image. |
| 2559 | */ |
| 2560 | geometry=ConstantString(argv[i+1]); |
| 2561 | (void) SubstituteString(&geometry,">",""); |
| 2562 | (void) SubstituteString(&geometry,"<",""); |
| 2563 | (void) ParseGeometry(geometry,&geometry_info); |
| 2564 | geometry=DestroyString(geometry); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2565 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2566 | break; |
| 2567 | } |
| 2568 | break; |
| 2569 | } |
| 2570 | case 's': |
| 2571 | { |
| 2572 | if (LocaleCompare("sample",option+1) == 0) |
| 2573 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2574 | /* |
| 2575 | Sample image with pixel replication. |
| 2576 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2577 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2578 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2579 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2580 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2581 | break; |
| 2582 | } |
| 2583 | if (LocaleCompare("scale",option+1) == 0) |
| 2584 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2585 | /* |
| 2586 | Resize image. |
| 2587 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2588 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2589 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2590 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2591 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2592 | break; |
| 2593 | } |
| 2594 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2595 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2596 | /* |
| 2597 | Selectively blur pixels within a contrast threshold. |
| 2598 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2599 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2600 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2601 | if ((flags & PercentValue) != 0) |
| 2602 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2603 | mogrify_image=SelectiveBlurImageChannel(*image,channel, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2604 | geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2605 | break; |
| 2606 | } |
| 2607 | if (LocaleCompare("separate",option+1) == 0) |
| 2608 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2609 | /* |
| 2610 | Break channels into separate images. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 2611 | WARNING: This can generate multiple images! |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2612 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2613 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2614 | mogrify_image=SeparateImages(*image,channel,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2615 | break; |
| 2616 | } |
| 2617 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2618 | { |
| 2619 | double |
| 2620 | threshold; |
| 2621 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2622 | /* |
| 2623 | Sepia-tone image. |
| 2624 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2625 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 2626 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2627 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2628 | break; |
| 2629 | } |
| 2630 | if (LocaleCompare("segment",option+1) == 0) |
| 2631 | { |
| 2632 | /* |
| 2633 | Segment image. |
| 2634 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2635 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2636 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2637 | if ((flags & SigmaValue) == 0) |
| 2638 | geometry_info.sigma=1.0; |
cristy | 7e6164a | 2010-07-22 20:43:57 +0000 | [diff] [blame] | 2639 | (void) SegmentImage(*image,(*image)->colorspace, |
| 2640 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2641 | InheritException(exception,&(*image)->exception); |
| 2642 | break; |
| 2643 | } |
| 2644 | if (LocaleCompare("set",option+1) == 0) |
| 2645 | { |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2646 | char |
| 2647 | *value; |
| 2648 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2649 | /* |
| 2650 | Set image option. |
| 2651 | */ |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2652 | if (*option == '+') |
| 2653 | { |
| 2654 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2655 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2656 | else |
| 2657 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
cristy | 7e10958 | 2010-06-01 12:56:44 +0000 | [diff] [blame] | 2658 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2659 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
cristy | 7e10958 | 2010-06-01 12:56:44 +0000 | [diff] [blame] | 2660 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2661 | } |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2662 | else |
| 2663 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2664 | break; |
| 2665 | } |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2666 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2667 | if (value == (char *) NULL) |
| 2668 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2669 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2670 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2671 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2672 | else |
| 2673 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2674 | { |
cristy | 7f02ba1 | 2010-09-21 12:39:28 +0000 | [diff] [blame] | 2675 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2676 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2677 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2678 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2679 | else |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2680 | (void) SetImageProperty(*image,argv[i+1],value); |
| 2681 | value=DestroyString(value); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2682 | break; |
| 2683 | } |
| 2684 | if (LocaleCompare("shade",option+1) == 0) |
| 2685 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2686 | /* |
| 2687 | Shade image. |
| 2688 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2689 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2690 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2691 | if ((flags & SigmaValue) == 0) |
| 2692 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2693 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2694 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2695 | break; |
| 2696 | } |
| 2697 | if (LocaleCompare("shadow",option+1) == 0) |
| 2698 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2699 | /* |
| 2700 | Shadow 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; |
| 2706 | if ((flags & XiValue) == 0) |
| 2707 | geometry_info.xi=4.0; |
| 2708 | if ((flags & PsiValue) == 0) |
| 2709 | geometry_info.psi=4.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2710 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
| 2711 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 2712 | ceil(geometry_info.psi-0.5),exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2713 | break; |
| 2714 | } |
| 2715 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2716 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2717 | /* |
| 2718 | Sharpen image. |
| 2719 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2720 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2721 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2722 | if ((flags & SigmaValue) == 0) |
| 2723 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2724 | mogrify_image=SharpenImageChannel(*image,channel,geometry_info.rho, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2725 | geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2726 | break; |
| 2727 | } |
| 2728 | if (LocaleCompare("shave",option+1) == 0) |
| 2729 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2730 | /* |
| 2731 | Shave the image edges. |
| 2732 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2733 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2734 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2735 | mogrify_image=ShaveImage(*image,&geometry,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2736 | break; |
| 2737 | } |
| 2738 | if (LocaleCompare("shear",option+1) == 0) |
| 2739 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2740 | /* |
| 2741 | Shear image. |
| 2742 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2743 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2744 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2745 | if ((flags & SigmaValue) == 0) |
| 2746 | geometry_info.sigma=geometry_info.rho; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2747 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2748 | geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2749 | break; |
| 2750 | } |
| 2751 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2752 | { |
| 2753 | /* |
| 2754 | Sigmoidal non-linearity contrast control. |
| 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=(double) QuantumRange/2.0; |
| 2760 | if ((flags & PercentValue) != 0) |
| 2761 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2762 | 100.0; |
| 2763 | (void) SigmoidalContrastImageChannel(*image,channel, |
| 2764 | (*option == '-') ? MagickTrue : MagickFalse,geometry_info.rho, |
| 2765 | geometry_info.sigma); |
| 2766 | InheritException(exception,&(*image)->exception); |
| 2767 | break; |
| 2768 | } |
| 2769 | if (LocaleCompare("sketch",option+1) == 0) |
| 2770 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2771 | /* |
| 2772 | Sketch image. |
| 2773 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2774 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2775 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2776 | if ((flags & SigmaValue) == 0) |
| 2777 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2778 | mogrify_image=SketchImage(*image,geometry_info.rho, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2779 | geometry_info.sigma,geometry_info.xi,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2780 | break; |
| 2781 | } |
| 2782 | if (LocaleCompare("solarize",option+1) == 0) |
| 2783 | { |
| 2784 | double |
| 2785 | threshold; |
| 2786 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2787 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 2788 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2789 | (void) SolarizeImage(*image,threshold); |
| 2790 | InheritException(exception,&(*image)->exception); |
| 2791 | break; |
| 2792 | } |
| 2793 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2794 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2795 | SparseColorMethod |
| 2796 | method; |
| 2797 | |
| 2798 | char |
| 2799 | *arguments; |
| 2800 | |
| 2801 | /* |
| 2802 | Sparse Color Interpolated Gradient |
| 2803 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2804 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2805 | method=(SparseColorMethod) ParseMagickOption( |
| 2806 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2807 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2808 | InheritException(exception,&(*image)->exception); |
| 2809 | if (arguments == (char *) NULL) |
| 2810 | break; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2811 | mogrify_image=SparseColorOption(*image,channel,method,arguments, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2812 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2813 | arguments=DestroyString(arguments); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2814 | break; |
| 2815 | } |
| 2816 | if (LocaleCompare("splice",option+1) == 0) |
| 2817 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2818 | /* |
| 2819 | Splice a solid color into the image. |
| 2820 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2821 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2822 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2823 | mogrify_image=SpliceImage(*image,&geometry,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2824 | break; |
| 2825 | } |
| 2826 | if (LocaleCompare("spread",option+1) == 0) |
| 2827 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2828 | /* |
| 2829 | Spread an image. |
| 2830 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2831 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2832 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2833 | mogrify_image=SpreadImage(*image,geometry_info.rho,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2834 | break; |
| 2835 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 2836 | if (LocaleCompare("statistic",option+1) == 0) |
| 2837 | { |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 2838 | StatisticType |
| 2839 | type; |
| 2840 | |
| 2841 | (void) SyncImageSettings(mogrify_info,*image); |
| 2842 | type=(StatisticType) ParseMagickOption(MagickStatisticOptions, |
| 2843 | MagickFalse,argv[i+1]); |
| 2844 | (void) ParseGeometry(argv[i+2],&geometry_info); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2845 | mogrify_image=StatisticImageChannel(*image,channel,type,(size_t) |
| 2846 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 2847 | break; |
| 2848 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2849 | if (LocaleCompare("stretch",option+1) == 0) |
| 2850 | { |
| 2851 | if (*option == '+') |
| 2852 | { |
| 2853 | draw_info->stretch=UndefinedStretch; |
| 2854 | break; |
| 2855 | } |
| 2856 | draw_info->stretch=(StretchType) ParseMagickOption( |
| 2857 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2858 | break; |
| 2859 | } |
| 2860 | if (LocaleCompare("strip",option+1) == 0) |
| 2861 | { |
| 2862 | /* |
| 2863 | Strip image of profiles and comments. |
| 2864 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2865 | (void) SyncImageSettings(mogrify_info,*image); |
glennrp | 3dae5ae | 2010-12-23 22:42:52 +0000 | [diff] [blame] | 2866 | (void) StripImage(*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2867 | InheritException(exception,&(*image)->exception); |
| 2868 | break; |
| 2869 | } |
| 2870 | if (LocaleCompare("stroke",option+1) == 0) |
| 2871 | { |
| 2872 | ExceptionInfo |
| 2873 | *sans; |
| 2874 | |
| 2875 | if (*option == '+') |
| 2876 | { |
| 2877 | (void) QueryColorDatabase("none",&draw_info->stroke,exception); |
| 2878 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2879 | draw_info->stroke_pattern=DestroyImage( |
| 2880 | draw_info->stroke_pattern); |
| 2881 | break; |
| 2882 | } |
| 2883 | sans=AcquireExceptionInfo(); |
| 2884 | status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans); |
| 2885 | sans=DestroyExceptionInfo(sans); |
| 2886 | if (status == MagickFalse) |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2887 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2888 | exception); |
| 2889 | break; |
| 2890 | } |
| 2891 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2892 | { |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 2893 | draw_info->stroke_width=StringToDouble(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2894 | break; |
| 2895 | } |
| 2896 | if (LocaleCompare("style",option+1) == 0) |
| 2897 | { |
| 2898 | if (*option == '+') |
| 2899 | { |
| 2900 | draw_info->style=UndefinedStyle; |
| 2901 | break; |
| 2902 | } |
| 2903 | draw_info->style=(StyleType) ParseMagickOption(MagickStyleOptions, |
| 2904 | MagickFalse,argv[i+1]); |
| 2905 | break; |
| 2906 | } |
| 2907 | if (LocaleCompare("swirl",option+1) == 0) |
| 2908 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2909 | /* |
| 2910 | Swirl image. |
| 2911 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2912 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2913 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2914 | mogrify_image=SwirlImage(*image,geometry_info.rho,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2915 | break; |
| 2916 | } |
| 2917 | break; |
| 2918 | } |
| 2919 | case 't': |
| 2920 | { |
| 2921 | if (LocaleCompare("threshold",option+1) == 0) |
| 2922 | { |
| 2923 | double |
| 2924 | threshold; |
| 2925 | |
| 2926 | /* |
| 2927 | Threshold image. |
| 2928 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2929 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2930 | if (*option == '+') |
| 2931 | threshold=(double) QuantumRange/2.5; |
| 2932 | else |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 2933 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2934 | (void) BilevelImageChannel(*image,channel,threshold); |
| 2935 | InheritException(exception,&(*image)->exception); |
| 2936 | break; |
| 2937 | } |
| 2938 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2939 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2940 | /* |
| 2941 | Thumbnail image. |
| 2942 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2943 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2944 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2945 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2946 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2947 | break; |
| 2948 | } |
| 2949 | if (LocaleCompare("tile",option+1) == 0) |
| 2950 | { |
| 2951 | if (*option == '+') |
| 2952 | { |
| 2953 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2954 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2955 | break; |
| 2956 | } |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2957 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2958 | exception); |
| 2959 | break; |
| 2960 | } |
| 2961 | if (LocaleCompare("tint",option+1) == 0) |
| 2962 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2963 | /* |
| 2964 | Tint the image. |
| 2965 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2966 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2967 | mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2968 | break; |
| 2969 | } |
| 2970 | if (LocaleCompare("transform",option+1) == 0) |
| 2971 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2972 | /* |
| 2973 | Affine transform image. |
| 2974 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2975 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2976 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2977 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2978 | break; |
| 2979 | } |
| 2980 | if (LocaleCompare("transparent",option+1) == 0) |
| 2981 | { |
| 2982 | MagickPixelPacket |
| 2983 | target; |
| 2984 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2985 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2986 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2987 | (void) TransparentPaintImage(*image,&target,(Quantum) |
| 2988 | TransparentOpacity,*option == '-' ? MagickFalse : MagickTrue); |
| 2989 | InheritException(exception,&(*image)->exception); |
| 2990 | break; |
| 2991 | } |
| 2992 | if (LocaleCompare("transpose",option+1) == 0) |
| 2993 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2994 | /* |
| 2995 | Transpose image scanlines. |
| 2996 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2997 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 2998 | mogrify_image=TransposeImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2999 | break; |
| 3000 | } |
| 3001 | if (LocaleCompare("transverse",option+1) == 0) |
| 3002 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3003 | /* |
| 3004 | Transverse image scanlines. |
| 3005 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3006 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 3007 | mogrify_image=TransverseImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3008 | break; |
| 3009 | } |
| 3010 | if (LocaleCompare("treedepth",option+1) == 0) |
| 3011 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 3012 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3013 | break; |
| 3014 | } |
| 3015 | if (LocaleCompare("trim",option+1) == 0) |
| 3016 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3017 | /* |
| 3018 | Trim image. |
| 3019 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3020 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 3021 | mogrify_image=TrimImage(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3022 | break; |
| 3023 | } |
| 3024 | if (LocaleCompare("type",option+1) == 0) |
| 3025 | { |
| 3026 | ImageType |
| 3027 | type; |
| 3028 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3029 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3030 | if (*option == '+') |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 3031 | type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3032 | else |
| 3033 | type=(ImageType) ParseMagickOption(MagickTypeOptions,MagickFalse, |
| 3034 | argv[i+1]); |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 3035 | (*image)->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3036 | (void) SetImageType(*image,type); |
| 3037 | InheritException(exception,&(*image)->exception); |
| 3038 | break; |
| 3039 | } |
| 3040 | break; |
| 3041 | } |
| 3042 | case 'u': |
| 3043 | { |
| 3044 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3045 | { |
| 3046 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 3047 | exception); |
| 3048 | break; |
| 3049 | } |
cristy | 045bd90 | 2010-01-30 18:56:24 +0000 | [diff] [blame] | 3050 | if (LocaleCompare("unique",option+1) == 0) |
| 3051 | { |
| 3052 | if (*option == '+') |
| 3053 | { |
cristy | 83fae87 | 2010-04-22 15:04:16 +0000 | [diff] [blame] | 3054 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
cristy | 045bd90 | 2010-01-30 18:56:24 +0000 | [diff] [blame] | 3055 | break; |
| 3056 | } |
cristy | 83fae87 | 2010-04-22 15:04:16 +0000 | [diff] [blame] | 3057 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
cristy | a01cbea | 2010-11-03 16:33:33 +0000 | [diff] [blame] | 3058 | (void) SetImageArtifact(*image,"verbose","true"); |
cristy | 045bd90 | 2010-01-30 18:56:24 +0000 | [diff] [blame] | 3059 | break; |
| 3060 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3061 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3062 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3063 | /* |
| 3064 | Unique image colors. |
| 3065 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3066 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 3067 | mogrify_image=UniqueImageColors(*image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3068 | break; |
| 3069 | } |
| 3070 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3071 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3072 | /* |
| 3073 | Unsharp mask image. |
| 3074 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3075 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3076 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3077 | if ((flags & SigmaValue) == 0) |
| 3078 | geometry_info.sigma=1.0; |
| 3079 | if ((flags & XiValue) == 0) |
| 3080 | geometry_info.xi=1.0; |
| 3081 | if ((flags & PsiValue) == 0) |
| 3082 | geometry_info.psi=0.05; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 3083 | mogrify_image=UnsharpMaskImageChannel(*image,channel, |
| 3084 | geometry_info.rho,geometry_info.sigma,geometry_info.xi, |
| 3085 | geometry_info.psi,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3086 | break; |
| 3087 | } |
| 3088 | break; |
| 3089 | } |
| 3090 | case 'v': |
| 3091 | { |
| 3092 | if (LocaleCompare("verbose",option+1) == 0) |
| 3093 | { |
| 3094 | (void) SetImageArtifact(*image,option+1, |
| 3095 | *option == '+' ? "false" : "true"); |
| 3096 | break; |
| 3097 | } |
| 3098 | if (LocaleCompare("vignette",option+1) == 0) |
| 3099 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3100 | /* |
| 3101 | Vignette image. |
| 3102 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3103 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3104 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3105 | if ((flags & SigmaValue) == 0) |
| 3106 | geometry_info.sigma=1.0; |
| 3107 | if ((flags & XiValue) == 0) |
| 3108 | geometry_info.xi=0.1*(*image)->columns; |
| 3109 | if ((flags & PsiValue) == 0) |
| 3110 | geometry_info.psi=0.1*(*image)->rows; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 3111 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3112 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
cristy | 0534a6b | 2010-03-18 01:19:38 +0000 | [diff] [blame] | 3113 | ceil(geometry_info.psi-0.5),exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3114 | break; |
| 3115 | } |
| 3116 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3117 | { |
| 3118 | if (*option == '+') |
| 3119 | { |
| 3120 | (void) SetImageVirtualPixelMethod(*image, |
| 3121 | UndefinedVirtualPixelMethod); |
| 3122 | break; |
| 3123 | } |
| 3124 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3125 | ParseMagickOption(MagickVirtualPixelOptions,MagickFalse, |
| 3126 | argv[i+1])); |
| 3127 | break; |
| 3128 | } |
| 3129 | break; |
| 3130 | } |
| 3131 | case 'w': |
| 3132 | { |
| 3133 | if (LocaleCompare("wave",option+1) == 0) |
| 3134 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3135 | /* |
| 3136 | Wave image. |
| 3137 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3138 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3139 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3140 | if ((flags & SigmaValue) == 0) |
| 3141 | geometry_info.sigma=1.0; |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 3142 | mogrify_image=WaveImage(*image,geometry_info.rho, |
| 3143 | geometry_info.sigma,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3144 | break; |
| 3145 | } |
| 3146 | if (LocaleCompare("weight",option+1) == 0) |
| 3147 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 3148 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3149 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3150 | draw_info->weight=0; |
| 3151 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3152 | draw_info->weight=700; |
| 3153 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3154 | if (draw_info->weight <= 800) |
| 3155 | draw_info->weight+=100; |
| 3156 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3157 | if (draw_info->weight >= 100) |
| 3158 | draw_info->weight-=100; |
| 3159 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3160 | draw_info->weight=400; |
| 3161 | break; |
| 3162 | } |
| 3163 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3164 | { |
| 3165 | /* |
| 3166 | White threshold image. |
| 3167 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3168 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3169 | (void) WhiteThresholdImageChannel(*image,channel,argv[i+1], |
| 3170 | exception); |
| 3171 | InheritException(exception,&(*image)->exception); |
| 3172 | break; |
| 3173 | } |
| 3174 | break; |
| 3175 | } |
| 3176 | default: |
| 3177 | break; |
| 3178 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3179 | /* |
| 3180 | Replace current image with any image that was generated |
| 3181 | */ |
cristy | d241f44 | 2011-03-29 13:50:49 +0000 | [diff] [blame] | 3182 | if (mogrify_image != (Image *) NULL) |
| 3183 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3184 | i+=count; |
| 3185 | } |
| 3186 | if (region_image != (Image *) NULL) |
| 3187 | { |
| 3188 | /* |
| 3189 | Composite transformed region onto image. |
| 3190 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3191 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3192 | (void) CompositeImage(region_image,region_image->matte != |
| 3193 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3194 | region_geometry.x,region_geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3195 | InheritException(exception,®ion_image->exception); |
| 3196 | *image=DestroyImage(*image); |
| 3197 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3198 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3199 | } |
| 3200 | /* |
| 3201 | Free resources. |
| 3202 | */ |
| 3203 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3204 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3205 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3206 | status=(*image)->exception.severity == UndefinedException ? 1 : 0; |
| 3207 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3208 | } |
| 3209 | |
| 3210 | /* |
| 3211 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3212 | % % |
| 3213 | % % |
| 3214 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3215 | + 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] | 3216 | % % |
| 3217 | % % |
| 3218 | % % |
| 3219 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3220 | % |
| 3221 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3222 | % transforms include image scaling, image rotation, color reduction, and |
| 3223 | % others. The transmogrified image overwrites the original image. |
| 3224 | % |
| 3225 | % The format of the MogrifyImageCommand method is: |
| 3226 | % |
| 3227 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3228 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3229 | % |
| 3230 | % A description of each parameter follows: |
| 3231 | % |
| 3232 | % o image_info: the image info. |
| 3233 | % |
| 3234 | % o argc: the number of elements in the argument vector. |
| 3235 | % |
| 3236 | % o argv: A text array containing the command line arguments. |
| 3237 | % |
| 3238 | % o metadata: any metadata is returned here. |
| 3239 | % |
| 3240 | % o exception: return any errors or warnings in this structure. |
| 3241 | % |
| 3242 | */ |
| 3243 | |
| 3244 | static MagickBooleanType MogrifyUsage(void) |
| 3245 | { |
| 3246 | static const char |
| 3247 | *miscellaneous[]= |
| 3248 | { |
| 3249 | "-debug events display copious debugging information", |
| 3250 | "-help print program options", |
| 3251 | "-list type print a list of supported option arguments", |
| 3252 | "-log format format of debugging information", |
| 3253 | "-version print version information", |
| 3254 | (char *) NULL |
| 3255 | }, |
| 3256 | *operators[]= |
| 3257 | { |
| 3258 | "-adaptive-blur geometry", |
| 3259 | " adaptively blur pixels; decrease effect near edges", |
| 3260 | "-adaptive-resize geometry", |
| 3261 | " adaptively resize image using 'mesh' interpolation", |
| 3262 | "-adaptive-sharpen geometry", |
| 3263 | " adaptively sharpen pixels; increase effect near edges", |
| 3264 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3265 | " transparent, extract, background, or shape", |
| 3266 | "-annotate geometry text", |
| 3267 | " annotate the image with text", |
| 3268 | "-auto-gamma automagically adjust gamma level of image", |
| 3269 | "-auto-level automagically adjust color levels of image", |
| 3270 | "-auto-orient automagically orient (rotate) image", |
| 3271 | "-bench iterations measure performance", |
| 3272 | "-black-threshold value", |
| 3273 | " force all pixels below the threshold into black", |
| 3274 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3275 | "-blur geometry reduce image noise and reduce detail levels", |
| 3276 | "-border geometry surround image with a border of color", |
| 3277 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3278 | "-brightness-contrast geometry", |
| 3279 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3280 | "-cdl filename color correct with a color decision list", |
| 3281 | "-charcoal radius simulate a charcoal drawing", |
| 3282 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3283 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3284 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3285 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3286 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3287 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3288 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3289 | "-contrast enhance or reduce the image contrast", |
| 3290 | "-contrast-stretch geometry", |
| 3291 | " improve contrast by `stretching' the intensity range", |
| 3292 | "-convolve coefficients", |
| 3293 | " apply a convolution kernel to the image", |
| 3294 | "-cycle amount cycle the image colormap", |
| 3295 | "-decipher filename convert cipher pixels to plain pixels", |
| 3296 | "-deskew threshold straighten an image", |
| 3297 | "-despeckle reduce the speckles within an image", |
| 3298 | "-distort method args", |
| 3299 | " distort images according to given method ad args", |
| 3300 | "-draw string annotate the image with a graphic primitive", |
| 3301 | "-edge radius apply a filter to detect edges in the image", |
| 3302 | "-encipher filename convert plain pixels to cipher pixels", |
| 3303 | "-emboss radius emboss an image", |
| 3304 | "-enhance apply a digital filter to enhance a noisy image", |
| 3305 | "-equalize perform histogram equalization to an image", |
| 3306 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3307 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3308 | "-extent geometry set the image size", |
| 3309 | "-extract geometry extract area from image", |
| 3310 | "-fft implements the discrete Fourier transform (DFT)", |
| 3311 | "-flip flip image vertically", |
| 3312 | "-floodfill geometry color", |
| 3313 | " floodfill the image with color", |
| 3314 | "-flop flop image horizontally", |
| 3315 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3316 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3317 | " apply function over image values", |
| 3318 | "-gamma value level of gamma correction", |
| 3319 | "-gaussian-blur geometry", |
| 3320 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3321 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3322 | "-identify identify the format and characteristics of the image", |
| 3323 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3324 | "-implode amount implode image pixels about the center", |
| 3325 | "-lat geometry local adaptive thresholding", |
| 3326 | "-layers method optimize, merge, or compare image layers", |
| 3327 | "-level value adjust the level of image contrast", |
| 3328 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3329 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3330 | "-linear-stretch geometry", |
| 3331 | " improve contrast by `stretching with saturation'", |
| 3332 | "-liquid-rescale geometry", |
| 3333 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3334 | "-median geometry apply a median filter to the image", |
| 3335 | "-mode geometry make each pixel the 'predominate color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3336 | "-modulate value vary the brightness, saturation, and hue", |
| 3337 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3338 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3339 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3340 | "-motion-blur geometry", |
| 3341 | " simulate motion blur", |
| 3342 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3343 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3344 | "-normalize transform image to span the full range of colors", |
| 3345 | "-opaque color change this color to the fill color", |
| 3346 | "-ordered-dither NxN", |
| 3347 | " add a noise pattern to the image with specific", |
| 3348 | " amplitudes", |
| 3349 | "-paint radius simulate an oil painting", |
| 3350 | "-polaroid angle simulate a Polaroid picture", |
| 3351 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3352 | "-profile filename add, delete, or apply an image profile", |
| 3353 | "-quantize colorspace reduce colors in this colorspace", |
| 3354 | "-radial-blur angle radial blur the image", |
| 3355 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3356 | "-random-threshold low,high", |
| 3357 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3358 | "-region geometry apply options to a portion of the image", |
| 3359 | "-render render vector graphics", |
| 3360 | "-repage geometry size and location of an image canvas", |
| 3361 | "-resample geometry change the resolution of an image", |
| 3362 | "-resize geometry resize the image", |
| 3363 | "-roll geometry roll an image vertically or horizontally", |
| 3364 | "-rotate degrees apply Paeth rotation to the image", |
| 3365 | "-sample geometry scale image with pixel sampling", |
| 3366 | "-scale geometry scale the image", |
| 3367 | "-segment values segment an image", |
| 3368 | "-selective-blur geometry", |
| 3369 | " selectively blur pixels within a contrast threshold", |
| 3370 | "-sepia-tone threshold", |
| 3371 | " simulate a sepia-toned photo", |
| 3372 | "-set property value set an image property", |
| 3373 | "-shade degrees shade the image using a distant light source", |
| 3374 | "-shadow geometry simulate an image shadow", |
| 3375 | "-sharpen geometry sharpen the image", |
| 3376 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3377 | "-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] | 3378 | "-sigmoidal-contrast geometry", |
| 3379 | " increase the contrast without saturating highlights or shadows", |
| 3380 | "-sketch geometry simulate a pencil sketch", |
| 3381 | "-solarize threshold negate all pixels above the threshold level", |
| 3382 | "-sparse-color method args", |
| 3383 | " fill in a image based on a few color points", |
| 3384 | "-splice geometry splice the background color into the image", |
| 3385 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3386 | "-statistic type radius", |
| 3387 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3388 | "-strip strip image of all profiles and comments", |
| 3389 | "-swirl degrees swirl image pixels about the center", |
| 3390 | "-threshold value threshold the image", |
| 3391 | "-thumbnail geometry create a thumbnail of the image", |
| 3392 | "-tile filename tile image when filling a graphic primitive", |
| 3393 | "-tint value tint the image with the fill color", |
| 3394 | "-transform affine transform image", |
| 3395 | "-transparent color make this color transparent within the image", |
| 3396 | "-transpose flip image vertically and rotate 90 degrees", |
| 3397 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3398 | "-trim trim image edges", |
| 3399 | "-type type image type", |
| 3400 | "-unique-colors discard all but one of any pixel color", |
| 3401 | "-unsharp geometry sharpen the image", |
| 3402 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3403 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3404 | "-white-threshold value", |
| 3405 | " force all pixels above the threshold into white", |
| 3406 | (char *) NULL |
| 3407 | }, |
| 3408 | *sequence_operators[]= |
| 3409 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3410 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3411 | "-clut apply a color lookup table to the image", |
| 3412 | "-coalesce merge a sequence of images", |
| 3413 | "-combine combine a sequence of images", |
| 3414 | "-composite composite image", |
| 3415 | "-crop geometry cut out a rectangular region of the image", |
| 3416 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3417 | "-evaluate-sequence operator", |
| 3418 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3419 | "-flatten flatten a sequence of images", |
| 3420 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3421 | "-hald-clut apply a Hald color lookup table to the image", |
| 3422 | "-morph value morph an image sequence", |
| 3423 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3424 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3425 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3426 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3427 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3428 | "-write filename write images to this file", |
| 3429 | (char *) NULL |
| 3430 | }, |
| 3431 | *settings[]= |
| 3432 | { |
| 3433 | "-adjoin join images into a single multi-image file", |
| 3434 | "-affine matrix affine transform matrix", |
| 3435 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3436 | "-antialias remove pixel-aliasing", |
| 3437 | "-authenticate password", |
| 3438 | " decipher image with this password", |
| 3439 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3440 | "-background color background color", |
| 3441 | "-bias value add bias when convolving an image", |
| 3442 | "-black-point-compensation", |
| 3443 | " use black point compensation", |
| 3444 | "-blue-primary point chromaticity blue primary point", |
| 3445 | "-bordercolor color border color", |
| 3446 | "-caption string assign a caption to an image", |
| 3447 | "-channel type apply option to select image channels", |
| 3448 | "-colors value preferred number of colors in the image", |
| 3449 | "-colorspace type alternate image colorspace", |
| 3450 | "-comment string annotate image with comment", |
| 3451 | "-compose operator set image composite operator", |
| 3452 | "-compress type type of pixel compression when writing the image", |
| 3453 | "-define format:option", |
| 3454 | " define one or more image format options", |
| 3455 | "-delay value display the next image after pausing", |
| 3456 | "-density geometry horizontal and vertical density of the image", |
| 3457 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3458 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3459 | "-display server get image or font from this X server", |
| 3460 | "-dispose method layer disposal method", |
| 3461 | "-dither method apply error diffusion to image", |
| 3462 | "-encoding type text encoding type", |
| 3463 | "-endian type endianness (MSB or LSB) of the image", |
| 3464 | "-family name render text with this font family", |
| 3465 | "-fill color color to use when filling a graphic primitive", |
| 3466 | "-filter type use this filter when resizing an image", |
| 3467 | "-font name render text with this font", |
| 3468 | "-format \"string\" output formatted image characteristics", |
| 3469 | "-fuzz distance colors within this distance are considered equal", |
| 3470 | "-gravity type horizontal and vertical text placement", |
| 3471 | "-green-primary point chromaticity green primary point", |
| 3472 | "-intent type type of rendering intent when managing the image color", |
| 3473 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3474 | "-interline-spacing value", |
| 3475 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3476 | "-interpolate method pixel color interpolation method", |
| 3477 | "-interword-spacing value", |
| 3478 | " set the space between two words", |
| 3479 | "-kerning value set the space between two letters", |
| 3480 | "-label string assign a label to an image", |
| 3481 | "-limit type value pixel cache resource limit", |
| 3482 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3483 | "-mask filename associate a mask with the image", |
| 3484 | "-mattecolor color frame color", |
| 3485 | "-monitor monitor progress", |
| 3486 | "-orient type image orientation", |
| 3487 | "-page geometry size and location of an image canvas (setting)", |
| 3488 | "-ping efficiently determine image attributes", |
| 3489 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3490 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3491 | "-preview type image preview type", |
| 3492 | "-quality value JPEG/MIFF/PNG compression level", |
| 3493 | "-quiet suppress all warning messages", |
| 3494 | "-red-primary point chromaticity red primary point", |
| 3495 | "-regard-warnings pay attention to warning messages", |
| 3496 | "-remap filename transform image colors to match this set of colors", |
| 3497 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3498 | "-sampling-factor geometry", |
| 3499 | " horizontal and vertical sampling factor", |
| 3500 | "-scene value image scene number", |
| 3501 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3502 | "-size geometry width and height of image", |
| 3503 | "-stretch type render text with this font stretch", |
| 3504 | "-stroke color graphic primitive stroke color", |
| 3505 | "-strokewidth value graphic primitive stroke width", |
| 3506 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3507 | "-synchronize synchronize image to storage device", |
| 3508 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3509 | "-texture filename name of texture to tile onto the image background", |
| 3510 | "-tile-offset geometry", |
| 3511 | " tile offset", |
| 3512 | "-treedepth value color tree depth", |
| 3513 | "-transparent-color color", |
| 3514 | " transparent color", |
| 3515 | "-undercolor color annotation bounding box color", |
| 3516 | "-units type the units of image resolution", |
| 3517 | "-verbose print detailed information about the image", |
| 3518 | "-view FlashPix viewing transforms", |
| 3519 | "-virtual-pixel method", |
| 3520 | " virtual pixel access method", |
| 3521 | "-weight type render text with this font weight", |
| 3522 | "-white-point point chromaticity white point", |
| 3523 | (char *) NULL |
| 3524 | }, |
| 3525 | *stack_operators[]= |
| 3526 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3527 | "-delete indexes delete the image from the image sequence", |
| 3528 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3529 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3530 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3531 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3532 | "-swap indexes swap two images in the image sequence", |
| 3533 | (char *) NULL |
| 3534 | }; |
| 3535 | |
| 3536 | const char |
| 3537 | **p; |
| 3538 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3539 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3540 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3541 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3542 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3543 | GetClientName()); |
| 3544 | (void) printf("\nImage Settings:\n"); |
| 3545 | for (p=settings; *p != (char *) NULL; p++) |
| 3546 | (void) printf(" %s\n",*p); |
| 3547 | (void) printf("\nImage Operators:\n"); |
| 3548 | for (p=operators; *p != (char *) NULL; p++) |
| 3549 | (void) printf(" %s\n",*p); |
| 3550 | (void) printf("\nImage Sequence Operators:\n"); |
| 3551 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3552 | (void) printf(" %s\n",*p); |
| 3553 | (void) printf("\nImage Stack Operators:\n"); |
| 3554 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3555 | (void) printf(" %s\n",*p); |
| 3556 | (void) printf("\nMiscellaneous Options:\n"); |
| 3557 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3558 | (void) printf(" %s\n",*p); |
| 3559 | (void) printf( |
| 3560 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3561 | (void) printf( |
| 3562 | "number. To specify a particular image format, precede the filename\n"); |
| 3563 | (void) printf( |
| 3564 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3565 | (void) printf( |
| 3566 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3567 | (void) printf("'-' for standard input or output.\n"); |
| 3568 | return(MagickFalse); |
| 3569 | } |
| 3570 | |
| 3571 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3572 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3573 | { |
| 3574 | #define DestroyMogrify() \ |
| 3575 | { \ |
| 3576 | if (format != (char *) NULL) \ |
| 3577 | format=DestroyString(format); \ |
| 3578 | if (path != (char *) NULL) \ |
| 3579 | path=DestroyString(path); \ |
| 3580 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3581 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3582 | argv[i]=DestroyString(argv[i]); \ |
| 3583 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3584 | } |
| 3585 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3586 | { \ |
| 3587 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3588 | option); \ |
| 3589 | DestroyMogrify(); \ |
| 3590 | return(MagickFalse); \ |
| 3591 | } |
| 3592 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3593 | { \ |
| 3594 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3595 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3596 | DestroyMogrify(); \ |
| 3597 | return(MagickFalse); \ |
| 3598 | } |
| 3599 | |
| 3600 | char |
| 3601 | *format, |
| 3602 | *option, |
| 3603 | *path; |
| 3604 | |
| 3605 | Image |
| 3606 | *image; |
| 3607 | |
| 3608 | ImageStack |
| 3609 | image_stack[MaxImageStackDepth+1]; |
| 3610 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3611 | MagickBooleanType |
| 3612 | global_colormap; |
| 3613 | |
| 3614 | MagickBooleanType |
| 3615 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3616 | pend, |
| 3617 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3618 | |
| 3619 | MagickStatusType |
| 3620 | status; |
| 3621 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3622 | register ssize_t |
| 3623 | i; |
| 3624 | |
| 3625 | ssize_t |
| 3626 | j, |
| 3627 | k; |
| 3628 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3629 | /* |
| 3630 | Set defaults. |
| 3631 | */ |
| 3632 | assert(image_info != (ImageInfo *) NULL); |
| 3633 | assert(image_info->signature == MagickSignature); |
| 3634 | if (image_info->debug != MagickFalse) |
| 3635 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3636 | assert(exception != (ExceptionInfo *) NULL); |
| 3637 | if (argc == 2) |
| 3638 | { |
| 3639 | option=argv[1]; |
| 3640 | if ((LocaleCompare("version",option+1) == 0) || |
| 3641 | (LocaleCompare("-version",option+1) == 0)) |
| 3642 | { |
| 3643 | (void) fprintf(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3644 | GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3645 | (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright()); |
| 3646 | (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3647 | return(MagickFalse); |
| 3648 | } |
| 3649 | } |
| 3650 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3651 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3652 | format=(char *) NULL; |
| 3653 | path=(char *) NULL; |
| 3654 | global_colormap=MagickFalse; |
| 3655 | k=0; |
| 3656 | j=1; |
| 3657 | NewImageStack(); |
| 3658 | option=(char *) NULL; |
| 3659 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3660 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3661 | status=MagickTrue; |
| 3662 | /* |
| 3663 | Parse command line. |
| 3664 | */ |
| 3665 | ReadCommandlLine(argc,&argv); |
| 3666 | status=ExpandFilenames(&argc,&argv); |
| 3667 | if (status == MagickFalse) |
| 3668 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3669 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3670 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3671 | { |
| 3672 | option=argv[i]; |
| 3673 | if (LocaleCompare(option,"(") == 0) |
| 3674 | { |
| 3675 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3676 | if (k == MaxImageStackDepth) |
| 3677 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3678 | option); |
| 3679 | PushImageStack(); |
| 3680 | continue; |
| 3681 | } |
| 3682 | if (LocaleCompare(option,")") == 0) |
| 3683 | { |
| 3684 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3685 | if (k == 0) |
| 3686 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3687 | PopImageStack(); |
| 3688 | continue; |
| 3689 | } |
| 3690 | if (IsMagickOption(option) == MagickFalse) |
| 3691 | { |
| 3692 | char |
| 3693 | backup_filename[MaxTextExtent], |
| 3694 | *filename; |
| 3695 | |
| 3696 | Image |
| 3697 | *images; |
| 3698 | |
| 3699 | /* |
| 3700 | Option is a file name: begin by reading image from specified file. |
| 3701 | */ |
| 3702 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3703 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3704 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3705 | filename=argv[++i]; |
| 3706 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 3707 | images=ReadImages(image_info,exception); |
| 3708 | status&=(images != (Image *) NULL) && |
| 3709 | (exception->severity < ErrorException); |
| 3710 | if (images == (Image *) NULL) |
| 3711 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3712 | if (format != (char *) NULL) |
| 3713 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3714 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3715 | if (path != (char *) NULL) |
| 3716 | { |
| 3717 | GetPathComponent(option,TailPath,filename); |
| 3718 | (void) FormatMagickString(images->filename,MaxTextExtent,"%s%c%s", |
| 3719 | path,*DirectorySeparator,filename); |
| 3720 | } |
| 3721 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3722 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3723 | AppendImageStack(images); |
| 3724 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3725 | if (global_colormap != MagickFalse) |
| 3726 | { |
| 3727 | QuantizeInfo |
| 3728 | *quantize_info; |
| 3729 | |
| 3730 | quantize_info=AcquireQuantizeInfo(image_info); |
| 3731 | (void) RemapImages(quantize_info,images,(Image *) NULL); |
| 3732 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3733 | } |
| 3734 | *backup_filename='\0'; |
| 3735 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3736 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3737 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3738 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3739 | i; |
| 3740 | |
| 3741 | /* |
| 3742 | Rename image file as backup. |
| 3743 | */ |
| 3744 | (void) CopyMagickString(backup_filename,image->filename, |
| 3745 | MaxTextExtent); |
| 3746 | for (i=0; i < 6; i++) |
| 3747 | { |
| 3748 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3749 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3750 | break; |
| 3751 | } |
| 3752 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
| 3753 | (rename(image->filename,backup_filename) != 0)) |
| 3754 | *backup_filename='\0'; |
| 3755 | } |
| 3756 | /* |
| 3757 | Write transmogrified image to disk. |
| 3758 | */ |
| 3759 | image_info->synchronize=MagickTrue; |
| 3760 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3761 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
| 3762 | (void) remove(backup_filename); |
| 3763 | RemoveAllImageStack(); |
| 3764 | continue; |
| 3765 | } |
| 3766 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3767 | switch (*(option+1)) |
| 3768 | { |
| 3769 | case 'a': |
| 3770 | { |
| 3771 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3772 | { |
| 3773 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3774 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3775 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3776 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3777 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3778 | break; |
| 3779 | } |
| 3780 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3781 | { |
| 3782 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3783 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3784 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3785 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3786 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3787 | break; |
| 3788 | } |
| 3789 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3790 | { |
| 3791 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3792 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3793 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3794 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3795 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3796 | break; |
| 3797 | } |
| 3798 | if (LocaleCompare("affine",option+1) == 0) |
| 3799 | { |
| 3800 | if (*option == '+') |
| 3801 | break; |
| 3802 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3803 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3804 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3805 | break; |
| 3806 | } |
| 3807 | if (LocaleCompare("alpha",option+1) == 0) |
| 3808 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3809 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3810 | type; |
| 3811 | |
| 3812 | if (*option == '+') |
| 3813 | break; |
| 3814 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3815 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3816 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3817 | type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]); |
| 3818 | if (type < 0) |
| 3819 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3820 | argv[i]); |
| 3821 | break; |
| 3822 | } |
| 3823 | if (LocaleCompare("annotate",option+1) == 0) |
| 3824 | { |
| 3825 | if (*option == '+') |
| 3826 | break; |
| 3827 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3828 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3829 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3830 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3831 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3832 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3833 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3834 | i++; |
| 3835 | break; |
| 3836 | } |
| 3837 | if (LocaleCompare("antialias",option+1) == 0) |
| 3838 | break; |
| 3839 | if (LocaleCompare("append",option+1) == 0) |
| 3840 | break; |
| 3841 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3842 | { |
| 3843 | if (*option == '+') |
| 3844 | break; |
| 3845 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3846 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3847 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3848 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3849 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3850 | break; |
| 3851 | } |
| 3852 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3853 | { |
| 3854 | if (*option == '+') |
| 3855 | break; |
| 3856 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3857 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3858 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3859 | break; |
| 3860 | } |
| 3861 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3862 | break; |
| 3863 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3864 | break; |
| 3865 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3866 | break; |
| 3867 | if (LocaleCompare("average",option+1) == 0) |
| 3868 | break; |
| 3869 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3870 | } |
| 3871 | case 'b': |
| 3872 | { |
| 3873 | if (LocaleCompare("background",option+1) == 0) |
| 3874 | { |
| 3875 | if (*option == '+') |
| 3876 | break; |
| 3877 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3878 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3879 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3880 | break; |
| 3881 | } |
| 3882 | if (LocaleCompare("bias",option+1) == 0) |
| 3883 | { |
| 3884 | if (*option == '+') |
| 3885 | break; |
| 3886 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3887 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3888 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3889 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3890 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3891 | break; |
| 3892 | } |
| 3893 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 3894 | break; |
| 3895 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 3896 | { |
| 3897 | if (*option == '+') |
| 3898 | break; |
| 3899 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3900 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3901 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3902 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3903 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3904 | break; |
| 3905 | } |
| 3906 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3907 | { |
| 3908 | if (*option == '+') |
| 3909 | break; |
| 3910 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3911 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3912 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3913 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3914 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3915 | break; |
| 3916 | } |
| 3917 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3918 | { |
| 3919 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3920 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3921 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3922 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3923 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3924 | break; |
| 3925 | } |
| 3926 | if (LocaleCompare("blur",option+1) == 0) |
| 3927 | { |
| 3928 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3929 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3930 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3931 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3932 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3933 | break; |
| 3934 | } |
| 3935 | if (LocaleCompare("border",option+1) == 0) |
| 3936 | { |
| 3937 | if (*option == '+') |
| 3938 | break; |
| 3939 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3940 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3941 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3942 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3943 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3944 | break; |
| 3945 | } |
| 3946 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3947 | { |
| 3948 | if (*option == '+') |
| 3949 | break; |
| 3950 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3951 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3952 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3953 | break; |
| 3954 | } |
| 3955 | if (LocaleCompare("box",option+1) == 0) |
| 3956 | { |
| 3957 | if (*option == '+') |
| 3958 | break; |
| 3959 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3960 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3961 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3962 | break; |
| 3963 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3964 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 3965 | { |
| 3966 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3967 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3968 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3969 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3970 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3971 | break; |
| 3972 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3973 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3974 | } |
| 3975 | case 'c': |
| 3976 | { |
| 3977 | if (LocaleCompare("cache",option+1) == 0) |
| 3978 | { |
| 3979 | if (*option == '+') |
| 3980 | break; |
| 3981 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3982 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3983 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3984 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3985 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3986 | break; |
| 3987 | } |
| 3988 | if (LocaleCompare("caption",option+1) == 0) |
| 3989 | { |
| 3990 | if (*option == '+') |
| 3991 | break; |
| 3992 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3993 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3994 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3995 | break; |
| 3996 | } |
| 3997 | if (LocaleCompare("channel",option+1) == 0) |
| 3998 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3999 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4000 | channel; |
| 4001 | |
| 4002 | if (*option == '+') |
| 4003 | break; |
| 4004 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4005 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4006 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4007 | channel=ParseChannelOption(argv[i]); |
| 4008 | if (channel < 0) |
| 4009 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 4010 | argv[i]); |
| 4011 | break; |
| 4012 | } |
| 4013 | if (LocaleCompare("cdl",option+1) == 0) |
| 4014 | { |
| 4015 | if (*option == '+') |
| 4016 | break; |
| 4017 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4018 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4019 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4020 | break; |
| 4021 | } |
| 4022 | if (LocaleCompare("charcoal",option+1) == 0) |
| 4023 | { |
| 4024 | if (*option == '+') |
| 4025 | break; |
| 4026 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4027 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4028 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4029 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4030 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4031 | break; |
| 4032 | } |
| 4033 | if (LocaleCompare("chop",option+1) == 0) |
| 4034 | { |
| 4035 | if (*option == '+') |
| 4036 | break; |
| 4037 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4038 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4039 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4040 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4041 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4042 | break; |
| 4043 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4044 | if (LocaleCompare("clamp",option+1) == 0) |
| 4045 | break; |
| 4046 | if (LocaleCompare("clip",option+1) == 0) |
| 4047 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4048 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4049 | { |
| 4050 | if (*option == '+') |
| 4051 | break; |
| 4052 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4053 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4054 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4055 | break; |
| 4056 | } |
| 4057 | if (LocaleCompare("clut",option+1) == 0) |
| 4058 | break; |
| 4059 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4060 | break; |
| 4061 | if (LocaleCompare("colorize",option+1) == 0) |
| 4062 | { |
| 4063 | if (*option == '+') |
| 4064 | break; |
| 4065 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4066 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4067 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4068 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4069 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4070 | break; |
| 4071 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4072 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4073 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4074 | KernelInfo |
| 4075 | *kernel_info; |
| 4076 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4077 | if (*option == '+') |
| 4078 | break; |
| 4079 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4080 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4081 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4082 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4083 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4084 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4085 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4086 | break; |
| 4087 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4088 | if (LocaleCompare("colors",option+1) == 0) |
| 4089 | { |
| 4090 | if (*option == '+') |
| 4091 | break; |
| 4092 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4093 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4094 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4095 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4096 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4097 | break; |
| 4098 | } |
| 4099 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4100 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4101 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4102 | colorspace; |
| 4103 | |
| 4104 | if (*option == '+') |
| 4105 | break; |
| 4106 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4107 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4108 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4109 | colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse, |
| 4110 | argv[i]); |
| 4111 | if (colorspace < 0) |
| 4112 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4113 | argv[i]); |
| 4114 | break; |
| 4115 | } |
| 4116 | if (LocaleCompare("combine",option+1) == 0) |
| 4117 | break; |
| 4118 | if (LocaleCompare("comment",option+1) == 0) |
| 4119 | { |
| 4120 | if (*option == '+') |
| 4121 | break; |
| 4122 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4123 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4124 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4125 | break; |
| 4126 | } |
| 4127 | if (LocaleCompare("composite",option+1) == 0) |
| 4128 | break; |
| 4129 | if (LocaleCompare("compress",option+1) == 0) |
| 4130 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4131 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4132 | compress; |
| 4133 | |
| 4134 | if (*option == '+') |
| 4135 | break; |
| 4136 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4137 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4138 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4139 | compress=ParseMagickOption(MagickCompressOptions,MagickFalse, |
| 4140 | argv[i]); |
| 4141 | if (compress < 0) |
| 4142 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4143 | argv[i]); |
| 4144 | break; |
| 4145 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4146 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4147 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4148 | if (LocaleCompare("contrast",option+1) == 0) |
| 4149 | break; |
| 4150 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4151 | { |
| 4152 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4153 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4154 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4155 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4156 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4157 | break; |
| 4158 | } |
| 4159 | if (LocaleCompare("convolve",option+1) == 0) |
| 4160 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4161 | KernelInfo |
| 4162 | *kernel_info; |
| 4163 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4164 | if (*option == '+') |
| 4165 | break; |
| 4166 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4167 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4168 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4169 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4170 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4171 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4172 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4173 | break; |
| 4174 | } |
| 4175 | if (LocaleCompare("crop",option+1) == 0) |
| 4176 | { |
| 4177 | if (*option == '+') |
| 4178 | break; |
| 4179 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4180 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4181 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4182 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4183 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4184 | break; |
| 4185 | } |
| 4186 | if (LocaleCompare("cycle",option+1) == 0) |
| 4187 | { |
| 4188 | if (*option == '+') |
| 4189 | break; |
| 4190 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4191 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4192 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4193 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4194 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4195 | break; |
| 4196 | } |
| 4197 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4198 | } |
| 4199 | case 'd': |
| 4200 | { |
| 4201 | if (LocaleCompare("decipher",option+1) == 0) |
| 4202 | { |
| 4203 | if (*option == '+') |
| 4204 | break; |
| 4205 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4206 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4207 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4208 | break; |
| 4209 | } |
| 4210 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4211 | break; |
| 4212 | if (LocaleCompare("debug",option+1) == 0) |
| 4213 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4214 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4215 | event; |
| 4216 | |
| 4217 | if (*option == '+') |
| 4218 | break; |
| 4219 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4220 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4221 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4222 | event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]); |
| 4223 | if (event < 0) |
| 4224 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4225 | argv[i]); |
| 4226 | (void) SetLogEventMask(argv[i]); |
| 4227 | break; |
| 4228 | } |
| 4229 | if (LocaleCompare("define",option+1) == 0) |
| 4230 | { |
| 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 (*option == '+') |
| 4235 | { |
| 4236 | const char |
| 4237 | *define; |
| 4238 | |
| 4239 | define=GetImageOption(image_info,argv[i]); |
| 4240 | if (define == (const char *) NULL) |
| 4241 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4242 | break; |
| 4243 | } |
| 4244 | break; |
| 4245 | } |
| 4246 | if (LocaleCompare("delay",option+1) == 0) |
| 4247 | { |
| 4248 | if (*option == '+') |
| 4249 | break; |
| 4250 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4251 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4252 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4253 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4254 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4255 | break; |
| 4256 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4257 | if (LocaleCompare("delete",option+1) == 0) |
| 4258 | { |
| 4259 | if (*option == '+') |
| 4260 | break; |
| 4261 | i++; |
| 4262 | if (i == (ssize_t) (argc-1)) |
| 4263 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4264 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4265 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4266 | break; |
| 4267 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4268 | if (LocaleCompare("density",option+1) == 0) |
| 4269 | { |
| 4270 | if (*option == '+') |
| 4271 | break; |
| 4272 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4273 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4274 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4275 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4276 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4277 | break; |
| 4278 | } |
| 4279 | if (LocaleCompare("depth",option+1) == 0) |
| 4280 | { |
| 4281 | if (*option == '+') |
| 4282 | break; |
| 4283 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4284 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4285 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4286 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4287 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4288 | break; |
| 4289 | } |
| 4290 | if (LocaleCompare("deskew",option+1) == 0) |
| 4291 | { |
| 4292 | if (*option == '+') |
| 4293 | break; |
| 4294 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4295 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4296 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4297 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4298 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4299 | break; |
| 4300 | } |
| 4301 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4302 | break; |
| 4303 | if (LocaleCompare("dft",option+1) == 0) |
| 4304 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4305 | if (LocaleCompare("direction",option+1) == 0) |
| 4306 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4307 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4308 | direction; |
| 4309 | |
| 4310 | if (*option == '+') |
| 4311 | break; |
| 4312 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4313 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4314 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4315 | direction=ParseMagickOption(MagickDirectionOptions,MagickFalse, |
| 4316 | argv[i]); |
| 4317 | if (direction < 0) |
| 4318 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4319 | argv[i]); |
| 4320 | break; |
| 4321 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4322 | if (LocaleCompare("display",option+1) == 0) |
| 4323 | { |
| 4324 | if (*option == '+') |
| 4325 | break; |
| 4326 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4327 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4328 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4329 | break; |
| 4330 | } |
| 4331 | if (LocaleCompare("dispose",option+1) == 0) |
| 4332 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4333 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4334 | dispose; |
| 4335 | |
| 4336 | if (*option == '+') |
| 4337 | break; |
| 4338 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4339 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4340 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4341 | dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]); |
| 4342 | if (dispose < 0) |
| 4343 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4344 | argv[i]); |
| 4345 | break; |
| 4346 | } |
| 4347 | if (LocaleCompare("distort",option+1) == 0) |
| 4348 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4349 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4350 | op; |
| 4351 | |
| 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 | op=ParseMagickOption(MagickDistortOptions,MagickFalse,argv[i]); |
| 4356 | if (op < 0) |
| 4357 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4358 | argv[i]); |
| 4359 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4360 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4361 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4362 | break; |
| 4363 | } |
| 4364 | if (LocaleCompare("dither",option+1) == 0) |
| 4365 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4366 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4367 | method; |
| 4368 | |
| 4369 | if (*option == '+') |
| 4370 | break; |
| 4371 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4372 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4373 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4374 | method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]); |
| 4375 | if (method < 0) |
| 4376 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4377 | argv[i]); |
| 4378 | break; |
| 4379 | } |
| 4380 | if (LocaleCompare("draw",option+1) == 0) |
| 4381 | { |
| 4382 | if (*option == '+') |
| 4383 | break; |
| 4384 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4385 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4386 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4387 | break; |
| 4388 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4389 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4390 | { |
| 4391 | if (*option == '+') |
| 4392 | break; |
| 4393 | i++; |
| 4394 | if (i == (ssize_t) (argc-1)) |
| 4395 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4396 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4397 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4398 | break; |
| 4399 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4400 | if (LocaleCompare("duration",option+1) == 0) |
| 4401 | { |
| 4402 | if (*option == '+') |
| 4403 | break; |
| 4404 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4405 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4406 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4407 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4408 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4409 | break; |
| 4410 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4411 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4412 | } |
| 4413 | case 'e': |
| 4414 | { |
| 4415 | if (LocaleCompare("edge",option+1) == 0) |
| 4416 | { |
| 4417 | if (*option == '+') |
| 4418 | break; |
| 4419 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4420 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4421 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4422 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4423 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4424 | break; |
| 4425 | } |
| 4426 | if (LocaleCompare("emboss",option+1) == 0) |
| 4427 | { |
| 4428 | if (*option == '+') |
| 4429 | break; |
| 4430 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4431 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4432 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4433 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4434 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4435 | break; |
| 4436 | } |
| 4437 | if (LocaleCompare("encipher",option+1) == 0) |
| 4438 | { |
| 4439 | if (*option == '+') |
| 4440 | break; |
| 4441 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4442 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4443 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4444 | break; |
| 4445 | } |
| 4446 | if (LocaleCompare("encoding",option+1) == 0) |
| 4447 | { |
| 4448 | if (*option == '+') |
| 4449 | break; |
| 4450 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4451 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4452 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4453 | break; |
| 4454 | } |
| 4455 | if (LocaleCompare("endian",option+1) == 0) |
| 4456 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4457 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4458 | endian; |
| 4459 | |
| 4460 | if (*option == '+') |
| 4461 | break; |
| 4462 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4463 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4464 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4465 | endian=ParseMagickOption(MagickEndianOptions,MagickFalse,argv[i]); |
| 4466 | if (endian < 0) |
| 4467 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4468 | argv[i]); |
| 4469 | break; |
| 4470 | } |
| 4471 | if (LocaleCompare("enhance",option+1) == 0) |
| 4472 | break; |
| 4473 | if (LocaleCompare("equalize",option+1) == 0) |
| 4474 | break; |
| 4475 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4476 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4477 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4478 | op; |
| 4479 | |
| 4480 | if (*option == '+') |
| 4481 | break; |
| 4482 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4483 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4484 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4485 | op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
| 4486 | if (op < 0) |
| 4487 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4488 | argv[i]); |
| 4489 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4490 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4491 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4492 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4493 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4494 | break; |
| 4495 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4496 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4497 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4498 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4499 | op; |
| 4500 | |
| 4501 | if (*option == '+') |
| 4502 | break; |
| 4503 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4504 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4505 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4506 | op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
| 4507 | if (op < 0) |
| 4508 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4509 | argv[i]); |
| 4510 | break; |
| 4511 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4512 | if (LocaleCompare("extent",option+1) == 0) |
| 4513 | { |
| 4514 | if (*option == '+') |
| 4515 | break; |
| 4516 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4517 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4518 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4519 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4520 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4521 | break; |
| 4522 | } |
| 4523 | if (LocaleCompare("extract",option+1) == 0) |
| 4524 | { |
| 4525 | if (*option == '+') |
| 4526 | break; |
| 4527 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4528 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4529 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4530 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4531 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4532 | break; |
| 4533 | } |
| 4534 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4535 | } |
| 4536 | case 'f': |
| 4537 | { |
| 4538 | if (LocaleCompare("family",option+1) == 0) |
| 4539 | { |
| 4540 | if (*option == '+') |
| 4541 | break; |
| 4542 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4543 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4544 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4545 | break; |
| 4546 | } |
| 4547 | if (LocaleCompare("fill",option+1) == 0) |
| 4548 | { |
| 4549 | if (*option == '+') |
| 4550 | break; |
| 4551 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4552 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4553 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4554 | break; |
| 4555 | } |
| 4556 | if (LocaleCompare("filter",option+1) == 0) |
| 4557 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4558 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4559 | filter; |
| 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 | filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]); |
| 4567 | if (filter < 0) |
| 4568 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4569 | argv[i]); |
| 4570 | break; |
| 4571 | } |
| 4572 | if (LocaleCompare("flatten",option+1) == 0) |
| 4573 | break; |
| 4574 | if (LocaleCompare("flip",option+1) == 0) |
| 4575 | break; |
| 4576 | if (LocaleCompare("flop",option+1) == 0) |
| 4577 | break; |
| 4578 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4579 | { |
| 4580 | if (*option == '+') |
| 4581 | break; |
| 4582 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4583 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4584 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4585 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4586 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4587 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4588 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4589 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4590 | break; |
| 4591 | } |
| 4592 | if (LocaleCompare("font",option+1) == 0) |
| 4593 | { |
| 4594 | if (*option == '+') |
| 4595 | break; |
| 4596 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4597 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4598 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4599 | break; |
| 4600 | } |
| 4601 | if (LocaleCompare("format",option+1) == 0) |
| 4602 | { |
| 4603 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4604 | (void) CloneString(&format,(char *) NULL); |
| 4605 | if (*option == '+') |
| 4606 | break; |
| 4607 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4608 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4609 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4610 | (void) CloneString(&format,argv[i]); |
| 4611 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4612 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4613 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4614 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4615 | if (*image_info->magick == '\0') |
| 4616 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4617 | format); |
| 4618 | break; |
| 4619 | } |
| 4620 | if (LocaleCompare("frame",option+1) == 0) |
| 4621 | { |
| 4622 | if (*option == '+') |
| 4623 | break; |
| 4624 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4625 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4626 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4627 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4628 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4629 | break; |
| 4630 | } |
| 4631 | if (LocaleCompare("function",option+1) == 0) |
| 4632 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4633 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4634 | op; |
| 4635 | |
| 4636 | if (*option == '+') |
| 4637 | break; |
| 4638 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4639 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4640 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4641 | op=ParseMagickOption(MagickFunctionOptions,MagickFalse,argv[i]); |
| 4642 | if (op < 0) |
| 4643 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4644 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4645 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4646 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4647 | break; |
| 4648 | } |
| 4649 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4650 | { |
| 4651 | if (*option == '+') |
| 4652 | break; |
| 4653 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4654 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4655 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4656 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4657 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4658 | break; |
| 4659 | } |
| 4660 | if (LocaleCompare("fx",option+1) == 0) |
| 4661 | { |
| 4662 | if (*option == '+') |
| 4663 | break; |
| 4664 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4665 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4666 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4667 | break; |
| 4668 | } |
| 4669 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4670 | } |
| 4671 | case 'g': |
| 4672 | { |
| 4673 | if (LocaleCompare("gamma",option+1) == 0) |
| 4674 | { |
| 4675 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4676 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4677 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4678 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4679 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4680 | break; |
| 4681 | } |
| 4682 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4683 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4684 | { |
| 4685 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4686 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4687 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4688 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4689 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4690 | break; |
| 4691 | } |
| 4692 | if (LocaleCompare("geometry",option+1) == 0) |
| 4693 | { |
| 4694 | if (*option == '+') |
| 4695 | break; |
| 4696 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4697 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4698 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4699 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4700 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4701 | break; |
| 4702 | } |
| 4703 | if (LocaleCompare("gravity",option+1) == 0) |
| 4704 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4705 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4706 | gravity; |
| 4707 | |
| 4708 | if (*option == '+') |
| 4709 | break; |
| 4710 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4711 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4712 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4713 | gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,argv[i]); |
| 4714 | if (gravity < 0) |
| 4715 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4716 | argv[i]); |
| 4717 | break; |
| 4718 | } |
| 4719 | if (LocaleCompare("green-primary",option+1) == 0) |
| 4720 | { |
| 4721 | if (*option == '+') |
| 4722 | break; |
| 4723 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4724 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4725 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4726 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4727 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4728 | break; |
| 4729 | } |
| 4730 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4731 | } |
| 4732 | case 'h': |
| 4733 | { |
| 4734 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4735 | break; |
| 4736 | if ((LocaleCompare("help",option+1) == 0) || |
| 4737 | (LocaleCompare("-help",option+1) == 0)) |
| 4738 | return(MogrifyUsage()); |
| 4739 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4740 | } |
| 4741 | case 'i': |
| 4742 | { |
| 4743 | if (LocaleCompare("identify",option+1) == 0) |
| 4744 | break; |
| 4745 | if (LocaleCompare("idft",option+1) == 0) |
| 4746 | break; |
| 4747 | if (LocaleCompare("implode",option+1) == 0) |
| 4748 | { |
| 4749 | if (*option == '+') |
| 4750 | break; |
| 4751 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4752 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4753 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4754 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4755 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4756 | break; |
| 4757 | } |
| 4758 | if (LocaleCompare("intent",option+1) == 0) |
| 4759 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4760 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4761 | intent; |
| 4762 | |
| 4763 | if (*option == '+') |
| 4764 | break; |
| 4765 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4766 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4767 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4768 | intent=ParseMagickOption(MagickIntentOptions,MagickFalse,argv[i]); |
| 4769 | if (intent < 0) |
| 4770 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4771 | argv[i]); |
| 4772 | break; |
| 4773 | } |
| 4774 | if (LocaleCompare("interlace",option+1) == 0) |
| 4775 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4776 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4777 | interlace; |
| 4778 | |
| 4779 | if (*option == '+') |
| 4780 | break; |
| 4781 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4782 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4783 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4784 | interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse, |
| 4785 | argv[i]); |
| 4786 | if (interlace < 0) |
| 4787 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4788 | argv[i]); |
| 4789 | break; |
| 4790 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4791 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4792 | { |
| 4793 | if (*option == '+') |
| 4794 | break; |
| 4795 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4796 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4797 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4798 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4799 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4800 | break; |
| 4801 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4802 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4803 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4804 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4805 | interpolate; |
| 4806 | |
| 4807 | if (*option == '+') |
| 4808 | break; |
| 4809 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4810 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4811 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4812 | interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse, |
| 4813 | argv[i]); |
| 4814 | if (interpolate < 0) |
| 4815 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4816 | argv[i]); |
| 4817 | break; |
| 4818 | } |
| 4819 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4820 | { |
| 4821 | if (*option == '+') |
| 4822 | break; |
| 4823 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4824 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4825 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4826 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4827 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4828 | break; |
| 4829 | } |
| 4830 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4831 | } |
| 4832 | case 'k': |
| 4833 | { |
| 4834 | if (LocaleCompare("kerning",option+1) == 0) |
| 4835 | { |
| 4836 | if (*option == '+') |
| 4837 | break; |
| 4838 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4839 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4840 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4841 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4842 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4843 | break; |
| 4844 | } |
| 4845 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4846 | } |
| 4847 | case 'l': |
| 4848 | { |
| 4849 | if (LocaleCompare("label",option+1) == 0) |
| 4850 | { |
| 4851 | if (*option == '+') |
| 4852 | break; |
| 4853 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4854 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4855 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4856 | break; |
| 4857 | } |
| 4858 | if (LocaleCompare("lat",option+1) == 0) |
| 4859 | { |
| 4860 | if (*option == '+') |
| 4861 | break; |
| 4862 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4863 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4864 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4865 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4866 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4867 | } |
| 4868 | if (LocaleCompare("layers",option+1) == 0) |
| 4869 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4870 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4871 | type; |
| 4872 | |
| 4873 | if (*option == '+') |
| 4874 | break; |
| 4875 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4876 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4877 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4878 | type=ParseMagickOption(MagickLayerOptions,MagickFalse,argv[i]); |
| 4879 | if (type < 0) |
| 4880 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4881 | argv[i]); |
| 4882 | break; |
| 4883 | } |
| 4884 | if (LocaleCompare("level",option+1) == 0) |
| 4885 | { |
| 4886 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4887 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4888 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4889 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4890 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4891 | break; |
| 4892 | } |
| 4893 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4894 | { |
| 4895 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4896 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4897 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4898 | break; |
| 4899 | } |
| 4900 | if (LocaleCompare("linewidth",option+1) == 0) |
| 4901 | { |
| 4902 | if (*option == '+') |
| 4903 | break; |
| 4904 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4905 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4906 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4907 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4908 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4909 | break; |
| 4910 | } |
| 4911 | if (LocaleCompare("limit",option+1) == 0) |
| 4912 | { |
| 4913 | char |
| 4914 | *p; |
| 4915 | |
| 4916 | double |
| 4917 | value; |
| 4918 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4919 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4920 | resource; |
| 4921 | |
| 4922 | if (*option == '+') |
| 4923 | break; |
| 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 | resource=ParseMagickOption(MagickResourceOptions,MagickFalse, |
| 4928 | argv[i]); |
| 4929 | if (resource < 0) |
| 4930 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4931 | argv[i]); |
| 4932 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4933 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4934 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4935 | value=strtod(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4936 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4937 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4938 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4939 | break; |
| 4940 | } |
| 4941 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4942 | { |
| 4943 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4944 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4945 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4946 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4947 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4948 | break; |
| 4949 | } |
| 4950 | if (LocaleCompare("list",option+1) == 0) |
| 4951 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4952 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4953 | list; |
| 4954 | |
| 4955 | if (*option == '+') |
| 4956 | break; |
| 4957 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4958 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4959 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4960 | list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]); |
| 4961 | if (list < 0) |
| 4962 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4963 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4964 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4965 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4966 | } |
| 4967 | if (LocaleCompare("log",option+1) == 0) |
| 4968 | { |
| 4969 | if (*option == '+') |
| 4970 | break; |
| 4971 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4972 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4973 | (strchr(argv[i],'%') == (char *) NULL)) |
| 4974 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4975 | break; |
| 4976 | } |
| 4977 | if (LocaleCompare("loop",option+1) == 0) |
| 4978 | { |
| 4979 | if (*option == '+') |
| 4980 | break; |
| 4981 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4982 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4983 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4984 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4985 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4986 | break; |
| 4987 | } |
| 4988 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4989 | } |
| 4990 | case 'm': |
| 4991 | { |
| 4992 | if (LocaleCompare("map",option+1) == 0) |
| 4993 | { |
| 4994 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 4995 | if (*option == '+') |
| 4996 | break; |
| 4997 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4998 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4999 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5000 | break; |
| 5001 | } |
| 5002 | if (LocaleCompare("mask",option+1) == 0) |
| 5003 | { |
| 5004 | if (*option == '+') |
| 5005 | break; |
| 5006 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5007 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5008 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5009 | break; |
| 5010 | } |
| 5011 | if (LocaleCompare("matte",option+1) == 0) |
| 5012 | break; |
| 5013 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 5014 | { |
| 5015 | if (*option == '+') |
| 5016 | break; |
| 5017 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5018 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5019 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5020 | break; |
| 5021 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5022 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5023 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5024 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5025 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5026 | if (LocaleCompare("modulate",option+1) == 0) |
| 5027 | { |
| 5028 | if (*option == '+') |
| 5029 | break; |
| 5030 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5031 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5032 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5033 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5034 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5035 | break; |
| 5036 | } |
| 5037 | if (LocaleCompare("median",option+1) == 0) |
| 5038 | { |
| 5039 | if (*option == '+') |
| 5040 | break; |
| 5041 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5042 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5043 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5044 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5045 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5046 | break; |
| 5047 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5048 | if (LocaleCompare("mode",option+1) == 0) |
| 5049 | { |
| 5050 | if (*option == '+') |
| 5051 | break; |
| 5052 | i++; |
| 5053 | if (i == (ssize_t) argc) |
| 5054 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5055 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5056 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5057 | break; |
| 5058 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5059 | if (LocaleCompare("monitor",option+1) == 0) |
| 5060 | break; |
| 5061 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5062 | break; |
| 5063 | if (LocaleCompare("morph",option+1) == 0) |
| 5064 | { |
| 5065 | if (*option == '+') |
| 5066 | break; |
| 5067 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5068 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5069 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5070 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5071 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5072 | break; |
| 5073 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5074 | if (LocaleCompare("morphology",option+1) == 0) |
| 5075 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5076 | char |
| 5077 | token[MaxTextExtent]; |
| 5078 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5079 | KernelInfo |
| 5080 | *kernel_info; |
| 5081 | |
| 5082 | ssize_t |
| 5083 | op; |
| 5084 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5085 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5086 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5087 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5088 | GetMagickToken(argv[i],NULL,token); |
| 5089 | op=ParseMagickOption(MagickMorphologyOptions,MagickFalse,token); |
| 5090 | if (op < 0) |
| 5091 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5092 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5093 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5094 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5095 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5096 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5097 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5098 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5099 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5100 | break; |
| 5101 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5102 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5103 | break; |
| 5104 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5105 | { |
| 5106 | if (*option == '+') |
| 5107 | break; |
| 5108 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5109 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5110 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5111 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5112 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5113 | break; |
| 5114 | } |
| 5115 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5116 | } |
| 5117 | case 'n': |
| 5118 | { |
| 5119 | if (LocaleCompare("negate",option+1) == 0) |
| 5120 | break; |
| 5121 | if (LocaleCompare("noise",option+1) == 0) |
| 5122 | { |
| 5123 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5124 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5125 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5126 | if (*option == '+') |
| 5127 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5128 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5129 | noise; |
| 5130 | |
| 5131 | noise=ParseMagickOption(MagickNoiseOptions,MagickFalse,argv[i]); |
| 5132 | if (noise < 0) |
| 5133 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5134 | argv[i]); |
| 5135 | break; |
| 5136 | } |
| 5137 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5138 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5139 | break; |
| 5140 | } |
| 5141 | if (LocaleCompare("noop",option+1) == 0) |
| 5142 | break; |
| 5143 | if (LocaleCompare("normalize",option+1) == 0) |
| 5144 | break; |
| 5145 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5146 | } |
| 5147 | case 'o': |
| 5148 | { |
| 5149 | if (LocaleCompare("opaque",option+1) == 0) |
| 5150 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5151 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5152 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5153 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5154 | break; |
| 5155 | } |
| 5156 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5157 | { |
| 5158 | if (*option == '+') |
| 5159 | break; |
| 5160 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5161 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5162 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5163 | break; |
| 5164 | } |
| 5165 | if (LocaleCompare("orient",option+1) == 0) |
| 5166 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5167 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5168 | orientation; |
| 5169 | |
| 5170 | orientation=UndefinedOrientation; |
| 5171 | if (*option == '+') |
| 5172 | break; |
| 5173 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5174 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5175 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5176 | orientation=ParseMagickOption(MagickOrientationOptions,MagickFalse, |
| 5177 | argv[i]); |
| 5178 | if (orientation < 0) |
| 5179 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5180 | argv[i]); |
| 5181 | break; |
| 5182 | } |
| 5183 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5184 | } |
| 5185 | case 'p': |
| 5186 | { |
| 5187 | if (LocaleCompare("page",option+1) == 0) |
| 5188 | { |
| 5189 | if (*option == '+') |
| 5190 | break; |
| 5191 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5192 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5193 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5194 | break; |
| 5195 | } |
| 5196 | if (LocaleCompare("paint",option+1) == 0) |
| 5197 | { |
| 5198 | if (*option == '+') |
| 5199 | break; |
| 5200 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5201 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5202 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5203 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5204 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5205 | break; |
| 5206 | } |
| 5207 | if (LocaleCompare("path",option+1) == 0) |
| 5208 | { |
| 5209 | (void) CloneString(&path,(char *) NULL); |
| 5210 | if (*option == '+') |
| 5211 | break; |
| 5212 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5213 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5214 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5215 | (void) CloneString(&path,argv[i]); |
| 5216 | break; |
| 5217 | } |
| 5218 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5219 | { |
| 5220 | if (*option == '+') |
| 5221 | break; |
| 5222 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5223 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5224 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5225 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5226 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5227 | break; |
| 5228 | } |
| 5229 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5230 | { |
| 5231 | if (*option == '+') |
| 5232 | break; |
| 5233 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5234 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5235 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5236 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5237 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5238 | break; |
| 5239 | } |
| 5240 | if (LocaleCompare("posterize",option+1) == 0) |
| 5241 | { |
| 5242 | if (*option == '+') |
| 5243 | break; |
| 5244 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5245 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5246 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5247 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5248 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5249 | break; |
| 5250 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5251 | if (LocaleCompare("precision",option+1) == 0) |
| 5252 | { |
| 5253 | if (*option == '+') |
| 5254 | break; |
| 5255 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5256 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5257 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5258 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5259 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5260 | break; |
| 5261 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5262 | if (LocaleCompare("print",option+1) == 0) |
| 5263 | { |
| 5264 | if (*option == '+') |
| 5265 | break; |
| 5266 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5267 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5268 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5269 | break; |
| 5270 | } |
| 5271 | if (LocaleCompare("process",option+1) == 0) |
| 5272 | { |
| 5273 | if (*option == '+') |
| 5274 | break; |
| 5275 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5276 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5277 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5278 | break; |
| 5279 | } |
| 5280 | if (LocaleCompare("profile",option+1) == 0) |
| 5281 | { |
| 5282 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5283 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5284 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5285 | break; |
| 5286 | } |
| 5287 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5288 | } |
| 5289 | case 'q': |
| 5290 | { |
| 5291 | if (LocaleCompare("quality",option+1) == 0) |
| 5292 | { |
| 5293 | if (*option == '+') |
| 5294 | break; |
| 5295 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5296 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5297 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5298 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5299 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5300 | break; |
| 5301 | } |
| 5302 | if (LocaleCompare("quantize",option+1) == 0) |
| 5303 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5304 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5305 | colorspace; |
| 5306 | |
| 5307 | if (*option == '+') |
| 5308 | break; |
| 5309 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5310 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5311 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5312 | colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse, |
| 5313 | argv[i]); |
| 5314 | if (colorspace < 0) |
| 5315 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5316 | argv[i]); |
| 5317 | break; |
| 5318 | } |
| 5319 | if (LocaleCompare("quiet",option+1) == 0) |
| 5320 | break; |
| 5321 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5322 | } |
| 5323 | case 'r': |
| 5324 | { |
| 5325 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5326 | { |
| 5327 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5328 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5329 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5330 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5331 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5332 | break; |
| 5333 | } |
| 5334 | if (LocaleCompare("raise",option+1) == 0) |
| 5335 | { |
| 5336 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5337 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5338 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5339 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5340 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5341 | break; |
| 5342 | } |
| 5343 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5344 | { |
| 5345 | if (*option == '+') |
| 5346 | break; |
| 5347 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5348 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5349 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5350 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5351 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5352 | break; |
| 5353 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5354 | if (LocaleCompare("recolor",option+1) == 0) |
| 5355 | { |
| 5356 | if (*option == '+') |
| 5357 | break; |
| 5358 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5359 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5360 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5361 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5362 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5363 | break; |
| 5364 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5365 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5366 | { |
| 5367 | if (*option == '+') |
| 5368 | break; |
| 5369 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5370 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5371 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5372 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5373 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5374 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5375 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5376 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5377 | if (LocaleCompare("region",option+1) == 0) |
| 5378 | { |
| 5379 | if (*option == '+') |
| 5380 | break; |
| 5381 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5382 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5383 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5384 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5385 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5386 | break; |
| 5387 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5388 | if (LocaleCompare("remap",option+1) == 0) |
| 5389 | { |
| 5390 | if (*option == '+') |
| 5391 | break; |
| 5392 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5393 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5394 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5395 | break; |
| 5396 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5397 | if (LocaleCompare("render",option+1) == 0) |
| 5398 | break; |
| 5399 | if (LocaleCompare("repage",option+1) == 0) |
| 5400 | { |
| 5401 | if (*option == '+') |
| 5402 | break; |
| 5403 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5404 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5405 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5406 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5407 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5408 | break; |
| 5409 | } |
| 5410 | if (LocaleCompare("resample",option+1) == 0) |
| 5411 | { |
| 5412 | if (*option == '+') |
| 5413 | break; |
| 5414 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5415 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5416 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5417 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5418 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5419 | break; |
| 5420 | } |
| 5421 | if (LocaleCompare("resize",option+1) == 0) |
| 5422 | { |
| 5423 | if (*option == '+') |
| 5424 | break; |
| 5425 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5426 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5427 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5428 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5429 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5430 | break; |
| 5431 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5432 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5433 | { |
| 5434 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5435 | break; |
| 5436 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5437 | if (LocaleCompare("reverse",option+1) == 0) |
| 5438 | break; |
| 5439 | if (LocaleCompare("roll",option+1) == 0) |
| 5440 | { |
| 5441 | if (*option == '+') |
| 5442 | break; |
| 5443 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5444 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5445 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5446 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5447 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5448 | break; |
| 5449 | } |
| 5450 | if (LocaleCompare("rotate",option+1) == 0) |
| 5451 | { |
| 5452 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5453 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5454 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5455 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5456 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5457 | break; |
| 5458 | } |
| 5459 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5460 | } |
| 5461 | case 's': |
| 5462 | { |
| 5463 | if (LocaleCompare("sample",option+1) == 0) |
| 5464 | { |
| 5465 | if (*option == '+') |
| 5466 | break; |
| 5467 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5468 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5469 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5470 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5471 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5472 | break; |
| 5473 | } |
| 5474 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5475 | { |
| 5476 | if (*option == '+') |
| 5477 | break; |
| 5478 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5479 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5480 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5481 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5482 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5483 | break; |
| 5484 | } |
| 5485 | if (LocaleCompare("scale",option+1) == 0) |
| 5486 | { |
| 5487 | if (*option == '+') |
| 5488 | break; |
| 5489 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5490 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5491 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5492 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5493 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5494 | break; |
| 5495 | } |
| 5496 | if (LocaleCompare("scene",option+1) == 0) |
| 5497 | { |
| 5498 | if (*option == '+') |
| 5499 | break; |
| 5500 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5501 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5502 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5503 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5504 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5505 | break; |
| 5506 | } |
| 5507 | if (LocaleCompare("seed",option+1) == 0) |
| 5508 | { |
| 5509 | if (*option == '+') |
| 5510 | break; |
| 5511 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5512 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5513 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5514 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5515 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5516 | break; |
| 5517 | } |
| 5518 | if (LocaleCompare("segment",option+1) == 0) |
| 5519 | { |
| 5520 | if (*option == '+') |
| 5521 | break; |
| 5522 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5523 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5524 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5525 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5526 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5527 | break; |
| 5528 | } |
| 5529 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5530 | { |
| 5531 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5532 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5533 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5534 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5535 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5536 | break; |
| 5537 | } |
| 5538 | if (LocaleCompare("separate",option+1) == 0) |
| 5539 | break; |
| 5540 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5541 | { |
| 5542 | if (*option == '+') |
| 5543 | break; |
| 5544 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5545 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5546 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5547 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5548 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5549 | break; |
| 5550 | } |
| 5551 | if (LocaleCompare("set",option+1) == 0) |
| 5552 | { |
| 5553 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5554 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5555 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5556 | if (*option == '+') |
| 5557 | break; |
| 5558 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5559 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5560 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5561 | break; |
| 5562 | } |
| 5563 | if (LocaleCompare("shade",option+1) == 0) |
| 5564 | { |
| 5565 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5566 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5567 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5568 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5569 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5570 | break; |
| 5571 | } |
| 5572 | if (LocaleCompare("shadow",option+1) == 0) |
| 5573 | { |
| 5574 | if (*option == '+') |
| 5575 | break; |
| 5576 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5577 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5578 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5579 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5580 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5581 | break; |
| 5582 | } |
| 5583 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5584 | { |
| 5585 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5586 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5587 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5588 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5589 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5590 | break; |
| 5591 | } |
| 5592 | if (LocaleCompare("shave",option+1) == 0) |
| 5593 | { |
| 5594 | if (*option == '+') |
| 5595 | break; |
| 5596 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5597 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5598 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5599 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5600 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5601 | break; |
| 5602 | } |
| 5603 | if (LocaleCompare("shear",option+1) == 0) |
| 5604 | { |
| 5605 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5606 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5607 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5608 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5609 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5610 | break; |
| 5611 | } |
| 5612 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5613 | { |
| 5614 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5615 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5616 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5617 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5618 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5619 | break; |
| 5620 | } |
| 5621 | if (LocaleCompare("size",option+1) == 0) |
| 5622 | { |
| 5623 | if (*option == '+') |
| 5624 | break; |
| 5625 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5626 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5627 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5628 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5629 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5630 | break; |
| 5631 | } |
| 5632 | if (LocaleCompare("sketch",option+1) == 0) |
| 5633 | { |
| 5634 | if (*option == '+') |
| 5635 | break; |
| 5636 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5637 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5638 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5639 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5640 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5641 | break; |
| 5642 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5643 | if (LocaleCompare("smush",option+1) == 0) |
| 5644 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5645 | i++; |
| 5646 | if (i == (ssize_t) argc) |
| 5647 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5648 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5649 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5650 | i++; |
| 5651 | break; |
| 5652 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5653 | if (LocaleCompare("solarize",option+1) == 0) |
| 5654 | { |
| 5655 | if (*option == '+') |
| 5656 | break; |
| 5657 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5658 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5659 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5660 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5661 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5662 | break; |
| 5663 | } |
| 5664 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5665 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5666 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5667 | op; |
| 5668 | |
| 5669 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5670 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5671 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5672 | op=ParseMagickOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
| 5673 | if (op < 0) |
| 5674 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5675 | argv[i]); |
| 5676 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5677 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5678 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5679 | break; |
| 5680 | } |
| 5681 | if (LocaleCompare("spread",option+1) == 0) |
| 5682 | { |
| 5683 | if (*option == '+') |
| 5684 | break; |
| 5685 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5686 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5687 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5688 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5689 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5690 | break; |
| 5691 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5692 | if (LocaleCompare("statistic",option+1) == 0) |
| 5693 | { |
| 5694 | ssize_t |
| 5695 | op; |
| 5696 | |
| 5697 | if (*option == '+') |
| 5698 | break; |
| 5699 | i++; |
| 5700 | if (i == (ssize_t) argc) |
| 5701 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5702 | op=ParseMagickOption(MagickStatisticOptions,MagickFalse,argv[i]); |
| 5703 | if (op < 0) |
| 5704 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5705 | argv[i]); |
| 5706 | i++; |
| 5707 | if (i == (ssize_t) (argc-1)) |
| 5708 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5709 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5710 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5711 | break; |
| 5712 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5713 | if (LocaleCompare("stretch",option+1) == 0) |
| 5714 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5715 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5716 | stretch; |
| 5717 | |
| 5718 | if (*option == '+') |
| 5719 | break; |
| 5720 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5721 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5722 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5723 | stretch=ParseMagickOption(MagickStretchOptions,MagickFalse,argv[i]); |
| 5724 | if (stretch < 0) |
| 5725 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5726 | argv[i]); |
| 5727 | break; |
| 5728 | } |
| 5729 | if (LocaleCompare("strip",option+1) == 0) |
| 5730 | break; |
| 5731 | if (LocaleCompare("stroke",option+1) == 0) |
| 5732 | { |
| 5733 | if (*option == '+') |
| 5734 | break; |
| 5735 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5736 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5737 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5738 | break; |
| 5739 | } |
| 5740 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5741 | { |
| 5742 | if (*option == '+') |
| 5743 | break; |
| 5744 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5745 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5746 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5747 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5748 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5749 | break; |
| 5750 | } |
| 5751 | if (LocaleCompare("style",option+1) == 0) |
| 5752 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5753 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5754 | style; |
| 5755 | |
| 5756 | if (*option == '+') |
| 5757 | break; |
| 5758 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5759 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5760 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5761 | style=ParseMagickOption(MagickStyleOptions,MagickFalse,argv[i]); |
| 5762 | if (style < 0) |
| 5763 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5764 | argv[i]); |
| 5765 | break; |
| 5766 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5767 | if (LocaleCompare("swap",option+1) == 0) |
| 5768 | { |
| 5769 | if (*option == '+') |
| 5770 | break; |
| 5771 | i++; |
| 5772 | if (i == (ssize_t) (argc-1)) |
| 5773 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5774 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5775 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5776 | break; |
| 5777 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5778 | if (LocaleCompare("swirl",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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5786 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5787 | break; |
| 5788 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5789 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5790 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5791 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5792 | } |
| 5793 | case 't': |
| 5794 | { |
| 5795 | if (LocaleCompare("taint",option+1) == 0) |
| 5796 | break; |
| 5797 | if (LocaleCompare("texture",option+1) == 0) |
| 5798 | { |
| 5799 | if (*option == '+') |
| 5800 | break; |
| 5801 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5802 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5803 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5804 | break; |
| 5805 | } |
| 5806 | if (LocaleCompare("tile",option+1) == 0) |
| 5807 | { |
| 5808 | if (*option == '+') |
| 5809 | break; |
| 5810 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5811 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5812 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5813 | break; |
| 5814 | } |
| 5815 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5816 | { |
| 5817 | if (*option == '+') |
| 5818 | break; |
| 5819 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5820 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5821 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5822 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5823 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5824 | break; |
| 5825 | } |
| 5826 | if (LocaleCompare("tint",option+1) == 0) |
| 5827 | { |
| 5828 | if (*option == '+') |
| 5829 | break; |
| 5830 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5831 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5832 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5833 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5834 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5835 | break; |
| 5836 | } |
| 5837 | if (LocaleCompare("transform",option+1) == 0) |
| 5838 | break; |
| 5839 | if (LocaleCompare("transpose",option+1) == 0) |
| 5840 | break; |
| 5841 | if (LocaleCompare("transverse",option+1) == 0) |
| 5842 | break; |
| 5843 | if (LocaleCompare("threshold",option+1) == 0) |
| 5844 | { |
| 5845 | if (*option == '+') |
| 5846 | break; |
| 5847 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5848 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5849 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5850 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5851 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5852 | break; |
| 5853 | } |
| 5854 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5855 | { |
| 5856 | if (*option == '+') |
| 5857 | break; |
| 5858 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5859 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5860 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5861 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5862 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5863 | break; |
| 5864 | } |
| 5865 | if (LocaleCompare("transparent",option+1) == 0) |
| 5866 | { |
| 5867 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5868 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5869 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5870 | break; |
| 5871 | } |
| 5872 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 5873 | { |
| 5874 | if (*option == '+') |
| 5875 | break; |
| 5876 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5877 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5878 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5879 | break; |
| 5880 | } |
| 5881 | if (LocaleCompare("treedepth",option+1) == 0) |
| 5882 | { |
| 5883 | if (*option == '+') |
| 5884 | break; |
| 5885 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5886 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5887 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5888 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5889 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5890 | break; |
| 5891 | } |
| 5892 | if (LocaleCompare("trim",option+1) == 0) |
| 5893 | break; |
| 5894 | if (LocaleCompare("type",option+1) == 0) |
| 5895 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5896 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5897 | type; |
| 5898 | |
| 5899 | if (*option == '+') |
| 5900 | break; |
| 5901 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5902 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5903 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5904 | type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]); |
| 5905 | if (type < 0) |
| 5906 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5907 | argv[i]); |
| 5908 | break; |
| 5909 | } |
| 5910 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5911 | } |
| 5912 | case 'u': |
| 5913 | { |
| 5914 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5915 | { |
| 5916 | if (*option == '+') |
| 5917 | break; |
| 5918 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5919 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5920 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5921 | break; |
| 5922 | } |
| 5923 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5924 | break; |
| 5925 | if (LocaleCompare("units",option+1) == 0) |
| 5926 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5927 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5928 | units; |
| 5929 | |
| 5930 | if (*option == '+') |
| 5931 | break; |
| 5932 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5933 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5934 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5935 | units=ParseMagickOption(MagickResolutionOptions,MagickFalse, |
| 5936 | argv[i]); |
| 5937 | if (units < 0) |
| 5938 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5939 | argv[i]); |
| 5940 | break; |
| 5941 | } |
| 5942 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5943 | { |
| 5944 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5945 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5946 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5947 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5948 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5949 | break; |
| 5950 | } |
| 5951 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5952 | } |
| 5953 | case 'v': |
| 5954 | { |
| 5955 | if (LocaleCompare("verbose",option+1) == 0) |
| 5956 | { |
| 5957 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 5958 | break; |
| 5959 | } |
| 5960 | if ((LocaleCompare("version",option+1) == 0) || |
| 5961 | (LocaleCompare("-version",option+1) == 0)) |
| 5962 | { |
| 5963 | (void) fprintf(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5964 | GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 5965 | (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright()); |
| 5966 | (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5967 | break; |
| 5968 | } |
| 5969 | if (LocaleCompare("view",option+1) == 0) |
| 5970 | { |
| 5971 | if (*option == '+') |
| 5972 | break; |
| 5973 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5974 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5975 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5976 | break; |
| 5977 | } |
| 5978 | if (LocaleCompare("vignette",option+1) == 0) |
| 5979 | { |
| 5980 | if (*option == '+') |
| 5981 | break; |
| 5982 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5983 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5984 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5985 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5986 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5987 | break; |
| 5988 | } |
| 5989 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 5990 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5991 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5992 | method; |
| 5993 | |
| 5994 | if (*option == '+') |
| 5995 | break; |
| 5996 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5997 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5998 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5999 | method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse, |
| 6000 | argv[i]); |
| 6001 | if (method < 0) |
| 6002 | ThrowMogrifyException(OptionError, |
| 6003 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 6004 | break; |
| 6005 | } |
| 6006 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6007 | } |
| 6008 | case 'w': |
| 6009 | { |
| 6010 | if (LocaleCompare("wave",option+1) == 0) |
| 6011 | { |
| 6012 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6013 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6014 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6015 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6016 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6017 | break; |
| 6018 | } |
| 6019 | if (LocaleCompare("weight",option+1) == 0) |
| 6020 | { |
| 6021 | if (*option == '+') |
| 6022 | break; |
| 6023 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6024 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6025 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6026 | break; |
| 6027 | } |
| 6028 | if (LocaleCompare("white-point",option+1) == 0) |
| 6029 | { |
| 6030 | if (*option == '+') |
| 6031 | break; |
| 6032 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6033 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6034 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6035 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6036 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6037 | break; |
| 6038 | } |
| 6039 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6040 | { |
| 6041 | if (*option == '+') |
| 6042 | break; |
| 6043 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6044 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6045 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6046 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6047 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6048 | break; |
| 6049 | } |
| 6050 | if (LocaleCompare("write",option+1) == 0) |
| 6051 | { |
| 6052 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6053 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6054 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6055 | break; |
| 6056 | } |
| 6057 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6058 | } |
| 6059 | case '?': |
| 6060 | break; |
| 6061 | default: |
| 6062 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6063 | } |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame^] | 6064 | fire=(ParseMagickOption(MagickCommandOptions,MagickFalse,option) |
| 6065 | &FireOption) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6066 | if (fire != MagickFalse) |
| 6067 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6068 | } |
| 6069 | if (k != 0) |
| 6070 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6071 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6072 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6073 | DestroyMogrify(); |
| 6074 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6075 | } |
| 6076 | |
| 6077 | /* |
| 6078 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6079 | % % |
| 6080 | % % |
| 6081 | % % |
| 6082 | + M o g r i f y I m a g e I n f o % |
| 6083 | % % |
| 6084 | % % |
| 6085 | % % |
| 6086 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6087 | % |
| 6088 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6089 | % prescribed by command line options. |
| 6090 | % |
| 6091 | % The format of the MogrifyImageInfo method is: |
| 6092 | % |
| 6093 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6094 | % const char **argv,ExceptionInfo *exception) |
| 6095 | % |
| 6096 | % A description of each parameter follows: |
| 6097 | % |
| 6098 | % o image_info: the image info.. |
| 6099 | % |
| 6100 | % o argc: Specifies a pointer to an integer describing the number of |
| 6101 | % elements in the argument vector. |
| 6102 | % |
| 6103 | % o argv: Specifies a pointer to a text array containing the command line |
| 6104 | % arguments. |
| 6105 | % |
| 6106 | % o exception: return any errors or warnings in this structure. |
| 6107 | % |
| 6108 | */ |
| 6109 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6110 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6111 | { |
| 6112 | const char |
| 6113 | *option; |
| 6114 | |
| 6115 | GeometryInfo |
| 6116 | geometry_info; |
| 6117 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6118 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6119 | count; |
| 6120 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6121 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6122 | i; |
| 6123 | |
| 6124 | /* |
| 6125 | Initialize method variables. |
| 6126 | */ |
| 6127 | assert(image_info != (ImageInfo *) NULL); |
| 6128 | assert(image_info->signature == MagickSignature); |
| 6129 | if (image_info->debug != MagickFalse) |
| 6130 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6131 | image_info->filename); |
| 6132 | if (argc < 0) |
| 6133 | return(MagickTrue); |
| 6134 | /* |
| 6135 | Set the image settings. |
| 6136 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6137 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6138 | { |
| 6139 | option=argv[i]; |
| 6140 | if (IsMagickOption(option) == MagickFalse) |
| 6141 | continue; |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame^] | 6142 | count=ParseMagickOption(MagickCommandOptions,MagickFalse,option); |
| 6143 | count=MagickMax(count,0L); |
| 6144 | count&=NumArgsOption; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6145 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6146 | break; |
| 6147 | switch (*(option+1)) |
| 6148 | { |
| 6149 | case 'a': |
| 6150 | { |
| 6151 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6152 | { |
| 6153 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6154 | break; |
| 6155 | } |
| 6156 | if (LocaleCompare("antialias",option+1) == 0) |
| 6157 | { |
| 6158 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6159 | break; |
| 6160 | } |
| 6161 | if (LocaleCompare("attenuate",option+1) == 0) |
| 6162 | { |
| 6163 | if (*option == '+') |
| 6164 | { |
| 6165 | (void) DeleteImageOption(image_info,option+1); |
| 6166 | break; |
| 6167 | } |
| 6168 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6169 | break; |
| 6170 | } |
| 6171 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6172 | { |
| 6173 | if (*option == '+') |
| 6174 | (void) CloneString(&image_info->authenticate,(char *) NULL); |
| 6175 | else |
| 6176 | (void) CloneString(&image_info->authenticate,argv[i+1]); |
| 6177 | break; |
| 6178 | } |
| 6179 | break; |
| 6180 | } |
| 6181 | case 'b': |
| 6182 | { |
| 6183 | if (LocaleCompare("background",option+1) == 0) |
| 6184 | { |
| 6185 | if (*option == '+') |
| 6186 | { |
| 6187 | (void) DeleteImageOption(image_info,option+1); |
| 6188 | (void) QueryColorDatabase(BackgroundColor, |
| 6189 | &image_info->background_color,exception); |
| 6190 | break; |
| 6191 | } |
| 6192 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6193 | (void) QueryColorDatabase(argv[i+1],&image_info->background_color, |
| 6194 | exception); |
| 6195 | break; |
| 6196 | } |
| 6197 | if (LocaleCompare("bias",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("black-point-compensation",option+1) == 0) |
| 6208 | { |
| 6209 | if (*option == '+') |
| 6210 | { |
| 6211 | (void) SetImageOption(image_info,option+1,"false"); |
| 6212 | break; |
| 6213 | } |
| 6214 | (void) SetImageOption(image_info,option+1,"true"); |
| 6215 | break; |
| 6216 | } |
| 6217 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6218 | { |
| 6219 | if (*option == '+') |
| 6220 | { |
| 6221 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6222 | break; |
| 6223 | } |
| 6224 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6225 | break; |
| 6226 | } |
| 6227 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6228 | { |
| 6229 | if (*option == '+') |
| 6230 | { |
| 6231 | (void) DeleteImageOption(image_info,option+1); |
| 6232 | (void) QueryColorDatabase(BorderColor,&image_info->border_color, |
| 6233 | exception); |
| 6234 | break; |
| 6235 | } |
| 6236 | (void) QueryColorDatabase(argv[i+1],&image_info->border_color, |
| 6237 | exception); |
| 6238 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6239 | break; |
| 6240 | } |
| 6241 | if (LocaleCompare("box",option+1) == 0) |
| 6242 | { |
| 6243 | if (*option == '+') |
| 6244 | { |
| 6245 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6246 | break; |
| 6247 | } |
| 6248 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6249 | break; |
| 6250 | } |
| 6251 | break; |
| 6252 | } |
| 6253 | case 'c': |
| 6254 | { |
| 6255 | if (LocaleCompare("cache",option+1) == 0) |
| 6256 | { |
| 6257 | MagickSizeType |
| 6258 | limit; |
| 6259 | |
| 6260 | limit=MagickResourceInfinity; |
| 6261 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6262 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6263 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6264 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6265 | break; |
| 6266 | } |
| 6267 | if (LocaleCompare("caption",option+1) == 0) |
| 6268 | { |
| 6269 | if (*option == '+') |
| 6270 | { |
| 6271 | (void) DeleteImageOption(image_info,option+1); |
| 6272 | break; |
| 6273 | } |
| 6274 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6275 | break; |
| 6276 | } |
| 6277 | if (LocaleCompare("channel",option+1) == 0) |
| 6278 | { |
| 6279 | if (*option == '+') |
| 6280 | { |
| 6281 | image_info->channel=DefaultChannels; |
| 6282 | break; |
| 6283 | } |
| 6284 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6285 | break; |
| 6286 | } |
| 6287 | if (LocaleCompare("colors",option+1) == 0) |
| 6288 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6289 | image_info->colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6290 | break; |
| 6291 | } |
| 6292 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6293 | { |
| 6294 | if (*option == '+') |
| 6295 | { |
| 6296 | image_info->colorspace=UndefinedColorspace; |
| 6297 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6298 | break; |
| 6299 | } |
| 6300 | image_info->colorspace=(ColorspaceType) ParseMagickOption( |
| 6301 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6302 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6303 | break; |
| 6304 | } |
| 6305 | if (LocaleCompare("compress",option+1) == 0) |
| 6306 | { |
| 6307 | if (*option == '+') |
| 6308 | { |
| 6309 | image_info->compression=UndefinedCompression; |
| 6310 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6311 | break; |
| 6312 | } |
| 6313 | image_info->compression=(CompressionType) ParseMagickOption( |
| 6314 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6315 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6316 | break; |
| 6317 | } |
| 6318 | if (LocaleCompare("comment",option+1) == 0) |
| 6319 | { |
| 6320 | if (*option == '+') |
| 6321 | { |
| 6322 | (void) DeleteImageOption(image_info,option+1); |
| 6323 | break; |
| 6324 | } |
| 6325 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6326 | break; |
| 6327 | } |
| 6328 | if (LocaleCompare("compose",option+1) == 0) |
| 6329 | { |
| 6330 | if (*option == '+') |
| 6331 | { |
| 6332 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6333 | break; |
| 6334 | } |
| 6335 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6336 | break; |
| 6337 | } |
| 6338 | if (LocaleCompare("compress",option+1) == 0) |
| 6339 | { |
| 6340 | if (*option == '+') |
| 6341 | { |
| 6342 | image_info->compression=UndefinedCompression; |
| 6343 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6344 | break; |
| 6345 | } |
| 6346 | image_info->compression=(CompressionType) ParseMagickOption( |
| 6347 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6348 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6349 | break; |
| 6350 | } |
| 6351 | break; |
| 6352 | } |
| 6353 | case 'd': |
| 6354 | { |
| 6355 | if (LocaleCompare("debug",option+1) == 0) |
| 6356 | { |
| 6357 | if (*option == '+') |
| 6358 | (void) SetLogEventMask("none"); |
| 6359 | else |
| 6360 | (void) SetLogEventMask(argv[i+1]); |
| 6361 | image_info->debug=IsEventLogging(); |
| 6362 | break; |
| 6363 | } |
| 6364 | if (LocaleCompare("define",option+1) == 0) |
| 6365 | { |
| 6366 | if (*option == '+') |
| 6367 | { |
| 6368 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6369 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6370 | else |
| 6371 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6372 | break; |
| 6373 | } |
| 6374 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6375 | { |
| 6376 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6377 | exception); |
| 6378 | break; |
| 6379 | } |
| 6380 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6381 | break; |
| 6382 | } |
| 6383 | if (LocaleCompare("delay",option+1) == 0) |
| 6384 | { |
| 6385 | if (*option == '+') |
| 6386 | { |
| 6387 | (void) SetImageOption(image_info,option+1,"0"); |
| 6388 | break; |
| 6389 | } |
| 6390 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6391 | break; |
| 6392 | } |
| 6393 | if (LocaleCompare("density",option+1) == 0) |
| 6394 | { |
| 6395 | /* |
| 6396 | Set image density. |
| 6397 | */ |
| 6398 | if (*option == '+') |
| 6399 | { |
| 6400 | if (image_info->density != (char *) NULL) |
| 6401 | image_info->density=DestroyString(image_info->density); |
| 6402 | (void) SetImageOption(image_info,option+1,"72"); |
| 6403 | break; |
| 6404 | } |
| 6405 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6406 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6407 | break; |
| 6408 | } |
| 6409 | if (LocaleCompare("depth",option+1) == 0) |
| 6410 | { |
| 6411 | if (*option == '+') |
| 6412 | { |
| 6413 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6414 | break; |
| 6415 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6416 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6417 | break; |
| 6418 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6419 | if (LocaleCompare("direction",option+1) == 0) |
| 6420 | { |
| 6421 | if (*option == '+') |
| 6422 | { |
| 6423 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6424 | break; |
| 6425 | } |
| 6426 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6427 | break; |
| 6428 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6429 | if (LocaleCompare("display",option+1) == 0) |
| 6430 | { |
| 6431 | if (*option == '+') |
| 6432 | { |
| 6433 | if (image_info->server_name != (char *) NULL) |
| 6434 | image_info->server_name=DestroyString( |
| 6435 | image_info->server_name); |
| 6436 | break; |
| 6437 | } |
| 6438 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6439 | break; |
| 6440 | } |
| 6441 | if (LocaleCompare("dispose",option+1) == 0) |
| 6442 | { |
| 6443 | if (*option == '+') |
| 6444 | { |
| 6445 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6446 | break; |
| 6447 | } |
| 6448 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6449 | break; |
| 6450 | } |
| 6451 | if (LocaleCompare("dither",option+1) == 0) |
| 6452 | { |
| 6453 | if (*option == '+') |
| 6454 | { |
| 6455 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6456 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6457 | break; |
| 6458 | } |
| 6459 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6460 | image_info->dither=MagickTrue; |
| 6461 | break; |
| 6462 | } |
| 6463 | break; |
| 6464 | } |
| 6465 | case 'e': |
| 6466 | { |
| 6467 | if (LocaleCompare("encoding",option+1) == 0) |
| 6468 | { |
| 6469 | if (*option == '+') |
| 6470 | { |
| 6471 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6472 | break; |
| 6473 | } |
| 6474 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6475 | break; |
| 6476 | } |
| 6477 | if (LocaleCompare("endian",option+1) == 0) |
| 6478 | { |
| 6479 | if (*option == '+') |
| 6480 | { |
| 6481 | image_info->endian=UndefinedEndian; |
| 6482 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6483 | break; |
| 6484 | } |
| 6485 | image_info->endian=(EndianType) ParseMagickOption( |
| 6486 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6487 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6488 | break; |
| 6489 | } |
| 6490 | if (LocaleCompare("extract",option+1) == 0) |
| 6491 | { |
| 6492 | /* |
| 6493 | Set image extract geometry. |
| 6494 | */ |
| 6495 | if (*option == '+') |
| 6496 | { |
| 6497 | if (image_info->extract != (char *) NULL) |
| 6498 | image_info->extract=DestroyString(image_info->extract); |
| 6499 | break; |
| 6500 | } |
| 6501 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6502 | break; |
| 6503 | } |
| 6504 | break; |
| 6505 | } |
| 6506 | case 'f': |
| 6507 | { |
| 6508 | if (LocaleCompare("fill",option+1) == 0) |
| 6509 | { |
| 6510 | if (*option == '+') |
| 6511 | { |
| 6512 | (void) SetImageOption(image_info,option+1,"none"); |
| 6513 | break; |
| 6514 | } |
| 6515 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6516 | break; |
| 6517 | } |
| 6518 | if (LocaleCompare("filter",option+1) == 0) |
| 6519 | { |
| 6520 | if (*option == '+') |
| 6521 | { |
| 6522 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6523 | break; |
| 6524 | } |
| 6525 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6526 | break; |
| 6527 | } |
| 6528 | if (LocaleCompare("font",option+1) == 0) |
| 6529 | { |
| 6530 | if (*option == '+') |
| 6531 | { |
| 6532 | if (image_info->font != (char *) NULL) |
| 6533 | image_info->font=DestroyString(image_info->font); |
| 6534 | break; |
| 6535 | } |
| 6536 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6537 | break; |
| 6538 | } |
| 6539 | if (LocaleCompare("format",option+1) == 0) |
| 6540 | { |
| 6541 | register const char |
| 6542 | *q; |
| 6543 | |
| 6544 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6545 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6546 | image_info->ping=MagickFalse; |
| 6547 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6548 | break; |
| 6549 | } |
| 6550 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6551 | { |
| 6552 | if (*option == '+') |
| 6553 | { |
| 6554 | image_info->fuzz=0.0; |
| 6555 | (void) SetImageOption(image_info,option+1,"0"); |
| 6556 | break; |
| 6557 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6558 | image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6559 | 1.0); |
| 6560 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6561 | break; |
| 6562 | } |
| 6563 | break; |
| 6564 | } |
| 6565 | case 'g': |
| 6566 | { |
| 6567 | if (LocaleCompare("gravity",option+1) == 0) |
| 6568 | { |
| 6569 | if (*option == '+') |
| 6570 | { |
| 6571 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6572 | break; |
| 6573 | } |
| 6574 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6575 | break; |
| 6576 | } |
| 6577 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6578 | { |
| 6579 | if (*option == '+') |
| 6580 | { |
| 6581 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6582 | break; |
| 6583 | } |
| 6584 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6585 | break; |
| 6586 | } |
| 6587 | break; |
| 6588 | } |
| 6589 | case 'i': |
| 6590 | { |
| 6591 | if (LocaleCompare("intent",option+1) == 0) |
| 6592 | { |
| 6593 | if (*option == '+') |
| 6594 | { |
| 6595 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6596 | break; |
| 6597 | } |
| 6598 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6599 | break; |
| 6600 | } |
| 6601 | if (LocaleCompare("interlace",option+1) == 0) |
| 6602 | { |
| 6603 | if (*option == '+') |
| 6604 | { |
| 6605 | image_info->interlace=UndefinedInterlace; |
| 6606 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6607 | break; |
| 6608 | } |
| 6609 | image_info->interlace=(InterlaceType) ParseMagickOption( |
| 6610 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6611 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6612 | break; |
| 6613 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6614 | if (LocaleCompare("interline-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 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6624 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6625 | { |
| 6626 | if (*option == '+') |
| 6627 | { |
| 6628 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6629 | break; |
| 6630 | } |
| 6631 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6632 | break; |
| 6633 | } |
| 6634 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6635 | { |
| 6636 | if (*option == '+') |
| 6637 | { |
| 6638 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6639 | break; |
| 6640 | } |
| 6641 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6642 | break; |
| 6643 | } |
| 6644 | break; |
| 6645 | } |
| 6646 | case 'k': |
| 6647 | { |
| 6648 | if (LocaleCompare("kerning",option+1) == 0) |
| 6649 | { |
| 6650 | if (*option == '+') |
| 6651 | { |
| 6652 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6653 | break; |
| 6654 | } |
| 6655 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6656 | break; |
| 6657 | } |
| 6658 | break; |
| 6659 | } |
| 6660 | case 'l': |
| 6661 | { |
| 6662 | if (LocaleCompare("label",option+1) == 0) |
| 6663 | { |
| 6664 | if (*option == '+') |
| 6665 | { |
| 6666 | (void) DeleteImageOption(image_info,option+1); |
| 6667 | break; |
| 6668 | } |
| 6669 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6670 | break; |
| 6671 | } |
| 6672 | if (LocaleCompare("limit",option+1) == 0) |
| 6673 | { |
| 6674 | MagickSizeType |
| 6675 | limit; |
| 6676 | |
| 6677 | ResourceType |
| 6678 | type; |
| 6679 | |
| 6680 | if (*option == '+') |
| 6681 | break; |
| 6682 | type=(ResourceType) ParseMagickOption(MagickResourceOptions, |
| 6683 | MagickFalse,argv[i+1]); |
| 6684 | limit=MagickResourceInfinity; |
| 6685 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6686 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6687 | (void) SetMagickResourceLimit(type,limit); |
| 6688 | break; |
| 6689 | } |
| 6690 | if (LocaleCompare("list",option+1) == 0) |
| 6691 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6692 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6693 | list; |
| 6694 | |
| 6695 | /* |
| 6696 | Display configuration list. |
| 6697 | */ |
| 6698 | list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i+1]); |
| 6699 | switch (list) |
| 6700 | { |
| 6701 | case MagickCoderOptions: |
| 6702 | { |
| 6703 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6704 | break; |
| 6705 | } |
| 6706 | case MagickColorOptions: |
| 6707 | { |
| 6708 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6709 | break; |
| 6710 | } |
| 6711 | case MagickConfigureOptions: |
| 6712 | { |
| 6713 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6714 | break; |
| 6715 | } |
| 6716 | case MagickDelegateOptions: |
| 6717 | { |
| 6718 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6719 | break; |
| 6720 | } |
| 6721 | case MagickFontOptions: |
| 6722 | { |
| 6723 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6724 | break; |
| 6725 | } |
| 6726 | case MagickFormatOptions: |
| 6727 | { |
| 6728 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6729 | break; |
| 6730 | } |
| 6731 | case MagickLocaleOptions: |
| 6732 | { |
| 6733 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6734 | break; |
| 6735 | } |
| 6736 | case MagickLogOptions: |
| 6737 | { |
| 6738 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6739 | break; |
| 6740 | } |
| 6741 | case MagickMagicOptions: |
| 6742 | { |
| 6743 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6744 | break; |
| 6745 | } |
| 6746 | case MagickMimeOptions: |
| 6747 | { |
| 6748 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6749 | break; |
| 6750 | } |
| 6751 | case MagickModuleOptions: |
| 6752 | { |
| 6753 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6754 | break; |
| 6755 | } |
| 6756 | case MagickPolicyOptions: |
| 6757 | { |
| 6758 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6759 | break; |
| 6760 | } |
| 6761 | case MagickResourceOptions: |
| 6762 | { |
| 6763 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6764 | break; |
| 6765 | } |
| 6766 | case MagickThresholdOptions: |
| 6767 | { |
| 6768 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6769 | break; |
| 6770 | } |
| 6771 | default: |
| 6772 | { |
| 6773 | (void) ListMagickOptions((FILE *) NULL,(MagickOption) list, |
| 6774 | exception); |
| 6775 | break; |
| 6776 | } |
| 6777 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6778 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6779 | } |
| 6780 | if (LocaleCompare("log",option+1) == 0) |
| 6781 | { |
| 6782 | if (*option == '+') |
| 6783 | break; |
| 6784 | (void) SetLogFormat(argv[i+1]); |
| 6785 | break; |
| 6786 | } |
| 6787 | if (LocaleCompare("loop",option+1) == 0) |
| 6788 | { |
| 6789 | if (*option == '+') |
| 6790 | { |
| 6791 | (void) SetImageOption(image_info,option+1,"0"); |
| 6792 | break; |
| 6793 | } |
| 6794 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6795 | break; |
| 6796 | } |
| 6797 | break; |
| 6798 | } |
| 6799 | case 'm': |
| 6800 | { |
| 6801 | if (LocaleCompare("matte",option+1) == 0) |
| 6802 | { |
| 6803 | if (*option == '+') |
| 6804 | { |
| 6805 | (void) SetImageOption(image_info,option+1,"false"); |
| 6806 | break; |
| 6807 | } |
| 6808 | (void) SetImageOption(image_info,option+1,"true"); |
| 6809 | break; |
| 6810 | } |
| 6811 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6812 | { |
| 6813 | if (*option == '+') |
| 6814 | { |
| 6815 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6816 | (void) QueryColorDatabase(MatteColor,&image_info->matte_color, |
| 6817 | exception); |
| 6818 | break; |
| 6819 | } |
| 6820 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6821 | (void) QueryColorDatabase(argv[i+1],&image_info->matte_color, |
| 6822 | exception); |
| 6823 | break; |
| 6824 | } |
| 6825 | if (LocaleCompare("monitor",option+1) == 0) |
| 6826 | { |
| 6827 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6828 | (void *) NULL); |
| 6829 | break; |
| 6830 | } |
| 6831 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6832 | { |
| 6833 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6834 | break; |
| 6835 | } |
| 6836 | break; |
| 6837 | } |
| 6838 | case 'o': |
| 6839 | { |
| 6840 | if (LocaleCompare("orient",option+1) == 0) |
| 6841 | { |
| 6842 | if (*option == '+') |
| 6843 | { |
| 6844 | image_info->orientation=UndefinedOrientation; |
| 6845 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6846 | break; |
| 6847 | } |
| 6848 | image_info->orientation=(OrientationType) ParseMagickOption( |
| 6849 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6850 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6851 | break; |
| 6852 | } |
| 6853 | } |
| 6854 | case 'p': |
| 6855 | { |
| 6856 | if (LocaleCompare("page",option+1) == 0) |
| 6857 | { |
| 6858 | char |
| 6859 | *canonical_page, |
| 6860 | page[MaxTextExtent]; |
| 6861 | |
| 6862 | const char |
| 6863 | *image_option; |
| 6864 | |
| 6865 | MagickStatusType |
| 6866 | flags; |
| 6867 | |
| 6868 | RectangleInfo |
| 6869 | geometry; |
| 6870 | |
| 6871 | if (*option == '+') |
| 6872 | { |
| 6873 | (void) DeleteImageOption(image_info,option+1); |
| 6874 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6875 | break; |
| 6876 | } |
| 6877 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6878 | image_option=GetImageOption(image_info,"page"); |
| 6879 | if (image_option != (const char *) NULL) |
| 6880 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6881 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6882 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6883 | canonical_page=DestroyString(canonical_page); |
| 6884 | (void) FormatMagickString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6885 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6886 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 6887 | (void) FormatMagickString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6888 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6889 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6890 | (void) SetImageOption(image_info,option+1,page); |
| 6891 | (void) CloneString(&image_info->page,page); |
| 6892 | break; |
| 6893 | } |
| 6894 | if (LocaleCompare("pen",option+1) == 0) |
| 6895 | { |
| 6896 | if (*option == '+') |
| 6897 | { |
| 6898 | (void) SetImageOption(image_info,option+1,"none"); |
| 6899 | break; |
| 6900 | } |
| 6901 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6902 | break; |
| 6903 | } |
| 6904 | if (LocaleCompare("ping",option+1) == 0) |
| 6905 | { |
| 6906 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6907 | break; |
| 6908 | } |
| 6909 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6910 | { |
| 6911 | if (*option == '+') |
| 6912 | geometry_info.rho=0.0; |
| 6913 | else |
| 6914 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6915 | image_info->pointsize=geometry_info.rho; |
| 6916 | break; |
| 6917 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6918 | if (LocaleCompare("precision",option+1) == 0) |
| 6919 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6920 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6921 | break; |
| 6922 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6923 | if (LocaleCompare("preview",option+1) == 0) |
| 6924 | { |
| 6925 | /* |
| 6926 | Preview image. |
| 6927 | */ |
| 6928 | if (*option == '+') |
| 6929 | { |
| 6930 | image_info->preview_type=UndefinedPreview; |
| 6931 | break; |
| 6932 | } |
| 6933 | image_info->preview_type=(PreviewType) ParseMagickOption( |
| 6934 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6935 | break; |
| 6936 | } |
| 6937 | break; |
| 6938 | } |
| 6939 | case 'q': |
| 6940 | { |
| 6941 | if (LocaleCompare("quality",option+1) == 0) |
| 6942 | { |
| 6943 | /* |
| 6944 | Set image compression quality. |
| 6945 | */ |
| 6946 | if (*option == '+') |
| 6947 | { |
| 6948 | image_info->quality=UndefinedCompressionQuality; |
| 6949 | (void) SetImageOption(image_info,option+1,"0"); |
| 6950 | break; |
| 6951 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6952 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6953 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6954 | break; |
| 6955 | } |
| 6956 | if (LocaleCompare("quiet",option+1) == 0) |
| 6957 | { |
| 6958 | static WarningHandler |
| 6959 | warning_handler = (WarningHandler) NULL; |
| 6960 | |
| 6961 | if (*option == '+') |
| 6962 | { |
| 6963 | /* |
| 6964 | Restore error or warning messages. |
| 6965 | */ |
| 6966 | warning_handler=SetWarningHandler(warning_handler); |
| 6967 | break; |
| 6968 | } |
| 6969 | /* |
| 6970 | Suppress error or warning messages. |
| 6971 | */ |
| 6972 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6973 | break; |
| 6974 | } |
| 6975 | break; |
| 6976 | } |
| 6977 | case 'r': |
| 6978 | { |
| 6979 | if (LocaleCompare("red-primary",option+1) == 0) |
| 6980 | { |
| 6981 | if (*option == '+') |
| 6982 | { |
| 6983 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6984 | break; |
| 6985 | } |
| 6986 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6987 | break; |
| 6988 | } |
| 6989 | break; |
| 6990 | } |
| 6991 | case 's': |
| 6992 | { |
| 6993 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 6994 | { |
| 6995 | /* |
| 6996 | Set image sampling factor. |
| 6997 | */ |
| 6998 | if (*option == '+') |
| 6999 | { |
| 7000 | if (image_info->sampling_factor != (char *) NULL) |
| 7001 | image_info->sampling_factor=DestroyString( |
| 7002 | image_info->sampling_factor); |
| 7003 | break; |
| 7004 | } |
| 7005 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 7006 | break; |
| 7007 | } |
| 7008 | if (LocaleCompare("scene",option+1) == 0) |
| 7009 | { |
| 7010 | /* |
| 7011 | Set image scene. |
| 7012 | */ |
| 7013 | if (*option == '+') |
| 7014 | { |
| 7015 | image_info->scene=0; |
| 7016 | (void) SetImageOption(image_info,option+1,"0"); |
| 7017 | break; |
| 7018 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7019 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7020 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7021 | break; |
| 7022 | } |
| 7023 | if (LocaleCompare("seed",option+1) == 0) |
| 7024 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7025 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7026 | seed; |
| 7027 | |
| 7028 | if (*option == '+') |
| 7029 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7030 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7031 | SeedPseudoRandomGenerator(seed); |
| 7032 | break; |
| 7033 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7034 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7035 | SeedPseudoRandomGenerator(seed); |
| 7036 | break; |
| 7037 | } |
| 7038 | if (LocaleCompare("size",option+1) == 0) |
| 7039 | { |
| 7040 | if (*option == '+') |
| 7041 | { |
| 7042 | if (image_info->size != (char *) NULL) |
| 7043 | image_info->size=DestroyString(image_info->size); |
| 7044 | break; |
| 7045 | } |
| 7046 | (void) CloneString(&image_info->size,argv[i+1]); |
| 7047 | break; |
| 7048 | } |
| 7049 | if (LocaleCompare("stroke",option+1) == 0) |
| 7050 | { |
| 7051 | if (*option == '+') |
| 7052 | { |
| 7053 | (void) SetImageOption(image_info,option+1,"none"); |
| 7054 | break; |
| 7055 | } |
| 7056 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7057 | break; |
| 7058 | } |
| 7059 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7060 | { |
| 7061 | if (*option == '+') |
| 7062 | { |
| 7063 | (void) SetImageOption(image_info,option+1,"0"); |
| 7064 | break; |
| 7065 | } |
| 7066 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7067 | break; |
| 7068 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7069 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7070 | { |
| 7071 | if (*option == '+') |
| 7072 | { |
| 7073 | image_info->synchronize=MagickFalse; |
| 7074 | break; |
| 7075 | } |
| 7076 | image_info->synchronize=MagickTrue; |
| 7077 | break; |
| 7078 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7079 | break; |
| 7080 | } |
| 7081 | case 't': |
| 7082 | { |
| 7083 | if (LocaleCompare("taint",option+1) == 0) |
| 7084 | { |
| 7085 | if (*option == '+') |
| 7086 | { |
| 7087 | (void) SetImageOption(image_info,option+1,"false"); |
| 7088 | break; |
| 7089 | } |
| 7090 | (void) SetImageOption(image_info,option+1,"true"); |
| 7091 | break; |
| 7092 | } |
| 7093 | if (LocaleCompare("texture",option+1) == 0) |
| 7094 | { |
| 7095 | if (*option == '+') |
| 7096 | { |
| 7097 | if (image_info->texture != (char *) NULL) |
| 7098 | image_info->texture=DestroyString(image_info->texture); |
| 7099 | break; |
| 7100 | } |
| 7101 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7102 | break; |
| 7103 | } |
| 7104 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7105 | { |
| 7106 | if (*option == '+') |
| 7107 | { |
| 7108 | (void) SetImageOption(image_info,option+1,"0"); |
| 7109 | break; |
| 7110 | } |
| 7111 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7112 | break; |
| 7113 | } |
| 7114 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7115 | { |
| 7116 | if (*option == '+') |
| 7117 | { |
| 7118 | (void) QueryColorDatabase("none",&image_info->transparent_color, exception); |
| 7119 | (void) SetImageOption(image_info,option+1,"none"); |
| 7120 | break; |
| 7121 | } |
| 7122 | (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color, |
| 7123 | exception); |
| 7124 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7125 | break; |
| 7126 | } |
| 7127 | if (LocaleCompare("type",option+1) == 0) |
| 7128 | { |
| 7129 | if (*option == '+') |
| 7130 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7131 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7132 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7133 | break; |
| 7134 | } |
| 7135 | image_info->type=(ImageType) ParseMagickOption(MagickTypeOptions, |
| 7136 | MagickFalse,argv[i+1]); |
| 7137 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7138 | break; |
| 7139 | } |
| 7140 | break; |
| 7141 | } |
| 7142 | case 'u': |
| 7143 | { |
| 7144 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7145 | { |
| 7146 | if (*option == '+') |
| 7147 | { |
| 7148 | (void) DeleteImageOption(image_info,option+1); |
| 7149 | break; |
| 7150 | } |
| 7151 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7152 | break; |
| 7153 | } |
| 7154 | if (LocaleCompare("units",option+1) == 0) |
| 7155 | { |
| 7156 | if (*option == '+') |
| 7157 | { |
| 7158 | image_info->units=UndefinedResolution; |
| 7159 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7160 | break; |
| 7161 | } |
| 7162 | image_info->units=(ResolutionType) ParseMagickOption( |
| 7163 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7164 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7165 | break; |
| 7166 | } |
| 7167 | break; |
| 7168 | } |
| 7169 | case 'v': |
| 7170 | { |
| 7171 | if (LocaleCompare("verbose",option+1) == 0) |
| 7172 | { |
| 7173 | if (*option == '+') |
| 7174 | { |
| 7175 | image_info->verbose=MagickFalse; |
| 7176 | break; |
| 7177 | } |
| 7178 | image_info->verbose=MagickTrue; |
| 7179 | image_info->ping=MagickFalse; |
| 7180 | break; |
| 7181 | } |
| 7182 | if (LocaleCompare("view",option+1) == 0) |
| 7183 | { |
| 7184 | if (*option == '+') |
| 7185 | { |
| 7186 | if (image_info->view != (char *) NULL) |
| 7187 | image_info->view=DestroyString(image_info->view); |
| 7188 | break; |
| 7189 | } |
| 7190 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7191 | break; |
| 7192 | } |
| 7193 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7194 | { |
| 7195 | if (*option == '+') |
| 7196 | { |
| 7197 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7198 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7199 | break; |
| 7200 | } |
| 7201 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
| 7202 | ParseMagickOption(MagickVirtualPixelOptions,MagickFalse, |
| 7203 | argv[i+1]); |
| 7204 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7205 | break; |
| 7206 | } |
| 7207 | break; |
| 7208 | } |
| 7209 | case 'w': |
| 7210 | { |
| 7211 | if (LocaleCompare("white-point",option+1) == 0) |
| 7212 | { |
| 7213 | if (*option == '+') |
| 7214 | { |
| 7215 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7216 | break; |
| 7217 | } |
| 7218 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7219 | break; |
| 7220 | } |
| 7221 | break; |
| 7222 | } |
| 7223 | default: |
| 7224 | break; |
| 7225 | } |
| 7226 | i+=count; |
| 7227 | } |
| 7228 | return(MagickTrue); |
| 7229 | } |
| 7230 | |
| 7231 | /* |
| 7232 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7233 | % % |
| 7234 | % % |
| 7235 | % % |
| 7236 | + M o g r i f y I m a g e L i s t % |
| 7237 | % % |
| 7238 | % % |
| 7239 | % % |
| 7240 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7241 | % |
| 7242 | % MogrifyImageList() applies any command line options that might affect the |
| 7243 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7244 | % |
| 7245 | % The format of the MogrifyImage method is: |
| 7246 | % |
| 7247 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7248 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7249 | % |
| 7250 | % A description of each parameter follows: |
| 7251 | % |
| 7252 | % o image_info: the image info.. |
| 7253 | % |
| 7254 | % o argc: Specifies a pointer to an integer describing the number of |
| 7255 | % elements in the argument vector. |
| 7256 | % |
| 7257 | % o argv: Specifies a pointer to a text array containing the command line |
| 7258 | % arguments. |
| 7259 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7260 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7261 | % |
| 7262 | % o exception: return any errors or warnings in this structure. |
| 7263 | % |
| 7264 | */ |
| 7265 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7266 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7267 | { |
| 7268 | ChannelType |
| 7269 | channel; |
| 7270 | |
| 7271 | const char |
| 7272 | *option; |
| 7273 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7274 | ImageInfo |
| 7275 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7276 | |
| 7277 | MagickStatusType |
| 7278 | status; |
| 7279 | |
| 7280 | QuantizeInfo |
| 7281 | *quantize_info; |
| 7282 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7283 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7284 | i; |
| 7285 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7286 | ssize_t |
| 7287 | count, |
| 7288 | index; |
| 7289 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7290 | /* |
| 7291 | Apply options to the image list. |
| 7292 | */ |
| 7293 | assert(image_info != (ImageInfo *) NULL); |
| 7294 | assert(image_info->signature == MagickSignature); |
| 7295 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7296 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7297 | assert((*images)->signature == MagickSignature); |
| 7298 | if ((*images)->debug != MagickFalse) |
| 7299 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7300 | (*images)->filename); |
| 7301 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7302 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7303 | mogrify_info=CloneImageInfo(image_info); |
| 7304 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 7305 | channel=mogrify_info->channel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7306 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7307 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7308 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7309 | if (*images == (Image *) NULL) |
| 7310 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7311 | option=argv[i]; |
| 7312 | if (IsMagickOption(option) == MagickFalse) |
| 7313 | continue; |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame^] | 7314 | count=ParseMagickOption(MagickCommandOptions,MagickFalse,option); |
| 7315 | count=MagickMax(count,0L); |
| 7316 | count&=NumArgsOption; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7317 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7318 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7319 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7320 | switch (*(option+1)) |
| 7321 | { |
| 7322 | case 'a': |
| 7323 | { |
| 7324 | if (LocaleCompare("affinity",option+1) == 0) |
| 7325 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7326 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7327 | if (*option == '+') |
| 7328 | { |
| 7329 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7330 | InheritException(exception,&(*images)->exception); |
| 7331 | break; |
| 7332 | } |
| 7333 | i++; |
| 7334 | break; |
| 7335 | } |
| 7336 | if (LocaleCompare("append",option+1) == 0) |
| 7337 | { |
| 7338 | Image |
| 7339 | *append_image; |
| 7340 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7341 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7342 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7343 | MagickFalse,exception); |
| 7344 | if (append_image == (Image *) NULL) |
| 7345 | { |
| 7346 | status=MagickFalse; |
| 7347 | break; |
| 7348 | } |
| 7349 | *images=DestroyImageList(*images); |
| 7350 | *images=append_image; |
| 7351 | break; |
| 7352 | } |
| 7353 | if (LocaleCompare("average",option+1) == 0) |
| 7354 | { |
| 7355 | Image |
| 7356 | *average_image; |
| 7357 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7358 | /* |
| 7359 | Average an image sequence (deprecated). |
| 7360 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7361 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7362 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7363 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7364 | if (average_image == (Image *) NULL) |
| 7365 | { |
| 7366 | status=MagickFalse; |
| 7367 | break; |
| 7368 | } |
| 7369 | *images=DestroyImageList(*images); |
| 7370 | *images=average_image; |
| 7371 | break; |
| 7372 | } |
| 7373 | break; |
| 7374 | } |
| 7375 | case 'c': |
| 7376 | { |
| 7377 | if (LocaleCompare("channel",option+1) == 0) |
| 7378 | { |
| 7379 | if (*option == '+') |
| 7380 | { |
| 7381 | channel=DefaultChannels; |
| 7382 | break; |
| 7383 | } |
| 7384 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 7385 | break; |
| 7386 | } |
| 7387 | if (LocaleCompare("clut",option+1) == 0) |
| 7388 | { |
| 7389 | Image |
| 7390 | *clut_image, |
| 7391 | *image; |
| 7392 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7393 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7394 | image=RemoveFirstImageFromList(images); |
| 7395 | clut_image=RemoveFirstImageFromList(images); |
| 7396 | if (clut_image == (Image *) NULL) |
| 7397 | { |
| 7398 | status=MagickFalse; |
| 7399 | break; |
| 7400 | } |
| 7401 | (void) ClutImageChannel(image,channel,clut_image); |
| 7402 | clut_image=DestroyImage(clut_image); |
| 7403 | InheritException(exception,&image->exception); |
| 7404 | *images=DestroyImageList(*images); |
| 7405 | *images=image; |
| 7406 | break; |
| 7407 | } |
| 7408 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7409 | { |
| 7410 | Image |
| 7411 | *coalesce_image; |
| 7412 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7413 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7414 | coalesce_image=CoalesceImages(*images,exception); |
| 7415 | if (coalesce_image == (Image *) NULL) |
| 7416 | { |
| 7417 | status=MagickFalse; |
| 7418 | break; |
| 7419 | } |
| 7420 | *images=DestroyImageList(*images); |
| 7421 | *images=coalesce_image; |
| 7422 | break; |
| 7423 | } |
| 7424 | if (LocaleCompare("combine",option+1) == 0) |
| 7425 | { |
| 7426 | Image |
| 7427 | *combine_image; |
| 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 | combine_image=CombineImages(*images,channel,exception); |
| 7431 | if (combine_image == (Image *) NULL) |
| 7432 | { |
| 7433 | status=MagickFalse; |
| 7434 | break; |
| 7435 | } |
| 7436 | *images=DestroyImageList(*images); |
| 7437 | *images=combine_image; |
| 7438 | break; |
| 7439 | } |
| 7440 | if (LocaleCompare("composite",option+1) == 0) |
| 7441 | { |
| 7442 | Image |
| 7443 | *mask_image, |
| 7444 | *composite_image, |
| 7445 | *image; |
| 7446 | |
| 7447 | RectangleInfo |
| 7448 | geometry; |
| 7449 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7450 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7451 | image=RemoveFirstImageFromList(images); |
| 7452 | composite_image=RemoveFirstImageFromList(images); |
| 7453 | if (composite_image == (Image *) NULL) |
| 7454 | { |
| 7455 | status=MagickFalse; |
| 7456 | break; |
| 7457 | } |
| 7458 | (void) TransformImage(&composite_image,(char *) NULL, |
| 7459 | composite_image->geometry); |
| 7460 | SetGeometry(composite_image,&geometry); |
| 7461 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7462 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7463 | &geometry); |
| 7464 | mask_image=RemoveFirstImageFromList(images); |
| 7465 | if (mask_image != (Image *) NULL) |
| 7466 | { |
| 7467 | if ((image->compose == DisplaceCompositeOp) || |
| 7468 | (image->compose == DistortCompositeOp)) |
| 7469 | { |
| 7470 | /* |
| 7471 | Merge Y displacement into X displacement image. |
| 7472 | */ |
| 7473 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
| 7474 | mask_image,0,0); |
| 7475 | mask_image=DestroyImage(mask_image); |
| 7476 | } |
| 7477 | else |
| 7478 | { |
| 7479 | /* |
| 7480 | Set a blending mask for the composition. |
| 7481 | */ |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7482 | /* POSIBLE ERROR; what if image->mask already set */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7483 | image->mask=mask_image; |
| 7484 | (void) NegateImage(image->mask,MagickFalse); |
| 7485 | } |
| 7486 | } |
| 7487 | (void) CompositeImageChannel(image,channel,image->compose, |
| 7488 | composite_image,geometry.x,geometry.y); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7489 | if (mask_image != (Image *) NULL) |
| 7490 | mask_image=image->mask=DestroyImage(image->mask); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7491 | composite_image=DestroyImage(composite_image); |
| 7492 | InheritException(exception,&image->exception); |
| 7493 | *images=DestroyImageList(*images); |
| 7494 | *images=image; |
| 7495 | break; |
| 7496 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7497 | #if 0 |
| 7498 | This has been merged completely into MogrifyImage() |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7499 | if (LocaleCompare("crop",option+1) == 0) |
| 7500 | { |
| 7501 | MagickStatusType |
| 7502 | flags; |
| 7503 | |
| 7504 | RectangleInfo |
| 7505 | geometry; |
| 7506 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7507 | /* |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7508 | Crop Image. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7509 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7510 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7511 | flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception); |
| 7512 | if (((geometry.width == 0) && (geometry.height == 0)) || |
| 7513 | ((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 7514 | break; |
| 7515 | (void) TransformImages(images,argv[i+1],(char *) NULL); |
| 7516 | InheritException(exception,&(*images)->exception); |
| 7517 | break; |
| 7518 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7519 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7520 | break; |
| 7521 | } |
| 7522 | case 'd': |
| 7523 | { |
| 7524 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7525 | { |
| 7526 | Image |
| 7527 | *deconstruct_image; |
| 7528 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7529 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7530 | deconstruct_image=DeconstructImages(*images,exception); |
| 7531 | if (deconstruct_image == (Image *) NULL) |
| 7532 | { |
| 7533 | status=MagickFalse; |
| 7534 | break; |
| 7535 | } |
| 7536 | *images=DestroyImageList(*images); |
| 7537 | *images=deconstruct_image; |
| 7538 | break; |
| 7539 | } |
| 7540 | if (LocaleCompare("delete",option+1) == 0) |
| 7541 | { |
| 7542 | if (*option == '+') |
| 7543 | DeleteImages(images,"-1",exception); |
| 7544 | else |
| 7545 | DeleteImages(images,argv[i+1],exception); |
| 7546 | break; |
| 7547 | } |
| 7548 | if (LocaleCompare("dither",option+1) == 0) |
| 7549 | { |
| 7550 | if (*option == '+') |
| 7551 | { |
| 7552 | quantize_info->dither=MagickFalse; |
| 7553 | break; |
| 7554 | } |
| 7555 | quantize_info->dither=MagickTrue; |
| 7556 | quantize_info->dither_method=(DitherMethod) ParseMagickOption( |
| 7557 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7558 | break; |
| 7559 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7560 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7561 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7562 | Image |
| 7563 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7564 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7565 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7566 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7567 | else |
| 7568 | { |
| 7569 | const char |
| 7570 | *p; |
| 7571 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7572 | size_t |
| 7573 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7574 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7575 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7576 | p=strchr(argv[i+1],','); |
| 7577 | if (p == (const char *) NULL) |
| 7578 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7579 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7580 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7581 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7582 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7583 | } |
| 7584 | AppendImageToList(images, duplicate_images); |
| 7585 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7586 | break; |
| 7587 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7588 | break; |
| 7589 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7590 | case 'e': |
| 7591 | { |
| 7592 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7593 | { |
| 7594 | Image |
| 7595 | *evaluate_image; |
| 7596 | |
| 7597 | MagickEvaluateOperator |
| 7598 | op; |
| 7599 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7600 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7601 | op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions, |
| 7602 | MagickFalse,argv[i+1]); |
| 7603 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7604 | if (evaluate_image == (Image *) NULL) |
| 7605 | { |
| 7606 | status=MagickFalse; |
| 7607 | break; |
| 7608 | } |
| 7609 | *images=DestroyImageList(*images); |
| 7610 | *images=evaluate_image; |
| 7611 | break; |
| 7612 | } |
| 7613 | break; |
| 7614 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7615 | case 'f': |
| 7616 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7617 | if (LocaleCompare("fft",option+1) == 0) |
| 7618 | { |
| 7619 | Image |
| 7620 | *fourier_image; |
| 7621 | |
| 7622 | /* |
| 7623 | Implements the discrete Fourier transform (DFT). |
| 7624 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7625 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7626 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7627 | MagickTrue : MagickFalse,exception); |
| 7628 | if (fourier_image == (Image *) NULL) |
| 7629 | break; |
| 7630 | *images=DestroyImage(*images); |
| 7631 | *images=fourier_image; |
| 7632 | break; |
| 7633 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7634 | if (LocaleCompare("flatten",option+1) == 0) |
| 7635 | { |
| 7636 | Image |
| 7637 | *flatten_image; |
| 7638 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7639 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7640 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7641 | if (flatten_image == (Image *) NULL) |
| 7642 | break; |
| 7643 | *images=DestroyImageList(*images); |
| 7644 | *images=flatten_image; |
| 7645 | break; |
| 7646 | } |
| 7647 | if (LocaleCompare("fx",option+1) == 0) |
| 7648 | { |
| 7649 | Image |
| 7650 | *fx_image; |
| 7651 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7652 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7653 | fx_image=FxImageChannel(*images,channel,argv[i+1],exception); |
| 7654 | if (fx_image == (Image *) NULL) |
| 7655 | { |
| 7656 | status=MagickFalse; |
| 7657 | break; |
| 7658 | } |
| 7659 | *images=DestroyImageList(*images); |
| 7660 | *images=fx_image; |
| 7661 | break; |
| 7662 | } |
| 7663 | break; |
| 7664 | } |
| 7665 | case 'h': |
| 7666 | { |
| 7667 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7668 | { |
| 7669 | Image |
| 7670 | *hald_image, |
| 7671 | *image; |
| 7672 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7673 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7674 | image=RemoveFirstImageFromList(images); |
| 7675 | hald_image=RemoveFirstImageFromList(images); |
| 7676 | if (hald_image == (Image *) NULL) |
| 7677 | { |
| 7678 | status=MagickFalse; |
| 7679 | break; |
| 7680 | } |
| 7681 | (void) HaldClutImageChannel(image,channel,hald_image); |
| 7682 | hald_image=DestroyImage(hald_image); |
| 7683 | InheritException(exception,&image->exception); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7684 | if (*images != (Image *) NULL) |
| 7685 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7686 | *images=image; |
| 7687 | break; |
| 7688 | } |
| 7689 | break; |
| 7690 | } |
| 7691 | case 'i': |
| 7692 | { |
| 7693 | if (LocaleCompare("ift",option+1) == 0) |
| 7694 | { |
| 7695 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7696 | *fourier_image, |
| 7697 | *magnitude_image, |
| 7698 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7699 | |
| 7700 | /* |
| 7701 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7702 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7703 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7704 | magnitude_image=RemoveFirstImageFromList(images); |
| 7705 | phase_image=RemoveFirstImageFromList(images); |
| 7706 | if (phase_image == (Image *) NULL) |
| 7707 | { |
| 7708 | status=MagickFalse; |
| 7709 | break; |
| 7710 | } |
| 7711 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7712 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7713 | if (fourier_image == (Image *) NULL) |
| 7714 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7715 | if (*images != (Image *) NULL) |
| 7716 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7717 | *images=fourier_image; |
| 7718 | break; |
| 7719 | } |
| 7720 | if (LocaleCompare("insert",option+1) == 0) |
| 7721 | { |
| 7722 | Image |
| 7723 | *p, |
| 7724 | *q; |
| 7725 | |
| 7726 | index=0; |
| 7727 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7728 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7729 | p=RemoveLastImageFromList(images); |
| 7730 | if (p == (Image *) NULL) |
| 7731 | { |
| 7732 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7733 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7734 | status=MagickFalse; |
| 7735 | break; |
| 7736 | } |
| 7737 | q=p; |
| 7738 | if (index == 0) |
| 7739 | PrependImageToList(images,q); |
| 7740 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7741 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7742 | AppendImageToList(images,q); |
| 7743 | else |
| 7744 | { |
| 7745 | q=GetImageFromList(*images,index-1); |
| 7746 | if (q == (Image *) NULL) |
| 7747 | { |
| 7748 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7749 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7750 | status=MagickFalse; |
| 7751 | break; |
| 7752 | } |
| 7753 | InsertImageInList(&q,p); |
| 7754 | } |
| 7755 | *images=GetFirstImageInList(q); |
| 7756 | break; |
| 7757 | } |
| 7758 | break; |
| 7759 | } |
| 7760 | case 'l': |
| 7761 | { |
| 7762 | if (LocaleCompare("layers",option+1) == 0) |
| 7763 | { |
| 7764 | Image |
| 7765 | *layers; |
| 7766 | |
| 7767 | ImageLayerMethod |
| 7768 | method; |
| 7769 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7770 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7771 | layers=(Image *) NULL; |
| 7772 | method=(ImageLayerMethod) ParseMagickOption(MagickLayerOptions, |
| 7773 | MagickFalse,argv[i+1]); |
| 7774 | switch (method) |
| 7775 | { |
| 7776 | case CoalesceLayer: |
| 7777 | { |
| 7778 | layers=CoalesceImages(*images,exception); |
| 7779 | break; |
| 7780 | } |
| 7781 | case CompareAnyLayer: |
| 7782 | case CompareClearLayer: |
| 7783 | case CompareOverlayLayer: |
| 7784 | default: |
| 7785 | { |
| 7786 | layers=CompareImageLayers(*images,method,exception); |
| 7787 | break; |
| 7788 | } |
| 7789 | case MergeLayer: |
| 7790 | case FlattenLayer: |
| 7791 | case MosaicLayer: |
| 7792 | case TrimBoundsLayer: |
| 7793 | { |
| 7794 | layers=MergeImageLayers(*images,method,exception); |
| 7795 | break; |
| 7796 | } |
| 7797 | case DisposeLayer: |
| 7798 | { |
| 7799 | layers=DisposeImages(*images,exception); |
| 7800 | break; |
| 7801 | } |
| 7802 | case OptimizeImageLayer: |
| 7803 | { |
| 7804 | layers=OptimizeImageLayers(*images,exception); |
| 7805 | break; |
| 7806 | } |
| 7807 | case OptimizePlusLayer: |
| 7808 | { |
| 7809 | layers=OptimizePlusImageLayers(*images,exception); |
| 7810 | break; |
| 7811 | } |
| 7812 | case OptimizeTransLayer: |
| 7813 | { |
| 7814 | OptimizeImageTransparency(*images,exception); |
| 7815 | break; |
| 7816 | } |
| 7817 | case RemoveDupsLayer: |
| 7818 | { |
| 7819 | RemoveDuplicateLayers(images,exception); |
| 7820 | break; |
| 7821 | } |
| 7822 | case RemoveZeroLayer: |
| 7823 | { |
| 7824 | RemoveZeroDelayLayers(images,exception); |
| 7825 | break; |
| 7826 | } |
| 7827 | case OptimizeLayer: |
| 7828 | { |
| 7829 | /* |
| 7830 | General Purpose, GIF Animation Optimizer. |
| 7831 | */ |
| 7832 | layers=CoalesceImages(*images,exception); |
| 7833 | if (layers == (Image *) NULL) |
| 7834 | { |
| 7835 | status=MagickFalse; |
| 7836 | break; |
| 7837 | } |
| 7838 | InheritException(exception,&layers->exception); |
| 7839 | *images=DestroyImageList(*images); |
| 7840 | *images=layers; |
| 7841 | layers=OptimizeImageLayers(*images,exception); |
| 7842 | if (layers == (Image *) NULL) |
| 7843 | { |
| 7844 | status=MagickFalse; |
| 7845 | break; |
| 7846 | } |
| 7847 | InheritException(exception,&layers->exception); |
| 7848 | *images=DestroyImageList(*images); |
| 7849 | *images=layers; |
| 7850 | layers=(Image *) NULL; |
| 7851 | OptimizeImageTransparency(*images,exception); |
| 7852 | InheritException(exception,&(*images)->exception); |
| 7853 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7854 | break; |
| 7855 | } |
| 7856 | case CompositeLayer: |
| 7857 | { |
| 7858 | CompositeOperator |
| 7859 | compose; |
| 7860 | |
| 7861 | Image |
| 7862 | *source; |
| 7863 | |
| 7864 | RectangleInfo |
| 7865 | geometry; |
| 7866 | |
| 7867 | /* |
| 7868 | Split image sequence at the first 'NULL:' image. |
| 7869 | */ |
| 7870 | source=(*images); |
| 7871 | while (source != (Image *) NULL) |
| 7872 | { |
| 7873 | source=GetNextImageInList(source); |
| 7874 | if ((source != (Image *) NULL) && |
| 7875 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7876 | break; |
| 7877 | } |
| 7878 | if (source != (Image *) NULL) |
| 7879 | { |
| 7880 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7881 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7882 | source=(Image *) NULL; |
| 7883 | else |
| 7884 | { |
| 7885 | /* |
| 7886 | Separate the two lists, junk the null: image. |
| 7887 | */ |
| 7888 | source=SplitImageList(source->previous); |
| 7889 | DeleteImageFromList(&source); |
| 7890 | } |
| 7891 | } |
| 7892 | if (source == (Image *) NULL) |
| 7893 | { |
| 7894 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7895 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7896 | status=MagickFalse; |
| 7897 | break; |
| 7898 | } |
| 7899 | /* |
| 7900 | Adjust offset with gravity and virtual canvas. |
| 7901 | */ |
| 7902 | SetGeometry(*images,&geometry); |
| 7903 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7904 | geometry.width=source->page.width != 0 ? |
| 7905 | source->page.width : source->columns; |
| 7906 | geometry.height=source->page.height != 0 ? |
| 7907 | source->page.height : source->rows; |
| 7908 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7909 | (*images)->page.width : (*images)->columns, |
| 7910 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7911 | (*images)->rows,(*images)->gravity,&geometry); |
| 7912 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7913 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7914 | if (option != (const char *) NULL) |
| 7915 | compose=(CompositeOperator) ParseMagickOption( |
| 7916 | MagickComposeOptions,MagickFalse,option); |
| 7917 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7918 | exception); |
| 7919 | source=DestroyImageList(source); |
| 7920 | break; |
| 7921 | } |
| 7922 | } |
| 7923 | if (layers == (Image *) NULL) |
| 7924 | break; |
| 7925 | InheritException(exception,&layers->exception); |
| 7926 | *images=DestroyImageList(*images); |
| 7927 | *images=layers; |
| 7928 | break; |
| 7929 | } |
| 7930 | break; |
| 7931 | } |
| 7932 | case 'm': |
| 7933 | { |
| 7934 | if (LocaleCompare("map",option+1) == 0) |
| 7935 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7936 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7937 | if (*option == '+') |
| 7938 | { |
| 7939 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7940 | InheritException(exception,&(*images)->exception); |
| 7941 | break; |
| 7942 | } |
| 7943 | i++; |
| 7944 | break; |
| 7945 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7946 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7947 | { |
| 7948 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7949 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7950 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7951 | /* |
| 7952 | Maximum image sequence (deprecated). |
| 7953 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7954 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7955 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7956 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7957 | { |
| 7958 | status=MagickFalse; |
| 7959 | break; |
| 7960 | } |
| 7961 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7962 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7963 | break; |
| 7964 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7965 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7966 | { |
| 7967 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7968 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7969 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7970 | /* |
| 7971 | Minimum image sequence (deprecated). |
| 7972 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7973 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7974 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7975 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7976 | { |
| 7977 | status=MagickFalse; |
| 7978 | break; |
| 7979 | } |
| 7980 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7981 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7982 | break; |
| 7983 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7984 | if (LocaleCompare("morph",option+1) == 0) |
| 7985 | { |
| 7986 | Image |
| 7987 | *morph_image; |
| 7988 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7989 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7990 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7991 | exception); |
| 7992 | if (morph_image == (Image *) NULL) |
| 7993 | { |
| 7994 | status=MagickFalse; |
| 7995 | break; |
| 7996 | } |
| 7997 | *images=DestroyImageList(*images); |
| 7998 | *images=morph_image; |
| 7999 | break; |
| 8000 | } |
| 8001 | if (LocaleCompare("mosaic",option+1) == 0) |
| 8002 | { |
| 8003 | Image |
| 8004 | *mosaic_image; |
| 8005 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8006 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8007 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 8008 | if (mosaic_image == (Image *) NULL) |
| 8009 | { |
| 8010 | status=MagickFalse; |
| 8011 | break; |
| 8012 | } |
| 8013 | *images=DestroyImageList(*images); |
| 8014 | *images=mosaic_image; |
| 8015 | break; |
| 8016 | } |
| 8017 | break; |
| 8018 | } |
| 8019 | case 'p': |
| 8020 | { |
| 8021 | if (LocaleCompare("print",option+1) == 0) |
| 8022 | { |
| 8023 | char |
| 8024 | *string; |
| 8025 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8026 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8027 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8028 | if (string == (char *) NULL) |
| 8029 | break; |
| 8030 | InheritException(exception,&(*images)->exception); |
| 8031 | (void) fprintf(stdout,"%s",string); |
| 8032 | string=DestroyString(string); |
| 8033 | } |
| 8034 | if (LocaleCompare("process",option+1) == 0) |
| 8035 | { |
| 8036 | char |
| 8037 | **arguments; |
| 8038 | |
| 8039 | int |
| 8040 | j, |
| 8041 | number_arguments; |
| 8042 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8043 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8044 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 8045 | if (arguments == (char **) NULL) |
| 8046 | break; |
| 8047 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 8048 | { |
| 8049 | char |
| 8050 | breaker, |
| 8051 | quote, |
| 8052 | *token; |
| 8053 | |
| 8054 | const char |
| 8055 | *arguments; |
| 8056 | |
| 8057 | int |
| 8058 | next, |
| 8059 | status; |
| 8060 | |
| 8061 | size_t |
| 8062 | length; |
| 8063 | |
| 8064 | TokenInfo |
| 8065 | *token_info; |
| 8066 | |
| 8067 | /* |
| 8068 | Support old style syntax, filter="-option arg". |
| 8069 | */ |
| 8070 | length=strlen(argv[i+1]); |
| 8071 | token=(char *) NULL; |
| 8072 | if (~length >= MaxTextExtent) |
| 8073 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8074 | sizeof(*token)); |
| 8075 | if (token == (char *) NULL) |
| 8076 | break; |
| 8077 | next=0; |
| 8078 | arguments=argv[i+1]; |
| 8079 | token_info=AcquireTokenInfo(); |
| 8080 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8081 | "\"",'\0',&breaker,&next,"e); |
| 8082 | token_info=DestroyTokenInfo(token_info); |
| 8083 | if (status == 0) |
| 8084 | { |
| 8085 | const char |
| 8086 | *argv; |
| 8087 | |
| 8088 | argv=(&(arguments[next])); |
| 8089 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8090 | exception); |
| 8091 | } |
| 8092 | token=DestroyString(token); |
| 8093 | break; |
| 8094 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8095 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8096 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8097 | number_arguments-2,(const char **) arguments+2,exception); |
| 8098 | for (j=0; j < number_arguments; j++) |
| 8099 | arguments[j]=DestroyString(arguments[j]); |
| 8100 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8101 | break; |
| 8102 | } |
| 8103 | break; |
| 8104 | } |
| 8105 | case 'r': |
| 8106 | { |
| 8107 | if (LocaleCompare("reverse",option+1) == 0) |
| 8108 | { |
| 8109 | ReverseImageList(images); |
| 8110 | InheritException(exception,&(*images)->exception); |
| 8111 | break; |
| 8112 | } |
| 8113 | break; |
| 8114 | } |
| 8115 | case 's': |
| 8116 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8117 | if (LocaleCompare("smush",option+1) == 0) |
| 8118 | { |
| 8119 | Image |
| 8120 | *smush_image; |
| 8121 | |
| 8122 | ssize_t |
| 8123 | offset; |
| 8124 | |
| 8125 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8126 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8127 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8128 | MagickFalse,offset,exception); |
| 8129 | if (smush_image == (Image *) NULL) |
| 8130 | { |
| 8131 | status=MagickFalse; |
| 8132 | break; |
| 8133 | } |
| 8134 | *images=DestroyImageList(*images); |
| 8135 | *images=smush_image; |
| 8136 | break; |
| 8137 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8138 | if (LocaleCompare("swap",option+1) == 0) |
| 8139 | { |
| 8140 | Image |
| 8141 | *p, |
| 8142 | *q, |
| 8143 | *swap; |
| 8144 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8145 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8146 | swap_index; |
| 8147 | |
| 8148 | index=(-1); |
| 8149 | swap_index=(-2); |
| 8150 | if (*option != '+') |
| 8151 | { |
| 8152 | GeometryInfo |
| 8153 | geometry_info; |
| 8154 | |
| 8155 | MagickStatusType |
| 8156 | flags; |
| 8157 | |
| 8158 | swap_index=(-1); |
| 8159 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8160 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8161 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8162 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8163 | } |
| 8164 | p=GetImageFromList(*images,index); |
| 8165 | q=GetImageFromList(*images,swap_index); |
| 8166 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8167 | { |
| 8168 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8169 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8170 | status=MagickFalse; |
| 8171 | break; |
| 8172 | } |
| 8173 | if (p == q) |
| 8174 | break; |
| 8175 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8176 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8177 | ReplaceImageInList(&q,swap); |
| 8178 | *images=GetFirstImageInList(q); |
| 8179 | break; |
| 8180 | } |
| 8181 | break; |
| 8182 | } |
| 8183 | case 'w': |
| 8184 | { |
| 8185 | if (LocaleCompare("write",option+1) == 0) |
| 8186 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8187 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8188 | key[MaxTextExtent]; |
| 8189 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8190 | Image |
| 8191 | *write_images; |
| 8192 | |
| 8193 | ImageInfo |
| 8194 | *write_info; |
| 8195 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8196 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8197 | (void) FormatMagickString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
| 8198 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8199 | write_images=(*images); |
| 8200 | if (*option == '+') |
| 8201 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8202 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8203 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8204 | write_info=DestroyImageInfo(write_info); |
| 8205 | if (*option == '+') |
| 8206 | write_images=DestroyImageList(write_images); |
| 8207 | break; |
| 8208 | } |
| 8209 | break; |
| 8210 | } |
| 8211 | default: |
| 8212 | break; |
| 8213 | } |
| 8214 | i+=count; |
| 8215 | } |
| 8216 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8217 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8218 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8219 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8220 | } |
| 8221 | |
| 8222 | /* |
| 8223 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8224 | % % |
| 8225 | % % |
| 8226 | % % |
| 8227 | + M o g r i f y I m a g e s % |
| 8228 | % % |
| 8229 | % % |
| 8230 | % % |
| 8231 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8232 | % |
| 8233 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8234 | % prescribed by command line options. |
| 8235 | % |
| 8236 | % The format of the MogrifyImage method is: |
| 8237 | % |
| 8238 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8239 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8240 | % Image **images,Exceptioninfo *exception) |
| 8241 | % |
| 8242 | % A description of each parameter follows: |
| 8243 | % |
| 8244 | % o image_info: the image info.. |
| 8245 | % |
| 8246 | % o post: If true, post process image list operators otherwise pre-process. |
| 8247 | % |
| 8248 | % o argc: Specifies a pointer to an integer describing the number of |
| 8249 | % elements in the argument vector. |
| 8250 | % |
| 8251 | % o argv: Specifies a pointer to a text array containing the command line |
| 8252 | % arguments. |
| 8253 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8254 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8255 | % |
| 8256 | % o exception: return any errors or warnings in this structure. |
| 8257 | % |
| 8258 | */ |
| 8259 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8260 | const MagickBooleanType post,const int argc,const char **argv, |
| 8261 | Image **images,ExceptionInfo *exception) |
| 8262 | { |
| 8263 | #define MogrifyImageTag "Mogrify/Image" |
| 8264 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8265 | MagickStatusType |
| 8266 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8267 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8268 | MagickBooleanType |
| 8269 | proceed; |
| 8270 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8271 | size_t |
| 8272 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8273 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8274 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8275 | i; |
| 8276 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8277 | assert(image_info != (ImageInfo *) NULL); |
| 8278 | assert(image_info->signature == MagickSignature); |
| 8279 | if (images == (Image **) NULL) |
| 8280 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8281 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8282 | assert((*images)->signature == MagickSignature); |
| 8283 | if ((*images)->debug != MagickFalse) |
| 8284 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8285 | (*images)->filename); |
| 8286 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8287 | return(MagickTrue); |
| 8288 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8289 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8290 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8291 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame^] | 8292 | #if 0 |
| 8293 | fprintf(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,post?"post":"pre"); |
| 8294 | #endif |
| 8295 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8296 | /* |
| 8297 | Pre-process multi-image sequence operators |
| 8298 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8299 | if (post == MagickFalse) |
| 8300 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8301 | |
| 8302 | /* |
| 8303 | For each image, process simple single image operators |
| 8304 | */ |
| 8305 | i=0; |
| 8306 | n=GetImageListLength(*images); |
| 8307 | for (;;) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8308 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame^] | 8309 | #if 0 |
| 8310 | fprintf(stderr, "mogrify %ld of %ld\n", |
| 8311 | (long)GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
| 8312 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8313 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8314 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8315 | if (proceed == MagickFalse) |
| 8316 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8317 | if ( (*images)->next == (Image *) NULL ) |
| 8318 | break; |
| 8319 | *images=(*images)->next; |
| 8320 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8321 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8322 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame^] | 8323 | #if 0 |
| 8324 | fprintf(stderr, "mogrify end %ld of %ld\n", |
| 8325 | (long)GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
| 8326 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8327 | |
| 8328 | /* |
| 8329 | Post-process, multi-image sequence operators |
| 8330 | */ |
| 8331 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8332 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8333 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8334 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8335 | } |