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 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 47 | #include "MagickWand/studio.h" |
| 48 | #include "MagickWand/MagickWand.h" |
| 49 | #include "MagickWand/mogrify-private.h" |
| 50 | #undef DegreesToRadians |
| 51 | #undef RadiansToDegrees |
| 52 | #include "MagickCore/image-private.h" |
| 53 | #include "MagickCore/monitor-private.h" |
| 54 | #include "MagickCore/thread-private.h" |
| 55 | #include "MagickCore/string-private.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 56 | |
| 57 | /* |
| 58 | Define declarations. |
| 59 | */ |
| 60 | #define UndefinedCompressionQuality 0UL |
| 61 | |
| 62 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 63 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 64 | % % |
| 65 | % % |
| 66 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 67 | % 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] | 68 | % % |
| 69 | % % |
| 70 | % % |
| 71 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 72 | % |
| 73 | % MagickCommandGenesis() applies image processing options to an image as |
| 74 | % prescribed by command line options. |
| 75 | % |
| 76 | % The format of the MagickCommandGenesis method is: |
| 77 | % |
| 78 | % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 79 | % MagickCommand command,int argc,char **argv,char **metadata, |
| 80 | % ExceptionInfo *exception) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 81 | % |
| 82 | % A description of each parameter follows: |
| 83 | % |
| 84 | % o image_info: the image info. |
| 85 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 86 | % o command: Choose from ConvertImageCommand, IdentifyImageCommand, |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 87 | % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 88 | % ConjureImageCommand, StreamImageCommand, ImportImageCommand, |
| 89 | % DisplayImageCommand, or AnimateImageCommand. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 90 | % |
| 91 | % o argc: Specifies a pointer to an integer describing the number of |
| 92 | % elements in the argument vector. |
| 93 | % |
| 94 | % o argv: Specifies a pointer to a text array containing the command line |
| 95 | % arguments. |
| 96 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 97 | % o metadata: any metadata is returned here. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 98 | % |
| 99 | % o exception: return any errors or warnings in this structure. |
| 100 | % |
| 101 | */ |
| 102 | WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
| 103 | MagickCommand command,int argc,char **argv,char **metadata, |
| 104 | ExceptionInfo *exception) |
| 105 | { |
| 106 | char |
| 107 | *option; |
| 108 | |
| 109 | double |
| 110 | duration, |
| 111 | elapsed_time, |
| 112 | user_time; |
| 113 | |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 114 | MagickBooleanType |
| 115 | concurrent, |
| 116 | regard_warnings, |
| 117 | status; |
| 118 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 119 | register ssize_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 120 | i; |
| 121 | |
| 122 | TimerInfo |
| 123 | *timer; |
| 124 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 125 | size_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 126 | iterations; |
| 127 | |
cristy | d0a94fa | 2010-03-12 14:18:11 +0000 | [diff] [blame] | 128 | (void) setlocale(LC_ALL,""); |
| 129 | (void) setlocale(LC_NUMERIC,"C"); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 130 | concurrent=MagickFalse; |
| 131 | duration=(-1.0); |
| 132 | iterations=1; |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 133 | status=MagickFalse; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 134 | regard_warnings=MagickFalse; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 135 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 136 | { |
| 137 | option=argv[i]; |
| 138 | if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) |
| 139 | continue; |
| 140 | if (LocaleCompare("bench",option+1) == 0) |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 141 | iterations=StringToUnsignedLong(argv[++i]); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 142 | if (LocaleCompare("concurrent",option+1) == 0) |
| 143 | concurrent=MagickTrue; |
| 144 | if (LocaleCompare("debug",option+1) == 0) |
| 145 | (void) SetLogEventMask(argv[++i]); |
| 146 | if (LocaleCompare("duration",option+1) == 0) |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 147 | duration=InterpretLocaleValue(argv[++i],(char **) NULL); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 148 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 149 | regard_warnings=MagickTrue; |
| 150 | } |
| 151 | timer=AcquireTimerInfo(); |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 152 | if (concurrent == MagickFalse) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 153 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 154 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 155 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 156 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 157 | continue; |
| 158 | if (duration > 0) |
| 159 | { |
| 160 | if (GetElapsedTime(timer) > duration) |
| 161 | continue; |
| 162 | (void) ContinueTimer(timer); |
| 163 | } |
| 164 | status=command(image_info,argc,argv,metadata,exception); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 165 | if (exception->severity != UndefinedException) |
| 166 | { |
| 167 | if ((exception->severity > ErrorException) || |
| 168 | (regard_warnings != MagickFalse)) |
| 169 | status=MagickTrue; |
| 170 | CatchException(exception); |
| 171 | } |
cristy | 3d1a551 | 2009-10-25 21:23:27 +0000 | [diff] [blame] | 172 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 173 | { |
| 174 | (void) fputs(*metadata,stdout); |
| 175 | (void) fputc('\n',stdout); |
| 176 | *metadata=DestroyString(*metadata); |
| 177 | } |
| 178 | } |
| 179 | } |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 180 | else |
| 181 | { |
| 182 | SetOpenMPNested(1); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 183 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 184 | # pragma omp parallel for shared(status) |
| 185 | #endif |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 186 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 187 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 188 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 189 | continue; |
| 190 | if (duration > 0) |
| 191 | { |
| 192 | if (GetElapsedTime(timer) > duration) |
| 193 | continue; |
| 194 | (void) ContinueTimer(timer); |
| 195 | } |
| 196 | status=command(image_info,argc,argv,metadata,exception); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 197 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 198 | # pragma omp critical (MagickCore_CommandGenesis) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 199 | #endif |
| 200 | { |
| 201 | if (exception->severity != UndefinedException) |
| 202 | { |
| 203 | if ((exception->severity > ErrorException) || |
| 204 | (regard_warnings != MagickFalse)) |
| 205 | status=MagickTrue; |
| 206 | CatchException(exception); |
| 207 | } |
| 208 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 209 | { |
| 210 | (void) fputs(*metadata,stdout); |
| 211 | (void) fputc('\n',stdout); |
| 212 | *metadata=DestroyString(*metadata); |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | } |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 217 | if (iterations > 1) |
| 218 | { |
| 219 | elapsed_time=GetElapsedTime(timer); |
| 220 | user_time=GetUserTime(timer); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 221 | (void) FormatLocaleFile(stderr, |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 222 | "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double) |
| 223 | iterations,1.0*iterations/elapsed_time,user_time,(double) |
| 224 | (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double) |
| 225 | (1000.0*(elapsed_time-floor(elapsed_time)))); |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 226 | (void) fflush(stderr); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 227 | } |
| 228 | timer=DestroyTimerInfo(timer); |
cristy | 1f9e1ed | 2009-11-18 04:09:38 +0000 | [diff] [blame] | 229 | return(status); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | /* |
| 233 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 234 | % % |
| 235 | % % |
| 236 | % % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 237 | + M o g r i f y I m a g e % |
| 238 | % % |
| 239 | % % |
| 240 | % % |
| 241 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 242 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 243 | % MogrifyImage() applies simple single image processing options to a single |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 244 | % image that may be part of a large list, but also handles any 'region' |
| 245 | % image handling. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 246 | % |
| 247 | % The image in the list may be modified in three different ways... |
| 248 | % |
| 249 | % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 250 | % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 251 | % * replace by a list of images (only the -separate option!) |
| 252 | % |
| 253 | % In each case the result is returned into the list, and a pointer to the |
| 254 | % modified image (last image added if replaced by a list of images) is |
| 255 | % returned. |
| 256 | % |
| 257 | % ASIDE: The -crop is present but restricted to non-tile single image crops |
| 258 | % |
| 259 | % This means if all the images are being processed (such as by |
| 260 | % MogrifyImages(), next image to be processed will be as per the pointer |
| 261 | % (*image)->next. Also the image list may grow as a result of some specific |
| 262 | % operations but as images are never merged or deleted, it will never shrink |
| 263 | % in length. Typically the list will remain the same length. |
| 264 | % |
| 265 | % WARNING: As the image pointed to may be replaced, the first image in the |
| 266 | % list may also change. GetFirstImageInList() should be used by caller if |
| 267 | % they wish return the Image pointer to the first image in list. |
| 268 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 269 | % |
| 270 | % The format of the MogrifyImage method is: |
| 271 | % |
| 272 | % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 273 | % const char **argv,Image **image) |
| 274 | % |
| 275 | % A description of each parameter follows: |
| 276 | % |
| 277 | % o image_info: the image info.. |
| 278 | % |
| 279 | % o argc: Specifies a pointer to an integer describing the number of |
| 280 | % elements in the argument vector. |
| 281 | % |
| 282 | % o argv: Specifies a pointer to a text array containing the command line |
| 283 | % arguments. |
| 284 | % |
| 285 | % o image: the image. |
| 286 | % |
| 287 | % o exception: return any errors or warnings in this structure. |
| 288 | % |
| 289 | */ |
| 290 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 291 | /* |
| 292 | ** GetImageCache() will read an image into a image cache if not already |
| 293 | ** present then return the image that is in the cache under that filename. |
| 294 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 295 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 296 | ExceptionInfo *exception) |
| 297 | { |
| 298 | char |
| 299 | key[MaxTextExtent]; |
| 300 | |
| 301 | ExceptionInfo |
| 302 | *sans_exception; |
| 303 | |
| 304 | Image |
| 305 | *image; |
| 306 | |
| 307 | ImageInfo |
| 308 | *read_info; |
| 309 | |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 310 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 311 | sans_exception=AcquireExceptionInfo(); |
| 312 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 313 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 314 | if (image != (Image *) NULL) |
| 315 | return(image); |
| 316 | read_info=CloneImageInfo(image_info); |
| 317 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 318 | image=ReadImage(read_info,exception); |
| 319 | read_info=DestroyImageInfo(read_info); |
| 320 | if (image != (Image *) NULL) |
| 321 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 322 | return(image); |
| 323 | } |
| 324 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 325 | static MagickBooleanType IsPathWritable(const char *path) |
| 326 | { |
| 327 | if (IsPathAccessible(path) == MagickFalse) |
| 328 | return(MagickFalse); |
| 329 | if (access(path,W_OK) != 0) |
| 330 | return(MagickFalse); |
| 331 | return(MagickTrue); |
| 332 | } |
| 333 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 334 | static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 335 | { |
| 336 | if (x > y) |
| 337 | return(x); |
| 338 | return(y); |
| 339 | } |
| 340 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 341 | static MagickBooleanType MonitorProgress(const char *text, |
| 342 | const MagickOffsetType offset,const MagickSizeType extent, |
| 343 | void *wand_unused(client_data)) |
| 344 | { |
| 345 | char |
| 346 | message[MaxTextExtent], |
| 347 | tag[MaxTextExtent]; |
| 348 | |
| 349 | const char |
| 350 | *locale_message; |
| 351 | |
| 352 | register char |
| 353 | *p; |
| 354 | |
| 355 | if (extent < 2) |
| 356 | return(MagickTrue); |
| 357 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 358 | p=strrchr(tag,'/'); |
| 359 | if (p != (char *) NULL) |
| 360 | *p='\0'; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 361 | (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 362 | locale_message=GetLocaleMessage(message); |
| 363 | if (locale_message == message) |
| 364 | locale_message=tag; |
| 365 | if (p == (char *) NULL) |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 366 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", |
| 367 | locale_message,(long) offset,(unsigned long) extent,(long) |
| 368 | (100L*offset/(extent-1))); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 369 | else |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 370 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 371 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 372 | (100L*offset/(extent-1))); |
| 373 | if (offset == (MagickOffsetType) (extent-1)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 374 | (void) FormatLocaleFile(stderr,"\n"); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 375 | (void) fflush(stderr); |
| 376 | return(MagickTrue); |
| 377 | } |
| 378 | |
| 379 | /* |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 380 | ** SparseColorOption() parses the complex -sparse-color argument into an |
| 381 | ** an array of floating point values then calls SparseColorImage(). |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 382 | ** Argument is a complex mix of floating-point pixel coodinates, and color |
| 383 | ** specifications (or direct floating point numbers). The number of floats |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 384 | ** needed to represent a color varies depending on the current channel |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 385 | ** setting. |
| 386 | */ |
| 387 | static Image *SparseColorOption(const Image *image,const ChannelType channel, |
| 388 | const SparseColorMethod method,const char *arguments, |
| 389 | const MagickBooleanType color_from_image,ExceptionInfo *exception) |
| 390 | { |
| 391 | ChannelType |
| 392 | channels; |
| 393 | |
| 394 | char |
| 395 | token[MaxTextExtent]; |
| 396 | |
| 397 | const char |
| 398 | *p; |
| 399 | |
| 400 | double |
| 401 | *sparse_arguments; |
| 402 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 403 | Image |
| 404 | *sparse_image; |
| 405 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 406 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 407 | color; |
| 408 | |
| 409 | MagickBooleanType |
| 410 | error; |
| 411 | |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 412 | register size_t |
| 413 | x; |
| 414 | |
| 415 | size_t |
| 416 | number_arguments, |
| 417 | number_colors; |
| 418 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 419 | assert(image != (Image *) NULL); |
| 420 | assert(image->signature == MagickSignature); |
| 421 | if (image->debug != MagickFalse) |
| 422 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 423 | assert(exception != (ExceptionInfo *) NULL); |
| 424 | assert(exception->signature == MagickSignature); |
| 425 | /* |
| 426 | Limit channels according to image - and add up number of color channel. |
| 427 | */ |
| 428 | channels=channel; |
| 429 | if (image->colorspace != CMYKColorspace) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 430 | channels=(ChannelType) (channels & ~BlackChannel); /* no black channel */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 431 | if (image->matte == MagickFalse) |
| 432 | channels=(ChannelType) (channels & ~OpacityChannel); /* no alpha channel */ |
| 433 | number_colors=0; |
| 434 | if ((channels & RedChannel) != 0) |
| 435 | number_colors++; |
| 436 | if ((channels & GreenChannel) != 0) |
| 437 | number_colors++; |
| 438 | if ((channels & BlueChannel) != 0) |
| 439 | number_colors++; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 440 | if ((channels & BlackChannel) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 441 | number_colors++; |
| 442 | if ((channels & OpacityChannel) != 0) |
| 443 | number_colors++; |
| 444 | |
| 445 | /* |
| 446 | Read string, to determine number of arguments needed, |
| 447 | */ |
| 448 | p=arguments; |
| 449 | x=0; |
| 450 | while( *p != '\0' ) |
| 451 | { |
| 452 | GetMagickToken(p,&p,token); |
| 453 | if ( token[0] == ',' ) continue; |
| 454 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 455 | if ( color_from_image ) { |
| 456 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 457 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 458 | "Color arg given, when colors are coming from image"); |
| 459 | return( (Image *)NULL); |
| 460 | } |
| 461 | x += number_colors; /* color argument */ |
| 462 | } |
| 463 | else { |
| 464 | x++; /* floating point argument */ |
| 465 | } |
| 466 | } |
| 467 | error=MagickTrue; |
| 468 | if ( color_from_image ) { |
| 469 | /* just the control points are being given */ |
| 470 | error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; |
| 471 | number_arguments=(x/2)*(2+number_colors); |
| 472 | } |
| 473 | else { |
| 474 | /* control points and color values */ |
| 475 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; |
| 476 | number_arguments=x; |
| 477 | } |
| 478 | if ( error ) { |
| 479 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 480 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 481 | "Invalid number of Arguments"); |
| 482 | return( (Image *)NULL); |
| 483 | } |
| 484 | |
| 485 | /* Allocate and fill in the floating point arguments */ |
| 486 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 487 | sizeof(*sparse_arguments)); |
| 488 | if (sparse_arguments == (double *) NULL) { |
| 489 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 490 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 491 | return( (Image *)NULL); |
| 492 | } |
| 493 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 494 | sizeof(*sparse_arguments)); |
| 495 | p=arguments; |
| 496 | x=0; |
| 497 | while( *p != '\0' && x < number_arguments ) { |
| 498 | /* X coordinate */ |
| 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 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 503 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 504 | "Color found, instead of X-coord"); |
| 505 | error = MagickTrue; |
| 506 | break; |
| 507 | } |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 508 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 509 | /* Y coordinate */ |
| 510 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 511 | if ( token[0] == '\0' ) break; |
| 512 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 513 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 514 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 515 | "Color found, instead of Y-coord"); |
| 516 | error = MagickTrue; |
| 517 | break; |
| 518 | } |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 519 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 520 | /* color values for this control point */ |
| 521 | #if 0 |
| 522 | if ( (color_from_image ) { |
| 523 | /* get color from image */ |
| 524 | /* HOW??? */ |
| 525 | } |
| 526 | else |
| 527 | #endif |
| 528 | { |
| 529 | /* color name or function given in string argument */ |
| 530 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 531 | if ( token[0] == '\0' ) break; |
| 532 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 533 | /* Color string given */ |
| 534 | (void) QueryMagickColor(token,&color,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 535 | if (channels & RedChannel) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 536 | sparse_arguments[x++] = QuantumScale*color.red; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 537 | if (channels & GreenChannel) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 538 | sparse_arguments[x++] = QuantumScale*color.green; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 539 | if (channels & BlueChannel) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 540 | sparse_arguments[x++] = QuantumScale*color.blue; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 541 | if (channels & BlackChannel) |
| 542 | sparse_arguments[x++] = QuantumScale*color.black; |
| 543 | if (channels & OpacityChannel) |
| 544 | sparse_arguments[x++] = QuantumScale*color.alpha; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 545 | } |
| 546 | else { |
| 547 | /* Colors given as a set of floating point values - experimental */ |
| 548 | /* NB: token contains the first floating point value to use! */ |
| 549 | if ( channels & RedChannel ) { |
| 550 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 551 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 552 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 553 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 554 | token[0] = ','; /* used this token - get another */ |
| 555 | } |
| 556 | if ( channels & GreenChannel ) { |
| 557 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 558 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 559 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 560 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 561 | token[0] = ','; /* used this token - get another */ |
| 562 | } |
| 563 | if ( channels & BlueChannel ) { |
| 564 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 565 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 566 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 567 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 568 | token[0] = ','; /* used this token - get another */ |
| 569 | } |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 570 | if (channels & BlackChannel) { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 571 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 572 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 573 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 574 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 575 | token[0] = ','; /* used this token - get another */ |
| 576 | } |
| 577 | if ( channels & OpacityChannel ) { |
| 578 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 579 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 580 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 581 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 582 | token[0] = ','; /* used this token - get another */ |
| 583 | } |
| 584 | } |
| 585 | } |
| 586 | } |
| 587 | if ( number_arguments != x && !error ) { |
| 588 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
| 589 | "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error"); |
| 590 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 591 | return( (Image *)NULL); |
| 592 | } |
| 593 | if ( error ) |
| 594 | return( (Image *)NULL); |
| 595 | |
| 596 | /* Call the Interpolation function with the parsed arguments */ |
| 597 | sparse_image=SparseColorImage(image,channels,method,number_arguments, |
| 598 | sparse_arguments,exception); |
| 599 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 600 | return( sparse_image ); |
| 601 | } |
| 602 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 603 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 604 | const char **argv,Image **image,ExceptionInfo *exception) |
| 605 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 606 | ChannelType |
| 607 | channel; |
| 608 | |
| 609 | const char |
| 610 | *format, |
| 611 | *option; |
| 612 | |
| 613 | DrawInfo |
| 614 | *draw_info; |
| 615 | |
| 616 | GeometryInfo |
| 617 | geometry_info; |
| 618 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 619 | Image |
| 620 | *region_image; |
| 621 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 622 | ImageInfo |
| 623 | *mogrify_info; |
| 624 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 625 | MagickStatusType |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 626 | status; |
| 627 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 628 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 629 | fill; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 630 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 631 | MagickStatusType |
| 632 | flags; |
| 633 | |
| 634 | QuantizeInfo |
| 635 | *quantize_info; |
| 636 | |
| 637 | RectangleInfo |
| 638 | geometry, |
| 639 | region_geometry; |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame] | 640 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 641 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 642 | i; |
| 643 | |
| 644 | /* |
| 645 | Initialize method variables. |
| 646 | */ |
| 647 | assert(image_info != (const ImageInfo *) NULL); |
| 648 | assert(image_info->signature == MagickSignature); |
| 649 | assert(image != (Image **) NULL); |
| 650 | assert((*image)->signature == MagickSignature); |
| 651 | if ((*image)->debug != MagickFalse) |
| 652 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); |
| 653 | if (argc < 0) |
| 654 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 655 | mogrify_info=CloneImageInfo(image_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 656 | draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL); |
| 657 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 658 | SetGeometryInfo(&geometry_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 659 | GetPixelInfo(*image,&fill); |
| 660 | SetPixelInfoPacket(*image,&(*image)->background_color,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 661 | channel=mogrify_info->channel; |
| 662 | format=GetImageOption(mogrify_info,"format"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 663 | SetGeometry(*image,®ion_geometry); |
| 664 | region_image=NewImageList(); |
| 665 | /* |
| 666 | Transmogrify the image. |
| 667 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 668 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 669 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 670 | Image |
| 671 | *mogrify_image; |
| 672 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 673 | ssize_t |
| 674 | count; |
| 675 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 676 | option=argv[i]; |
| 677 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 678 | continue; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 679 | count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option), |
| 680 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 681 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 682 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 683 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 684 | mogrify_image=(Image *)NULL; |
| 685 | switch (*(option+1)) |
| 686 | { |
| 687 | case 'a': |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 688 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 689 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 690 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 691 | /* |
| 692 | Adaptive blur image. |
| 693 | */ |
| 694 | (void) SyncImageSettings(mogrify_info,*image); |
| 695 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 696 | if ((flags & SigmaValue) == 0) |
| 697 | geometry_info.sigma=1.0; |
| 698 | mogrify_image=AdaptiveBlurImageChannel(*image,channel, |
| 699 | geometry_info.rho,geometry_info.sigma,exception); |
| 700 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 701 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 702 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 703 | { |
| 704 | /* |
| 705 | Adaptive resize image. |
| 706 | */ |
| 707 | (void) SyncImageSettings(mogrify_info,*image); |
| 708 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 709 | mogrify_image=AdaptiveResizeImage(*image,geometry.width, |
| 710 | geometry.height,exception); |
| 711 | break; |
| 712 | } |
| 713 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 714 | { |
| 715 | /* |
| 716 | Adaptive sharpen image. |
| 717 | */ |
| 718 | (void) SyncImageSettings(mogrify_info,*image); |
| 719 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 720 | if ((flags & SigmaValue) == 0) |
| 721 | geometry_info.sigma=1.0; |
| 722 | mogrify_image=AdaptiveSharpenImageChannel(*image,channel, |
| 723 | geometry_info.rho,geometry_info.sigma,exception); |
| 724 | break; |
| 725 | } |
| 726 | if (LocaleCompare("affine",option+1) == 0) |
| 727 | { |
| 728 | /* |
| 729 | Affine matrix. |
| 730 | */ |
| 731 | if (*option == '+') |
| 732 | { |
| 733 | GetAffineMatrix(&draw_info->affine); |
| 734 | break; |
| 735 | } |
| 736 | (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); |
| 737 | break; |
| 738 | } |
| 739 | if (LocaleCompare("alpha",option+1) == 0) |
| 740 | { |
| 741 | AlphaChannelType |
| 742 | alpha_type; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 743 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 744 | (void) SyncImageSettings(mogrify_info,*image); |
| 745 | alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions, |
| 746 | MagickFalse,argv[i+1]); |
| 747 | (void) SetImageAlphaChannel(*image,alpha_type); |
| 748 | InheritException(exception,&(*image)->exception); |
| 749 | break; |
| 750 | } |
| 751 | if (LocaleCompare("annotate",option+1) == 0) |
| 752 | { |
| 753 | char |
| 754 | *text, |
| 755 | geometry[MaxTextExtent]; |
| 756 | |
| 757 | /* |
| 758 | Annotate image. |
| 759 | */ |
| 760 | (void) SyncImageSettings(mogrify_info,*image); |
| 761 | SetGeometryInfo(&geometry_info); |
| 762 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 763 | if ((flags & SigmaValue) == 0) |
| 764 | geometry_info.sigma=geometry_info.rho; |
| 765 | text=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 766 | InheritException(exception,&(*image)->exception); |
| 767 | if (text == (char *) NULL) |
| 768 | break; |
| 769 | (void) CloneString(&draw_info->text,text); |
| 770 | text=DestroyString(text); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 771 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 772 | geometry_info.xi,geometry_info.psi); |
| 773 | (void) CloneString(&draw_info->geometry,geometry); |
| 774 | draw_info->affine.sx=cos(DegreesToRadians( |
| 775 | fmod(geometry_info.rho,360.0))); |
| 776 | draw_info->affine.rx=sin(DegreesToRadians( |
| 777 | fmod(geometry_info.rho,360.0))); |
| 778 | draw_info->affine.ry=(-sin(DegreesToRadians( |
| 779 | fmod(geometry_info.sigma,360.0)))); |
| 780 | draw_info->affine.sy=cos(DegreesToRadians( |
| 781 | fmod(geometry_info.sigma,360.0))); |
| 782 | (void) AnnotateImage(*image,draw_info); |
| 783 | InheritException(exception,&(*image)->exception); |
| 784 | break; |
| 785 | } |
| 786 | if (LocaleCompare("antialias",option+1) == 0) |
| 787 | { |
| 788 | draw_info->stroke_antialias=(*option == '-') ? MagickTrue : |
| 789 | MagickFalse; |
| 790 | draw_info->text_antialias=(*option == '-') ? MagickTrue : |
| 791 | MagickFalse; |
| 792 | break; |
| 793 | } |
| 794 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 795 | { |
| 796 | /* |
| 797 | Auto Adjust Gamma of image based on its mean |
| 798 | */ |
| 799 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | ab01585 | 2011-07-06 01:03:32 +0000 | [diff] [blame] | 800 | (void) AutoGammaImage(*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 801 | break; |
| 802 | } |
| 803 | if (LocaleCompare("auto-level",option+1) == 0) |
| 804 | { |
| 805 | /* |
| 806 | Perfectly Normalize (max/min stretch) the image |
| 807 | */ |
| 808 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | ab01585 | 2011-07-06 01:03:32 +0000 | [diff] [blame] | 809 | (void) AutoLevelImage(*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 810 | break; |
| 811 | } |
| 812 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 813 | { |
| 814 | (void) SyncImageSettings(mogrify_info,*image); |
| 815 | switch ((*image)->orientation) |
| 816 | { |
| 817 | case TopRightOrientation: |
| 818 | { |
| 819 | mogrify_image=FlopImage(*image,exception); |
| 820 | break; |
| 821 | } |
| 822 | case BottomRightOrientation: |
| 823 | { |
| 824 | mogrify_image=RotateImage(*image,180.0,exception); |
| 825 | break; |
| 826 | } |
| 827 | case BottomLeftOrientation: |
| 828 | { |
| 829 | mogrify_image=FlipImage(*image,exception); |
| 830 | break; |
| 831 | } |
| 832 | case LeftTopOrientation: |
| 833 | { |
| 834 | mogrify_image=TransposeImage(*image,exception); |
| 835 | break; |
| 836 | } |
| 837 | case RightTopOrientation: |
| 838 | { |
| 839 | mogrify_image=RotateImage(*image,90.0,exception); |
| 840 | break; |
| 841 | } |
| 842 | case RightBottomOrientation: |
| 843 | { |
| 844 | mogrify_image=TransverseImage(*image,exception); |
| 845 | break; |
| 846 | } |
| 847 | case LeftBottomOrientation: |
| 848 | { |
| 849 | mogrify_image=RotateImage(*image,270.0,exception); |
| 850 | break; |
| 851 | } |
| 852 | default: |
| 853 | break; |
| 854 | } |
| 855 | if (mogrify_image != (Image *) NULL) |
| 856 | mogrify_image->orientation=TopLeftOrientation; |
| 857 | break; |
| 858 | } |
| 859 | break; |
| 860 | } |
| 861 | case 'b': |
| 862 | { |
| 863 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 864 | { |
| 865 | /* |
| 866 | Black threshold image. |
| 867 | */ |
| 868 | (void) SyncImageSettings(mogrify_info,*image); |
| 869 | (void) BlackThresholdImageChannel(*image,channel,argv[i+1], |
| 870 | exception); |
| 871 | InheritException(exception,&(*image)->exception); |
| 872 | break; |
| 873 | } |
| 874 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 875 | { |
| 876 | /* |
| 877 | Blue shift image. |
| 878 | */ |
| 879 | (void) SyncImageSettings(mogrify_info,*image); |
| 880 | geometry_info.rho=1.5; |
| 881 | if (*option == '-') |
| 882 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 883 | mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception); |
| 884 | break; |
| 885 | } |
| 886 | if (LocaleCompare("blur",option+1) == 0) |
| 887 | { |
| 888 | /* |
| 889 | Gaussian blur image. |
| 890 | */ |
| 891 | (void) SyncImageSettings(mogrify_info,*image); |
| 892 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 893 | if ((flags & SigmaValue) == 0) |
| 894 | geometry_info.sigma=1.0; |
| 895 | mogrify_image=BlurImageChannel(*image,channel,geometry_info.rho, |
| 896 | geometry_info.sigma,exception); |
| 897 | break; |
| 898 | } |
| 899 | if (LocaleCompare("border",option+1) == 0) |
| 900 | { |
| 901 | /* |
| 902 | Surround image with a border of solid color. |
| 903 | */ |
| 904 | (void) SyncImageSettings(mogrify_info,*image); |
| 905 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 906 | if ((flags & SigmaValue) == 0) |
| 907 | geometry.height=geometry.width; |
| 908 | mogrify_image=BorderImage(*image,&geometry,exception); |
| 909 | break; |
| 910 | } |
| 911 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 912 | { |
| 913 | if (*option == '+') |
| 914 | { |
| 915 | (void) QueryColorDatabase(BorderColor,&draw_info->border_color, |
| 916 | exception); |
| 917 | break; |
| 918 | } |
| 919 | (void) QueryColorDatabase(argv[i+1],&draw_info->border_color, |
| 920 | exception); |
| 921 | break; |
| 922 | } |
| 923 | if (LocaleCompare("box",option+1) == 0) |
| 924 | { |
| 925 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 926 | exception); |
| 927 | break; |
| 928 | } |
| 929 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 930 | { |
| 931 | double |
| 932 | brightness, |
| 933 | contrast; |
| 934 | |
| 935 | GeometryInfo |
| 936 | geometry_info; |
| 937 | |
| 938 | MagickStatusType |
| 939 | flags; |
| 940 | |
| 941 | /* |
| 942 | Brightness / contrast image. |
| 943 | */ |
| 944 | (void) SyncImageSettings(mogrify_info,*image); |
| 945 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 946 | brightness=geometry_info.rho; |
| 947 | contrast=0.0; |
| 948 | if ((flags & SigmaValue) != 0) |
| 949 | contrast=geometry_info.sigma; |
cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 950 | (void) BrightnessContrastImage(*image,brightness,contrast); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 951 | InheritException(exception,&(*image)->exception); |
| 952 | break; |
| 953 | } |
| 954 | break; |
| 955 | } |
| 956 | case 'c': |
| 957 | { |
| 958 | if (LocaleCompare("cdl",option+1) == 0) |
| 959 | { |
| 960 | char |
| 961 | *color_correction_collection; |
| 962 | |
| 963 | /* |
| 964 | Color correct with a color decision list. |
| 965 | */ |
| 966 | (void) SyncImageSettings(mogrify_info,*image); |
| 967 | color_correction_collection=FileToString(argv[i+1],~0,exception); |
| 968 | if (color_correction_collection == (char *) NULL) |
| 969 | break; |
| 970 | (void) ColorDecisionListImage(*image,color_correction_collection); |
| 971 | InheritException(exception,&(*image)->exception); |
| 972 | break; |
| 973 | } |
| 974 | if (LocaleCompare("channel",option+1) == 0) |
| 975 | { |
| 976 | if (*option == '+') |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 977 | channel=DefaultChannels; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 978 | else |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 979 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 980 | SetPixelComponentMap(*image,channel); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 981 | break; |
| 982 | } |
| 983 | if (LocaleCompare("charcoal",option+1) == 0) |
| 984 | { |
| 985 | /* |
| 986 | Charcoal image. |
| 987 | */ |
| 988 | (void) SyncImageSettings(mogrify_info,*image); |
| 989 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 990 | if ((flags & SigmaValue) == 0) |
| 991 | geometry_info.sigma=1.0; |
| 992 | mogrify_image=CharcoalImage(*image,geometry_info.rho, |
| 993 | geometry_info.sigma,exception); |
| 994 | break; |
| 995 | } |
| 996 | if (LocaleCompare("chop",option+1) == 0) |
| 997 | { |
| 998 | /* |
| 999 | Chop the image. |
| 1000 | */ |
| 1001 | (void) SyncImageSettings(mogrify_info,*image); |
| 1002 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1003 | mogrify_image=ChopImage(*image,&geometry,exception); |
| 1004 | break; |
| 1005 | } |
| 1006 | if (LocaleCompare("clamp",option+1) == 0) |
| 1007 | { |
| 1008 | /* |
| 1009 | Clamp image. |
| 1010 | */ |
| 1011 | (void) SyncImageSettings(mogrify_info,*image); |
| 1012 | (void) ClampImageChannel(*image,channel); |
| 1013 | InheritException(exception,&(*image)->exception); |
| 1014 | break; |
| 1015 | } |
| 1016 | if (LocaleCompare("clip",option+1) == 0) |
| 1017 | { |
| 1018 | (void) SyncImageSettings(mogrify_info,*image); |
| 1019 | if (*option == '+') |
| 1020 | { |
| 1021 | (void) SetImageClipMask(*image,(Image *) NULL); |
| 1022 | InheritException(exception,&(*image)->exception); |
| 1023 | break; |
| 1024 | } |
| 1025 | (void) ClipImage(*image); |
| 1026 | InheritException(exception,&(*image)->exception); |
| 1027 | break; |
| 1028 | } |
| 1029 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1030 | { |
| 1031 | CacheView |
| 1032 | *mask_view; |
| 1033 | |
| 1034 | Image |
| 1035 | *mask_image; |
| 1036 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1037 | register Quantum |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1038 | *restrict q; |
| 1039 | |
| 1040 | register ssize_t |
| 1041 | x; |
| 1042 | |
| 1043 | ssize_t |
| 1044 | y; |
| 1045 | |
| 1046 | (void) SyncImageSettings(mogrify_info,*image); |
| 1047 | if (*option == '+') |
| 1048 | { |
| 1049 | /* |
| 1050 | Remove a mask. |
| 1051 | */ |
| 1052 | (void) SetImageMask(*image,(Image *) NULL); |
| 1053 | InheritException(exception,&(*image)->exception); |
| 1054 | break; |
| 1055 | } |
| 1056 | /* |
| 1057 | Set the image mask. |
| 1058 | FUTURE: This Should Be a SetImageAlphaChannel() call, Or two. |
| 1059 | */ |
| 1060 | mask_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1061 | if (mask_image == (Image *) NULL) |
| 1062 | break; |
| 1063 | if (SetImageStorageClass(mask_image,DirectClass) == MagickFalse) |
| 1064 | return(MagickFalse); |
| 1065 | mask_view=AcquireCacheView(mask_image); |
| 1066 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1067 | { |
| 1068 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1069 | exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1070 | if (q == (const Quantum *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1071 | break; |
| 1072 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1073 | { |
| 1074 | if (mask_image->matte == MagickFalse) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1075 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 1076 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1077 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1078 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
cristy | dcfc1ad | 2011-07-07 16:25:41 +0000 | [diff] [blame] | 1079 | q+=GetPixelComponents(mask_image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1080 | } |
| 1081 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
| 1082 | break; |
| 1083 | } |
| 1084 | mask_view=DestroyCacheView(mask_view); |
| 1085 | mask_image->matte=MagickTrue; |
| 1086 | (void) SetImageClipMask(*image,mask_image); |
| 1087 | mask_image=DestroyImage(mask_image); |
| 1088 | InheritException(exception,&(*image)->exception); |
| 1089 | break; |
| 1090 | } |
| 1091 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1092 | { |
| 1093 | (void) SyncImageSettings(mogrify_info,*image); |
| 1094 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
| 1095 | MagickFalse); |
| 1096 | InheritException(exception,&(*image)->exception); |
| 1097 | break; |
| 1098 | } |
| 1099 | if (LocaleCompare("colorize",option+1) == 0) |
| 1100 | { |
| 1101 | /* |
| 1102 | Colorize the image. |
| 1103 | */ |
| 1104 | (void) SyncImageSettings(mogrify_info,*image); |
| 1105 | mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill, |
| 1106 | exception); |
| 1107 | break; |
| 1108 | } |
| 1109 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1110 | { |
| 1111 | KernelInfo |
| 1112 | *kernel; |
| 1113 | |
| 1114 | (void) SyncImageSettings(mogrify_info,*image); |
| 1115 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1116 | if (kernel == (KernelInfo *) NULL) |
| 1117 | break; |
| 1118 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 1119 | kernel=DestroyKernelInfo(kernel); |
| 1120 | break; |
| 1121 | } |
| 1122 | if (LocaleCompare("colors",option+1) == 0) |
| 1123 | { |
| 1124 | /* |
| 1125 | Reduce the number of colors in the image. |
| 1126 | */ |
| 1127 | (void) SyncImageSettings(mogrify_info,*image); |
| 1128 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
| 1129 | if (quantize_info->number_colors == 0) |
| 1130 | break; |
| 1131 | if (((*image)->storage_class == DirectClass) || |
| 1132 | (*image)->colors > quantize_info->number_colors) |
| 1133 | (void) QuantizeImage(quantize_info,*image); |
| 1134 | else |
| 1135 | (void) CompressImageColormap(*image); |
| 1136 | InheritException(exception,&(*image)->exception); |
| 1137 | break; |
| 1138 | } |
| 1139 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1140 | { |
| 1141 | ColorspaceType |
| 1142 | colorspace; |
| 1143 | |
| 1144 | (void) SyncImageSettings(mogrify_info,*image); |
| 1145 | if (*option == '+') |
| 1146 | { |
| 1147 | (void) TransformImageColorspace(*image,RGBColorspace); |
| 1148 | InheritException(exception,&(*image)->exception); |
| 1149 | break; |
| 1150 | } |
| 1151 | colorspace=(ColorspaceType) ParseCommandOption( |
| 1152 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 1153 | (void) TransformImageColorspace(*image,colorspace); |
| 1154 | InheritException(exception,&(*image)->exception); |
| 1155 | break; |
| 1156 | } |
| 1157 | if (LocaleCompare("contrast",option+1) == 0) |
| 1158 | { |
| 1159 | (void) SyncImageSettings(mogrify_info,*image); |
| 1160 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
| 1161 | MagickFalse); |
| 1162 | InheritException(exception,&(*image)->exception); |
| 1163 | break; |
| 1164 | } |
| 1165 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1166 | { |
| 1167 | double |
| 1168 | black_point, |
| 1169 | white_point; |
| 1170 | |
| 1171 | MagickStatusType |
| 1172 | flags; |
| 1173 | |
| 1174 | /* |
| 1175 | Contrast stretch image. |
| 1176 | */ |
| 1177 | (void) SyncImageSettings(mogrify_info,*image); |
| 1178 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1179 | black_point=geometry_info.rho; |
| 1180 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1181 | black_point; |
| 1182 | if ((flags & PercentValue) != 0) |
| 1183 | { |
| 1184 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1185 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1186 | } |
| 1187 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1188 | white_point; |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1189 | (void) ContrastStretchImage(*image,black_point,white_point); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1190 | InheritException(exception,&(*image)->exception); |
| 1191 | break; |
| 1192 | } |
| 1193 | if (LocaleCompare("convolve",option+1) == 0) |
| 1194 | { |
| 1195 | double |
| 1196 | gamma; |
| 1197 | |
| 1198 | KernelInfo |
| 1199 | *kernel; |
| 1200 | |
| 1201 | register ssize_t |
| 1202 | j; |
| 1203 | |
| 1204 | (void) SyncImageSettings(mogrify_info,*image); |
| 1205 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1206 | if (kernel == (KernelInfo *) NULL) |
| 1207 | break; |
| 1208 | gamma=0.0; |
| 1209 | for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++) |
| 1210 | gamma+=kernel->values[j]; |
| 1211 | gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma); |
| 1212 | for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++) |
| 1213 | kernel->values[j]*=gamma; |
| 1214 | mogrify_image=FilterImageChannel(*image,channel,kernel,exception); |
| 1215 | kernel=DestroyKernelInfo(kernel); |
| 1216 | break; |
| 1217 | } |
| 1218 | if (LocaleCompare("crop",option+1) == 0) |
| 1219 | { |
| 1220 | /* |
| 1221 | Crop a image to a smaller size |
| 1222 | */ |
| 1223 | (void) SyncImageSettings(mogrify_info,*image); |
| 1224 | #if 0 |
| 1225 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1226 | if (((geometry.width != 0) || (geometry.height != 0)) && |
| 1227 | ((flags & XValue) == 0) && ((flags & YValue) == 0)) |
| 1228 | break; |
| 1229 | #endif |
| 1230 | #if 0 |
| 1231 | mogrify_image=CloneImage(*image,0,0,MagickTrue,&(*image)->exception); |
| 1232 | mogrify_image->next = mogrify_image->previous = (Image *)NULL; |
| 1233 | (void) TransformImage(&mogrify_image,argv[i+1],(char *) NULL); |
| 1234 | InheritException(exception,&mogrify_image->exception); |
| 1235 | #else |
| 1236 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
| 1237 | #endif |
| 1238 | break; |
| 1239 | } |
| 1240 | if (LocaleCompare("cycle",option+1) == 0) |
| 1241 | { |
| 1242 | /* |
| 1243 | Cycle an image colormap. |
| 1244 | */ |
| 1245 | (void) SyncImageSettings(mogrify_info,*image); |
| 1246 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1])); |
| 1247 | InheritException(exception,&(*image)->exception); |
| 1248 | break; |
| 1249 | } |
| 1250 | break; |
| 1251 | } |
| 1252 | case 'd': |
| 1253 | { |
| 1254 | if (LocaleCompare("decipher",option+1) == 0) |
| 1255 | { |
| 1256 | StringInfo |
| 1257 | *passkey; |
| 1258 | |
| 1259 | /* |
| 1260 | Decipher pixels. |
| 1261 | */ |
| 1262 | (void) SyncImageSettings(mogrify_info,*image); |
| 1263 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1264 | if (passkey != (StringInfo *) NULL) |
| 1265 | { |
| 1266 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1267 | passkey=DestroyStringInfo(passkey); |
| 1268 | } |
| 1269 | break; |
| 1270 | } |
| 1271 | if (LocaleCompare("density",option+1) == 0) |
| 1272 | { |
| 1273 | /* |
| 1274 | Set image density. |
| 1275 | */ |
| 1276 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1277 | break; |
| 1278 | } |
| 1279 | if (LocaleCompare("depth",option+1) == 0) |
| 1280 | { |
| 1281 | (void) SyncImageSettings(mogrify_info,*image); |
| 1282 | if (*option == '+') |
| 1283 | { |
| 1284 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH); |
| 1285 | break; |
| 1286 | } |
| 1287 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1])); |
| 1288 | break; |
| 1289 | } |
| 1290 | if (LocaleCompare("deskew",option+1) == 0) |
| 1291 | { |
| 1292 | double |
| 1293 | threshold; |
| 1294 | |
| 1295 | /* |
| 1296 | Straighten the image. |
| 1297 | */ |
| 1298 | (void) SyncImageSettings(mogrify_info,*image); |
| 1299 | if (*option == '+') |
| 1300 | threshold=40.0*QuantumRange/100.0; |
| 1301 | else |
| 1302 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 1303 | mogrify_image=DeskewImage(*image,threshold,exception); |
| 1304 | break; |
| 1305 | } |
| 1306 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1307 | { |
| 1308 | /* |
| 1309 | Reduce the speckles within an image. |
| 1310 | */ |
| 1311 | (void) SyncImageSettings(mogrify_info,*image); |
| 1312 | mogrify_image=DespeckleImage(*image,exception); |
| 1313 | break; |
| 1314 | } |
| 1315 | if (LocaleCompare("display",option+1) == 0) |
| 1316 | { |
| 1317 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1318 | break; |
| 1319 | } |
| 1320 | if (LocaleCompare("distort",option+1) == 0) |
| 1321 | { |
| 1322 | char |
| 1323 | *args, |
| 1324 | token[MaxTextExtent]; |
| 1325 | |
| 1326 | const char |
| 1327 | *p; |
| 1328 | |
| 1329 | DistortImageMethod |
| 1330 | method; |
| 1331 | |
| 1332 | double |
| 1333 | *arguments; |
| 1334 | |
| 1335 | register ssize_t |
| 1336 | x; |
| 1337 | |
| 1338 | size_t |
| 1339 | number_arguments; |
| 1340 | |
| 1341 | /* |
| 1342 | Distort image. |
| 1343 | */ |
| 1344 | (void) SyncImageSettings(mogrify_info,*image); |
| 1345 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, |
| 1346 | MagickFalse,argv[i+1]); |
| 1347 | if ( method == ResizeDistortion ) |
| 1348 | { |
| 1349 | /* Special Case - Argument is actually a resize geometry! |
| 1350 | ** Convert that to an appropriate distortion argument array. |
| 1351 | */ |
| 1352 | double |
| 1353 | resize_args[2]; |
| 1354 | (void) ParseRegionGeometry(*image,argv[i+2],&geometry, |
| 1355 | exception); |
| 1356 | resize_args[0]=(double)geometry.width; |
| 1357 | resize_args[1]=(double)geometry.height; |
| 1358 | mogrify_image=DistortImage(*image,method,(size_t)2, |
| 1359 | resize_args,MagickTrue,exception); |
| 1360 | break; |
| 1361 | } |
| 1362 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 1363 | InheritException(exception,&(*image)->exception); |
| 1364 | if (args == (char *) NULL) |
| 1365 | break; |
| 1366 | p=(char *) args; |
| 1367 | for (x=0; *p != '\0'; x++) |
| 1368 | { |
| 1369 | GetMagickToken(p,&p,token); |
| 1370 | if (*token == ',') |
| 1371 | GetMagickToken(p,&p,token); |
| 1372 | } |
| 1373 | number_arguments=(size_t) x; |
| 1374 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1375 | sizeof(*arguments)); |
| 1376 | if (arguments == (double *) NULL) |
| 1377 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1378 | "MemoryAllocationFailed",(*image)->filename); |
| 1379 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1380 | sizeof(*arguments)); |
| 1381 | p=(char *) args; |
| 1382 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 1383 | { |
| 1384 | GetMagickToken(p,&p,token); |
| 1385 | if (*token == ',') |
| 1386 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1387 | arguments[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1388 | } |
| 1389 | args=DestroyString(args); |
| 1390 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
| 1391 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1392 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1393 | break; |
| 1394 | } |
| 1395 | if (LocaleCompare("dither",option+1) == 0) |
| 1396 | { |
| 1397 | if (*option == '+') |
| 1398 | { |
| 1399 | quantize_info->dither=MagickFalse; |
| 1400 | break; |
| 1401 | } |
| 1402 | quantize_info->dither=MagickTrue; |
| 1403 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
| 1404 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1405 | if (quantize_info->dither_method == NoDitherMethod) |
| 1406 | quantize_info->dither=MagickFalse; |
| 1407 | break; |
| 1408 | } |
| 1409 | if (LocaleCompare("draw",option+1) == 0) |
| 1410 | { |
| 1411 | /* |
| 1412 | Draw image. |
| 1413 | */ |
| 1414 | (void) SyncImageSettings(mogrify_info,*image); |
| 1415 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
| 1416 | (void) DrawImage(*image,draw_info); |
| 1417 | InheritException(exception,&(*image)->exception); |
| 1418 | break; |
| 1419 | } |
| 1420 | break; |
| 1421 | } |
| 1422 | case 'e': |
| 1423 | { |
| 1424 | if (LocaleCompare("edge",option+1) == 0) |
| 1425 | { |
| 1426 | /* |
| 1427 | Enhance edges in the image. |
| 1428 | */ |
| 1429 | (void) SyncImageSettings(mogrify_info,*image); |
| 1430 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1431 | if ((flags & SigmaValue) == 0) |
| 1432 | geometry_info.sigma=1.0; |
| 1433 | mogrify_image=EdgeImage(*image,geometry_info.rho,exception); |
| 1434 | break; |
| 1435 | } |
| 1436 | if (LocaleCompare("emboss",option+1) == 0) |
| 1437 | { |
| 1438 | /* |
| 1439 | Gaussian embossen image. |
| 1440 | */ |
| 1441 | (void) SyncImageSettings(mogrify_info,*image); |
| 1442 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1443 | if ((flags & SigmaValue) == 0) |
| 1444 | geometry_info.sigma=1.0; |
| 1445 | mogrify_image=EmbossImage(*image,geometry_info.rho, |
| 1446 | geometry_info.sigma,exception); |
| 1447 | break; |
| 1448 | } |
| 1449 | if (LocaleCompare("encipher",option+1) == 0) |
| 1450 | { |
| 1451 | StringInfo |
| 1452 | *passkey; |
| 1453 | |
| 1454 | /* |
| 1455 | Encipher pixels. |
| 1456 | */ |
| 1457 | (void) SyncImageSettings(mogrify_info,*image); |
| 1458 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1459 | if (passkey != (StringInfo *) NULL) |
| 1460 | { |
| 1461 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1462 | passkey=DestroyStringInfo(passkey); |
| 1463 | } |
| 1464 | break; |
| 1465 | } |
| 1466 | if (LocaleCompare("encoding",option+1) == 0) |
| 1467 | { |
| 1468 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1469 | break; |
| 1470 | } |
| 1471 | if (LocaleCompare("enhance",option+1) == 0) |
| 1472 | { |
| 1473 | /* |
| 1474 | Enhance image. |
| 1475 | */ |
| 1476 | (void) SyncImageSettings(mogrify_info,*image); |
| 1477 | mogrify_image=EnhanceImage(*image,exception); |
| 1478 | break; |
| 1479 | } |
| 1480 | if (LocaleCompare("equalize",option+1) == 0) |
| 1481 | { |
| 1482 | /* |
| 1483 | Equalize image. |
| 1484 | */ |
| 1485 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1486 | (void) EqualizeImage(*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1487 | InheritException(exception,&(*image)->exception); |
| 1488 | break; |
| 1489 | } |
| 1490 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1491 | { |
| 1492 | double |
| 1493 | constant; |
| 1494 | |
| 1495 | MagickEvaluateOperator |
| 1496 | op; |
| 1497 | |
| 1498 | (void) SyncImageSettings(mogrify_info,*image); |
| 1499 | op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions, |
| 1500 | MagickFalse,argv[i+1]); |
| 1501 | constant=SiPrefixToDouble(argv[i+2],QuantumRange); |
| 1502 | (void) EvaluateImageChannel(*image,channel,op,constant,exception); |
| 1503 | break; |
| 1504 | } |
| 1505 | if (LocaleCompare("extent",option+1) == 0) |
| 1506 | { |
| 1507 | /* |
| 1508 | Set the image extent. |
| 1509 | */ |
| 1510 | (void) SyncImageSettings(mogrify_info,*image); |
| 1511 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1512 | if (geometry.width == 0) |
| 1513 | geometry.width=(*image)->columns; |
| 1514 | if (geometry.height == 0) |
| 1515 | geometry.height=(*image)->rows; |
| 1516 | mogrify_image=ExtentImage(*image,&geometry,exception); |
| 1517 | break; |
| 1518 | } |
| 1519 | break; |
| 1520 | } |
| 1521 | case 'f': |
| 1522 | { |
| 1523 | if (LocaleCompare("family",option+1) == 0) |
| 1524 | { |
| 1525 | if (*option == '+') |
| 1526 | { |
| 1527 | if (draw_info->family != (char *) NULL) |
| 1528 | draw_info->family=DestroyString(draw_info->family); |
| 1529 | break; |
| 1530 | } |
| 1531 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1532 | break; |
| 1533 | } |
| 1534 | if (LocaleCompare("features",option+1) == 0) |
| 1535 | { |
| 1536 | if (*option == '+') |
| 1537 | { |
| 1538 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1539 | break; |
| 1540 | } |
| 1541 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1542 | break; |
| 1543 | } |
| 1544 | if (LocaleCompare("fill",option+1) == 0) |
| 1545 | { |
| 1546 | ExceptionInfo |
| 1547 | *sans; |
| 1548 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1549 | GetPixelInfo(*image,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1550 | if (*option == '+') |
| 1551 | { |
| 1552 | (void) QueryMagickColor("none",&fill,exception); |
| 1553 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 1554 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1555 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1556 | break; |
| 1557 | } |
| 1558 | sans=AcquireExceptionInfo(); |
| 1559 | (void) QueryMagickColor(argv[i+1],&fill,sans); |
| 1560 | status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans); |
| 1561 | sans=DestroyExceptionInfo(sans); |
| 1562 | if (status == MagickFalse) |
| 1563 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 1564 | exception); |
| 1565 | break; |
| 1566 | } |
| 1567 | if (LocaleCompare("flip",option+1) == 0) |
| 1568 | { |
| 1569 | /* |
| 1570 | Flip image scanlines. |
| 1571 | */ |
| 1572 | (void) SyncImageSettings(mogrify_info,*image); |
| 1573 | mogrify_image=FlipImage(*image,exception); |
| 1574 | break; |
| 1575 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1576 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1577 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1578 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1579 | target; |
| 1580 | |
| 1581 | /* |
| 1582 | Floodfill image. |
| 1583 | */ |
| 1584 | (void) SyncImageSettings(mogrify_info,*image); |
| 1585 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1586 | (void) QueryMagickColor(argv[i+2],&target,exception); |
| 1587 | (void) FloodfillPaintImage(*image,channel,draw_info,&target, |
| 1588 | geometry.x,geometry.y,*option == '-' ? MagickFalse : MagickTrue); |
| 1589 | InheritException(exception,&(*image)->exception); |
| 1590 | break; |
| 1591 | } |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1592 | if (LocaleCompare("flop",option+1) == 0) |
| 1593 | { |
| 1594 | /* |
| 1595 | Flop image scanlines. |
| 1596 | */ |
| 1597 | (void) SyncImageSettings(mogrify_info,*image); |
| 1598 | mogrify_image=FlopImage(*image,exception); |
| 1599 | break; |
| 1600 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1601 | if (LocaleCompare("font",option+1) == 0) |
| 1602 | { |
| 1603 | if (*option == '+') |
| 1604 | { |
| 1605 | if (draw_info->font != (char *) NULL) |
| 1606 | draw_info->font=DestroyString(draw_info->font); |
| 1607 | break; |
| 1608 | } |
| 1609 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1610 | break; |
| 1611 | } |
| 1612 | if (LocaleCompare("format",option+1) == 0) |
| 1613 | { |
| 1614 | format=argv[i+1]; |
| 1615 | break; |
| 1616 | } |
| 1617 | if (LocaleCompare("frame",option+1) == 0) |
| 1618 | { |
| 1619 | FrameInfo |
| 1620 | frame_info; |
| 1621 | |
| 1622 | /* |
| 1623 | Surround image with an ornamental border. |
| 1624 | */ |
| 1625 | (void) SyncImageSettings(mogrify_info,*image); |
| 1626 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1627 | frame_info.width=geometry.width; |
| 1628 | frame_info.height=geometry.height; |
| 1629 | if ((flags & HeightValue) == 0) |
| 1630 | frame_info.height=geometry.width; |
| 1631 | frame_info.outer_bevel=geometry.x; |
| 1632 | frame_info.inner_bevel=geometry.y; |
| 1633 | frame_info.x=(ssize_t) frame_info.width; |
| 1634 | frame_info.y=(ssize_t) frame_info.height; |
| 1635 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1636 | frame_info.height=(*image)->rows+2*frame_info.height; |
| 1637 | mogrify_image=FrameImage(*image,&frame_info,exception); |
| 1638 | break; |
| 1639 | } |
| 1640 | if (LocaleCompare("function",option+1) == 0) |
| 1641 | { |
| 1642 | char |
| 1643 | *arguments, |
| 1644 | token[MaxTextExtent]; |
| 1645 | |
| 1646 | const char |
| 1647 | *p; |
| 1648 | |
| 1649 | double |
| 1650 | *parameters; |
| 1651 | |
| 1652 | MagickFunction |
| 1653 | function; |
| 1654 | |
| 1655 | register ssize_t |
| 1656 | x; |
| 1657 | |
| 1658 | size_t |
| 1659 | number_parameters; |
| 1660 | |
| 1661 | /* |
| 1662 | Function Modify Image Values |
| 1663 | */ |
| 1664 | (void) SyncImageSettings(mogrify_info,*image); |
| 1665 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, |
| 1666 | MagickFalse,argv[i+1]); |
| 1667 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 1668 | InheritException(exception,&(*image)->exception); |
| 1669 | if (arguments == (char *) NULL) |
| 1670 | break; |
| 1671 | p=(char *) arguments; |
| 1672 | for (x=0; *p != '\0'; x++) |
| 1673 | { |
| 1674 | GetMagickToken(p,&p,token); |
| 1675 | if (*token == ',') |
| 1676 | GetMagickToken(p,&p,token); |
| 1677 | } |
| 1678 | number_parameters=(size_t) x; |
| 1679 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1680 | sizeof(*parameters)); |
| 1681 | if (parameters == (double *) NULL) |
| 1682 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1683 | "MemoryAllocationFailed",(*image)->filename); |
| 1684 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1685 | sizeof(*parameters)); |
| 1686 | p=(char *) arguments; |
| 1687 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
| 1688 | { |
| 1689 | GetMagickToken(p,&p,token); |
| 1690 | if (*token == ',') |
| 1691 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1692 | parameters[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1693 | } |
| 1694 | arguments=DestroyString(arguments); |
| 1695 | (void) FunctionImageChannel(*image,channel,function, |
| 1696 | number_parameters,parameters,exception); |
| 1697 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1698 | break; |
| 1699 | } |
| 1700 | break; |
| 1701 | } |
| 1702 | case 'g': |
| 1703 | { |
| 1704 | if (LocaleCompare("gamma",option+1) == 0) |
| 1705 | { |
| 1706 | /* |
| 1707 | Gamma image. |
| 1708 | */ |
| 1709 | (void) SyncImageSettings(mogrify_info,*image); |
| 1710 | if (*option == '+') |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1711 | (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1712 | else |
| 1713 | { |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1714 | (void) GammaImage(*image,InterpretLocaleValue(argv[i+1], |
| 1715 | (char **) NULL)); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1716 | InheritException(exception,&(*image)->exception); |
| 1717 | } |
| 1718 | break; |
| 1719 | } |
| 1720 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1721 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1722 | { |
| 1723 | /* |
| 1724 | Gaussian blur image. |
| 1725 | */ |
| 1726 | (void) SyncImageSettings(mogrify_info,*image); |
| 1727 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1728 | if ((flags & SigmaValue) == 0) |
| 1729 | geometry_info.sigma=1.0; |
| 1730 | mogrify_image=GaussianBlurImageChannel(*image,channel, |
| 1731 | geometry_info.rho,geometry_info.sigma,exception); |
| 1732 | break; |
| 1733 | } |
| 1734 | if (LocaleCompare("geometry",option+1) == 0) |
| 1735 | { |
| 1736 | /* |
| 1737 | Record Image offset, Resize last image. |
| 1738 | */ |
| 1739 | (void) SyncImageSettings(mogrify_info,*image); |
| 1740 | if (*option == '+') |
| 1741 | { |
| 1742 | if ((*image)->geometry != (char *) NULL) |
| 1743 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1744 | break; |
| 1745 | } |
| 1746 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1747 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1748 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1749 | else |
| 1750 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 1751 | (*image)->filter,(*image)->blur,exception); |
| 1752 | break; |
| 1753 | } |
| 1754 | if (LocaleCompare("gravity",option+1) == 0) |
| 1755 | { |
| 1756 | if (*option == '+') |
| 1757 | { |
| 1758 | draw_info->gravity=UndefinedGravity; |
| 1759 | break; |
| 1760 | } |
| 1761 | draw_info->gravity=(GravityType) ParseCommandOption( |
| 1762 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1763 | break; |
| 1764 | } |
| 1765 | break; |
| 1766 | } |
| 1767 | case 'h': |
| 1768 | { |
| 1769 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1770 | { |
| 1771 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1772 | break; |
| 1773 | } |
| 1774 | break; |
| 1775 | } |
| 1776 | case 'i': |
| 1777 | { |
| 1778 | if (LocaleCompare("identify",option+1) == 0) |
| 1779 | { |
| 1780 | char |
| 1781 | *text; |
| 1782 | |
| 1783 | (void) SyncImageSettings(mogrify_info,*image); |
| 1784 | if (format == (char *) NULL) |
| 1785 | { |
| 1786 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose); |
| 1787 | InheritException(exception,&(*image)->exception); |
| 1788 | break; |
| 1789 | } |
| 1790 | text=InterpretImageProperties(mogrify_info,*image,format); |
| 1791 | InheritException(exception,&(*image)->exception); |
| 1792 | if (text == (char *) NULL) |
| 1793 | break; |
| 1794 | (void) fputs(text,stdout); |
| 1795 | (void) fputc('\n',stdout); |
| 1796 | text=DestroyString(text); |
| 1797 | break; |
| 1798 | } |
| 1799 | if (LocaleCompare("implode",option+1) == 0) |
| 1800 | { |
| 1801 | /* |
| 1802 | Implode image. |
| 1803 | */ |
| 1804 | (void) SyncImageSettings(mogrify_info,*image); |
| 1805 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1806 | mogrify_image=ImplodeImage(*image,geometry_info.rho,exception); |
| 1807 | break; |
| 1808 | } |
| 1809 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1810 | { |
| 1811 | if (*option == '+') |
| 1812 | (void) ParseGeometry("0",&geometry_info); |
| 1813 | else |
| 1814 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1815 | draw_info->interline_spacing=geometry_info.rho; |
| 1816 | break; |
| 1817 | } |
| 1818 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1819 | { |
| 1820 | if (*option == '+') |
| 1821 | (void) ParseGeometry("0",&geometry_info); |
| 1822 | else |
| 1823 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1824 | draw_info->interword_spacing=geometry_info.rho; |
| 1825 | break; |
| 1826 | } |
| 1827 | break; |
| 1828 | } |
| 1829 | case 'k': |
| 1830 | { |
| 1831 | if (LocaleCompare("kerning",option+1) == 0) |
| 1832 | { |
| 1833 | if (*option == '+') |
| 1834 | (void) ParseGeometry("0",&geometry_info); |
| 1835 | else |
| 1836 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1837 | draw_info->kerning=geometry_info.rho; |
| 1838 | break; |
| 1839 | } |
| 1840 | break; |
| 1841 | } |
| 1842 | case 'l': |
| 1843 | { |
| 1844 | if (LocaleCompare("lat",option+1) == 0) |
| 1845 | { |
| 1846 | /* |
| 1847 | Local adaptive threshold image. |
| 1848 | */ |
| 1849 | (void) SyncImageSettings(mogrify_info,*image); |
| 1850 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1851 | if ((flags & PercentValue) != 0) |
| 1852 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 1853 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
| 1854 | geometry_info.rho,(size_t) geometry_info.sigma,(ssize_t) |
| 1855 | geometry_info.xi,exception); |
| 1856 | break; |
| 1857 | } |
| 1858 | if (LocaleCompare("level",option+1) == 0) |
| 1859 | { |
| 1860 | MagickRealType |
| 1861 | black_point, |
| 1862 | gamma, |
| 1863 | white_point; |
| 1864 | |
| 1865 | MagickStatusType |
| 1866 | flags; |
| 1867 | |
| 1868 | /* |
| 1869 | Parse levels. |
| 1870 | */ |
| 1871 | (void) SyncImageSettings(mogrify_info,*image); |
| 1872 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1873 | black_point=geometry_info.rho; |
| 1874 | white_point=(MagickRealType) QuantumRange; |
| 1875 | if ((flags & SigmaValue) != 0) |
| 1876 | white_point=geometry_info.sigma; |
| 1877 | gamma=1.0; |
| 1878 | if ((flags & XiValue) != 0) |
| 1879 | gamma=geometry_info.xi; |
| 1880 | if ((flags & PercentValue) != 0) |
| 1881 | { |
| 1882 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 1883 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 1884 | } |
| 1885 | if ((flags & SigmaValue) == 0) |
| 1886 | white_point=(MagickRealType) QuantumRange-black_point; |
| 1887 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1888 | (void) LevelizeImage(*image,black_point,white_point,gamma); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1889 | else |
cristy | f89cb1d | 2011-07-07 01:24:37 +0000 | [diff] [blame] | 1890 | (void) LevelImage(*image,black_point,white_point,gamma); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1891 | InheritException(exception,&(*image)->exception); |
| 1892 | break; |
| 1893 | } |
| 1894 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1895 | { |
| 1896 | char |
| 1897 | token[MaxTextExtent]; |
| 1898 | |
| 1899 | const char |
| 1900 | *p; |
| 1901 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1902 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1903 | black_point, |
| 1904 | white_point; |
| 1905 | |
| 1906 | p=(const char *) argv[i+1]; |
| 1907 | GetMagickToken(p,&p,token); /* get black point color */ |
| 1908 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1909 | (void) QueryMagickColor(token,&black_point,exception); |
| 1910 | else |
| 1911 | (void) QueryMagickColor("#000000",&black_point,exception); |
| 1912 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1913 | GetMagickToken(p,&p,token); |
| 1914 | if (*token == '\0') |
| 1915 | white_point=black_point; /* set everything to that color */ |
| 1916 | else |
| 1917 | { |
| 1918 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 1919 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 1920 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1921 | (void) QueryMagickColor(token,&white_point,exception); |
| 1922 | else |
| 1923 | (void) QueryMagickColor("#ffffff",&white_point,exception); |
| 1924 | } |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 1925 | (void) LevelImageColors(*image,&black_point,&white_point, |
| 1926 | *option == '+' ? MagickTrue : MagickFalse); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1927 | break; |
| 1928 | } |
| 1929 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 1930 | { |
| 1931 | double |
| 1932 | black_point, |
| 1933 | white_point; |
| 1934 | |
| 1935 | MagickStatusType |
| 1936 | flags; |
| 1937 | |
| 1938 | (void) SyncImageSettings(mogrify_info,*image); |
| 1939 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1940 | black_point=geometry_info.rho; |
| 1941 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 1942 | if ((flags & SigmaValue) != 0) |
| 1943 | white_point=geometry_info.sigma; |
| 1944 | if ((flags & PercentValue) != 0) |
| 1945 | { |
| 1946 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1947 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1948 | } |
| 1949 | if ((flags & SigmaValue) == 0) |
| 1950 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1951 | black_point; |
| 1952 | (void) LinearStretchImage(*image,black_point,white_point); |
| 1953 | InheritException(exception,&(*image)->exception); |
| 1954 | break; |
| 1955 | } |
| 1956 | if (LocaleCompare("linewidth",option+1) == 0) |
| 1957 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1958 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 1959 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1960 | break; |
| 1961 | } |
| 1962 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 1963 | { |
| 1964 | /* |
| 1965 | Liquid rescale image. |
| 1966 | */ |
| 1967 | (void) SyncImageSettings(mogrify_info,*image); |
| 1968 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1969 | if ((flags & XValue) == 0) |
| 1970 | geometry.x=1; |
| 1971 | if ((flags & YValue) == 0) |
| 1972 | geometry.y=0; |
| 1973 | mogrify_image=LiquidRescaleImage(*image,geometry.width, |
| 1974 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 1975 | break; |
| 1976 | } |
| 1977 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 1978 | { |
| 1979 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1980 | break; |
| 1981 | } |
| 1982 | break; |
| 1983 | } |
| 1984 | case 'm': |
| 1985 | { |
| 1986 | if (LocaleCompare("map",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1987 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1988 | Image |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1989 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1990 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1991 | /* |
| 1992 | Transform image colors to match this set of colors. |
| 1993 | */ |
| 1994 | (void) SyncImageSettings(mogrify_info,*image); |
| 1995 | if (*option == '+') |
| 1996 | break; |
| 1997 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1998 | if (remap_image == (Image *) NULL) |
| 1999 | break; |
| 2000 | (void) RemapImage(quantize_info,*image,remap_image); |
| 2001 | InheritException(exception,&(*image)->exception); |
| 2002 | remap_image=DestroyImage(remap_image); |
| 2003 | break; |
| 2004 | } |
| 2005 | if (LocaleCompare("mask",option+1) == 0) |
| 2006 | { |
| 2007 | Image |
| 2008 | *mask; |
| 2009 | |
| 2010 | (void) SyncImageSettings(mogrify_info,*image); |
| 2011 | if (*option == '+') |
| 2012 | { |
| 2013 | /* |
| 2014 | Remove a mask. |
| 2015 | */ |
| 2016 | (void) SetImageMask(*image,(Image *) NULL); |
| 2017 | InheritException(exception,&(*image)->exception); |
| 2018 | break; |
| 2019 | } |
| 2020 | /* |
| 2021 | Set the image mask. |
| 2022 | */ |
| 2023 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2024 | if (mask == (Image *) NULL) |
| 2025 | break; |
| 2026 | (void) SetImageMask(*image,mask); |
| 2027 | mask=DestroyImage(mask); |
| 2028 | InheritException(exception,&(*image)->exception); |
| 2029 | break; |
| 2030 | } |
| 2031 | if (LocaleCompare("matte",option+1) == 0) |
| 2032 | { |
| 2033 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
| 2034 | SetAlphaChannel : DeactivateAlphaChannel ); |
| 2035 | InheritException(exception,&(*image)->exception); |
| 2036 | break; |
| 2037 | } |
| 2038 | if (LocaleCompare("median",option+1) == 0) |
| 2039 | { |
| 2040 | /* |
| 2041 | Median filter image. |
| 2042 | */ |
| 2043 | (void) SyncImageSettings(mogrify_info,*image); |
| 2044 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2045 | mogrify_image=StatisticImageChannel(*image,channel,MedianStatistic, |
| 2046 | (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception); |
| 2047 | break; |
| 2048 | } |
| 2049 | if (LocaleCompare("mode",option+1) == 0) |
| 2050 | { |
| 2051 | /* |
| 2052 | Mode image. |
| 2053 | */ |
| 2054 | (void) SyncImageSettings(mogrify_info,*image); |
| 2055 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2056 | mogrify_image=StatisticImageChannel(*image,channel,ModeStatistic, |
| 2057 | (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception); |
| 2058 | break; |
| 2059 | } |
| 2060 | if (LocaleCompare("modulate",option+1) == 0) |
| 2061 | { |
| 2062 | (void) SyncImageSettings(mogrify_info,*image); |
| 2063 | (void) ModulateImage(*image,argv[i+1]); |
| 2064 | InheritException(exception,&(*image)->exception); |
| 2065 | break; |
| 2066 | } |
| 2067 | if (LocaleCompare("monitor",option+1) == 0) |
| 2068 | { |
| 2069 | if (*option == '+') |
| 2070 | { |
| 2071 | (void) SetImageProgressMonitor(*image, |
| 2072 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2073 | break; |
| 2074 | } |
| 2075 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2076 | (void *) NULL); |
| 2077 | break; |
| 2078 | } |
| 2079 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2080 | { |
| 2081 | (void) SyncImageSettings(mogrify_info,*image); |
| 2082 | (void) SetImageType(*image,BilevelType); |
| 2083 | InheritException(exception,&(*image)->exception); |
| 2084 | break; |
| 2085 | } |
| 2086 | if (LocaleCompare("morphology",option+1) == 0) |
| 2087 | { |
| 2088 | char |
| 2089 | token[MaxTextExtent]; |
| 2090 | |
| 2091 | const char |
| 2092 | *p; |
| 2093 | |
| 2094 | KernelInfo |
| 2095 | *kernel; |
| 2096 | |
| 2097 | MorphologyMethod |
| 2098 | method; |
| 2099 | |
| 2100 | ssize_t |
| 2101 | iterations; |
| 2102 | |
| 2103 | /* |
| 2104 | Morphological Image Operation |
| 2105 | */ |
| 2106 | (void) SyncImageSettings(mogrify_info,*image); |
| 2107 | p=argv[i+1]; |
| 2108 | GetMagickToken(p,&p,token); |
| 2109 | method=(MorphologyMethod) ParseCommandOption(MagickMorphologyOptions, |
| 2110 | MagickFalse,token); |
| 2111 | iterations=1L; |
| 2112 | GetMagickToken(p,&p,token); |
| 2113 | if ((*p == ':') || (*p == ',')) |
| 2114 | GetMagickToken(p,&p,token); |
| 2115 | if ((*p != '\0')) |
| 2116 | iterations=(ssize_t) StringToLong(p); |
| 2117 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2118 | if (kernel == (KernelInfo *) NULL) |
| 2119 | { |
| 2120 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2121 | OptionError,"UnabletoParseKernel","morphology"); |
| 2122 | status=MagickFalse; |
| 2123 | break; |
| 2124 | } |
| 2125 | mogrify_image=MorphologyImageChannel(*image,channel,method, |
| 2126 | iterations,kernel,exception); |
| 2127 | kernel=DestroyKernelInfo(kernel); |
| 2128 | break; |
| 2129 | } |
| 2130 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2131 | { |
| 2132 | /* |
| 2133 | Motion blur image. |
| 2134 | */ |
| 2135 | (void) SyncImageSettings(mogrify_info,*image); |
| 2136 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2137 | if ((flags & SigmaValue) == 0) |
| 2138 | geometry_info.sigma=1.0; |
| 2139 | mogrify_image=MotionBlurImageChannel(*image,channel, |
| 2140 | geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception); |
| 2141 | break; |
| 2142 | } |
| 2143 | break; |
| 2144 | } |
| 2145 | case 'n': |
| 2146 | { |
| 2147 | if (LocaleCompare("negate",option+1) == 0) |
| 2148 | { |
| 2149 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2150 | (void) NegateImage(*image,*option == '+' ? MagickTrue : |
| 2151 | MagickFalse); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2152 | InheritException(exception,&(*image)->exception); |
| 2153 | break; |
| 2154 | } |
| 2155 | if (LocaleCompare("noise",option+1) == 0) |
| 2156 | { |
| 2157 | (void) SyncImageSettings(mogrify_info,*image); |
| 2158 | if (*option == '-') |
| 2159 | { |
| 2160 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2161 | mogrify_image=StatisticImageChannel(*image,channel, |
| 2162 | NonpeakStatistic,(size_t) geometry_info.rho,(size_t) |
| 2163 | geometry_info.rho,exception); |
| 2164 | } |
| 2165 | else |
| 2166 | { |
| 2167 | NoiseType |
| 2168 | noise; |
| 2169 | |
| 2170 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
| 2171 | MagickFalse,argv[i+1]); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 2172 | mogrify_image=AddNoiseImage(*image,noise,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2173 | } |
| 2174 | break; |
| 2175 | } |
| 2176 | if (LocaleCompare("normalize",option+1) == 0) |
| 2177 | { |
| 2178 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2179 | (void) NormalizeImage(*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2180 | InheritException(exception,&(*image)->exception); |
| 2181 | break; |
| 2182 | } |
| 2183 | break; |
| 2184 | } |
| 2185 | case 'o': |
| 2186 | { |
| 2187 | if (LocaleCompare("opaque",option+1) == 0) |
| 2188 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2189 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2190 | target; |
| 2191 | |
| 2192 | (void) SyncImageSettings(mogrify_info,*image); |
| 2193 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2194 | (void) OpaquePaintImageChannel(*image,channel,&target,&fill, |
| 2195 | *option == '-' ? MagickFalse : MagickTrue); |
| 2196 | break; |
| 2197 | } |
| 2198 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2199 | { |
| 2200 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 1302067 | 2011-07-08 02:33:26 +0000 | [diff] [blame^] | 2201 | (void) OrderedPosterizeImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2202 | break; |
| 2203 | } |
| 2204 | break; |
| 2205 | } |
| 2206 | case 'p': |
| 2207 | { |
| 2208 | if (LocaleCompare("paint",option+1) == 0) |
| 2209 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2210 | (void) SyncImageSettings(mogrify_info,*image); |
| 2211 | (void) ParseGeometry(argv[i+1],&geometry_info); |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 2212 | mogrify_image=OilPaintImage(*image,geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2213 | break; |
| 2214 | } |
| 2215 | if (LocaleCompare("pen",option+1) == 0) |
| 2216 | { |
| 2217 | if (*option == '+') |
| 2218 | { |
| 2219 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 2220 | break; |
| 2221 | } |
| 2222 | (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception); |
| 2223 | break; |
| 2224 | } |
| 2225 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2226 | { |
| 2227 | if (*option == '+') |
| 2228 | (void) ParseGeometry("12",&geometry_info); |
| 2229 | else |
| 2230 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2231 | draw_info->pointsize=geometry_info.rho; |
| 2232 | break; |
| 2233 | } |
| 2234 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2235 | { |
| 2236 | double |
| 2237 | angle; |
| 2238 | |
| 2239 | RandomInfo |
| 2240 | *random_info; |
| 2241 | |
| 2242 | /* |
| 2243 | Simulate a Polaroid picture. |
| 2244 | */ |
| 2245 | (void) SyncImageSettings(mogrify_info,*image); |
| 2246 | random_info=AcquireRandomInfo(); |
| 2247 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2248 | random_info=DestroyRandomInfo(random_info); |
| 2249 | if (*option == '-') |
| 2250 | { |
| 2251 | SetGeometryInfo(&geometry_info); |
| 2252 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2253 | angle=geometry_info.rho; |
| 2254 | } |
| 2255 | mogrify_image=PolaroidImage(*image,draw_info,angle,exception); |
| 2256 | break; |
| 2257 | } |
| 2258 | if (LocaleCompare("posterize",option+1) == 0) |
| 2259 | { |
| 2260 | /* |
| 2261 | Posterize image. |
| 2262 | */ |
| 2263 | (void) SyncImageSettings(mogrify_info,*image); |
| 2264 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
| 2265 | quantize_info->dither); |
| 2266 | InheritException(exception,&(*image)->exception); |
| 2267 | break; |
| 2268 | } |
| 2269 | if (LocaleCompare("preview",option+1) == 0) |
| 2270 | { |
| 2271 | PreviewType |
| 2272 | preview_type; |
| 2273 | |
| 2274 | /* |
| 2275 | Preview image. |
| 2276 | */ |
| 2277 | (void) SyncImageSettings(mogrify_info,*image); |
| 2278 | if (*option == '+') |
| 2279 | preview_type=UndefinedPreview; |
| 2280 | else |
| 2281 | preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions, |
| 2282 | MagickFalse,argv[i+1]); |
| 2283 | mogrify_image=PreviewImage(*image,preview_type,exception); |
| 2284 | break; |
| 2285 | } |
| 2286 | if (LocaleCompare("profile",option+1) == 0) |
| 2287 | { |
| 2288 | const char |
| 2289 | *name; |
| 2290 | |
| 2291 | const StringInfo |
| 2292 | *profile; |
| 2293 | |
| 2294 | Image |
| 2295 | *profile_image; |
| 2296 | |
| 2297 | ImageInfo |
| 2298 | *profile_info; |
| 2299 | |
| 2300 | (void) SyncImageSettings(mogrify_info,*image); |
| 2301 | if (*option == '+') |
| 2302 | { |
| 2303 | /* |
| 2304 | Remove a profile from the image. |
| 2305 | */ |
| 2306 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
| 2307 | NULL,0,MagickTrue); |
| 2308 | InheritException(exception,&(*image)->exception); |
| 2309 | break; |
| 2310 | } |
| 2311 | /* |
| 2312 | Associate a profile with the image. |
| 2313 | */ |
| 2314 | profile_info=CloneImageInfo(mogrify_info); |
| 2315 | profile=GetImageProfile(*image,"iptc"); |
| 2316 | if (profile != (StringInfo *) NULL) |
| 2317 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2318 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2319 | profile_info=DestroyImageInfo(profile_info); |
| 2320 | if (profile_image == (Image *) NULL) |
| 2321 | { |
| 2322 | StringInfo |
| 2323 | *profile; |
| 2324 | |
| 2325 | profile_info=CloneImageInfo(mogrify_info); |
| 2326 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2327 | MaxTextExtent); |
| 2328 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
| 2329 | if (profile != (StringInfo *) NULL) |
| 2330 | { |
| 2331 | (void) ProfileImage(*image,profile_info->magick, |
| 2332 | GetStringInfoDatum(profile),(size_t) |
| 2333 | GetStringInfoLength(profile),MagickFalse); |
| 2334 | profile=DestroyStringInfo(profile); |
| 2335 | } |
| 2336 | profile_info=DestroyImageInfo(profile_info); |
| 2337 | break; |
| 2338 | } |
| 2339 | ResetImageProfileIterator(profile_image); |
| 2340 | name=GetNextImageProfile(profile_image); |
| 2341 | while (name != (const char *) NULL) |
| 2342 | { |
| 2343 | profile=GetImageProfile(profile_image,name); |
| 2344 | if (profile != (StringInfo *) NULL) |
| 2345 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
| 2346 | (size_t) GetStringInfoLength(profile),MagickFalse); |
| 2347 | name=GetNextImageProfile(profile_image); |
| 2348 | } |
| 2349 | profile_image=DestroyImage(profile_image); |
| 2350 | break; |
| 2351 | } |
| 2352 | break; |
| 2353 | } |
| 2354 | case 'q': |
| 2355 | { |
| 2356 | if (LocaleCompare("quantize",option+1) == 0) |
| 2357 | { |
| 2358 | if (*option == '+') |
| 2359 | { |
| 2360 | quantize_info->colorspace=UndefinedColorspace; |
| 2361 | break; |
| 2362 | } |
| 2363 | quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
| 2364 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2365 | break; |
| 2366 | } |
| 2367 | break; |
| 2368 | } |
| 2369 | case 'r': |
| 2370 | { |
| 2371 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2372 | { |
| 2373 | /* |
| 2374 | Radial blur image. |
| 2375 | */ |
| 2376 | (void) SyncImageSettings(mogrify_info,*image); |
| 2377 | mogrify_image=RadialBlurImageChannel(*image,channel, |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 2378 | InterpretLocaleValue(argv[i+1],(char **) NULL),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2379 | break; |
| 2380 | } |
| 2381 | if (LocaleCompare("raise",option+1) == 0) |
| 2382 | { |
| 2383 | /* |
| 2384 | Surround image with a raise of solid color. |
| 2385 | */ |
| 2386 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2387 | if ((flags & SigmaValue) == 0) |
| 2388 | geometry.height=geometry.width; |
| 2389 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
| 2390 | MagickFalse); |
| 2391 | InheritException(exception,&(*image)->exception); |
| 2392 | break; |
| 2393 | } |
| 2394 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2395 | { |
| 2396 | /* |
| 2397 | Threshold image. |
| 2398 | */ |
| 2399 | (void) SyncImageSettings(mogrify_info,*image); |
| 2400 | (void) RandomThresholdImageChannel(*image,channel,argv[i+1], |
| 2401 | exception); |
| 2402 | break; |
| 2403 | } |
| 2404 | if (LocaleCompare("recolor",option+1) == 0) |
| 2405 | { |
| 2406 | KernelInfo |
| 2407 | *kernel; |
| 2408 | |
| 2409 | (void) SyncImageSettings(mogrify_info,*image); |
| 2410 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2411 | if (kernel == (KernelInfo *) NULL) |
| 2412 | break; |
| 2413 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 2414 | kernel=DestroyKernelInfo(kernel); |
| 2415 | break; |
| 2416 | } |
| 2417 | if (LocaleCompare("region",option+1) == 0) |
| 2418 | { |
| 2419 | (void) SyncImageSettings(mogrify_info,*image); |
| 2420 | if (region_image != (Image *) NULL) |
| 2421 | { |
| 2422 | /* |
| 2423 | Composite region. |
| 2424 | */ |
| 2425 | (void) CompositeImage(region_image,region_image->matte != |
cristy | ab01585 | 2011-07-06 01:03:32 +0000 | [diff] [blame] | 2426 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 2427 | region_geometry.x,region_geometry.y); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2428 | InheritException(exception,®ion_image->exception); |
| 2429 | *image=DestroyImage(*image); |
| 2430 | *image=region_image; |
| 2431 | region_image = (Image *) NULL; |
| 2432 | } |
| 2433 | if (*option == '+') |
| 2434 | break; |
| 2435 | /* |
| 2436 | Apply transformations to a selected region of the image. |
| 2437 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2438 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2439 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2440 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2441 | if (mogrify_image == (Image *) NULL) |
| 2442 | break; |
| 2443 | region_image=(*image); |
| 2444 | *image=mogrify_image; |
| 2445 | mogrify_image=(Image *) NULL; |
| 2446 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2447 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2448 | if (LocaleCompare("render",option+1) == 0) |
| 2449 | { |
| 2450 | (void) SyncImageSettings(mogrify_info,*image); |
| 2451 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2452 | break; |
| 2453 | } |
| 2454 | if (LocaleCompare("remap",option+1) == 0) |
| 2455 | { |
| 2456 | Image |
| 2457 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2458 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2459 | /* |
| 2460 | Transform image colors to match this set of colors. |
| 2461 | */ |
| 2462 | (void) SyncImageSettings(mogrify_info,*image); |
| 2463 | if (*option == '+') |
| 2464 | break; |
| 2465 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2466 | if (remap_image == (Image *) NULL) |
| 2467 | break; |
| 2468 | (void) RemapImage(quantize_info,*image,remap_image); |
| 2469 | InheritException(exception,&(*image)->exception); |
| 2470 | remap_image=DestroyImage(remap_image); |
| 2471 | break; |
| 2472 | } |
| 2473 | if (LocaleCompare("repage",option+1) == 0) |
| 2474 | { |
| 2475 | if (*option == '+') |
| 2476 | { |
| 2477 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2478 | break; |
| 2479 | } |
| 2480 | (void) ResetImagePage(*image,argv[i+1]); |
| 2481 | InheritException(exception,&(*image)->exception); |
| 2482 | break; |
| 2483 | } |
| 2484 | if (LocaleCompare("resample",option+1) == 0) |
| 2485 | { |
| 2486 | /* |
| 2487 | Resample image. |
| 2488 | */ |
| 2489 | (void) SyncImageSettings(mogrify_info,*image); |
| 2490 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2491 | if ((flags & SigmaValue) == 0) |
| 2492 | geometry_info.sigma=geometry_info.rho; |
| 2493 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
| 2494 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2495 | break; |
| 2496 | } |
| 2497 | if (LocaleCompare("resize",option+1) == 0) |
| 2498 | { |
| 2499 | /* |
| 2500 | Resize image. |
| 2501 | */ |
| 2502 | (void) SyncImageSettings(mogrify_info,*image); |
| 2503 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2504 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2505 | (*image)->filter,(*image)->blur,exception); |
| 2506 | break; |
| 2507 | } |
| 2508 | if (LocaleCompare("roll",option+1) == 0) |
| 2509 | { |
| 2510 | /* |
| 2511 | Roll image. |
| 2512 | */ |
| 2513 | (void) SyncImageSettings(mogrify_info,*image); |
| 2514 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2515 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2516 | break; |
| 2517 | } |
| 2518 | if (LocaleCompare("rotate",option+1) == 0) |
| 2519 | { |
| 2520 | char |
| 2521 | *geometry; |
| 2522 | |
| 2523 | /* |
| 2524 | Check for conditional image rotation. |
| 2525 | */ |
| 2526 | (void) SyncImageSettings(mogrify_info,*image); |
| 2527 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2528 | if ((*image)->columns <= (*image)->rows) |
| 2529 | break; |
| 2530 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2531 | if ((*image)->columns >= (*image)->rows) |
| 2532 | break; |
| 2533 | /* |
| 2534 | Rotate image. |
| 2535 | */ |
| 2536 | geometry=ConstantString(argv[i+1]); |
| 2537 | (void) SubstituteString(&geometry,">",""); |
| 2538 | (void) SubstituteString(&geometry,"<",""); |
| 2539 | (void) ParseGeometry(geometry,&geometry_info); |
| 2540 | geometry=DestroyString(geometry); |
| 2541 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
| 2542 | break; |
| 2543 | } |
| 2544 | break; |
| 2545 | } |
| 2546 | case 's': |
| 2547 | { |
| 2548 | if (LocaleCompare("sample",option+1) == 0) |
| 2549 | { |
| 2550 | /* |
| 2551 | Sample image with pixel replication. |
| 2552 | */ |
| 2553 | (void) SyncImageSettings(mogrify_info,*image); |
| 2554 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2555 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
| 2556 | exception); |
| 2557 | break; |
| 2558 | } |
| 2559 | if (LocaleCompare("scale",option+1) == 0) |
| 2560 | { |
| 2561 | /* |
| 2562 | Resize image. |
| 2563 | */ |
| 2564 | (void) SyncImageSettings(mogrify_info,*image); |
| 2565 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2566 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2567 | exception); |
| 2568 | break; |
| 2569 | } |
| 2570 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2571 | { |
| 2572 | /* |
| 2573 | Selectively blur pixels within a contrast threshold. |
| 2574 | */ |
| 2575 | (void) SyncImageSettings(mogrify_info,*image); |
| 2576 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2577 | if ((flags & PercentValue) != 0) |
| 2578 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 2579 | mogrify_image=SelectiveBlurImageChannel(*image,channel, |
| 2580 | geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception); |
| 2581 | break; |
| 2582 | } |
| 2583 | if (LocaleCompare("separate",option+1) == 0) |
| 2584 | { |
| 2585 | /* |
| 2586 | Break channels into separate images. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2587 | */ |
| 2588 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 2589 | mogrify_image=SeparateImages(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2590 | break; |
| 2591 | } |
| 2592 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2593 | { |
| 2594 | double |
| 2595 | threshold; |
| 2596 | |
| 2597 | /* |
| 2598 | Sepia-tone image. |
| 2599 | */ |
| 2600 | (void) SyncImageSettings(mogrify_info,*image); |
| 2601 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2602 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
| 2603 | break; |
| 2604 | } |
| 2605 | if (LocaleCompare("segment",option+1) == 0) |
| 2606 | { |
| 2607 | /* |
| 2608 | Segment image. |
| 2609 | */ |
| 2610 | (void) SyncImageSettings(mogrify_info,*image); |
| 2611 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2612 | if ((flags & SigmaValue) == 0) |
| 2613 | geometry_info.sigma=1.0; |
| 2614 | (void) SegmentImage(*image,(*image)->colorspace, |
| 2615 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma); |
| 2616 | InheritException(exception,&(*image)->exception); |
| 2617 | break; |
| 2618 | } |
| 2619 | if (LocaleCompare("set",option+1) == 0) |
| 2620 | { |
| 2621 | char |
| 2622 | *value; |
| 2623 | |
| 2624 | /* |
| 2625 | Set image option. |
| 2626 | */ |
| 2627 | if (*option == '+') |
| 2628 | { |
| 2629 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2630 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2631 | else |
| 2632 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2633 | { |
| 2634 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
| 2635 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2636 | } |
| 2637 | else |
| 2638 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2639 | break; |
| 2640 | } |
| 2641 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 2642 | if (value == (char *) NULL) |
| 2643 | break; |
| 2644 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2645 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2646 | exception); |
| 2647 | else |
| 2648 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2649 | { |
| 2650 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
| 2651 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
| 2652 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2653 | } |
| 2654 | else |
| 2655 | (void) SetImageProperty(*image,argv[i+1],value); |
| 2656 | value=DestroyString(value); |
| 2657 | break; |
| 2658 | } |
| 2659 | if (LocaleCompare("shade",option+1) == 0) |
| 2660 | { |
| 2661 | /* |
| 2662 | Shade image. |
| 2663 | */ |
| 2664 | (void) SyncImageSettings(mogrify_info,*image); |
| 2665 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2666 | if ((flags & SigmaValue) == 0) |
| 2667 | geometry_info.sigma=1.0; |
| 2668 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2669 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2670 | break; |
| 2671 | } |
| 2672 | if (LocaleCompare("shadow",option+1) == 0) |
| 2673 | { |
| 2674 | /* |
| 2675 | Shadow image. |
| 2676 | */ |
| 2677 | (void) SyncImageSettings(mogrify_info,*image); |
| 2678 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2679 | if ((flags & SigmaValue) == 0) |
| 2680 | geometry_info.sigma=1.0; |
| 2681 | if ((flags & XiValue) == 0) |
| 2682 | geometry_info.xi=4.0; |
| 2683 | if ((flags & PsiValue) == 0) |
| 2684 | geometry_info.psi=4.0; |
| 2685 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
| 2686 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 2687 | ceil(geometry_info.psi-0.5),exception); |
| 2688 | break; |
| 2689 | } |
| 2690 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2691 | { |
| 2692 | /* |
| 2693 | Sharpen image. |
| 2694 | */ |
| 2695 | (void) SyncImageSettings(mogrify_info,*image); |
| 2696 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2697 | if ((flags & SigmaValue) == 0) |
| 2698 | geometry_info.sigma=1.0; |
| 2699 | mogrify_image=SharpenImageChannel(*image,channel,geometry_info.rho, |
| 2700 | geometry_info.sigma,exception); |
| 2701 | break; |
| 2702 | } |
| 2703 | if (LocaleCompare("shave",option+1) == 0) |
| 2704 | { |
| 2705 | /* |
| 2706 | Shave the image edges. |
| 2707 | */ |
| 2708 | (void) SyncImageSettings(mogrify_info,*image); |
| 2709 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2710 | mogrify_image=ShaveImage(*image,&geometry,exception); |
| 2711 | break; |
| 2712 | } |
| 2713 | if (LocaleCompare("shear",option+1) == 0) |
| 2714 | { |
| 2715 | /* |
| 2716 | Shear image. |
| 2717 | */ |
| 2718 | (void) SyncImageSettings(mogrify_info,*image); |
| 2719 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2720 | if ((flags & SigmaValue) == 0) |
| 2721 | geometry_info.sigma=geometry_info.rho; |
| 2722 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2723 | geometry_info.sigma,exception); |
| 2724 | break; |
| 2725 | } |
| 2726 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2727 | { |
| 2728 | /* |
| 2729 | Sigmoidal non-linearity contrast control. |
| 2730 | */ |
| 2731 | (void) SyncImageSettings(mogrify_info,*image); |
| 2732 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2733 | if ((flags & SigmaValue) == 0) |
| 2734 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 2735 | if ((flags & PercentValue) != 0) |
| 2736 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2737 | 100.0; |
cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 2738 | (void) SigmoidalContrastImage(*image,(*option == '-') ? |
| 2739 | MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2740 | InheritException(exception,&(*image)->exception); |
| 2741 | break; |
| 2742 | } |
| 2743 | if (LocaleCompare("sketch",option+1) == 0) |
| 2744 | { |
| 2745 | /* |
| 2746 | Sketch image. |
| 2747 | */ |
| 2748 | (void) SyncImageSettings(mogrify_info,*image); |
| 2749 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2750 | if ((flags & SigmaValue) == 0) |
| 2751 | geometry_info.sigma=1.0; |
| 2752 | mogrify_image=SketchImage(*image,geometry_info.rho, |
| 2753 | geometry_info.sigma,geometry_info.xi,exception); |
| 2754 | break; |
| 2755 | } |
| 2756 | if (LocaleCompare("solarize",option+1) == 0) |
| 2757 | { |
| 2758 | double |
| 2759 | threshold; |
| 2760 | |
| 2761 | (void) SyncImageSettings(mogrify_info,*image); |
| 2762 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2763 | (void) SolarizeImage(*image,threshold); |
| 2764 | InheritException(exception,&(*image)->exception); |
| 2765 | break; |
| 2766 | } |
| 2767 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2768 | { |
| 2769 | SparseColorMethod |
| 2770 | method; |
| 2771 | |
| 2772 | char |
| 2773 | *arguments; |
| 2774 | |
| 2775 | /* |
| 2776 | Sparse Color Interpolated Gradient |
| 2777 | */ |
| 2778 | (void) SyncImageSettings(mogrify_info,*image); |
| 2779 | method=(SparseColorMethod) ParseCommandOption( |
| 2780 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
| 2781 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 2782 | InheritException(exception,&(*image)->exception); |
| 2783 | if (arguments == (char *) NULL) |
| 2784 | break; |
| 2785 | mogrify_image=SparseColorOption(*image,channel,method,arguments, |
| 2786 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2787 | arguments=DestroyString(arguments); |
| 2788 | break; |
| 2789 | } |
| 2790 | if (LocaleCompare("splice",option+1) == 0) |
| 2791 | { |
| 2792 | /* |
| 2793 | Splice a solid color into the image. |
| 2794 | */ |
| 2795 | (void) SyncImageSettings(mogrify_info,*image); |
| 2796 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 2797 | mogrify_image=SpliceImage(*image,&geometry,exception); |
| 2798 | break; |
| 2799 | } |
| 2800 | if (LocaleCompare("spread",option+1) == 0) |
| 2801 | { |
| 2802 | /* |
| 2803 | Spread an image. |
| 2804 | */ |
| 2805 | (void) SyncImageSettings(mogrify_info,*image); |
| 2806 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2807 | mogrify_image=SpreadImage(*image,geometry_info.rho,exception); |
| 2808 | break; |
| 2809 | } |
| 2810 | if (LocaleCompare("statistic",option+1) == 0) |
| 2811 | { |
| 2812 | StatisticType |
| 2813 | type; |
| 2814 | |
| 2815 | (void) SyncImageSettings(mogrify_info,*image); |
| 2816 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
| 2817 | MagickFalse,argv[i+1]); |
| 2818 | (void) ParseGeometry(argv[i+2],&geometry_info); |
| 2819 | mogrify_image=StatisticImageChannel(*image,channel,type,(size_t) |
| 2820 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
| 2821 | break; |
| 2822 | } |
| 2823 | if (LocaleCompare("stretch",option+1) == 0) |
| 2824 | { |
| 2825 | if (*option == '+') |
| 2826 | { |
| 2827 | draw_info->stretch=UndefinedStretch; |
| 2828 | break; |
| 2829 | } |
| 2830 | draw_info->stretch=(StretchType) ParseCommandOption( |
| 2831 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2832 | break; |
| 2833 | } |
| 2834 | if (LocaleCompare("strip",option+1) == 0) |
| 2835 | { |
| 2836 | /* |
| 2837 | Strip image of profiles and comments. |
| 2838 | */ |
| 2839 | (void) SyncImageSettings(mogrify_info,*image); |
| 2840 | (void) StripImage(*image); |
| 2841 | InheritException(exception,&(*image)->exception); |
| 2842 | break; |
| 2843 | } |
| 2844 | if (LocaleCompare("stroke",option+1) == 0) |
| 2845 | { |
| 2846 | ExceptionInfo |
| 2847 | *sans; |
| 2848 | |
| 2849 | if (*option == '+') |
| 2850 | { |
| 2851 | (void) QueryColorDatabase("none",&draw_info->stroke,exception); |
| 2852 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2853 | draw_info->stroke_pattern=DestroyImage( |
| 2854 | draw_info->stroke_pattern); |
| 2855 | break; |
| 2856 | } |
| 2857 | sans=AcquireExceptionInfo(); |
| 2858 | status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans); |
| 2859 | sans=DestroyExceptionInfo(sans); |
| 2860 | if (status == MagickFalse) |
| 2861 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2862 | exception); |
| 2863 | break; |
| 2864 | } |
| 2865 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2866 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 2867 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 2868 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2869 | break; |
| 2870 | } |
| 2871 | if (LocaleCompare("style",option+1) == 0) |
| 2872 | { |
| 2873 | if (*option == '+') |
| 2874 | { |
| 2875 | draw_info->style=UndefinedStyle; |
| 2876 | break; |
| 2877 | } |
| 2878 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 2879 | MagickFalse,argv[i+1]); |
| 2880 | break; |
| 2881 | } |
| 2882 | if (LocaleCompare("swirl",option+1) == 0) |
| 2883 | { |
| 2884 | /* |
| 2885 | Swirl image. |
| 2886 | */ |
| 2887 | (void) SyncImageSettings(mogrify_info,*image); |
| 2888 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2889 | mogrify_image=SwirlImage(*image,geometry_info.rho,exception); |
| 2890 | break; |
| 2891 | } |
| 2892 | break; |
| 2893 | } |
| 2894 | case 't': |
| 2895 | { |
| 2896 | if (LocaleCompare("threshold",option+1) == 0) |
| 2897 | { |
| 2898 | double |
| 2899 | threshold; |
| 2900 | |
| 2901 | /* |
| 2902 | Threshold image. |
| 2903 | */ |
| 2904 | (void) SyncImageSettings(mogrify_info,*image); |
| 2905 | if (*option == '+') |
anthony | 247a86d | 2011-05-03 13:18:18 +0000 | [diff] [blame] | 2906 | threshold=(double) QuantumRange/2; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2907 | else |
| 2908 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2909 | (void) BilevelImageChannel(*image,channel,threshold); |
| 2910 | InheritException(exception,&(*image)->exception); |
| 2911 | break; |
| 2912 | } |
| 2913 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2914 | { |
| 2915 | /* |
| 2916 | Thumbnail image. |
| 2917 | */ |
| 2918 | (void) SyncImageSettings(mogrify_info,*image); |
| 2919 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2920 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2921 | exception); |
| 2922 | break; |
| 2923 | } |
| 2924 | if (LocaleCompare("tile",option+1) == 0) |
| 2925 | { |
| 2926 | if (*option == '+') |
| 2927 | { |
| 2928 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2929 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2930 | break; |
| 2931 | } |
| 2932 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2933 | exception); |
| 2934 | break; |
| 2935 | } |
| 2936 | if (LocaleCompare("tint",option+1) == 0) |
| 2937 | { |
| 2938 | /* |
| 2939 | Tint the image. |
| 2940 | */ |
| 2941 | (void) SyncImageSettings(mogrify_info,*image); |
| 2942 | mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception); |
| 2943 | break; |
| 2944 | } |
| 2945 | if (LocaleCompare("transform",option+1) == 0) |
| 2946 | { |
| 2947 | /* |
| 2948 | Affine transform image. |
| 2949 | */ |
| 2950 | (void) SyncImageSettings(mogrify_info,*image); |
| 2951 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
| 2952 | exception); |
| 2953 | break; |
| 2954 | } |
| 2955 | if (LocaleCompare("transparent",option+1) == 0) |
| 2956 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2957 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2958 | target; |
| 2959 | |
| 2960 | (void) SyncImageSettings(mogrify_info,*image); |
| 2961 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2962 | (void) TransparentPaintImage(*image,&target,(Quantum) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2963 | TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2964 | InheritException(exception,&(*image)->exception); |
| 2965 | break; |
| 2966 | } |
| 2967 | if (LocaleCompare("transpose",option+1) == 0) |
| 2968 | { |
| 2969 | /* |
| 2970 | Transpose image scanlines. |
| 2971 | */ |
| 2972 | (void) SyncImageSettings(mogrify_info,*image); |
| 2973 | mogrify_image=TransposeImage(*image,exception); |
| 2974 | break; |
| 2975 | } |
| 2976 | if (LocaleCompare("transverse",option+1) == 0) |
| 2977 | { |
| 2978 | /* |
| 2979 | Transverse image scanlines. |
| 2980 | */ |
| 2981 | (void) SyncImageSettings(mogrify_info,*image); |
| 2982 | mogrify_image=TransverseImage(*image,exception); |
| 2983 | break; |
| 2984 | } |
| 2985 | if (LocaleCompare("treedepth",option+1) == 0) |
| 2986 | { |
| 2987 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
| 2988 | break; |
| 2989 | } |
| 2990 | if (LocaleCompare("trim",option+1) == 0) |
| 2991 | { |
| 2992 | /* |
| 2993 | Trim image. |
| 2994 | */ |
| 2995 | (void) SyncImageSettings(mogrify_info,*image); |
| 2996 | mogrify_image=TrimImage(*image,exception); |
| 2997 | break; |
| 2998 | } |
| 2999 | if (LocaleCompare("type",option+1) == 0) |
| 3000 | { |
| 3001 | ImageType |
| 3002 | type; |
| 3003 | |
| 3004 | (void) SyncImageSettings(mogrify_info,*image); |
| 3005 | if (*option == '+') |
| 3006 | type=UndefinedType; |
| 3007 | else |
| 3008 | type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 3009 | argv[i+1]); |
| 3010 | (*image)->type=UndefinedType; |
| 3011 | (void) SetImageType(*image,type); |
| 3012 | InheritException(exception,&(*image)->exception); |
| 3013 | break; |
| 3014 | } |
| 3015 | break; |
| 3016 | } |
| 3017 | case 'u': |
| 3018 | { |
| 3019 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3020 | { |
| 3021 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 3022 | exception); |
| 3023 | break; |
| 3024 | } |
| 3025 | if (LocaleCompare("unique",option+1) == 0) |
| 3026 | { |
| 3027 | if (*option == '+') |
| 3028 | { |
| 3029 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
| 3030 | break; |
| 3031 | } |
| 3032 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
| 3033 | (void) SetImageArtifact(*image,"verbose","true"); |
| 3034 | break; |
| 3035 | } |
| 3036 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3037 | { |
| 3038 | /* |
| 3039 | Unique image colors. |
| 3040 | */ |
| 3041 | (void) SyncImageSettings(mogrify_info,*image); |
| 3042 | mogrify_image=UniqueImageColors(*image,exception); |
| 3043 | break; |
| 3044 | } |
| 3045 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3046 | { |
| 3047 | /* |
| 3048 | Unsharp mask image. |
| 3049 | */ |
| 3050 | (void) SyncImageSettings(mogrify_info,*image); |
| 3051 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3052 | if ((flags & SigmaValue) == 0) |
| 3053 | geometry_info.sigma=1.0; |
| 3054 | if ((flags & XiValue) == 0) |
| 3055 | geometry_info.xi=1.0; |
| 3056 | if ((flags & PsiValue) == 0) |
| 3057 | geometry_info.psi=0.05; |
| 3058 | mogrify_image=UnsharpMaskImageChannel(*image,channel, |
| 3059 | geometry_info.rho,geometry_info.sigma,geometry_info.xi, |
| 3060 | geometry_info.psi,exception); |
| 3061 | break; |
| 3062 | } |
| 3063 | break; |
| 3064 | } |
| 3065 | case 'v': |
| 3066 | { |
| 3067 | if (LocaleCompare("verbose",option+1) == 0) |
| 3068 | { |
| 3069 | (void) SetImageArtifact(*image,option+1, |
| 3070 | *option == '+' ? "false" : "true"); |
| 3071 | break; |
| 3072 | } |
| 3073 | if (LocaleCompare("vignette",option+1) == 0) |
| 3074 | { |
| 3075 | /* |
| 3076 | Vignette image. |
| 3077 | */ |
| 3078 | (void) SyncImageSettings(mogrify_info,*image); |
| 3079 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3080 | if ((flags & SigmaValue) == 0) |
| 3081 | geometry_info.sigma=1.0; |
| 3082 | if ((flags & XiValue) == 0) |
| 3083 | geometry_info.xi=0.1*(*image)->columns; |
| 3084 | if ((flags & PsiValue) == 0) |
| 3085 | geometry_info.psi=0.1*(*image)->rows; |
| 3086 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
| 3087 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3088 | ceil(geometry_info.psi-0.5),exception); |
| 3089 | break; |
| 3090 | } |
| 3091 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3092 | { |
| 3093 | if (*option == '+') |
| 3094 | { |
| 3095 | (void) SetImageVirtualPixelMethod(*image, |
| 3096 | UndefinedVirtualPixelMethod); |
| 3097 | break; |
| 3098 | } |
| 3099 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3100 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 3101 | argv[i+1])); |
| 3102 | break; |
| 3103 | } |
| 3104 | break; |
| 3105 | } |
| 3106 | case 'w': |
| 3107 | { |
| 3108 | if (LocaleCompare("wave",option+1) == 0) |
| 3109 | { |
| 3110 | /* |
| 3111 | Wave image. |
| 3112 | */ |
| 3113 | (void) SyncImageSettings(mogrify_info,*image); |
| 3114 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3115 | if ((flags & SigmaValue) == 0) |
| 3116 | geometry_info.sigma=1.0; |
| 3117 | mogrify_image=WaveImage(*image,geometry_info.rho, |
| 3118 | geometry_info.sigma,exception); |
| 3119 | break; |
| 3120 | } |
| 3121 | if (LocaleCompare("weight",option+1) == 0) |
| 3122 | { |
| 3123 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
| 3124 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3125 | draw_info->weight=0; |
| 3126 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3127 | draw_info->weight=700; |
| 3128 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3129 | if (draw_info->weight <= 800) |
| 3130 | draw_info->weight+=100; |
| 3131 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3132 | if (draw_info->weight >= 100) |
| 3133 | draw_info->weight-=100; |
| 3134 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3135 | draw_info->weight=400; |
| 3136 | break; |
| 3137 | } |
| 3138 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3139 | { |
| 3140 | /* |
| 3141 | White threshold image. |
| 3142 | */ |
| 3143 | (void) SyncImageSettings(mogrify_info,*image); |
| 3144 | (void) WhiteThresholdImageChannel(*image,channel,argv[i+1], |
| 3145 | exception); |
| 3146 | InheritException(exception,&(*image)->exception); |
| 3147 | break; |
| 3148 | } |
| 3149 | break; |
| 3150 | } |
| 3151 | default: |
| 3152 | break; |
| 3153 | } |
| 3154 | /* |
| 3155 | Replace current image with any image that was generated |
| 3156 | */ |
| 3157 | if (mogrify_image != (Image *) NULL) |
| 3158 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3159 | i+=count; |
| 3160 | } |
| 3161 | if (region_image != (Image *) NULL) |
| 3162 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3163 | /* |
| 3164 | Composite transformed region onto image. |
| 3165 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3166 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3167 | (void) CompositeImage(region_image,region_image->matte != |
cristy | ab01585 | 2011-07-06 01:03:32 +0000 | [diff] [blame] | 3168 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 3169 | region_geometry.x,region_geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3170 | InheritException(exception,®ion_image->exception); |
| 3171 | *image=DestroyImage(*image); |
| 3172 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3173 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3174 | } |
| 3175 | /* |
| 3176 | Free resources. |
| 3177 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3178 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3179 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3180 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 3181 | status=(MagickStatusType) ((*image)->exception.severity == |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 3182 | UndefinedException ? 1 : 0); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3183 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3184 | } |
| 3185 | |
| 3186 | /* |
| 3187 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3188 | % % |
| 3189 | % % |
| 3190 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3191 | + 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] | 3192 | % % |
| 3193 | % % |
| 3194 | % % |
| 3195 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3196 | % |
| 3197 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3198 | % transforms include image scaling, image rotation, color reduction, and |
| 3199 | % others. The transmogrified image overwrites the original image. |
| 3200 | % |
| 3201 | % The format of the MogrifyImageCommand method is: |
| 3202 | % |
| 3203 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3204 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3205 | % |
| 3206 | % A description of each parameter follows: |
| 3207 | % |
| 3208 | % o image_info: the image info. |
| 3209 | % |
| 3210 | % o argc: the number of elements in the argument vector. |
| 3211 | % |
| 3212 | % o argv: A text array containing the command line arguments. |
| 3213 | % |
| 3214 | % o metadata: any metadata is returned here. |
| 3215 | % |
| 3216 | % o exception: return any errors or warnings in this structure. |
| 3217 | % |
| 3218 | */ |
| 3219 | |
| 3220 | static MagickBooleanType MogrifyUsage(void) |
| 3221 | { |
| 3222 | static const char |
| 3223 | *miscellaneous[]= |
| 3224 | { |
| 3225 | "-debug events display copious debugging information", |
| 3226 | "-help print program options", |
| 3227 | "-list type print a list of supported option arguments", |
| 3228 | "-log format format of debugging information", |
| 3229 | "-version print version information", |
| 3230 | (char *) NULL |
| 3231 | }, |
| 3232 | *operators[]= |
| 3233 | { |
| 3234 | "-adaptive-blur geometry", |
| 3235 | " adaptively blur pixels; decrease effect near edges", |
| 3236 | "-adaptive-resize geometry", |
| 3237 | " adaptively resize image using 'mesh' interpolation", |
| 3238 | "-adaptive-sharpen geometry", |
| 3239 | " adaptively sharpen pixels; increase effect near edges", |
| 3240 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3241 | " transparent, extract, background, or shape", |
| 3242 | "-annotate geometry text", |
| 3243 | " annotate the image with text", |
| 3244 | "-auto-gamma automagically adjust gamma level of image", |
| 3245 | "-auto-level automagically adjust color levels of image", |
| 3246 | "-auto-orient automagically orient (rotate) image", |
| 3247 | "-bench iterations measure performance", |
| 3248 | "-black-threshold value", |
| 3249 | " force all pixels below the threshold into black", |
| 3250 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3251 | "-blur geometry reduce image noise and reduce detail levels", |
| 3252 | "-border geometry surround image with a border of color", |
| 3253 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3254 | "-brightness-contrast geometry", |
| 3255 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3256 | "-cdl filename color correct with a color decision list", |
| 3257 | "-charcoal radius simulate a charcoal drawing", |
| 3258 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3259 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3260 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3261 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3262 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3263 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3264 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3265 | "-contrast enhance or reduce the image contrast", |
| 3266 | "-contrast-stretch geometry", |
| 3267 | " improve contrast by `stretching' the intensity range", |
| 3268 | "-convolve coefficients", |
| 3269 | " apply a convolution kernel to the image", |
| 3270 | "-cycle amount cycle the image colormap", |
| 3271 | "-decipher filename convert cipher pixels to plain pixels", |
| 3272 | "-deskew threshold straighten an image", |
| 3273 | "-despeckle reduce the speckles within an image", |
| 3274 | "-distort method args", |
| 3275 | " distort images according to given method ad args", |
| 3276 | "-draw string annotate the image with a graphic primitive", |
| 3277 | "-edge radius apply a filter to detect edges in the image", |
| 3278 | "-encipher filename convert plain pixels to cipher pixels", |
| 3279 | "-emboss radius emboss an image", |
| 3280 | "-enhance apply a digital filter to enhance a noisy image", |
| 3281 | "-equalize perform histogram equalization to an image", |
| 3282 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3283 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3284 | "-extent geometry set the image size", |
| 3285 | "-extract geometry extract area from image", |
| 3286 | "-fft implements the discrete Fourier transform (DFT)", |
| 3287 | "-flip flip image vertically", |
| 3288 | "-floodfill geometry color", |
| 3289 | " floodfill the image with color", |
| 3290 | "-flop flop image horizontally", |
| 3291 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3292 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3293 | " apply function over image values", |
| 3294 | "-gamma value level of gamma correction", |
| 3295 | "-gaussian-blur geometry", |
| 3296 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3297 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3298 | "-identify identify the format and characteristics of the image", |
| 3299 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3300 | "-implode amount implode image pixels about the center", |
| 3301 | "-lat geometry local adaptive thresholding", |
| 3302 | "-layers method optimize, merge, or compare image layers", |
| 3303 | "-level value adjust the level of image contrast", |
| 3304 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3305 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3306 | "-linear-stretch geometry", |
| 3307 | " improve contrast by `stretching with saturation'", |
| 3308 | "-liquid-rescale geometry", |
| 3309 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3310 | "-median geometry apply a median filter to the image", |
glennrp | 30d2dc6 | 2011-06-25 03:17:16 +0000 | [diff] [blame] | 3311 | "-mode geometry make each pixel the 'predominant color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3312 | "-modulate value vary the brightness, saturation, and hue", |
| 3313 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3314 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3315 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3316 | "-motion-blur geometry", |
| 3317 | " simulate motion blur", |
| 3318 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3319 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3320 | "-normalize transform image to span the full range of colors", |
| 3321 | "-opaque color change this color to the fill color", |
| 3322 | "-ordered-dither NxN", |
| 3323 | " add a noise pattern to the image with specific", |
| 3324 | " amplitudes", |
| 3325 | "-paint radius simulate an oil painting", |
| 3326 | "-polaroid angle simulate a Polaroid picture", |
| 3327 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3328 | "-profile filename add, delete, or apply an image profile", |
| 3329 | "-quantize colorspace reduce colors in this colorspace", |
| 3330 | "-radial-blur angle radial blur the image", |
| 3331 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3332 | "-random-threshold low,high", |
| 3333 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3334 | "-region geometry apply options to a portion of the image", |
| 3335 | "-render render vector graphics", |
| 3336 | "-repage geometry size and location of an image canvas", |
| 3337 | "-resample geometry change the resolution of an image", |
| 3338 | "-resize geometry resize the image", |
| 3339 | "-roll geometry roll an image vertically or horizontally", |
| 3340 | "-rotate degrees apply Paeth rotation to the image", |
| 3341 | "-sample geometry scale image with pixel sampling", |
| 3342 | "-scale geometry scale the image", |
| 3343 | "-segment values segment an image", |
| 3344 | "-selective-blur geometry", |
| 3345 | " selectively blur pixels within a contrast threshold", |
| 3346 | "-sepia-tone threshold", |
| 3347 | " simulate a sepia-toned photo", |
| 3348 | "-set property value set an image property", |
| 3349 | "-shade degrees shade the image using a distant light source", |
| 3350 | "-shadow geometry simulate an image shadow", |
| 3351 | "-sharpen geometry sharpen the image", |
| 3352 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3353 | "-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] | 3354 | "-sigmoidal-contrast geometry", |
| 3355 | " increase the contrast without saturating highlights or shadows", |
| 3356 | "-sketch geometry simulate a pencil sketch", |
| 3357 | "-solarize threshold negate all pixels above the threshold level", |
| 3358 | "-sparse-color method args", |
| 3359 | " fill in a image based on a few color points", |
| 3360 | "-splice geometry splice the background color into the image", |
| 3361 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3362 | "-statistic type radius", |
| 3363 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3364 | "-strip strip image of all profiles and comments", |
| 3365 | "-swirl degrees swirl image pixels about the center", |
| 3366 | "-threshold value threshold the image", |
| 3367 | "-thumbnail geometry create a thumbnail of the image", |
| 3368 | "-tile filename tile image when filling a graphic primitive", |
| 3369 | "-tint value tint the image with the fill color", |
| 3370 | "-transform affine transform image", |
| 3371 | "-transparent color make this color transparent within the image", |
| 3372 | "-transpose flip image vertically and rotate 90 degrees", |
| 3373 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3374 | "-trim trim image edges", |
| 3375 | "-type type image type", |
| 3376 | "-unique-colors discard all but one of any pixel color", |
| 3377 | "-unsharp geometry sharpen the image", |
| 3378 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3379 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3380 | "-white-threshold value", |
| 3381 | " force all pixels above the threshold into white", |
| 3382 | (char *) NULL |
| 3383 | }, |
| 3384 | *sequence_operators[]= |
| 3385 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3386 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3387 | "-clut apply a color lookup table to the image", |
| 3388 | "-coalesce merge a sequence of images", |
| 3389 | "-combine combine a sequence of images", |
| 3390 | "-composite composite image", |
| 3391 | "-crop geometry cut out a rectangular region of the image", |
| 3392 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3393 | "-evaluate-sequence operator", |
| 3394 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3395 | "-flatten flatten a sequence of images", |
| 3396 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3397 | "-hald-clut apply a Hald color lookup table to the image", |
| 3398 | "-morph value morph an image sequence", |
| 3399 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3400 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3401 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3402 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3403 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3404 | "-write filename write images to this file", |
| 3405 | (char *) NULL |
| 3406 | }, |
| 3407 | *settings[]= |
| 3408 | { |
| 3409 | "-adjoin join images into a single multi-image file", |
| 3410 | "-affine matrix affine transform matrix", |
| 3411 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3412 | "-antialias remove pixel-aliasing", |
| 3413 | "-authenticate password", |
| 3414 | " decipher image with this password", |
| 3415 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3416 | "-background color background color", |
| 3417 | "-bias value add bias when convolving an image", |
| 3418 | "-black-point-compensation", |
| 3419 | " use black point compensation", |
| 3420 | "-blue-primary point chromaticity blue primary point", |
| 3421 | "-bordercolor color border color", |
| 3422 | "-caption string assign a caption to an image", |
| 3423 | "-channel type apply option to select image channels", |
| 3424 | "-colors value preferred number of colors in the image", |
| 3425 | "-colorspace type alternate image colorspace", |
| 3426 | "-comment string annotate image with comment", |
| 3427 | "-compose operator set image composite operator", |
| 3428 | "-compress type type of pixel compression when writing the image", |
| 3429 | "-define format:option", |
| 3430 | " define one or more image format options", |
| 3431 | "-delay value display the next image after pausing", |
| 3432 | "-density geometry horizontal and vertical density of the image", |
| 3433 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3434 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3435 | "-display server get image or font from this X server", |
| 3436 | "-dispose method layer disposal method", |
| 3437 | "-dither method apply error diffusion to image", |
| 3438 | "-encoding type text encoding type", |
| 3439 | "-endian type endianness (MSB or LSB) of the image", |
| 3440 | "-family name render text with this font family", |
| 3441 | "-fill color color to use when filling a graphic primitive", |
| 3442 | "-filter type use this filter when resizing an image", |
| 3443 | "-font name render text with this font", |
| 3444 | "-format \"string\" output formatted image characteristics", |
| 3445 | "-fuzz distance colors within this distance are considered equal", |
| 3446 | "-gravity type horizontal and vertical text placement", |
| 3447 | "-green-primary point chromaticity green primary point", |
| 3448 | "-intent type type of rendering intent when managing the image color", |
| 3449 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3450 | "-interline-spacing value", |
| 3451 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3452 | "-interpolate method pixel color interpolation method", |
| 3453 | "-interword-spacing value", |
| 3454 | " set the space between two words", |
| 3455 | "-kerning value set the space between two letters", |
| 3456 | "-label string assign a label to an image", |
| 3457 | "-limit type value pixel cache resource limit", |
| 3458 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3459 | "-mask filename associate a mask with the image", |
| 3460 | "-mattecolor color frame color", |
| 3461 | "-monitor monitor progress", |
| 3462 | "-orient type image orientation", |
| 3463 | "-page geometry size and location of an image canvas (setting)", |
| 3464 | "-ping efficiently determine image attributes", |
| 3465 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3466 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3467 | "-preview type image preview type", |
| 3468 | "-quality value JPEG/MIFF/PNG compression level", |
| 3469 | "-quiet suppress all warning messages", |
| 3470 | "-red-primary point chromaticity red primary point", |
| 3471 | "-regard-warnings pay attention to warning messages", |
| 3472 | "-remap filename transform image colors to match this set of colors", |
| 3473 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3474 | "-sampling-factor geometry", |
| 3475 | " horizontal and vertical sampling factor", |
| 3476 | "-scene value image scene number", |
| 3477 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3478 | "-size geometry width and height of image", |
| 3479 | "-stretch type render text with this font stretch", |
| 3480 | "-stroke color graphic primitive stroke color", |
| 3481 | "-strokewidth value graphic primitive stroke width", |
| 3482 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3483 | "-synchronize synchronize image to storage device", |
| 3484 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3485 | "-texture filename name of texture to tile onto the image background", |
| 3486 | "-tile-offset geometry", |
| 3487 | " tile offset", |
| 3488 | "-treedepth value color tree depth", |
| 3489 | "-transparent-color color", |
| 3490 | " transparent color", |
| 3491 | "-undercolor color annotation bounding box color", |
| 3492 | "-units type the units of image resolution", |
| 3493 | "-verbose print detailed information about the image", |
| 3494 | "-view FlashPix viewing transforms", |
| 3495 | "-virtual-pixel method", |
| 3496 | " virtual pixel access method", |
| 3497 | "-weight type render text with this font weight", |
| 3498 | "-white-point point chromaticity white point", |
| 3499 | (char *) NULL |
| 3500 | }, |
| 3501 | *stack_operators[]= |
| 3502 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3503 | "-delete indexes delete the image from the image sequence", |
| 3504 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3505 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3506 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3507 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3508 | "-swap indexes swap two images in the image sequence", |
| 3509 | (char *) NULL |
| 3510 | }; |
| 3511 | |
| 3512 | const char |
| 3513 | **p; |
| 3514 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3515 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3516 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3517 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3518 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3519 | GetClientName()); |
| 3520 | (void) printf("\nImage Settings:\n"); |
| 3521 | for (p=settings; *p != (char *) NULL; p++) |
| 3522 | (void) printf(" %s\n",*p); |
| 3523 | (void) printf("\nImage Operators:\n"); |
| 3524 | for (p=operators; *p != (char *) NULL; p++) |
| 3525 | (void) printf(" %s\n",*p); |
| 3526 | (void) printf("\nImage Sequence Operators:\n"); |
| 3527 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3528 | (void) printf(" %s\n",*p); |
| 3529 | (void) printf("\nImage Stack Operators:\n"); |
| 3530 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3531 | (void) printf(" %s\n",*p); |
| 3532 | (void) printf("\nMiscellaneous Options:\n"); |
| 3533 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3534 | (void) printf(" %s\n",*p); |
| 3535 | (void) printf( |
| 3536 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3537 | (void) printf( |
| 3538 | "number. To specify a particular image format, precede the filename\n"); |
| 3539 | (void) printf( |
| 3540 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3541 | (void) printf( |
| 3542 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3543 | (void) printf("'-' for standard input or output.\n"); |
| 3544 | return(MagickFalse); |
| 3545 | } |
| 3546 | |
| 3547 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3548 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3549 | { |
| 3550 | #define DestroyMogrify() \ |
| 3551 | { \ |
| 3552 | if (format != (char *) NULL) \ |
| 3553 | format=DestroyString(format); \ |
| 3554 | if (path != (char *) NULL) \ |
| 3555 | path=DestroyString(path); \ |
| 3556 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3557 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3558 | argv[i]=DestroyString(argv[i]); \ |
| 3559 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3560 | } |
| 3561 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3562 | { \ |
| 3563 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3564 | option); \ |
| 3565 | DestroyMogrify(); \ |
| 3566 | return(MagickFalse); \ |
| 3567 | } |
| 3568 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3569 | { \ |
| 3570 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3571 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3572 | DestroyMogrify(); \ |
| 3573 | return(MagickFalse); \ |
| 3574 | } |
| 3575 | |
| 3576 | char |
| 3577 | *format, |
| 3578 | *option, |
| 3579 | *path; |
| 3580 | |
| 3581 | Image |
| 3582 | *image; |
| 3583 | |
| 3584 | ImageStack |
| 3585 | image_stack[MaxImageStackDepth+1]; |
| 3586 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3587 | MagickBooleanType |
| 3588 | global_colormap; |
| 3589 | |
| 3590 | MagickBooleanType |
| 3591 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3592 | pend, |
| 3593 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3594 | |
| 3595 | MagickStatusType |
| 3596 | status; |
| 3597 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3598 | register ssize_t |
| 3599 | i; |
| 3600 | |
| 3601 | ssize_t |
| 3602 | j, |
| 3603 | k; |
| 3604 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3605 | /* |
| 3606 | Set defaults. |
| 3607 | */ |
| 3608 | assert(image_info != (ImageInfo *) NULL); |
| 3609 | assert(image_info->signature == MagickSignature); |
| 3610 | if (image_info->debug != MagickFalse) |
| 3611 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3612 | assert(exception != (ExceptionInfo *) NULL); |
| 3613 | if (argc == 2) |
| 3614 | { |
| 3615 | option=argv[1]; |
| 3616 | if ((LocaleCompare("version",option+1) == 0) || |
| 3617 | (LocaleCompare("-version",option+1) == 0)) |
| 3618 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3619 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3620 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 3621 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 3622 | GetMagickCopyright()); |
| 3623 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 3624 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3625 | return(MagickFalse); |
| 3626 | } |
| 3627 | } |
| 3628 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3629 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3630 | format=(char *) NULL; |
| 3631 | path=(char *) NULL; |
| 3632 | global_colormap=MagickFalse; |
| 3633 | k=0; |
| 3634 | j=1; |
| 3635 | NewImageStack(); |
| 3636 | option=(char *) NULL; |
| 3637 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3638 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3639 | status=MagickTrue; |
| 3640 | /* |
| 3641 | Parse command line. |
| 3642 | */ |
| 3643 | ReadCommandlLine(argc,&argv); |
| 3644 | status=ExpandFilenames(&argc,&argv); |
| 3645 | if (status == MagickFalse) |
| 3646 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3647 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3648 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3649 | { |
| 3650 | option=argv[i]; |
| 3651 | if (LocaleCompare(option,"(") == 0) |
| 3652 | { |
| 3653 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3654 | if (k == MaxImageStackDepth) |
| 3655 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3656 | option); |
| 3657 | PushImageStack(); |
| 3658 | continue; |
| 3659 | } |
| 3660 | if (LocaleCompare(option,")") == 0) |
| 3661 | { |
| 3662 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3663 | if (k == 0) |
| 3664 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3665 | PopImageStack(); |
| 3666 | continue; |
| 3667 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3668 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3669 | { |
| 3670 | char |
| 3671 | backup_filename[MaxTextExtent], |
| 3672 | *filename; |
| 3673 | |
| 3674 | Image |
| 3675 | *images; |
| 3676 | |
| 3677 | /* |
| 3678 | Option is a file name: begin by reading image from specified file. |
| 3679 | */ |
| 3680 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3681 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3682 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3683 | filename=argv[++i]; |
| 3684 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 3685 | images=ReadImages(image_info,exception); |
| 3686 | status&=(images != (Image *) NULL) && |
| 3687 | (exception->severity < ErrorException); |
| 3688 | if (images == (Image *) NULL) |
| 3689 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3690 | if (format != (char *) NULL) |
| 3691 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3692 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3693 | if (path != (char *) NULL) |
| 3694 | { |
| 3695 | GetPathComponent(option,TailPath,filename); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3696 | (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3697 | path,*DirectorySeparator,filename); |
| 3698 | } |
| 3699 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3700 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3701 | AppendImageStack(images); |
| 3702 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3703 | if (global_colormap != MagickFalse) |
| 3704 | { |
| 3705 | QuantizeInfo |
| 3706 | *quantize_info; |
| 3707 | |
| 3708 | quantize_info=AcquireQuantizeInfo(image_info); |
| 3709 | (void) RemapImages(quantize_info,images,(Image *) NULL); |
| 3710 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3711 | } |
| 3712 | *backup_filename='\0'; |
| 3713 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3714 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3715 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3716 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3717 | i; |
| 3718 | |
| 3719 | /* |
| 3720 | Rename image file as backup. |
| 3721 | */ |
| 3722 | (void) CopyMagickString(backup_filename,image->filename, |
| 3723 | MaxTextExtent); |
| 3724 | for (i=0; i < 6; i++) |
| 3725 | { |
| 3726 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3727 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3728 | break; |
| 3729 | } |
| 3730 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
| 3731 | (rename(image->filename,backup_filename) != 0)) |
| 3732 | *backup_filename='\0'; |
| 3733 | } |
| 3734 | /* |
| 3735 | Write transmogrified image to disk. |
| 3736 | */ |
| 3737 | image_info->synchronize=MagickTrue; |
| 3738 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3739 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
| 3740 | (void) remove(backup_filename); |
| 3741 | RemoveAllImageStack(); |
| 3742 | continue; |
| 3743 | } |
| 3744 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3745 | switch (*(option+1)) |
| 3746 | { |
| 3747 | case 'a': |
| 3748 | { |
| 3749 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3750 | { |
| 3751 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3752 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3753 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3754 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3755 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3756 | break; |
| 3757 | } |
| 3758 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3759 | { |
| 3760 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3761 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3762 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3763 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3764 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3765 | break; |
| 3766 | } |
| 3767 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3768 | { |
| 3769 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3770 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3771 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3772 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3773 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3774 | break; |
| 3775 | } |
| 3776 | if (LocaleCompare("affine",option+1) == 0) |
| 3777 | { |
| 3778 | if (*option == '+') |
| 3779 | break; |
| 3780 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3781 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3782 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3783 | break; |
| 3784 | } |
| 3785 | if (LocaleCompare("alpha",option+1) == 0) |
| 3786 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3787 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3788 | type; |
| 3789 | |
| 3790 | if (*option == '+') |
| 3791 | break; |
| 3792 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3793 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3794 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3795 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3796 | if (type < 0) |
| 3797 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3798 | argv[i]); |
| 3799 | break; |
| 3800 | } |
| 3801 | if (LocaleCompare("annotate",option+1) == 0) |
| 3802 | { |
| 3803 | if (*option == '+') |
| 3804 | break; |
| 3805 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3806 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3807 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3808 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3809 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3810 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3811 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3812 | i++; |
| 3813 | break; |
| 3814 | } |
| 3815 | if (LocaleCompare("antialias",option+1) == 0) |
| 3816 | break; |
| 3817 | if (LocaleCompare("append",option+1) == 0) |
| 3818 | break; |
| 3819 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3820 | { |
| 3821 | if (*option == '+') |
| 3822 | break; |
| 3823 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3824 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3825 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3826 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3827 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3828 | break; |
| 3829 | } |
| 3830 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3831 | { |
| 3832 | if (*option == '+') |
| 3833 | break; |
| 3834 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3835 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3836 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3837 | break; |
| 3838 | } |
| 3839 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3840 | break; |
| 3841 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3842 | break; |
| 3843 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3844 | break; |
| 3845 | if (LocaleCompare("average",option+1) == 0) |
| 3846 | break; |
| 3847 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3848 | } |
| 3849 | case 'b': |
| 3850 | { |
| 3851 | if (LocaleCompare("background",option+1) == 0) |
| 3852 | { |
| 3853 | if (*option == '+') |
| 3854 | break; |
| 3855 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3856 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3857 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3858 | break; |
| 3859 | } |
| 3860 | if (LocaleCompare("bias",option+1) == 0) |
| 3861 | { |
| 3862 | if (*option == '+') |
| 3863 | break; |
| 3864 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3865 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3866 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3867 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3868 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3869 | break; |
| 3870 | } |
| 3871 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 3872 | break; |
| 3873 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 3874 | { |
| 3875 | if (*option == '+') |
| 3876 | break; |
| 3877 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3878 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3879 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3880 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3881 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3882 | break; |
| 3883 | } |
| 3884 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3885 | { |
| 3886 | if (*option == '+') |
| 3887 | break; |
| 3888 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3889 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3890 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3891 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3892 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3893 | break; |
| 3894 | } |
| 3895 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3896 | { |
| 3897 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3898 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3899 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3900 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3901 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3902 | break; |
| 3903 | } |
| 3904 | if (LocaleCompare("blur",option+1) == 0) |
| 3905 | { |
| 3906 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3907 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3908 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3909 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3910 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3911 | break; |
| 3912 | } |
| 3913 | if (LocaleCompare("border",option+1) == 0) |
| 3914 | { |
| 3915 | if (*option == '+') |
| 3916 | break; |
| 3917 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3918 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3919 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3920 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3921 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3922 | break; |
| 3923 | } |
| 3924 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3925 | { |
| 3926 | if (*option == '+') |
| 3927 | break; |
| 3928 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3929 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3930 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3931 | break; |
| 3932 | } |
| 3933 | if (LocaleCompare("box",option+1) == 0) |
| 3934 | { |
| 3935 | if (*option == '+') |
| 3936 | break; |
| 3937 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3938 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3939 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3940 | break; |
| 3941 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3942 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 3943 | { |
| 3944 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3945 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3946 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3947 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3948 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3949 | break; |
| 3950 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3951 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3952 | } |
| 3953 | case 'c': |
| 3954 | { |
| 3955 | if (LocaleCompare("cache",option+1) == 0) |
| 3956 | { |
| 3957 | if (*option == '+') |
| 3958 | break; |
| 3959 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3960 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3961 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3962 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3963 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3964 | break; |
| 3965 | } |
| 3966 | if (LocaleCompare("caption",option+1) == 0) |
| 3967 | { |
| 3968 | if (*option == '+') |
| 3969 | break; |
| 3970 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3971 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3972 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3973 | break; |
| 3974 | } |
| 3975 | if (LocaleCompare("channel",option+1) == 0) |
| 3976 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3977 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3978 | channel; |
| 3979 | |
| 3980 | if (*option == '+') |
| 3981 | break; |
| 3982 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3983 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3984 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3985 | channel=ParseChannelOption(argv[i]); |
| 3986 | if (channel < 0) |
| 3987 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 3988 | argv[i]); |
| 3989 | break; |
| 3990 | } |
| 3991 | if (LocaleCompare("cdl",option+1) == 0) |
| 3992 | { |
| 3993 | if (*option == '+') |
| 3994 | break; |
| 3995 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3996 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3997 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3998 | break; |
| 3999 | } |
| 4000 | if (LocaleCompare("charcoal",option+1) == 0) |
| 4001 | { |
| 4002 | if (*option == '+') |
| 4003 | break; |
| 4004 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4005 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4006 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4007 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4008 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4009 | break; |
| 4010 | } |
| 4011 | if (LocaleCompare("chop",option+1) == 0) |
| 4012 | { |
| 4013 | if (*option == '+') |
| 4014 | break; |
| 4015 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4016 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4017 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4018 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4019 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4020 | break; |
| 4021 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4022 | if (LocaleCompare("clamp",option+1) == 0) |
| 4023 | break; |
| 4024 | if (LocaleCompare("clip",option+1) == 0) |
| 4025 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4026 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4027 | { |
| 4028 | if (*option == '+') |
| 4029 | break; |
| 4030 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4031 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4032 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4033 | break; |
| 4034 | } |
| 4035 | if (LocaleCompare("clut",option+1) == 0) |
| 4036 | break; |
| 4037 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4038 | break; |
| 4039 | if (LocaleCompare("colorize",option+1) == 0) |
| 4040 | { |
| 4041 | if (*option == '+') |
| 4042 | break; |
| 4043 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4044 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4045 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4046 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4047 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4048 | break; |
| 4049 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4050 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4051 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4052 | KernelInfo |
| 4053 | *kernel_info; |
| 4054 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4055 | if (*option == '+') |
| 4056 | break; |
| 4057 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4058 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4059 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4060 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4061 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4062 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4063 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4064 | break; |
| 4065 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4066 | if (LocaleCompare("colors",option+1) == 0) |
| 4067 | { |
| 4068 | if (*option == '+') |
| 4069 | break; |
| 4070 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4071 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4072 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4073 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4074 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4075 | break; |
| 4076 | } |
| 4077 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4078 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4079 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4080 | colorspace; |
| 4081 | |
| 4082 | if (*option == '+') |
| 4083 | break; |
| 4084 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4085 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4086 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4087 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4088 | argv[i]); |
| 4089 | if (colorspace < 0) |
| 4090 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4091 | argv[i]); |
| 4092 | break; |
| 4093 | } |
| 4094 | if (LocaleCompare("combine",option+1) == 0) |
| 4095 | break; |
| 4096 | if (LocaleCompare("comment",option+1) == 0) |
| 4097 | { |
| 4098 | if (*option == '+') |
| 4099 | break; |
| 4100 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4101 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4102 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4103 | break; |
| 4104 | } |
| 4105 | if (LocaleCompare("composite",option+1) == 0) |
| 4106 | break; |
| 4107 | if (LocaleCompare("compress",option+1) == 0) |
| 4108 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4109 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4110 | compress; |
| 4111 | |
| 4112 | if (*option == '+') |
| 4113 | break; |
| 4114 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4115 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4116 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4117 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4118 | argv[i]); |
| 4119 | if (compress < 0) |
| 4120 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4121 | argv[i]); |
| 4122 | break; |
| 4123 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4124 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4125 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4126 | if (LocaleCompare("contrast",option+1) == 0) |
| 4127 | break; |
| 4128 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4129 | { |
| 4130 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4131 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4132 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4133 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4134 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4135 | break; |
| 4136 | } |
| 4137 | if (LocaleCompare("convolve",option+1) == 0) |
| 4138 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4139 | KernelInfo |
| 4140 | *kernel_info; |
| 4141 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4142 | if (*option == '+') |
| 4143 | break; |
| 4144 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4145 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4146 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4147 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4148 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4149 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4150 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4151 | break; |
| 4152 | } |
| 4153 | if (LocaleCompare("crop",option+1) == 0) |
| 4154 | { |
| 4155 | if (*option == '+') |
| 4156 | break; |
| 4157 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4158 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4159 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4160 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4161 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4162 | break; |
| 4163 | } |
| 4164 | if (LocaleCompare("cycle",option+1) == 0) |
| 4165 | { |
| 4166 | if (*option == '+') |
| 4167 | break; |
| 4168 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4169 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4170 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4171 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4172 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4173 | break; |
| 4174 | } |
| 4175 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4176 | } |
| 4177 | case 'd': |
| 4178 | { |
| 4179 | if (LocaleCompare("decipher",option+1) == 0) |
| 4180 | { |
| 4181 | if (*option == '+') |
| 4182 | break; |
| 4183 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4184 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4185 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4186 | break; |
| 4187 | } |
| 4188 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4189 | break; |
| 4190 | if (LocaleCompare("debug",option+1) == 0) |
| 4191 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4192 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4193 | event; |
| 4194 | |
| 4195 | if (*option == '+') |
| 4196 | break; |
| 4197 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4198 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4199 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4200 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4201 | if (event < 0) |
| 4202 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4203 | argv[i]); |
| 4204 | (void) SetLogEventMask(argv[i]); |
| 4205 | break; |
| 4206 | } |
| 4207 | if (LocaleCompare("define",option+1) == 0) |
| 4208 | { |
| 4209 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4210 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4211 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4212 | if (*option == '+') |
| 4213 | { |
| 4214 | const char |
| 4215 | *define; |
| 4216 | |
| 4217 | define=GetImageOption(image_info,argv[i]); |
| 4218 | if (define == (const char *) NULL) |
| 4219 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4220 | break; |
| 4221 | } |
| 4222 | break; |
| 4223 | } |
| 4224 | if (LocaleCompare("delay",option+1) == 0) |
| 4225 | { |
| 4226 | if (*option == '+') |
| 4227 | break; |
| 4228 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4229 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4230 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4231 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4232 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4233 | break; |
| 4234 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4235 | if (LocaleCompare("delete",option+1) == 0) |
| 4236 | { |
| 4237 | if (*option == '+') |
| 4238 | break; |
| 4239 | i++; |
| 4240 | if (i == (ssize_t) (argc-1)) |
| 4241 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4242 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4243 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4244 | break; |
| 4245 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4246 | if (LocaleCompare("density",option+1) == 0) |
| 4247 | { |
| 4248 | if (*option == '+') |
| 4249 | break; |
| 4250 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4251 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4252 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4253 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4254 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4255 | break; |
| 4256 | } |
| 4257 | if (LocaleCompare("depth",option+1) == 0) |
| 4258 | { |
| 4259 | if (*option == '+') |
| 4260 | break; |
| 4261 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4262 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4263 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4264 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4265 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4266 | break; |
| 4267 | } |
| 4268 | if (LocaleCompare("deskew",option+1) == 0) |
| 4269 | { |
| 4270 | if (*option == '+') |
| 4271 | break; |
| 4272 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4273 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4274 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4275 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4276 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4277 | break; |
| 4278 | } |
| 4279 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4280 | break; |
| 4281 | if (LocaleCompare("dft",option+1) == 0) |
| 4282 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4283 | if (LocaleCompare("direction",option+1) == 0) |
| 4284 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4285 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4286 | direction; |
| 4287 | |
| 4288 | if (*option == '+') |
| 4289 | break; |
| 4290 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4291 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4292 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4293 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4294 | argv[i]); |
| 4295 | if (direction < 0) |
| 4296 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4297 | argv[i]); |
| 4298 | break; |
| 4299 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4300 | if (LocaleCompare("display",option+1) == 0) |
| 4301 | { |
| 4302 | if (*option == '+') |
| 4303 | break; |
| 4304 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4305 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4306 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4307 | break; |
| 4308 | } |
| 4309 | if (LocaleCompare("dispose",option+1) == 0) |
| 4310 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4311 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4312 | dispose; |
| 4313 | |
| 4314 | if (*option == '+') |
| 4315 | break; |
| 4316 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4317 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4318 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4319 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4320 | if (dispose < 0) |
| 4321 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4322 | argv[i]); |
| 4323 | break; |
| 4324 | } |
| 4325 | if (LocaleCompare("distort",option+1) == 0) |
| 4326 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4327 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4328 | op; |
| 4329 | |
| 4330 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4331 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4332 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4333 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4334 | if (op < 0) |
| 4335 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4336 | argv[i]); |
| 4337 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4338 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4339 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4340 | break; |
| 4341 | } |
| 4342 | if (LocaleCompare("dither",option+1) == 0) |
| 4343 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4344 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4345 | method; |
| 4346 | |
| 4347 | if (*option == '+') |
| 4348 | break; |
| 4349 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4350 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4351 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4352 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4353 | if (method < 0) |
| 4354 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4355 | argv[i]); |
| 4356 | break; |
| 4357 | } |
| 4358 | if (LocaleCompare("draw",option+1) == 0) |
| 4359 | { |
| 4360 | if (*option == '+') |
| 4361 | break; |
| 4362 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4363 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4364 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4365 | break; |
| 4366 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4367 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4368 | { |
| 4369 | if (*option == '+') |
| 4370 | break; |
| 4371 | i++; |
| 4372 | if (i == (ssize_t) (argc-1)) |
| 4373 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4374 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4375 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4376 | break; |
| 4377 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4378 | if (LocaleCompare("duration",option+1) == 0) |
| 4379 | { |
| 4380 | if (*option == '+') |
| 4381 | break; |
| 4382 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4383 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4384 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4385 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4386 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4387 | break; |
| 4388 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4389 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4390 | } |
| 4391 | case 'e': |
| 4392 | { |
| 4393 | if (LocaleCompare("edge",option+1) == 0) |
| 4394 | { |
| 4395 | if (*option == '+') |
| 4396 | break; |
| 4397 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4398 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4399 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4400 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4401 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4402 | break; |
| 4403 | } |
| 4404 | if (LocaleCompare("emboss",option+1) == 0) |
| 4405 | { |
| 4406 | if (*option == '+') |
| 4407 | break; |
| 4408 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4409 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4410 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4411 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4412 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4413 | break; |
| 4414 | } |
| 4415 | if (LocaleCompare("encipher",option+1) == 0) |
| 4416 | { |
| 4417 | if (*option == '+') |
| 4418 | break; |
| 4419 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4420 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4421 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4422 | break; |
| 4423 | } |
| 4424 | if (LocaleCompare("encoding",option+1) == 0) |
| 4425 | { |
| 4426 | if (*option == '+') |
| 4427 | break; |
| 4428 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4429 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4430 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4431 | break; |
| 4432 | } |
| 4433 | if (LocaleCompare("endian",option+1) == 0) |
| 4434 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4435 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4436 | endian; |
| 4437 | |
| 4438 | if (*option == '+') |
| 4439 | break; |
| 4440 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4441 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4442 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4443 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4444 | if (endian < 0) |
| 4445 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4446 | argv[i]); |
| 4447 | break; |
| 4448 | } |
| 4449 | if (LocaleCompare("enhance",option+1) == 0) |
| 4450 | break; |
| 4451 | if (LocaleCompare("equalize",option+1) == 0) |
| 4452 | break; |
| 4453 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4454 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4455 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4456 | op; |
| 4457 | |
| 4458 | if (*option == '+') |
| 4459 | break; |
| 4460 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4461 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4462 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4463 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4464 | if (op < 0) |
| 4465 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4466 | argv[i]); |
| 4467 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4468 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4469 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4470 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4471 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4472 | break; |
| 4473 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4474 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4475 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4476 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4477 | op; |
| 4478 | |
| 4479 | if (*option == '+') |
| 4480 | break; |
| 4481 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4482 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4483 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4484 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4485 | if (op < 0) |
| 4486 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4487 | argv[i]); |
| 4488 | break; |
| 4489 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4490 | if (LocaleCompare("extent",option+1) == 0) |
| 4491 | { |
| 4492 | if (*option == '+') |
| 4493 | break; |
| 4494 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4495 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4496 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4497 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4498 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4499 | break; |
| 4500 | } |
| 4501 | if (LocaleCompare("extract",option+1) == 0) |
| 4502 | { |
| 4503 | if (*option == '+') |
| 4504 | break; |
| 4505 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4506 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4507 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4508 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4509 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4510 | break; |
| 4511 | } |
| 4512 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4513 | } |
| 4514 | case 'f': |
| 4515 | { |
| 4516 | if (LocaleCompare("family",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-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4522 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4523 | break; |
| 4524 | } |
| 4525 | if (LocaleCompare("fill",option+1) == 0) |
| 4526 | { |
| 4527 | if (*option == '+') |
| 4528 | break; |
| 4529 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4530 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4531 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4532 | break; |
| 4533 | } |
| 4534 | if (LocaleCompare("filter",option+1) == 0) |
| 4535 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4536 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4537 | filter; |
| 4538 | |
| 4539 | if (*option == '+') |
| 4540 | break; |
| 4541 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4542 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4543 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4544 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4545 | if (filter < 0) |
| 4546 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4547 | argv[i]); |
| 4548 | break; |
| 4549 | } |
| 4550 | if (LocaleCompare("flatten",option+1) == 0) |
| 4551 | break; |
| 4552 | if (LocaleCompare("flip",option+1) == 0) |
| 4553 | break; |
| 4554 | if (LocaleCompare("flop",option+1) == 0) |
| 4555 | break; |
| 4556 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4557 | { |
| 4558 | if (*option == '+') |
| 4559 | break; |
| 4560 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4561 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4562 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4563 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4564 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4565 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4566 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4567 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4568 | break; |
| 4569 | } |
| 4570 | if (LocaleCompare("font",option+1) == 0) |
| 4571 | { |
| 4572 | if (*option == '+') |
| 4573 | break; |
| 4574 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4575 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4576 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4577 | break; |
| 4578 | } |
| 4579 | if (LocaleCompare("format",option+1) == 0) |
| 4580 | { |
| 4581 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4582 | (void) CloneString(&format,(char *) NULL); |
| 4583 | if (*option == '+') |
| 4584 | break; |
| 4585 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4586 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4587 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4588 | (void) CloneString(&format,argv[i]); |
| 4589 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4590 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4591 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4592 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4593 | if (*image_info->magick == '\0') |
| 4594 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4595 | format); |
| 4596 | break; |
| 4597 | } |
| 4598 | if (LocaleCompare("frame",option+1) == 0) |
| 4599 | { |
| 4600 | if (*option == '+') |
| 4601 | break; |
| 4602 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4603 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4604 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4605 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4606 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4607 | break; |
| 4608 | } |
| 4609 | if (LocaleCompare("function",option+1) == 0) |
| 4610 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4611 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4612 | op; |
| 4613 | |
| 4614 | if (*option == '+') |
| 4615 | break; |
| 4616 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4617 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4618 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4619 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4620 | if (op < 0) |
| 4621 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4622 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4623 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4624 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4625 | break; |
| 4626 | } |
| 4627 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4628 | { |
| 4629 | if (*option == '+') |
| 4630 | break; |
| 4631 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4632 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4633 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4634 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4635 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4636 | break; |
| 4637 | } |
| 4638 | if (LocaleCompare("fx",option+1) == 0) |
| 4639 | { |
| 4640 | if (*option == '+') |
| 4641 | break; |
| 4642 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4643 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4644 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4645 | break; |
| 4646 | } |
| 4647 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4648 | } |
| 4649 | case 'g': |
| 4650 | { |
| 4651 | if (LocaleCompare("gamma",option+1) == 0) |
| 4652 | { |
| 4653 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4654 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4655 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4656 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4657 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4658 | break; |
| 4659 | } |
| 4660 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4661 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4662 | { |
| 4663 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4664 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4665 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4666 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4667 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4668 | break; |
| 4669 | } |
| 4670 | if (LocaleCompare("geometry",option+1) == 0) |
| 4671 | { |
| 4672 | if (*option == '+') |
| 4673 | break; |
| 4674 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4675 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4676 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4677 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4678 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4679 | break; |
| 4680 | } |
| 4681 | if (LocaleCompare("gravity",option+1) == 0) |
| 4682 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4683 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4684 | gravity; |
| 4685 | |
| 4686 | if (*option == '+') |
| 4687 | break; |
| 4688 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4689 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4690 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4691 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4692 | if (gravity < 0) |
| 4693 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4694 | argv[i]); |
| 4695 | break; |
| 4696 | } |
| 4697 | if (LocaleCompare("green-primary",option+1) == 0) |
| 4698 | { |
| 4699 | if (*option == '+') |
| 4700 | break; |
| 4701 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4702 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4703 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4704 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4705 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4706 | break; |
| 4707 | } |
| 4708 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4709 | } |
| 4710 | case 'h': |
| 4711 | { |
| 4712 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4713 | break; |
| 4714 | if ((LocaleCompare("help",option+1) == 0) || |
| 4715 | (LocaleCompare("-help",option+1) == 0)) |
| 4716 | return(MogrifyUsage()); |
| 4717 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4718 | } |
| 4719 | case 'i': |
| 4720 | { |
| 4721 | if (LocaleCompare("identify",option+1) == 0) |
| 4722 | break; |
| 4723 | if (LocaleCompare("idft",option+1) == 0) |
| 4724 | break; |
| 4725 | if (LocaleCompare("implode",option+1) == 0) |
| 4726 | { |
| 4727 | if (*option == '+') |
| 4728 | break; |
| 4729 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4730 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4731 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4732 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4733 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4734 | break; |
| 4735 | } |
| 4736 | if (LocaleCompare("intent",option+1) == 0) |
| 4737 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4738 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4739 | intent; |
| 4740 | |
| 4741 | if (*option == '+') |
| 4742 | break; |
| 4743 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4744 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4745 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4746 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4747 | if (intent < 0) |
| 4748 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4749 | argv[i]); |
| 4750 | break; |
| 4751 | } |
| 4752 | if (LocaleCompare("interlace",option+1) == 0) |
| 4753 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4754 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4755 | interlace; |
| 4756 | |
| 4757 | if (*option == '+') |
| 4758 | break; |
| 4759 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4760 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4761 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4762 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4763 | argv[i]); |
| 4764 | if (interlace < 0) |
| 4765 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4766 | argv[i]); |
| 4767 | break; |
| 4768 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4769 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4770 | { |
| 4771 | if (*option == '+') |
| 4772 | break; |
| 4773 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4774 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4775 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4776 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4777 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4778 | break; |
| 4779 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4780 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4781 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4782 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4783 | interpolate; |
| 4784 | |
| 4785 | if (*option == '+') |
| 4786 | break; |
| 4787 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4788 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4789 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4790 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4791 | argv[i]); |
| 4792 | if (interpolate < 0) |
| 4793 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4794 | argv[i]); |
| 4795 | break; |
| 4796 | } |
| 4797 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4798 | { |
| 4799 | if (*option == '+') |
| 4800 | break; |
| 4801 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4802 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4803 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4804 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4805 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4806 | break; |
| 4807 | } |
| 4808 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4809 | } |
| 4810 | case 'k': |
| 4811 | { |
| 4812 | if (LocaleCompare("kerning",option+1) == 0) |
| 4813 | { |
| 4814 | if (*option == '+') |
| 4815 | break; |
| 4816 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4817 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4818 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4819 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4820 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4821 | break; |
| 4822 | } |
| 4823 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4824 | } |
| 4825 | case 'l': |
| 4826 | { |
| 4827 | if (LocaleCompare("label",option+1) == 0) |
| 4828 | { |
| 4829 | if (*option == '+') |
| 4830 | break; |
| 4831 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4832 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4833 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4834 | break; |
| 4835 | } |
| 4836 | if (LocaleCompare("lat",option+1) == 0) |
| 4837 | { |
| 4838 | if (*option == '+') |
| 4839 | break; |
| 4840 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4841 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4842 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4843 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4844 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4845 | } |
| 4846 | if (LocaleCompare("layers",option+1) == 0) |
| 4847 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4848 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4849 | type; |
| 4850 | |
| 4851 | if (*option == '+') |
| 4852 | break; |
| 4853 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4854 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4855 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4856 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4857 | if (type < 0) |
| 4858 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4859 | argv[i]); |
| 4860 | break; |
| 4861 | } |
| 4862 | if (LocaleCompare("level",option+1) == 0) |
| 4863 | { |
| 4864 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4865 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4866 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4867 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4868 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4869 | break; |
| 4870 | } |
| 4871 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4872 | { |
| 4873 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4874 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4875 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4876 | break; |
| 4877 | } |
| 4878 | if (LocaleCompare("linewidth",option+1) == 0) |
| 4879 | { |
| 4880 | if (*option == '+') |
| 4881 | break; |
| 4882 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4883 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4884 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4885 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4886 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4887 | break; |
| 4888 | } |
| 4889 | if (LocaleCompare("limit",option+1) == 0) |
| 4890 | { |
| 4891 | char |
| 4892 | *p; |
| 4893 | |
| 4894 | double |
| 4895 | value; |
| 4896 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4897 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4898 | resource; |
| 4899 | |
| 4900 | if (*option == '+') |
| 4901 | break; |
| 4902 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4903 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4904 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4905 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4906 | argv[i]); |
| 4907 | if (resource < 0) |
| 4908 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4909 | argv[i]); |
| 4910 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4911 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4912 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 4913 | value=InterpretLocaleValue(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4914 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4915 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4916 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4917 | break; |
| 4918 | } |
| 4919 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4920 | { |
| 4921 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4922 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4923 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4924 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4925 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4926 | break; |
| 4927 | } |
| 4928 | if (LocaleCompare("list",option+1) == 0) |
| 4929 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4930 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4931 | list; |
| 4932 | |
| 4933 | if (*option == '+') |
| 4934 | break; |
| 4935 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4936 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4937 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4938 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4939 | if (list < 0) |
| 4940 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4941 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4942 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4943 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4944 | } |
| 4945 | if (LocaleCompare("log",option+1) == 0) |
| 4946 | { |
| 4947 | if (*option == '+') |
| 4948 | break; |
| 4949 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4950 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4951 | (strchr(argv[i],'%') == (char *) NULL)) |
| 4952 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4953 | break; |
| 4954 | } |
| 4955 | if (LocaleCompare("loop",option+1) == 0) |
| 4956 | { |
| 4957 | if (*option == '+') |
| 4958 | break; |
| 4959 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4960 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4961 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4962 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4963 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4964 | break; |
| 4965 | } |
| 4966 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4967 | } |
| 4968 | case 'm': |
| 4969 | { |
| 4970 | if (LocaleCompare("map",option+1) == 0) |
| 4971 | { |
| 4972 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 4973 | if (*option == '+') |
| 4974 | break; |
| 4975 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4976 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4977 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4978 | break; |
| 4979 | } |
| 4980 | if (LocaleCompare("mask",option+1) == 0) |
| 4981 | { |
| 4982 | if (*option == '+') |
| 4983 | break; |
| 4984 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4985 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4986 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4987 | break; |
| 4988 | } |
| 4989 | if (LocaleCompare("matte",option+1) == 0) |
| 4990 | break; |
| 4991 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 4992 | { |
| 4993 | if (*option == '+') |
| 4994 | break; |
| 4995 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4996 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4997 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4998 | break; |
| 4999 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5000 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5001 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5002 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5003 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5004 | if (LocaleCompare("modulate",option+1) == 0) |
| 5005 | { |
| 5006 | if (*option == '+') |
| 5007 | break; |
| 5008 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5009 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5010 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5011 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5012 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5013 | break; |
| 5014 | } |
| 5015 | if (LocaleCompare("median",option+1) == 0) |
| 5016 | { |
| 5017 | if (*option == '+') |
| 5018 | break; |
| 5019 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5020 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5021 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5022 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5023 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5024 | break; |
| 5025 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5026 | if (LocaleCompare("mode",option+1) == 0) |
| 5027 | { |
| 5028 | if (*option == '+') |
| 5029 | break; |
| 5030 | i++; |
| 5031 | if (i == (ssize_t) argc) |
| 5032 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5033 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5034 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5035 | break; |
| 5036 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5037 | if (LocaleCompare("monitor",option+1) == 0) |
| 5038 | break; |
| 5039 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5040 | break; |
| 5041 | if (LocaleCompare("morph",option+1) == 0) |
| 5042 | { |
| 5043 | if (*option == '+') |
| 5044 | break; |
| 5045 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5046 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5047 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5048 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5049 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5050 | break; |
| 5051 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5052 | if (LocaleCompare("morphology",option+1) == 0) |
| 5053 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5054 | char |
| 5055 | token[MaxTextExtent]; |
| 5056 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5057 | KernelInfo |
| 5058 | *kernel_info; |
| 5059 | |
| 5060 | ssize_t |
| 5061 | op; |
| 5062 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5063 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5064 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5065 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5066 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5067 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5068 | if (op < 0) |
| 5069 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5070 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5071 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5072 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5073 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5074 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5075 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5076 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5077 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5078 | break; |
| 5079 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5080 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5081 | break; |
| 5082 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5090 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5091 | break; |
| 5092 | } |
| 5093 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5094 | } |
| 5095 | case 'n': |
| 5096 | { |
| 5097 | if (LocaleCompare("negate",option+1) == 0) |
| 5098 | break; |
| 5099 | if (LocaleCompare("noise",option+1) == 0) |
| 5100 | { |
| 5101 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5102 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5103 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5104 | if (*option == '+') |
| 5105 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5106 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5107 | noise; |
| 5108 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5109 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5110 | if (noise < 0) |
| 5111 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5112 | argv[i]); |
| 5113 | break; |
| 5114 | } |
| 5115 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5116 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5117 | break; |
| 5118 | } |
| 5119 | if (LocaleCompare("noop",option+1) == 0) |
| 5120 | break; |
| 5121 | if (LocaleCompare("normalize",option+1) == 0) |
| 5122 | break; |
| 5123 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5124 | } |
| 5125 | case 'o': |
| 5126 | { |
| 5127 | if (LocaleCompare("opaque",option+1) == 0) |
| 5128 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5129 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5130 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5131 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5132 | break; |
| 5133 | } |
| 5134 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5135 | { |
| 5136 | if (*option == '+') |
| 5137 | break; |
| 5138 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5139 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5140 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5141 | break; |
| 5142 | } |
| 5143 | if (LocaleCompare("orient",option+1) == 0) |
| 5144 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5145 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5146 | orientation; |
| 5147 | |
| 5148 | orientation=UndefinedOrientation; |
| 5149 | if (*option == '+') |
| 5150 | break; |
| 5151 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5152 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5153 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5154 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5155 | argv[i]); |
| 5156 | if (orientation < 0) |
| 5157 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5158 | argv[i]); |
| 5159 | break; |
| 5160 | } |
| 5161 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5162 | } |
| 5163 | case 'p': |
| 5164 | { |
| 5165 | if (LocaleCompare("page",option+1) == 0) |
| 5166 | { |
| 5167 | if (*option == '+') |
| 5168 | break; |
| 5169 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5170 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5171 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5172 | break; |
| 5173 | } |
| 5174 | if (LocaleCompare("paint",option+1) == 0) |
| 5175 | { |
| 5176 | if (*option == '+') |
| 5177 | break; |
| 5178 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5179 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5180 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5181 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5182 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5183 | break; |
| 5184 | } |
| 5185 | if (LocaleCompare("path",option+1) == 0) |
| 5186 | { |
| 5187 | (void) CloneString(&path,(char *) NULL); |
| 5188 | if (*option == '+') |
| 5189 | break; |
| 5190 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5191 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5192 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5193 | (void) CloneString(&path,argv[i]); |
| 5194 | break; |
| 5195 | } |
| 5196 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5197 | { |
| 5198 | if (*option == '+') |
| 5199 | break; |
| 5200 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5201 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5202 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5203 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5204 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5205 | break; |
| 5206 | } |
| 5207 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5208 | { |
| 5209 | if (*option == '+') |
| 5210 | break; |
| 5211 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5212 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5213 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5214 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5215 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5216 | break; |
| 5217 | } |
| 5218 | if (LocaleCompare("posterize",option+1) == 0) |
| 5219 | { |
| 5220 | if (*option == '+') |
| 5221 | break; |
| 5222 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5223 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5224 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5225 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5226 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5227 | break; |
| 5228 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5229 | if (LocaleCompare("precision",option+1) == 0) |
| 5230 | { |
| 5231 | if (*option == '+') |
| 5232 | break; |
| 5233 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5234 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5235 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5236 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5237 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5238 | break; |
| 5239 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5240 | if (LocaleCompare("print",option+1) == 0) |
| 5241 | { |
| 5242 | if (*option == '+') |
| 5243 | break; |
| 5244 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5245 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5246 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5247 | break; |
| 5248 | } |
| 5249 | if (LocaleCompare("process",option+1) == 0) |
| 5250 | { |
| 5251 | if (*option == '+') |
| 5252 | break; |
| 5253 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5254 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5255 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5256 | break; |
| 5257 | } |
| 5258 | if (LocaleCompare("profile",option+1) == 0) |
| 5259 | { |
| 5260 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5261 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5262 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5263 | break; |
| 5264 | } |
| 5265 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5266 | } |
| 5267 | case 'q': |
| 5268 | { |
| 5269 | if (LocaleCompare("quality",option+1) == 0) |
| 5270 | { |
| 5271 | if (*option == '+') |
| 5272 | break; |
| 5273 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5274 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5275 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5276 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5277 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5278 | break; |
| 5279 | } |
| 5280 | if (LocaleCompare("quantize",option+1) == 0) |
| 5281 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5282 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5283 | colorspace; |
| 5284 | |
| 5285 | if (*option == '+') |
| 5286 | break; |
| 5287 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5288 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5289 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5290 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5291 | argv[i]); |
| 5292 | if (colorspace < 0) |
| 5293 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5294 | argv[i]); |
| 5295 | break; |
| 5296 | } |
| 5297 | if (LocaleCompare("quiet",option+1) == 0) |
| 5298 | break; |
| 5299 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5300 | } |
| 5301 | case 'r': |
| 5302 | { |
| 5303 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5304 | { |
| 5305 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5306 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5307 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5308 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5309 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5310 | break; |
| 5311 | } |
| 5312 | if (LocaleCompare("raise",option+1) == 0) |
| 5313 | { |
| 5314 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5315 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5316 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5317 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5318 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5319 | break; |
| 5320 | } |
| 5321 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5322 | { |
| 5323 | if (*option == '+') |
| 5324 | break; |
| 5325 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5326 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5327 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5328 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5329 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5330 | break; |
| 5331 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5332 | if (LocaleCompare("recolor",option+1) == 0) |
| 5333 | { |
| 5334 | if (*option == '+') |
| 5335 | break; |
| 5336 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5337 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5338 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5339 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5340 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5341 | break; |
| 5342 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5343 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5344 | { |
| 5345 | if (*option == '+') |
| 5346 | break; |
| 5347 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5348 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5349 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5350 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5351 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5352 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5353 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5354 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5355 | if (LocaleCompare("region",option+1) == 0) |
| 5356 | { |
| 5357 | if (*option == '+') |
| 5358 | break; |
| 5359 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5360 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5361 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5362 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5363 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5364 | break; |
| 5365 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5366 | if (LocaleCompare("remap",option+1) == 0) |
| 5367 | { |
| 5368 | if (*option == '+') |
| 5369 | break; |
| 5370 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5371 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5372 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5373 | break; |
| 5374 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5375 | if (LocaleCompare("render",option+1) == 0) |
| 5376 | break; |
| 5377 | if (LocaleCompare("repage",option+1) == 0) |
| 5378 | { |
| 5379 | if (*option == '+') |
| 5380 | break; |
| 5381 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5382 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5383 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5384 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5385 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5386 | break; |
| 5387 | } |
| 5388 | if (LocaleCompare("resample",option+1) == 0) |
| 5389 | { |
| 5390 | if (*option == '+') |
| 5391 | break; |
| 5392 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5393 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5394 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5395 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5396 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5397 | break; |
| 5398 | } |
| 5399 | if (LocaleCompare("resize",option+1) == 0) |
| 5400 | { |
| 5401 | if (*option == '+') |
| 5402 | break; |
| 5403 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5404 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5405 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5406 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5407 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5408 | break; |
| 5409 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5410 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5411 | { |
| 5412 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5413 | break; |
| 5414 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5415 | if (LocaleCompare("reverse",option+1) == 0) |
| 5416 | break; |
| 5417 | if (LocaleCompare("roll",option+1) == 0) |
| 5418 | { |
| 5419 | if (*option == '+') |
| 5420 | break; |
| 5421 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5422 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5423 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5424 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5425 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5426 | break; |
| 5427 | } |
| 5428 | if (LocaleCompare("rotate",option+1) == 0) |
| 5429 | { |
| 5430 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5431 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5432 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5433 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5434 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5435 | break; |
| 5436 | } |
| 5437 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5438 | } |
| 5439 | case 's': |
| 5440 | { |
| 5441 | if (LocaleCompare("sample",option+1) == 0) |
| 5442 | { |
| 5443 | if (*option == '+') |
| 5444 | break; |
| 5445 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5446 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5447 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5448 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5449 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5450 | break; |
| 5451 | } |
| 5452 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5453 | { |
| 5454 | if (*option == '+') |
| 5455 | break; |
| 5456 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5457 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5458 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5459 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5460 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5461 | break; |
| 5462 | } |
| 5463 | if (LocaleCompare("scale",option+1) == 0) |
| 5464 | { |
| 5465 | if (*option == '+') |
| 5466 | break; |
| 5467 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5468 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5469 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5470 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5471 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5472 | break; |
| 5473 | } |
| 5474 | if (LocaleCompare("scene",option+1) == 0) |
| 5475 | { |
| 5476 | if (*option == '+') |
| 5477 | break; |
| 5478 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5479 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5480 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5481 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5482 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5483 | break; |
| 5484 | } |
| 5485 | if (LocaleCompare("seed",option+1) == 0) |
| 5486 | { |
| 5487 | if (*option == '+') |
| 5488 | break; |
| 5489 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5490 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5491 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5492 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5493 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5494 | break; |
| 5495 | } |
| 5496 | if (LocaleCompare("segment",option+1) == 0) |
| 5497 | { |
| 5498 | if (*option == '+') |
| 5499 | break; |
| 5500 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5501 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5502 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5503 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5504 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5505 | break; |
| 5506 | } |
| 5507 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5508 | { |
| 5509 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5510 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5511 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5512 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5513 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5514 | break; |
| 5515 | } |
| 5516 | if (LocaleCompare("separate",option+1) == 0) |
| 5517 | break; |
| 5518 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5519 | { |
| 5520 | if (*option == '+') |
| 5521 | break; |
| 5522 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5523 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5524 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5525 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5526 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5527 | break; |
| 5528 | } |
| 5529 | if (LocaleCompare("set",option+1) == 0) |
| 5530 | { |
| 5531 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5532 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5533 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5534 | if (*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("shade",option+1) == 0) |
| 5542 | { |
| 5543 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5544 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5545 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5546 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5547 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5548 | break; |
| 5549 | } |
| 5550 | if (LocaleCompare("shadow",option+1) == 0) |
| 5551 | { |
| 5552 | if (*option == '+') |
| 5553 | break; |
| 5554 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5555 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5556 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5557 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5558 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5559 | break; |
| 5560 | } |
| 5561 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5562 | { |
| 5563 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5564 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5565 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5566 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5567 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5568 | break; |
| 5569 | } |
| 5570 | if (LocaleCompare("shave",option+1) == 0) |
| 5571 | { |
| 5572 | if (*option == '+') |
| 5573 | break; |
| 5574 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5575 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5576 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5577 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5578 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5579 | break; |
| 5580 | } |
| 5581 | if (LocaleCompare("shear",option+1) == 0) |
| 5582 | { |
| 5583 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5584 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5585 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5586 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5587 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5588 | break; |
| 5589 | } |
| 5590 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5591 | { |
| 5592 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5593 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5594 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5595 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5596 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5597 | break; |
| 5598 | } |
| 5599 | if (LocaleCompare("size",option+1) == 0) |
| 5600 | { |
| 5601 | if (*option == '+') |
| 5602 | break; |
| 5603 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5604 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5605 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5606 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5607 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5608 | break; |
| 5609 | } |
| 5610 | if (LocaleCompare("sketch",option+1) == 0) |
| 5611 | { |
| 5612 | if (*option == '+') |
| 5613 | break; |
| 5614 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5615 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5616 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5617 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5618 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5619 | break; |
| 5620 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5621 | if (LocaleCompare("smush",option+1) == 0) |
| 5622 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5623 | i++; |
| 5624 | if (i == (ssize_t) argc) |
| 5625 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5626 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5627 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5628 | i++; |
| 5629 | break; |
| 5630 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5631 | if (LocaleCompare("solarize",option+1) == 0) |
| 5632 | { |
| 5633 | if (*option == '+') |
| 5634 | break; |
| 5635 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5636 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5637 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5638 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5639 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5640 | break; |
| 5641 | } |
| 5642 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5643 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5644 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5645 | op; |
| 5646 | |
| 5647 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5648 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5649 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5650 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5651 | if (op < 0) |
| 5652 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5653 | argv[i]); |
| 5654 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5655 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5656 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5657 | break; |
| 5658 | } |
| 5659 | if (LocaleCompare("spread",option+1) == 0) |
| 5660 | { |
| 5661 | if (*option == '+') |
| 5662 | break; |
| 5663 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5664 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5665 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5666 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5667 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5668 | break; |
| 5669 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5670 | if (LocaleCompare("statistic",option+1) == 0) |
| 5671 | { |
| 5672 | ssize_t |
| 5673 | op; |
| 5674 | |
| 5675 | if (*option == '+') |
| 5676 | break; |
| 5677 | i++; |
| 5678 | if (i == (ssize_t) argc) |
| 5679 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5680 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5681 | if (op < 0) |
| 5682 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5683 | argv[i]); |
| 5684 | i++; |
| 5685 | if (i == (ssize_t) (argc-1)) |
| 5686 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5687 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5688 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5689 | break; |
| 5690 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5691 | if (LocaleCompare("stretch",option+1) == 0) |
| 5692 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5693 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5694 | stretch; |
| 5695 | |
| 5696 | if (*option == '+') |
| 5697 | break; |
| 5698 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5699 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5700 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5701 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5702 | if (stretch < 0) |
| 5703 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5704 | argv[i]); |
| 5705 | break; |
| 5706 | } |
| 5707 | if (LocaleCompare("strip",option+1) == 0) |
| 5708 | break; |
| 5709 | if (LocaleCompare("stroke",option+1) == 0) |
| 5710 | { |
| 5711 | if (*option == '+') |
| 5712 | break; |
| 5713 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5714 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5715 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5716 | break; |
| 5717 | } |
| 5718 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5719 | { |
| 5720 | if (*option == '+') |
| 5721 | break; |
| 5722 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5723 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5724 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5725 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5726 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5727 | break; |
| 5728 | } |
| 5729 | if (LocaleCompare("style",option+1) == 0) |
| 5730 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5731 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5732 | style; |
| 5733 | |
| 5734 | if (*option == '+') |
| 5735 | break; |
| 5736 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5737 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5738 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5739 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5740 | if (style < 0) |
| 5741 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5742 | argv[i]); |
| 5743 | break; |
| 5744 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5745 | if (LocaleCompare("swap",option+1) == 0) |
| 5746 | { |
| 5747 | if (*option == '+') |
| 5748 | break; |
| 5749 | i++; |
| 5750 | if (i == (ssize_t) (argc-1)) |
| 5751 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5752 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5753 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5754 | break; |
| 5755 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5756 | if (LocaleCompare("swirl",option+1) == 0) |
| 5757 | { |
| 5758 | if (*option == '+') |
| 5759 | break; |
| 5760 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5761 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5762 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5763 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5764 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5765 | break; |
| 5766 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5767 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5768 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5769 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5770 | } |
| 5771 | case 't': |
| 5772 | { |
| 5773 | if (LocaleCompare("taint",option+1) == 0) |
| 5774 | break; |
| 5775 | if (LocaleCompare("texture",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 | break; |
| 5783 | } |
| 5784 | if (LocaleCompare("tile",option+1) == 0) |
| 5785 | { |
| 5786 | if (*option == '+') |
| 5787 | break; |
| 5788 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5789 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5790 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5791 | break; |
| 5792 | } |
| 5793 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5794 | { |
| 5795 | if (*option == '+') |
| 5796 | break; |
| 5797 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5798 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5799 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5800 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5801 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5802 | break; |
| 5803 | } |
| 5804 | if (LocaleCompare("tint",option+1) == 0) |
| 5805 | { |
| 5806 | if (*option == '+') |
| 5807 | break; |
| 5808 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5809 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5810 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5811 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5812 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5813 | break; |
| 5814 | } |
| 5815 | if (LocaleCompare("transform",option+1) == 0) |
| 5816 | break; |
| 5817 | if (LocaleCompare("transpose",option+1) == 0) |
| 5818 | break; |
| 5819 | if (LocaleCompare("transverse",option+1) == 0) |
| 5820 | break; |
| 5821 | if (LocaleCompare("threshold",option+1) == 0) |
| 5822 | { |
| 5823 | if (*option == '+') |
| 5824 | break; |
| 5825 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5826 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5827 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5828 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5829 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5830 | break; |
| 5831 | } |
| 5832 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5833 | { |
| 5834 | if (*option == '+') |
| 5835 | break; |
| 5836 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5837 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5838 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5839 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5840 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5841 | break; |
| 5842 | } |
| 5843 | if (LocaleCompare("transparent",option+1) == 0) |
| 5844 | { |
| 5845 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5846 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5847 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5848 | break; |
| 5849 | } |
| 5850 | if (LocaleCompare("transparent-color",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-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5856 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5857 | break; |
| 5858 | } |
| 5859 | if (LocaleCompare("treedepth",option+1) == 0) |
| 5860 | { |
| 5861 | if (*option == '+') |
| 5862 | break; |
| 5863 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5864 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5865 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5866 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5867 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5868 | break; |
| 5869 | } |
| 5870 | if (LocaleCompare("trim",option+1) == 0) |
| 5871 | break; |
| 5872 | if (LocaleCompare("type",option+1) == 0) |
| 5873 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5874 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5875 | type; |
| 5876 | |
| 5877 | if (*option == '+') |
| 5878 | break; |
| 5879 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5880 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5881 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5882 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5883 | if (type < 0) |
| 5884 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5885 | argv[i]); |
| 5886 | break; |
| 5887 | } |
| 5888 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5889 | } |
| 5890 | case 'u': |
| 5891 | { |
| 5892 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5893 | { |
| 5894 | if (*option == '+') |
| 5895 | break; |
| 5896 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5897 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5898 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5899 | break; |
| 5900 | } |
| 5901 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5902 | break; |
| 5903 | if (LocaleCompare("units",option+1) == 0) |
| 5904 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5905 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5906 | units; |
| 5907 | |
| 5908 | if (*option == '+') |
| 5909 | break; |
| 5910 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5911 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5912 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5913 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5914 | argv[i]); |
| 5915 | if (units < 0) |
| 5916 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5917 | argv[i]); |
| 5918 | break; |
| 5919 | } |
| 5920 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5921 | { |
| 5922 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5923 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5924 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5925 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5926 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5927 | break; |
| 5928 | } |
| 5929 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5930 | } |
| 5931 | case 'v': |
| 5932 | { |
| 5933 | if (LocaleCompare("verbose",option+1) == 0) |
| 5934 | { |
| 5935 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 5936 | break; |
| 5937 | } |
| 5938 | if ((LocaleCompare("version",option+1) == 0) || |
| 5939 | (LocaleCompare("-version",option+1) == 0)) |
| 5940 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 5941 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5942 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 5943 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 5944 | GetMagickCopyright()); |
| 5945 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 5946 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5947 | break; |
| 5948 | } |
| 5949 | if (LocaleCompare("view",option+1) == 0) |
| 5950 | { |
| 5951 | if (*option == '+') |
| 5952 | break; |
| 5953 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5954 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5955 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5956 | break; |
| 5957 | } |
| 5958 | if (LocaleCompare("vignette",option+1) == 0) |
| 5959 | { |
| 5960 | if (*option == '+') |
| 5961 | break; |
| 5962 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5963 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5964 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5965 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5966 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5967 | break; |
| 5968 | } |
| 5969 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 5970 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5971 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5972 | method; |
| 5973 | |
| 5974 | if (*option == '+') |
| 5975 | break; |
| 5976 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5977 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5978 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5979 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5980 | argv[i]); |
| 5981 | if (method < 0) |
| 5982 | ThrowMogrifyException(OptionError, |
| 5983 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 5984 | break; |
| 5985 | } |
| 5986 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5987 | } |
| 5988 | case 'w': |
| 5989 | { |
| 5990 | if (LocaleCompare("wave",option+1) == 0) |
| 5991 | { |
| 5992 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5993 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5994 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5995 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5996 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5997 | break; |
| 5998 | } |
| 5999 | if (LocaleCompare("weight",option+1) == 0) |
| 6000 | { |
| 6001 | if (*option == '+') |
| 6002 | break; |
| 6003 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6004 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6005 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6006 | break; |
| 6007 | } |
| 6008 | if (LocaleCompare("white-point",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 | } |
| 6019 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6020 | { |
| 6021 | if (*option == '+') |
| 6022 | break; |
| 6023 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6024 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6025 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6026 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6027 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6028 | break; |
| 6029 | } |
| 6030 | if (LocaleCompare("write",option+1) == 0) |
| 6031 | { |
| 6032 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6033 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6034 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6035 | break; |
| 6036 | } |
| 6037 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6038 | } |
| 6039 | case '?': |
| 6040 | break; |
| 6041 | default: |
| 6042 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6043 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6044 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 6045 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6046 | if (fire != MagickFalse) |
| 6047 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6048 | } |
| 6049 | if (k != 0) |
| 6050 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6051 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6052 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6053 | DestroyMogrify(); |
| 6054 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6055 | } |
| 6056 | |
| 6057 | /* |
| 6058 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6059 | % % |
| 6060 | % % |
| 6061 | % % |
| 6062 | + M o g r i f y I m a g e I n f o % |
| 6063 | % % |
| 6064 | % % |
| 6065 | % % |
| 6066 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6067 | % |
| 6068 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6069 | % prescribed by command line options. |
| 6070 | % |
| 6071 | % The format of the MogrifyImageInfo method is: |
| 6072 | % |
| 6073 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6074 | % const char **argv,ExceptionInfo *exception) |
| 6075 | % |
| 6076 | % A description of each parameter follows: |
| 6077 | % |
| 6078 | % o image_info: the image info.. |
| 6079 | % |
| 6080 | % o argc: Specifies a pointer to an integer describing the number of |
| 6081 | % elements in the argument vector. |
| 6082 | % |
| 6083 | % o argv: Specifies a pointer to a text array containing the command line |
| 6084 | % arguments. |
| 6085 | % |
| 6086 | % o exception: return any errors or warnings in this structure. |
| 6087 | % |
| 6088 | */ |
| 6089 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6090 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6091 | { |
| 6092 | const char |
| 6093 | *option; |
| 6094 | |
| 6095 | GeometryInfo |
| 6096 | geometry_info; |
| 6097 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6098 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6099 | count; |
| 6100 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6101 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6102 | i; |
| 6103 | |
| 6104 | /* |
| 6105 | Initialize method variables. |
| 6106 | */ |
| 6107 | assert(image_info != (ImageInfo *) NULL); |
| 6108 | assert(image_info->signature == MagickSignature); |
| 6109 | if (image_info->debug != MagickFalse) |
| 6110 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6111 | image_info->filename); |
| 6112 | if (argc < 0) |
| 6113 | return(MagickTrue); |
| 6114 | /* |
| 6115 | Set the image settings. |
| 6116 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6117 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6118 | { |
| 6119 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6120 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6121 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6122 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6123 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6124 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6125 | break; |
| 6126 | switch (*(option+1)) |
| 6127 | { |
| 6128 | case 'a': |
| 6129 | { |
| 6130 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6131 | { |
| 6132 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6133 | break; |
| 6134 | } |
| 6135 | if (LocaleCompare("antialias",option+1) == 0) |
| 6136 | { |
| 6137 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6138 | break; |
| 6139 | } |
| 6140 | if (LocaleCompare("attenuate",option+1) == 0) |
| 6141 | { |
| 6142 | if (*option == '+') |
| 6143 | { |
| 6144 | (void) DeleteImageOption(image_info,option+1); |
| 6145 | break; |
| 6146 | } |
| 6147 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6148 | break; |
| 6149 | } |
| 6150 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6151 | { |
| 6152 | if (*option == '+') |
| 6153 | (void) CloneString(&image_info->authenticate,(char *) NULL); |
| 6154 | else |
| 6155 | (void) CloneString(&image_info->authenticate,argv[i+1]); |
| 6156 | break; |
| 6157 | } |
| 6158 | break; |
| 6159 | } |
| 6160 | case 'b': |
| 6161 | { |
| 6162 | if (LocaleCompare("background",option+1) == 0) |
| 6163 | { |
| 6164 | if (*option == '+') |
| 6165 | { |
| 6166 | (void) DeleteImageOption(image_info,option+1); |
| 6167 | (void) QueryColorDatabase(BackgroundColor, |
| 6168 | &image_info->background_color,exception); |
| 6169 | break; |
| 6170 | } |
| 6171 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6172 | (void) QueryColorDatabase(argv[i+1],&image_info->background_color, |
| 6173 | exception); |
| 6174 | break; |
| 6175 | } |
| 6176 | if (LocaleCompare("bias",option+1) == 0) |
| 6177 | { |
| 6178 | if (*option == '+') |
| 6179 | { |
| 6180 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6181 | break; |
| 6182 | } |
| 6183 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6184 | break; |
| 6185 | } |
| 6186 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6187 | { |
| 6188 | if (*option == '+') |
| 6189 | { |
| 6190 | (void) SetImageOption(image_info,option+1,"false"); |
| 6191 | break; |
| 6192 | } |
| 6193 | (void) SetImageOption(image_info,option+1,"true"); |
| 6194 | break; |
| 6195 | } |
| 6196 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6197 | { |
| 6198 | if (*option == '+') |
| 6199 | { |
| 6200 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6201 | break; |
| 6202 | } |
| 6203 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6204 | break; |
| 6205 | } |
| 6206 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6207 | { |
| 6208 | if (*option == '+') |
| 6209 | { |
| 6210 | (void) DeleteImageOption(image_info,option+1); |
| 6211 | (void) QueryColorDatabase(BorderColor,&image_info->border_color, |
| 6212 | exception); |
| 6213 | break; |
| 6214 | } |
| 6215 | (void) QueryColorDatabase(argv[i+1],&image_info->border_color, |
| 6216 | exception); |
| 6217 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6218 | break; |
| 6219 | } |
| 6220 | if (LocaleCompare("box",option+1) == 0) |
| 6221 | { |
| 6222 | if (*option == '+') |
| 6223 | { |
| 6224 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6225 | break; |
| 6226 | } |
| 6227 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6228 | break; |
| 6229 | } |
| 6230 | break; |
| 6231 | } |
| 6232 | case 'c': |
| 6233 | { |
| 6234 | if (LocaleCompare("cache",option+1) == 0) |
| 6235 | { |
| 6236 | MagickSizeType |
| 6237 | limit; |
| 6238 | |
| 6239 | limit=MagickResourceInfinity; |
| 6240 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6241 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6242 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6243 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6244 | break; |
| 6245 | } |
| 6246 | if (LocaleCompare("caption",option+1) == 0) |
| 6247 | { |
| 6248 | if (*option == '+') |
| 6249 | { |
| 6250 | (void) DeleteImageOption(image_info,option+1); |
| 6251 | break; |
| 6252 | } |
| 6253 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6254 | break; |
| 6255 | } |
| 6256 | if (LocaleCompare("channel",option+1) == 0) |
| 6257 | { |
| 6258 | if (*option == '+') |
| 6259 | { |
| 6260 | image_info->channel=DefaultChannels; |
| 6261 | break; |
| 6262 | } |
| 6263 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6264 | break; |
| 6265 | } |
| 6266 | if (LocaleCompare("colors",option+1) == 0) |
| 6267 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6268 | image_info->colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6269 | break; |
| 6270 | } |
| 6271 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6272 | { |
| 6273 | if (*option == '+') |
| 6274 | { |
| 6275 | image_info->colorspace=UndefinedColorspace; |
| 6276 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6277 | break; |
| 6278 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6279 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6280 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6281 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6282 | break; |
| 6283 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6284 | if (LocaleCompare("comment",option+1) == 0) |
| 6285 | { |
| 6286 | if (*option == '+') |
| 6287 | { |
| 6288 | (void) DeleteImageOption(image_info,option+1); |
| 6289 | break; |
| 6290 | } |
| 6291 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6292 | break; |
| 6293 | } |
| 6294 | if (LocaleCompare("compose",option+1) == 0) |
| 6295 | { |
| 6296 | if (*option == '+') |
| 6297 | { |
| 6298 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6299 | break; |
| 6300 | } |
| 6301 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6302 | break; |
| 6303 | } |
| 6304 | if (LocaleCompare("compress",option+1) == 0) |
| 6305 | { |
| 6306 | if (*option == '+') |
| 6307 | { |
| 6308 | image_info->compression=UndefinedCompression; |
| 6309 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6310 | break; |
| 6311 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6312 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6313 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6314 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6315 | break; |
| 6316 | } |
| 6317 | break; |
| 6318 | } |
| 6319 | case 'd': |
| 6320 | { |
| 6321 | if (LocaleCompare("debug",option+1) == 0) |
| 6322 | { |
| 6323 | if (*option == '+') |
| 6324 | (void) SetLogEventMask("none"); |
| 6325 | else |
| 6326 | (void) SetLogEventMask(argv[i+1]); |
| 6327 | image_info->debug=IsEventLogging(); |
| 6328 | break; |
| 6329 | } |
| 6330 | if (LocaleCompare("define",option+1) == 0) |
| 6331 | { |
| 6332 | if (*option == '+') |
| 6333 | { |
| 6334 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6335 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6336 | else |
| 6337 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6338 | break; |
| 6339 | } |
| 6340 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6341 | { |
| 6342 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6343 | exception); |
| 6344 | break; |
| 6345 | } |
| 6346 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6347 | break; |
| 6348 | } |
| 6349 | if (LocaleCompare("delay",option+1) == 0) |
| 6350 | { |
| 6351 | if (*option == '+') |
| 6352 | { |
| 6353 | (void) SetImageOption(image_info,option+1,"0"); |
| 6354 | break; |
| 6355 | } |
| 6356 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6357 | break; |
| 6358 | } |
| 6359 | if (LocaleCompare("density",option+1) == 0) |
| 6360 | { |
| 6361 | /* |
| 6362 | Set image density. |
| 6363 | */ |
| 6364 | if (*option == '+') |
| 6365 | { |
| 6366 | if (image_info->density != (char *) NULL) |
| 6367 | image_info->density=DestroyString(image_info->density); |
| 6368 | (void) SetImageOption(image_info,option+1,"72"); |
| 6369 | break; |
| 6370 | } |
| 6371 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6372 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6373 | break; |
| 6374 | } |
| 6375 | if (LocaleCompare("depth",option+1) == 0) |
| 6376 | { |
| 6377 | if (*option == '+') |
| 6378 | { |
| 6379 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6380 | break; |
| 6381 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6382 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6383 | break; |
| 6384 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6385 | if (LocaleCompare("direction",option+1) == 0) |
| 6386 | { |
| 6387 | if (*option == '+') |
| 6388 | { |
| 6389 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6390 | break; |
| 6391 | } |
| 6392 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6393 | break; |
| 6394 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6395 | if (LocaleCompare("display",option+1) == 0) |
| 6396 | { |
| 6397 | if (*option == '+') |
| 6398 | { |
| 6399 | if (image_info->server_name != (char *) NULL) |
| 6400 | image_info->server_name=DestroyString( |
| 6401 | image_info->server_name); |
| 6402 | break; |
| 6403 | } |
| 6404 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6405 | break; |
| 6406 | } |
| 6407 | if (LocaleCompare("dispose",option+1) == 0) |
| 6408 | { |
| 6409 | if (*option == '+') |
| 6410 | { |
| 6411 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6412 | break; |
| 6413 | } |
| 6414 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6415 | break; |
| 6416 | } |
| 6417 | if (LocaleCompare("dither",option+1) == 0) |
| 6418 | { |
| 6419 | if (*option == '+') |
| 6420 | { |
| 6421 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6422 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6423 | break; |
| 6424 | } |
| 6425 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6426 | image_info->dither=MagickTrue; |
| 6427 | break; |
| 6428 | } |
| 6429 | break; |
| 6430 | } |
| 6431 | case 'e': |
| 6432 | { |
| 6433 | if (LocaleCompare("encoding",option+1) == 0) |
| 6434 | { |
| 6435 | if (*option == '+') |
| 6436 | { |
| 6437 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6438 | break; |
| 6439 | } |
| 6440 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6441 | break; |
| 6442 | } |
| 6443 | if (LocaleCompare("endian",option+1) == 0) |
| 6444 | { |
| 6445 | if (*option == '+') |
| 6446 | { |
| 6447 | image_info->endian=UndefinedEndian; |
| 6448 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6449 | break; |
| 6450 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6451 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6452 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6453 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6454 | break; |
| 6455 | } |
| 6456 | if (LocaleCompare("extract",option+1) == 0) |
| 6457 | { |
| 6458 | /* |
| 6459 | Set image extract geometry. |
| 6460 | */ |
| 6461 | if (*option == '+') |
| 6462 | { |
| 6463 | if (image_info->extract != (char *) NULL) |
| 6464 | image_info->extract=DestroyString(image_info->extract); |
| 6465 | break; |
| 6466 | } |
| 6467 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6468 | break; |
| 6469 | } |
| 6470 | break; |
| 6471 | } |
| 6472 | case 'f': |
| 6473 | { |
| 6474 | if (LocaleCompare("fill",option+1) == 0) |
| 6475 | { |
| 6476 | if (*option == '+') |
| 6477 | { |
| 6478 | (void) SetImageOption(image_info,option+1,"none"); |
| 6479 | break; |
| 6480 | } |
| 6481 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6482 | break; |
| 6483 | } |
| 6484 | if (LocaleCompare("filter",option+1) == 0) |
| 6485 | { |
| 6486 | if (*option == '+') |
| 6487 | { |
| 6488 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6489 | break; |
| 6490 | } |
| 6491 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6492 | break; |
| 6493 | } |
| 6494 | if (LocaleCompare("font",option+1) == 0) |
| 6495 | { |
| 6496 | if (*option == '+') |
| 6497 | { |
| 6498 | if (image_info->font != (char *) NULL) |
| 6499 | image_info->font=DestroyString(image_info->font); |
| 6500 | break; |
| 6501 | } |
| 6502 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6503 | break; |
| 6504 | } |
| 6505 | if (LocaleCompare("format",option+1) == 0) |
| 6506 | { |
| 6507 | register const char |
| 6508 | *q; |
| 6509 | |
| 6510 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6511 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6512 | image_info->ping=MagickFalse; |
| 6513 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6514 | break; |
| 6515 | } |
| 6516 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6517 | { |
| 6518 | if (*option == '+') |
| 6519 | { |
| 6520 | image_info->fuzz=0.0; |
| 6521 | (void) SetImageOption(image_info,option+1,"0"); |
| 6522 | break; |
| 6523 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6524 | image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6525 | 1.0); |
| 6526 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6527 | break; |
| 6528 | } |
| 6529 | break; |
| 6530 | } |
| 6531 | case 'g': |
| 6532 | { |
| 6533 | if (LocaleCompare("gravity",option+1) == 0) |
| 6534 | { |
| 6535 | if (*option == '+') |
| 6536 | { |
| 6537 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6538 | break; |
| 6539 | } |
| 6540 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6541 | break; |
| 6542 | } |
| 6543 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6544 | { |
| 6545 | if (*option == '+') |
| 6546 | { |
| 6547 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6548 | break; |
| 6549 | } |
| 6550 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6551 | break; |
| 6552 | } |
| 6553 | break; |
| 6554 | } |
| 6555 | case 'i': |
| 6556 | { |
| 6557 | if (LocaleCompare("intent",option+1) == 0) |
| 6558 | { |
| 6559 | if (*option == '+') |
| 6560 | { |
| 6561 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6562 | break; |
| 6563 | } |
| 6564 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6565 | break; |
| 6566 | } |
| 6567 | if (LocaleCompare("interlace",option+1) == 0) |
| 6568 | { |
| 6569 | if (*option == '+') |
| 6570 | { |
| 6571 | image_info->interlace=UndefinedInterlace; |
| 6572 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6573 | break; |
| 6574 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6575 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6576 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6577 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6578 | break; |
| 6579 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6580 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6581 | { |
| 6582 | if (*option == '+') |
| 6583 | { |
| 6584 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6585 | break; |
| 6586 | } |
| 6587 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6588 | break; |
| 6589 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6590 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6591 | { |
| 6592 | if (*option == '+') |
| 6593 | { |
| 6594 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6595 | break; |
| 6596 | } |
| 6597 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6598 | break; |
| 6599 | } |
| 6600 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6601 | { |
| 6602 | if (*option == '+') |
| 6603 | { |
| 6604 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6605 | break; |
| 6606 | } |
| 6607 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6608 | break; |
| 6609 | } |
| 6610 | break; |
| 6611 | } |
| 6612 | case 'k': |
| 6613 | { |
| 6614 | if (LocaleCompare("kerning",option+1) == 0) |
| 6615 | { |
| 6616 | if (*option == '+') |
| 6617 | { |
| 6618 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6619 | break; |
| 6620 | } |
| 6621 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6622 | break; |
| 6623 | } |
| 6624 | break; |
| 6625 | } |
| 6626 | case 'l': |
| 6627 | { |
| 6628 | if (LocaleCompare("label",option+1) == 0) |
| 6629 | { |
| 6630 | if (*option == '+') |
| 6631 | { |
| 6632 | (void) DeleteImageOption(image_info,option+1); |
| 6633 | break; |
| 6634 | } |
| 6635 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6636 | break; |
| 6637 | } |
| 6638 | if (LocaleCompare("limit",option+1) == 0) |
| 6639 | { |
| 6640 | MagickSizeType |
| 6641 | limit; |
| 6642 | |
| 6643 | ResourceType |
| 6644 | type; |
| 6645 | |
| 6646 | if (*option == '+') |
| 6647 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6648 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6649 | MagickFalse,argv[i+1]); |
| 6650 | limit=MagickResourceInfinity; |
| 6651 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6652 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6653 | (void) SetMagickResourceLimit(type,limit); |
| 6654 | break; |
| 6655 | } |
| 6656 | if (LocaleCompare("list",option+1) == 0) |
| 6657 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6658 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6659 | list; |
| 6660 | |
| 6661 | /* |
| 6662 | Display configuration list. |
| 6663 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6664 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6665 | switch (list) |
| 6666 | { |
| 6667 | case MagickCoderOptions: |
| 6668 | { |
| 6669 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6670 | break; |
| 6671 | } |
| 6672 | case MagickColorOptions: |
| 6673 | { |
| 6674 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6675 | break; |
| 6676 | } |
| 6677 | case MagickConfigureOptions: |
| 6678 | { |
| 6679 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6680 | break; |
| 6681 | } |
| 6682 | case MagickDelegateOptions: |
| 6683 | { |
| 6684 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6685 | break; |
| 6686 | } |
| 6687 | case MagickFontOptions: |
| 6688 | { |
| 6689 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6690 | break; |
| 6691 | } |
| 6692 | case MagickFormatOptions: |
| 6693 | { |
| 6694 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6695 | break; |
| 6696 | } |
| 6697 | case MagickLocaleOptions: |
| 6698 | { |
| 6699 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6700 | break; |
| 6701 | } |
| 6702 | case MagickLogOptions: |
| 6703 | { |
| 6704 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6705 | break; |
| 6706 | } |
| 6707 | case MagickMagicOptions: |
| 6708 | { |
| 6709 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6710 | break; |
| 6711 | } |
| 6712 | case MagickMimeOptions: |
| 6713 | { |
| 6714 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6715 | break; |
| 6716 | } |
| 6717 | case MagickModuleOptions: |
| 6718 | { |
| 6719 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6720 | break; |
| 6721 | } |
| 6722 | case MagickPolicyOptions: |
| 6723 | { |
| 6724 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6725 | break; |
| 6726 | } |
| 6727 | case MagickResourceOptions: |
| 6728 | { |
| 6729 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6730 | break; |
| 6731 | } |
| 6732 | case MagickThresholdOptions: |
| 6733 | { |
| 6734 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6735 | break; |
| 6736 | } |
| 6737 | default: |
| 6738 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6739 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6740 | exception); |
| 6741 | break; |
| 6742 | } |
| 6743 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6744 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6745 | } |
| 6746 | if (LocaleCompare("log",option+1) == 0) |
| 6747 | { |
| 6748 | if (*option == '+') |
| 6749 | break; |
| 6750 | (void) SetLogFormat(argv[i+1]); |
| 6751 | break; |
| 6752 | } |
| 6753 | if (LocaleCompare("loop",option+1) == 0) |
| 6754 | { |
| 6755 | if (*option == '+') |
| 6756 | { |
| 6757 | (void) SetImageOption(image_info,option+1,"0"); |
| 6758 | break; |
| 6759 | } |
| 6760 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6761 | break; |
| 6762 | } |
| 6763 | break; |
| 6764 | } |
| 6765 | case 'm': |
| 6766 | { |
| 6767 | if (LocaleCompare("matte",option+1) == 0) |
| 6768 | { |
| 6769 | if (*option == '+') |
| 6770 | { |
| 6771 | (void) SetImageOption(image_info,option+1,"false"); |
| 6772 | break; |
| 6773 | } |
| 6774 | (void) SetImageOption(image_info,option+1,"true"); |
| 6775 | break; |
| 6776 | } |
| 6777 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6778 | { |
| 6779 | if (*option == '+') |
| 6780 | { |
| 6781 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6782 | (void) QueryColorDatabase(MatteColor,&image_info->matte_color, |
| 6783 | exception); |
| 6784 | break; |
| 6785 | } |
| 6786 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6787 | (void) QueryColorDatabase(argv[i+1],&image_info->matte_color, |
| 6788 | exception); |
| 6789 | break; |
| 6790 | } |
| 6791 | if (LocaleCompare("monitor",option+1) == 0) |
| 6792 | { |
| 6793 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6794 | (void *) NULL); |
| 6795 | break; |
| 6796 | } |
| 6797 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6798 | { |
| 6799 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6800 | break; |
| 6801 | } |
| 6802 | break; |
| 6803 | } |
| 6804 | case 'o': |
| 6805 | { |
| 6806 | if (LocaleCompare("orient",option+1) == 0) |
| 6807 | { |
| 6808 | if (*option == '+') |
| 6809 | { |
| 6810 | image_info->orientation=UndefinedOrientation; |
| 6811 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6812 | break; |
| 6813 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6814 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6815 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6816 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6817 | break; |
| 6818 | } |
| 6819 | } |
| 6820 | case 'p': |
| 6821 | { |
| 6822 | if (LocaleCompare("page",option+1) == 0) |
| 6823 | { |
| 6824 | char |
| 6825 | *canonical_page, |
| 6826 | page[MaxTextExtent]; |
| 6827 | |
| 6828 | const char |
| 6829 | *image_option; |
| 6830 | |
| 6831 | MagickStatusType |
| 6832 | flags; |
| 6833 | |
| 6834 | RectangleInfo |
| 6835 | geometry; |
| 6836 | |
| 6837 | if (*option == '+') |
| 6838 | { |
| 6839 | (void) DeleteImageOption(image_info,option+1); |
| 6840 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6841 | break; |
| 6842 | } |
| 6843 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6844 | image_option=GetImageOption(image_info,"page"); |
| 6845 | if (image_option != (const char *) NULL) |
| 6846 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6847 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6848 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6849 | canonical_page=DestroyString(canonical_page); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6850 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6851 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6852 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6853 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6854 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6855 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6856 | (void) SetImageOption(image_info,option+1,page); |
| 6857 | (void) CloneString(&image_info->page,page); |
| 6858 | break; |
| 6859 | } |
| 6860 | if (LocaleCompare("pen",option+1) == 0) |
| 6861 | { |
| 6862 | if (*option == '+') |
| 6863 | { |
| 6864 | (void) SetImageOption(image_info,option+1,"none"); |
| 6865 | break; |
| 6866 | } |
| 6867 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6868 | break; |
| 6869 | } |
| 6870 | if (LocaleCompare("ping",option+1) == 0) |
| 6871 | { |
| 6872 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6873 | break; |
| 6874 | } |
| 6875 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6876 | { |
| 6877 | if (*option == '+') |
| 6878 | geometry_info.rho=0.0; |
| 6879 | else |
| 6880 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6881 | image_info->pointsize=geometry_info.rho; |
| 6882 | break; |
| 6883 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6884 | if (LocaleCompare("precision",option+1) == 0) |
| 6885 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6886 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6887 | break; |
| 6888 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6889 | if (LocaleCompare("preview",option+1) == 0) |
| 6890 | { |
| 6891 | /* |
| 6892 | Preview image. |
| 6893 | */ |
| 6894 | if (*option == '+') |
| 6895 | { |
| 6896 | image_info->preview_type=UndefinedPreview; |
| 6897 | break; |
| 6898 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6899 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6900 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6901 | break; |
| 6902 | } |
| 6903 | break; |
| 6904 | } |
| 6905 | case 'q': |
| 6906 | { |
| 6907 | if (LocaleCompare("quality",option+1) == 0) |
| 6908 | { |
| 6909 | /* |
| 6910 | Set image compression quality. |
| 6911 | */ |
| 6912 | if (*option == '+') |
| 6913 | { |
| 6914 | image_info->quality=UndefinedCompressionQuality; |
| 6915 | (void) SetImageOption(image_info,option+1,"0"); |
| 6916 | break; |
| 6917 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6918 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6919 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6920 | break; |
| 6921 | } |
| 6922 | if (LocaleCompare("quiet",option+1) == 0) |
| 6923 | { |
| 6924 | static WarningHandler |
| 6925 | warning_handler = (WarningHandler) NULL; |
| 6926 | |
| 6927 | if (*option == '+') |
| 6928 | { |
| 6929 | /* |
| 6930 | Restore error or warning messages. |
| 6931 | */ |
| 6932 | warning_handler=SetWarningHandler(warning_handler); |
| 6933 | break; |
| 6934 | } |
| 6935 | /* |
| 6936 | Suppress error or warning messages. |
| 6937 | */ |
| 6938 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6939 | break; |
| 6940 | } |
| 6941 | break; |
| 6942 | } |
| 6943 | case 'r': |
| 6944 | { |
| 6945 | if (LocaleCompare("red-primary",option+1) == 0) |
| 6946 | { |
| 6947 | if (*option == '+') |
| 6948 | { |
| 6949 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6950 | break; |
| 6951 | } |
| 6952 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6953 | break; |
| 6954 | } |
| 6955 | break; |
| 6956 | } |
| 6957 | case 's': |
| 6958 | { |
| 6959 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 6960 | { |
| 6961 | /* |
| 6962 | Set image sampling factor. |
| 6963 | */ |
| 6964 | if (*option == '+') |
| 6965 | { |
| 6966 | if (image_info->sampling_factor != (char *) NULL) |
| 6967 | image_info->sampling_factor=DestroyString( |
| 6968 | image_info->sampling_factor); |
| 6969 | break; |
| 6970 | } |
| 6971 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 6972 | break; |
| 6973 | } |
| 6974 | if (LocaleCompare("scene",option+1) == 0) |
| 6975 | { |
| 6976 | /* |
| 6977 | Set image scene. |
| 6978 | */ |
| 6979 | if (*option == '+') |
| 6980 | { |
| 6981 | image_info->scene=0; |
| 6982 | (void) SetImageOption(image_info,option+1,"0"); |
| 6983 | break; |
| 6984 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6985 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6986 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6987 | break; |
| 6988 | } |
| 6989 | if (LocaleCompare("seed",option+1) == 0) |
| 6990 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6991 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6992 | seed; |
| 6993 | |
| 6994 | if (*option == '+') |
| 6995 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6996 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6997 | SeedPseudoRandomGenerator(seed); |
| 6998 | break; |
| 6999 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7000 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7001 | SeedPseudoRandomGenerator(seed); |
| 7002 | break; |
| 7003 | } |
| 7004 | if (LocaleCompare("size",option+1) == 0) |
| 7005 | { |
| 7006 | if (*option == '+') |
| 7007 | { |
| 7008 | if (image_info->size != (char *) NULL) |
| 7009 | image_info->size=DestroyString(image_info->size); |
| 7010 | break; |
| 7011 | } |
| 7012 | (void) CloneString(&image_info->size,argv[i+1]); |
| 7013 | break; |
| 7014 | } |
| 7015 | if (LocaleCompare("stroke",option+1) == 0) |
| 7016 | { |
| 7017 | if (*option == '+') |
| 7018 | { |
| 7019 | (void) SetImageOption(image_info,option+1,"none"); |
| 7020 | break; |
| 7021 | } |
| 7022 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7023 | break; |
| 7024 | } |
| 7025 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7026 | { |
| 7027 | if (*option == '+') |
| 7028 | { |
| 7029 | (void) SetImageOption(image_info,option+1,"0"); |
| 7030 | break; |
| 7031 | } |
| 7032 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7033 | break; |
| 7034 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7035 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7036 | { |
| 7037 | if (*option == '+') |
| 7038 | { |
| 7039 | image_info->synchronize=MagickFalse; |
| 7040 | break; |
| 7041 | } |
| 7042 | image_info->synchronize=MagickTrue; |
| 7043 | break; |
| 7044 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7045 | break; |
| 7046 | } |
| 7047 | case 't': |
| 7048 | { |
| 7049 | if (LocaleCompare("taint",option+1) == 0) |
| 7050 | { |
| 7051 | if (*option == '+') |
| 7052 | { |
| 7053 | (void) SetImageOption(image_info,option+1,"false"); |
| 7054 | break; |
| 7055 | } |
| 7056 | (void) SetImageOption(image_info,option+1,"true"); |
| 7057 | break; |
| 7058 | } |
| 7059 | if (LocaleCompare("texture",option+1) == 0) |
| 7060 | { |
| 7061 | if (*option == '+') |
| 7062 | { |
| 7063 | if (image_info->texture != (char *) NULL) |
| 7064 | image_info->texture=DestroyString(image_info->texture); |
| 7065 | break; |
| 7066 | } |
| 7067 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7068 | break; |
| 7069 | } |
| 7070 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7071 | { |
| 7072 | if (*option == '+') |
| 7073 | { |
| 7074 | (void) SetImageOption(image_info,option+1,"0"); |
| 7075 | break; |
| 7076 | } |
| 7077 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7078 | break; |
| 7079 | } |
| 7080 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7081 | { |
| 7082 | if (*option == '+') |
| 7083 | { |
| 7084 | (void) QueryColorDatabase("none",&image_info->transparent_color, exception); |
| 7085 | (void) SetImageOption(image_info,option+1,"none"); |
| 7086 | break; |
| 7087 | } |
| 7088 | (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color, |
| 7089 | exception); |
| 7090 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7091 | break; |
| 7092 | } |
| 7093 | if (LocaleCompare("type",option+1) == 0) |
| 7094 | { |
| 7095 | if (*option == '+') |
| 7096 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7097 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7098 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7099 | break; |
| 7100 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7101 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7102 | MagickFalse,argv[i+1]); |
| 7103 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7104 | break; |
| 7105 | } |
| 7106 | break; |
| 7107 | } |
| 7108 | case 'u': |
| 7109 | { |
| 7110 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7111 | { |
| 7112 | if (*option == '+') |
| 7113 | { |
| 7114 | (void) DeleteImageOption(image_info,option+1); |
| 7115 | break; |
| 7116 | } |
| 7117 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7118 | break; |
| 7119 | } |
| 7120 | if (LocaleCompare("units",option+1) == 0) |
| 7121 | { |
| 7122 | if (*option == '+') |
| 7123 | { |
| 7124 | image_info->units=UndefinedResolution; |
| 7125 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7126 | break; |
| 7127 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7128 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7129 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7130 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7131 | break; |
| 7132 | } |
| 7133 | break; |
| 7134 | } |
| 7135 | case 'v': |
| 7136 | { |
| 7137 | if (LocaleCompare("verbose",option+1) == 0) |
| 7138 | { |
| 7139 | if (*option == '+') |
| 7140 | { |
| 7141 | image_info->verbose=MagickFalse; |
| 7142 | break; |
| 7143 | } |
| 7144 | image_info->verbose=MagickTrue; |
| 7145 | image_info->ping=MagickFalse; |
| 7146 | break; |
| 7147 | } |
| 7148 | if (LocaleCompare("view",option+1) == 0) |
| 7149 | { |
| 7150 | if (*option == '+') |
| 7151 | { |
| 7152 | if (image_info->view != (char *) NULL) |
| 7153 | image_info->view=DestroyString(image_info->view); |
| 7154 | break; |
| 7155 | } |
| 7156 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7157 | break; |
| 7158 | } |
| 7159 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7160 | { |
| 7161 | if (*option == '+') |
| 7162 | { |
| 7163 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7164 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7165 | break; |
| 7166 | } |
| 7167 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7168 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7169 | argv[i+1]); |
| 7170 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7171 | break; |
| 7172 | } |
| 7173 | break; |
| 7174 | } |
| 7175 | case 'w': |
| 7176 | { |
| 7177 | if (LocaleCompare("white-point",option+1) == 0) |
| 7178 | { |
| 7179 | if (*option == '+') |
| 7180 | { |
| 7181 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7182 | break; |
| 7183 | } |
| 7184 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7185 | break; |
| 7186 | } |
| 7187 | break; |
| 7188 | } |
| 7189 | default: |
| 7190 | break; |
| 7191 | } |
| 7192 | i+=count; |
| 7193 | } |
| 7194 | return(MagickTrue); |
| 7195 | } |
| 7196 | |
| 7197 | /* |
| 7198 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7199 | % % |
| 7200 | % % |
| 7201 | % % |
| 7202 | + M o g r i f y I m a g e L i s t % |
| 7203 | % % |
| 7204 | % % |
| 7205 | % % |
| 7206 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7207 | % |
| 7208 | % MogrifyImageList() applies any command line options that might affect the |
| 7209 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7210 | % |
| 7211 | % The format of the MogrifyImage method is: |
| 7212 | % |
| 7213 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7214 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7215 | % |
| 7216 | % A description of each parameter follows: |
| 7217 | % |
| 7218 | % o image_info: the image info.. |
| 7219 | % |
| 7220 | % o argc: Specifies a pointer to an integer describing the number of |
| 7221 | % elements in the argument vector. |
| 7222 | % |
| 7223 | % o argv: Specifies a pointer to a text array containing the command line |
| 7224 | % arguments. |
| 7225 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7226 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7227 | % |
| 7228 | % o exception: return any errors or warnings in this structure. |
| 7229 | % |
| 7230 | */ |
| 7231 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7232 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7233 | { |
| 7234 | ChannelType |
| 7235 | channel; |
| 7236 | |
| 7237 | const char |
| 7238 | *option; |
| 7239 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7240 | ImageInfo |
| 7241 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7242 | |
| 7243 | MagickStatusType |
| 7244 | status; |
| 7245 | |
| 7246 | QuantizeInfo |
| 7247 | *quantize_info; |
| 7248 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7249 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7250 | i; |
| 7251 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7252 | ssize_t |
| 7253 | count, |
| 7254 | index; |
| 7255 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7256 | /* |
| 7257 | Apply options to the image list. |
| 7258 | */ |
| 7259 | assert(image_info != (ImageInfo *) NULL); |
| 7260 | assert(image_info->signature == MagickSignature); |
| 7261 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7262 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7263 | assert((*images)->signature == MagickSignature); |
| 7264 | if ((*images)->debug != MagickFalse) |
| 7265 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7266 | (*images)->filename); |
| 7267 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7268 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7269 | mogrify_info=CloneImageInfo(image_info); |
| 7270 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 7271 | channel=mogrify_info->channel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7272 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7273 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7274 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7275 | if (*images == (Image *) NULL) |
| 7276 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7277 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7278 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7279 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7280 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7281 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7282 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7283 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7284 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7285 | switch (*(option+1)) |
| 7286 | { |
| 7287 | case 'a': |
| 7288 | { |
| 7289 | if (LocaleCompare("affinity",option+1) == 0) |
| 7290 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7291 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7292 | if (*option == '+') |
| 7293 | { |
| 7294 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7295 | InheritException(exception,&(*images)->exception); |
| 7296 | break; |
| 7297 | } |
| 7298 | i++; |
| 7299 | break; |
| 7300 | } |
| 7301 | if (LocaleCompare("append",option+1) == 0) |
| 7302 | { |
| 7303 | Image |
| 7304 | *append_image; |
| 7305 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7306 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7307 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7308 | MagickFalse,exception); |
| 7309 | if (append_image == (Image *) NULL) |
| 7310 | { |
| 7311 | status=MagickFalse; |
| 7312 | break; |
| 7313 | } |
| 7314 | *images=DestroyImageList(*images); |
| 7315 | *images=append_image; |
| 7316 | break; |
| 7317 | } |
| 7318 | if (LocaleCompare("average",option+1) == 0) |
| 7319 | { |
| 7320 | Image |
| 7321 | *average_image; |
| 7322 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7323 | /* |
| 7324 | Average an image sequence (deprecated). |
| 7325 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7326 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7327 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7328 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7329 | if (average_image == (Image *) NULL) |
| 7330 | { |
| 7331 | status=MagickFalse; |
| 7332 | break; |
| 7333 | } |
| 7334 | *images=DestroyImageList(*images); |
| 7335 | *images=average_image; |
| 7336 | break; |
| 7337 | } |
| 7338 | break; |
| 7339 | } |
| 7340 | case 'c': |
| 7341 | { |
| 7342 | if (LocaleCompare("channel",option+1) == 0) |
| 7343 | { |
| 7344 | if (*option == '+') |
| 7345 | { |
| 7346 | channel=DefaultChannels; |
| 7347 | break; |
| 7348 | } |
| 7349 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 7350 | break; |
| 7351 | } |
| 7352 | if (LocaleCompare("clut",option+1) == 0) |
| 7353 | { |
| 7354 | Image |
| 7355 | *clut_image, |
| 7356 | *image; |
| 7357 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7358 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7359 | image=RemoveFirstImageFromList(images); |
| 7360 | clut_image=RemoveFirstImageFromList(images); |
| 7361 | if (clut_image == (Image *) NULL) |
| 7362 | { |
| 7363 | status=MagickFalse; |
| 7364 | break; |
| 7365 | } |
cristy | f89cb1d | 2011-07-07 01:24:37 +0000 | [diff] [blame] | 7366 | (void) ClutImage(image,clut_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7367 | clut_image=DestroyImage(clut_image); |
| 7368 | InheritException(exception,&image->exception); |
| 7369 | *images=DestroyImageList(*images); |
| 7370 | *images=image; |
| 7371 | break; |
| 7372 | } |
| 7373 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7374 | { |
| 7375 | Image |
| 7376 | *coalesce_image; |
| 7377 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7378 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7379 | coalesce_image=CoalesceImages(*images,exception); |
| 7380 | if (coalesce_image == (Image *) NULL) |
| 7381 | { |
| 7382 | status=MagickFalse; |
| 7383 | break; |
| 7384 | } |
| 7385 | *images=DestroyImageList(*images); |
| 7386 | *images=coalesce_image; |
| 7387 | break; |
| 7388 | } |
| 7389 | if (LocaleCompare("combine",option+1) == 0) |
| 7390 | { |
| 7391 | Image |
| 7392 | *combine_image; |
| 7393 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7394 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 7395 | combine_image=CombineImages(*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7396 | if (combine_image == (Image *) NULL) |
| 7397 | { |
| 7398 | status=MagickFalse; |
| 7399 | break; |
| 7400 | } |
| 7401 | *images=DestroyImageList(*images); |
| 7402 | *images=combine_image; |
| 7403 | break; |
| 7404 | } |
| 7405 | if (LocaleCompare("composite",option+1) == 0) |
| 7406 | { |
| 7407 | Image |
| 7408 | *mask_image, |
| 7409 | *composite_image, |
| 7410 | *image; |
| 7411 | |
| 7412 | RectangleInfo |
| 7413 | geometry; |
| 7414 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7415 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7416 | image=RemoveFirstImageFromList(images); |
| 7417 | composite_image=RemoveFirstImageFromList(images); |
| 7418 | if (composite_image == (Image *) NULL) |
| 7419 | { |
| 7420 | status=MagickFalse; |
| 7421 | break; |
| 7422 | } |
| 7423 | (void) TransformImage(&composite_image,(char *) NULL, |
| 7424 | composite_image->geometry); |
| 7425 | SetGeometry(composite_image,&geometry); |
| 7426 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7427 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7428 | &geometry); |
| 7429 | mask_image=RemoveFirstImageFromList(images); |
| 7430 | if (mask_image != (Image *) NULL) |
| 7431 | { |
| 7432 | if ((image->compose == DisplaceCompositeOp) || |
| 7433 | (image->compose == DistortCompositeOp)) |
| 7434 | { |
| 7435 | /* |
| 7436 | Merge Y displacement into X displacement image. |
| 7437 | */ |
| 7438 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
| 7439 | mask_image,0,0); |
| 7440 | mask_image=DestroyImage(mask_image); |
| 7441 | } |
| 7442 | else |
| 7443 | { |
| 7444 | /* |
| 7445 | Set a blending mask for the composition. |
| 7446 | */ |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7447 | /* POSIBLE ERROR; what if image->mask already set */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7448 | image->mask=mask_image; |
| 7449 | (void) NegateImage(image->mask,MagickFalse); |
| 7450 | } |
| 7451 | } |
cristy | ab01585 | 2011-07-06 01:03:32 +0000 | [diff] [blame] | 7452 | (void) CompositeImageChannel(image,channel,image->compose, |
| 7453 | composite_image,geometry.x,geometry.y); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7454 | if (mask_image != (Image *) NULL) |
| 7455 | mask_image=image->mask=DestroyImage(image->mask); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7456 | composite_image=DestroyImage(composite_image); |
| 7457 | InheritException(exception,&image->exception); |
| 7458 | *images=DestroyImageList(*images); |
| 7459 | *images=image; |
| 7460 | break; |
| 7461 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7462 | #if 0 |
| 7463 | This has been merged completely into MogrifyImage() |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7464 | if (LocaleCompare("crop",option+1) == 0) |
| 7465 | { |
| 7466 | MagickStatusType |
| 7467 | flags; |
| 7468 | |
| 7469 | RectangleInfo |
| 7470 | geometry; |
| 7471 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7472 | /* |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7473 | Crop Image. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7474 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7475 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7476 | flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception); |
| 7477 | if (((geometry.width == 0) && (geometry.height == 0)) || |
| 7478 | ((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 7479 | break; |
| 7480 | (void) TransformImages(images,argv[i+1],(char *) NULL); |
| 7481 | InheritException(exception,&(*images)->exception); |
| 7482 | break; |
| 7483 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7484 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7485 | break; |
| 7486 | } |
| 7487 | case 'd': |
| 7488 | { |
| 7489 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7490 | { |
| 7491 | Image |
| 7492 | *deconstruct_image; |
| 7493 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7494 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7495 | deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer, |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 7496 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7497 | if (deconstruct_image == (Image *) NULL) |
| 7498 | { |
| 7499 | status=MagickFalse; |
| 7500 | break; |
| 7501 | } |
| 7502 | *images=DestroyImageList(*images); |
| 7503 | *images=deconstruct_image; |
| 7504 | break; |
| 7505 | } |
| 7506 | if (LocaleCompare("delete",option+1) == 0) |
| 7507 | { |
| 7508 | if (*option == '+') |
| 7509 | DeleteImages(images,"-1",exception); |
| 7510 | else |
| 7511 | DeleteImages(images,argv[i+1],exception); |
| 7512 | break; |
| 7513 | } |
| 7514 | if (LocaleCompare("dither",option+1) == 0) |
| 7515 | { |
| 7516 | if (*option == '+') |
| 7517 | { |
| 7518 | quantize_info->dither=MagickFalse; |
| 7519 | break; |
| 7520 | } |
| 7521 | quantize_info->dither=MagickTrue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7522 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7523 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7524 | break; |
| 7525 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7526 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7527 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7528 | Image |
| 7529 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7530 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7531 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7532 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7533 | else |
| 7534 | { |
| 7535 | const char |
| 7536 | *p; |
| 7537 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7538 | size_t |
| 7539 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7540 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7541 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7542 | p=strchr(argv[i+1],','); |
| 7543 | if (p == (const char *) NULL) |
| 7544 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7545 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7546 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7547 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7548 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7549 | } |
| 7550 | AppendImageToList(images, duplicate_images); |
| 7551 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7552 | break; |
| 7553 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7554 | break; |
| 7555 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7556 | case 'e': |
| 7557 | { |
| 7558 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7559 | { |
| 7560 | Image |
| 7561 | *evaluate_image; |
| 7562 | |
| 7563 | MagickEvaluateOperator |
| 7564 | op; |
| 7565 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7566 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7567 | op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions, |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7568 | MagickFalse,argv[i+1]); |
| 7569 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7570 | if (evaluate_image == (Image *) NULL) |
| 7571 | { |
| 7572 | status=MagickFalse; |
| 7573 | break; |
| 7574 | } |
| 7575 | *images=DestroyImageList(*images); |
| 7576 | *images=evaluate_image; |
| 7577 | break; |
| 7578 | } |
| 7579 | break; |
| 7580 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7581 | case 'f': |
| 7582 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7583 | if (LocaleCompare("fft",option+1) == 0) |
| 7584 | { |
| 7585 | Image |
| 7586 | *fourier_image; |
| 7587 | |
| 7588 | /* |
| 7589 | Implements the discrete Fourier transform (DFT). |
| 7590 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7591 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7592 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7593 | MagickTrue : MagickFalse,exception); |
| 7594 | if (fourier_image == (Image *) NULL) |
| 7595 | break; |
| 7596 | *images=DestroyImage(*images); |
| 7597 | *images=fourier_image; |
| 7598 | break; |
| 7599 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7600 | if (LocaleCompare("flatten",option+1) == 0) |
| 7601 | { |
| 7602 | Image |
| 7603 | *flatten_image; |
| 7604 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7605 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7606 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7607 | if (flatten_image == (Image *) NULL) |
| 7608 | break; |
| 7609 | *images=DestroyImageList(*images); |
| 7610 | *images=flatten_image; |
| 7611 | break; |
| 7612 | } |
| 7613 | if (LocaleCompare("fx",option+1) == 0) |
| 7614 | { |
| 7615 | Image |
| 7616 | *fx_image; |
| 7617 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7618 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 7619 | fx_image=FxImage(*images,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7620 | if (fx_image == (Image *) NULL) |
| 7621 | { |
| 7622 | status=MagickFalse; |
| 7623 | break; |
| 7624 | } |
| 7625 | *images=DestroyImageList(*images); |
| 7626 | *images=fx_image; |
| 7627 | break; |
| 7628 | } |
| 7629 | break; |
| 7630 | } |
| 7631 | case 'h': |
| 7632 | { |
| 7633 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7634 | { |
| 7635 | Image |
| 7636 | *hald_image, |
| 7637 | *image; |
| 7638 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7639 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7640 | image=RemoveFirstImageFromList(images); |
| 7641 | hald_image=RemoveFirstImageFromList(images); |
| 7642 | if (hald_image == (Image *) NULL) |
| 7643 | { |
| 7644 | status=MagickFalse; |
| 7645 | break; |
| 7646 | } |
cristy | f89cb1d | 2011-07-07 01:24:37 +0000 | [diff] [blame] | 7647 | (void) HaldClutImage(image,hald_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7648 | hald_image=DestroyImage(hald_image); |
| 7649 | InheritException(exception,&image->exception); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7650 | if (*images != (Image *) NULL) |
| 7651 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7652 | *images=image; |
| 7653 | break; |
| 7654 | } |
| 7655 | break; |
| 7656 | } |
| 7657 | case 'i': |
| 7658 | { |
| 7659 | if (LocaleCompare("ift",option+1) == 0) |
| 7660 | { |
| 7661 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7662 | *fourier_image, |
| 7663 | *magnitude_image, |
| 7664 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7665 | |
| 7666 | /* |
| 7667 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7668 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7669 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7670 | magnitude_image=RemoveFirstImageFromList(images); |
| 7671 | phase_image=RemoveFirstImageFromList(images); |
| 7672 | if (phase_image == (Image *) NULL) |
| 7673 | { |
| 7674 | status=MagickFalse; |
| 7675 | break; |
| 7676 | } |
| 7677 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7678 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7679 | if (fourier_image == (Image *) NULL) |
| 7680 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7681 | if (*images != (Image *) NULL) |
| 7682 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7683 | *images=fourier_image; |
| 7684 | break; |
| 7685 | } |
| 7686 | if (LocaleCompare("insert",option+1) == 0) |
| 7687 | { |
| 7688 | Image |
| 7689 | *p, |
| 7690 | *q; |
| 7691 | |
| 7692 | index=0; |
| 7693 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7694 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7695 | p=RemoveLastImageFromList(images); |
| 7696 | if (p == (Image *) NULL) |
| 7697 | { |
| 7698 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7699 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7700 | status=MagickFalse; |
| 7701 | break; |
| 7702 | } |
| 7703 | q=p; |
| 7704 | if (index == 0) |
| 7705 | PrependImageToList(images,q); |
| 7706 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7707 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7708 | AppendImageToList(images,q); |
| 7709 | else |
| 7710 | { |
| 7711 | q=GetImageFromList(*images,index-1); |
| 7712 | if (q == (Image *) NULL) |
| 7713 | { |
| 7714 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7715 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7716 | status=MagickFalse; |
| 7717 | break; |
| 7718 | } |
| 7719 | InsertImageInList(&q,p); |
| 7720 | } |
| 7721 | *images=GetFirstImageInList(q); |
| 7722 | break; |
| 7723 | } |
| 7724 | break; |
| 7725 | } |
| 7726 | case 'l': |
| 7727 | { |
| 7728 | if (LocaleCompare("layers",option+1) == 0) |
| 7729 | { |
| 7730 | Image |
| 7731 | *layers; |
| 7732 | |
| 7733 | ImageLayerMethod |
| 7734 | method; |
| 7735 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7736 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7737 | layers=(Image *) NULL; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7738 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7739 | MagickFalse,argv[i+1]); |
| 7740 | switch (method) |
| 7741 | { |
| 7742 | case CoalesceLayer: |
| 7743 | { |
| 7744 | layers=CoalesceImages(*images,exception); |
| 7745 | break; |
| 7746 | } |
| 7747 | case CompareAnyLayer: |
| 7748 | case CompareClearLayer: |
| 7749 | case CompareOverlayLayer: |
| 7750 | default: |
| 7751 | { |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7752 | layers=CompareImagesLayers(*images,method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7753 | break; |
| 7754 | } |
| 7755 | case MergeLayer: |
| 7756 | case FlattenLayer: |
| 7757 | case MosaicLayer: |
| 7758 | case TrimBoundsLayer: |
| 7759 | { |
| 7760 | layers=MergeImageLayers(*images,method,exception); |
| 7761 | break; |
| 7762 | } |
| 7763 | case DisposeLayer: |
| 7764 | { |
| 7765 | layers=DisposeImages(*images,exception); |
| 7766 | break; |
| 7767 | } |
| 7768 | case OptimizeImageLayer: |
| 7769 | { |
| 7770 | layers=OptimizeImageLayers(*images,exception); |
| 7771 | break; |
| 7772 | } |
| 7773 | case OptimizePlusLayer: |
| 7774 | { |
| 7775 | layers=OptimizePlusImageLayers(*images,exception); |
| 7776 | break; |
| 7777 | } |
| 7778 | case OptimizeTransLayer: |
| 7779 | { |
| 7780 | OptimizeImageTransparency(*images,exception); |
| 7781 | break; |
| 7782 | } |
| 7783 | case RemoveDupsLayer: |
| 7784 | { |
| 7785 | RemoveDuplicateLayers(images,exception); |
| 7786 | break; |
| 7787 | } |
| 7788 | case RemoveZeroLayer: |
| 7789 | { |
| 7790 | RemoveZeroDelayLayers(images,exception); |
| 7791 | break; |
| 7792 | } |
| 7793 | case OptimizeLayer: |
| 7794 | { |
| 7795 | /* |
| 7796 | General Purpose, GIF Animation Optimizer. |
| 7797 | */ |
| 7798 | layers=CoalesceImages(*images,exception); |
| 7799 | if (layers == (Image *) NULL) |
| 7800 | { |
| 7801 | status=MagickFalse; |
| 7802 | break; |
| 7803 | } |
| 7804 | InheritException(exception,&layers->exception); |
| 7805 | *images=DestroyImageList(*images); |
| 7806 | *images=layers; |
| 7807 | layers=OptimizeImageLayers(*images,exception); |
| 7808 | if (layers == (Image *) NULL) |
| 7809 | { |
| 7810 | status=MagickFalse; |
| 7811 | break; |
| 7812 | } |
| 7813 | InheritException(exception,&layers->exception); |
| 7814 | *images=DestroyImageList(*images); |
| 7815 | *images=layers; |
| 7816 | layers=(Image *) NULL; |
| 7817 | OptimizeImageTransparency(*images,exception); |
| 7818 | InheritException(exception,&(*images)->exception); |
| 7819 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7820 | break; |
| 7821 | } |
| 7822 | case CompositeLayer: |
| 7823 | { |
| 7824 | CompositeOperator |
| 7825 | compose; |
| 7826 | |
| 7827 | Image |
| 7828 | *source; |
| 7829 | |
| 7830 | RectangleInfo |
| 7831 | geometry; |
| 7832 | |
| 7833 | /* |
| 7834 | Split image sequence at the first 'NULL:' image. |
| 7835 | */ |
| 7836 | source=(*images); |
| 7837 | while (source != (Image *) NULL) |
| 7838 | { |
| 7839 | source=GetNextImageInList(source); |
| 7840 | if ((source != (Image *) NULL) && |
| 7841 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7842 | break; |
| 7843 | } |
| 7844 | if (source != (Image *) NULL) |
| 7845 | { |
| 7846 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7847 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7848 | source=(Image *) NULL; |
| 7849 | else |
| 7850 | { |
| 7851 | /* |
| 7852 | Separate the two lists, junk the null: image. |
| 7853 | */ |
| 7854 | source=SplitImageList(source->previous); |
| 7855 | DeleteImageFromList(&source); |
| 7856 | } |
| 7857 | } |
| 7858 | if (source == (Image *) NULL) |
| 7859 | { |
| 7860 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7861 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7862 | status=MagickFalse; |
| 7863 | break; |
| 7864 | } |
| 7865 | /* |
| 7866 | Adjust offset with gravity and virtual canvas. |
| 7867 | */ |
| 7868 | SetGeometry(*images,&geometry); |
| 7869 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7870 | geometry.width=source->page.width != 0 ? |
| 7871 | source->page.width : source->columns; |
| 7872 | geometry.height=source->page.height != 0 ? |
| 7873 | source->page.height : source->rows; |
| 7874 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7875 | (*images)->page.width : (*images)->columns, |
| 7876 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7877 | (*images)->rows,(*images)->gravity,&geometry); |
| 7878 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7879 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7880 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7881 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7882 | MagickComposeOptions,MagickFalse,option); |
| 7883 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7884 | exception); |
| 7885 | source=DestroyImageList(source); |
| 7886 | break; |
| 7887 | } |
| 7888 | } |
| 7889 | if (layers == (Image *) NULL) |
| 7890 | break; |
| 7891 | InheritException(exception,&layers->exception); |
| 7892 | *images=DestroyImageList(*images); |
| 7893 | *images=layers; |
| 7894 | break; |
| 7895 | } |
| 7896 | break; |
| 7897 | } |
| 7898 | case 'm': |
| 7899 | { |
| 7900 | if (LocaleCompare("map",option+1) == 0) |
| 7901 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7902 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7903 | if (*option == '+') |
| 7904 | { |
| 7905 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7906 | InheritException(exception,&(*images)->exception); |
| 7907 | break; |
| 7908 | } |
| 7909 | i++; |
| 7910 | break; |
| 7911 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7912 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7913 | { |
| 7914 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7915 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7916 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7917 | /* |
| 7918 | Maximum image sequence (deprecated). |
| 7919 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7920 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7921 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7922 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7923 | { |
| 7924 | status=MagickFalse; |
| 7925 | break; |
| 7926 | } |
| 7927 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7928 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7929 | break; |
| 7930 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7931 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7932 | { |
| 7933 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7934 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7935 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7936 | /* |
| 7937 | Minimum image sequence (deprecated). |
| 7938 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7939 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7940 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7941 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7942 | { |
| 7943 | status=MagickFalse; |
| 7944 | break; |
| 7945 | } |
| 7946 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7947 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7948 | break; |
| 7949 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7950 | if (LocaleCompare("morph",option+1) == 0) |
| 7951 | { |
| 7952 | Image |
| 7953 | *morph_image; |
| 7954 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7955 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7956 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7957 | exception); |
| 7958 | if (morph_image == (Image *) NULL) |
| 7959 | { |
| 7960 | status=MagickFalse; |
| 7961 | break; |
| 7962 | } |
| 7963 | *images=DestroyImageList(*images); |
| 7964 | *images=morph_image; |
| 7965 | break; |
| 7966 | } |
| 7967 | if (LocaleCompare("mosaic",option+1) == 0) |
| 7968 | { |
| 7969 | Image |
| 7970 | *mosaic_image; |
| 7971 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7972 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7973 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 7974 | if (mosaic_image == (Image *) NULL) |
| 7975 | { |
| 7976 | status=MagickFalse; |
| 7977 | break; |
| 7978 | } |
| 7979 | *images=DestroyImageList(*images); |
| 7980 | *images=mosaic_image; |
| 7981 | break; |
| 7982 | } |
| 7983 | break; |
| 7984 | } |
| 7985 | case 'p': |
| 7986 | { |
| 7987 | if (LocaleCompare("print",option+1) == 0) |
| 7988 | { |
| 7989 | char |
| 7990 | *string; |
| 7991 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7992 | (void) SyncImagesSettings(mogrify_info,*images); |
| 7993 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7994 | if (string == (char *) NULL) |
| 7995 | break; |
| 7996 | InheritException(exception,&(*images)->exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 7997 | (void) FormatLocaleFile(stdout,"%s",string); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7998 | string=DestroyString(string); |
| 7999 | } |
| 8000 | if (LocaleCompare("process",option+1) == 0) |
| 8001 | { |
| 8002 | char |
| 8003 | **arguments; |
| 8004 | |
| 8005 | int |
| 8006 | j, |
| 8007 | number_arguments; |
| 8008 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8009 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8010 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 8011 | if (arguments == (char **) NULL) |
| 8012 | break; |
| 8013 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 8014 | { |
| 8015 | char |
| 8016 | breaker, |
| 8017 | quote, |
| 8018 | *token; |
| 8019 | |
| 8020 | const char |
| 8021 | *arguments; |
| 8022 | |
| 8023 | int |
| 8024 | next, |
| 8025 | status; |
| 8026 | |
| 8027 | size_t |
| 8028 | length; |
| 8029 | |
| 8030 | TokenInfo |
| 8031 | *token_info; |
| 8032 | |
| 8033 | /* |
| 8034 | Support old style syntax, filter="-option arg". |
| 8035 | */ |
| 8036 | length=strlen(argv[i+1]); |
| 8037 | token=(char *) NULL; |
cristy | 37e0b38 | 2011-06-07 13:31:21 +0000 | [diff] [blame] | 8038 | if (~length >= (MaxTextExtent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8039 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8040 | sizeof(*token)); |
| 8041 | if (token == (char *) NULL) |
| 8042 | break; |
| 8043 | next=0; |
| 8044 | arguments=argv[i+1]; |
| 8045 | token_info=AcquireTokenInfo(); |
| 8046 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8047 | "\"",'\0',&breaker,&next,"e); |
| 8048 | token_info=DestroyTokenInfo(token_info); |
| 8049 | if (status == 0) |
| 8050 | { |
| 8051 | const char |
| 8052 | *argv; |
| 8053 | |
| 8054 | argv=(&(arguments[next])); |
| 8055 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8056 | exception); |
| 8057 | } |
| 8058 | token=DestroyString(token); |
| 8059 | break; |
| 8060 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8061 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8062 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8063 | number_arguments-2,(const char **) arguments+2,exception); |
| 8064 | for (j=0; j < number_arguments; j++) |
| 8065 | arguments[j]=DestroyString(arguments[j]); |
| 8066 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8067 | break; |
| 8068 | } |
| 8069 | break; |
| 8070 | } |
| 8071 | case 'r': |
| 8072 | { |
| 8073 | if (LocaleCompare("reverse",option+1) == 0) |
| 8074 | { |
| 8075 | ReverseImageList(images); |
| 8076 | InheritException(exception,&(*images)->exception); |
| 8077 | break; |
| 8078 | } |
| 8079 | break; |
| 8080 | } |
| 8081 | case 's': |
| 8082 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8083 | if (LocaleCompare("smush",option+1) == 0) |
| 8084 | { |
| 8085 | Image |
| 8086 | *smush_image; |
| 8087 | |
| 8088 | ssize_t |
| 8089 | offset; |
| 8090 | |
| 8091 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8092 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8093 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8094 | MagickFalse,offset,exception); |
| 8095 | if (smush_image == (Image *) NULL) |
| 8096 | { |
| 8097 | status=MagickFalse; |
| 8098 | break; |
| 8099 | } |
| 8100 | *images=DestroyImageList(*images); |
| 8101 | *images=smush_image; |
| 8102 | break; |
| 8103 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8104 | if (LocaleCompare("swap",option+1) == 0) |
| 8105 | { |
| 8106 | Image |
| 8107 | *p, |
| 8108 | *q, |
| 8109 | *swap; |
| 8110 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8111 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8112 | swap_index; |
| 8113 | |
| 8114 | index=(-1); |
| 8115 | swap_index=(-2); |
| 8116 | if (*option != '+') |
| 8117 | { |
| 8118 | GeometryInfo |
| 8119 | geometry_info; |
| 8120 | |
| 8121 | MagickStatusType |
| 8122 | flags; |
| 8123 | |
| 8124 | swap_index=(-1); |
| 8125 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8126 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8127 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8128 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8129 | } |
| 8130 | p=GetImageFromList(*images,index); |
| 8131 | q=GetImageFromList(*images,swap_index); |
| 8132 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8133 | { |
| 8134 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8135 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8136 | status=MagickFalse; |
| 8137 | break; |
| 8138 | } |
| 8139 | if (p == q) |
| 8140 | break; |
| 8141 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8142 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8143 | ReplaceImageInList(&q,swap); |
| 8144 | *images=GetFirstImageInList(q); |
| 8145 | break; |
| 8146 | } |
| 8147 | break; |
| 8148 | } |
| 8149 | case 'w': |
| 8150 | { |
| 8151 | if (LocaleCompare("write",option+1) == 0) |
| 8152 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8153 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8154 | key[MaxTextExtent]; |
| 8155 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8156 | Image |
| 8157 | *write_images; |
| 8158 | |
| 8159 | ImageInfo |
| 8160 | *write_info; |
| 8161 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8162 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8163 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8164 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8165 | write_images=(*images); |
| 8166 | if (*option == '+') |
| 8167 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8168 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8169 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8170 | write_info=DestroyImageInfo(write_info); |
| 8171 | if (*option == '+') |
| 8172 | write_images=DestroyImageList(write_images); |
| 8173 | break; |
| 8174 | } |
| 8175 | break; |
| 8176 | } |
| 8177 | default: |
| 8178 | break; |
| 8179 | } |
| 8180 | i+=count; |
| 8181 | } |
| 8182 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8183 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8184 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8185 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8186 | } |
| 8187 | |
| 8188 | /* |
| 8189 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8190 | % % |
| 8191 | % % |
| 8192 | % % |
| 8193 | + M o g r i f y I m a g e s % |
| 8194 | % % |
| 8195 | % % |
| 8196 | % % |
| 8197 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8198 | % |
| 8199 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8200 | % prescribed by command line options. |
| 8201 | % |
| 8202 | % The format of the MogrifyImage method is: |
| 8203 | % |
| 8204 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8205 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8206 | % Image **images,Exceptioninfo *exception) |
| 8207 | % |
| 8208 | % A description of each parameter follows: |
| 8209 | % |
| 8210 | % o image_info: the image info.. |
| 8211 | % |
| 8212 | % o post: If true, post process image list operators otherwise pre-process. |
| 8213 | % |
| 8214 | % o argc: Specifies a pointer to an integer describing the number of |
| 8215 | % elements in the argument vector. |
| 8216 | % |
| 8217 | % o argv: Specifies a pointer to a text array containing the command line |
| 8218 | % arguments. |
| 8219 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8220 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8221 | % |
| 8222 | % o exception: return any errors or warnings in this structure. |
| 8223 | % |
| 8224 | */ |
| 8225 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8226 | const MagickBooleanType post,const int argc,const char **argv, |
| 8227 | Image **images,ExceptionInfo *exception) |
| 8228 | { |
| 8229 | #define MogrifyImageTag "Mogrify/Image" |
| 8230 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8231 | MagickStatusType |
| 8232 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8233 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8234 | MagickBooleanType |
| 8235 | proceed; |
| 8236 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8237 | size_t |
| 8238 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8239 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8240 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8241 | i; |
| 8242 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8243 | assert(image_info != (ImageInfo *) NULL); |
| 8244 | assert(image_info->signature == MagickSignature); |
| 8245 | if (images == (Image **) NULL) |
| 8246 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8247 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8248 | assert((*images)->signature == MagickSignature); |
| 8249 | if ((*images)->debug != MagickFalse) |
| 8250 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8251 | (*images)->filename); |
| 8252 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8253 | return(MagickTrue); |
| 8254 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8255 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8256 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8257 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8258 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8259 | (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc, |
| 8260 | post?"post":"pre"); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8261 | #endif |
| 8262 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8263 | /* |
| 8264 | Pre-process multi-image sequence operators |
| 8265 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8266 | if (post == MagickFalse) |
| 8267 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8268 | /* |
| 8269 | For each image, process simple single image operators |
| 8270 | */ |
| 8271 | i=0; |
| 8272 | n=GetImageListLength(*images); |
| 8273 | for (;;) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8274 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8275 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8276 | (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long) |
| 8277 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8278 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8279 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8280 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8281 | if (proceed == MagickFalse) |
| 8282 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8283 | if ( (*images)->next == (Image *) NULL ) |
| 8284 | break; |
| 8285 | *images=(*images)->next; |
| 8286 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8287 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8288 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8289 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8290 | (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long) |
| 8291 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8292 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8293 | |
| 8294 | /* |
| 8295 | Post-process, multi-image sequence operators |
| 8296 | */ |
| 8297 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8298 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8299 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8300 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8301 | } |