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 | % |
| 248 | % MogrifyImage() applies image processing options to an image as prescribed |
| 249 | % by command line options. |
| 250 | % |
| 251 | % The format of the MogrifyImage method is: |
| 252 | % |
| 253 | % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 254 | % const char **argv,Image **image) |
| 255 | % |
| 256 | % A description of each parameter follows: |
| 257 | % |
| 258 | % o image_info: the image info.. |
| 259 | % |
| 260 | % o argc: Specifies a pointer to an integer describing the number of |
| 261 | % elements in the argument vector. |
| 262 | % |
| 263 | % o argv: Specifies a pointer to a text array containing the command line |
| 264 | % arguments. |
| 265 | % |
| 266 | % o image: the image. |
| 267 | % |
| 268 | % o exception: return any errors or warnings in this structure. |
| 269 | % |
| 270 | */ |
| 271 | |
| 272 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 273 | ExceptionInfo *exception) |
| 274 | { |
| 275 | char |
| 276 | key[MaxTextExtent]; |
| 277 | |
| 278 | ExceptionInfo |
| 279 | *sans_exception; |
| 280 | |
| 281 | Image |
| 282 | *image; |
| 283 | |
| 284 | ImageInfo |
| 285 | *read_info; |
| 286 | |
| 287 | (void) FormatMagickString(key,MaxTextExtent,"cache:%s",path); |
| 288 | sans_exception=AcquireExceptionInfo(); |
| 289 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 290 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 291 | if (image != (Image *) NULL) |
| 292 | return(image); |
| 293 | read_info=CloneImageInfo(image_info); |
| 294 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 295 | image=ReadImage(read_info,exception); |
| 296 | read_info=DestroyImageInfo(read_info); |
| 297 | if (image != (Image *) NULL) |
| 298 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 299 | return(image); |
| 300 | } |
| 301 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 302 | static MagickBooleanType IsPathWritable(const char *path) |
| 303 | { |
| 304 | if (IsPathAccessible(path) == MagickFalse) |
| 305 | return(MagickFalse); |
| 306 | if (access(path,W_OK) != 0) |
| 307 | return(MagickFalse); |
| 308 | return(MagickTrue); |
| 309 | } |
| 310 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 311 | static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 312 | { |
| 313 | if (x > y) |
| 314 | return(x); |
| 315 | return(y); |
| 316 | } |
| 317 | |
| 318 | static MagickBooleanType MonitorProgress(const char *text, |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 319 | const MagickOffsetType offset,const MagickSizeType extent, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 320 | void *wand_unused(client_data)) |
| 321 | { |
| 322 | char |
| 323 | message[MaxTextExtent], |
| 324 | tag[MaxTextExtent]; |
| 325 | |
| 326 | const char |
| 327 | *locale_message; |
| 328 | |
| 329 | register char |
| 330 | *p; |
| 331 | |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 332 | if (extent < 2) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 333 | return(MagickTrue); |
| 334 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 335 | p=strrchr(tag,'/'); |
| 336 | if (p != (char *) NULL) |
| 337 | *p='\0'; |
| 338 | (void) FormatMagickString(message,MaxTextExtent,"Monitor/%s",tag); |
| 339 | locale_message=GetLocaleMessage(message); |
| 340 | if (locale_message == message) |
| 341 | locale_message=tag; |
| 342 | if (p == (char *) NULL) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 343 | (void) fprintf(stderr,"%s: %ld of %lu, %02ld%% complete\r",locale_message, |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 344 | (long) offset,(unsigned long) extent,(long) (100L*offset/(extent-1))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 345 | else |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 346 | (void) fprintf(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 347 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 348 | (100L*offset/(extent-1))); |
| 349 | if (offset == (MagickOffsetType) (extent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 350 | (void) fprintf(stderr,"\n"); |
| 351 | (void) fflush(stderr); |
| 352 | return(MagickTrue); |
| 353 | } |
| 354 | |
| 355 | static Image *SparseColorOption(const Image *image,const ChannelType channel, |
| 356 | const SparseColorMethod method,const char *arguments, |
| 357 | const MagickBooleanType color_from_image,ExceptionInfo *exception) |
| 358 | { |
| 359 | ChannelType |
| 360 | channels; |
| 361 | |
| 362 | char |
| 363 | token[MaxTextExtent]; |
| 364 | |
| 365 | const char |
| 366 | *p; |
| 367 | |
| 368 | double |
| 369 | *sparse_arguments; |
| 370 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 371 | register size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 372 | x; |
| 373 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 374 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 375 | number_arguments; |
| 376 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 377 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 378 | number_colors; |
| 379 | |
| 380 | Image |
| 381 | *sparse_image; |
| 382 | |
| 383 | MagickPixelPacket |
| 384 | color; |
| 385 | |
| 386 | MagickBooleanType |
| 387 | error; |
| 388 | |
| 389 | assert(image != (Image *) NULL); |
| 390 | assert(image->signature == MagickSignature); |
| 391 | if (image->debug != MagickFalse) |
| 392 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 393 | assert(exception != (ExceptionInfo *) NULL); |
| 394 | assert(exception->signature == MagickSignature); |
| 395 | /* |
| 396 | Limit channels according to image - and add up number of color channel. |
| 397 | */ |
| 398 | channels=channel; |
| 399 | if (image->colorspace != CMYKColorspace) |
| 400 | channels=(ChannelType) (channels & ~IndexChannel); /* no index channel */ |
| 401 | if (image->matte == MagickFalse) |
| 402 | channels=(ChannelType) (channels & ~OpacityChannel); /* no alpha channel */ |
| 403 | number_colors=0; |
| 404 | if ((channels & RedChannel) != 0) |
| 405 | number_colors++; |
| 406 | if ((channels & GreenChannel) != 0) |
| 407 | number_colors++; |
| 408 | if ((channels & BlueChannel) != 0) |
| 409 | number_colors++; |
| 410 | if ((channels & IndexChannel) != 0) |
| 411 | number_colors++; |
| 412 | if ((channels & OpacityChannel) != 0) |
| 413 | number_colors++; |
| 414 | /* |
| 415 | Read string, to determine number of arguments needed, |
| 416 | */ |
| 417 | p=arguments; |
| 418 | x=0; |
| 419 | while( *p != '\0' ) |
| 420 | { |
| 421 | GetMagickToken(p,&p,token); |
| 422 | if ( token[0] == ',' ) continue; |
| 423 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 424 | if ( color_from_image ) { |
| 425 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 426 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 427 | "Color arg given, when colors are coming from image"); |
| 428 | return( (Image *)NULL); |
| 429 | } |
| 430 | x += number_colors; /* color argument */ |
| 431 | } |
| 432 | else { |
| 433 | x++; /* floating point argument */ |
| 434 | } |
| 435 | } |
| 436 | error=MagickTrue; |
| 437 | if ( color_from_image ) { |
| 438 | /* just the control points are being given */ |
| 439 | error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; |
| 440 | number_arguments=(x/2)*(2+number_colors); |
| 441 | } |
| 442 | else { |
| 443 | /* control points and color values */ |
| 444 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; |
| 445 | number_arguments=x; |
| 446 | } |
| 447 | if ( error ) { |
| 448 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 449 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 450 | "Invalid number of Arguments"); |
| 451 | return( (Image *)NULL); |
| 452 | } |
| 453 | |
| 454 | /* Allocate and fill in the floating point arguments */ |
| 455 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 456 | sizeof(*sparse_arguments)); |
| 457 | if (sparse_arguments == (double *) NULL) { |
| 458 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 459 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 460 | return( (Image *)NULL); |
| 461 | } |
| 462 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 463 | sizeof(*sparse_arguments)); |
| 464 | p=arguments; |
| 465 | x=0; |
| 466 | while( *p != '\0' && x < number_arguments ) { |
| 467 | /* X coordinate */ |
| 468 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 469 | if ( token[0] == '\0' ) break; |
| 470 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 471 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 472 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 473 | "Color found, instead of X-coord"); |
| 474 | error = MagickTrue; |
| 475 | break; |
| 476 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 477 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 478 | /* Y coordinate */ |
| 479 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 480 | if ( token[0] == '\0' ) break; |
| 481 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 482 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 483 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 484 | "Color found, instead of Y-coord"); |
| 485 | error = MagickTrue; |
| 486 | break; |
| 487 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 488 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 489 | /* color values for this control point */ |
| 490 | #if 0 |
| 491 | if ( (color_from_image ) { |
| 492 | /* get color from image */ |
| 493 | /* HOW??? */ |
| 494 | } |
| 495 | else |
| 496 | #endif |
| 497 | { |
| 498 | /* color name or function given in string argument */ |
| 499 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 500 | if ( token[0] == '\0' ) break; |
| 501 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 502 | /* Color string given */ |
| 503 | (void) QueryMagickColor(token,&color,exception); |
| 504 | if ( channels & RedChannel ) |
| 505 | sparse_arguments[x++] = QuantumScale*color.red; |
| 506 | if ( channels & GreenChannel ) |
| 507 | sparse_arguments[x++] = QuantumScale*color.green; |
| 508 | if ( channels & BlueChannel ) |
| 509 | sparse_arguments[x++] = QuantumScale*color.blue; |
| 510 | if ( channels & IndexChannel ) |
| 511 | sparse_arguments[x++] = QuantumScale*color.index; |
| 512 | if ( channels & OpacityChannel ) |
| 513 | sparse_arguments[x++] = QuantumScale*color.opacity; |
| 514 | } |
| 515 | else { |
| 516 | #if 0 |
| 517 | /* the color name/function/value was not found - error */ |
| 518 | break; |
| 519 | #else |
| 520 | /* Colors given as a set of floating point values - experimental */ |
| 521 | /* NB: token contains the first floating point value to use! */ |
| 522 | if ( channels & RedChannel ) { |
| 523 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 524 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 525 | break; |
cristy | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 526 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 527 | token[0] = ','; /* used this token - get another */ |
| 528 | } |
| 529 | if ( channels & GreenChannel ) { |
| 530 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 531 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 532 | break; |
cristy | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 533 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 534 | token[0] = ','; /* used this token - get another */ |
| 535 | } |
| 536 | if ( channels & BlueChannel ) { |
| 537 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 538 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 539 | break; |
cristy | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 540 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 541 | token[0] = ','; /* used this token - get another */ |
| 542 | } |
| 543 | if ( channels & IndexChannel ) { |
| 544 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 545 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 546 | break; |
cristy | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 547 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 548 | token[0] = ','; /* used this token - get another */ |
| 549 | } |
| 550 | if ( channels & OpacityChannel ) { |
| 551 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 552 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 553 | break; |
cristy | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 554 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 555 | token[0] = ','; /* used this token - get another */ |
| 556 | } |
| 557 | #endif |
| 558 | } |
| 559 | } |
| 560 | } |
| 561 | if ( number_arguments != x && !error ) { |
| 562 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
| 563 | "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error"); |
| 564 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 565 | return( (Image *)NULL); |
| 566 | } |
| 567 | if ( error ) |
| 568 | return( (Image *)NULL); |
| 569 | |
| 570 | /* Call the Interpolation function with the parsed arguments */ |
| 571 | sparse_image=SparseColorImage(image,channels,method,number_arguments, |
| 572 | sparse_arguments,exception); |
| 573 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 574 | return( sparse_image ); |
| 575 | } |
| 576 | |
| 577 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 578 | const char **argv,Image **image,ExceptionInfo *exception) |
| 579 | { |
| 580 | ChannelType |
| 581 | channel; |
| 582 | |
| 583 | const char |
| 584 | *format, |
| 585 | *option; |
| 586 | |
| 587 | DrawInfo |
| 588 | *draw_info; |
| 589 | |
| 590 | GeometryInfo |
| 591 | geometry_info; |
| 592 | |
| 593 | Image |
| 594 | *region_image; |
| 595 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 596 | ImageInfo |
| 597 | *mogrify_info; |
| 598 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 599 | MagickStatusType |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 600 | status; |
| 601 | |
| 602 | MagickPixelPacket |
| 603 | fill; |
| 604 | |
| 605 | MagickStatusType |
| 606 | flags; |
| 607 | |
| 608 | QuantizeInfo |
| 609 | *quantize_info; |
| 610 | |
| 611 | RectangleInfo |
| 612 | geometry, |
| 613 | region_geometry; |
| 614 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 615 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 616 | i; |
| 617 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 618 | ssize_t |
| 619 | count; |
| 620 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 621 | /* |
| 622 | Initialize method variables. |
| 623 | */ |
| 624 | assert(image_info != (const ImageInfo *) NULL); |
| 625 | assert(image_info->signature == MagickSignature); |
| 626 | assert(image != (Image **) NULL); |
| 627 | assert((*image)->signature == MagickSignature); |
| 628 | if ((*image)->debug != MagickFalse) |
| 629 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); |
| 630 | if (argc < 0) |
| 631 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 632 | mogrify_info=CloneImageInfo(image_info); |
| 633 | draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL); |
| 634 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 635 | SetGeometryInfo(&geometry_info); |
| 636 | GetMagickPixelPacket(*image,&fill); |
| 637 | SetMagickPixelPacket(*image,&(*image)->background_color,(IndexPacket *) NULL, |
| 638 | &fill); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 639 | channel=mogrify_info->channel; |
| 640 | format=GetImageOption(mogrify_info,"format"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 641 | SetGeometry(*image,®ion_geometry); |
| 642 | region_image=NewImageList(); |
| 643 | /* |
| 644 | Transmogrify the image. |
| 645 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 646 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 647 | { |
| 648 | option=argv[i]; |
| 649 | if (IsMagickOption(option) == MagickFalse) |
| 650 | continue; |
| 651 | count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option), |
| 652 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 653 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 654 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 655 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 656 | switch (*(option+1)) |
| 657 | { |
| 658 | case 'a': |
| 659 | { |
| 660 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 661 | { |
| 662 | Image |
| 663 | *blur_image; |
| 664 | |
| 665 | /* |
| 666 | Adaptive blur image. |
| 667 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 668 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 669 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 670 | if ((flags & SigmaValue) == 0) |
| 671 | geometry_info.sigma=1.0; |
| 672 | blur_image=AdaptiveBlurImageChannel(*image,channel, |
| 673 | geometry_info.rho,geometry_info.sigma,exception); |
| 674 | if (blur_image == (Image *) NULL) |
| 675 | break; |
| 676 | *image=DestroyImage(*image); |
| 677 | *image=blur_image; |
| 678 | break; |
| 679 | } |
| 680 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 681 | { |
| 682 | Image |
| 683 | *resize_image; |
| 684 | |
| 685 | /* |
| 686 | Adaptive resize image. |
| 687 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 688 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 689 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 690 | resize_image=AdaptiveResizeImage(*image,geometry.width, |
| 691 | geometry.height,exception); |
| 692 | if (resize_image == (Image *) NULL) |
| 693 | break; |
| 694 | *image=DestroyImage(*image); |
| 695 | *image=resize_image; |
| 696 | break; |
| 697 | } |
| 698 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 699 | { |
| 700 | Image |
| 701 | *sharp_image; |
| 702 | |
| 703 | /* |
| 704 | Adaptive sharpen image. |
| 705 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 706 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 707 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 708 | if ((flags & SigmaValue) == 0) |
| 709 | geometry_info.sigma=1.0; |
| 710 | sharp_image=AdaptiveSharpenImageChannel(*image,channel, |
| 711 | geometry_info.rho,geometry_info.sigma,exception); |
| 712 | if (sharp_image == (Image *) NULL) |
| 713 | break; |
| 714 | *image=DestroyImage(*image); |
| 715 | *image=sharp_image; |
| 716 | break; |
| 717 | } |
| 718 | if (LocaleCompare("affine",option+1) == 0) |
| 719 | { |
| 720 | /* |
| 721 | Affine matrix. |
| 722 | */ |
| 723 | if (*option == '+') |
| 724 | { |
| 725 | GetAffineMatrix(&draw_info->affine); |
| 726 | break; |
| 727 | } |
| 728 | (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); |
| 729 | break; |
| 730 | } |
| 731 | if (LocaleCompare("alpha",option+1) == 0) |
| 732 | { |
| 733 | AlphaChannelType |
| 734 | alpha_type; |
| 735 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 736 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 737 | alpha_type=(AlphaChannelType) ParseMagickOption(MagickAlphaOptions, |
| 738 | MagickFalse,argv[i+1]); |
| 739 | (void) SetImageAlphaChannel(*image,alpha_type); |
| 740 | InheritException(exception,&(*image)->exception); |
| 741 | break; |
| 742 | } |
| 743 | if (LocaleCompare("annotate",option+1) == 0) |
| 744 | { |
| 745 | char |
| 746 | *text, |
| 747 | geometry[MaxTextExtent]; |
| 748 | |
| 749 | /* |
| 750 | Annotate image. |
| 751 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 752 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 753 | SetGeometryInfo(&geometry_info); |
| 754 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 755 | if ((flags & SigmaValue) == 0) |
| 756 | geometry_info.sigma=geometry_info.rho; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 757 | text=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 758 | InheritException(exception,&(*image)->exception); |
| 759 | if (text == (char *) NULL) |
| 760 | break; |
| 761 | (void) CloneString(&draw_info->text,text); |
| 762 | text=DestroyString(text); |
| 763 | (void) FormatMagickString(geometry,MaxTextExtent,"%+f%+f", |
| 764 | geometry_info.xi,geometry_info.psi); |
| 765 | (void) CloneString(&draw_info->geometry,geometry); |
| 766 | draw_info->affine.sx=cos(DegreesToRadians( |
| 767 | fmod(geometry_info.rho,360.0))); |
| 768 | draw_info->affine.rx=sin(DegreesToRadians( |
| 769 | fmod(geometry_info.rho,360.0))); |
| 770 | draw_info->affine.ry=(-sin(DegreesToRadians( |
| 771 | fmod(geometry_info.sigma,360.0)))); |
| 772 | draw_info->affine.sy=cos(DegreesToRadians( |
| 773 | fmod(geometry_info.sigma,360.0))); |
| 774 | (void) AnnotateImage(*image,draw_info); |
| 775 | InheritException(exception,&(*image)->exception); |
| 776 | break; |
| 777 | } |
| 778 | if (LocaleCompare("antialias",option+1) == 0) |
| 779 | { |
| 780 | draw_info->stroke_antialias=(*option == '-') ? MagickTrue : |
| 781 | MagickFalse; |
| 782 | draw_info->text_antialias=(*option == '-') ? MagickTrue : |
| 783 | MagickFalse; |
| 784 | break; |
| 785 | } |
| 786 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 787 | { |
| 788 | /* |
| 789 | Auto Adjust Gamma of image based on its mean |
| 790 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 791 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 792 | (void) AutoGammaImageChannel(*image,channel); |
| 793 | break; |
| 794 | } |
| 795 | if (LocaleCompare("auto-level",option+1) == 0) |
| 796 | { |
| 797 | /* |
| 798 | Perfectly Normalize (max/min stretch) the image |
| 799 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 800 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 801 | (void) AutoLevelImageChannel(*image,channel); |
| 802 | break; |
| 803 | } |
| 804 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 805 | { |
| 806 | Image |
| 807 | *orient_image; |
| 808 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 809 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 810 | orient_image=NewImageList(); |
| 811 | switch ((*image)->orientation) |
| 812 | { |
| 813 | case TopRightOrientation: |
| 814 | { |
| 815 | orient_image=FlopImage(*image,exception); |
| 816 | break; |
| 817 | } |
| 818 | case BottomRightOrientation: |
| 819 | { |
| 820 | orient_image=RotateImage(*image,180.0,exception); |
| 821 | break; |
| 822 | } |
| 823 | case BottomLeftOrientation: |
| 824 | { |
| 825 | orient_image=FlipImage(*image,exception); |
| 826 | break; |
| 827 | } |
| 828 | case LeftTopOrientation: |
| 829 | { |
| 830 | orient_image=TransposeImage(*image,exception); |
| 831 | break; |
| 832 | } |
| 833 | case RightTopOrientation: |
| 834 | { |
| 835 | orient_image=RotateImage(*image,90.0,exception); |
| 836 | break; |
| 837 | } |
| 838 | case RightBottomOrientation: |
| 839 | { |
| 840 | orient_image=TransverseImage(*image,exception); |
| 841 | break; |
| 842 | } |
| 843 | case LeftBottomOrientation: |
| 844 | { |
| 845 | orient_image=RotateImage(*image,270.0,exception); |
| 846 | break; |
| 847 | } |
| 848 | default: |
| 849 | break; |
| 850 | } |
| 851 | if (orient_image == (Image *) NULL) |
| 852 | break; |
| 853 | orient_image->orientation=TopLeftOrientation; |
| 854 | *image=DestroyImage(*image); |
| 855 | *image=orient_image; |
| 856 | break; |
| 857 | } |
| 858 | break; |
| 859 | } |
| 860 | case 'b': |
| 861 | { |
| 862 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 863 | { |
| 864 | /* |
| 865 | Black threshold image. |
| 866 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 867 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 868 | (void) BlackThresholdImageChannel(*image,channel,argv[i+1], |
| 869 | exception); |
| 870 | InheritException(exception,&(*image)->exception); |
| 871 | break; |
| 872 | } |
| 873 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 874 | { |
| 875 | Image |
| 876 | *shift_image; |
| 877 | |
| 878 | /* |
| 879 | Blue shift image. |
| 880 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 881 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 882 | geometry_info.rho=1.5; |
| 883 | if (*option == '-') |
| 884 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 885 | shift_image=BlueShiftImage(*image,geometry_info.rho,exception); |
| 886 | if (shift_image == (Image *) NULL) |
| 887 | break; |
| 888 | *image=DestroyImage(*image); |
| 889 | *image=shift_image; |
| 890 | break; |
| 891 | } |
| 892 | if (LocaleCompare("blur",option+1) == 0) |
| 893 | { |
| 894 | Image |
| 895 | *blur_image; |
| 896 | |
| 897 | /* |
| 898 | Gaussian blur image. |
| 899 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 900 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 901 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 902 | if ((flags & SigmaValue) == 0) |
| 903 | geometry_info.sigma=1.0; |
| 904 | blur_image=BlurImageChannel(*image,channel,geometry_info.rho, |
| 905 | geometry_info.sigma,exception); |
| 906 | if (blur_image == (Image *) NULL) |
| 907 | break; |
| 908 | *image=DestroyImage(*image); |
| 909 | *image=blur_image; |
| 910 | break; |
| 911 | } |
| 912 | if (LocaleCompare("border",option+1) == 0) |
| 913 | { |
| 914 | Image |
| 915 | *border_image; |
| 916 | |
| 917 | /* |
| 918 | Surround image with a border of solid color. |
| 919 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 920 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 921 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 922 | if ((flags & SigmaValue) == 0) |
| 923 | geometry.height=geometry.width; |
| 924 | border_image=BorderImage(*image,&geometry,exception); |
| 925 | if (border_image == (Image *) NULL) |
| 926 | break; |
| 927 | *image=DestroyImage(*image); |
| 928 | *image=border_image; |
| 929 | break; |
| 930 | } |
| 931 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 932 | { |
| 933 | if (*option == '+') |
| 934 | { |
| 935 | (void) QueryColorDatabase(BorderColor,&draw_info->border_color, |
| 936 | exception); |
| 937 | break; |
| 938 | } |
| 939 | (void) QueryColorDatabase(argv[i+1],&draw_info->border_color, |
| 940 | exception); |
| 941 | break; |
| 942 | } |
| 943 | if (LocaleCompare("box",option+1) == 0) |
| 944 | { |
| 945 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 946 | exception); |
| 947 | break; |
| 948 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 949 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 950 | { |
| 951 | double |
| 952 | brightness, |
| 953 | contrast; |
| 954 | |
| 955 | GeometryInfo |
| 956 | geometry_info; |
| 957 | |
| 958 | MagickStatusType |
| 959 | flags; |
| 960 | |
| 961 | /* |
| 962 | Brightness / contrast image. |
| 963 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 964 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 965 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 966 | brightness=geometry_info.rho; |
cristy | 81fbc8b | 2010-01-11 20:04:07 +0000 | [diff] [blame] | 967 | contrast=0.0; |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 968 | if ((flags & SigmaValue) != 0) |
| 969 | contrast=geometry_info.sigma; |
cristy | 02cc0f2 | 2010-01-12 00:02:32 +0000 | [diff] [blame] | 970 | (void) BrightnessContrastImageChannel(*image,channel,brightness, |
| 971 | contrast); |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 972 | InheritException(exception,&(*image)->exception); |
| 973 | break; |
| 974 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 975 | break; |
| 976 | } |
| 977 | case 'c': |
| 978 | { |
| 979 | if (LocaleCompare("cdl",option+1) == 0) |
| 980 | { |
| 981 | char |
| 982 | *color_correction_collection; |
| 983 | |
| 984 | /* |
| 985 | Color correct with a color decision list. |
| 986 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 987 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 988 | color_correction_collection=FileToString(argv[i+1],~0,exception); |
| 989 | if (color_correction_collection == (char *) NULL) |
| 990 | break; |
| 991 | (void) ColorDecisionListImage(*image,color_correction_collection); |
| 992 | InheritException(exception,&(*image)->exception); |
| 993 | break; |
| 994 | } |
| 995 | if (LocaleCompare("channel",option+1) == 0) |
| 996 | { |
| 997 | if (*option == '+') |
| 998 | { |
| 999 | channel=DefaultChannels; |
| 1000 | break; |
| 1001 | } |
| 1002 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 1003 | break; |
| 1004 | } |
| 1005 | if (LocaleCompare("charcoal",option+1) == 0) |
| 1006 | { |
| 1007 | Image |
| 1008 | *charcoal_image; |
| 1009 | |
| 1010 | /* |
| 1011 | Charcoal image. |
| 1012 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1013 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1014 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1015 | if ((flags & SigmaValue) == 0) |
| 1016 | geometry_info.sigma=1.0; |
| 1017 | charcoal_image=CharcoalImage(*image,geometry_info.rho, |
| 1018 | geometry_info.sigma,exception); |
| 1019 | if (charcoal_image == (Image *) NULL) |
| 1020 | break; |
| 1021 | *image=DestroyImage(*image); |
| 1022 | *image=charcoal_image; |
| 1023 | break; |
| 1024 | } |
| 1025 | if (LocaleCompare("chop",option+1) == 0) |
| 1026 | { |
| 1027 | Image |
| 1028 | *chop_image; |
| 1029 | |
| 1030 | /* |
| 1031 | Chop the image. |
| 1032 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1033 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1034 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1035 | chop_image=ChopImage(*image,&geometry,exception); |
| 1036 | if (chop_image == (Image *) NULL) |
| 1037 | break; |
| 1038 | *image=DestroyImage(*image); |
| 1039 | *image=chop_image; |
| 1040 | break; |
| 1041 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 1042 | if (LocaleCompare("clamp",option+1) == 0) |
| 1043 | { |
| 1044 | /* |
| 1045 | Clamp image. |
| 1046 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1047 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 1048 | (void) ClampImageChannel(*image,channel); |
| 1049 | InheritException(exception,&(*image)->exception); |
| 1050 | break; |
| 1051 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1052 | if (LocaleCompare("clip",option+1) == 0) |
| 1053 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1054 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1055 | if (*option == '+') |
| 1056 | { |
| 1057 | (void) SetImageClipMask(*image,(Image *) NULL); |
| 1058 | InheritException(exception,&(*image)->exception); |
| 1059 | break; |
| 1060 | } |
| 1061 | (void) ClipImage(*image); |
| 1062 | InheritException(exception,&(*image)->exception); |
| 1063 | break; |
| 1064 | } |
| 1065 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1066 | { |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1067 | CacheView |
| 1068 | *mask_view; |
cristy | a01cbea | 2010-11-03 16:33:33 +0000 | [diff] [blame] | 1069 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1070 | Image |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1071 | *mask_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1072 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1073 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1074 | y; |
| 1075 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1076 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1077 | x; |
| 1078 | |
| 1079 | register PixelPacket |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 1080 | *restrict q; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1081 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1082 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1083 | if (*option == '+') |
| 1084 | { |
| 1085 | /* |
| 1086 | Remove a mask. |
| 1087 | */ |
| 1088 | (void) SetImageMask(*image,(Image *) NULL); |
| 1089 | InheritException(exception,&(*image)->exception); |
| 1090 | break; |
| 1091 | } |
| 1092 | /* |
| 1093 | Set the image mask. |
| 1094 | */ |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1095 | mask_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1096 | if (mask_image == (Image *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1097 | break; |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1098 | if (SetImageStorageClass(mask_image,DirectClass) == MagickFalse) |
| 1099 | return(MagickFalse); |
| 1100 | mask_view=AcquireCacheView(mask_image); |
| 1101 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1102 | { |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1103 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1104 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1105 | if (q == (PixelPacket *) NULL) |
| 1106 | break; |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1107 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1108 | { |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1109 | if (mask_image->matte == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1110 | q->opacity=PixelIntensityToQuantum(q); |
| 1111 | q->red=q->opacity; |
| 1112 | q->green=q->opacity; |
| 1113 | q->blue=q->opacity; |
| 1114 | q++; |
| 1115 | } |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1116 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1117 | break; |
| 1118 | } |
cristy | b0d3bb9 | 2010-09-22 14:37:58 +0000 | [diff] [blame] | 1119 | mask_view=DestroyCacheView(mask_view); |
| 1120 | mask_image->matte=MagickTrue; |
| 1121 | (void) SetImageClipMask(*image,mask_image); |
| 1122 | mask_image=DestroyImage(mask_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1123 | InheritException(exception,&(*image)->exception); |
| 1124 | break; |
| 1125 | } |
| 1126 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1127 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1128 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1129 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
| 1130 | MagickFalse); |
| 1131 | InheritException(exception,&(*image)->exception); |
| 1132 | break; |
| 1133 | } |
| 1134 | if (LocaleCompare("colorize",option+1) == 0) |
| 1135 | { |
| 1136 | Image |
| 1137 | *colorize_image; |
| 1138 | |
| 1139 | /* |
| 1140 | Colorize the image. |
| 1141 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1142 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1143 | colorize_image=ColorizeImage(*image,argv[i+1],draw_info->fill, |
| 1144 | exception); |
| 1145 | if (colorize_image == (Image *) NULL) |
| 1146 | break; |
| 1147 | *image=DestroyImage(*image); |
| 1148 | *image=colorize_image; |
| 1149 | break; |
| 1150 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 1151 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1152 | { |
| 1153 | Image |
| 1154 | *color_image; |
| 1155 | |
| 1156 | KernelInfo |
| 1157 | *kernel; |
| 1158 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1159 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 1160 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1161 | if (kernel == (KernelInfo *) NULL) |
| 1162 | break; |
| 1163 | color_image=ColorMatrixImage(*image,kernel,exception); |
| 1164 | kernel=DestroyKernelInfo(kernel); |
| 1165 | if (color_image == (Image *) NULL) |
| 1166 | break; |
| 1167 | *image=DestroyImage(*image); |
| 1168 | *image=color_image; |
| 1169 | break; |
| 1170 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1171 | if (LocaleCompare("colors",option+1) == 0) |
| 1172 | { |
| 1173 | /* |
| 1174 | Reduce the number of colors in the image. |
| 1175 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1176 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 1177 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1178 | if (quantize_info->number_colors == 0) |
| 1179 | break; |
| 1180 | if (((*image)->storage_class == DirectClass) || |
| 1181 | (*image)->colors > quantize_info->number_colors) |
| 1182 | (void) QuantizeImage(quantize_info,*image); |
| 1183 | else |
| 1184 | (void) CompressImageColormap(*image); |
| 1185 | InheritException(exception,&(*image)->exception); |
| 1186 | break; |
| 1187 | } |
| 1188 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1189 | { |
| 1190 | ColorspaceType |
| 1191 | colorspace; |
| 1192 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1193 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1194 | if (*option == '+') |
| 1195 | { |
| 1196 | (void) TransformImageColorspace(*image,RGBColorspace); |
| 1197 | InheritException(exception,&(*image)->exception); |
| 1198 | break; |
| 1199 | } |
| 1200 | colorspace=(ColorspaceType) ParseMagickOption( |
| 1201 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 1202 | (void) TransformImageColorspace(*image,colorspace); |
| 1203 | InheritException(exception,&(*image)->exception); |
| 1204 | break; |
| 1205 | } |
cristy | df81b99 | 2011-02-27 14:33:24 +0000 | [diff] [blame] | 1206 | if (LocaleCompare("comment",option+1) == 0) |
| 1207 | { |
| 1208 | if (*option == '+') |
| 1209 | { |
cristy | 3fb6d77 | 2011-02-27 15:13:43 +0000 | [diff] [blame] | 1210 | (void) DeleteImageProperty(*image,option+1); |
cristy | df81b99 | 2011-02-27 14:33:24 +0000 | [diff] [blame] | 1211 | break; |
| 1212 | } |
cristy | 3fb6d77 | 2011-02-27 15:13:43 +0000 | [diff] [blame] | 1213 | (void) SetImageProperty(*image,option+1,argv[i+1]); |
cristy | df81b99 | 2011-02-27 14:33:24 +0000 | [diff] [blame] | 1214 | break; |
| 1215 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1216 | if (LocaleCompare("contrast",option+1) == 0) |
| 1217 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1218 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1219 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
| 1220 | MagickFalse); |
| 1221 | InheritException(exception,&(*image)->exception); |
| 1222 | break; |
| 1223 | } |
| 1224 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1225 | { |
| 1226 | double |
| 1227 | black_point, |
| 1228 | white_point; |
| 1229 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1230 | MagickStatusType |
| 1231 | flags; |
| 1232 | |
| 1233 | /* |
| 1234 | Contrast stretch image. |
| 1235 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1236 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1237 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1238 | black_point=geometry_info.rho; |
| 1239 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1240 | black_point; |
| 1241 | if ((flags & PercentValue) != 0) |
| 1242 | { |
| 1243 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1244 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1245 | } |
| 1246 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1247 | white_point; |
| 1248 | (void) ContrastStretchImageChannel(*image,channel,black_point, |
| 1249 | white_point); |
| 1250 | InheritException(exception,&(*image)->exception); |
| 1251 | break; |
| 1252 | } |
| 1253 | if (LocaleCompare("convolve",option+1) == 0) |
| 1254 | { |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1255 | double |
| 1256 | gamma; |
| 1257 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1258 | Image |
| 1259 | *convolve_image; |
| 1260 | |
cristy | 2be1538 | 2010-01-21 02:38:03 +0000 | [diff] [blame] | 1261 | KernelInfo |
cristy | 56a9e51 | 2010-01-06 18:18:55 +0000 | [diff] [blame] | 1262 | *kernel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1263 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1264 | register ssize_t |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1265 | j; |
| 1266 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1267 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 2be1538 | 2010-01-21 02:38:03 +0000 | [diff] [blame] | 1268 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1269 | if (kernel == (KernelInfo *) NULL) |
cristy | 56a9e51 | 2010-01-06 18:18:55 +0000 | [diff] [blame] | 1270 | break; |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1271 | gamma=0.0; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1272 | for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++) |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1273 | gamma+=kernel->values[j]; |
| 1274 | gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1275 | for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++) |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1276 | kernel->values[j]*=gamma; |
cristy | 6771f1e | 2010-03-05 19:43:39 +0000 | [diff] [blame] | 1277 | convolve_image=FilterImageChannel(*image,channel,kernel,exception); |
anthony | 83ba99b | 2010-01-24 08:48:15 +0000 | [diff] [blame] | 1278 | kernel=DestroyKernelInfo(kernel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1279 | if (convolve_image == (Image *) NULL) |
| 1280 | break; |
| 1281 | *image=DestroyImage(*image); |
| 1282 | *image=convolve_image; |
| 1283 | break; |
| 1284 | } |
| 1285 | if (LocaleCompare("crop",option+1) == 0) |
| 1286 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1287 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1288 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1289 | if (((geometry.width != 0) || (geometry.height != 0)) && |
| 1290 | ((flags & XValue) == 0) && ((flags & YValue) == 0)) |
| 1291 | break; |
| 1292 | (void) TransformImage(image,argv[i+1],(char *) NULL); |
| 1293 | InheritException(exception,&(*image)->exception); |
| 1294 | break; |
| 1295 | } |
| 1296 | if (LocaleCompare("cycle",option+1) == 0) |
| 1297 | { |
| 1298 | /* |
| 1299 | Cycle an image colormap. |
| 1300 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1301 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 1302 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1])); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1303 | InheritException(exception,&(*image)->exception); |
| 1304 | break; |
| 1305 | } |
| 1306 | break; |
| 1307 | } |
| 1308 | case 'd': |
| 1309 | { |
| 1310 | if (LocaleCompare("decipher",option+1) == 0) |
| 1311 | { |
| 1312 | StringInfo |
| 1313 | *passkey; |
| 1314 | |
| 1315 | /* |
| 1316 | Decipher pixels. |
| 1317 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1318 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1319 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1320 | if (passkey != (StringInfo *) NULL) |
| 1321 | { |
| 1322 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1323 | passkey=DestroyStringInfo(passkey); |
| 1324 | } |
| 1325 | break; |
| 1326 | } |
| 1327 | if (LocaleCompare("density",option+1) == 0) |
| 1328 | { |
| 1329 | /* |
| 1330 | Set image density. |
| 1331 | */ |
| 1332 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1333 | break; |
| 1334 | } |
| 1335 | if (LocaleCompare("depth",option+1) == 0) |
| 1336 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1337 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1338 | if (*option == '+') |
| 1339 | { |
| 1340 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH); |
| 1341 | break; |
| 1342 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 1343 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1])); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1344 | break; |
| 1345 | } |
| 1346 | if (LocaleCompare("deskew",option+1) == 0) |
| 1347 | { |
| 1348 | double |
| 1349 | threshold; |
| 1350 | |
| 1351 | Image |
| 1352 | *deskew_image; |
| 1353 | |
| 1354 | /* |
| 1355 | Straighten the image. |
| 1356 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1357 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1358 | if (*option == '+') |
| 1359 | threshold=40.0*QuantumRange/100.0; |
| 1360 | else |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1361 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1362 | deskew_image=DeskewImage(*image,threshold,exception); |
| 1363 | if (deskew_image == (Image *) NULL) |
| 1364 | break; |
| 1365 | *image=DestroyImage(*image); |
| 1366 | *image=deskew_image; |
| 1367 | break; |
| 1368 | } |
| 1369 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1370 | { |
| 1371 | Image |
| 1372 | *despeckle_image; |
| 1373 | |
| 1374 | /* |
| 1375 | Reduce the speckles within an image. |
| 1376 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1377 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1378 | despeckle_image=DespeckleImage(*image,exception); |
| 1379 | if (despeckle_image == (Image *) NULL) |
| 1380 | break; |
| 1381 | *image=DestroyImage(*image); |
| 1382 | *image=despeckle_image; |
| 1383 | break; |
| 1384 | } |
| 1385 | if (LocaleCompare("display",option+1) == 0) |
| 1386 | { |
| 1387 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1388 | break; |
| 1389 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1390 | if (LocaleCompare("distort",option+1) == 0) |
| 1391 | { |
| 1392 | char |
| 1393 | *args, |
| 1394 | token[MaxTextExtent]; |
| 1395 | |
| 1396 | const char |
| 1397 | *p; |
| 1398 | |
| 1399 | DistortImageMethod |
| 1400 | method; |
| 1401 | |
| 1402 | double |
| 1403 | *arguments; |
| 1404 | |
| 1405 | Image |
| 1406 | *distort_image; |
| 1407 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1408 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1409 | x; |
| 1410 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1411 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1412 | number_arguments; |
| 1413 | |
| 1414 | /* |
| 1415 | Distort image. |
| 1416 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1417 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1418 | method=(DistortImageMethod) ParseMagickOption(MagickDistortOptions, |
| 1419 | MagickFalse,argv[i+1]); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1420 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1421 | InheritException(exception,&(*image)->exception); |
| 1422 | if (args == (char *) NULL) |
| 1423 | break; |
| 1424 | p=(char *) args; |
| 1425 | for (x=0; *p != '\0'; x++) |
| 1426 | { |
| 1427 | GetMagickToken(p,&p,token); |
| 1428 | if (*token == ',') |
| 1429 | GetMagickToken(p,&p,token); |
| 1430 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1431 | number_arguments=(size_t) x; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1432 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1433 | sizeof(*arguments)); |
| 1434 | if (arguments == (double *) NULL) |
| 1435 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1436 | "MemoryAllocationFailed",(*image)->filename); |
| 1437 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1438 | sizeof(*arguments)); |
| 1439 | p=(char *) args; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1440 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1441 | { |
| 1442 | GetMagickToken(p,&p,token); |
| 1443 | if (*token == ',') |
| 1444 | GetMagickToken(p,&p,token); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1445 | arguments[x]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1446 | } |
| 1447 | args=DestroyString(args); |
| 1448 | distort_image=DistortImage(*image,method,number_arguments,arguments, |
| 1449 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1450 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1451 | if (distort_image == (Image *) NULL) |
| 1452 | break; |
| 1453 | *image=DestroyImage(*image); |
| 1454 | *image=distort_image; |
| 1455 | break; |
| 1456 | } |
| 1457 | if (LocaleCompare("dither",option+1) == 0) |
| 1458 | { |
| 1459 | if (*option == '+') |
| 1460 | { |
| 1461 | quantize_info->dither=MagickFalse; |
| 1462 | break; |
| 1463 | } |
| 1464 | quantize_info->dither=MagickTrue; |
| 1465 | quantize_info->dither_method=(DitherMethod) ParseMagickOption( |
| 1466 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1467 | if (quantize_info->dither_method == NoDitherMethod) |
| 1468 | quantize_info->dither=MagickFalse; |
| 1469 | break; |
| 1470 | } |
| 1471 | if (LocaleCompare("draw",option+1) == 0) |
| 1472 | { |
| 1473 | /* |
| 1474 | Draw image. |
| 1475 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1476 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1477 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
| 1478 | (void) DrawImage(*image,draw_info); |
| 1479 | InheritException(exception,&(*image)->exception); |
| 1480 | break; |
| 1481 | } |
| 1482 | break; |
| 1483 | } |
| 1484 | case 'e': |
| 1485 | { |
| 1486 | if (LocaleCompare("edge",option+1) == 0) |
| 1487 | { |
| 1488 | Image |
| 1489 | *edge_image; |
| 1490 | |
| 1491 | /* |
| 1492 | Enhance edges in the image. |
| 1493 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1494 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1495 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1496 | if ((flags & SigmaValue) == 0) |
| 1497 | geometry_info.sigma=1.0; |
| 1498 | edge_image=EdgeImage(*image,geometry_info.rho,exception); |
| 1499 | if (edge_image == (Image *) NULL) |
| 1500 | break; |
| 1501 | *image=DestroyImage(*image); |
| 1502 | *image=edge_image; |
| 1503 | break; |
| 1504 | } |
| 1505 | if (LocaleCompare("emboss",option+1) == 0) |
| 1506 | { |
| 1507 | Image |
| 1508 | *emboss_image; |
| 1509 | |
| 1510 | /* |
| 1511 | Gaussian embossen image. |
| 1512 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1513 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1514 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1515 | if ((flags & SigmaValue) == 0) |
| 1516 | geometry_info.sigma=1.0; |
| 1517 | emboss_image=EmbossImage(*image,geometry_info.rho, |
| 1518 | geometry_info.sigma,exception); |
| 1519 | if (emboss_image == (Image *) NULL) |
| 1520 | break; |
| 1521 | *image=DestroyImage(*image); |
| 1522 | *image=emboss_image; |
| 1523 | break; |
| 1524 | } |
| 1525 | if (LocaleCompare("encipher",option+1) == 0) |
| 1526 | { |
| 1527 | StringInfo |
| 1528 | *passkey; |
| 1529 | |
| 1530 | /* |
| 1531 | Encipher pixels. |
| 1532 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1533 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1534 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1535 | if (passkey != (StringInfo *) NULL) |
| 1536 | { |
| 1537 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1538 | passkey=DestroyStringInfo(passkey); |
| 1539 | } |
| 1540 | break; |
| 1541 | } |
| 1542 | if (LocaleCompare("encoding",option+1) == 0) |
| 1543 | { |
| 1544 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1545 | break; |
| 1546 | } |
| 1547 | if (LocaleCompare("enhance",option+1) == 0) |
| 1548 | { |
| 1549 | Image |
| 1550 | *enhance_image; |
| 1551 | |
| 1552 | /* |
| 1553 | Enhance image. |
| 1554 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1555 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1556 | enhance_image=EnhanceImage(*image,exception); |
| 1557 | if (enhance_image == (Image *) NULL) |
| 1558 | break; |
| 1559 | *image=DestroyImage(*image); |
| 1560 | *image=enhance_image; |
| 1561 | break; |
| 1562 | } |
| 1563 | if (LocaleCompare("equalize",option+1) == 0) |
| 1564 | { |
| 1565 | /* |
| 1566 | Equalize image. |
| 1567 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1568 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1569 | (void) EqualizeImageChannel(*image,channel); |
| 1570 | InheritException(exception,&(*image)->exception); |
| 1571 | break; |
| 1572 | } |
| 1573 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1574 | { |
| 1575 | double |
| 1576 | constant; |
| 1577 | |
| 1578 | MagickEvaluateOperator |
| 1579 | op; |
| 1580 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1581 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1582 | op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions, |
| 1583 | MagickFalse,argv[i+1]); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1584 | constant=SiPrefixToDouble(argv[i+2],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1585 | (void) EvaluateImageChannel(*image,channel,op,constant,exception); |
| 1586 | break; |
| 1587 | } |
| 1588 | if (LocaleCompare("extent",option+1) == 0) |
| 1589 | { |
| 1590 | Image |
| 1591 | *extent_image; |
| 1592 | |
| 1593 | /* |
| 1594 | Set the image extent. |
| 1595 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1596 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1597 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
cristy | f0bbfd9 | 2009-11-25 14:12:31 +0000 | [diff] [blame] | 1598 | if (geometry.width == 0) |
cristy | 2ea9a4e | 2009-11-25 14:30:22 +0000 | [diff] [blame] | 1599 | geometry.width=(*image)->columns; |
cristy | f0bbfd9 | 2009-11-25 14:12:31 +0000 | [diff] [blame] | 1600 | if (geometry.height == 0) |
cristy | 2ea9a4e | 2009-11-25 14:30:22 +0000 | [diff] [blame] | 1601 | geometry.height=(*image)->rows; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1602 | extent_image=ExtentImage(*image,&geometry,exception); |
| 1603 | if (extent_image == (Image *) NULL) |
| 1604 | break; |
| 1605 | *image=DestroyImage(*image); |
| 1606 | *image=extent_image; |
| 1607 | break; |
| 1608 | } |
| 1609 | break; |
| 1610 | } |
| 1611 | case 'f': |
| 1612 | { |
| 1613 | if (LocaleCompare("family",option+1) == 0) |
| 1614 | { |
| 1615 | if (*option == '+') |
| 1616 | { |
| 1617 | if (draw_info->family != (char *) NULL) |
| 1618 | draw_info->family=DestroyString(draw_info->family); |
| 1619 | break; |
| 1620 | } |
| 1621 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1622 | break; |
| 1623 | } |
cristy | 0fe961c | 2010-01-30 03:09:54 +0000 | [diff] [blame] | 1624 | if (LocaleCompare("features",option+1) == 0) |
| 1625 | { |
| 1626 | if (*option == '+') |
| 1627 | { |
| 1628 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1629 | break; |
| 1630 | } |
| 1631 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1632 | break; |
| 1633 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1634 | if (LocaleCompare("fill",option+1) == 0) |
| 1635 | { |
| 1636 | ExceptionInfo |
| 1637 | *sans; |
| 1638 | |
| 1639 | GetMagickPixelPacket(*image,&fill); |
| 1640 | if (*option == '+') |
| 1641 | { |
| 1642 | (void) QueryMagickColor("none",&fill,exception); |
| 1643 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 1644 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1645 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1646 | break; |
| 1647 | } |
| 1648 | sans=AcquireExceptionInfo(); |
| 1649 | (void) QueryMagickColor(argv[i+1],&fill,sans); |
| 1650 | status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans); |
| 1651 | sans=DestroyExceptionInfo(sans); |
| 1652 | if (status == MagickFalse) |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1653 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1654 | exception); |
| 1655 | break; |
| 1656 | } |
| 1657 | if (LocaleCompare("flip",option+1) == 0) |
| 1658 | { |
| 1659 | Image |
| 1660 | *flip_image; |
| 1661 | |
| 1662 | /* |
| 1663 | Flip image scanlines. |
| 1664 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1665 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1666 | flip_image=FlipImage(*image,exception); |
| 1667 | if (flip_image == (Image *) NULL) |
| 1668 | break; |
| 1669 | *image=DestroyImage(*image); |
| 1670 | *image=flip_image; |
| 1671 | break; |
| 1672 | } |
| 1673 | if (LocaleCompare("flop",option+1) == 0) |
| 1674 | { |
| 1675 | Image |
| 1676 | *flop_image; |
| 1677 | |
| 1678 | /* |
| 1679 | Flop image scanlines. |
| 1680 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1681 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1682 | flop_image=FlopImage(*image,exception); |
| 1683 | if (flop_image == (Image *) NULL) |
| 1684 | break; |
| 1685 | *image=DestroyImage(*image); |
| 1686 | *image=flop_image; |
| 1687 | break; |
| 1688 | } |
| 1689 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1690 | { |
| 1691 | MagickPixelPacket |
| 1692 | target; |
| 1693 | |
| 1694 | /* |
| 1695 | Floodfill image. |
| 1696 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1697 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1698 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1699 | (void) QueryMagickColor(argv[i+2],&target,exception); |
| 1700 | (void) FloodfillPaintImage(*image,channel,draw_info,&target, |
| 1701 | geometry.x,geometry.y,*option == '-' ? MagickFalse : MagickTrue); |
| 1702 | InheritException(exception,&(*image)->exception); |
| 1703 | break; |
| 1704 | } |
| 1705 | if (LocaleCompare("font",option+1) == 0) |
| 1706 | { |
| 1707 | if (*option == '+') |
| 1708 | { |
| 1709 | if (draw_info->font != (char *) NULL) |
| 1710 | draw_info->font=DestroyString(draw_info->font); |
| 1711 | break; |
| 1712 | } |
| 1713 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1714 | break; |
| 1715 | } |
| 1716 | if (LocaleCompare("format",option+1) == 0) |
| 1717 | { |
| 1718 | format=argv[i+1]; |
| 1719 | break; |
| 1720 | } |
| 1721 | if (LocaleCompare("frame",option+1) == 0) |
| 1722 | { |
| 1723 | FrameInfo |
| 1724 | frame_info; |
| 1725 | |
| 1726 | Image |
| 1727 | *frame_image; |
| 1728 | |
| 1729 | /* |
| 1730 | Surround image with an ornamental border. |
| 1731 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1732 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1733 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1734 | frame_info.width=geometry.width; |
| 1735 | frame_info.height=geometry.height; |
| 1736 | if ((flags & HeightValue) == 0) |
| 1737 | frame_info.height=geometry.width; |
| 1738 | frame_info.outer_bevel=geometry.x; |
| 1739 | frame_info.inner_bevel=geometry.y; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1740 | frame_info.x=(ssize_t) frame_info.width; |
| 1741 | frame_info.y=(ssize_t) frame_info.height; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1742 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1743 | frame_info.height=(*image)->rows+2*frame_info.height; |
| 1744 | frame_image=FrameImage(*image,&frame_info,exception); |
| 1745 | if (frame_image == (Image *) NULL) |
| 1746 | break; |
| 1747 | *image=DestroyImage(*image); |
| 1748 | *image=frame_image; |
| 1749 | break; |
| 1750 | } |
| 1751 | if (LocaleCompare("function",option+1) == 0) |
| 1752 | { |
| 1753 | char |
| 1754 | *arguments, |
| 1755 | token[MaxTextExtent]; |
| 1756 | |
| 1757 | const char |
| 1758 | *p; |
| 1759 | |
| 1760 | double |
| 1761 | *parameters; |
| 1762 | |
| 1763 | MagickFunction |
| 1764 | function; |
| 1765 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1766 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1767 | x; |
| 1768 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1769 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1770 | number_parameters; |
| 1771 | |
| 1772 | /* |
| 1773 | Function Modify Image Values |
| 1774 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1775 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1776 | function=(MagickFunction) ParseMagickOption(MagickFunctionOptions, |
| 1777 | MagickFalse,argv[i+1]); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1778 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1779 | InheritException(exception,&(*image)->exception); |
| 1780 | if (arguments == (char *) NULL) |
| 1781 | break; |
| 1782 | p=(char *) arguments; |
| 1783 | for (x=0; *p != '\0'; x++) |
| 1784 | { |
| 1785 | GetMagickToken(p,&p,token); |
| 1786 | if (*token == ',') |
| 1787 | GetMagickToken(p,&p,token); |
| 1788 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1789 | number_parameters=(size_t) x; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1790 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1791 | sizeof(*parameters)); |
| 1792 | if (parameters == (double *) NULL) |
| 1793 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1794 | "MemoryAllocationFailed",(*image)->filename); |
| 1795 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1796 | sizeof(*parameters)); |
| 1797 | p=(char *) arguments; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1798 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1799 | { |
| 1800 | GetMagickToken(p,&p,token); |
| 1801 | if (*token == ',') |
| 1802 | GetMagickToken(p,&p,token); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1803 | parameters[x]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1804 | } |
| 1805 | arguments=DestroyString(arguments); |
| 1806 | (void) FunctionImageChannel(*image,channel,function, |
| 1807 | number_parameters,parameters,exception); |
| 1808 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1809 | break; |
| 1810 | } |
| 1811 | break; |
| 1812 | } |
| 1813 | case 'g': |
| 1814 | { |
| 1815 | if (LocaleCompare("gamma",option+1) == 0) |
| 1816 | { |
| 1817 | /* |
| 1818 | Gamma image. |
| 1819 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1820 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1821 | if (*option == '+') |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1822 | (*image)->gamma=StringToDouble(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1823 | else |
| 1824 | { |
| 1825 | if (strchr(argv[i+1],',') != (char *) NULL) |
| 1826 | (void) GammaImage(*image,argv[i+1]); |
| 1827 | else |
cristy | a5447be | 2010-01-11 00:20:51 +0000 | [diff] [blame] | 1828 | (void) GammaImageChannel(*image,channel, |
| 1829 | StringToDouble(argv[i+1])); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1830 | InheritException(exception,&(*image)->exception); |
| 1831 | } |
| 1832 | break; |
| 1833 | } |
| 1834 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1835 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1836 | { |
| 1837 | Image |
| 1838 | *gaussian_image; |
| 1839 | |
| 1840 | /* |
| 1841 | Gaussian blur image. |
| 1842 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1843 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1844 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1845 | if ((flags & SigmaValue) == 0) |
| 1846 | geometry_info.sigma=1.0; |
| 1847 | gaussian_image=GaussianBlurImageChannel(*image,channel, |
| 1848 | geometry_info.rho,geometry_info.sigma,exception); |
| 1849 | if (gaussian_image == (Image *) NULL) |
| 1850 | break; |
| 1851 | *image=DestroyImage(*image); |
| 1852 | *image=gaussian_image; |
| 1853 | break; |
| 1854 | } |
| 1855 | if (LocaleCompare("geometry",option+1) == 0) |
| 1856 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1857 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1858 | if (*option == '+') |
| 1859 | { |
| 1860 | if ((*image)->geometry != (char *) NULL) |
| 1861 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1862 | break; |
| 1863 | } |
| 1864 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1865 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1866 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1867 | else |
| 1868 | { |
| 1869 | Image |
cristy | 15b98cd | 2010-09-12 19:42:50 +0000 | [diff] [blame] | 1870 | *resize_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1871 | |
| 1872 | /* |
| 1873 | Resize image. |
| 1874 | */ |
cristy | 15b98cd | 2010-09-12 19:42:50 +0000 | [diff] [blame] | 1875 | resize_image=ResizeImage(*image,geometry.width,geometry.height, |
| 1876 | (*image)->filter,(*image)->blur,exception); |
| 1877 | if (resize_image == (Image *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1878 | break; |
| 1879 | *image=DestroyImage(*image); |
cristy | 15b98cd | 2010-09-12 19:42:50 +0000 | [diff] [blame] | 1880 | *image=resize_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1881 | } |
| 1882 | break; |
| 1883 | } |
| 1884 | if (LocaleCompare("gravity",option+1) == 0) |
| 1885 | { |
| 1886 | if (*option == '+') |
| 1887 | { |
| 1888 | draw_info->gravity=UndefinedGravity; |
| 1889 | break; |
| 1890 | } |
| 1891 | draw_info->gravity=(GravityType) ParseMagickOption( |
| 1892 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1893 | break; |
| 1894 | } |
| 1895 | break; |
| 1896 | } |
| 1897 | case 'h': |
| 1898 | { |
| 1899 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1900 | { |
| 1901 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1902 | break; |
| 1903 | } |
| 1904 | break; |
| 1905 | } |
| 1906 | case 'i': |
| 1907 | { |
| 1908 | if (LocaleCompare("identify",option+1) == 0) |
| 1909 | { |
| 1910 | char |
| 1911 | *text; |
| 1912 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1913 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1914 | if (format == (char *) NULL) |
| 1915 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1916 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1917 | InheritException(exception,&(*image)->exception); |
| 1918 | break; |
| 1919 | } |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1920 | text=InterpretImageProperties(mogrify_info,*image,format); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1921 | InheritException(exception,&(*image)->exception); |
| 1922 | if (text == (char *) NULL) |
| 1923 | break; |
| 1924 | (void) fputs(text,stdout); |
| 1925 | (void) fputc('\n',stdout); |
| 1926 | text=DestroyString(text); |
| 1927 | break; |
| 1928 | } |
| 1929 | if (LocaleCompare("implode",option+1) == 0) |
| 1930 | { |
| 1931 | Image |
| 1932 | *implode_image; |
| 1933 | |
| 1934 | /* |
| 1935 | Implode image. |
| 1936 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1937 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1938 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1939 | implode_image=ImplodeImage(*image,geometry_info.rho,exception); |
| 1940 | if (implode_image == (Image *) NULL) |
| 1941 | break; |
| 1942 | *image=DestroyImage(*image); |
| 1943 | *image=implode_image; |
| 1944 | break; |
| 1945 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 1946 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1947 | { |
| 1948 | if (*option == '+') |
| 1949 | (void) ParseGeometry("0",&geometry_info); |
| 1950 | else |
| 1951 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1952 | draw_info->interline_spacing=geometry_info.rho; |
| 1953 | break; |
| 1954 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1955 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1956 | { |
| 1957 | if (*option == '+') |
| 1958 | (void) ParseGeometry("0",&geometry_info); |
| 1959 | else |
| 1960 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1961 | draw_info->interword_spacing=geometry_info.rho; |
| 1962 | break; |
| 1963 | } |
| 1964 | break; |
| 1965 | } |
| 1966 | case 'k': |
| 1967 | { |
| 1968 | if (LocaleCompare("kerning",option+1) == 0) |
| 1969 | { |
| 1970 | if (*option == '+') |
| 1971 | (void) ParseGeometry("0",&geometry_info); |
| 1972 | else |
| 1973 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1974 | draw_info->kerning=geometry_info.rho; |
| 1975 | break; |
| 1976 | } |
| 1977 | break; |
| 1978 | } |
| 1979 | case 'l': |
| 1980 | { |
cristy | df81b99 | 2011-02-27 14:33:24 +0000 | [diff] [blame] | 1981 | if (LocaleCompare("label",option+1) == 0) |
| 1982 | { |
| 1983 | if (*option == '+') |
| 1984 | { |
cristy | 3fb6d77 | 2011-02-27 15:13:43 +0000 | [diff] [blame] | 1985 | (void) DeleteImageProperty(*image,option+1); |
cristy | df81b99 | 2011-02-27 14:33:24 +0000 | [diff] [blame] | 1986 | break; |
| 1987 | } |
cristy | 3fb6d77 | 2011-02-27 15:13:43 +0000 | [diff] [blame] | 1988 | (void) SetImageProperty(*image,option+1,argv[i+1]); |
cristy | df81b99 | 2011-02-27 14:33:24 +0000 | [diff] [blame] | 1989 | break; |
| 1990 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1991 | if (LocaleCompare("lat",option+1) == 0) |
| 1992 | { |
| 1993 | Image |
| 1994 | *threshold_image; |
| 1995 | |
| 1996 | /* |
| 1997 | Local adaptive threshold image. |
| 1998 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1999 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2000 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2001 | if ((flags & PercentValue) != 0) |
| 2002 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2003 | threshold_image=AdaptiveThresholdImage(*image,(size_t) |
| 2004 | geometry_info.rho,(size_t) geometry_info.sigma, |
| 2005 | (ssize_t) geometry_info.xi,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2006 | if (threshold_image == (Image *) NULL) |
| 2007 | break; |
| 2008 | *image=DestroyImage(*image); |
| 2009 | *image=threshold_image; |
| 2010 | break; |
| 2011 | } |
| 2012 | if (LocaleCompare("level",option+1) == 0) |
| 2013 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2014 | MagickRealType |
| 2015 | black_point, |
| 2016 | gamma, |
| 2017 | white_point; |
| 2018 | |
| 2019 | MagickStatusType |
| 2020 | flags; |
| 2021 | |
| 2022 | /* |
| 2023 | Parse levels. |
| 2024 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2025 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2026 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2027 | black_point=geometry_info.rho; |
| 2028 | white_point=(MagickRealType) QuantumRange; |
| 2029 | if ((flags & SigmaValue) != 0) |
| 2030 | white_point=geometry_info.sigma; |
| 2031 | gamma=1.0; |
| 2032 | if ((flags & XiValue) != 0) |
| 2033 | gamma=geometry_info.xi; |
| 2034 | if ((flags & PercentValue) != 0) |
| 2035 | { |
| 2036 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 2037 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 2038 | } |
| 2039 | if ((flags & SigmaValue) == 0) |
| 2040 | white_point=(MagickRealType) QuantumRange-black_point; |
| 2041 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
| 2042 | (void) LevelizeImageChannel(*image,channel,black_point, |
| 2043 | white_point,gamma); |
| 2044 | else |
| 2045 | (void) LevelImageChannel(*image,channel,black_point,white_point, |
| 2046 | gamma); |
| 2047 | InheritException(exception,&(*image)->exception); |
| 2048 | break; |
| 2049 | } |
| 2050 | if (LocaleCompare("level-colors",option+1) == 0) |
| 2051 | { |
| 2052 | char |
| 2053 | token[MaxTextExtent]; |
| 2054 | |
| 2055 | const char |
| 2056 | *p; |
| 2057 | |
| 2058 | MagickPixelPacket |
| 2059 | black_point, |
| 2060 | white_point; |
| 2061 | |
| 2062 | p=(const char *) argv[i+1]; |
| 2063 | GetMagickToken(p,&p,token); /* get black point color */ |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 2064 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2065 | (void) QueryMagickColor(token,&black_point,exception); |
| 2066 | else |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 2067 | (void) QueryMagickColor("#000000",&black_point,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2068 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 2069 | GetMagickToken(p,&p,token); |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 2070 | if (*token == '\0') |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2071 | white_point=black_point; /* set everything to that color */ |
| 2072 | else |
| 2073 | { |
| 2074 | /* |
| 2075 | Get white point color. |
| 2076 | */ |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 2077 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2078 | GetMagickToken(p,&p,token); |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 2079 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2080 | (void) QueryMagickColor(token,&white_point,exception); |
| 2081 | else |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 2082 | (void) QueryMagickColor("#ffffff",&white_point,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2083 | } |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 2084 | (void) LevelColorsImageChannel(*image,channel,&black_point, |
| 2085 | &white_point,*option == '+' ? MagickTrue : MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2086 | break; |
| 2087 | } |
| 2088 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 2089 | { |
| 2090 | double |
| 2091 | black_point, |
| 2092 | white_point; |
| 2093 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2094 | MagickStatusType |
| 2095 | flags; |
| 2096 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2097 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2098 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2099 | black_point=geometry_info.rho; |
| 2100 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 2101 | if ((flags & SigmaValue) != 0) |
| 2102 | white_point=geometry_info.sigma; |
| 2103 | if ((flags & PercentValue) != 0) |
| 2104 | { |
| 2105 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 2106 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 2107 | } |
| 2108 | if ((flags & SigmaValue) == 0) |
| 2109 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 2110 | black_point; |
| 2111 | (void) LinearStretchImage(*image,black_point,white_point); |
| 2112 | InheritException(exception,&(*image)->exception); |
| 2113 | break; |
| 2114 | } |
| 2115 | if (LocaleCompare("linewidth",option+1) == 0) |
| 2116 | { |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 2117 | draw_info->stroke_width=StringToDouble(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2118 | break; |
| 2119 | } |
| 2120 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 2121 | { |
| 2122 | Image |
| 2123 | *resize_image; |
| 2124 | |
| 2125 | /* |
| 2126 | Liquid rescale image. |
| 2127 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2128 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2129 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2130 | if ((flags & XValue) == 0) |
| 2131 | geometry.x=1; |
| 2132 | if ((flags & YValue) == 0) |
| 2133 | geometry.y=0; |
| 2134 | resize_image=LiquidRescaleImage(*image,geometry.width, |
| 2135 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 2136 | if (resize_image == (Image *) NULL) |
| 2137 | break; |
| 2138 | *image=DestroyImage(*image); |
| 2139 | *image=resize_image; |
| 2140 | break; |
| 2141 | } |
| 2142 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 2143 | { |
| 2144 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 2145 | break; |
| 2146 | } |
| 2147 | break; |
| 2148 | } |
| 2149 | case 'm': |
| 2150 | { |
| 2151 | if (LocaleCompare("map",option+1) == 0) |
| 2152 | { |
| 2153 | Image |
| 2154 | *remap_image; |
| 2155 | |
| 2156 | /* |
| 2157 | Transform image colors to match this set of colors. |
| 2158 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2159 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2160 | if (*option == '+') |
| 2161 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2162 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2163 | if (remap_image == (Image *) NULL) |
| 2164 | break; |
| 2165 | (void) RemapImage(quantize_info,*image,remap_image); |
| 2166 | InheritException(exception,&(*image)->exception); |
| 2167 | remap_image=DestroyImage(remap_image); |
| 2168 | break; |
| 2169 | } |
| 2170 | if (LocaleCompare("mask",option+1) == 0) |
| 2171 | { |
| 2172 | Image |
| 2173 | *mask; |
| 2174 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2175 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2176 | if (*option == '+') |
| 2177 | { |
| 2178 | /* |
| 2179 | Remove a mask. |
| 2180 | */ |
| 2181 | (void) SetImageMask(*image,(Image *) NULL); |
| 2182 | InheritException(exception,&(*image)->exception); |
| 2183 | break; |
| 2184 | } |
| 2185 | /* |
| 2186 | Set the image mask. |
| 2187 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2188 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2189 | if (mask == (Image *) NULL) |
| 2190 | break; |
| 2191 | (void) SetImageMask(*image,mask); |
| 2192 | mask=DestroyImage(mask); |
| 2193 | InheritException(exception,&(*image)->exception); |
| 2194 | break; |
| 2195 | } |
| 2196 | if (LocaleCompare("matte",option+1) == 0) |
| 2197 | { |
| 2198 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
| 2199 | SetAlphaChannel : DeactivateAlphaChannel ); |
| 2200 | InheritException(exception,&(*image)->exception); |
| 2201 | break; |
| 2202 | } |
| 2203 | if (LocaleCompare("median",option+1) == 0) |
| 2204 | { |
| 2205 | Image |
| 2206 | *median_image; |
| 2207 | |
| 2208 | /* |
| 2209 | Median filter image. |
| 2210 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2211 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2212 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2213 | median_image=MedianFilterImage(*image,geometry_info.rho,exception); |
| 2214 | if (median_image == (Image *) NULL) |
| 2215 | break; |
| 2216 | *image=DestroyImage(*image); |
| 2217 | *image=median_image; |
| 2218 | break; |
| 2219 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame^] | 2220 | if (LocaleCompare("mode",option+1) == 0) |
| 2221 | { |
| 2222 | Image |
| 2223 | *mode_image; |
| 2224 | |
| 2225 | /* |
| 2226 | Mode image. |
| 2227 | */ |
| 2228 | (void) SyncImageSettings(mogrify_info,*image); |
| 2229 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2230 | mode_image=ModeImage(*image,geometry_info.rho,exception); |
| 2231 | if (mode_image == (Image *) NULL) |
| 2232 | break; |
| 2233 | *image=DestroyImage(*image); |
| 2234 | *image=mode_image; |
| 2235 | break; |
| 2236 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2237 | if (LocaleCompare("modulate",option+1) == 0) |
| 2238 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2239 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2240 | (void) ModulateImage(*image,argv[i+1]); |
| 2241 | InheritException(exception,&(*image)->exception); |
| 2242 | break; |
| 2243 | } |
| 2244 | if (LocaleCompare("monitor",option+1) == 0) |
| 2245 | { |
cristy | 7d34ef2 | 2010-03-25 01:11:22 +0000 | [diff] [blame] | 2246 | if (*option == '+') |
| 2247 | { |
| 2248 | (void) SetImageProgressMonitor(*image, |
| 2249 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2250 | break; |
| 2251 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2252 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2253 | (void *) NULL); |
| 2254 | break; |
| 2255 | } |
| 2256 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2257 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2258 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2259 | (void) SetImageType(*image,BilevelType); |
| 2260 | InheritException(exception,&(*image)->exception); |
| 2261 | break; |
| 2262 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2263 | if (LocaleCompare("morphology",option+1) == 0) |
| 2264 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2265 | char |
| 2266 | token[MaxTextExtent]; |
| 2267 | |
| 2268 | const char |
| 2269 | *p; |
| 2270 | |
cristy | e96405a | 2010-05-19 02:24:31 +0000 | [diff] [blame] | 2271 | Image |
| 2272 | *morphology_image; |
| 2273 | |
| 2274 | KernelInfo |
| 2275 | *kernel; |
| 2276 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2277 | ssize_t |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2278 | iterations; |
| 2279 | |
cristy | e96405a | 2010-05-19 02:24:31 +0000 | [diff] [blame] | 2280 | MorphologyMethod |
| 2281 | method; |
| 2282 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2283 | /* |
| 2284 | Morphological Image Operation |
| 2285 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2286 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2287 | p=argv[i+1]; |
| 2288 | GetMagickToken(p,&p,token); |
| 2289 | method=(MorphologyMethod) ParseMagickOption(MagickMorphologyOptions, |
cristy | d2c1e1e | 2010-05-08 01:05:44 +0000 | [diff] [blame] | 2290 | MagickFalse,token); |
cristy | ef65691 | 2010-03-05 19:54:59 +0000 | [diff] [blame] | 2291 | iterations=1L; |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2292 | GetMagickToken(p,&p,token); |
cristy | ef65691 | 2010-03-05 19:54:59 +0000 | [diff] [blame] | 2293 | if ((*p == ':') || (*p == ',')) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2294 | GetMagickToken(p,&p,token); |
cristy | ef65691 | 2010-03-05 19:54:59 +0000 | [diff] [blame] | 2295 | if ((*p != '\0')) |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 2296 | iterations=(ssize_t) StringToLong(p); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2297 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2298 | if (kernel == (KernelInfo *) NULL) |
cristy | e96405a | 2010-05-19 02:24:31 +0000 | [diff] [blame] | 2299 | { |
| 2300 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2301 | OptionError,"UnabletoParseKernel","morphology"); |
| 2302 | status=MagickFalse; |
| 2303 | break; |
| 2304 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2305 | morphology_image=MorphologyImageChannel(*image,channel,method, |
cristy | 02d5b4f | 2010-02-01 01:08:27 +0000 | [diff] [blame] | 2306 | iterations,kernel,exception); |
anthony | 83ba99b | 2010-01-24 08:48:15 +0000 | [diff] [blame] | 2307 | kernel=DestroyKernelInfo(kernel); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2308 | if (morphology_image == (Image *) NULL) |
| 2309 | break; |
| 2310 | *image=DestroyImage(*image); |
| 2311 | *image=morphology_image; |
| 2312 | break; |
| 2313 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2314 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2315 | { |
| 2316 | Image |
| 2317 | *blur_image; |
| 2318 | |
| 2319 | /* |
| 2320 | Motion blur image. |
| 2321 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2322 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2323 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2324 | if ((flags & SigmaValue) == 0) |
| 2325 | geometry_info.sigma=1.0; |
| 2326 | blur_image=MotionBlurImageChannel(*image,channel,geometry_info.rho, |
| 2327 | geometry_info.sigma,geometry_info.xi,exception); |
| 2328 | if (blur_image == (Image *) NULL) |
| 2329 | break; |
| 2330 | *image=DestroyImage(*image); |
| 2331 | *image=blur_image; |
| 2332 | break; |
| 2333 | } |
| 2334 | break; |
| 2335 | } |
| 2336 | case 'n': |
| 2337 | { |
| 2338 | if (LocaleCompare("negate",option+1) == 0) |
| 2339 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2340 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2341 | (void) NegateImageChannel(*image,channel,*option == '+' ? |
| 2342 | MagickTrue : MagickFalse); |
| 2343 | InheritException(exception,&(*image)->exception); |
| 2344 | break; |
| 2345 | } |
| 2346 | if (LocaleCompare("noise",option+1) == 0) |
| 2347 | { |
| 2348 | Image |
| 2349 | *noisy_image; |
| 2350 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2351 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2352 | if (*option == '-') |
| 2353 | { |
| 2354 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2355 | noisy_image=ReduceNoiseImage(*image,geometry_info.rho, |
| 2356 | exception); |
| 2357 | } |
| 2358 | else |
| 2359 | { |
| 2360 | NoiseType |
| 2361 | noise; |
| 2362 | |
| 2363 | noise=(NoiseType) ParseMagickOption(MagickNoiseOptions, |
| 2364 | MagickFalse,argv[i+1]); |
| 2365 | noisy_image=AddNoiseImageChannel(*image,channel,noise, |
| 2366 | exception); |
| 2367 | } |
| 2368 | if (noisy_image == (Image *) NULL) |
| 2369 | break; |
| 2370 | *image=DestroyImage(*image); |
| 2371 | *image=noisy_image; |
| 2372 | break; |
| 2373 | } |
| 2374 | if (LocaleCompare("normalize",option+1) == 0) |
| 2375 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2376 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2377 | (void) NormalizeImageChannel(*image,channel); |
| 2378 | InheritException(exception,&(*image)->exception); |
| 2379 | break; |
| 2380 | } |
| 2381 | break; |
| 2382 | } |
| 2383 | case 'o': |
| 2384 | { |
| 2385 | if (LocaleCompare("opaque",option+1) == 0) |
| 2386 | { |
| 2387 | MagickPixelPacket |
| 2388 | target; |
| 2389 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2390 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2391 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2392 | (void) OpaquePaintImageChannel(*image,channel,&target,&fill, |
| 2393 | *option == '-' ? MagickFalse : MagickTrue); |
| 2394 | break; |
| 2395 | } |
| 2396 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2397 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2398 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2399 | (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1], |
| 2400 | exception); |
| 2401 | break; |
| 2402 | } |
| 2403 | break; |
| 2404 | } |
| 2405 | case 'p': |
| 2406 | { |
| 2407 | if (LocaleCompare("paint",option+1) == 0) |
| 2408 | { |
| 2409 | Image |
| 2410 | *paint_image; |
| 2411 | |
| 2412 | /* |
| 2413 | Oil paint image. |
| 2414 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2415 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2416 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2417 | paint_image=OilPaintImage(*image,geometry_info.rho,exception); |
| 2418 | if (paint_image == (Image *) NULL) |
| 2419 | break; |
| 2420 | *image=DestroyImage(*image); |
| 2421 | *image=paint_image; |
| 2422 | break; |
| 2423 | } |
| 2424 | if (LocaleCompare("pen",option+1) == 0) |
| 2425 | { |
| 2426 | if (*option == '+') |
| 2427 | { |
| 2428 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 2429 | break; |
| 2430 | } |
| 2431 | (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception); |
| 2432 | break; |
| 2433 | } |
| 2434 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2435 | { |
| 2436 | if (*option == '+') |
| 2437 | (void) ParseGeometry("12",&geometry_info); |
| 2438 | else |
| 2439 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2440 | draw_info->pointsize=geometry_info.rho; |
| 2441 | break; |
| 2442 | } |
| 2443 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2444 | { |
| 2445 | double |
| 2446 | angle; |
| 2447 | |
| 2448 | Image |
| 2449 | *polaroid_image; |
| 2450 | |
| 2451 | RandomInfo |
| 2452 | *random_info; |
| 2453 | |
| 2454 | /* |
| 2455 | Simulate a Polaroid picture. |
| 2456 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2457 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2458 | random_info=AcquireRandomInfo(); |
| 2459 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2460 | random_info=DestroyRandomInfo(random_info); |
| 2461 | if (*option == '-') |
| 2462 | { |
| 2463 | SetGeometryInfo(&geometry_info); |
| 2464 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2465 | angle=geometry_info.rho; |
| 2466 | } |
| 2467 | polaroid_image=PolaroidImage(*image,draw_info,angle,exception); |
| 2468 | if (polaroid_image == (Image *) NULL) |
| 2469 | break; |
| 2470 | *image=DestroyImage(*image); |
| 2471 | *image=polaroid_image; |
| 2472 | break; |
| 2473 | } |
| 2474 | if (LocaleCompare("posterize",option+1) == 0) |
| 2475 | { |
| 2476 | /* |
| 2477 | Posterize image. |
| 2478 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2479 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 2480 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2481 | quantize_info->dither); |
| 2482 | InheritException(exception,&(*image)->exception); |
| 2483 | break; |
| 2484 | } |
| 2485 | if (LocaleCompare("preview",option+1) == 0) |
| 2486 | { |
| 2487 | Image |
| 2488 | *preview_image; |
| 2489 | |
| 2490 | PreviewType |
| 2491 | preview_type; |
| 2492 | |
| 2493 | /* |
| 2494 | Preview image. |
| 2495 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2496 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2497 | if (*option == '+') |
| 2498 | preview_type=UndefinedPreview; |
| 2499 | else |
| 2500 | preview_type=(PreviewType) ParseMagickOption(MagickPreviewOptions, |
| 2501 | MagickFalse,argv[i+1]); |
| 2502 | preview_image=PreviewImage(*image,preview_type,exception); |
| 2503 | if (preview_image == (Image *) NULL) |
| 2504 | break; |
| 2505 | *image=DestroyImage(*image); |
| 2506 | *image=preview_image; |
| 2507 | break; |
| 2508 | } |
| 2509 | if (LocaleCompare("profile",option+1) == 0) |
| 2510 | { |
| 2511 | const char |
| 2512 | *name; |
| 2513 | |
| 2514 | const StringInfo |
| 2515 | *profile; |
| 2516 | |
| 2517 | Image |
| 2518 | *profile_image; |
| 2519 | |
| 2520 | ImageInfo |
| 2521 | *profile_info; |
| 2522 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2523 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2524 | if (*option == '+') |
| 2525 | { |
| 2526 | /* |
| 2527 | Remove a profile from the image. |
| 2528 | */ |
| 2529 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
| 2530 | NULL,0,MagickTrue); |
| 2531 | InheritException(exception,&(*image)->exception); |
| 2532 | break; |
| 2533 | } |
| 2534 | /* |
| 2535 | Associate a profile with the image. |
| 2536 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2537 | profile_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2538 | profile=GetImageProfile(*image,"iptc"); |
| 2539 | if (profile != (StringInfo *) NULL) |
| 2540 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2541 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2542 | profile_info=DestroyImageInfo(profile_info); |
| 2543 | if (profile_image == (Image *) NULL) |
| 2544 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2545 | StringInfo |
| 2546 | *profile; |
| 2547 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2548 | profile_info=CloneImageInfo(mogrify_info); |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2549 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2550 | MaxTextExtent); |
| 2551 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2552 | if (profile != (StringInfo *) NULL) |
| 2553 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2554 | (void) ProfileImage(*image,profile_info->magick, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2555 | GetStringInfoDatum(profile),(size_t) |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2556 | GetStringInfoLength(profile),MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2557 | profile=DestroyStringInfo(profile); |
| 2558 | } |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2559 | profile_info=DestroyImageInfo(profile_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2560 | break; |
| 2561 | } |
| 2562 | ResetImageProfileIterator(profile_image); |
| 2563 | name=GetNextImageProfile(profile_image); |
| 2564 | while (name != (const char *) NULL) |
| 2565 | { |
| 2566 | profile=GetImageProfile(profile_image,name); |
| 2567 | if (profile != (StringInfo *) NULL) |
| 2568 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2569 | (size_t) GetStringInfoLength(profile),MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2570 | name=GetNextImageProfile(profile_image); |
| 2571 | } |
| 2572 | profile_image=DestroyImage(profile_image); |
| 2573 | break; |
| 2574 | } |
| 2575 | break; |
| 2576 | } |
| 2577 | case 'q': |
| 2578 | { |
| 2579 | if (LocaleCompare("quantize",option+1) == 0) |
| 2580 | { |
| 2581 | if (*option == '+') |
| 2582 | { |
| 2583 | quantize_info->colorspace=UndefinedColorspace; |
| 2584 | break; |
| 2585 | } |
| 2586 | quantize_info->colorspace=(ColorspaceType) ParseMagickOption( |
| 2587 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2588 | break; |
| 2589 | } |
| 2590 | break; |
| 2591 | } |
| 2592 | case 'r': |
| 2593 | { |
| 2594 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2595 | { |
| 2596 | Image |
| 2597 | *blur_image; |
| 2598 | |
| 2599 | /* |
| 2600 | Radial blur image. |
| 2601 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2602 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | a5447be | 2010-01-11 00:20:51 +0000 | [diff] [blame] | 2603 | blur_image=RadialBlurImageChannel(*image,channel, |
| 2604 | StringToDouble(argv[i+1]),exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2605 | if (blur_image == (Image *) NULL) |
| 2606 | break; |
| 2607 | *image=DestroyImage(*image); |
| 2608 | *image=blur_image; |
| 2609 | break; |
| 2610 | } |
| 2611 | if (LocaleCompare("raise",option+1) == 0) |
| 2612 | { |
| 2613 | /* |
| 2614 | Surround image with a raise of solid color. |
| 2615 | */ |
| 2616 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2617 | if ((flags & SigmaValue) == 0) |
| 2618 | geometry.height=geometry.width; |
| 2619 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
| 2620 | MagickFalse); |
| 2621 | InheritException(exception,&(*image)->exception); |
| 2622 | break; |
| 2623 | } |
| 2624 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2625 | { |
| 2626 | /* |
| 2627 | Threshold image. |
| 2628 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2629 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2630 | (void) RandomThresholdImageChannel(*image,channel,argv[i+1], |
| 2631 | exception); |
| 2632 | break; |
| 2633 | } |
| 2634 | if (LocaleCompare("recolor",option+1) == 0) |
| 2635 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2636 | Image |
cristy | f055ae4 | 2010-04-02 23:01:38 +0000 | [diff] [blame] | 2637 | *color_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2638 | |
cristy | f055ae4 | 2010-04-02 23:01:38 +0000 | [diff] [blame] | 2639 | KernelInfo |
| 2640 | *kernel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2641 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2642 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f055ae4 | 2010-04-02 23:01:38 +0000 | [diff] [blame] | 2643 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2644 | if (kernel == (KernelInfo *) NULL) |
| 2645 | break; |
| 2646 | color_image=ColorMatrixImage(*image,kernel,exception); |
| 2647 | kernel=DestroyKernelInfo(kernel); |
| 2648 | if (color_image == (Image *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2649 | break; |
| 2650 | *image=DestroyImage(*image); |
cristy | f055ae4 | 2010-04-02 23:01:38 +0000 | [diff] [blame] | 2651 | *image=color_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2652 | break; |
| 2653 | } |
| 2654 | if (LocaleCompare("region",option+1) == 0) |
| 2655 | { |
| 2656 | Image |
| 2657 | *crop_image; |
| 2658 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2659 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2660 | if (region_image != (Image *) NULL) |
| 2661 | { |
| 2662 | /* |
| 2663 | Composite region. |
| 2664 | */ |
| 2665 | (void) CompositeImage(region_image,(*image)->matte != |
| 2666 | MagickFalse ? OverCompositeOp : CopyCompositeOp,*image, |
| 2667 | region_geometry.x,region_geometry.y); |
| 2668 | InheritException(exception,®ion_image->exception); |
| 2669 | *image=DestroyImage(*image); |
| 2670 | *image=region_image; |
| 2671 | } |
| 2672 | if (*option == '+') |
| 2673 | { |
| 2674 | if (region_image != (Image *) NULL) |
cristy | b0a6e43 | 2010-10-09 13:26:15 +0000 | [diff] [blame] | 2675 | region_image=(Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2676 | break; |
| 2677 | } |
| 2678 | /* |
| 2679 | Apply transformations to a selected region of the image. |
| 2680 | */ |
| 2681 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2682 | exception); |
| 2683 | crop_image=CropImage(*image,®ion_geometry,exception); |
| 2684 | if (crop_image == (Image *) NULL) |
| 2685 | break; |
| 2686 | region_image=(*image); |
| 2687 | *image=crop_image; |
| 2688 | break; |
| 2689 | } |
| 2690 | if (LocaleCompare("render",option+1) == 0) |
| 2691 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2692 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2693 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2694 | break; |
| 2695 | } |
| 2696 | if (LocaleCompare("remap",option+1) == 0) |
| 2697 | { |
| 2698 | Image |
| 2699 | *remap_image; |
| 2700 | |
| 2701 | /* |
| 2702 | Transform image colors to match this set of colors. |
| 2703 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2704 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2705 | if (*option == '+') |
| 2706 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2707 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2708 | if (remap_image == (Image *) NULL) |
| 2709 | break; |
| 2710 | (void) RemapImage(quantize_info,*image,remap_image); |
| 2711 | InheritException(exception,&(*image)->exception); |
| 2712 | remap_image=DestroyImage(remap_image); |
| 2713 | break; |
| 2714 | } |
| 2715 | if (LocaleCompare("repage",option+1) == 0) |
| 2716 | { |
| 2717 | if (*option == '+') |
| 2718 | { |
| 2719 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2720 | break; |
| 2721 | } |
| 2722 | (void) ResetImagePage(*image,argv[i+1]); |
| 2723 | InheritException(exception,&(*image)->exception); |
| 2724 | break; |
| 2725 | } |
| 2726 | if (LocaleCompare("resample",option+1) == 0) |
| 2727 | { |
| 2728 | Image |
| 2729 | *resample_image; |
| 2730 | |
| 2731 | /* |
| 2732 | Resample image. |
| 2733 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2734 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2735 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2736 | if ((flags & SigmaValue) == 0) |
| 2737 | geometry_info.sigma=geometry_info.rho; |
| 2738 | resample_image=ResampleImage(*image,geometry_info.rho, |
| 2739 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2740 | if (resample_image == (Image *) NULL) |
| 2741 | break; |
| 2742 | *image=DestroyImage(*image); |
| 2743 | *image=resample_image; |
| 2744 | break; |
| 2745 | } |
| 2746 | if (LocaleCompare("resize",option+1) == 0) |
| 2747 | { |
| 2748 | Image |
| 2749 | *resize_image; |
| 2750 | |
| 2751 | /* |
| 2752 | Resize image. |
| 2753 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2754 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2755 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2756 | resize_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2757 | (*image)->filter,(*image)->blur,exception); |
| 2758 | if (resize_image == (Image *) NULL) |
| 2759 | break; |
| 2760 | *image=DestroyImage(*image); |
| 2761 | *image=resize_image; |
| 2762 | break; |
| 2763 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2764 | if (LocaleCompare("roll",option+1) == 0) |
| 2765 | { |
| 2766 | Image |
| 2767 | *roll_image; |
| 2768 | |
| 2769 | /* |
| 2770 | Roll image. |
| 2771 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2772 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2773 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2774 | roll_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2775 | if (roll_image == (Image *) NULL) |
| 2776 | break; |
| 2777 | *image=DestroyImage(*image); |
| 2778 | *image=roll_image; |
| 2779 | break; |
| 2780 | } |
| 2781 | if (LocaleCompare("rotate",option+1) == 0) |
| 2782 | { |
| 2783 | char |
| 2784 | *geometry; |
| 2785 | |
| 2786 | Image |
| 2787 | *rotate_image; |
| 2788 | |
| 2789 | /* |
| 2790 | Check for conditional image rotation. |
| 2791 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2792 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2793 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2794 | if ((*image)->columns <= (*image)->rows) |
| 2795 | break; |
| 2796 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2797 | if ((*image)->columns >= (*image)->rows) |
| 2798 | break; |
| 2799 | /* |
| 2800 | Rotate image. |
| 2801 | */ |
| 2802 | geometry=ConstantString(argv[i+1]); |
| 2803 | (void) SubstituteString(&geometry,">",""); |
| 2804 | (void) SubstituteString(&geometry,"<",""); |
| 2805 | (void) ParseGeometry(geometry,&geometry_info); |
| 2806 | geometry=DestroyString(geometry); |
| 2807 | rotate_image=RotateImage(*image,geometry_info.rho,exception); |
| 2808 | if (rotate_image == (Image *) NULL) |
| 2809 | break; |
| 2810 | *image=DestroyImage(*image); |
| 2811 | *image=rotate_image; |
| 2812 | break; |
| 2813 | } |
| 2814 | break; |
| 2815 | } |
| 2816 | case 's': |
| 2817 | { |
| 2818 | if (LocaleCompare("sample",option+1) == 0) |
| 2819 | { |
| 2820 | Image |
| 2821 | *sample_image; |
| 2822 | |
| 2823 | /* |
| 2824 | Sample image with pixel replication. |
| 2825 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2826 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2827 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2828 | sample_image=SampleImage(*image,geometry.width,geometry.height, |
| 2829 | exception); |
| 2830 | if (sample_image == (Image *) NULL) |
| 2831 | break; |
| 2832 | *image=DestroyImage(*image); |
| 2833 | *image=sample_image; |
| 2834 | break; |
| 2835 | } |
| 2836 | if (LocaleCompare("scale",option+1) == 0) |
| 2837 | { |
| 2838 | Image |
| 2839 | *scale_image; |
| 2840 | |
| 2841 | /* |
| 2842 | Resize image. |
| 2843 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2844 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2845 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2846 | scale_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2847 | exception); |
| 2848 | if (scale_image == (Image *) NULL) |
| 2849 | break; |
| 2850 | *image=DestroyImage(*image); |
| 2851 | *image=scale_image; |
| 2852 | break; |
| 2853 | } |
| 2854 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2855 | { |
| 2856 | Image |
| 2857 | *blur_image; |
| 2858 | |
| 2859 | /* |
| 2860 | Selectively blur pixels within a contrast threshold. |
| 2861 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2862 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2863 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2864 | if ((flags & PercentValue) != 0) |
| 2865 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 2866 | blur_image=SelectiveBlurImageChannel(*image,channel, |
| 2867 | geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception); |
| 2868 | if (blur_image == (Image *) NULL) |
| 2869 | break; |
| 2870 | *image=DestroyImage(*image); |
| 2871 | *image=blur_image; |
| 2872 | break; |
| 2873 | } |
| 2874 | if (LocaleCompare("separate",option+1) == 0) |
| 2875 | { |
| 2876 | Image |
| 2877 | *separate_images; |
| 2878 | |
| 2879 | /* |
| 2880 | Break channels into separate images. |
| 2881 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2882 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2883 | separate_images=SeparateImages(*image,channel,exception); |
| 2884 | if (separate_images == (Image *) NULL) |
| 2885 | break; |
| 2886 | *image=DestroyImage(*image); |
| 2887 | *image=separate_images; |
| 2888 | break; |
| 2889 | } |
| 2890 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2891 | { |
| 2892 | double |
| 2893 | threshold; |
| 2894 | |
| 2895 | Image |
| 2896 | *sepia_image; |
| 2897 | |
| 2898 | /* |
| 2899 | Sepia-tone image. |
| 2900 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2901 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 2902 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2903 | sepia_image=SepiaToneImage(*image,threshold,exception); |
| 2904 | if (sepia_image == (Image *) NULL) |
| 2905 | break; |
| 2906 | *image=DestroyImage(*image); |
| 2907 | *image=sepia_image; |
| 2908 | break; |
| 2909 | } |
| 2910 | if (LocaleCompare("segment",option+1) == 0) |
| 2911 | { |
| 2912 | /* |
| 2913 | Segment image. |
| 2914 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2915 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2916 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2917 | if ((flags & SigmaValue) == 0) |
| 2918 | geometry_info.sigma=1.0; |
cristy | 7e6164a | 2010-07-22 20:43:57 +0000 | [diff] [blame] | 2919 | (void) SegmentImage(*image,(*image)->colorspace, |
| 2920 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2921 | InheritException(exception,&(*image)->exception); |
| 2922 | break; |
| 2923 | } |
| 2924 | if (LocaleCompare("set",option+1) == 0) |
| 2925 | { |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2926 | char |
| 2927 | *value; |
| 2928 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2929 | /* |
| 2930 | Set image option. |
| 2931 | */ |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2932 | if (*option == '+') |
| 2933 | { |
| 2934 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2935 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2936 | else |
| 2937 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
cristy | 7e10958 | 2010-06-01 12:56:44 +0000 | [diff] [blame] | 2938 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2939 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
cristy | 7e10958 | 2010-06-01 12:56:44 +0000 | [diff] [blame] | 2940 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2941 | } |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2942 | else |
| 2943 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2944 | break; |
| 2945 | } |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2946 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2947 | if (value == (char *) NULL) |
| 2948 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2949 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2950 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2951 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2952 | else |
| 2953 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2954 | { |
cristy | 7f02ba1 | 2010-09-21 12:39:28 +0000 | [diff] [blame] | 2955 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2956 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2957 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2958 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2959 | else |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2960 | (void) SetImageProperty(*image,argv[i+1],value); |
| 2961 | value=DestroyString(value); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2962 | break; |
| 2963 | } |
| 2964 | if (LocaleCompare("shade",option+1) == 0) |
| 2965 | { |
| 2966 | Image |
| 2967 | *shade_image; |
| 2968 | |
| 2969 | /* |
| 2970 | Shade image. |
| 2971 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2972 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2973 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2974 | if ((flags & SigmaValue) == 0) |
| 2975 | geometry_info.sigma=1.0; |
| 2976 | shade_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2977 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2978 | if (shade_image == (Image *) NULL) |
| 2979 | break; |
| 2980 | *image=DestroyImage(*image); |
| 2981 | *image=shade_image; |
| 2982 | break; |
| 2983 | } |
| 2984 | if (LocaleCompare("shadow",option+1) == 0) |
| 2985 | { |
| 2986 | Image |
| 2987 | *shadow_image; |
| 2988 | |
| 2989 | /* |
| 2990 | Shadow image. |
| 2991 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2992 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2993 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2994 | if ((flags & SigmaValue) == 0) |
| 2995 | geometry_info.sigma=1.0; |
| 2996 | if ((flags & XiValue) == 0) |
| 2997 | geometry_info.xi=4.0; |
| 2998 | if ((flags & PsiValue) == 0) |
| 2999 | geometry_info.psi=4.0; |
| 3000 | shadow_image=ShadowImage(*image,geometry_info.rho, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3001 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
cristy | 0534a6b | 2010-03-18 01:19:38 +0000 | [diff] [blame] | 3002 | ceil(geometry_info.psi-0.5),exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3003 | if (shadow_image == (Image *) NULL) |
| 3004 | break; |
| 3005 | *image=DestroyImage(*image); |
| 3006 | *image=shadow_image; |
| 3007 | break; |
| 3008 | } |
| 3009 | if (LocaleCompare("sharpen",option+1) == 0) |
| 3010 | { |
| 3011 | Image |
| 3012 | *sharp_image; |
| 3013 | |
| 3014 | /* |
| 3015 | Sharpen image. |
| 3016 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3017 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3018 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3019 | if ((flags & SigmaValue) == 0) |
| 3020 | geometry_info.sigma=1.0; |
| 3021 | sharp_image=SharpenImageChannel(*image,channel,geometry_info.rho, |
| 3022 | geometry_info.sigma,exception); |
| 3023 | if (sharp_image == (Image *) NULL) |
| 3024 | break; |
| 3025 | *image=DestroyImage(*image); |
| 3026 | *image=sharp_image; |
| 3027 | break; |
| 3028 | } |
| 3029 | if (LocaleCompare("shave",option+1) == 0) |
| 3030 | { |
| 3031 | Image |
| 3032 | *shave_image; |
| 3033 | |
| 3034 | /* |
| 3035 | Shave the image edges. |
| 3036 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3037 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3038 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 3039 | shave_image=ShaveImage(*image,&geometry,exception); |
| 3040 | if (shave_image == (Image *) NULL) |
| 3041 | break; |
| 3042 | *image=DestroyImage(*image); |
| 3043 | *image=shave_image; |
| 3044 | break; |
| 3045 | } |
| 3046 | if (LocaleCompare("shear",option+1) == 0) |
| 3047 | { |
| 3048 | Image |
| 3049 | *shear_image; |
| 3050 | |
| 3051 | /* |
| 3052 | Shear image. |
| 3053 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3054 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3055 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3056 | if ((flags & SigmaValue) == 0) |
| 3057 | geometry_info.sigma=geometry_info.rho; |
| 3058 | shear_image=ShearImage(*image,geometry_info.rho,geometry_info.sigma, |
| 3059 | exception); |
| 3060 | if (shear_image == (Image *) NULL) |
| 3061 | break; |
| 3062 | *image=DestroyImage(*image); |
| 3063 | *image=shear_image; |
| 3064 | break; |
| 3065 | } |
| 3066 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 3067 | { |
| 3068 | /* |
| 3069 | Sigmoidal non-linearity contrast control. |
| 3070 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3071 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3072 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3073 | if ((flags & SigmaValue) == 0) |
| 3074 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 3075 | if ((flags & PercentValue) != 0) |
| 3076 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 3077 | 100.0; |
| 3078 | (void) SigmoidalContrastImageChannel(*image,channel, |
| 3079 | (*option == '-') ? MagickTrue : MagickFalse,geometry_info.rho, |
| 3080 | geometry_info.sigma); |
| 3081 | InheritException(exception,&(*image)->exception); |
| 3082 | break; |
| 3083 | } |
| 3084 | if (LocaleCompare("sketch",option+1) == 0) |
| 3085 | { |
| 3086 | Image |
| 3087 | *sketch_image; |
| 3088 | |
| 3089 | /* |
| 3090 | Sketch image. |
| 3091 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3092 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3093 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3094 | if ((flags & SigmaValue) == 0) |
| 3095 | geometry_info.sigma=1.0; |
| 3096 | sketch_image=SketchImage(*image,geometry_info.rho, |
| 3097 | geometry_info.sigma,geometry_info.xi,exception); |
| 3098 | if (sketch_image == (Image *) NULL) |
| 3099 | break; |
| 3100 | *image=DestroyImage(*image); |
| 3101 | *image=sketch_image; |
| 3102 | break; |
| 3103 | } |
| 3104 | if (LocaleCompare("solarize",option+1) == 0) |
| 3105 | { |
| 3106 | double |
| 3107 | threshold; |
| 3108 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3109 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 3110 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3111 | (void) SolarizeImage(*image,threshold); |
| 3112 | InheritException(exception,&(*image)->exception); |
| 3113 | break; |
| 3114 | } |
| 3115 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 3116 | { |
| 3117 | Image |
| 3118 | *sparse_image; |
| 3119 | |
| 3120 | SparseColorMethod |
| 3121 | method; |
| 3122 | |
| 3123 | char |
| 3124 | *arguments; |
| 3125 | |
| 3126 | /* |
| 3127 | Sparse Color Interpolated Gradient |
| 3128 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3129 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3130 | method=(SparseColorMethod) ParseMagickOption( |
| 3131 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3132 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3133 | InheritException(exception,&(*image)->exception); |
| 3134 | if (arguments == (char *) NULL) |
| 3135 | break; |
| 3136 | sparse_image=SparseColorOption(*image,channel,method,arguments, |
| 3137 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 3138 | arguments=DestroyString(arguments); |
| 3139 | if (sparse_image == (Image *) NULL) |
| 3140 | break; |
| 3141 | *image=DestroyImage(*image); |
| 3142 | *image=sparse_image; |
| 3143 | break; |
| 3144 | } |
| 3145 | if (LocaleCompare("splice",option+1) == 0) |
| 3146 | { |
| 3147 | Image |
| 3148 | *splice_image; |
| 3149 | |
| 3150 | /* |
| 3151 | Splice a solid color into the image. |
| 3152 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3153 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3154 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 3155 | splice_image=SpliceImage(*image,&geometry,exception); |
| 3156 | if (splice_image == (Image *) NULL) |
| 3157 | break; |
| 3158 | *image=DestroyImage(*image); |
| 3159 | *image=splice_image; |
| 3160 | break; |
| 3161 | } |
| 3162 | if (LocaleCompare("spread",option+1) == 0) |
| 3163 | { |
| 3164 | Image |
| 3165 | *spread_image; |
| 3166 | |
| 3167 | /* |
| 3168 | Spread an image. |
| 3169 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3170 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3171 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 3172 | spread_image=SpreadImage(*image,geometry_info.rho,exception); |
| 3173 | if (spread_image == (Image *) NULL) |
| 3174 | break; |
| 3175 | *image=DestroyImage(*image); |
| 3176 | *image=spread_image; |
| 3177 | break; |
| 3178 | } |
| 3179 | if (LocaleCompare("stretch",option+1) == 0) |
| 3180 | { |
| 3181 | if (*option == '+') |
| 3182 | { |
| 3183 | draw_info->stretch=UndefinedStretch; |
| 3184 | break; |
| 3185 | } |
| 3186 | draw_info->stretch=(StretchType) ParseMagickOption( |
| 3187 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 3188 | break; |
| 3189 | } |
| 3190 | if (LocaleCompare("strip",option+1) == 0) |
| 3191 | { |
| 3192 | /* |
| 3193 | Strip image of profiles and comments. |
| 3194 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3195 | (void) SyncImageSettings(mogrify_info,*image); |
glennrp | 3dae5ae | 2010-12-23 22:42:52 +0000 | [diff] [blame] | 3196 | (void) StripImage(*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3197 | InheritException(exception,&(*image)->exception); |
| 3198 | break; |
| 3199 | } |
| 3200 | if (LocaleCompare("stroke",option+1) == 0) |
| 3201 | { |
| 3202 | ExceptionInfo |
| 3203 | *sans; |
| 3204 | |
| 3205 | if (*option == '+') |
| 3206 | { |
| 3207 | (void) QueryColorDatabase("none",&draw_info->stroke,exception); |
| 3208 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 3209 | draw_info->stroke_pattern=DestroyImage( |
| 3210 | draw_info->stroke_pattern); |
| 3211 | break; |
| 3212 | } |
| 3213 | sans=AcquireExceptionInfo(); |
| 3214 | status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans); |
| 3215 | sans=DestroyExceptionInfo(sans); |
| 3216 | if (status == MagickFalse) |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3217 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3218 | exception); |
| 3219 | break; |
| 3220 | } |
| 3221 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 3222 | { |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 3223 | draw_info->stroke_width=StringToDouble(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3224 | break; |
| 3225 | } |
| 3226 | if (LocaleCompare("style",option+1) == 0) |
| 3227 | { |
| 3228 | if (*option == '+') |
| 3229 | { |
| 3230 | draw_info->style=UndefinedStyle; |
| 3231 | break; |
| 3232 | } |
| 3233 | draw_info->style=(StyleType) ParseMagickOption(MagickStyleOptions, |
| 3234 | MagickFalse,argv[i+1]); |
| 3235 | break; |
| 3236 | } |
| 3237 | if (LocaleCompare("swirl",option+1) == 0) |
| 3238 | { |
| 3239 | Image |
| 3240 | *swirl_image; |
| 3241 | |
| 3242 | /* |
| 3243 | Swirl image. |
| 3244 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3245 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3246 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 3247 | swirl_image=SwirlImage(*image,geometry_info.rho,exception); |
| 3248 | if (swirl_image == (Image *) NULL) |
| 3249 | break; |
| 3250 | *image=DestroyImage(*image); |
| 3251 | *image=swirl_image; |
| 3252 | break; |
| 3253 | } |
| 3254 | break; |
| 3255 | } |
| 3256 | case 't': |
| 3257 | { |
| 3258 | if (LocaleCompare("threshold",option+1) == 0) |
| 3259 | { |
| 3260 | double |
| 3261 | threshold; |
| 3262 | |
| 3263 | /* |
| 3264 | Threshold image. |
| 3265 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3266 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3267 | if (*option == '+') |
| 3268 | threshold=(double) QuantumRange/2.5; |
| 3269 | else |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 3270 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3271 | (void) BilevelImageChannel(*image,channel,threshold); |
| 3272 | InheritException(exception,&(*image)->exception); |
| 3273 | break; |
| 3274 | } |
| 3275 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 3276 | { |
| 3277 | Image |
| 3278 | *thumbnail_image; |
| 3279 | |
| 3280 | /* |
| 3281 | Thumbnail image. |
| 3282 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3283 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3284 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 3285 | thumbnail_image=ThumbnailImage(*image,geometry.width, |
| 3286 | geometry.height,exception); |
| 3287 | if (thumbnail_image == (Image *) NULL) |
| 3288 | break; |
| 3289 | *image=DestroyImage(*image); |
| 3290 | *image=thumbnail_image; |
| 3291 | break; |
| 3292 | } |
| 3293 | if (LocaleCompare("tile",option+1) == 0) |
| 3294 | { |
| 3295 | if (*option == '+') |
| 3296 | { |
| 3297 | if (draw_info->fill_pattern != (Image *) NULL) |
| 3298 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 3299 | break; |
| 3300 | } |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3301 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3302 | exception); |
| 3303 | break; |
| 3304 | } |
| 3305 | if (LocaleCompare("tint",option+1) == 0) |
| 3306 | { |
| 3307 | Image |
| 3308 | *tint_image; |
| 3309 | |
| 3310 | /* |
| 3311 | Tint the image. |
| 3312 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3313 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3314 | tint_image=TintImage(*image,argv[i+1],draw_info->fill,exception); |
| 3315 | if (tint_image == (Image *) NULL) |
| 3316 | break; |
| 3317 | *image=DestroyImage(*image); |
| 3318 | *image=tint_image; |
| 3319 | break; |
| 3320 | } |
| 3321 | if (LocaleCompare("transform",option+1) == 0) |
| 3322 | { |
| 3323 | Image |
| 3324 | *transform_image; |
| 3325 | |
| 3326 | /* |
| 3327 | Affine transform image. |
| 3328 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3329 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3330 | transform_image=AffineTransformImage(*image,&draw_info->affine, |
| 3331 | exception); |
| 3332 | if (transform_image == (Image *) NULL) |
| 3333 | break; |
| 3334 | *image=DestroyImage(*image); |
| 3335 | *image=transform_image; |
| 3336 | break; |
| 3337 | } |
| 3338 | if (LocaleCompare("transparent",option+1) == 0) |
| 3339 | { |
| 3340 | MagickPixelPacket |
| 3341 | target; |
| 3342 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3343 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3344 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 3345 | (void) TransparentPaintImage(*image,&target,(Quantum) |
| 3346 | TransparentOpacity,*option == '-' ? MagickFalse : MagickTrue); |
| 3347 | InheritException(exception,&(*image)->exception); |
| 3348 | break; |
| 3349 | } |
| 3350 | if (LocaleCompare("transpose",option+1) == 0) |
| 3351 | { |
| 3352 | Image |
| 3353 | *transpose_image; |
| 3354 | |
| 3355 | /* |
| 3356 | Transpose image scanlines. |
| 3357 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3358 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3359 | transpose_image=TransposeImage(*image,exception); |
| 3360 | if (transpose_image == (Image *) NULL) |
| 3361 | break; |
| 3362 | *image=DestroyImage(*image); |
| 3363 | *image=transpose_image; |
| 3364 | break; |
| 3365 | } |
| 3366 | if (LocaleCompare("transverse",option+1) == 0) |
| 3367 | { |
| 3368 | Image |
| 3369 | *transverse_image; |
| 3370 | |
| 3371 | /* |
| 3372 | Transverse image scanlines. |
| 3373 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3374 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3375 | transverse_image=TransverseImage(*image,exception); |
| 3376 | if (transverse_image == (Image *) NULL) |
| 3377 | break; |
| 3378 | *image=DestroyImage(*image); |
| 3379 | *image=transverse_image; |
| 3380 | break; |
| 3381 | } |
| 3382 | if (LocaleCompare("treedepth",option+1) == 0) |
| 3383 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 3384 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3385 | break; |
| 3386 | } |
| 3387 | if (LocaleCompare("trim",option+1) == 0) |
| 3388 | { |
| 3389 | Image |
| 3390 | *trim_image; |
| 3391 | |
| 3392 | /* |
| 3393 | Trim image. |
| 3394 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3395 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3396 | trim_image=TrimImage(*image,exception); |
| 3397 | if (trim_image == (Image *) NULL) |
| 3398 | break; |
| 3399 | *image=DestroyImage(*image); |
| 3400 | *image=trim_image; |
| 3401 | break; |
| 3402 | } |
| 3403 | if (LocaleCompare("type",option+1) == 0) |
| 3404 | { |
| 3405 | ImageType |
| 3406 | type; |
| 3407 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3408 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3409 | if (*option == '+') |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 3410 | type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3411 | else |
| 3412 | type=(ImageType) ParseMagickOption(MagickTypeOptions,MagickFalse, |
| 3413 | argv[i+1]); |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 3414 | (*image)->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3415 | (void) SetImageType(*image,type); |
| 3416 | InheritException(exception,&(*image)->exception); |
| 3417 | break; |
| 3418 | } |
| 3419 | break; |
| 3420 | } |
| 3421 | case 'u': |
| 3422 | { |
| 3423 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3424 | { |
| 3425 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 3426 | exception); |
| 3427 | break; |
| 3428 | } |
cristy | 045bd90 | 2010-01-30 18:56:24 +0000 | [diff] [blame] | 3429 | if (LocaleCompare("unique",option+1) == 0) |
| 3430 | { |
| 3431 | if (*option == '+') |
| 3432 | { |
cristy | 83fae87 | 2010-04-22 15:04:16 +0000 | [diff] [blame] | 3433 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
cristy | 045bd90 | 2010-01-30 18:56:24 +0000 | [diff] [blame] | 3434 | break; |
| 3435 | } |
cristy | 83fae87 | 2010-04-22 15:04:16 +0000 | [diff] [blame] | 3436 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
cristy | a01cbea | 2010-11-03 16:33:33 +0000 | [diff] [blame] | 3437 | (void) SetImageArtifact(*image,"verbose","true"); |
cristy | 045bd90 | 2010-01-30 18:56:24 +0000 | [diff] [blame] | 3438 | break; |
| 3439 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3440 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3441 | { |
| 3442 | Image |
| 3443 | *unique_image; |
| 3444 | |
| 3445 | /* |
| 3446 | Unique image colors. |
| 3447 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3448 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3449 | unique_image=UniqueImageColors(*image,exception); |
| 3450 | if (unique_image == (Image *) NULL) |
| 3451 | break; |
| 3452 | *image=DestroyImage(*image); |
| 3453 | *image=unique_image; |
| 3454 | break; |
| 3455 | } |
| 3456 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3457 | { |
| 3458 | Image |
| 3459 | *unsharp_image; |
| 3460 | |
| 3461 | /* |
| 3462 | Unsharp mask image. |
| 3463 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3464 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3465 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3466 | if ((flags & SigmaValue) == 0) |
| 3467 | geometry_info.sigma=1.0; |
| 3468 | if ((flags & XiValue) == 0) |
| 3469 | geometry_info.xi=1.0; |
| 3470 | if ((flags & PsiValue) == 0) |
| 3471 | geometry_info.psi=0.05; |
| 3472 | unsharp_image=UnsharpMaskImageChannel(*image,channel, |
| 3473 | geometry_info.rho,geometry_info.sigma,geometry_info.xi, |
| 3474 | geometry_info.psi,exception); |
| 3475 | if (unsharp_image == (Image *) NULL) |
| 3476 | break; |
| 3477 | *image=DestroyImage(*image); |
| 3478 | *image=unsharp_image; |
| 3479 | break; |
| 3480 | } |
| 3481 | break; |
| 3482 | } |
| 3483 | case 'v': |
| 3484 | { |
| 3485 | if (LocaleCompare("verbose",option+1) == 0) |
| 3486 | { |
| 3487 | (void) SetImageArtifact(*image,option+1, |
| 3488 | *option == '+' ? "false" : "true"); |
| 3489 | break; |
| 3490 | } |
| 3491 | if (LocaleCompare("vignette",option+1) == 0) |
| 3492 | { |
| 3493 | Image |
| 3494 | *vignette_image; |
| 3495 | |
| 3496 | /* |
| 3497 | Vignette image. |
| 3498 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3499 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3500 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3501 | if ((flags & SigmaValue) == 0) |
| 3502 | geometry_info.sigma=1.0; |
| 3503 | if ((flags & XiValue) == 0) |
| 3504 | geometry_info.xi=0.1*(*image)->columns; |
| 3505 | if ((flags & PsiValue) == 0) |
| 3506 | geometry_info.psi=0.1*(*image)->rows; |
| 3507 | vignette_image=VignetteImage(*image,geometry_info.rho, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3508 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
cristy | 0534a6b | 2010-03-18 01:19:38 +0000 | [diff] [blame] | 3509 | ceil(geometry_info.psi-0.5),exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3510 | if (vignette_image == (Image *) NULL) |
| 3511 | break; |
| 3512 | *image=DestroyImage(*image); |
| 3513 | *image=vignette_image; |
| 3514 | break; |
| 3515 | } |
| 3516 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3517 | { |
| 3518 | if (*option == '+') |
| 3519 | { |
| 3520 | (void) SetImageVirtualPixelMethod(*image, |
| 3521 | UndefinedVirtualPixelMethod); |
| 3522 | break; |
| 3523 | } |
| 3524 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3525 | ParseMagickOption(MagickVirtualPixelOptions,MagickFalse, |
| 3526 | argv[i+1])); |
| 3527 | break; |
| 3528 | } |
| 3529 | break; |
| 3530 | } |
| 3531 | case 'w': |
| 3532 | { |
| 3533 | if (LocaleCompare("wave",option+1) == 0) |
| 3534 | { |
| 3535 | Image |
| 3536 | *wave_image; |
| 3537 | |
| 3538 | /* |
| 3539 | Wave image. |
| 3540 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3541 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3542 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3543 | if ((flags & SigmaValue) == 0) |
| 3544 | geometry_info.sigma=1.0; |
| 3545 | wave_image=WaveImage(*image,geometry_info.rho,geometry_info.sigma, |
| 3546 | exception); |
| 3547 | if (wave_image == (Image *) NULL) |
| 3548 | break; |
| 3549 | *image=DestroyImage(*image); |
| 3550 | *image=wave_image; |
| 3551 | break; |
| 3552 | } |
| 3553 | if (LocaleCompare("weight",option+1) == 0) |
| 3554 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 3555 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3556 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3557 | draw_info->weight=0; |
| 3558 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3559 | draw_info->weight=700; |
| 3560 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3561 | if (draw_info->weight <= 800) |
| 3562 | draw_info->weight+=100; |
| 3563 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3564 | if (draw_info->weight >= 100) |
| 3565 | draw_info->weight-=100; |
| 3566 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3567 | draw_info->weight=400; |
| 3568 | break; |
| 3569 | } |
| 3570 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3571 | { |
| 3572 | /* |
| 3573 | White threshold image. |
| 3574 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3575 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3576 | (void) WhiteThresholdImageChannel(*image,channel,argv[i+1], |
| 3577 | exception); |
| 3578 | InheritException(exception,&(*image)->exception); |
| 3579 | break; |
| 3580 | } |
| 3581 | break; |
| 3582 | } |
| 3583 | default: |
| 3584 | break; |
| 3585 | } |
| 3586 | i+=count; |
| 3587 | } |
| 3588 | if (region_image != (Image *) NULL) |
| 3589 | { |
| 3590 | /* |
| 3591 | Composite transformed region onto image. |
| 3592 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3593 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3594 | (void) CompositeImage(region_image,(*image)->matte != MagickFalse ? |
| 3595 | OverCompositeOp : CopyCompositeOp,*image,region_geometry.x, |
| 3596 | region_geometry.y); |
| 3597 | InheritException(exception,®ion_image->exception); |
| 3598 | *image=DestroyImage(*image); |
| 3599 | *image=region_image; |
| 3600 | } |
| 3601 | /* |
| 3602 | Free resources. |
| 3603 | */ |
| 3604 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3605 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3606 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 3607 | status=(*image)->exception.severity == UndefinedException ? MagickTrue : |
| 3608 | MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3609 | return(status); |
| 3610 | } |
| 3611 | |
| 3612 | /* |
| 3613 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3614 | % % |
| 3615 | % % |
| 3616 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3617 | + 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] | 3618 | % % |
| 3619 | % % |
| 3620 | % % |
| 3621 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3622 | % |
| 3623 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3624 | % transforms include image scaling, image rotation, color reduction, and |
| 3625 | % others. The transmogrified image overwrites the original image. |
| 3626 | % |
| 3627 | % The format of the MogrifyImageCommand method is: |
| 3628 | % |
| 3629 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3630 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3631 | % |
| 3632 | % A description of each parameter follows: |
| 3633 | % |
| 3634 | % o image_info: the image info. |
| 3635 | % |
| 3636 | % o argc: the number of elements in the argument vector. |
| 3637 | % |
| 3638 | % o argv: A text array containing the command line arguments. |
| 3639 | % |
| 3640 | % o metadata: any metadata is returned here. |
| 3641 | % |
| 3642 | % o exception: return any errors or warnings in this structure. |
| 3643 | % |
| 3644 | */ |
| 3645 | |
| 3646 | static MagickBooleanType MogrifyUsage(void) |
| 3647 | { |
| 3648 | static const char |
| 3649 | *miscellaneous[]= |
| 3650 | { |
| 3651 | "-debug events display copious debugging information", |
| 3652 | "-help print program options", |
| 3653 | "-list type print a list of supported option arguments", |
| 3654 | "-log format format of debugging information", |
| 3655 | "-version print version information", |
| 3656 | (char *) NULL |
| 3657 | }, |
| 3658 | *operators[]= |
| 3659 | { |
| 3660 | "-adaptive-blur geometry", |
| 3661 | " adaptively blur pixels; decrease effect near edges", |
| 3662 | "-adaptive-resize geometry", |
| 3663 | " adaptively resize image using 'mesh' interpolation", |
| 3664 | "-adaptive-sharpen geometry", |
| 3665 | " adaptively sharpen pixels; increase effect near edges", |
| 3666 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3667 | " transparent, extract, background, or shape", |
| 3668 | "-annotate geometry text", |
| 3669 | " annotate the image with text", |
| 3670 | "-auto-gamma automagically adjust gamma level of image", |
| 3671 | "-auto-level automagically adjust color levels of image", |
| 3672 | "-auto-orient automagically orient (rotate) image", |
| 3673 | "-bench iterations measure performance", |
| 3674 | "-black-threshold value", |
| 3675 | " force all pixels below the threshold into black", |
| 3676 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3677 | "-blur geometry reduce image noise and reduce detail levels", |
| 3678 | "-border geometry surround image with a border of color", |
| 3679 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3680 | "-brightness-contrast geometry", |
| 3681 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3682 | "-cdl filename color correct with a color decision list", |
| 3683 | "-charcoal radius simulate a charcoal drawing", |
| 3684 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3685 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3686 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3687 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3688 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3689 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3690 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3691 | "-contrast enhance or reduce the image contrast", |
| 3692 | "-contrast-stretch geometry", |
| 3693 | " improve contrast by `stretching' the intensity range", |
| 3694 | "-convolve coefficients", |
| 3695 | " apply a convolution kernel to the image", |
| 3696 | "-cycle amount cycle the image colormap", |
| 3697 | "-decipher filename convert cipher pixels to plain pixels", |
| 3698 | "-deskew threshold straighten an image", |
| 3699 | "-despeckle reduce the speckles within an image", |
| 3700 | "-distort method args", |
| 3701 | " distort images according to given method ad args", |
| 3702 | "-draw string annotate the image with a graphic primitive", |
| 3703 | "-edge radius apply a filter to detect edges in the image", |
| 3704 | "-encipher filename convert plain pixels to cipher pixels", |
| 3705 | "-emboss radius emboss an image", |
| 3706 | "-enhance apply a digital filter to enhance a noisy image", |
| 3707 | "-equalize perform histogram equalization to an image", |
| 3708 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3709 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3710 | "-extent geometry set the image size", |
| 3711 | "-extract geometry extract area from image", |
| 3712 | "-fft implements the discrete Fourier transform (DFT)", |
| 3713 | "-flip flip image vertically", |
| 3714 | "-floodfill geometry color", |
| 3715 | " floodfill the image with color", |
| 3716 | "-flop flop image horizontally", |
| 3717 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3718 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3719 | " apply function over image values", |
| 3720 | "-gamma value level of gamma correction", |
| 3721 | "-gaussian-blur geometry", |
| 3722 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3723 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3724 | "-identify identify the format and characteristics of the image", |
| 3725 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3726 | "-implode amount implode image pixels about the center", |
| 3727 | "-lat geometry local adaptive thresholding", |
| 3728 | "-layers method optimize, merge, or compare image layers", |
| 3729 | "-level value adjust the level of image contrast", |
| 3730 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3731 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3732 | "-linear-stretch geometry", |
| 3733 | " improve contrast by `stretching with saturation'", |
| 3734 | "-liquid-rescale geometry", |
| 3735 | " rescale image with seam-carving", |
| 3736 | "-median radius apply a median filter to the image", |
| 3737 | "-modulate value vary the brightness, saturation, and hue", |
| 3738 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3739 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3740 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3741 | "-motion-blur geometry", |
| 3742 | " simulate motion blur", |
| 3743 | "-negate replace every pixel with its complementary color ", |
| 3744 | "-noise radius add or reduce noise in an image", |
| 3745 | "-normalize transform image to span the full range of colors", |
| 3746 | "-opaque color change this color to the fill color", |
| 3747 | "-ordered-dither NxN", |
| 3748 | " add a noise pattern to the image with specific", |
| 3749 | " amplitudes", |
| 3750 | "-paint radius simulate an oil painting", |
| 3751 | "-polaroid angle simulate a Polaroid picture", |
| 3752 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3753 | "-profile filename add, delete, or apply an image profile", |
| 3754 | "-quantize colorspace reduce colors in this colorspace", |
| 3755 | "-radial-blur angle radial blur the image", |
| 3756 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3757 | "-random-threshold low,high", |
| 3758 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3759 | "-region geometry apply options to a portion of the image", |
| 3760 | "-render render vector graphics", |
| 3761 | "-repage geometry size and location of an image canvas", |
| 3762 | "-resample geometry change the resolution of an image", |
| 3763 | "-resize geometry resize the image", |
| 3764 | "-roll geometry roll an image vertically or horizontally", |
| 3765 | "-rotate degrees apply Paeth rotation to the image", |
| 3766 | "-sample geometry scale image with pixel sampling", |
| 3767 | "-scale geometry scale the image", |
| 3768 | "-segment values segment an image", |
| 3769 | "-selective-blur geometry", |
| 3770 | " selectively blur pixels within a contrast threshold", |
| 3771 | "-sepia-tone threshold", |
| 3772 | " simulate a sepia-toned photo", |
| 3773 | "-set property value set an image property", |
| 3774 | "-shade degrees shade the image using a distant light source", |
| 3775 | "-shadow geometry simulate an image shadow", |
| 3776 | "-sharpen geometry sharpen the image", |
| 3777 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3778 | "-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] | 3779 | "-sigmoidal-contrast geometry", |
| 3780 | " increase the contrast without saturating highlights or shadows", |
| 3781 | "-sketch geometry simulate a pencil sketch", |
| 3782 | "-solarize threshold negate all pixels above the threshold level", |
| 3783 | "-sparse-color method args", |
| 3784 | " fill in a image based on a few color points", |
| 3785 | "-splice geometry splice the background color into the image", |
| 3786 | "-spread radius displace image pixels by a random amount", |
| 3787 | "-strip strip image of all profiles and comments", |
| 3788 | "-swirl degrees swirl image pixels about the center", |
| 3789 | "-threshold value threshold the image", |
| 3790 | "-thumbnail geometry create a thumbnail of the image", |
| 3791 | "-tile filename tile image when filling a graphic primitive", |
| 3792 | "-tint value tint the image with the fill color", |
| 3793 | "-transform affine transform image", |
| 3794 | "-transparent color make this color transparent within the image", |
| 3795 | "-transpose flip image vertically and rotate 90 degrees", |
| 3796 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3797 | "-trim trim image edges", |
| 3798 | "-type type image type", |
| 3799 | "-unique-colors discard all but one of any pixel color", |
| 3800 | "-unsharp geometry sharpen the image", |
| 3801 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3802 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3803 | "-white-threshold value", |
| 3804 | " force all pixels above the threshold into white", |
| 3805 | (char *) NULL |
| 3806 | }, |
| 3807 | *sequence_operators[]= |
| 3808 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3809 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3810 | "-clut apply a color lookup table to the image", |
| 3811 | "-coalesce merge a sequence of images", |
| 3812 | "-combine combine a sequence of images", |
| 3813 | "-composite composite image", |
| 3814 | "-crop geometry cut out a rectangular region of the image", |
| 3815 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3816 | "-evaluate-sequence operator", |
| 3817 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3818 | "-flatten flatten a sequence of images", |
| 3819 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3820 | "-hald-clut apply a Hald color lookup table to the image", |
| 3821 | "-morph value morph an image sequence", |
| 3822 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3823 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3824 | "-process arguments process the image with a custom image filter", |
| 3825 | "-reverse reverse image sequence", |
| 3826 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3827 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3828 | "-write filename write images to this file", |
| 3829 | (char *) NULL |
| 3830 | }, |
| 3831 | *settings[]= |
| 3832 | { |
| 3833 | "-adjoin join images into a single multi-image file", |
| 3834 | "-affine matrix affine transform matrix", |
| 3835 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3836 | "-antialias remove pixel-aliasing", |
| 3837 | "-authenticate password", |
| 3838 | " decipher image with this password", |
| 3839 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3840 | "-background color background color", |
| 3841 | "-bias value add bias when convolving an image", |
| 3842 | "-black-point-compensation", |
| 3843 | " use black point compensation", |
| 3844 | "-blue-primary point chromaticity blue primary point", |
| 3845 | "-bordercolor color border color", |
| 3846 | "-caption string assign a caption to an image", |
| 3847 | "-channel type apply option to select image channels", |
| 3848 | "-colors value preferred number of colors in the image", |
| 3849 | "-colorspace type alternate image colorspace", |
| 3850 | "-comment string annotate image with comment", |
| 3851 | "-compose operator set image composite operator", |
| 3852 | "-compress type type of pixel compression when writing the image", |
| 3853 | "-define format:option", |
| 3854 | " define one or more image format options", |
| 3855 | "-delay value display the next image after pausing", |
| 3856 | "-density geometry horizontal and vertical density of the image", |
| 3857 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3858 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3859 | "-display server get image or font from this X server", |
| 3860 | "-dispose method layer disposal method", |
| 3861 | "-dither method apply error diffusion to image", |
| 3862 | "-encoding type text encoding type", |
| 3863 | "-endian type endianness (MSB or LSB) of the image", |
| 3864 | "-family name render text with this font family", |
| 3865 | "-fill color color to use when filling a graphic primitive", |
| 3866 | "-filter type use this filter when resizing an image", |
| 3867 | "-font name render text with this font", |
| 3868 | "-format \"string\" output formatted image characteristics", |
| 3869 | "-fuzz distance colors within this distance are considered equal", |
| 3870 | "-gravity type horizontal and vertical text placement", |
| 3871 | "-green-primary point chromaticity green primary point", |
| 3872 | "-intent type type of rendering intent when managing the image color", |
| 3873 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3874 | "-interline-spacing value", |
| 3875 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3876 | "-interpolate method pixel color interpolation method", |
| 3877 | "-interword-spacing value", |
| 3878 | " set the space between two words", |
| 3879 | "-kerning value set the space between two letters", |
| 3880 | "-label string assign a label to an image", |
| 3881 | "-limit type value pixel cache resource limit", |
| 3882 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3883 | "-mask filename associate a mask with the image", |
| 3884 | "-mattecolor color frame color", |
| 3885 | "-monitor monitor progress", |
| 3886 | "-orient type image orientation", |
| 3887 | "-page geometry size and location of an image canvas (setting)", |
| 3888 | "-ping efficiently determine image attributes", |
| 3889 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3890 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3891 | "-preview type image preview type", |
| 3892 | "-quality value JPEG/MIFF/PNG compression level", |
| 3893 | "-quiet suppress all warning messages", |
| 3894 | "-red-primary point chromaticity red primary point", |
| 3895 | "-regard-warnings pay attention to warning messages", |
| 3896 | "-remap filename transform image colors to match this set of colors", |
| 3897 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3898 | "-sampling-factor geometry", |
| 3899 | " horizontal and vertical sampling factor", |
| 3900 | "-scene value image scene number", |
| 3901 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3902 | "-size geometry width and height of image", |
| 3903 | "-stretch type render text with this font stretch", |
| 3904 | "-stroke color graphic primitive stroke color", |
| 3905 | "-strokewidth value graphic primitive stroke width", |
| 3906 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3907 | "-synchronize synchronize image to storage device", |
| 3908 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3909 | "-texture filename name of texture to tile onto the image background", |
| 3910 | "-tile-offset geometry", |
| 3911 | " tile offset", |
| 3912 | "-treedepth value color tree depth", |
| 3913 | "-transparent-color color", |
| 3914 | " transparent color", |
| 3915 | "-undercolor color annotation bounding box color", |
| 3916 | "-units type the units of image resolution", |
| 3917 | "-verbose print detailed information about the image", |
| 3918 | "-view FlashPix viewing transforms", |
| 3919 | "-virtual-pixel method", |
| 3920 | " virtual pixel access method", |
| 3921 | "-weight type render text with this font weight", |
| 3922 | "-white-point point chromaticity white point", |
| 3923 | (char *) NULL |
| 3924 | }, |
| 3925 | *stack_operators[]= |
| 3926 | { |
| 3927 | "-clone index clone an image", |
| 3928 | "-delete index delete the image from the image sequence", |
| 3929 | "-insert index insert last image into the image sequence", |
| 3930 | "-swap indexes swap two images in the image sequence", |
| 3931 | (char *) NULL |
| 3932 | }; |
| 3933 | |
| 3934 | const char |
| 3935 | **p; |
| 3936 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3937 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3938 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3939 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3940 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3941 | GetClientName()); |
| 3942 | (void) printf("\nImage Settings:\n"); |
| 3943 | for (p=settings; *p != (char *) NULL; p++) |
| 3944 | (void) printf(" %s\n",*p); |
| 3945 | (void) printf("\nImage Operators:\n"); |
| 3946 | for (p=operators; *p != (char *) NULL; p++) |
| 3947 | (void) printf(" %s\n",*p); |
| 3948 | (void) printf("\nImage Sequence Operators:\n"); |
| 3949 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3950 | (void) printf(" %s\n",*p); |
| 3951 | (void) printf("\nImage Stack Operators:\n"); |
| 3952 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3953 | (void) printf(" %s\n",*p); |
| 3954 | (void) printf("\nMiscellaneous Options:\n"); |
| 3955 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3956 | (void) printf(" %s\n",*p); |
| 3957 | (void) printf( |
| 3958 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3959 | (void) printf( |
| 3960 | "number. To specify a particular image format, precede the filename\n"); |
| 3961 | (void) printf( |
| 3962 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3963 | (void) printf( |
| 3964 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3965 | (void) printf("'-' for standard input or output.\n"); |
| 3966 | return(MagickFalse); |
| 3967 | } |
| 3968 | |
| 3969 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3970 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3971 | { |
| 3972 | #define DestroyMogrify() \ |
| 3973 | { \ |
| 3974 | if (format != (char *) NULL) \ |
| 3975 | format=DestroyString(format); \ |
| 3976 | if (path != (char *) NULL) \ |
| 3977 | path=DestroyString(path); \ |
| 3978 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3979 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3980 | argv[i]=DestroyString(argv[i]); \ |
| 3981 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3982 | } |
| 3983 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3984 | { \ |
| 3985 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3986 | option); \ |
| 3987 | DestroyMogrify(); \ |
| 3988 | return(MagickFalse); \ |
| 3989 | } |
| 3990 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3991 | { \ |
| 3992 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3993 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3994 | DestroyMogrify(); \ |
| 3995 | return(MagickFalse); \ |
| 3996 | } |
| 3997 | |
| 3998 | char |
| 3999 | *format, |
| 4000 | *option, |
| 4001 | *path; |
| 4002 | |
| 4003 | Image |
| 4004 | *image; |
| 4005 | |
| 4006 | ImageStack |
| 4007 | image_stack[MaxImageStackDepth+1]; |
| 4008 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4009 | MagickBooleanType |
| 4010 | global_colormap; |
| 4011 | |
| 4012 | MagickBooleanType |
| 4013 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 4014 | pend, |
| 4015 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4016 | |
| 4017 | MagickStatusType |
| 4018 | status; |
| 4019 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 4020 | register ssize_t |
| 4021 | i; |
| 4022 | |
| 4023 | ssize_t |
| 4024 | j, |
| 4025 | k; |
| 4026 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4027 | /* |
| 4028 | Set defaults. |
| 4029 | */ |
| 4030 | assert(image_info != (ImageInfo *) NULL); |
| 4031 | assert(image_info->signature == MagickSignature); |
| 4032 | if (image_info->debug != MagickFalse) |
| 4033 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 4034 | assert(exception != (ExceptionInfo *) NULL); |
| 4035 | if (argc == 2) |
| 4036 | { |
| 4037 | option=argv[1]; |
| 4038 | if ((LocaleCompare("version",option+1) == 0) || |
| 4039 | (LocaleCompare("-version",option+1) == 0)) |
| 4040 | { |
| 4041 | (void) fprintf(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4042 | GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 4043 | (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright()); |
| 4044 | (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4045 | return(MagickFalse); |
| 4046 | } |
| 4047 | } |
| 4048 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 4049 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4050 | format=(char *) NULL; |
| 4051 | path=(char *) NULL; |
| 4052 | global_colormap=MagickFalse; |
| 4053 | k=0; |
| 4054 | j=1; |
| 4055 | NewImageStack(); |
| 4056 | option=(char *) NULL; |
| 4057 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 4058 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4059 | status=MagickTrue; |
| 4060 | /* |
| 4061 | Parse command line. |
| 4062 | */ |
| 4063 | ReadCommandlLine(argc,&argv); |
| 4064 | status=ExpandFilenames(&argc,&argv); |
| 4065 | if (status == MagickFalse) |
| 4066 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 4067 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4068 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4069 | { |
| 4070 | option=argv[i]; |
| 4071 | if (LocaleCompare(option,"(") == 0) |
| 4072 | { |
| 4073 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 4074 | if (k == MaxImageStackDepth) |
| 4075 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 4076 | option); |
| 4077 | PushImageStack(); |
| 4078 | continue; |
| 4079 | } |
| 4080 | if (LocaleCompare(option,")") == 0) |
| 4081 | { |
| 4082 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 4083 | if (k == 0) |
| 4084 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 4085 | PopImageStack(); |
| 4086 | continue; |
| 4087 | } |
| 4088 | if (IsMagickOption(option) == MagickFalse) |
| 4089 | { |
| 4090 | char |
| 4091 | backup_filename[MaxTextExtent], |
| 4092 | *filename; |
| 4093 | |
| 4094 | Image |
| 4095 | *images; |
| 4096 | |
| 4097 | /* |
| 4098 | Option is a file name: begin by reading image from specified file. |
| 4099 | */ |
| 4100 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 4101 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 4102 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4103 | filename=argv[++i]; |
| 4104 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 4105 | images=ReadImages(image_info,exception); |
| 4106 | status&=(images != (Image *) NULL) && |
| 4107 | (exception->severity < ErrorException); |
| 4108 | if (images == (Image *) NULL) |
| 4109 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 4110 | if (format != (char *) NULL) |
| 4111 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 4112 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4113 | if (path != (char *) NULL) |
| 4114 | { |
| 4115 | GetPathComponent(option,TailPath,filename); |
| 4116 | (void) FormatMagickString(images->filename,MaxTextExtent,"%s%c%s", |
| 4117 | path,*DirectorySeparator,filename); |
| 4118 | } |
| 4119 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 4120 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4121 | AppendImageStack(images); |
| 4122 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 4123 | if (global_colormap != MagickFalse) |
| 4124 | { |
| 4125 | QuantizeInfo |
| 4126 | *quantize_info; |
| 4127 | |
| 4128 | quantize_info=AcquireQuantizeInfo(image_info); |
| 4129 | (void) RemapImages(quantize_info,images,(Image *) NULL); |
| 4130 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 4131 | } |
| 4132 | *backup_filename='\0'; |
| 4133 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 4134 | (IsPathWritable(image->filename) != MagickFalse)) |
| 4135 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4136 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4137 | i; |
| 4138 | |
| 4139 | /* |
| 4140 | Rename image file as backup. |
| 4141 | */ |
| 4142 | (void) CopyMagickString(backup_filename,image->filename, |
| 4143 | MaxTextExtent); |
| 4144 | for (i=0; i < 6; i++) |
| 4145 | { |
| 4146 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 4147 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 4148 | break; |
| 4149 | } |
| 4150 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
| 4151 | (rename(image->filename,backup_filename) != 0)) |
| 4152 | *backup_filename='\0'; |
| 4153 | } |
| 4154 | /* |
| 4155 | Write transmogrified image to disk. |
| 4156 | */ |
| 4157 | image_info->synchronize=MagickTrue; |
| 4158 | status&=WriteImages(image_info,image,image->filename,exception); |
| 4159 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
| 4160 | (void) remove(backup_filename); |
| 4161 | RemoveAllImageStack(); |
| 4162 | continue; |
| 4163 | } |
| 4164 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 4165 | switch (*(option+1)) |
| 4166 | { |
| 4167 | case 'a': |
| 4168 | { |
| 4169 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 4170 | { |
| 4171 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4172 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4173 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4174 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4175 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4176 | break; |
| 4177 | } |
| 4178 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 4179 | { |
| 4180 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4181 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4182 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4183 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4184 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4185 | break; |
| 4186 | } |
| 4187 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 4188 | { |
| 4189 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4190 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4191 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4192 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4193 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4194 | break; |
| 4195 | } |
| 4196 | if (LocaleCompare("affine",option+1) == 0) |
| 4197 | { |
| 4198 | if (*option == '+') |
| 4199 | break; |
| 4200 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4201 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4202 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4203 | break; |
| 4204 | } |
| 4205 | if (LocaleCompare("alpha",option+1) == 0) |
| 4206 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4207 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4208 | type; |
| 4209 | |
| 4210 | if (*option == '+') |
| 4211 | break; |
| 4212 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4213 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4214 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4215 | type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]); |
| 4216 | if (type < 0) |
| 4217 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 4218 | argv[i]); |
| 4219 | break; |
| 4220 | } |
| 4221 | if (LocaleCompare("annotate",option+1) == 0) |
| 4222 | { |
| 4223 | if (*option == '+') |
| 4224 | break; |
| 4225 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4226 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4227 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4228 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4229 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4230 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4231 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4232 | i++; |
| 4233 | break; |
| 4234 | } |
| 4235 | if (LocaleCompare("antialias",option+1) == 0) |
| 4236 | break; |
| 4237 | if (LocaleCompare("append",option+1) == 0) |
| 4238 | break; |
| 4239 | if (LocaleCompare("attenuate",option+1) == 0) |
| 4240 | { |
| 4241 | if (*option == '+') |
| 4242 | break; |
| 4243 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4244 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4245 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4246 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4247 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4248 | break; |
| 4249 | } |
| 4250 | if (LocaleCompare("authenticate",option+1) == 0) |
| 4251 | { |
| 4252 | if (*option == '+') |
| 4253 | break; |
| 4254 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4255 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4256 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4257 | break; |
| 4258 | } |
| 4259 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 4260 | break; |
| 4261 | if (LocaleCompare("auto-level",option+1) == 0) |
| 4262 | break; |
| 4263 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 4264 | break; |
| 4265 | if (LocaleCompare("average",option+1) == 0) |
| 4266 | break; |
| 4267 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4268 | } |
| 4269 | case 'b': |
| 4270 | { |
| 4271 | if (LocaleCompare("background",option+1) == 0) |
| 4272 | { |
| 4273 | if (*option == '+') |
| 4274 | break; |
| 4275 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4276 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4277 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4278 | break; |
| 4279 | } |
| 4280 | if (LocaleCompare("bias",option+1) == 0) |
| 4281 | { |
| 4282 | if (*option == '+') |
| 4283 | break; |
| 4284 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4285 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4286 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4287 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4288 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4289 | break; |
| 4290 | } |
| 4291 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 4292 | break; |
| 4293 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 4294 | { |
| 4295 | if (*option == '+') |
| 4296 | break; |
| 4297 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4298 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4299 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4300 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4301 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4302 | break; |
| 4303 | } |
| 4304 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 4305 | { |
| 4306 | if (*option == '+') |
| 4307 | break; |
| 4308 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4309 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4310 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4311 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4312 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4313 | break; |
| 4314 | } |
| 4315 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 4316 | { |
| 4317 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4318 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4319 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4320 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4321 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4322 | break; |
| 4323 | } |
| 4324 | if (LocaleCompare("blur",option+1) == 0) |
| 4325 | { |
| 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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4330 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4331 | break; |
| 4332 | } |
| 4333 | if (LocaleCompare("border",option+1) == 0) |
| 4334 | { |
| 4335 | if (*option == '+') |
| 4336 | break; |
| 4337 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4338 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4339 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4340 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4341 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4342 | break; |
| 4343 | } |
| 4344 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 4345 | { |
| 4346 | if (*option == '+') |
| 4347 | break; |
| 4348 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4349 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4350 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4351 | break; |
| 4352 | } |
| 4353 | if (LocaleCompare("box",option+1) == 0) |
| 4354 | { |
| 4355 | if (*option == '+') |
| 4356 | break; |
| 4357 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4358 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4359 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4360 | break; |
| 4361 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 4362 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 4363 | { |
| 4364 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4365 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 4366 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4367 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4368 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4369 | break; |
| 4370 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4371 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4372 | } |
| 4373 | case 'c': |
| 4374 | { |
| 4375 | if (LocaleCompare("cache",option+1) == 0) |
| 4376 | { |
| 4377 | if (*option == '+') |
| 4378 | break; |
| 4379 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4380 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4381 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4382 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4383 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4384 | break; |
| 4385 | } |
| 4386 | if (LocaleCompare("caption",option+1) == 0) |
| 4387 | { |
| 4388 | if (*option == '+') |
| 4389 | break; |
| 4390 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4391 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4392 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4393 | break; |
| 4394 | } |
| 4395 | if (LocaleCompare("channel",option+1) == 0) |
| 4396 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4397 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4398 | channel; |
| 4399 | |
| 4400 | if (*option == '+') |
| 4401 | break; |
| 4402 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4403 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4404 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4405 | channel=ParseChannelOption(argv[i]); |
| 4406 | if (channel < 0) |
| 4407 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 4408 | argv[i]); |
| 4409 | break; |
| 4410 | } |
| 4411 | if (LocaleCompare("cdl",option+1) == 0) |
| 4412 | { |
| 4413 | if (*option == '+') |
| 4414 | break; |
| 4415 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4416 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4417 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4418 | break; |
| 4419 | } |
| 4420 | if (LocaleCompare("charcoal",option+1) == 0) |
| 4421 | { |
| 4422 | if (*option == '+') |
| 4423 | break; |
| 4424 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4425 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4426 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4427 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4428 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4429 | break; |
| 4430 | } |
| 4431 | if (LocaleCompare("chop",option+1) == 0) |
| 4432 | { |
| 4433 | if (*option == '+') |
| 4434 | break; |
| 4435 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4436 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4437 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4438 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4439 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4440 | break; |
| 4441 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4442 | if (LocaleCompare("clamp",option+1) == 0) |
| 4443 | break; |
| 4444 | if (LocaleCompare("clip",option+1) == 0) |
| 4445 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4446 | if (LocaleCompare("clip-mask",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("clut",option+1) == 0) |
| 4456 | break; |
| 4457 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4458 | break; |
| 4459 | if (LocaleCompare("colorize",option+1) == 0) |
| 4460 | { |
| 4461 | if (*option == '+') |
| 4462 | break; |
| 4463 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4464 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4465 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4466 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4467 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4468 | break; |
| 4469 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4470 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4471 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4472 | KernelInfo |
| 4473 | *kernel_info; |
| 4474 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4475 | if (*option == '+') |
| 4476 | break; |
| 4477 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4478 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4479 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4480 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4481 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4482 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4483 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4484 | break; |
| 4485 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4486 | if (LocaleCompare("colors",option+1) == 0) |
| 4487 | { |
| 4488 | if (*option == '+') |
| 4489 | break; |
| 4490 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4491 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4492 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4493 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4494 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4495 | break; |
| 4496 | } |
| 4497 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4498 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4499 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4500 | colorspace; |
| 4501 | |
| 4502 | if (*option == '+') |
| 4503 | break; |
| 4504 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4505 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4506 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4507 | colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse, |
| 4508 | argv[i]); |
| 4509 | if (colorspace < 0) |
| 4510 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4511 | argv[i]); |
| 4512 | break; |
| 4513 | } |
| 4514 | if (LocaleCompare("combine",option+1) == 0) |
| 4515 | break; |
| 4516 | if (LocaleCompare("comment",option+1) == 0) |
| 4517 | { |
| 4518 | if (*option == '+') |
| 4519 | break; |
| 4520 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4521 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4522 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4523 | break; |
| 4524 | } |
| 4525 | if (LocaleCompare("composite",option+1) == 0) |
| 4526 | break; |
| 4527 | if (LocaleCompare("compress",option+1) == 0) |
| 4528 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4529 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4530 | compress; |
| 4531 | |
| 4532 | if (*option == '+') |
| 4533 | break; |
| 4534 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4535 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4536 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4537 | compress=ParseMagickOption(MagickCompressOptions,MagickFalse, |
| 4538 | argv[i]); |
| 4539 | if (compress < 0) |
| 4540 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4541 | argv[i]); |
| 4542 | break; |
| 4543 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4544 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4545 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4546 | if (LocaleCompare("contrast",option+1) == 0) |
| 4547 | break; |
| 4548 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4549 | { |
| 4550 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4551 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4552 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4553 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4554 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4555 | break; |
| 4556 | } |
| 4557 | if (LocaleCompare("convolve",option+1) == 0) |
| 4558 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4559 | KernelInfo |
| 4560 | *kernel_info; |
| 4561 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4562 | if (*option == '+') |
| 4563 | break; |
| 4564 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4565 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4566 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4567 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4568 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4569 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4570 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4571 | break; |
| 4572 | } |
| 4573 | if (LocaleCompare("crop",option+1) == 0) |
| 4574 | { |
| 4575 | if (*option == '+') |
| 4576 | break; |
| 4577 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4578 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4579 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4580 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4581 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4582 | break; |
| 4583 | } |
| 4584 | if (LocaleCompare("cycle",option+1) == 0) |
| 4585 | { |
| 4586 | if (*option == '+') |
| 4587 | break; |
| 4588 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4589 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4590 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4591 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4592 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4593 | break; |
| 4594 | } |
| 4595 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4596 | } |
| 4597 | case 'd': |
| 4598 | { |
| 4599 | if (LocaleCompare("decipher",option+1) == 0) |
| 4600 | { |
| 4601 | if (*option == '+') |
| 4602 | break; |
| 4603 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4604 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4605 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4606 | break; |
| 4607 | } |
| 4608 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4609 | break; |
| 4610 | if (LocaleCompare("debug",option+1) == 0) |
| 4611 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4612 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4613 | event; |
| 4614 | |
| 4615 | if (*option == '+') |
| 4616 | break; |
| 4617 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4618 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4619 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4620 | event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]); |
| 4621 | if (event < 0) |
| 4622 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4623 | argv[i]); |
| 4624 | (void) SetLogEventMask(argv[i]); |
| 4625 | break; |
| 4626 | } |
| 4627 | if (LocaleCompare("define",option+1) == 0) |
| 4628 | { |
| 4629 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4630 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4631 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4632 | if (*option == '+') |
| 4633 | { |
| 4634 | const char |
| 4635 | *define; |
| 4636 | |
| 4637 | define=GetImageOption(image_info,argv[i]); |
| 4638 | if (define == (const char *) NULL) |
| 4639 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4640 | break; |
| 4641 | } |
| 4642 | break; |
| 4643 | } |
| 4644 | if (LocaleCompare("delay",option+1) == 0) |
| 4645 | { |
| 4646 | if (*option == '+') |
| 4647 | break; |
| 4648 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4649 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4650 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4651 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4652 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4653 | break; |
| 4654 | } |
| 4655 | if (LocaleCompare("density",option+1) == 0) |
| 4656 | { |
| 4657 | if (*option == '+') |
| 4658 | break; |
| 4659 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4660 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4661 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4662 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4663 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4664 | break; |
| 4665 | } |
| 4666 | if (LocaleCompare("depth",option+1) == 0) |
| 4667 | { |
| 4668 | if (*option == '+') |
| 4669 | break; |
| 4670 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4671 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4672 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4673 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4674 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4675 | break; |
| 4676 | } |
| 4677 | if (LocaleCompare("deskew",option+1) == 0) |
| 4678 | { |
| 4679 | if (*option == '+') |
| 4680 | break; |
| 4681 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4682 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4683 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4684 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4685 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4686 | break; |
| 4687 | } |
| 4688 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4689 | break; |
| 4690 | if (LocaleCompare("dft",option+1) == 0) |
| 4691 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4692 | if (LocaleCompare("direction",option+1) == 0) |
| 4693 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4694 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4695 | direction; |
| 4696 | |
| 4697 | if (*option == '+') |
| 4698 | break; |
| 4699 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4700 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4701 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4702 | direction=ParseMagickOption(MagickDirectionOptions,MagickFalse, |
| 4703 | argv[i]); |
| 4704 | if (direction < 0) |
| 4705 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4706 | argv[i]); |
| 4707 | break; |
| 4708 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4709 | if (LocaleCompare("display",option+1) == 0) |
| 4710 | { |
| 4711 | if (*option == '+') |
| 4712 | break; |
| 4713 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4714 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4715 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4716 | break; |
| 4717 | } |
| 4718 | if (LocaleCompare("dispose",option+1) == 0) |
| 4719 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4720 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4721 | dispose; |
| 4722 | |
| 4723 | if (*option == '+') |
| 4724 | break; |
| 4725 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4726 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4727 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4728 | dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]); |
| 4729 | if (dispose < 0) |
| 4730 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4731 | argv[i]); |
| 4732 | break; |
| 4733 | } |
| 4734 | if (LocaleCompare("distort",option+1) == 0) |
| 4735 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4736 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4737 | op; |
| 4738 | |
| 4739 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4740 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4741 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4742 | op=ParseMagickOption(MagickDistortOptions,MagickFalse,argv[i]); |
| 4743 | if (op < 0) |
| 4744 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4745 | argv[i]); |
| 4746 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4747 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4748 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4749 | break; |
| 4750 | } |
| 4751 | if (LocaleCompare("dither",option+1) == 0) |
| 4752 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4753 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4754 | method; |
| 4755 | |
| 4756 | if (*option == '+') |
| 4757 | break; |
| 4758 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4759 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4760 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4761 | method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]); |
| 4762 | if (method < 0) |
| 4763 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4764 | argv[i]); |
| 4765 | break; |
| 4766 | } |
| 4767 | if (LocaleCompare("draw",option+1) == 0) |
| 4768 | { |
| 4769 | if (*option == '+') |
| 4770 | break; |
| 4771 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4772 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4773 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4774 | break; |
| 4775 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4776 | if (LocaleCompare("duration",option+1) == 0) |
| 4777 | { |
| 4778 | if (*option == '+') |
| 4779 | break; |
| 4780 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4781 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4782 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4783 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4784 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4785 | break; |
| 4786 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4787 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4788 | } |
| 4789 | case 'e': |
| 4790 | { |
| 4791 | if (LocaleCompare("edge",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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4797 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4798 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4799 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4800 | break; |
| 4801 | } |
| 4802 | if (LocaleCompare("emboss",option+1) == 0) |
| 4803 | { |
| 4804 | if (*option == '+') |
| 4805 | break; |
| 4806 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4807 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4808 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4809 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4810 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4811 | break; |
| 4812 | } |
| 4813 | if (LocaleCompare("encipher",option+1) == 0) |
| 4814 | { |
| 4815 | if (*option == '+') |
| 4816 | break; |
| 4817 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4818 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4819 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4820 | break; |
| 4821 | } |
| 4822 | if (LocaleCompare("encoding",option+1) == 0) |
| 4823 | { |
| 4824 | if (*option == '+') |
| 4825 | break; |
| 4826 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4827 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4828 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4829 | break; |
| 4830 | } |
| 4831 | if (LocaleCompare("endian",option+1) == 0) |
| 4832 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4833 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4834 | endian; |
| 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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4840 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4841 | endian=ParseMagickOption(MagickEndianOptions,MagickFalse,argv[i]); |
| 4842 | if (endian < 0) |
| 4843 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4844 | argv[i]); |
| 4845 | break; |
| 4846 | } |
| 4847 | if (LocaleCompare("enhance",option+1) == 0) |
| 4848 | break; |
| 4849 | if (LocaleCompare("equalize",option+1) == 0) |
| 4850 | break; |
| 4851 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4852 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4853 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4854 | op; |
| 4855 | |
| 4856 | if (*option == '+') |
| 4857 | break; |
| 4858 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4859 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4860 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4861 | op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
| 4862 | if (op < 0) |
| 4863 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4864 | argv[i]); |
| 4865 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4866 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4867 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4868 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4869 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4870 | break; |
| 4871 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4872 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4873 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4874 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4875 | op; |
| 4876 | |
| 4877 | if (*option == '+') |
| 4878 | break; |
| 4879 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4880 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4881 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4882 | op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
| 4883 | if (op < 0) |
| 4884 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4885 | argv[i]); |
| 4886 | break; |
| 4887 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4888 | if (LocaleCompare("extent",option+1) == 0) |
| 4889 | { |
| 4890 | if (*option == '+') |
| 4891 | break; |
| 4892 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4893 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4894 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4895 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4896 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4897 | break; |
| 4898 | } |
| 4899 | if (LocaleCompare("extract",option+1) == 0) |
| 4900 | { |
| 4901 | if (*option == '+') |
| 4902 | break; |
| 4903 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4904 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4905 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4906 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4907 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4908 | break; |
| 4909 | } |
| 4910 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4911 | } |
| 4912 | case 'f': |
| 4913 | { |
| 4914 | if (LocaleCompare("family",option+1) == 0) |
| 4915 | { |
| 4916 | if (*option == '+') |
| 4917 | break; |
| 4918 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4919 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4920 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4921 | break; |
| 4922 | } |
| 4923 | if (LocaleCompare("fill",option+1) == 0) |
| 4924 | { |
| 4925 | if (*option == '+') |
| 4926 | break; |
| 4927 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4928 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4929 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4930 | break; |
| 4931 | } |
| 4932 | if (LocaleCompare("filter",option+1) == 0) |
| 4933 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4934 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4935 | filter; |
| 4936 | |
| 4937 | if (*option == '+') |
| 4938 | break; |
| 4939 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4940 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4941 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4942 | filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]); |
| 4943 | if (filter < 0) |
| 4944 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4945 | argv[i]); |
| 4946 | break; |
| 4947 | } |
| 4948 | if (LocaleCompare("flatten",option+1) == 0) |
| 4949 | break; |
| 4950 | if (LocaleCompare("flip",option+1) == 0) |
| 4951 | break; |
| 4952 | if (LocaleCompare("flop",option+1) == 0) |
| 4953 | break; |
| 4954 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4955 | { |
| 4956 | if (*option == '+') |
| 4957 | break; |
| 4958 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4959 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4960 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4961 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4962 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4963 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4964 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4965 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4966 | break; |
| 4967 | } |
| 4968 | if (LocaleCompare("font",option+1) == 0) |
| 4969 | { |
| 4970 | if (*option == '+') |
| 4971 | break; |
| 4972 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4973 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4974 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4975 | break; |
| 4976 | } |
| 4977 | if (LocaleCompare("format",option+1) == 0) |
| 4978 | { |
| 4979 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4980 | (void) CloneString(&format,(char *) NULL); |
| 4981 | if (*option == '+') |
| 4982 | break; |
| 4983 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4984 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4985 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4986 | (void) CloneString(&format,argv[i]); |
| 4987 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4988 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4989 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4990 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4991 | if (*image_info->magick == '\0') |
| 4992 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4993 | format); |
| 4994 | break; |
| 4995 | } |
| 4996 | if (LocaleCompare("frame",option+1) == 0) |
| 4997 | { |
| 4998 | if (*option == '+') |
| 4999 | break; |
| 5000 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5001 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5002 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5003 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5004 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5005 | break; |
| 5006 | } |
| 5007 | if (LocaleCompare("function",option+1) == 0) |
| 5008 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5009 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5010 | op; |
| 5011 | |
| 5012 | if (*option == '+') |
| 5013 | break; |
| 5014 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5015 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5016 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5017 | op=ParseMagickOption(MagickFunctionOptions,MagickFalse,argv[i]); |
| 5018 | if (op < 0) |
| 5019 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 5020 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5021 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5022 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5023 | break; |
| 5024 | } |
| 5025 | if (LocaleCompare("fuzz",option+1) == 0) |
| 5026 | { |
| 5027 | if (*option == '+') |
| 5028 | break; |
| 5029 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5030 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5031 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5032 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5033 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5034 | break; |
| 5035 | } |
| 5036 | if (LocaleCompare("fx",option+1) == 0) |
| 5037 | { |
| 5038 | if (*option == '+') |
| 5039 | break; |
| 5040 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5041 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5042 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5043 | break; |
| 5044 | } |
| 5045 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5046 | } |
| 5047 | case 'g': |
| 5048 | { |
| 5049 | if (LocaleCompare("gamma",option+1) == 0) |
| 5050 | { |
| 5051 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5052 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5053 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5054 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5055 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5056 | break; |
| 5057 | } |
| 5058 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 5059 | (LocaleCompare("gaussian",option+1) == 0)) |
| 5060 | { |
| 5061 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5062 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5063 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5064 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5065 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5066 | break; |
| 5067 | } |
| 5068 | if (LocaleCompare("geometry",option+1) == 0) |
| 5069 | { |
| 5070 | if (*option == '+') |
| 5071 | break; |
| 5072 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5073 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5074 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5075 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5076 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5077 | break; |
| 5078 | } |
| 5079 | if (LocaleCompare("gravity",option+1) == 0) |
| 5080 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5081 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5082 | gravity; |
| 5083 | |
| 5084 | if (*option == '+') |
| 5085 | break; |
| 5086 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5087 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5088 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5089 | gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,argv[i]); |
| 5090 | if (gravity < 0) |
| 5091 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 5092 | argv[i]); |
| 5093 | break; |
| 5094 | } |
| 5095 | if (LocaleCompare("green-primary",option+1) == 0) |
| 5096 | { |
| 5097 | if (*option == '+') |
| 5098 | break; |
| 5099 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5100 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5101 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5102 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5103 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5104 | break; |
| 5105 | } |
| 5106 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5107 | } |
| 5108 | case 'h': |
| 5109 | { |
| 5110 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 5111 | break; |
| 5112 | if ((LocaleCompare("help",option+1) == 0) || |
| 5113 | (LocaleCompare("-help",option+1) == 0)) |
| 5114 | return(MogrifyUsage()); |
| 5115 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5116 | } |
| 5117 | case 'i': |
| 5118 | { |
| 5119 | if (LocaleCompare("identify",option+1) == 0) |
| 5120 | break; |
| 5121 | if (LocaleCompare("idft",option+1) == 0) |
| 5122 | break; |
| 5123 | if (LocaleCompare("implode",option+1) == 0) |
| 5124 | { |
| 5125 | if (*option == '+') |
| 5126 | break; |
| 5127 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5128 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5129 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5130 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5131 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5132 | break; |
| 5133 | } |
| 5134 | if (LocaleCompare("intent",option+1) == 0) |
| 5135 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5136 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5137 | intent; |
| 5138 | |
| 5139 | if (*option == '+') |
| 5140 | break; |
| 5141 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5142 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5143 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5144 | intent=ParseMagickOption(MagickIntentOptions,MagickFalse,argv[i]); |
| 5145 | if (intent < 0) |
| 5146 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 5147 | argv[i]); |
| 5148 | break; |
| 5149 | } |
| 5150 | if (LocaleCompare("interlace",option+1) == 0) |
| 5151 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5152 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5153 | interlace; |
| 5154 | |
| 5155 | if (*option == '+') |
| 5156 | break; |
| 5157 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5158 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5159 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5160 | interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse, |
| 5161 | argv[i]); |
| 5162 | if (interlace < 0) |
| 5163 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 5164 | argv[i]); |
| 5165 | break; |
| 5166 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 5167 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 5168 | { |
| 5169 | if (*option == '+') |
| 5170 | break; |
| 5171 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5172 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 5173 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5174 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5175 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5176 | break; |
| 5177 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5178 | if (LocaleCompare("interpolate",option+1) == 0) |
| 5179 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5180 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5181 | interpolate; |
| 5182 | |
| 5183 | if (*option == '+') |
| 5184 | break; |
| 5185 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5186 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5187 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5188 | interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse, |
| 5189 | argv[i]); |
| 5190 | if (interpolate < 0) |
| 5191 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 5192 | argv[i]); |
| 5193 | break; |
| 5194 | } |
| 5195 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 5196 | { |
| 5197 | if (*option == '+') |
| 5198 | break; |
| 5199 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5200 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5201 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5202 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5203 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5204 | break; |
| 5205 | } |
| 5206 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5207 | } |
| 5208 | case 'k': |
| 5209 | { |
| 5210 | if (LocaleCompare("kerning",option+1) == 0) |
| 5211 | { |
| 5212 | if (*option == '+') |
| 5213 | break; |
| 5214 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5215 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5216 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5217 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5218 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5219 | break; |
| 5220 | } |
| 5221 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5222 | } |
| 5223 | case 'l': |
| 5224 | { |
| 5225 | if (LocaleCompare("label",option+1) == 0) |
| 5226 | { |
| 5227 | if (*option == '+') |
| 5228 | break; |
| 5229 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5230 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5231 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5232 | break; |
| 5233 | } |
| 5234 | if (LocaleCompare("lat",option+1) == 0) |
| 5235 | { |
| 5236 | if (*option == '+') |
| 5237 | break; |
| 5238 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5239 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5240 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5241 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5242 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5243 | } |
| 5244 | if (LocaleCompare("layers",option+1) == 0) |
| 5245 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5246 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5247 | type; |
| 5248 | |
| 5249 | if (*option == '+') |
| 5250 | break; |
| 5251 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5252 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5253 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5254 | type=ParseMagickOption(MagickLayerOptions,MagickFalse,argv[i]); |
| 5255 | if (type < 0) |
| 5256 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 5257 | argv[i]); |
| 5258 | break; |
| 5259 | } |
| 5260 | if (LocaleCompare("level",option+1) == 0) |
| 5261 | { |
| 5262 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5263 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5264 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5265 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5266 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5267 | break; |
| 5268 | } |
| 5269 | if (LocaleCompare("level-colors",option+1) == 0) |
| 5270 | { |
| 5271 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5272 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5273 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5274 | break; |
| 5275 | } |
| 5276 | if (LocaleCompare("linewidth",option+1) == 0) |
| 5277 | { |
| 5278 | if (*option == '+') |
| 5279 | break; |
| 5280 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5281 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5282 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5283 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5284 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5285 | break; |
| 5286 | } |
| 5287 | if (LocaleCompare("limit",option+1) == 0) |
| 5288 | { |
| 5289 | char |
| 5290 | *p; |
| 5291 | |
| 5292 | double |
| 5293 | value; |
| 5294 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5295 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5296 | resource; |
| 5297 | |
| 5298 | if (*option == '+') |
| 5299 | break; |
| 5300 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5301 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5302 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5303 | resource=ParseMagickOption(MagickResourceOptions,MagickFalse, |
| 5304 | argv[i]); |
| 5305 | if (resource < 0) |
| 5306 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 5307 | argv[i]); |
| 5308 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5309 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5310 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5311 | value=strtod(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 5312 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5313 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 5314 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5315 | break; |
| 5316 | } |
| 5317 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 5318 | { |
| 5319 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5320 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5321 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5322 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5323 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5324 | break; |
| 5325 | } |
| 5326 | if (LocaleCompare("list",option+1) == 0) |
| 5327 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5328 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5329 | list; |
| 5330 | |
| 5331 | if (*option == '+') |
| 5332 | break; |
| 5333 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5334 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5335 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5336 | list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]); |
| 5337 | if (list < 0) |
| 5338 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 5339 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5340 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 5341 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5342 | } |
| 5343 | if (LocaleCompare("log",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 | (strchr(argv[i],'%') == (char *) NULL)) |
| 5350 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5351 | break; |
| 5352 | } |
| 5353 | if (LocaleCompare("loop",option+1) == 0) |
| 5354 | { |
| 5355 | if (*option == '+') |
| 5356 | break; |
| 5357 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5358 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5359 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5360 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5361 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5362 | break; |
| 5363 | } |
| 5364 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5365 | } |
| 5366 | case 'm': |
| 5367 | { |
| 5368 | if (LocaleCompare("map",option+1) == 0) |
| 5369 | { |
| 5370 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 5371 | if (*option == '+') |
| 5372 | break; |
| 5373 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5374 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5375 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5376 | break; |
| 5377 | } |
| 5378 | if (LocaleCompare("mask",option+1) == 0) |
| 5379 | { |
| 5380 | if (*option == '+') |
| 5381 | break; |
| 5382 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5383 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5384 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5385 | break; |
| 5386 | } |
| 5387 | if (LocaleCompare("matte",option+1) == 0) |
| 5388 | break; |
| 5389 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 5390 | { |
| 5391 | if (*option == '+') |
| 5392 | break; |
| 5393 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5394 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5395 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5396 | break; |
| 5397 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5398 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5399 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5400 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5401 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5402 | if (LocaleCompare("modulate",option+1) == 0) |
| 5403 | { |
| 5404 | if (*option == '+') |
| 5405 | break; |
| 5406 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5407 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5408 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5409 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5410 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5411 | break; |
| 5412 | } |
| 5413 | if (LocaleCompare("median",option+1) == 0) |
| 5414 | { |
| 5415 | if (*option == '+') |
| 5416 | break; |
| 5417 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5418 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5419 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5420 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5421 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5422 | break; |
| 5423 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame^] | 5424 | if (LocaleCompare("mode",option+1) == 0) |
| 5425 | { |
| 5426 | if (*option == '+') |
| 5427 | break; |
| 5428 | i++; |
| 5429 | if (i == (ssize_t) argc) |
| 5430 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5431 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5432 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5433 | break; |
| 5434 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5435 | if (LocaleCompare("monitor",option+1) == 0) |
| 5436 | break; |
| 5437 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5438 | break; |
| 5439 | if (LocaleCompare("morph",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-1)) |
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 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5450 | if (LocaleCompare("morphology",option+1) == 0) |
| 5451 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5452 | char |
| 5453 | token[MaxTextExtent]; |
| 5454 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5455 | KernelInfo |
| 5456 | *kernel_info; |
| 5457 | |
| 5458 | ssize_t |
| 5459 | op; |
| 5460 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5461 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5462 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5463 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5464 | GetMagickToken(argv[i],NULL,token); |
| 5465 | op=ParseMagickOption(MagickMorphologyOptions,MagickFalse,token); |
| 5466 | if (op < 0) |
| 5467 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5468 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5469 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5470 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5471 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5472 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5473 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5474 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5475 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5476 | break; |
| 5477 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5478 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5479 | break; |
| 5480 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5481 | { |
| 5482 | if (*option == '+') |
| 5483 | break; |
| 5484 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5485 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5486 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5487 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5488 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5489 | break; |
| 5490 | } |
| 5491 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5492 | } |
| 5493 | case 'n': |
| 5494 | { |
| 5495 | if (LocaleCompare("negate",option+1) == 0) |
| 5496 | break; |
| 5497 | if (LocaleCompare("noise",option+1) == 0) |
| 5498 | { |
| 5499 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5500 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5501 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5502 | if (*option == '+') |
| 5503 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5504 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5505 | noise; |
| 5506 | |
| 5507 | noise=ParseMagickOption(MagickNoiseOptions,MagickFalse,argv[i]); |
| 5508 | if (noise < 0) |
| 5509 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5510 | argv[i]); |
| 5511 | break; |
| 5512 | } |
| 5513 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5514 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5515 | break; |
| 5516 | } |
| 5517 | if (LocaleCompare("noop",option+1) == 0) |
| 5518 | break; |
| 5519 | if (LocaleCompare("normalize",option+1) == 0) |
| 5520 | break; |
| 5521 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5522 | } |
| 5523 | case 'o': |
| 5524 | { |
| 5525 | if (LocaleCompare("opaque",option+1) == 0) |
| 5526 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5527 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5528 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5529 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5530 | break; |
| 5531 | } |
| 5532 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5533 | { |
| 5534 | if (*option == '+') |
| 5535 | break; |
| 5536 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5537 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5538 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5539 | break; |
| 5540 | } |
| 5541 | if (LocaleCompare("orient",option+1) == 0) |
| 5542 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5543 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5544 | orientation; |
| 5545 | |
| 5546 | orientation=UndefinedOrientation; |
| 5547 | if (*option == '+') |
| 5548 | break; |
| 5549 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5550 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5551 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5552 | orientation=ParseMagickOption(MagickOrientationOptions,MagickFalse, |
| 5553 | argv[i]); |
| 5554 | if (orientation < 0) |
| 5555 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5556 | argv[i]); |
| 5557 | break; |
| 5558 | } |
| 5559 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5560 | } |
| 5561 | case 'p': |
| 5562 | { |
| 5563 | if (LocaleCompare("page",option+1) == 0) |
| 5564 | { |
| 5565 | if (*option == '+') |
| 5566 | break; |
| 5567 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5568 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5569 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5570 | break; |
| 5571 | } |
| 5572 | if (LocaleCompare("paint",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("path",option+1) == 0) |
| 5584 | { |
| 5585 | (void) CloneString(&path,(char *) NULL); |
| 5586 | if (*option == '+') |
| 5587 | break; |
| 5588 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5589 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5590 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5591 | (void) CloneString(&path,argv[i]); |
| 5592 | break; |
| 5593 | } |
| 5594 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5595 | { |
| 5596 | if (*option == '+') |
| 5597 | break; |
| 5598 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5599 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5600 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5601 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5602 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5603 | break; |
| 5604 | } |
| 5605 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5606 | { |
| 5607 | if (*option == '+') |
| 5608 | break; |
| 5609 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5610 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5611 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5612 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5613 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5614 | break; |
| 5615 | } |
| 5616 | if (LocaleCompare("posterize",option+1) == 0) |
| 5617 | { |
| 5618 | if (*option == '+') |
| 5619 | break; |
| 5620 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5621 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5622 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5623 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5624 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5625 | break; |
| 5626 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5627 | if (LocaleCompare("precision",option+1) == 0) |
| 5628 | { |
| 5629 | if (*option == '+') |
| 5630 | break; |
| 5631 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5632 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5633 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5634 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5635 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5636 | break; |
| 5637 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5638 | if (LocaleCompare("print",option+1) == 0) |
| 5639 | { |
| 5640 | if (*option == '+') |
| 5641 | break; |
| 5642 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5643 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5644 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5645 | break; |
| 5646 | } |
| 5647 | if (LocaleCompare("process",option+1) == 0) |
| 5648 | { |
| 5649 | if (*option == '+') |
| 5650 | break; |
| 5651 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5652 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5653 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5654 | break; |
| 5655 | } |
| 5656 | if (LocaleCompare("profile",option+1) == 0) |
| 5657 | { |
| 5658 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5659 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5660 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5661 | break; |
| 5662 | } |
| 5663 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5664 | } |
| 5665 | case 'q': |
| 5666 | { |
| 5667 | if (LocaleCompare("quality",option+1) == 0) |
| 5668 | { |
| 5669 | if (*option == '+') |
| 5670 | break; |
| 5671 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5672 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5673 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5674 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5675 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5676 | break; |
| 5677 | } |
| 5678 | if (LocaleCompare("quantize",option+1) == 0) |
| 5679 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5680 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5681 | colorspace; |
| 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-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5687 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5688 | colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse, |
| 5689 | argv[i]); |
| 5690 | if (colorspace < 0) |
| 5691 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5692 | argv[i]); |
| 5693 | break; |
| 5694 | } |
| 5695 | if (LocaleCompare("quiet",option+1) == 0) |
| 5696 | break; |
| 5697 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5698 | } |
| 5699 | case 'r': |
| 5700 | { |
| 5701 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5702 | { |
| 5703 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5704 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5705 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5706 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5707 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5708 | break; |
| 5709 | } |
| 5710 | if (LocaleCompare("raise",option+1) == 0) |
| 5711 | { |
| 5712 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5713 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5714 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5715 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5716 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5717 | break; |
| 5718 | } |
| 5719 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5720 | { |
| 5721 | if (*option == '+') |
| 5722 | break; |
| 5723 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5724 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5725 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5726 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5727 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5728 | break; |
| 5729 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5730 | if (LocaleCompare("recolor",option+1) == 0) |
| 5731 | { |
| 5732 | if (*option == '+') |
| 5733 | break; |
| 5734 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5735 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5736 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5737 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5738 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5739 | break; |
| 5740 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5741 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5742 | { |
| 5743 | if (*option == '+') |
| 5744 | break; |
| 5745 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5746 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5747 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5748 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5749 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5750 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5751 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5752 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5753 | if (LocaleCompare("region",option+1) == 0) |
| 5754 | { |
| 5755 | if (*option == '+') |
| 5756 | break; |
| 5757 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5758 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5759 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5760 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5761 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5762 | break; |
| 5763 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5764 | if (LocaleCompare("remap",option+1) == 0) |
| 5765 | { |
| 5766 | if (*option == '+') |
| 5767 | break; |
| 5768 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5769 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5770 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5771 | break; |
| 5772 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5773 | if (LocaleCompare("render",option+1) == 0) |
| 5774 | break; |
| 5775 | if (LocaleCompare("repage",option+1) == 0) |
| 5776 | { |
| 5777 | if (*option == '+') |
| 5778 | break; |
| 5779 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5780 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5781 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5782 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5783 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5784 | break; |
| 5785 | } |
| 5786 | if (LocaleCompare("resample",option+1) == 0) |
| 5787 | { |
| 5788 | if (*option == '+') |
| 5789 | break; |
| 5790 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5791 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5792 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5793 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5794 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5795 | break; |
| 5796 | } |
| 5797 | if (LocaleCompare("resize",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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5805 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5806 | break; |
| 5807 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5808 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5809 | { |
| 5810 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5811 | break; |
| 5812 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5813 | if (LocaleCompare("reverse",option+1) == 0) |
| 5814 | break; |
| 5815 | if (LocaleCompare("roll",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("rotate",option+1) == 0) |
| 5827 | { |
| 5828 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5829 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5830 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5831 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5832 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5833 | break; |
| 5834 | } |
| 5835 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5836 | } |
| 5837 | case 's': |
| 5838 | { |
| 5839 | if (LocaleCompare("sample",option+1) == 0) |
| 5840 | { |
| 5841 | if (*option == '+') |
| 5842 | break; |
| 5843 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5844 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5845 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5846 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5847 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5848 | break; |
| 5849 | } |
| 5850 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5851 | { |
| 5852 | if (*option == '+') |
| 5853 | break; |
| 5854 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5855 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5856 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5857 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5858 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5859 | break; |
| 5860 | } |
| 5861 | if (LocaleCompare("scale",option+1) == 0) |
| 5862 | { |
| 5863 | if (*option == '+') |
| 5864 | break; |
| 5865 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5866 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5867 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5868 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5869 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5870 | break; |
| 5871 | } |
| 5872 | if (LocaleCompare("scene",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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5878 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5879 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5880 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5881 | break; |
| 5882 | } |
| 5883 | if (LocaleCompare("seed",option+1) == 0) |
| 5884 | { |
| 5885 | if (*option == '+') |
| 5886 | break; |
| 5887 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5888 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5889 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5890 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5891 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5892 | break; |
| 5893 | } |
| 5894 | if (LocaleCompare("segment",option+1) == 0) |
| 5895 | { |
| 5896 | if (*option == '+') |
| 5897 | break; |
| 5898 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5899 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5900 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5901 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5902 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5903 | break; |
| 5904 | } |
| 5905 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5906 | { |
| 5907 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5908 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5909 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5910 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5911 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5912 | break; |
| 5913 | } |
| 5914 | if (LocaleCompare("separate",option+1) == 0) |
| 5915 | break; |
| 5916 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5917 | { |
| 5918 | if (*option == '+') |
| 5919 | break; |
| 5920 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5921 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5922 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5923 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5924 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5925 | break; |
| 5926 | } |
| 5927 | if (LocaleCompare("set",option+1) == 0) |
| 5928 | { |
| 5929 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5930 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5931 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5932 | if (*option == '+') |
| 5933 | break; |
| 5934 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5935 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5936 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5937 | break; |
| 5938 | } |
| 5939 | if (LocaleCompare("shade",option+1) == 0) |
| 5940 | { |
| 5941 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5942 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5943 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5944 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5945 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5946 | break; |
| 5947 | } |
| 5948 | if (LocaleCompare("shadow",option+1) == 0) |
| 5949 | { |
| 5950 | if (*option == '+') |
| 5951 | break; |
| 5952 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5953 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5954 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5955 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5956 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5957 | break; |
| 5958 | } |
| 5959 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5960 | { |
| 5961 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5962 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5963 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5964 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5965 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5966 | break; |
| 5967 | } |
| 5968 | if (LocaleCompare("shave",option+1) == 0) |
| 5969 | { |
| 5970 | if (*option == '+') |
| 5971 | break; |
| 5972 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5973 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5974 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5975 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5976 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5977 | break; |
| 5978 | } |
| 5979 | if (LocaleCompare("shear",option+1) == 0) |
| 5980 | { |
| 5981 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5982 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5983 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5984 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5985 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5986 | break; |
| 5987 | } |
| 5988 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5989 | { |
| 5990 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5991 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5992 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5993 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5994 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5995 | break; |
| 5996 | } |
| 5997 | if (LocaleCompare("size",option+1) == 0) |
| 5998 | { |
| 5999 | if (*option == '+') |
| 6000 | break; |
| 6001 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6002 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6003 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6004 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6005 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6006 | break; |
| 6007 | } |
| 6008 | if (LocaleCompare("sketch",option+1) == 0) |
| 6009 | { |
| 6010 | if (*option == '+') |
| 6011 | break; |
| 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 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 6019 | if (LocaleCompare("smush",option+1) == 0) |
| 6020 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 6021 | i++; |
| 6022 | if (i == (ssize_t) argc) |
| 6023 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6024 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6025 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 6026 | i++; |
| 6027 | break; |
| 6028 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6029 | if (LocaleCompare("solarize",option+1) == 0) |
| 6030 | { |
| 6031 | if (*option == '+') |
| 6032 | break; |
| 6033 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6034 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6035 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6036 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6037 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6038 | break; |
| 6039 | } |
| 6040 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 6041 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6042 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6043 | op; |
| 6044 | |
| 6045 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6046 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6047 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6048 | op=ParseMagickOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
| 6049 | if (op < 0) |
| 6050 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 6051 | argv[i]); |
| 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 | if (LocaleCompare("spread",option+1) == 0) |
| 6058 | { |
| 6059 | if (*option == '+') |
| 6060 | break; |
| 6061 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6062 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6063 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6064 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6065 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6066 | break; |
| 6067 | } |
| 6068 | if (LocaleCompare("stretch",option+1) == 0) |
| 6069 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6070 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6071 | stretch; |
| 6072 | |
| 6073 | if (*option == '+') |
| 6074 | break; |
| 6075 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6076 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6077 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6078 | stretch=ParseMagickOption(MagickStretchOptions,MagickFalse,argv[i]); |
| 6079 | if (stretch < 0) |
| 6080 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 6081 | argv[i]); |
| 6082 | break; |
| 6083 | } |
| 6084 | if (LocaleCompare("strip",option+1) == 0) |
| 6085 | break; |
| 6086 | if (LocaleCompare("stroke",option+1) == 0) |
| 6087 | { |
| 6088 | if (*option == '+') |
| 6089 | break; |
| 6090 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6091 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6092 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6093 | break; |
| 6094 | } |
| 6095 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 6096 | { |
| 6097 | if (*option == '+') |
| 6098 | break; |
| 6099 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6100 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6101 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6102 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6103 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6104 | break; |
| 6105 | } |
| 6106 | if (LocaleCompare("style",option+1) == 0) |
| 6107 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6108 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6109 | style; |
| 6110 | |
| 6111 | if (*option == '+') |
| 6112 | break; |
| 6113 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6114 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6115 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6116 | style=ParseMagickOption(MagickStyleOptions,MagickFalse,argv[i]); |
| 6117 | if (style < 0) |
| 6118 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 6119 | argv[i]); |
| 6120 | break; |
| 6121 | } |
| 6122 | if (LocaleCompare("swirl",option+1) == 0) |
| 6123 | { |
| 6124 | if (*option == '+') |
| 6125 | break; |
| 6126 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6127 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6128 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6129 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6130 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6131 | break; |
| 6132 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 6133 | if (LocaleCompare("synchronize",option+1) == 0) |
| 6134 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6135 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6136 | } |
| 6137 | case 't': |
| 6138 | { |
| 6139 | if (LocaleCompare("taint",option+1) == 0) |
| 6140 | break; |
| 6141 | if (LocaleCompare("texture",option+1) == 0) |
| 6142 | { |
| 6143 | if (*option == '+') |
| 6144 | break; |
| 6145 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6146 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6147 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6148 | break; |
| 6149 | } |
| 6150 | if (LocaleCompare("tile",option+1) == 0) |
| 6151 | { |
| 6152 | if (*option == '+') |
| 6153 | break; |
| 6154 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6155 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6156 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6157 | break; |
| 6158 | } |
| 6159 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 6160 | { |
| 6161 | if (*option == '+') |
| 6162 | break; |
| 6163 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6164 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6165 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6166 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6167 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6168 | break; |
| 6169 | } |
| 6170 | if (LocaleCompare("tint",option+1) == 0) |
| 6171 | { |
| 6172 | if (*option == '+') |
| 6173 | break; |
| 6174 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6175 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6176 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6177 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6178 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6179 | break; |
| 6180 | } |
| 6181 | if (LocaleCompare("transform",option+1) == 0) |
| 6182 | break; |
| 6183 | if (LocaleCompare("transpose",option+1) == 0) |
| 6184 | break; |
| 6185 | if (LocaleCompare("transverse",option+1) == 0) |
| 6186 | break; |
| 6187 | if (LocaleCompare("threshold",option+1) == 0) |
| 6188 | { |
| 6189 | if (*option == '+') |
| 6190 | break; |
| 6191 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6192 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6193 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6194 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6195 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6196 | break; |
| 6197 | } |
| 6198 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 6199 | { |
| 6200 | if (*option == '+') |
| 6201 | break; |
| 6202 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6203 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6204 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6205 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6206 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6207 | break; |
| 6208 | } |
| 6209 | if (LocaleCompare("transparent",option+1) == 0) |
| 6210 | { |
| 6211 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6212 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6213 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6214 | break; |
| 6215 | } |
| 6216 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 6217 | { |
| 6218 | if (*option == '+') |
| 6219 | break; |
| 6220 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6221 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6222 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6223 | break; |
| 6224 | } |
| 6225 | if (LocaleCompare("treedepth",option+1) == 0) |
| 6226 | { |
| 6227 | if (*option == '+') |
| 6228 | break; |
| 6229 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6230 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6231 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6232 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6233 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6234 | break; |
| 6235 | } |
| 6236 | if (LocaleCompare("trim",option+1) == 0) |
| 6237 | break; |
| 6238 | if (LocaleCompare("type",option+1) == 0) |
| 6239 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6240 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6241 | type; |
| 6242 | |
| 6243 | if (*option == '+') |
| 6244 | break; |
| 6245 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6246 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6247 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6248 | type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]); |
| 6249 | if (type < 0) |
| 6250 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 6251 | argv[i]); |
| 6252 | break; |
| 6253 | } |
| 6254 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6255 | } |
| 6256 | case 'u': |
| 6257 | { |
| 6258 | if (LocaleCompare("undercolor",option+1) == 0) |
| 6259 | { |
| 6260 | if (*option == '+') |
| 6261 | break; |
| 6262 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6263 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6264 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6265 | break; |
| 6266 | } |
| 6267 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 6268 | break; |
| 6269 | if (LocaleCompare("units",option+1) == 0) |
| 6270 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6271 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6272 | units; |
| 6273 | |
| 6274 | if (*option == '+') |
| 6275 | break; |
| 6276 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6277 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6278 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6279 | units=ParseMagickOption(MagickResolutionOptions,MagickFalse, |
| 6280 | argv[i]); |
| 6281 | if (units < 0) |
| 6282 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 6283 | argv[i]); |
| 6284 | break; |
| 6285 | } |
| 6286 | if (LocaleCompare("unsharp",option+1) == 0) |
| 6287 | { |
| 6288 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6289 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6290 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6291 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6292 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6293 | break; |
| 6294 | } |
| 6295 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6296 | } |
| 6297 | case 'v': |
| 6298 | { |
| 6299 | if (LocaleCompare("verbose",option+1) == 0) |
| 6300 | { |
| 6301 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 6302 | break; |
| 6303 | } |
| 6304 | if ((LocaleCompare("version",option+1) == 0) || |
| 6305 | (LocaleCompare("-version",option+1) == 0)) |
| 6306 | { |
| 6307 | (void) fprintf(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6308 | GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 6309 | (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright()); |
| 6310 | (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6311 | break; |
| 6312 | } |
| 6313 | if (LocaleCompare("view",option+1) == 0) |
| 6314 | { |
| 6315 | if (*option == '+') |
| 6316 | break; |
| 6317 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6318 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6319 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6320 | break; |
| 6321 | } |
| 6322 | if (LocaleCompare("vignette",option+1) == 0) |
| 6323 | { |
| 6324 | if (*option == '+') |
| 6325 | break; |
| 6326 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6327 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6328 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6329 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6330 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6331 | break; |
| 6332 | } |
| 6333 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 6334 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6335 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6336 | method; |
| 6337 | |
| 6338 | if (*option == '+') |
| 6339 | break; |
| 6340 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6341 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6342 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6343 | method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse, |
| 6344 | argv[i]); |
| 6345 | if (method < 0) |
| 6346 | ThrowMogrifyException(OptionError, |
| 6347 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 6348 | break; |
| 6349 | } |
| 6350 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6351 | } |
| 6352 | case 'w': |
| 6353 | { |
| 6354 | if (LocaleCompare("wave",option+1) == 0) |
| 6355 | { |
| 6356 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6357 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6358 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6359 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6360 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6361 | break; |
| 6362 | } |
| 6363 | if (LocaleCompare("weight",option+1) == 0) |
| 6364 | { |
| 6365 | if (*option == '+') |
| 6366 | break; |
| 6367 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6368 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6369 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6370 | break; |
| 6371 | } |
| 6372 | if (LocaleCompare("white-point",option+1) == 0) |
| 6373 | { |
| 6374 | if (*option == '+') |
| 6375 | break; |
| 6376 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6377 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6378 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6379 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6380 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6381 | break; |
| 6382 | } |
| 6383 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6384 | { |
| 6385 | if (*option == '+') |
| 6386 | break; |
| 6387 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6388 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6389 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6390 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6391 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6392 | break; |
| 6393 | } |
| 6394 | if (LocaleCompare("write",option+1) == 0) |
| 6395 | { |
| 6396 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6397 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6398 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6399 | break; |
| 6400 | } |
| 6401 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6402 | } |
| 6403 | case '?': |
| 6404 | break; |
| 6405 | default: |
| 6406 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6407 | } |
| 6408 | fire=ParseMagickOption(MagickImageListOptions,MagickFalse,option+1) < 0 ? |
| 6409 | MagickFalse : MagickTrue; |
| 6410 | if (fire != MagickFalse) |
| 6411 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6412 | } |
| 6413 | if (k != 0) |
| 6414 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6415 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6416 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6417 | DestroyMogrify(); |
| 6418 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6419 | } |
| 6420 | |
| 6421 | /* |
| 6422 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6423 | % % |
| 6424 | % % |
| 6425 | % % |
| 6426 | + M o g r i f y I m a g e I n f o % |
| 6427 | % % |
| 6428 | % % |
| 6429 | % % |
| 6430 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6431 | % |
| 6432 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6433 | % prescribed by command line options. |
| 6434 | % |
| 6435 | % The format of the MogrifyImageInfo method is: |
| 6436 | % |
| 6437 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6438 | % const char **argv,ExceptionInfo *exception) |
| 6439 | % |
| 6440 | % A description of each parameter follows: |
| 6441 | % |
| 6442 | % o image_info: the image info.. |
| 6443 | % |
| 6444 | % o argc: Specifies a pointer to an integer describing the number of |
| 6445 | % elements in the argument vector. |
| 6446 | % |
| 6447 | % o argv: Specifies a pointer to a text array containing the command line |
| 6448 | % arguments. |
| 6449 | % |
| 6450 | % o exception: return any errors or warnings in this structure. |
| 6451 | % |
| 6452 | */ |
| 6453 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6454 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6455 | { |
| 6456 | const char |
| 6457 | *option; |
| 6458 | |
| 6459 | GeometryInfo |
| 6460 | geometry_info; |
| 6461 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6462 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6463 | count; |
| 6464 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6465 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6466 | i; |
| 6467 | |
| 6468 | /* |
| 6469 | Initialize method variables. |
| 6470 | */ |
| 6471 | assert(image_info != (ImageInfo *) NULL); |
| 6472 | assert(image_info->signature == MagickSignature); |
| 6473 | if (image_info->debug != MagickFalse) |
| 6474 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6475 | image_info->filename); |
| 6476 | if (argc < 0) |
| 6477 | return(MagickTrue); |
| 6478 | /* |
| 6479 | Set the image settings. |
| 6480 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6481 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6482 | { |
| 6483 | option=argv[i]; |
| 6484 | if (IsMagickOption(option) == MagickFalse) |
| 6485 | continue; |
| 6486 | count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option), |
| 6487 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6488 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6489 | break; |
| 6490 | switch (*(option+1)) |
| 6491 | { |
| 6492 | case 'a': |
| 6493 | { |
| 6494 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6495 | { |
| 6496 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6497 | break; |
| 6498 | } |
| 6499 | if (LocaleCompare("antialias",option+1) == 0) |
| 6500 | { |
| 6501 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6502 | break; |
| 6503 | } |
| 6504 | if (LocaleCompare("attenuate",option+1) == 0) |
| 6505 | { |
| 6506 | if (*option == '+') |
| 6507 | { |
| 6508 | (void) DeleteImageOption(image_info,option+1); |
| 6509 | break; |
| 6510 | } |
| 6511 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6512 | break; |
| 6513 | } |
| 6514 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6515 | { |
| 6516 | if (*option == '+') |
| 6517 | (void) CloneString(&image_info->authenticate,(char *) NULL); |
| 6518 | else |
| 6519 | (void) CloneString(&image_info->authenticate,argv[i+1]); |
| 6520 | break; |
| 6521 | } |
| 6522 | break; |
| 6523 | } |
| 6524 | case 'b': |
| 6525 | { |
| 6526 | if (LocaleCompare("background",option+1) == 0) |
| 6527 | { |
| 6528 | if (*option == '+') |
| 6529 | { |
| 6530 | (void) DeleteImageOption(image_info,option+1); |
| 6531 | (void) QueryColorDatabase(BackgroundColor, |
| 6532 | &image_info->background_color,exception); |
| 6533 | break; |
| 6534 | } |
| 6535 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6536 | (void) QueryColorDatabase(argv[i+1],&image_info->background_color, |
| 6537 | exception); |
| 6538 | break; |
| 6539 | } |
| 6540 | if (LocaleCompare("bias",option+1) == 0) |
| 6541 | { |
| 6542 | if (*option == '+') |
| 6543 | { |
| 6544 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6545 | break; |
| 6546 | } |
| 6547 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6548 | break; |
| 6549 | } |
| 6550 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6551 | { |
| 6552 | if (*option == '+') |
| 6553 | { |
| 6554 | (void) SetImageOption(image_info,option+1,"false"); |
| 6555 | break; |
| 6556 | } |
| 6557 | (void) SetImageOption(image_info,option+1,"true"); |
| 6558 | break; |
| 6559 | } |
| 6560 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6561 | { |
| 6562 | if (*option == '+') |
| 6563 | { |
| 6564 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6565 | break; |
| 6566 | } |
| 6567 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6568 | break; |
| 6569 | } |
| 6570 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6571 | { |
| 6572 | if (*option == '+') |
| 6573 | { |
| 6574 | (void) DeleteImageOption(image_info,option+1); |
| 6575 | (void) QueryColorDatabase(BorderColor,&image_info->border_color, |
| 6576 | exception); |
| 6577 | break; |
| 6578 | } |
| 6579 | (void) QueryColorDatabase(argv[i+1],&image_info->border_color, |
| 6580 | exception); |
| 6581 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6582 | break; |
| 6583 | } |
| 6584 | if (LocaleCompare("box",option+1) == 0) |
| 6585 | { |
| 6586 | if (*option == '+') |
| 6587 | { |
| 6588 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6589 | break; |
| 6590 | } |
| 6591 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6592 | break; |
| 6593 | } |
| 6594 | break; |
| 6595 | } |
| 6596 | case 'c': |
| 6597 | { |
| 6598 | if (LocaleCompare("cache",option+1) == 0) |
| 6599 | { |
| 6600 | MagickSizeType |
| 6601 | limit; |
| 6602 | |
| 6603 | limit=MagickResourceInfinity; |
| 6604 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6605 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6606 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6607 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6608 | break; |
| 6609 | } |
| 6610 | if (LocaleCompare("caption",option+1) == 0) |
| 6611 | { |
| 6612 | if (*option == '+') |
| 6613 | { |
| 6614 | (void) DeleteImageOption(image_info,option+1); |
| 6615 | break; |
| 6616 | } |
| 6617 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6618 | break; |
| 6619 | } |
| 6620 | if (LocaleCompare("channel",option+1) == 0) |
| 6621 | { |
| 6622 | if (*option == '+') |
| 6623 | { |
| 6624 | image_info->channel=DefaultChannels; |
| 6625 | break; |
| 6626 | } |
| 6627 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6628 | break; |
| 6629 | } |
| 6630 | if (LocaleCompare("colors",option+1) == 0) |
| 6631 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6632 | image_info->colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6633 | break; |
| 6634 | } |
| 6635 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6636 | { |
| 6637 | if (*option == '+') |
| 6638 | { |
| 6639 | image_info->colorspace=UndefinedColorspace; |
| 6640 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6641 | break; |
| 6642 | } |
| 6643 | image_info->colorspace=(ColorspaceType) ParseMagickOption( |
| 6644 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6645 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6646 | break; |
| 6647 | } |
| 6648 | if (LocaleCompare("compress",option+1) == 0) |
| 6649 | { |
| 6650 | if (*option == '+') |
| 6651 | { |
| 6652 | image_info->compression=UndefinedCompression; |
| 6653 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6654 | break; |
| 6655 | } |
| 6656 | image_info->compression=(CompressionType) ParseMagickOption( |
| 6657 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6658 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6659 | break; |
| 6660 | } |
| 6661 | if (LocaleCompare("comment",option+1) == 0) |
| 6662 | { |
| 6663 | if (*option == '+') |
| 6664 | { |
| 6665 | (void) DeleteImageOption(image_info,option+1); |
| 6666 | break; |
| 6667 | } |
| 6668 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6669 | break; |
| 6670 | } |
| 6671 | if (LocaleCompare("compose",option+1) == 0) |
| 6672 | { |
| 6673 | if (*option == '+') |
| 6674 | { |
| 6675 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6676 | break; |
| 6677 | } |
| 6678 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6679 | break; |
| 6680 | } |
| 6681 | if (LocaleCompare("compress",option+1) == 0) |
| 6682 | { |
| 6683 | if (*option == '+') |
| 6684 | { |
| 6685 | image_info->compression=UndefinedCompression; |
| 6686 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6687 | break; |
| 6688 | } |
| 6689 | image_info->compression=(CompressionType) ParseMagickOption( |
| 6690 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6691 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6692 | break; |
| 6693 | } |
| 6694 | break; |
| 6695 | } |
| 6696 | case 'd': |
| 6697 | { |
| 6698 | if (LocaleCompare("debug",option+1) == 0) |
| 6699 | { |
| 6700 | if (*option == '+') |
| 6701 | (void) SetLogEventMask("none"); |
| 6702 | else |
| 6703 | (void) SetLogEventMask(argv[i+1]); |
| 6704 | image_info->debug=IsEventLogging(); |
| 6705 | break; |
| 6706 | } |
| 6707 | if (LocaleCompare("define",option+1) == 0) |
| 6708 | { |
| 6709 | if (*option == '+') |
| 6710 | { |
| 6711 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6712 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6713 | else |
| 6714 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6715 | break; |
| 6716 | } |
| 6717 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6718 | { |
| 6719 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6720 | exception); |
| 6721 | break; |
| 6722 | } |
| 6723 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6724 | break; |
| 6725 | } |
| 6726 | if (LocaleCompare("delay",option+1) == 0) |
| 6727 | { |
| 6728 | if (*option == '+') |
| 6729 | { |
| 6730 | (void) SetImageOption(image_info,option+1,"0"); |
| 6731 | break; |
| 6732 | } |
| 6733 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6734 | break; |
| 6735 | } |
| 6736 | if (LocaleCompare("density",option+1) == 0) |
| 6737 | { |
| 6738 | /* |
| 6739 | Set image density. |
| 6740 | */ |
| 6741 | if (*option == '+') |
| 6742 | { |
| 6743 | if (image_info->density != (char *) NULL) |
| 6744 | image_info->density=DestroyString(image_info->density); |
| 6745 | (void) SetImageOption(image_info,option+1,"72"); |
| 6746 | break; |
| 6747 | } |
| 6748 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6749 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6750 | break; |
| 6751 | } |
| 6752 | if (LocaleCompare("depth",option+1) == 0) |
| 6753 | { |
| 6754 | if (*option == '+') |
| 6755 | { |
| 6756 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6757 | break; |
| 6758 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6759 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6760 | break; |
| 6761 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6762 | if (LocaleCompare("direction",option+1) == 0) |
| 6763 | { |
| 6764 | if (*option == '+') |
| 6765 | { |
| 6766 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6767 | break; |
| 6768 | } |
| 6769 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6770 | break; |
| 6771 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6772 | if (LocaleCompare("display",option+1) == 0) |
| 6773 | { |
| 6774 | if (*option == '+') |
| 6775 | { |
| 6776 | if (image_info->server_name != (char *) NULL) |
| 6777 | image_info->server_name=DestroyString( |
| 6778 | image_info->server_name); |
| 6779 | break; |
| 6780 | } |
| 6781 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6782 | break; |
| 6783 | } |
| 6784 | if (LocaleCompare("dispose",option+1) == 0) |
| 6785 | { |
| 6786 | if (*option == '+') |
| 6787 | { |
| 6788 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6789 | break; |
| 6790 | } |
| 6791 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6792 | break; |
| 6793 | } |
| 6794 | if (LocaleCompare("dither",option+1) == 0) |
| 6795 | { |
| 6796 | if (*option == '+') |
| 6797 | { |
| 6798 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6799 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6800 | break; |
| 6801 | } |
| 6802 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6803 | image_info->dither=MagickTrue; |
| 6804 | break; |
| 6805 | } |
| 6806 | break; |
| 6807 | } |
| 6808 | case 'e': |
| 6809 | { |
| 6810 | if (LocaleCompare("encoding",option+1) == 0) |
| 6811 | { |
| 6812 | if (*option == '+') |
| 6813 | { |
| 6814 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6815 | break; |
| 6816 | } |
| 6817 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6818 | break; |
| 6819 | } |
| 6820 | if (LocaleCompare("endian",option+1) == 0) |
| 6821 | { |
| 6822 | if (*option == '+') |
| 6823 | { |
| 6824 | image_info->endian=UndefinedEndian; |
| 6825 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6826 | break; |
| 6827 | } |
| 6828 | image_info->endian=(EndianType) ParseMagickOption( |
| 6829 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6830 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6831 | break; |
| 6832 | } |
| 6833 | if (LocaleCompare("extract",option+1) == 0) |
| 6834 | { |
| 6835 | /* |
| 6836 | Set image extract geometry. |
| 6837 | */ |
| 6838 | if (*option == '+') |
| 6839 | { |
| 6840 | if (image_info->extract != (char *) NULL) |
| 6841 | image_info->extract=DestroyString(image_info->extract); |
| 6842 | break; |
| 6843 | } |
| 6844 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6845 | break; |
| 6846 | } |
| 6847 | break; |
| 6848 | } |
| 6849 | case 'f': |
| 6850 | { |
| 6851 | if (LocaleCompare("fill",option+1) == 0) |
| 6852 | { |
| 6853 | if (*option == '+') |
| 6854 | { |
| 6855 | (void) SetImageOption(image_info,option+1,"none"); |
| 6856 | break; |
| 6857 | } |
| 6858 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6859 | break; |
| 6860 | } |
| 6861 | if (LocaleCompare("filter",option+1) == 0) |
| 6862 | { |
| 6863 | if (*option == '+') |
| 6864 | { |
| 6865 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6866 | break; |
| 6867 | } |
| 6868 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6869 | break; |
| 6870 | } |
| 6871 | if (LocaleCompare("font",option+1) == 0) |
| 6872 | { |
| 6873 | if (*option == '+') |
| 6874 | { |
| 6875 | if (image_info->font != (char *) NULL) |
| 6876 | image_info->font=DestroyString(image_info->font); |
| 6877 | break; |
| 6878 | } |
| 6879 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6880 | break; |
| 6881 | } |
| 6882 | if (LocaleCompare("format",option+1) == 0) |
| 6883 | { |
| 6884 | register const char |
| 6885 | *q; |
| 6886 | |
| 6887 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
| 6888 | if (strchr("gkrz@[#",*(q+1)) != (char *) NULL) |
| 6889 | image_info->ping=MagickFalse; |
| 6890 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6891 | break; |
| 6892 | } |
| 6893 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6894 | { |
| 6895 | if (*option == '+') |
| 6896 | { |
| 6897 | image_info->fuzz=0.0; |
| 6898 | (void) SetImageOption(image_info,option+1,"0"); |
| 6899 | break; |
| 6900 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6901 | image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6902 | 1.0); |
| 6903 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6904 | break; |
| 6905 | } |
| 6906 | break; |
| 6907 | } |
| 6908 | case 'g': |
| 6909 | { |
| 6910 | if (LocaleCompare("gravity",option+1) == 0) |
| 6911 | { |
| 6912 | if (*option == '+') |
| 6913 | { |
| 6914 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6915 | break; |
| 6916 | } |
| 6917 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6918 | break; |
| 6919 | } |
| 6920 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6921 | { |
| 6922 | if (*option == '+') |
| 6923 | { |
| 6924 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6925 | break; |
| 6926 | } |
| 6927 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6928 | break; |
| 6929 | } |
| 6930 | break; |
| 6931 | } |
| 6932 | case 'i': |
| 6933 | { |
| 6934 | if (LocaleCompare("intent",option+1) == 0) |
| 6935 | { |
| 6936 | if (*option == '+') |
| 6937 | { |
| 6938 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6939 | break; |
| 6940 | } |
| 6941 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6942 | break; |
| 6943 | } |
| 6944 | if (LocaleCompare("interlace",option+1) == 0) |
| 6945 | { |
| 6946 | if (*option == '+') |
| 6947 | { |
| 6948 | image_info->interlace=UndefinedInterlace; |
| 6949 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6950 | break; |
| 6951 | } |
| 6952 | image_info->interlace=(InterlaceType) ParseMagickOption( |
| 6953 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6954 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6955 | break; |
| 6956 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6957 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6958 | { |
| 6959 | if (*option == '+') |
| 6960 | { |
| 6961 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6962 | break; |
| 6963 | } |
| 6964 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6965 | break; |
| 6966 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6967 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6968 | { |
| 6969 | if (*option == '+') |
| 6970 | { |
| 6971 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6972 | break; |
| 6973 | } |
| 6974 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6975 | break; |
| 6976 | } |
| 6977 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6978 | { |
| 6979 | if (*option == '+') |
| 6980 | { |
| 6981 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6982 | break; |
| 6983 | } |
| 6984 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6985 | break; |
| 6986 | } |
| 6987 | break; |
| 6988 | } |
| 6989 | case 'k': |
| 6990 | { |
| 6991 | if (LocaleCompare("kerning",option+1) == 0) |
| 6992 | { |
| 6993 | if (*option == '+') |
| 6994 | { |
| 6995 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6996 | break; |
| 6997 | } |
| 6998 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6999 | break; |
| 7000 | } |
| 7001 | break; |
| 7002 | } |
| 7003 | case 'l': |
| 7004 | { |
| 7005 | if (LocaleCompare("label",option+1) == 0) |
| 7006 | { |
| 7007 | if (*option == '+') |
| 7008 | { |
| 7009 | (void) DeleteImageOption(image_info,option+1); |
| 7010 | break; |
| 7011 | } |
| 7012 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7013 | break; |
| 7014 | } |
| 7015 | if (LocaleCompare("limit",option+1) == 0) |
| 7016 | { |
| 7017 | MagickSizeType |
| 7018 | limit; |
| 7019 | |
| 7020 | ResourceType |
| 7021 | type; |
| 7022 | |
| 7023 | if (*option == '+') |
| 7024 | break; |
| 7025 | type=(ResourceType) ParseMagickOption(MagickResourceOptions, |
| 7026 | MagickFalse,argv[i+1]); |
| 7027 | limit=MagickResourceInfinity; |
| 7028 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 7029 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7030 | (void) SetMagickResourceLimit(type,limit); |
| 7031 | break; |
| 7032 | } |
| 7033 | if (LocaleCompare("list",option+1) == 0) |
| 7034 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7035 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7036 | list; |
| 7037 | |
| 7038 | /* |
| 7039 | Display configuration list. |
| 7040 | */ |
| 7041 | list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i+1]); |
| 7042 | switch (list) |
| 7043 | { |
| 7044 | case MagickCoderOptions: |
| 7045 | { |
| 7046 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 7047 | break; |
| 7048 | } |
| 7049 | case MagickColorOptions: |
| 7050 | { |
| 7051 | (void) ListColorInfo((FILE *) NULL,exception); |
| 7052 | break; |
| 7053 | } |
| 7054 | case MagickConfigureOptions: |
| 7055 | { |
| 7056 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 7057 | break; |
| 7058 | } |
| 7059 | case MagickDelegateOptions: |
| 7060 | { |
| 7061 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 7062 | break; |
| 7063 | } |
| 7064 | case MagickFontOptions: |
| 7065 | { |
| 7066 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 7067 | break; |
| 7068 | } |
| 7069 | case MagickFormatOptions: |
| 7070 | { |
| 7071 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 7072 | break; |
| 7073 | } |
| 7074 | case MagickLocaleOptions: |
| 7075 | { |
| 7076 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 7077 | break; |
| 7078 | } |
| 7079 | case MagickLogOptions: |
| 7080 | { |
| 7081 | (void) ListLogInfo((FILE *) NULL,exception); |
| 7082 | break; |
| 7083 | } |
| 7084 | case MagickMagicOptions: |
| 7085 | { |
| 7086 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 7087 | break; |
| 7088 | } |
| 7089 | case MagickMimeOptions: |
| 7090 | { |
| 7091 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 7092 | break; |
| 7093 | } |
| 7094 | case MagickModuleOptions: |
| 7095 | { |
| 7096 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 7097 | break; |
| 7098 | } |
| 7099 | case MagickPolicyOptions: |
| 7100 | { |
| 7101 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 7102 | break; |
| 7103 | } |
| 7104 | case MagickResourceOptions: |
| 7105 | { |
| 7106 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 7107 | break; |
| 7108 | } |
| 7109 | case MagickThresholdOptions: |
| 7110 | { |
| 7111 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 7112 | break; |
| 7113 | } |
| 7114 | default: |
| 7115 | { |
| 7116 | (void) ListMagickOptions((FILE *) NULL,(MagickOption) list, |
| 7117 | exception); |
| 7118 | break; |
| 7119 | } |
| 7120 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 7121 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7122 | } |
| 7123 | if (LocaleCompare("log",option+1) == 0) |
| 7124 | { |
| 7125 | if (*option == '+') |
| 7126 | break; |
| 7127 | (void) SetLogFormat(argv[i+1]); |
| 7128 | break; |
| 7129 | } |
| 7130 | if (LocaleCompare("loop",option+1) == 0) |
| 7131 | { |
| 7132 | if (*option == '+') |
| 7133 | { |
| 7134 | (void) SetImageOption(image_info,option+1,"0"); |
| 7135 | break; |
| 7136 | } |
| 7137 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7138 | break; |
| 7139 | } |
| 7140 | break; |
| 7141 | } |
| 7142 | case 'm': |
| 7143 | { |
| 7144 | if (LocaleCompare("matte",option+1) == 0) |
| 7145 | { |
| 7146 | if (*option == '+') |
| 7147 | { |
| 7148 | (void) SetImageOption(image_info,option+1,"false"); |
| 7149 | break; |
| 7150 | } |
| 7151 | (void) SetImageOption(image_info,option+1,"true"); |
| 7152 | break; |
| 7153 | } |
| 7154 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 7155 | { |
| 7156 | if (*option == '+') |
| 7157 | { |
| 7158 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7159 | (void) QueryColorDatabase(MatteColor,&image_info->matte_color, |
| 7160 | exception); |
| 7161 | break; |
| 7162 | } |
| 7163 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7164 | (void) QueryColorDatabase(argv[i+1],&image_info->matte_color, |
| 7165 | exception); |
| 7166 | break; |
| 7167 | } |
| 7168 | if (LocaleCompare("monitor",option+1) == 0) |
| 7169 | { |
| 7170 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 7171 | (void *) NULL); |
| 7172 | break; |
| 7173 | } |
| 7174 | if (LocaleCompare("monochrome",option+1) == 0) |
| 7175 | { |
| 7176 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 7177 | break; |
| 7178 | } |
| 7179 | break; |
| 7180 | } |
| 7181 | case 'o': |
| 7182 | { |
| 7183 | if (LocaleCompare("orient",option+1) == 0) |
| 7184 | { |
| 7185 | if (*option == '+') |
| 7186 | { |
| 7187 | image_info->orientation=UndefinedOrientation; |
| 7188 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7189 | break; |
| 7190 | } |
| 7191 | image_info->orientation=(OrientationType) ParseMagickOption( |
| 7192 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 7193 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7194 | break; |
| 7195 | } |
| 7196 | } |
| 7197 | case 'p': |
| 7198 | { |
| 7199 | if (LocaleCompare("page",option+1) == 0) |
| 7200 | { |
| 7201 | char |
| 7202 | *canonical_page, |
| 7203 | page[MaxTextExtent]; |
| 7204 | |
| 7205 | const char |
| 7206 | *image_option; |
| 7207 | |
| 7208 | MagickStatusType |
| 7209 | flags; |
| 7210 | |
| 7211 | RectangleInfo |
| 7212 | geometry; |
| 7213 | |
| 7214 | if (*option == '+') |
| 7215 | { |
| 7216 | (void) DeleteImageOption(image_info,option+1); |
| 7217 | (void) CloneString(&image_info->page,(char *) NULL); |
| 7218 | break; |
| 7219 | } |
| 7220 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 7221 | image_option=GetImageOption(image_info,"page"); |
| 7222 | if (image_option != (const char *) NULL) |
| 7223 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 7224 | canonical_page=GetPageGeometry(argv[i+1]); |
| 7225 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 7226 | canonical_page=DestroyString(canonical_page); |
| 7227 | (void) FormatMagickString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 7228 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7229 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 7230 | (void) FormatMagickString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 7231 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 7232 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7233 | (void) SetImageOption(image_info,option+1,page); |
| 7234 | (void) CloneString(&image_info->page,page); |
| 7235 | break; |
| 7236 | } |
| 7237 | if (LocaleCompare("pen",option+1) == 0) |
| 7238 | { |
| 7239 | if (*option == '+') |
| 7240 | { |
| 7241 | (void) SetImageOption(image_info,option+1,"none"); |
| 7242 | break; |
| 7243 | } |
| 7244 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7245 | break; |
| 7246 | } |
| 7247 | if (LocaleCompare("ping",option+1) == 0) |
| 7248 | { |
| 7249 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 7250 | break; |
| 7251 | } |
| 7252 | if (LocaleCompare("pointsize",option+1) == 0) |
| 7253 | { |
| 7254 | if (*option == '+') |
| 7255 | geometry_info.rho=0.0; |
| 7256 | else |
| 7257 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 7258 | image_info->pointsize=geometry_info.rho; |
| 7259 | break; |
| 7260 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 7261 | if (LocaleCompare("precision",option+1) == 0) |
| 7262 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 7263 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 7264 | break; |
| 7265 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7266 | if (LocaleCompare("preview",option+1) == 0) |
| 7267 | { |
| 7268 | /* |
| 7269 | Preview image. |
| 7270 | */ |
| 7271 | if (*option == '+') |
| 7272 | { |
| 7273 | image_info->preview_type=UndefinedPreview; |
| 7274 | break; |
| 7275 | } |
| 7276 | image_info->preview_type=(PreviewType) ParseMagickOption( |
| 7277 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 7278 | break; |
| 7279 | } |
| 7280 | break; |
| 7281 | } |
| 7282 | case 'q': |
| 7283 | { |
| 7284 | if (LocaleCompare("quality",option+1) == 0) |
| 7285 | { |
| 7286 | /* |
| 7287 | Set image compression quality. |
| 7288 | */ |
| 7289 | if (*option == '+') |
| 7290 | { |
| 7291 | image_info->quality=UndefinedCompressionQuality; |
| 7292 | (void) SetImageOption(image_info,option+1,"0"); |
| 7293 | break; |
| 7294 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7295 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7296 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7297 | break; |
| 7298 | } |
| 7299 | if (LocaleCompare("quiet",option+1) == 0) |
| 7300 | { |
| 7301 | static WarningHandler |
| 7302 | warning_handler = (WarningHandler) NULL; |
| 7303 | |
| 7304 | if (*option == '+') |
| 7305 | { |
| 7306 | /* |
| 7307 | Restore error or warning messages. |
| 7308 | */ |
| 7309 | warning_handler=SetWarningHandler(warning_handler); |
| 7310 | break; |
| 7311 | } |
| 7312 | /* |
| 7313 | Suppress error or warning messages. |
| 7314 | */ |
| 7315 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 7316 | break; |
| 7317 | } |
| 7318 | break; |
| 7319 | } |
| 7320 | case 'r': |
| 7321 | { |
| 7322 | if (LocaleCompare("red-primary",option+1) == 0) |
| 7323 | { |
| 7324 | if (*option == '+') |
| 7325 | { |
| 7326 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7327 | break; |
| 7328 | } |
| 7329 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7330 | break; |
| 7331 | } |
| 7332 | break; |
| 7333 | } |
| 7334 | case 's': |
| 7335 | { |
| 7336 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 7337 | { |
| 7338 | /* |
| 7339 | Set image sampling factor. |
| 7340 | */ |
| 7341 | if (*option == '+') |
| 7342 | { |
| 7343 | if (image_info->sampling_factor != (char *) NULL) |
| 7344 | image_info->sampling_factor=DestroyString( |
| 7345 | image_info->sampling_factor); |
| 7346 | break; |
| 7347 | } |
| 7348 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 7349 | break; |
| 7350 | } |
| 7351 | if (LocaleCompare("scene",option+1) == 0) |
| 7352 | { |
| 7353 | /* |
| 7354 | Set image scene. |
| 7355 | */ |
| 7356 | if (*option == '+') |
| 7357 | { |
| 7358 | image_info->scene=0; |
| 7359 | (void) SetImageOption(image_info,option+1,"0"); |
| 7360 | break; |
| 7361 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7362 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7363 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7364 | break; |
| 7365 | } |
| 7366 | if (LocaleCompare("seed",option+1) == 0) |
| 7367 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7368 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7369 | seed; |
| 7370 | |
| 7371 | if (*option == '+') |
| 7372 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7373 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7374 | SeedPseudoRandomGenerator(seed); |
| 7375 | break; |
| 7376 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7377 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7378 | SeedPseudoRandomGenerator(seed); |
| 7379 | break; |
| 7380 | } |
| 7381 | if (LocaleCompare("size",option+1) == 0) |
| 7382 | { |
| 7383 | if (*option == '+') |
| 7384 | { |
| 7385 | if (image_info->size != (char *) NULL) |
| 7386 | image_info->size=DestroyString(image_info->size); |
| 7387 | break; |
| 7388 | } |
| 7389 | (void) CloneString(&image_info->size,argv[i+1]); |
| 7390 | break; |
| 7391 | } |
| 7392 | if (LocaleCompare("stroke",option+1) == 0) |
| 7393 | { |
| 7394 | if (*option == '+') |
| 7395 | { |
| 7396 | (void) SetImageOption(image_info,option+1,"none"); |
| 7397 | break; |
| 7398 | } |
| 7399 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7400 | break; |
| 7401 | } |
| 7402 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7403 | { |
| 7404 | if (*option == '+') |
| 7405 | { |
| 7406 | (void) SetImageOption(image_info,option+1,"0"); |
| 7407 | break; |
| 7408 | } |
| 7409 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7410 | break; |
| 7411 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7412 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7413 | { |
| 7414 | if (*option == '+') |
| 7415 | { |
| 7416 | image_info->synchronize=MagickFalse; |
| 7417 | break; |
| 7418 | } |
| 7419 | image_info->synchronize=MagickTrue; |
| 7420 | break; |
| 7421 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7422 | break; |
| 7423 | } |
| 7424 | case 't': |
| 7425 | { |
| 7426 | if (LocaleCompare("taint",option+1) == 0) |
| 7427 | { |
| 7428 | if (*option == '+') |
| 7429 | { |
| 7430 | (void) SetImageOption(image_info,option+1,"false"); |
| 7431 | break; |
| 7432 | } |
| 7433 | (void) SetImageOption(image_info,option+1,"true"); |
| 7434 | break; |
| 7435 | } |
| 7436 | if (LocaleCompare("texture",option+1) == 0) |
| 7437 | { |
| 7438 | if (*option == '+') |
| 7439 | { |
| 7440 | if (image_info->texture != (char *) NULL) |
| 7441 | image_info->texture=DestroyString(image_info->texture); |
| 7442 | break; |
| 7443 | } |
| 7444 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7445 | break; |
| 7446 | } |
| 7447 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7448 | { |
| 7449 | if (*option == '+') |
| 7450 | { |
| 7451 | (void) SetImageOption(image_info,option+1,"0"); |
| 7452 | break; |
| 7453 | } |
| 7454 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7455 | break; |
| 7456 | } |
| 7457 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7458 | { |
| 7459 | if (*option == '+') |
| 7460 | { |
| 7461 | (void) QueryColorDatabase("none",&image_info->transparent_color, exception); |
| 7462 | (void) SetImageOption(image_info,option+1,"none"); |
| 7463 | break; |
| 7464 | } |
| 7465 | (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color, |
| 7466 | exception); |
| 7467 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7468 | break; |
| 7469 | } |
| 7470 | if (LocaleCompare("type",option+1) == 0) |
| 7471 | { |
| 7472 | if (*option == '+') |
| 7473 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7474 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7475 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7476 | break; |
| 7477 | } |
| 7478 | image_info->type=(ImageType) ParseMagickOption(MagickTypeOptions, |
| 7479 | MagickFalse,argv[i+1]); |
| 7480 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7481 | break; |
| 7482 | } |
| 7483 | break; |
| 7484 | } |
| 7485 | case 'u': |
| 7486 | { |
| 7487 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7488 | { |
| 7489 | if (*option == '+') |
| 7490 | { |
| 7491 | (void) DeleteImageOption(image_info,option+1); |
| 7492 | break; |
| 7493 | } |
| 7494 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7495 | break; |
| 7496 | } |
| 7497 | if (LocaleCompare("units",option+1) == 0) |
| 7498 | { |
| 7499 | if (*option == '+') |
| 7500 | { |
| 7501 | image_info->units=UndefinedResolution; |
| 7502 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7503 | break; |
| 7504 | } |
| 7505 | image_info->units=(ResolutionType) ParseMagickOption( |
| 7506 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7507 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7508 | break; |
| 7509 | } |
| 7510 | break; |
| 7511 | } |
| 7512 | case 'v': |
| 7513 | { |
| 7514 | if (LocaleCompare("verbose",option+1) == 0) |
| 7515 | { |
| 7516 | if (*option == '+') |
| 7517 | { |
| 7518 | image_info->verbose=MagickFalse; |
| 7519 | break; |
| 7520 | } |
| 7521 | image_info->verbose=MagickTrue; |
| 7522 | image_info->ping=MagickFalse; |
| 7523 | break; |
| 7524 | } |
| 7525 | if (LocaleCompare("view",option+1) == 0) |
| 7526 | { |
| 7527 | if (*option == '+') |
| 7528 | { |
| 7529 | if (image_info->view != (char *) NULL) |
| 7530 | image_info->view=DestroyString(image_info->view); |
| 7531 | break; |
| 7532 | } |
| 7533 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7534 | break; |
| 7535 | } |
| 7536 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7537 | { |
| 7538 | if (*option == '+') |
| 7539 | { |
| 7540 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7541 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7542 | break; |
| 7543 | } |
| 7544 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
| 7545 | ParseMagickOption(MagickVirtualPixelOptions,MagickFalse, |
| 7546 | argv[i+1]); |
| 7547 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7548 | break; |
| 7549 | } |
| 7550 | break; |
| 7551 | } |
| 7552 | case 'w': |
| 7553 | { |
| 7554 | if (LocaleCompare("white-point",option+1) == 0) |
| 7555 | { |
| 7556 | if (*option == '+') |
| 7557 | { |
| 7558 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7559 | break; |
| 7560 | } |
| 7561 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7562 | break; |
| 7563 | } |
| 7564 | break; |
| 7565 | } |
| 7566 | default: |
| 7567 | break; |
| 7568 | } |
| 7569 | i+=count; |
| 7570 | } |
| 7571 | return(MagickTrue); |
| 7572 | } |
| 7573 | |
| 7574 | /* |
| 7575 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7576 | % % |
| 7577 | % % |
| 7578 | % % |
| 7579 | + M o g r i f y I m a g e L i s t % |
| 7580 | % % |
| 7581 | % % |
| 7582 | % % |
| 7583 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7584 | % |
| 7585 | % MogrifyImageList() applies any command line options that might affect the |
| 7586 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7587 | % |
| 7588 | % The format of the MogrifyImage method is: |
| 7589 | % |
| 7590 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7591 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7592 | % |
| 7593 | % A description of each parameter follows: |
| 7594 | % |
| 7595 | % o image_info: the image info.. |
| 7596 | % |
| 7597 | % o argc: Specifies a pointer to an integer describing the number of |
| 7598 | % elements in the argument vector. |
| 7599 | % |
| 7600 | % o argv: Specifies a pointer to a text array containing the command line |
| 7601 | % arguments. |
| 7602 | % |
| 7603 | % o images: the images. |
| 7604 | % |
| 7605 | % o exception: return any errors or warnings in this structure. |
| 7606 | % |
| 7607 | */ |
| 7608 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7609 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7610 | { |
| 7611 | ChannelType |
| 7612 | channel; |
| 7613 | |
| 7614 | const char |
| 7615 | *option; |
| 7616 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7617 | ImageInfo |
| 7618 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7619 | |
| 7620 | MagickStatusType |
| 7621 | status; |
| 7622 | |
| 7623 | QuantizeInfo |
| 7624 | *quantize_info; |
| 7625 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7626 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7627 | i; |
| 7628 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7629 | ssize_t |
| 7630 | count, |
| 7631 | index; |
| 7632 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7633 | /* |
| 7634 | Apply options to the image list. |
| 7635 | */ |
| 7636 | assert(image_info != (ImageInfo *) NULL); |
| 7637 | assert(image_info->signature == MagickSignature); |
| 7638 | assert(images != (Image **) NULL); |
| 7639 | assert((*images)->signature == MagickSignature); |
| 7640 | if ((*images)->debug != MagickFalse) |
| 7641 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7642 | (*images)->filename); |
| 7643 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7644 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7645 | mogrify_info=CloneImageInfo(image_info); |
| 7646 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 7647 | channel=mogrify_info->channel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7648 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7649 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7650 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7651 | if (*images == (Image *) NULL) |
| 7652 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7653 | option=argv[i]; |
| 7654 | if (IsMagickOption(option) == MagickFalse) |
| 7655 | continue; |
| 7656 | count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option), |
| 7657 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7658 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7659 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7660 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7661 | switch (*(option+1)) |
| 7662 | { |
| 7663 | case 'a': |
| 7664 | { |
| 7665 | if (LocaleCompare("affinity",option+1) == 0) |
| 7666 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7667 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7668 | if (*option == '+') |
| 7669 | { |
| 7670 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7671 | InheritException(exception,&(*images)->exception); |
| 7672 | break; |
| 7673 | } |
| 7674 | i++; |
| 7675 | break; |
| 7676 | } |
| 7677 | if (LocaleCompare("append",option+1) == 0) |
| 7678 | { |
| 7679 | Image |
| 7680 | *append_image; |
| 7681 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7682 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7683 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7684 | MagickFalse,exception); |
| 7685 | if (append_image == (Image *) NULL) |
| 7686 | { |
| 7687 | status=MagickFalse; |
| 7688 | break; |
| 7689 | } |
| 7690 | *images=DestroyImageList(*images); |
| 7691 | *images=append_image; |
| 7692 | break; |
| 7693 | } |
| 7694 | if (LocaleCompare("average",option+1) == 0) |
| 7695 | { |
| 7696 | Image |
| 7697 | *average_image; |
| 7698 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7699 | /* |
| 7700 | Average an image sequence (deprecated). |
| 7701 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7702 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7703 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7704 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7705 | if (average_image == (Image *) NULL) |
| 7706 | { |
| 7707 | status=MagickFalse; |
| 7708 | break; |
| 7709 | } |
| 7710 | *images=DestroyImageList(*images); |
| 7711 | *images=average_image; |
| 7712 | break; |
| 7713 | } |
| 7714 | break; |
| 7715 | } |
| 7716 | case 'c': |
| 7717 | { |
| 7718 | if (LocaleCompare("channel",option+1) == 0) |
| 7719 | { |
| 7720 | if (*option == '+') |
| 7721 | { |
| 7722 | channel=DefaultChannels; |
| 7723 | break; |
| 7724 | } |
| 7725 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 7726 | break; |
| 7727 | } |
| 7728 | if (LocaleCompare("clut",option+1) == 0) |
| 7729 | { |
| 7730 | Image |
| 7731 | *clut_image, |
| 7732 | *image; |
| 7733 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7734 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7735 | image=RemoveFirstImageFromList(images); |
| 7736 | clut_image=RemoveFirstImageFromList(images); |
| 7737 | if (clut_image == (Image *) NULL) |
| 7738 | { |
| 7739 | status=MagickFalse; |
| 7740 | break; |
| 7741 | } |
| 7742 | (void) ClutImageChannel(image,channel,clut_image); |
| 7743 | clut_image=DestroyImage(clut_image); |
| 7744 | InheritException(exception,&image->exception); |
| 7745 | *images=DestroyImageList(*images); |
| 7746 | *images=image; |
| 7747 | break; |
| 7748 | } |
| 7749 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7750 | { |
| 7751 | Image |
| 7752 | *coalesce_image; |
| 7753 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7754 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7755 | coalesce_image=CoalesceImages(*images,exception); |
| 7756 | if (coalesce_image == (Image *) NULL) |
| 7757 | { |
| 7758 | status=MagickFalse; |
| 7759 | break; |
| 7760 | } |
| 7761 | *images=DestroyImageList(*images); |
| 7762 | *images=coalesce_image; |
| 7763 | break; |
| 7764 | } |
| 7765 | if (LocaleCompare("combine",option+1) == 0) |
| 7766 | { |
| 7767 | Image |
| 7768 | *combine_image; |
| 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 | combine_image=CombineImages(*images,channel,exception); |
| 7772 | if (combine_image == (Image *) NULL) |
| 7773 | { |
| 7774 | status=MagickFalse; |
| 7775 | break; |
| 7776 | } |
| 7777 | *images=DestroyImageList(*images); |
| 7778 | *images=combine_image; |
| 7779 | break; |
| 7780 | } |
| 7781 | if (LocaleCompare("composite",option+1) == 0) |
| 7782 | { |
| 7783 | Image |
| 7784 | *mask_image, |
| 7785 | *composite_image, |
| 7786 | *image; |
| 7787 | |
| 7788 | RectangleInfo |
| 7789 | geometry; |
| 7790 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7791 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7792 | image=RemoveFirstImageFromList(images); |
| 7793 | composite_image=RemoveFirstImageFromList(images); |
| 7794 | if (composite_image == (Image *) NULL) |
| 7795 | { |
| 7796 | status=MagickFalse; |
| 7797 | break; |
| 7798 | } |
| 7799 | (void) TransformImage(&composite_image,(char *) NULL, |
| 7800 | composite_image->geometry); |
| 7801 | SetGeometry(composite_image,&geometry); |
| 7802 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7803 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7804 | &geometry); |
| 7805 | mask_image=RemoveFirstImageFromList(images); |
| 7806 | if (mask_image != (Image *) NULL) |
| 7807 | { |
| 7808 | if ((image->compose == DisplaceCompositeOp) || |
| 7809 | (image->compose == DistortCompositeOp)) |
| 7810 | { |
| 7811 | /* |
| 7812 | Merge Y displacement into X displacement image. |
| 7813 | */ |
| 7814 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
| 7815 | mask_image,0,0); |
| 7816 | mask_image=DestroyImage(mask_image); |
| 7817 | } |
| 7818 | else |
| 7819 | { |
| 7820 | /* |
| 7821 | Set a blending mask for the composition. |
| 7822 | */ |
| 7823 | image->mask=mask_image; |
| 7824 | (void) NegateImage(image->mask,MagickFalse); |
| 7825 | } |
| 7826 | } |
| 7827 | (void) CompositeImageChannel(image,channel,image->compose, |
| 7828 | composite_image,geometry.x,geometry.y); |
| 7829 | if (image->mask != (Image *) NULL) |
| 7830 | image->mask=DestroyImage(image->mask); |
| 7831 | composite_image=DestroyImage(composite_image); |
| 7832 | InheritException(exception,&image->exception); |
| 7833 | *images=DestroyImageList(*images); |
| 7834 | *images=image; |
| 7835 | break; |
| 7836 | } |
| 7837 | if (LocaleCompare("crop",option+1) == 0) |
| 7838 | { |
| 7839 | MagickStatusType |
| 7840 | flags; |
| 7841 | |
| 7842 | RectangleInfo |
| 7843 | geometry; |
| 7844 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7845 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7846 | flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception); |
| 7847 | if (((geometry.width == 0) && (geometry.height == 0)) || |
| 7848 | ((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 7849 | break; |
| 7850 | (void) TransformImages(images,argv[i+1],(char *) NULL); |
| 7851 | InheritException(exception,&(*images)->exception); |
| 7852 | break; |
| 7853 | } |
| 7854 | break; |
| 7855 | } |
| 7856 | case 'd': |
| 7857 | { |
| 7858 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7859 | { |
| 7860 | Image |
| 7861 | *deconstruct_image; |
| 7862 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7863 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7864 | deconstruct_image=DeconstructImages(*images,exception); |
| 7865 | if (deconstruct_image == (Image *) NULL) |
| 7866 | { |
| 7867 | status=MagickFalse; |
| 7868 | break; |
| 7869 | } |
| 7870 | *images=DestroyImageList(*images); |
| 7871 | *images=deconstruct_image; |
| 7872 | break; |
| 7873 | } |
| 7874 | if (LocaleCompare("delete",option+1) == 0) |
| 7875 | { |
| 7876 | if (*option == '+') |
| 7877 | DeleteImages(images,"-1",exception); |
| 7878 | else |
| 7879 | DeleteImages(images,argv[i+1],exception); |
| 7880 | break; |
| 7881 | } |
| 7882 | if (LocaleCompare("dither",option+1) == 0) |
| 7883 | { |
| 7884 | if (*option == '+') |
| 7885 | { |
| 7886 | quantize_info->dither=MagickFalse; |
| 7887 | break; |
| 7888 | } |
| 7889 | quantize_info->dither=MagickTrue; |
| 7890 | quantize_info->dither_method=(DitherMethod) ParseMagickOption( |
| 7891 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7892 | break; |
| 7893 | } |
| 7894 | break; |
| 7895 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7896 | case 'e': |
| 7897 | { |
| 7898 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7899 | { |
| 7900 | Image |
| 7901 | *evaluate_image; |
| 7902 | |
| 7903 | MagickEvaluateOperator |
| 7904 | op; |
| 7905 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7906 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7907 | op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions, |
| 7908 | MagickFalse,argv[i+1]); |
| 7909 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7910 | if (evaluate_image == (Image *) NULL) |
| 7911 | { |
| 7912 | status=MagickFalse; |
| 7913 | break; |
| 7914 | } |
| 7915 | *images=DestroyImageList(*images); |
| 7916 | *images=evaluate_image; |
| 7917 | break; |
| 7918 | } |
| 7919 | break; |
| 7920 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7921 | case 'f': |
| 7922 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7923 | if (LocaleCompare("fft",option+1) == 0) |
| 7924 | { |
| 7925 | Image |
| 7926 | *fourier_image; |
| 7927 | |
| 7928 | /* |
| 7929 | Implements the discrete Fourier transform (DFT). |
| 7930 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7931 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7932 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7933 | MagickTrue : MagickFalse,exception); |
| 7934 | if (fourier_image == (Image *) NULL) |
| 7935 | break; |
| 7936 | *images=DestroyImage(*images); |
| 7937 | *images=fourier_image; |
| 7938 | break; |
| 7939 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7940 | if (LocaleCompare("flatten",option+1) == 0) |
| 7941 | { |
| 7942 | Image |
| 7943 | *flatten_image; |
| 7944 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7945 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7946 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7947 | if (flatten_image == (Image *) NULL) |
| 7948 | break; |
| 7949 | *images=DestroyImageList(*images); |
| 7950 | *images=flatten_image; |
| 7951 | break; |
| 7952 | } |
| 7953 | if (LocaleCompare("fx",option+1) == 0) |
| 7954 | { |
| 7955 | Image |
| 7956 | *fx_image; |
| 7957 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7958 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7959 | fx_image=FxImageChannel(*images,channel,argv[i+1],exception); |
| 7960 | if (fx_image == (Image *) NULL) |
| 7961 | { |
| 7962 | status=MagickFalse; |
| 7963 | break; |
| 7964 | } |
| 7965 | *images=DestroyImageList(*images); |
| 7966 | *images=fx_image; |
| 7967 | break; |
| 7968 | } |
| 7969 | break; |
| 7970 | } |
| 7971 | case 'h': |
| 7972 | { |
| 7973 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7974 | { |
| 7975 | Image |
| 7976 | *hald_image, |
| 7977 | *image; |
| 7978 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7979 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7980 | image=RemoveFirstImageFromList(images); |
| 7981 | hald_image=RemoveFirstImageFromList(images); |
| 7982 | if (hald_image == (Image *) NULL) |
| 7983 | { |
| 7984 | status=MagickFalse; |
| 7985 | break; |
| 7986 | } |
| 7987 | (void) HaldClutImageChannel(image,channel,hald_image); |
| 7988 | hald_image=DestroyImage(hald_image); |
| 7989 | InheritException(exception,&image->exception); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7990 | if (*images != (Image *) NULL) |
| 7991 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7992 | *images=image; |
| 7993 | break; |
| 7994 | } |
| 7995 | break; |
| 7996 | } |
| 7997 | case 'i': |
| 7998 | { |
| 7999 | if (LocaleCompare("ift",option+1) == 0) |
| 8000 | { |
| 8001 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 8002 | *fourier_image, |
| 8003 | *magnitude_image, |
| 8004 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8005 | |
| 8006 | /* |
| 8007 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 8008 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8009 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 8010 | magnitude_image=RemoveFirstImageFromList(images); |
| 8011 | phase_image=RemoveFirstImageFromList(images); |
| 8012 | if (phase_image == (Image *) NULL) |
| 8013 | { |
| 8014 | status=MagickFalse; |
| 8015 | break; |
| 8016 | } |
| 8017 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 8018 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8019 | if (fourier_image == (Image *) NULL) |
| 8020 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 8021 | if (*images != (Image *) NULL) |
| 8022 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8023 | *images=fourier_image; |
| 8024 | break; |
| 8025 | } |
| 8026 | if (LocaleCompare("insert",option+1) == 0) |
| 8027 | { |
| 8028 | Image |
| 8029 | *p, |
| 8030 | *q; |
| 8031 | |
| 8032 | index=0; |
| 8033 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 8034 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8035 | p=RemoveLastImageFromList(images); |
| 8036 | if (p == (Image *) NULL) |
| 8037 | { |
| 8038 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8039 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 8040 | status=MagickFalse; |
| 8041 | break; |
| 8042 | } |
| 8043 | q=p; |
| 8044 | if (index == 0) |
| 8045 | PrependImageToList(images,q); |
| 8046 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8047 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8048 | AppendImageToList(images,q); |
| 8049 | else |
| 8050 | { |
| 8051 | q=GetImageFromList(*images,index-1); |
| 8052 | if (q == (Image *) NULL) |
| 8053 | { |
| 8054 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8055 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 8056 | status=MagickFalse; |
| 8057 | break; |
| 8058 | } |
| 8059 | InsertImageInList(&q,p); |
| 8060 | } |
| 8061 | *images=GetFirstImageInList(q); |
| 8062 | break; |
| 8063 | } |
| 8064 | break; |
| 8065 | } |
| 8066 | case 'l': |
| 8067 | { |
| 8068 | if (LocaleCompare("layers",option+1) == 0) |
| 8069 | { |
| 8070 | Image |
| 8071 | *layers; |
| 8072 | |
| 8073 | ImageLayerMethod |
| 8074 | method; |
| 8075 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8076 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8077 | layers=(Image *) NULL; |
| 8078 | method=(ImageLayerMethod) ParseMagickOption(MagickLayerOptions, |
| 8079 | MagickFalse,argv[i+1]); |
| 8080 | switch (method) |
| 8081 | { |
| 8082 | case CoalesceLayer: |
| 8083 | { |
| 8084 | layers=CoalesceImages(*images,exception); |
| 8085 | break; |
| 8086 | } |
| 8087 | case CompareAnyLayer: |
| 8088 | case CompareClearLayer: |
| 8089 | case CompareOverlayLayer: |
| 8090 | default: |
| 8091 | { |
| 8092 | layers=CompareImageLayers(*images,method,exception); |
| 8093 | break; |
| 8094 | } |
| 8095 | case MergeLayer: |
| 8096 | case FlattenLayer: |
| 8097 | case MosaicLayer: |
| 8098 | case TrimBoundsLayer: |
| 8099 | { |
| 8100 | layers=MergeImageLayers(*images,method,exception); |
| 8101 | break; |
| 8102 | } |
| 8103 | case DisposeLayer: |
| 8104 | { |
| 8105 | layers=DisposeImages(*images,exception); |
| 8106 | break; |
| 8107 | } |
| 8108 | case OptimizeImageLayer: |
| 8109 | { |
| 8110 | layers=OptimizeImageLayers(*images,exception); |
| 8111 | break; |
| 8112 | } |
| 8113 | case OptimizePlusLayer: |
| 8114 | { |
| 8115 | layers=OptimizePlusImageLayers(*images,exception); |
| 8116 | break; |
| 8117 | } |
| 8118 | case OptimizeTransLayer: |
| 8119 | { |
| 8120 | OptimizeImageTransparency(*images,exception); |
| 8121 | break; |
| 8122 | } |
| 8123 | case RemoveDupsLayer: |
| 8124 | { |
| 8125 | RemoveDuplicateLayers(images,exception); |
| 8126 | break; |
| 8127 | } |
| 8128 | case RemoveZeroLayer: |
| 8129 | { |
| 8130 | RemoveZeroDelayLayers(images,exception); |
| 8131 | break; |
| 8132 | } |
| 8133 | case OptimizeLayer: |
| 8134 | { |
| 8135 | /* |
| 8136 | General Purpose, GIF Animation Optimizer. |
| 8137 | */ |
| 8138 | layers=CoalesceImages(*images,exception); |
| 8139 | if (layers == (Image *) NULL) |
| 8140 | { |
| 8141 | status=MagickFalse; |
| 8142 | break; |
| 8143 | } |
| 8144 | InheritException(exception,&layers->exception); |
| 8145 | *images=DestroyImageList(*images); |
| 8146 | *images=layers; |
| 8147 | layers=OptimizeImageLayers(*images,exception); |
| 8148 | if (layers == (Image *) NULL) |
| 8149 | { |
| 8150 | status=MagickFalse; |
| 8151 | break; |
| 8152 | } |
| 8153 | InheritException(exception,&layers->exception); |
| 8154 | *images=DestroyImageList(*images); |
| 8155 | *images=layers; |
| 8156 | layers=(Image *) NULL; |
| 8157 | OptimizeImageTransparency(*images,exception); |
| 8158 | InheritException(exception,&(*images)->exception); |
| 8159 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 8160 | break; |
| 8161 | } |
| 8162 | case CompositeLayer: |
| 8163 | { |
| 8164 | CompositeOperator |
| 8165 | compose; |
| 8166 | |
| 8167 | Image |
| 8168 | *source; |
| 8169 | |
| 8170 | RectangleInfo |
| 8171 | geometry; |
| 8172 | |
| 8173 | /* |
| 8174 | Split image sequence at the first 'NULL:' image. |
| 8175 | */ |
| 8176 | source=(*images); |
| 8177 | while (source != (Image *) NULL) |
| 8178 | { |
| 8179 | source=GetNextImageInList(source); |
| 8180 | if ((source != (Image *) NULL) && |
| 8181 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 8182 | break; |
| 8183 | } |
| 8184 | if (source != (Image *) NULL) |
| 8185 | { |
| 8186 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 8187 | (GetNextImageInList(source) == (Image *) NULL)) |
| 8188 | source=(Image *) NULL; |
| 8189 | else |
| 8190 | { |
| 8191 | /* |
| 8192 | Separate the two lists, junk the null: image. |
| 8193 | */ |
| 8194 | source=SplitImageList(source->previous); |
| 8195 | DeleteImageFromList(&source); |
| 8196 | } |
| 8197 | } |
| 8198 | if (source == (Image *) NULL) |
| 8199 | { |
| 8200 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8201 | OptionError,"MissingNullSeparator","layers Composite"); |
| 8202 | status=MagickFalse; |
| 8203 | break; |
| 8204 | } |
| 8205 | /* |
| 8206 | Adjust offset with gravity and virtual canvas. |
| 8207 | */ |
| 8208 | SetGeometry(*images,&geometry); |
| 8209 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 8210 | geometry.width=source->page.width != 0 ? |
| 8211 | source->page.width : source->columns; |
| 8212 | geometry.height=source->page.height != 0 ? |
| 8213 | source->page.height : source->rows; |
| 8214 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 8215 | (*images)->page.width : (*images)->columns, |
| 8216 | (*images)->page.height != 0 ? (*images)->page.height : |
| 8217 | (*images)->rows,(*images)->gravity,&geometry); |
| 8218 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8219 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8220 | if (option != (const char *) NULL) |
| 8221 | compose=(CompositeOperator) ParseMagickOption( |
| 8222 | MagickComposeOptions,MagickFalse,option); |
| 8223 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 8224 | exception); |
| 8225 | source=DestroyImageList(source); |
| 8226 | break; |
| 8227 | } |
| 8228 | } |
| 8229 | if (layers == (Image *) NULL) |
| 8230 | break; |
| 8231 | InheritException(exception,&layers->exception); |
| 8232 | *images=DestroyImageList(*images); |
| 8233 | *images=layers; |
| 8234 | break; |
| 8235 | } |
| 8236 | break; |
| 8237 | } |
| 8238 | case 'm': |
| 8239 | { |
| 8240 | if (LocaleCompare("map",option+1) == 0) |
| 8241 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8242 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8243 | if (*option == '+') |
| 8244 | { |
| 8245 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 8246 | InheritException(exception,&(*images)->exception); |
| 8247 | break; |
| 8248 | } |
| 8249 | i++; |
| 8250 | break; |
| 8251 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8252 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8253 | { |
| 8254 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8255 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8256 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 8257 | /* |
| 8258 | Maximum image sequence (deprecated). |
| 8259 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8260 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 8261 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8262 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8263 | { |
| 8264 | status=MagickFalse; |
| 8265 | break; |
| 8266 | } |
| 8267 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8268 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8269 | break; |
| 8270 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8271 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8272 | { |
| 8273 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8274 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8275 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 8276 | /* |
| 8277 | Minimum image sequence (deprecated). |
| 8278 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8279 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 8280 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8281 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8282 | { |
| 8283 | status=MagickFalse; |
| 8284 | break; |
| 8285 | } |
| 8286 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8287 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8288 | break; |
| 8289 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8290 | if (LocaleCompare("morph",option+1) == 0) |
| 8291 | { |
| 8292 | Image |
| 8293 | *morph_image; |
| 8294 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8295 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 8296 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8297 | exception); |
| 8298 | if (morph_image == (Image *) NULL) |
| 8299 | { |
| 8300 | status=MagickFalse; |
| 8301 | break; |
| 8302 | } |
| 8303 | *images=DestroyImageList(*images); |
| 8304 | *images=morph_image; |
| 8305 | break; |
| 8306 | } |
| 8307 | if (LocaleCompare("mosaic",option+1) == 0) |
| 8308 | { |
| 8309 | Image |
| 8310 | *mosaic_image; |
| 8311 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8312 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8313 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 8314 | if (mosaic_image == (Image *) NULL) |
| 8315 | { |
| 8316 | status=MagickFalse; |
| 8317 | break; |
| 8318 | } |
| 8319 | *images=DestroyImageList(*images); |
| 8320 | *images=mosaic_image; |
| 8321 | break; |
| 8322 | } |
| 8323 | break; |
| 8324 | } |
| 8325 | case 'p': |
| 8326 | { |
| 8327 | if (LocaleCompare("print",option+1) == 0) |
| 8328 | { |
| 8329 | char |
| 8330 | *string; |
| 8331 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8332 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8333 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8334 | if (string == (char *) NULL) |
| 8335 | break; |
| 8336 | InheritException(exception,&(*images)->exception); |
| 8337 | (void) fprintf(stdout,"%s",string); |
| 8338 | string=DestroyString(string); |
| 8339 | } |
| 8340 | if (LocaleCompare("process",option+1) == 0) |
| 8341 | { |
| 8342 | char |
| 8343 | **arguments; |
| 8344 | |
| 8345 | int |
| 8346 | j, |
| 8347 | number_arguments; |
| 8348 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8349 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8350 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 8351 | if (arguments == (char **) NULL) |
| 8352 | break; |
| 8353 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 8354 | { |
| 8355 | char |
| 8356 | breaker, |
| 8357 | quote, |
| 8358 | *token; |
| 8359 | |
| 8360 | const char |
| 8361 | *arguments; |
| 8362 | |
| 8363 | int |
| 8364 | next, |
| 8365 | status; |
| 8366 | |
| 8367 | size_t |
| 8368 | length; |
| 8369 | |
| 8370 | TokenInfo |
| 8371 | *token_info; |
| 8372 | |
| 8373 | /* |
| 8374 | Support old style syntax, filter="-option arg". |
| 8375 | */ |
| 8376 | length=strlen(argv[i+1]); |
| 8377 | token=(char *) NULL; |
| 8378 | if (~length >= MaxTextExtent) |
| 8379 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8380 | sizeof(*token)); |
| 8381 | if (token == (char *) NULL) |
| 8382 | break; |
| 8383 | next=0; |
| 8384 | arguments=argv[i+1]; |
| 8385 | token_info=AcquireTokenInfo(); |
| 8386 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8387 | "\"",'\0',&breaker,&next,"e); |
| 8388 | token_info=DestroyTokenInfo(token_info); |
| 8389 | if (status == 0) |
| 8390 | { |
| 8391 | const char |
| 8392 | *argv; |
| 8393 | |
| 8394 | argv=(&(arguments[next])); |
| 8395 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8396 | exception); |
| 8397 | } |
| 8398 | token=DestroyString(token); |
| 8399 | break; |
| 8400 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8401 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8402 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8403 | number_arguments-2,(const char **) arguments+2,exception); |
| 8404 | for (j=0; j < number_arguments; j++) |
| 8405 | arguments[j]=DestroyString(arguments[j]); |
| 8406 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8407 | break; |
| 8408 | } |
| 8409 | break; |
| 8410 | } |
| 8411 | case 'r': |
| 8412 | { |
| 8413 | if (LocaleCompare("reverse",option+1) == 0) |
| 8414 | { |
| 8415 | ReverseImageList(images); |
| 8416 | InheritException(exception,&(*images)->exception); |
| 8417 | break; |
| 8418 | } |
| 8419 | break; |
| 8420 | } |
| 8421 | case 's': |
| 8422 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8423 | if (LocaleCompare("smush",option+1) == 0) |
| 8424 | { |
| 8425 | Image |
| 8426 | *smush_image; |
| 8427 | |
| 8428 | ssize_t |
| 8429 | offset; |
| 8430 | |
| 8431 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8432 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8433 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8434 | MagickFalse,offset,exception); |
| 8435 | if (smush_image == (Image *) NULL) |
| 8436 | { |
| 8437 | status=MagickFalse; |
| 8438 | break; |
| 8439 | } |
| 8440 | *images=DestroyImageList(*images); |
| 8441 | *images=smush_image; |
| 8442 | break; |
| 8443 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8444 | if (LocaleCompare("swap",option+1) == 0) |
| 8445 | { |
| 8446 | Image |
| 8447 | *p, |
| 8448 | *q, |
| 8449 | *swap; |
| 8450 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8451 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8452 | swap_index; |
| 8453 | |
| 8454 | index=(-1); |
| 8455 | swap_index=(-2); |
| 8456 | if (*option != '+') |
| 8457 | { |
| 8458 | GeometryInfo |
| 8459 | geometry_info; |
| 8460 | |
| 8461 | MagickStatusType |
| 8462 | flags; |
| 8463 | |
| 8464 | swap_index=(-1); |
| 8465 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8466 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8467 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8468 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8469 | } |
| 8470 | p=GetImageFromList(*images,index); |
| 8471 | q=GetImageFromList(*images,swap_index); |
| 8472 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8473 | { |
| 8474 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8475 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8476 | status=MagickFalse; |
| 8477 | break; |
| 8478 | } |
| 8479 | if (p == q) |
| 8480 | break; |
| 8481 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8482 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8483 | ReplaceImageInList(&q,swap); |
| 8484 | *images=GetFirstImageInList(q); |
| 8485 | break; |
| 8486 | } |
| 8487 | break; |
| 8488 | } |
| 8489 | case 'w': |
| 8490 | { |
| 8491 | if (LocaleCompare("write",option+1) == 0) |
| 8492 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8493 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8494 | key[MaxTextExtent]; |
| 8495 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8496 | Image |
| 8497 | *write_images; |
| 8498 | |
| 8499 | ImageInfo |
| 8500 | *write_info; |
| 8501 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8502 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8503 | (void) FormatMagickString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
| 8504 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8505 | write_images=(*images); |
| 8506 | if (*option == '+') |
| 8507 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8508 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8509 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8510 | write_info=DestroyImageInfo(write_info); |
| 8511 | if (*option == '+') |
| 8512 | write_images=DestroyImageList(write_images); |
| 8513 | break; |
| 8514 | } |
| 8515 | break; |
| 8516 | } |
| 8517 | default: |
| 8518 | break; |
| 8519 | } |
| 8520 | i+=count; |
| 8521 | } |
| 8522 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8523 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8524 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8525 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8526 | } |
| 8527 | |
| 8528 | /* |
| 8529 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8530 | % % |
| 8531 | % % |
| 8532 | % % |
| 8533 | + M o g r i f y I m a g e s % |
| 8534 | % % |
| 8535 | % % |
| 8536 | % % |
| 8537 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8538 | % |
| 8539 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8540 | % prescribed by command line options. |
| 8541 | % |
| 8542 | % The format of the MogrifyImage method is: |
| 8543 | % |
| 8544 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8545 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8546 | % Image **images,Exceptioninfo *exception) |
| 8547 | % |
| 8548 | % A description of each parameter follows: |
| 8549 | % |
| 8550 | % o image_info: the image info.. |
| 8551 | % |
| 8552 | % o post: If true, post process image list operators otherwise pre-process. |
| 8553 | % |
| 8554 | % o argc: Specifies a pointer to an integer describing the number of |
| 8555 | % elements in the argument vector. |
| 8556 | % |
| 8557 | % o argv: Specifies a pointer to a text array containing the command line |
| 8558 | % arguments. |
| 8559 | % |
| 8560 | % o images: the images. |
| 8561 | % |
| 8562 | % o exception: return any errors or warnings in this structure. |
| 8563 | % |
| 8564 | */ |
| 8565 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8566 | const MagickBooleanType post,const int argc,const char **argv, |
| 8567 | Image **images,ExceptionInfo *exception) |
| 8568 | { |
| 8569 | #define MogrifyImageTag "Mogrify/Image" |
| 8570 | |
| 8571 | Image |
| 8572 | *image, |
| 8573 | *mogrify_images; |
| 8574 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8575 | MagickBooleanType |
| 8576 | proceed; |
| 8577 | |
| 8578 | MagickSizeType |
| 8579 | number_images; |
| 8580 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8581 | MagickStatusType |
| 8582 | status; |
| 8583 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8584 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8585 | i; |
| 8586 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8587 | /* |
| 8588 | Apply options to individual images in the list. |
| 8589 | */ |
| 8590 | assert(image_info != (ImageInfo *) NULL); |
| 8591 | assert(image_info->signature == MagickSignature); |
| 8592 | if (images == (Image **) NULL) |
| 8593 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
| 8594 | assert((*images)->signature == MagickSignature); |
| 8595 | if ((*images)->debug != MagickFalse) |
| 8596 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8597 | (*images)->filename); |
| 8598 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8599 | return(MagickTrue); |
| 8600 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8601 | (void *) NULL); |
| 8602 | mogrify_images=NewImageList(); |
| 8603 | number_images=GetImageListLength(*images); |
| 8604 | status=0; |
| 8605 | if (post == MagickFalse) |
| 8606 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8607 | for (i=0; i < (ssize_t) number_images; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8608 | { |
| 8609 | image=RemoveFirstImageFromList(images); |
| 8610 | if (image == (Image *) NULL) |
| 8611 | continue; |
| 8612 | status&=MogrifyImage(image_info,argc,argv,&image,exception); |
| 8613 | AppendImageToList(&mogrify_images,image); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8614 | proceed=SetImageProgress(image,MogrifyImageTag,(MagickOffsetType) i, |
| 8615 | number_images); |
| 8616 | if (proceed == MagickFalse) |
| 8617 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8618 | } |
| 8619 | if (post != MagickFalse) |
| 8620 | status&=MogrifyImageList(image_info,argc,argv,&mogrify_images,exception); |
| 8621 | *images=mogrify_images; |
| 8622 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8623 | } |