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" |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 54 | #include "MagickCore/string-private.h" |
cristy | 0740a98 | 2011-10-13 15:01:01 +0000 | [diff] [blame] | 55 | #include "MagickCore/thread-private.h" |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 56 | #include "MagickCore/utility-private.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 57 | |
| 58 | /* |
cristy | 154fa9d | 2011-08-05 14:25:15 +0000 | [diff] [blame] | 59 | Constant declaration. |
| 60 | */ |
cristy | 3a557c0 | 2011-08-06 19:48:02 +0000 | [diff] [blame] | 61 | static const char |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 62 | MogrifyBackgroundColor[] = "#ffffff", /* white */ |
| 63 | MogrifyBorderColor[] = "#dfdfdf", /* gray */ |
| 64 | MogrifyMatteColor[] = "#bdbdbd"; /* gray */ |
cristy | 154fa9d | 2011-08-05 14:25:15 +0000 | [diff] [blame] | 65 | |
| 66 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 67 | Define declarations. |
| 68 | */ |
| 69 | #define UndefinedCompressionQuality 0UL |
| 70 | |
| 71 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 72 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 73 | % % |
| 74 | % % |
| 75 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 76 | % 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] | 77 | % % |
| 78 | % % |
| 79 | % % |
| 80 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 81 | % |
| 82 | % MagickCommandGenesis() applies image processing options to an image as |
| 83 | % prescribed by command line options. |
| 84 | % |
| 85 | % The format of the MagickCommandGenesis method is: |
| 86 | % |
| 87 | % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 88 | % MagickCommand command,int argc,char **argv,char **metadata, |
| 89 | % ExceptionInfo *exception) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 90 | % |
| 91 | % A description of each parameter follows: |
| 92 | % |
| 93 | % o image_info: the image info. |
| 94 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 95 | % o command: Choose from ConvertImageCommand, IdentifyImageCommand, |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 96 | % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 97 | % ConjureImageCommand, StreamImageCommand, ImportImageCommand, |
| 98 | % DisplayImageCommand, or AnimateImageCommand. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 99 | % |
| 100 | % o argc: Specifies a pointer to an integer describing the number of |
| 101 | % elements in the argument vector. |
| 102 | % |
| 103 | % o argv: Specifies a pointer to a text array containing the command line |
| 104 | % arguments. |
| 105 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 106 | % o metadata: any metadata is returned here. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 107 | % |
| 108 | % o exception: return any errors or warnings in this structure. |
| 109 | % |
| 110 | */ |
| 111 | WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
| 112 | MagickCommand command,int argc,char **argv,char **metadata, |
| 113 | ExceptionInfo *exception) |
| 114 | { |
| 115 | char |
| 116 | *option; |
| 117 | |
| 118 | double |
| 119 | duration, |
| 120 | elapsed_time, |
| 121 | user_time; |
| 122 | |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 123 | MagickBooleanType |
| 124 | concurrent, |
| 125 | regard_warnings, |
| 126 | status; |
| 127 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 128 | register ssize_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 129 | i; |
| 130 | |
| 131 | TimerInfo |
| 132 | *timer; |
| 133 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 134 | size_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 135 | iterations; |
| 136 | |
cristy | d0a94fa | 2010-03-12 14:18:11 +0000 | [diff] [blame] | 137 | (void) setlocale(LC_ALL,""); |
| 138 | (void) setlocale(LC_NUMERIC,"C"); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 139 | concurrent=MagickFalse; |
| 140 | duration=(-1.0); |
| 141 | iterations=1; |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 142 | status=MagickFalse; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 143 | regard_warnings=MagickFalse; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 144 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 145 | { |
| 146 | option=argv[i]; |
| 147 | if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) |
| 148 | continue; |
| 149 | if (LocaleCompare("bench",option+1) == 0) |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 150 | iterations=StringToUnsignedLong(argv[++i]); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 151 | if (LocaleCompare("concurrent",option+1) == 0) |
| 152 | concurrent=MagickTrue; |
| 153 | if (LocaleCompare("debug",option+1) == 0) |
| 154 | (void) SetLogEventMask(argv[++i]); |
| 155 | if (LocaleCompare("duration",option+1) == 0) |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 156 | duration=StringToDouble(argv[++i],(char **) NULL); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 157 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 158 | regard_warnings=MagickTrue; |
| 159 | } |
| 160 | timer=AcquireTimerInfo(); |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 161 | if (concurrent == MagickFalse) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 162 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 163 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 164 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 165 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 166 | continue; |
| 167 | if (duration > 0) |
| 168 | { |
| 169 | if (GetElapsedTime(timer) > duration) |
| 170 | continue; |
| 171 | (void) ContinueTimer(timer); |
| 172 | } |
| 173 | status=command(image_info,argc,argv,metadata,exception); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 174 | if (exception->severity != UndefinedException) |
| 175 | { |
| 176 | if ((exception->severity > ErrorException) || |
| 177 | (regard_warnings != MagickFalse)) |
| 178 | status=MagickTrue; |
| 179 | CatchException(exception); |
| 180 | } |
cristy | 3d1a551 | 2009-10-25 21:23:27 +0000 | [diff] [blame] | 181 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 182 | { |
| 183 | (void) fputs(*metadata,stdout); |
| 184 | (void) fputc('\n',stdout); |
| 185 | *metadata=DestroyString(*metadata); |
| 186 | } |
| 187 | } |
| 188 | } |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 189 | else |
| 190 | { |
| 191 | SetOpenMPNested(1); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 192 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 193 | # pragma omp parallel for shared(status) |
| 194 | #endif |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 195 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 196 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 197 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 198 | continue; |
| 199 | if (duration > 0) |
| 200 | { |
| 201 | if (GetElapsedTime(timer) > duration) |
| 202 | continue; |
| 203 | (void) ContinueTimer(timer); |
| 204 | } |
| 205 | status=command(image_info,argc,argv,metadata,exception); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 206 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 207 | # pragma omp critical (MagickCore_CommandGenesis) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 208 | #endif |
| 209 | { |
| 210 | if (exception->severity != UndefinedException) |
| 211 | { |
| 212 | if ((exception->severity > ErrorException) || |
| 213 | (regard_warnings != MagickFalse)) |
| 214 | status=MagickTrue; |
| 215 | CatchException(exception); |
| 216 | } |
| 217 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 218 | { |
| 219 | (void) fputs(*metadata,stdout); |
| 220 | (void) fputc('\n',stdout); |
| 221 | *metadata=DestroyString(*metadata); |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | } |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 226 | if (iterations > 1) |
| 227 | { |
| 228 | elapsed_time=GetElapsedTime(timer); |
| 229 | user_time=GetUserTime(timer); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 230 | (void) FormatLocaleFile(stderr, |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 231 | "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double) |
| 232 | iterations,1.0*iterations/elapsed_time,user_time,(double) |
| 233 | (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double) |
| 234 | (1000.0*(elapsed_time-floor(elapsed_time)))); |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 235 | (void) fflush(stderr); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 236 | } |
| 237 | timer=DestroyTimerInfo(timer); |
cristy | 1f9e1ed | 2009-11-18 04:09:38 +0000 | [diff] [blame] | 238 | return(status); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | /* |
| 242 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 243 | % % |
| 244 | % % |
| 245 | % % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 246 | + M o g r i f y I m a g e % |
| 247 | % % |
| 248 | % % |
| 249 | % % |
| 250 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 251 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 252 | % MogrifyImage() applies simple single image processing options to a single |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 253 | % image that may be part of a large list, but also handles any 'region' |
| 254 | % image handling. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 255 | % |
| 256 | % The image in the list may be modified in three different ways... |
| 257 | % |
| 258 | % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 259 | % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 260 | % * replace by a list of images (only the -separate option!) |
| 261 | % |
| 262 | % In each case the result is returned into the list, and a pointer to the |
| 263 | % modified image (last image added if replaced by a list of images) is |
| 264 | % returned. |
| 265 | % |
| 266 | % ASIDE: The -crop is present but restricted to non-tile single image crops |
| 267 | % |
| 268 | % This means if all the images are being processed (such as by |
| 269 | % MogrifyImages(), next image to be processed will be as per the pointer |
| 270 | % (*image)->next. Also the image list may grow as a result of some specific |
| 271 | % operations but as images are never merged or deleted, it will never shrink |
| 272 | % in length. Typically the list will remain the same length. |
| 273 | % |
| 274 | % WARNING: As the image pointed to may be replaced, the first image in the |
| 275 | % list may also change. GetFirstImageInList() should be used by caller if |
| 276 | % they wish return the Image pointer to the first image in list. |
| 277 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 278 | % |
| 279 | % The format of the MogrifyImage method is: |
| 280 | % |
| 281 | % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 282 | % const char **argv,Image **image) |
| 283 | % |
| 284 | % A description of each parameter follows: |
| 285 | % |
| 286 | % o image_info: the image info.. |
| 287 | % |
| 288 | % o argc: Specifies a pointer to an integer describing the number of |
| 289 | % elements in the argument vector. |
| 290 | % |
| 291 | % o argv: Specifies a pointer to a text array containing the command line |
| 292 | % arguments. |
| 293 | % |
| 294 | % o image: the image. |
| 295 | % |
| 296 | % o exception: return any errors or warnings in this structure. |
| 297 | % |
| 298 | */ |
| 299 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 300 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 301 | ExceptionInfo *exception) |
| 302 | { |
| 303 | char |
| 304 | key[MaxTextExtent]; |
| 305 | |
| 306 | ExceptionInfo |
| 307 | *sans_exception; |
| 308 | |
| 309 | Image |
| 310 | *image; |
| 311 | |
| 312 | ImageInfo |
| 313 | *read_info; |
| 314 | |
cristy | fcd785b | 2011-11-08 01:48:33 +0000 | [diff] [blame^] | 315 | /* |
| 316 | Read an image into a image cache if not already present. Return the image |
| 317 | that is in the cache under that filename. |
| 318 | */ |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 319 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 320 | sans_exception=AcquireExceptionInfo(); |
| 321 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 322 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 323 | if (image != (Image *) NULL) |
| 324 | return(image); |
| 325 | read_info=CloneImageInfo(image_info); |
| 326 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 327 | image=ReadImage(read_info,exception); |
| 328 | read_info=DestroyImageInfo(read_info); |
| 329 | if (image != (Image *) NULL) |
| 330 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 331 | return(image); |
| 332 | } |
| 333 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 334 | static MagickBooleanType IsPathWritable(const char *path) |
| 335 | { |
| 336 | if (IsPathAccessible(path) == MagickFalse) |
| 337 | return(MagickFalse); |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 338 | if (access_utf8(path,W_OK) != 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 339 | return(MagickFalse); |
| 340 | return(MagickTrue); |
| 341 | } |
| 342 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 343 | static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 344 | { |
| 345 | if (x > y) |
| 346 | return(x); |
| 347 | return(y); |
| 348 | } |
| 349 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 350 | static MagickBooleanType MonitorProgress(const char *text, |
| 351 | const MagickOffsetType offset,const MagickSizeType extent, |
| 352 | void *wand_unused(client_data)) |
| 353 | { |
| 354 | char |
| 355 | message[MaxTextExtent], |
| 356 | tag[MaxTextExtent]; |
| 357 | |
| 358 | const char |
| 359 | *locale_message; |
| 360 | |
| 361 | register char |
| 362 | *p; |
| 363 | |
| 364 | if (extent < 2) |
| 365 | return(MagickTrue); |
| 366 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 367 | p=strrchr(tag,'/'); |
| 368 | if (p != (char *) NULL) |
| 369 | *p='\0'; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 370 | (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 371 | locale_message=GetLocaleMessage(message); |
| 372 | if (locale_message == message) |
| 373 | locale_message=tag; |
| 374 | if (p == (char *) NULL) |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 375 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", |
| 376 | locale_message,(long) offset,(unsigned long) extent,(long) |
| 377 | (100L*offset/(extent-1))); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 378 | else |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 379 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 380 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 381 | (100L*offset/(extent-1))); |
| 382 | if (offset == (MagickOffsetType) (extent-1)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 383 | (void) FormatLocaleFile(stderr,"\n"); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 384 | (void) fflush(stderr); |
| 385 | return(MagickTrue); |
| 386 | } |
| 387 | |
anthony | 0d0fd35 | 2011-10-04 11:09:07 +0000 | [diff] [blame] | 388 | /* |
| 389 | SparseColorOption() parses the complex -sparse-color argument into an |
| 390 | an array of floating point values then calls SparseColorImage(). |
| 391 | Argument is a complex mix of floating-point pixel coodinates, and color |
| 392 | specifications (or direct floating point numbers). The number of floats |
| 393 | needed to represent a color varies depending on the current channel |
| 394 | setting. |
| 395 | */ |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 396 | static Image *SparseColorOption(const Image *image, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 397 | const SparseColorMethod method,const char *arguments, |
| 398 | const MagickBooleanType color_from_image,ExceptionInfo *exception) |
| 399 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 400 | char |
| 401 | token[MaxTextExtent]; |
| 402 | |
| 403 | const char |
| 404 | *p; |
| 405 | |
| 406 | double |
| 407 | *sparse_arguments; |
| 408 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 409 | Image |
| 410 | *sparse_image; |
| 411 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 412 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 413 | color; |
| 414 | |
| 415 | MagickBooleanType |
| 416 | error; |
| 417 | |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 418 | register size_t |
| 419 | x; |
| 420 | |
| 421 | size_t |
| 422 | number_arguments, |
| 423 | number_colors; |
| 424 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 425 | assert(image != (Image *) NULL); |
| 426 | assert(image->signature == MagickSignature); |
| 427 | if (image->debug != MagickFalse) |
| 428 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 429 | assert(exception != (ExceptionInfo *) NULL); |
| 430 | assert(exception->signature == MagickSignature); |
| 431 | /* |
| 432 | Limit channels according to image - and add up number of color channel. |
| 433 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 434 | number_colors=0; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 435 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 436 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 437 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 438 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 439 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 440 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 441 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 442 | (image->colorspace == CMYKColorspace)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 443 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 444 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 445 | (image->matte != MagickFalse)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 446 | number_colors++; |
| 447 | |
| 448 | /* |
| 449 | Read string, to determine number of arguments needed, |
| 450 | */ |
| 451 | p=arguments; |
| 452 | x=0; |
| 453 | while( *p != '\0' ) |
| 454 | { |
| 455 | GetMagickToken(p,&p,token); |
| 456 | if ( token[0] == ',' ) continue; |
| 457 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 458 | if ( color_from_image ) { |
| 459 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 460 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 461 | "Color arg given, when colors are coming from image"); |
| 462 | return( (Image *)NULL); |
| 463 | } |
| 464 | x += number_colors; /* color argument */ |
| 465 | } |
| 466 | else { |
| 467 | x++; /* floating point argument */ |
| 468 | } |
| 469 | } |
| 470 | error=MagickTrue; |
| 471 | if ( color_from_image ) { |
| 472 | /* just the control points are being given */ |
| 473 | error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; |
| 474 | number_arguments=(x/2)*(2+number_colors); |
| 475 | } |
| 476 | else { |
| 477 | /* control points and color values */ |
| 478 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; |
| 479 | number_arguments=x; |
| 480 | } |
| 481 | if ( error ) { |
| 482 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 483 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 484 | "Invalid number of Arguments"); |
| 485 | return( (Image *)NULL); |
| 486 | } |
| 487 | |
| 488 | /* Allocate and fill in the floating point arguments */ |
| 489 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 490 | sizeof(*sparse_arguments)); |
| 491 | if (sparse_arguments == (double *) NULL) { |
| 492 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 493 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 494 | return( (Image *)NULL); |
| 495 | } |
| 496 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 497 | sizeof(*sparse_arguments)); |
| 498 | p=arguments; |
| 499 | x=0; |
| 500 | while( *p != '\0' && x < number_arguments ) { |
| 501 | /* X coordinate */ |
| 502 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 503 | if ( token[0] == '\0' ) break; |
| 504 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 505 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 506 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 507 | "Color found, instead of X-coord"); |
| 508 | error = MagickTrue; |
| 509 | break; |
| 510 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 511 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 512 | /* Y coordinate */ |
| 513 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 514 | if ( token[0] == '\0' ) break; |
| 515 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 516 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 517 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 518 | "Color found, instead of Y-coord"); |
| 519 | error = MagickTrue; |
| 520 | break; |
| 521 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 522 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 523 | /* color values for this control point */ |
| 524 | #if 0 |
| 525 | if ( (color_from_image ) { |
| 526 | /* get color from image */ |
| 527 | /* HOW??? */ |
| 528 | } |
| 529 | else |
| 530 | #endif |
| 531 | { |
| 532 | /* color name or function given in string argument */ |
| 533 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 534 | if ( token[0] == '\0' ) break; |
| 535 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 536 | /* Color string given */ |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 537 | (void) QueryColorCompliance(token,AllCompliance,&color,exception); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 538 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 539 | sparse_arguments[x++] = QuantumScale*color.red; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 540 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 541 | sparse_arguments[x++] = QuantumScale*color.green; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 542 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 543 | sparse_arguments[x++] = QuantumScale*color.blue; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 544 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 545 | (image->colorspace == CMYKColorspace)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 546 | sparse_arguments[x++] = QuantumScale*color.black; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 547 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 548 | (image->matte != MagickFalse)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 549 | sparse_arguments[x++] = QuantumScale*color.alpha; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 550 | } |
| 551 | else { |
| 552 | /* Colors given as a set of floating point values - experimental */ |
| 553 | /* NB: token contains the first floating point value to use! */ |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 554 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 555 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 556 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 557 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 558 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 559 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 560 | token[0] = ','; /* used this token - get another */ |
| 561 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 562 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 563 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 564 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 565 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 566 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 567 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 568 | token[0] = ','; /* used this token - get another */ |
| 569 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 570 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 571 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 572 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 573 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 574 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 575 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 576 | token[0] = ','; /* used this token - get another */ |
| 577 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 578 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 579 | (image->colorspace == CMYKColorspace)) |
| 580 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 581 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 582 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 583 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 584 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 585 | token[0] = ','; /* used this token - get another */ |
| 586 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 587 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 588 | (image->matte != MagickFalse)) |
| 589 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 590 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 591 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 592 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 593 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 594 | token[0] = ','; /* used this token - get another */ |
| 595 | } |
| 596 | } |
| 597 | } |
| 598 | } |
| 599 | if ( number_arguments != x && !error ) { |
| 600 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
| 601 | "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error"); |
| 602 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 603 | return( (Image *)NULL); |
| 604 | } |
| 605 | if ( error ) |
| 606 | return( (Image *)NULL); |
| 607 | |
| 608 | /* Call the Interpolation function with the parsed arguments */ |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 609 | sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, |
| 610 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 611 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 612 | return( sparse_image ); |
| 613 | } |
| 614 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 615 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 616 | const char **argv,Image **image,ExceptionInfo *exception) |
| 617 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 618 | ChannelType |
| 619 | channel; |
| 620 | |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 621 | CompositeOperator |
| 622 | compose; |
| 623 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 624 | const char |
| 625 | *format, |
| 626 | *option; |
| 627 | |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 628 | double |
| 629 | attenuate; |
| 630 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 631 | DrawInfo |
| 632 | *draw_info; |
| 633 | |
| 634 | GeometryInfo |
| 635 | geometry_info; |
| 636 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 637 | Image |
| 638 | *region_image; |
| 639 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 640 | ImageInfo |
| 641 | *mogrify_info; |
| 642 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 643 | MagickStatusType |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 644 | status; |
| 645 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 646 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 647 | fill; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 648 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 649 | MagickStatusType |
| 650 | flags; |
| 651 | |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 652 | PixelInterpolateMethod |
| 653 | interpolate_method; |
| 654 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 655 | QuantizeInfo |
| 656 | *quantize_info; |
| 657 | |
| 658 | RectangleInfo |
| 659 | geometry, |
| 660 | region_geometry; |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame] | 661 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 662 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 663 | i; |
| 664 | |
| 665 | /* |
| 666 | Initialize method variables. |
| 667 | */ |
| 668 | assert(image_info != (const ImageInfo *) NULL); |
| 669 | assert(image_info->signature == MagickSignature); |
| 670 | assert(image != (Image **) NULL); |
| 671 | assert((*image)->signature == MagickSignature); |
| 672 | if ((*image)->debug != MagickFalse) |
| 673 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); |
| 674 | if (argc < 0) |
| 675 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 676 | mogrify_info=CloneImageInfo(image_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 677 | draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL); |
| 678 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 679 | SetGeometryInfo(&geometry_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 680 | GetPixelInfo(*image,&fill); |
cristy | 9d8c8ce | 2011-10-25 16:13:52 +0000 | [diff] [blame] | 681 | fill=(*image)->background_color; |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 682 | attenuate=1.0; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 683 | compose=(*image)->compose; |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 684 | interpolate_method=UndefinedInterpolatePixel; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 685 | channel=mogrify_info->channel; |
| 686 | format=GetImageOption(mogrify_info,"format"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 687 | SetGeometry(*image,®ion_geometry); |
| 688 | region_image=NewImageList(); |
| 689 | /* |
| 690 | Transmogrify the image. |
| 691 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 692 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 693 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 694 | Image |
| 695 | *mogrify_image; |
| 696 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 697 | ssize_t |
| 698 | count; |
| 699 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 700 | option=argv[i]; |
| 701 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 702 | continue; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 703 | count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option), |
| 704 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 705 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 706 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 707 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 708 | mogrify_image=(Image *)NULL; |
| 709 | switch (*(option+1)) |
| 710 | { |
| 711 | case 'a': |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 712 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 713 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 714 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 715 | /* |
| 716 | Adaptive blur image. |
| 717 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 718 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 719 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 720 | if ((flags & SigmaValue) == 0) |
| 721 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 722 | if ((flags & XiValue) == 0) |
| 723 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 724 | mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho, |
cristy | 4c11c2b | 2011-09-05 20:17:07 +0000 | [diff] [blame] | 725 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 726 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 727 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 728 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 729 | { |
| 730 | /* |
| 731 | Adaptive resize image. |
| 732 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 733 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 734 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 735 | mogrify_image=AdaptiveResizeImage(*image,geometry.width, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 736 | geometry.height,interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 737 | break; |
| 738 | } |
| 739 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 740 | { |
| 741 | /* |
| 742 | Adaptive sharpen image. |
| 743 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 744 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 745 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 746 | if ((flags & SigmaValue) == 0) |
| 747 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 748 | if ((flags & XiValue) == 0) |
| 749 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 750 | mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho, |
cristy | 4c11c2b | 2011-09-05 20:17:07 +0000 | [diff] [blame] | 751 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 752 | break; |
| 753 | } |
| 754 | if (LocaleCompare("affine",option+1) == 0) |
| 755 | { |
| 756 | /* |
| 757 | Affine matrix. |
| 758 | */ |
| 759 | if (*option == '+') |
| 760 | { |
| 761 | GetAffineMatrix(&draw_info->affine); |
| 762 | break; |
| 763 | } |
| 764 | (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); |
| 765 | break; |
| 766 | } |
| 767 | if (LocaleCompare("alpha",option+1) == 0) |
| 768 | { |
| 769 | AlphaChannelType |
| 770 | alpha_type; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 771 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 772 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 773 | alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions, |
| 774 | MagickFalse,argv[i+1]); |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 775 | (void) SetImageAlphaChannel(*image,alpha_type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 776 | break; |
| 777 | } |
| 778 | if (LocaleCompare("annotate",option+1) == 0) |
| 779 | { |
| 780 | char |
| 781 | *text, |
| 782 | geometry[MaxTextExtent]; |
| 783 | |
| 784 | /* |
| 785 | Annotate image. |
| 786 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 787 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 788 | SetGeometryInfo(&geometry_info); |
| 789 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 790 | if ((flags & SigmaValue) == 0) |
| 791 | geometry_info.sigma=geometry_info.rho; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 792 | text=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 793 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 794 | if (text == (char *) NULL) |
| 795 | break; |
| 796 | (void) CloneString(&draw_info->text,text); |
| 797 | text=DestroyString(text); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 798 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 799 | geometry_info.xi,geometry_info.psi); |
| 800 | (void) CloneString(&draw_info->geometry,geometry); |
| 801 | draw_info->affine.sx=cos(DegreesToRadians( |
| 802 | fmod(geometry_info.rho,360.0))); |
| 803 | draw_info->affine.rx=sin(DegreesToRadians( |
| 804 | fmod(geometry_info.rho,360.0))); |
| 805 | draw_info->affine.ry=(-sin(DegreesToRadians( |
| 806 | fmod(geometry_info.sigma,360.0)))); |
| 807 | draw_info->affine.sy=cos(DegreesToRadians( |
| 808 | fmod(geometry_info.sigma,360.0))); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 809 | (void) AnnotateImage(*image,draw_info,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 810 | break; |
| 811 | } |
| 812 | if (LocaleCompare("antialias",option+1) == 0) |
| 813 | { |
| 814 | draw_info->stroke_antialias=(*option == '-') ? MagickTrue : |
| 815 | MagickFalse; |
| 816 | draw_info->text_antialias=(*option == '-') ? MagickTrue : |
| 817 | MagickFalse; |
| 818 | break; |
| 819 | } |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 820 | if (LocaleCompare("attenuate",option+1) == 0) |
| 821 | { |
| 822 | if (*option == '+') |
| 823 | { |
| 824 | attenuate=1.0; |
| 825 | break; |
| 826 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 827 | attenuate=StringToDouble(argv[i+1],(char **) NULL); |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 828 | break; |
| 829 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 830 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 831 | { |
| 832 | /* |
| 833 | Auto Adjust Gamma of image based on its mean |
| 834 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 835 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9511120 | 2011-08-09 19:41:42 +0000 | [diff] [blame] | 836 | (void) AutoGammaImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 837 | break; |
| 838 | } |
| 839 | if (LocaleCompare("auto-level",option+1) == 0) |
| 840 | { |
| 841 | /* |
| 842 | Perfectly Normalize (max/min stretch) the image |
| 843 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 844 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9511120 | 2011-08-09 19:41:42 +0000 | [diff] [blame] | 845 | (void) AutoLevelImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 846 | break; |
| 847 | } |
| 848 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 849 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 850 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 851 | switch ((*image)->orientation) |
| 852 | { |
| 853 | case TopRightOrientation: |
| 854 | { |
| 855 | mogrify_image=FlopImage(*image,exception); |
| 856 | break; |
| 857 | } |
| 858 | case BottomRightOrientation: |
| 859 | { |
| 860 | mogrify_image=RotateImage(*image,180.0,exception); |
| 861 | break; |
| 862 | } |
| 863 | case BottomLeftOrientation: |
| 864 | { |
| 865 | mogrify_image=FlipImage(*image,exception); |
| 866 | break; |
| 867 | } |
| 868 | case LeftTopOrientation: |
| 869 | { |
| 870 | mogrify_image=TransposeImage(*image,exception); |
| 871 | break; |
| 872 | } |
| 873 | case RightTopOrientation: |
| 874 | { |
| 875 | mogrify_image=RotateImage(*image,90.0,exception); |
| 876 | break; |
| 877 | } |
| 878 | case RightBottomOrientation: |
| 879 | { |
| 880 | mogrify_image=TransverseImage(*image,exception); |
| 881 | break; |
| 882 | } |
| 883 | case LeftBottomOrientation: |
| 884 | { |
| 885 | mogrify_image=RotateImage(*image,270.0,exception); |
| 886 | break; |
| 887 | } |
| 888 | default: |
| 889 | break; |
| 890 | } |
| 891 | if (mogrify_image != (Image *) NULL) |
| 892 | mogrify_image->orientation=TopLeftOrientation; |
| 893 | break; |
| 894 | } |
| 895 | break; |
| 896 | } |
| 897 | case 'b': |
| 898 | { |
| 899 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 900 | { |
| 901 | /* |
| 902 | Black threshold image. |
| 903 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 904 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 905 | (void) BlackThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 906 | break; |
| 907 | } |
| 908 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 909 | { |
| 910 | /* |
| 911 | Blue shift image. |
| 912 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 913 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 914 | geometry_info.rho=1.5; |
| 915 | if (*option == '-') |
| 916 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 917 | mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception); |
| 918 | break; |
| 919 | } |
| 920 | if (LocaleCompare("blur",option+1) == 0) |
| 921 | { |
| 922 | /* |
| 923 | Gaussian blur image. |
| 924 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 925 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 926 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 927 | if ((flags & SigmaValue) == 0) |
| 928 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 929 | if ((flags & XiValue) == 0) |
| 930 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 931 | mogrify_image=BlurImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 932 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 933 | break; |
| 934 | } |
| 935 | if (LocaleCompare("border",option+1) == 0) |
| 936 | { |
| 937 | /* |
| 938 | Surround image with a border of solid color. |
| 939 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 940 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 941 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 942 | if ((flags & SigmaValue) == 0) |
| 943 | geometry.height=geometry.width; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 944 | mogrify_image=BorderImage(*image,&geometry,compose,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 945 | break; |
| 946 | } |
| 947 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 948 | { |
| 949 | if (*option == '+') |
| 950 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 951 | (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 952 | &draw_info->border_color,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 953 | break; |
| 954 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 955 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 956 | &draw_info->border_color,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 957 | break; |
| 958 | } |
| 959 | if (LocaleCompare("box",option+1) == 0) |
| 960 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 961 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 962 | &draw_info->undercolor,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 963 | break; |
| 964 | } |
| 965 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 966 | { |
| 967 | double |
| 968 | brightness, |
| 969 | contrast; |
| 970 | |
| 971 | GeometryInfo |
| 972 | geometry_info; |
| 973 | |
| 974 | MagickStatusType |
| 975 | flags; |
| 976 | |
| 977 | /* |
| 978 | Brightness / contrast image. |
| 979 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 980 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 981 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 982 | brightness=geometry_info.rho; |
| 983 | contrast=0.0; |
| 984 | if ((flags & SigmaValue) != 0) |
| 985 | contrast=geometry_info.sigma; |
cristy | 444eda6 | 2011-08-10 02:07:46 +0000 | [diff] [blame] | 986 | (void) BrightnessContrastImage(*image,brightness,contrast, |
| 987 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 988 | break; |
| 989 | } |
| 990 | break; |
| 991 | } |
| 992 | case 'c': |
| 993 | { |
| 994 | if (LocaleCompare("cdl",option+1) == 0) |
| 995 | { |
| 996 | char |
| 997 | *color_correction_collection; |
| 998 | |
| 999 | /* |
| 1000 | Color correct with a color decision list. |
| 1001 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1002 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1003 | color_correction_collection=FileToString(argv[i+1],~0,exception); |
| 1004 | if (color_correction_collection == (char *) NULL) |
| 1005 | break; |
cristy | 1bfa9f0 | 2011-08-11 02:35:43 +0000 | [diff] [blame] | 1006 | (void) ColorDecisionListImage(*image,color_correction_collection, |
| 1007 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1008 | break; |
| 1009 | } |
| 1010 | if (LocaleCompare("channel",option+1) == 0) |
| 1011 | { |
| 1012 | if (*option == '+') |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 1013 | channel=DefaultChannels; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1014 | else |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 1015 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1016 | SetPixelChannelMap(*image,channel); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1017 | break; |
| 1018 | } |
| 1019 | if (LocaleCompare("charcoal",option+1) == 0) |
| 1020 | { |
| 1021 | /* |
| 1022 | Charcoal image. |
| 1023 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1024 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1025 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1026 | if ((flags & SigmaValue) == 0) |
| 1027 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1028 | if ((flags & XiValue) == 0) |
| 1029 | geometry_info.xi=1.0; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1030 | mogrify_image=CharcoalImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1031 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1032 | break; |
| 1033 | } |
| 1034 | if (LocaleCompare("chop",option+1) == 0) |
| 1035 | { |
| 1036 | /* |
| 1037 | Chop the image. |
| 1038 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1039 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1040 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1041 | mogrify_image=ChopImage(*image,&geometry,exception); |
| 1042 | break; |
| 1043 | } |
| 1044 | if (LocaleCompare("clamp",option+1) == 0) |
| 1045 | { |
| 1046 | /* |
| 1047 | Clamp image. |
| 1048 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1049 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 092d71c | 2011-10-14 18:01:29 +0000 | [diff] [blame] | 1050 | (void) ClampImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1051 | break; |
| 1052 | } |
| 1053 | if (LocaleCompare("clip",option+1) == 0) |
| 1054 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1055 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1056 | if (*option == '+') |
| 1057 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1058 | (void) SetImageClipMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1059 | break; |
| 1060 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1061 | (void) ClipImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1062 | break; |
| 1063 | } |
| 1064 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1065 | { |
| 1066 | CacheView |
| 1067 | *mask_view; |
| 1068 | |
| 1069 | Image |
| 1070 | *mask_image; |
| 1071 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1072 | register Quantum |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1073 | *restrict q; |
| 1074 | |
| 1075 | register ssize_t |
| 1076 | x; |
| 1077 | |
| 1078 | ssize_t |
| 1079 | y; |
| 1080 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1081 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1082 | if (*option == '+') |
| 1083 | { |
| 1084 | /* |
| 1085 | Remove a mask. |
| 1086 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1087 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1088 | break; |
| 1089 | } |
| 1090 | /* |
| 1091 | Set the image mask. |
| 1092 | FUTURE: This Should Be a SetImageAlphaChannel() call, Or two. |
| 1093 | */ |
| 1094 | mask_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1095 | if (mask_image == (Image *) NULL) |
| 1096 | break; |
cristy | 574cc26 | 2011-08-05 01:23:58 +0000 | [diff] [blame] | 1097 | if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1098 | return(MagickFalse); |
| 1099 | mask_view=AcquireCacheView(mask_image); |
| 1100 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1101 | { |
| 1102 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1103 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 1104 | if (q == (Quantum *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1105 | break; |
| 1106 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1107 | { |
| 1108 | if (mask_image->matte == MagickFalse) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1109 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 1110 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1111 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1112 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1113 | q+=GetPixelChannels(mask_image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1114 | } |
| 1115 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
| 1116 | break; |
| 1117 | } |
| 1118 | mask_view=DestroyCacheView(mask_view); |
| 1119 | mask_image->matte=MagickTrue; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1120 | (void) SetImageClipMask(*image,mask_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1121 | break; |
| 1122 | } |
| 1123 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1124 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1125 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1126 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1127 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1128 | break; |
| 1129 | } |
| 1130 | if (LocaleCompare("colorize",option+1) == 0) |
| 1131 | { |
| 1132 | /* |
| 1133 | Colorize the image. |
| 1134 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1135 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | c7e6ff6 | 2011-10-03 13:46:11 +0000 | [diff] [blame] | 1136 | mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1137 | break; |
| 1138 | } |
| 1139 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1140 | { |
| 1141 | KernelInfo |
| 1142 | *kernel; |
| 1143 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1144 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1145 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1146 | if (kernel == (KernelInfo *) NULL) |
| 1147 | break; |
| 1148 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 1149 | kernel=DestroyKernelInfo(kernel); |
| 1150 | break; |
| 1151 | } |
| 1152 | if (LocaleCompare("colors",option+1) == 0) |
| 1153 | { |
| 1154 | /* |
| 1155 | Reduce the number of colors in the image. |
| 1156 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1157 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1158 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
| 1159 | if (quantize_info->number_colors == 0) |
| 1160 | break; |
| 1161 | if (((*image)->storage_class == DirectClass) || |
| 1162 | (*image)->colors > quantize_info->number_colors) |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1163 | (void) QuantizeImage(quantize_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1164 | else |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1165 | (void) CompressImageColormap(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1166 | break; |
| 1167 | } |
| 1168 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1169 | { |
| 1170 | ColorspaceType |
| 1171 | colorspace; |
| 1172 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1173 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1174 | if (*option == '+') |
| 1175 | { |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 1176 | (void) TransformImageColorspace(*image,RGBColorspace,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1177 | break; |
| 1178 | } |
| 1179 | colorspace=(ColorspaceType) ParseCommandOption( |
| 1180 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 1181 | (void) TransformImageColorspace(*image,colorspace,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1182 | break; |
| 1183 | } |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1184 | if (LocaleCompare("compose",option+1) == 0) |
| 1185 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1186 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1187 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 1188 | MagickFalse,argv[i+1]); |
| 1189 | break; |
| 1190 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1191 | if (LocaleCompare("contrast",option+1) == 0) |
| 1192 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1193 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1194 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1195 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1196 | break; |
| 1197 | } |
| 1198 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1199 | { |
| 1200 | double |
| 1201 | black_point, |
| 1202 | white_point; |
| 1203 | |
| 1204 | MagickStatusType |
| 1205 | flags; |
| 1206 | |
| 1207 | /* |
| 1208 | Contrast stretch image. |
| 1209 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1210 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1211 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1212 | black_point=geometry_info.rho; |
| 1213 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1214 | black_point; |
| 1215 | if ((flags & PercentValue) != 0) |
| 1216 | { |
| 1217 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1218 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1219 | } |
| 1220 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1221 | white_point; |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1222 | (void) ContrastStretchImage(*image,black_point,white_point, |
| 1223 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1224 | break; |
| 1225 | } |
| 1226 | if (LocaleCompare("convolve",option+1) == 0) |
| 1227 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1228 | KernelInfo |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1229 | *kernel_info; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1230 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1231 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1232 | kernel_info=AcquireKernelInfo(argv[i+1]); |
| 1233 | if (kernel_info == (KernelInfo *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1234 | break; |
cristy | 0a92238 | 2011-07-16 15:30:34 +0000 | [diff] [blame] | 1235 | kernel_info->bias=(*image)->bias; |
cristy | 5e6be1e | 2011-07-16 01:23:39 +0000 | [diff] [blame] | 1236 | mogrify_image=ConvolveImage(*image,kernel_info,exception); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1237 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1238 | break; |
| 1239 | } |
| 1240 | if (LocaleCompare("crop",option+1) == 0) |
| 1241 | { |
| 1242 | /* |
| 1243 | Crop a image to a smaller size |
| 1244 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1245 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1246 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1247 | break; |
| 1248 | } |
| 1249 | if (LocaleCompare("cycle",option+1) == 0) |
| 1250 | { |
| 1251 | /* |
| 1252 | Cycle an image colormap. |
| 1253 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1254 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1255 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]), |
| 1256 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1257 | break; |
| 1258 | } |
| 1259 | break; |
| 1260 | } |
| 1261 | case 'd': |
| 1262 | { |
| 1263 | if (LocaleCompare("decipher",option+1) == 0) |
| 1264 | { |
| 1265 | StringInfo |
| 1266 | *passkey; |
| 1267 | |
| 1268 | /* |
| 1269 | Decipher pixels. |
| 1270 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1271 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1272 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1273 | if (passkey != (StringInfo *) NULL) |
| 1274 | { |
| 1275 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1276 | passkey=DestroyStringInfo(passkey); |
| 1277 | } |
| 1278 | break; |
| 1279 | } |
| 1280 | if (LocaleCompare("density",option+1) == 0) |
| 1281 | { |
| 1282 | /* |
| 1283 | Set image density. |
| 1284 | */ |
| 1285 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1286 | break; |
| 1287 | } |
| 1288 | if (LocaleCompare("depth",option+1) == 0) |
| 1289 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1290 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1291 | if (*option == '+') |
| 1292 | { |
cristy | 8a11cb1 | 2011-10-19 23:53:34 +0000 | [diff] [blame] | 1293 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1294 | break; |
| 1295 | } |
cristy | 8a11cb1 | 2011-10-19 23:53:34 +0000 | [diff] [blame] | 1296 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]), |
| 1297 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1298 | break; |
| 1299 | } |
| 1300 | if (LocaleCompare("deskew",option+1) == 0) |
| 1301 | { |
| 1302 | double |
| 1303 | threshold; |
| 1304 | |
| 1305 | /* |
| 1306 | Straighten the image. |
| 1307 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1308 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1309 | if (*option == '+') |
| 1310 | threshold=40.0*QuantumRange/100.0; |
| 1311 | else |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 1312 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 1313 | 1.0); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1314 | mogrify_image=DeskewImage(*image,threshold,exception); |
| 1315 | break; |
| 1316 | } |
| 1317 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1318 | { |
| 1319 | /* |
| 1320 | Reduce the speckles within an image. |
| 1321 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1322 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1323 | mogrify_image=DespeckleImage(*image,exception); |
| 1324 | break; |
| 1325 | } |
| 1326 | if (LocaleCompare("display",option+1) == 0) |
| 1327 | { |
| 1328 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1329 | break; |
| 1330 | } |
| 1331 | if (LocaleCompare("distort",option+1) == 0) |
| 1332 | { |
| 1333 | char |
| 1334 | *args, |
| 1335 | token[MaxTextExtent]; |
| 1336 | |
| 1337 | const char |
| 1338 | *p; |
| 1339 | |
| 1340 | DistortImageMethod |
| 1341 | method; |
| 1342 | |
| 1343 | double |
| 1344 | *arguments; |
| 1345 | |
| 1346 | register ssize_t |
| 1347 | x; |
| 1348 | |
| 1349 | size_t |
| 1350 | number_arguments; |
| 1351 | |
| 1352 | /* |
| 1353 | Distort image. |
| 1354 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1355 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1356 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, |
| 1357 | MagickFalse,argv[i+1]); |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1358 | if (method == ResizeDistortion) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1359 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1360 | double |
| 1361 | resize_args[2]; |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1362 | |
| 1363 | /* |
| 1364 | Special Case - Argument is actually a resize geometry! |
| 1365 | Convert that to an appropriate distortion argument array. |
| 1366 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1367 | (void) ParseRegionGeometry(*image,argv[i+2],&geometry, |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1368 | exception); |
| 1369 | resize_args[0]=(double) geometry.width; |
| 1370 | resize_args[1]=(double) geometry.height; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1371 | mogrify_image=DistortImage(*image,method,(size_t)2, |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1372 | resize_args,MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1373 | break; |
| 1374 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1375 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1376 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1377 | if (args == (char *) NULL) |
| 1378 | break; |
| 1379 | p=(char *) args; |
| 1380 | for (x=0; *p != '\0'; x++) |
| 1381 | { |
| 1382 | GetMagickToken(p,&p,token); |
| 1383 | if (*token == ',') |
| 1384 | GetMagickToken(p,&p,token); |
| 1385 | } |
| 1386 | number_arguments=(size_t) x; |
| 1387 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1388 | sizeof(*arguments)); |
| 1389 | if (arguments == (double *) NULL) |
| 1390 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1391 | "MemoryAllocationFailed",(*image)->filename); |
| 1392 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1393 | sizeof(*arguments)); |
| 1394 | p=(char *) args; |
| 1395 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 1396 | { |
| 1397 | GetMagickToken(p,&p,token); |
| 1398 | if (*token == ',') |
| 1399 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1400 | arguments[x]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1401 | } |
| 1402 | args=DestroyString(args); |
| 1403 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
| 1404 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1405 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1406 | break; |
| 1407 | } |
| 1408 | if (LocaleCompare("dither",option+1) == 0) |
| 1409 | { |
| 1410 | if (*option == '+') |
| 1411 | { |
| 1412 | quantize_info->dither=MagickFalse; |
| 1413 | break; |
| 1414 | } |
| 1415 | quantize_info->dither=MagickTrue; |
| 1416 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
| 1417 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1418 | if (quantize_info->dither_method == NoDitherMethod) |
| 1419 | quantize_info->dither=MagickFalse; |
| 1420 | break; |
| 1421 | } |
| 1422 | if (LocaleCompare("draw",option+1) == 0) |
| 1423 | { |
| 1424 | /* |
| 1425 | Draw image. |
| 1426 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1427 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1428 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1429 | (void) DrawImage(*image,draw_info,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1430 | break; |
| 1431 | } |
| 1432 | break; |
| 1433 | } |
| 1434 | case 'e': |
| 1435 | { |
| 1436 | if (LocaleCompare("edge",option+1) == 0) |
| 1437 | { |
| 1438 | /* |
| 1439 | Enhance edges in the image. |
| 1440 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1441 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1442 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1443 | if ((flags & SigmaValue) == 0) |
| 1444 | geometry_info.sigma=1.0; |
cristy | 8ae632d | 2011-09-05 17:29:53 +0000 | [diff] [blame] | 1445 | mogrify_image=EdgeImage(*image,geometry_info.rho, |
| 1446 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1447 | break; |
| 1448 | } |
| 1449 | if (LocaleCompare("emboss",option+1) == 0) |
| 1450 | { |
| 1451 | /* |
| 1452 | Gaussian embossen image. |
| 1453 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1454 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1455 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1456 | if ((flags & SigmaValue) == 0) |
| 1457 | geometry_info.sigma=1.0; |
| 1458 | mogrify_image=EmbossImage(*image,geometry_info.rho, |
| 1459 | geometry_info.sigma,exception); |
| 1460 | break; |
| 1461 | } |
| 1462 | if (LocaleCompare("encipher",option+1) == 0) |
| 1463 | { |
| 1464 | StringInfo |
| 1465 | *passkey; |
| 1466 | |
| 1467 | /* |
| 1468 | Encipher pixels. |
| 1469 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1470 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1471 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1472 | if (passkey != (StringInfo *) NULL) |
| 1473 | { |
| 1474 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1475 | passkey=DestroyStringInfo(passkey); |
| 1476 | } |
| 1477 | break; |
| 1478 | } |
| 1479 | if (LocaleCompare("encoding",option+1) == 0) |
| 1480 | { |
| 1481 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1482 | break; |
| 1483 | } |
| 1484 | if (LocaleCompare("enhance",option+1) == 0) |
| 1485 | { |
| 1486 | /* |
| 1487 | Enhance image. |
| 1488 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1489 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1490 | mogrify_image=EnhanceImage(*image,exception); |
| 1491 | break; |
| 1492 | } |
| 1493 | if (LocaleCompare("equalize",option+1) == 0) |
| 1494 | { |
| 1495 | /* |
| 1496 | Equalize image. |
| 1497 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1498 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 6d8c3d7 | 2011-08-22 01:20:01 +0000 | [diff] [blame] | 1499 | (void) EqualizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1500 | break; |
| 1501 | } |
| 1502 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1503 | { |
| 1504 | double |
| 1505 | constant; |
| 1506 | |
| 1507 | MagickEvaluateOperator |
| 1508 | op; |
| 1509 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1510 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1511 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 1512 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 1513 | constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+ |
| 1514 | 1.0); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1515 | (void) EvaluateImage(*image,op,constant,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1516 | break; |
| 1517 | } |
| 1518 | if (LocaleCompare("extent",option+1) == 0) |
| 1519 | { |
| 1520 | /* |
| 1521 | Set the image extent. |
| 1522 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1523 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1524 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1525 | if (geometry.width == 0) |
| 1526 | geometry.width=(*image)->columns; |
| 1527 | if (geometry.height == 0) |
| 1528 | geometry.height=(*image)->rows; |
| 1529 | mogrify_image=ExtentImage(*image,&geometry,exception); |
| 1530 | break; |
| 1531 | } |
| 1532 | break; |
| 1533 | } |
| 1534 | case 'f': |
| 1535 | { |
| 1536 | if (LocaleCompare("family",option+1) == 0) |
| 1537 | { |
| 1538 | if (*option == '+') |
| 1539 | { |
| 1540 | if (draw_info->family != (char *) NULL) |
| 1541 | draw_info->family=DestroyString(draw_info->family); |
| 1542 | break; |
| 1543 | } |
| 1544 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1545 | break; |
| 1546 | } |
| 1547 | if (LocaleCompare("features",option+1) == 0) |
| 1548 | { |
| 1549 | if (*option == '+') |
| 1550 | { |
| 1551 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1552 | break; |
| 1553 | } |
| 1554 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1555 | break; |
| 1556 | } |
| 1557 | if (LocaleCompare("fill",option+1) == 0) |
| 1558 | { |
| 1559 | ExceptionInfo |
| 1560 | *sans; |
| 1561 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1562 | GetPixelInfo(*image,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1563 | if (*option == '+') |
| 1564 | { |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1565 | (void) QueryColorCompliance("none",AllCompliance,&fill, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1566 | exception); |
| 1567 | (void) QueryColorCompliance("none",AllCompliance, |
| 1568 | &draw_info->fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1569 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1570 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1571 | break; |
| 1572 | } |
| 1573 | sans=AcquireExceptionInfo(); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1574 | (void) QueryColorCompliance(argv[i+1],AllCompliance,&fill, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1575 | sans); |
| 1576 | status=QueryColorCompliance(argv[i+1],AllCompliance, |
| 1577 | &draw_info->fill,sans); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1578 | sans=DestroyExceptionInfo(sans); |
| 1579 | if (status == MagickFalse) |
| 1580 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 1581 | exception); |
| 1582 | break; |
| 1583 | } |
| 1584 | if (LocaleCompare("flip",option+1) == 0) |
| 1585 | { |
| 1586 | /* |
| 1587 | Flip image scanlines. |
| 1588 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1589 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1590 | mogrify_image=FlipImage(*image,exception); |
| 1591 | break; |
| 1592 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1593 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1594 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1595 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1596 | target; |
| 1597 | |
| 1598 | /* |
| 1599 | Floodfill image. |
| 1600 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1601 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1602 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1603 | (void) QueryColorCompliance(argv[i+2],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1604 | exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1605 | (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x, |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 1606 | geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1607 | break; |
| 1608 | } |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1609 | if (LocaleCompare("flop",option+1) == 0) |
| 1610 | { |
| 1611 | /* |
| 1612 | Flop image scanlines. |
| 1613 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1614 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1615 | mogrify_image=FlopImage(*image,exception); |
| 1616 | break; |
| 1617 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1618 | if (LocaleCompare("font",option+1) == 0) |
| 1619 | { |
| 1620 | if (*option == '+') |
| 1621 | { |
| 1622 | if (draw_info->font != (char *) NULL) |
| 1623 | draw_info->font=DestroyString(draw_info->font); |
| 1624 | break; |
| 1625 | } |
| 1626 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1627 | break; |
| 1628 | } |
| 1629 | if (LocaleCompare("format",option+1) == 0) |
| 1630 | { |
| 1631 | format=argv[i+1]; |
| 1632 | break; |
| 1633 | } |
| 1634 | if (LocaleCompare("frame",option+1) == 0) |
| 1635 | { |
| 1636 | FrameInfo |
| 1637 | frame_info; |
| 1638 | |
| 1639 | /* |
| 1640 | Surround image with an ornamental border. |
| 1641 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1642 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1643 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1644 | frame_info.width=geometry.width; |
| 1645 | frame_info.height=geometry.height; |
| 1646 | if ((flags & HeightValue) == 0) |
| 1647 | frame_info.height=geometry.width; |
| 1648 | frame_info.outer_bevel=geometry.x; |
| 1649 | frame_info.inner_bevel=geometry.y; |
| 1650 | frame_info.x=(ssize_t) frame_info.width; |
| 1651 | frame_info.y=(ssize_t) frame_info.height; |
| 1652 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1653 | frame_info.height=(*image)->rows+2*frame_info.height; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1654 | mogrify_image=FrameImage(*image,&frame_info,compose,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1655 | break; |
| 1656 | } |
| 1657 | if (LocaleCompare("function",option+1) == 0) |
| 1658 | { |
| 1659 | char |
| 1660 | *arguments, |
| 1661 | token[MaxTextExtent]; |
| 1662 | |
| 1663 | const char |
| 1664 | *p; |
| 1665 | |
| 1666 | double |
| 1667 | *parameters; |
| 1668 | |
| 1669 | MagickFunction |
| 1670 | function; |
| 1671 | |
| 1672 | register ssize_t |
| 1673 | x; |
| 1674 | |
| 1675 | size_t |
| 1676 | number_parameters; |
| 1677 | |
| 1678 | /* |
| 1679 | Function Modify Image Values |
| 1680 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1681 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1682 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, |
| 1683 | MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1684 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1685 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1686 | if (arguments == (char *) NULL) |
| 1687 | break; |
| 1688 | p=(char *) arguments; |
| 1689 | for (x=0; *p != '\0'; x++) |
| 1690 | { |
| 1691 | GetMagickToken(p,&p,token); |
| 1692 | if (*token == ',') |
| 1693 | GetMagickToken(p,&p,token); |
| 1694 | } |
| 1695 | number_parameters=(size_t) x; |
| 1696 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1697 | sizeof(*parameters)); |
| 1698 | if (parameters == (double *) NULL) |
| 1699 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1700 | "MemoryAllocationFailed",(*image)->filename); |
| 1701 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1702 | sizeof(*parameters)); |
| 1703 | p=(char *) arguments; |
| 1704 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
| 1705 | { |
| 1706 | GetMagickToken(p,&p,token); |
| 1707 | if (*token == ',') |
| 1708 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1709 | parameters[x]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1710 | } |
| 1711 | arguments=DestroyString(arguments); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1712 | (void) FunctionImage(*image,function,number_parameters,parameters, |
| 1713 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1714 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1715 | break; |
| 1716 | } |
| 1717 | break; |
| 1718 | } |
| 1719 | case 'g': |
| 1720 | { |
| 1721 | if (LocaleCompare("gamma",option+1) == 0) |
| 1722 | { |
| 1723 | /* |
| 1724 | Gamma image. |
| 1725 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1726 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1727 | if (*option == '+') |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1728 | (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1729 | else |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1730 | (void) GammaImage(*image,StringToDouble(argv[i+1], |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 1731 | (char **) NULL),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1732 | break; |
| 1733 | } |
| 1734 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1735 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1736 | { |
| 1737 | /* |
| 1738 | Gaussian blur image. |
| 1739 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1740 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1741 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1742 | if ((flags & SigmaValue) == 0) |
| 1743 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1744 | if ((flags & XiValue) == 0) |
| 1745 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1746 | mogrify_image=GaussianBlurImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1747 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1748 | break; |
| 1749 | } |
| 1750 | if (LocaleCompare("geometry",option+1) == 0) |
| 1751 | { |
| 1752 | /* |
| 1753 | Record Image offset, Resize last image. |
| 1754 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1755 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1756 | if (*option == '+') |
| 1757 | { |
| 1758 | if ((*image)->geometry != (char *) NULL) |
| 1759 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1760 | break; |
| 1761 | } |
| 1762 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1763 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1764 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1765 | else |
| 1766 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 1767 | (*image)->filter,(*image)->blur,exception); |
| 1768 | break; |
| 1769 | } |
| 1770 | if (LocaleCompare("gravity",option+1) == 0) |
| 1771 | { |
| 1772 | if (*option == '+') |
| 1773 | { |
| 1774 | draw_info->gravity=UndefinedGravity; |
| 1775 | break; |
| 1776 | } |
| 1777 | draw_info->gravity=(GravityType) ParseCommandOption( |
| 1778 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1779 | break; |
| 1780 | } |
| 1781 | break; |
| 1782 | } |
| 1783 | case 'h': |
| 1784 | { |
| 1785 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1786 | { |
| 1787 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1788 | break; |
| 1789 | } |
| 1790 | break; |
| 1791 | } |
| 1792 | case 'i': |
| 1793 | { |
| 1794 | if (LocaleCompare("identify",option+1) == 0) |
| 1795 | { |
| 1796 | char |
| 1797 | *text; |
| 1798 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1799 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1800 | if (format == (char *) NULL) |
| 1801 | { |
cristy | a403727 | 2011-08-28 15:11:39 +0000 | [diff] [blame] | 1802 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose, |
| 1803 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1804 | break; |
| 1805 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1806 | text=InterpretImageProperties(mogrify_info,*image,format, |
| 1807 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1808 | if (text == (char *) NULL) |
| 1809 | break; |
| 1810 | (void) fputs(text,stdout); |
| 1811 | (void) fputc('\n',stdout); |
| 1812 | text=DestroyString(text); |
| 1813 | break; |
| 1814 | } |
| 1815 | if (LocaleCompare("implode",option+1) == 0) |
| 1816 | { |
| 1817 | /* |
| 1818 | Implode image. |
| 1819 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1820 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1821 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 76f512e | 2011-09-12 01:26:56 +0000 | [diff] [blame] | 1822 | mogrify_image=ImplodeImage(*image,geometry_info.rho, |
| 1823 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1824 | break; |
| 1825 | } |
| 1826 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1827 | { |
| 1828 | if (*option == '+') |
| 1829 | (void) ParseGeometry("0",&geometry_info); |
| 1830 | else |
| 1831 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1832 | draw_info->interline_spacing=geometry_info.rho; |
| 1833 | break; |
| 1834 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 1835 | if (LocaleCompare("interpolate",option+1) == 0) |
| 1836 | { |
| 1837 | interpolate_method=(PixelInterpolateMethod) ParseCommandOption( |
| 1838 | MagickInterpolateOptions,MagickFalse,argv[i+1]); |
| 1839 | break; |
| 1840 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1841 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1842 | { |
| 1843 | if (*option == '+') |
| 1844 | (void) ParseGeometry("0",&geometry_info); |
| 1845 | else |
| 1846 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1847 | draw_info->interword_spacing=geometry_info.rho; |
| 1848 | break; |
| 1849 | } |
| 1850 | break; |
| 1851 | } |
| 1852 | case 'k': |
| 1853 | { |
| 1854 | if (LocaleCompare("kerning",option+1) == 0) |
| 1855 | { |
| 1856 | if (*option == '+') |
| 1857 | (void) ParseGeometry("0",&geometry_info); |
| 1858 | else |
| 1859 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1860 | draw_info->kerning=geometry_info.rho; |
| 1861 | break; |
| 1862 | } |
| 1863 | break; |
| 1864 | } |
| 1865 | case 'l': |
| 1866 | { |
| 1867 | if (LocaleCompare("lat",option+1) == 0) |
| 1868 | { |
| 1869 | /* |
| 1870 | Local adaptive threshold image. |
| 1871 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1872 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1873 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1874 | if ((flags & PercentValue) != 0) |
| 1875 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 1876 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
cristy | de5cc63 | 2011-07-18 14:47:00 +0000 | [diff] [blame] | 1877 | geometry_info.rho,(size_t) geometry_info.sigma,(double) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1878 | geometry_info.xi,exception); |
| 1879 | break; |
| 1880 | } |
| 1881 | if (LocaleCompare("level",option+1) == 0) |
| 1882 | { |
| 1883 | MagickRealType |
| 1884 | black_point, |
| 1885 | gamma, |
| 1886 | white_point; |
| 1887 | |
| 1888 | MagickStatusType |
| 1889 | flags; |
| 1890 | |
| 1891 | /* |
| 1892 | Parse levels. |
| 1893 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1894 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1895 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1896 | black_point=geometry_info.rho; |
| 1897 | white_point=(MagickRealType) QuantumRange; |
| 1898 | if ((flags & SigmaValue) != 0) |
| 1899 | white_point=geometry_info.sigma; |
| 1900 | gamma=1.0; |
| 1901 | if ((flags & XiValue) != 0) |
| 1902 | gamma=geometry_info.xi; |
| 1903 | if ((flags & PercentValue) != 0) |
| 1904 | { |
| 1905 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 1906 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 1907 | } |
| 1908 | if ((flags & SigmaValue) == 0) |
| 1909 | white_point=(MagickRealType) QuantumRange-black_point; |
| 1910 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1911 | (void) LevelizeImage(*image,black_point,white_point,gamma, |
| 1912 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1913 | else |
cristy | 01e9afd | 2011-08-10 17:38:41 +0000 | [diff] [blame] | 1914 | (void) LevelImage(*image,black_point,white_point,gamma, |
| 1915 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1916 | break; |
| 1917 | } |
| 1918 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1919 | { |
| 1920 | char |
| 1921 | token[MaxTextExtent]; |
| 1922 | |
| 1923 | const char |
| 1924 | *p; |
| 1925 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1926 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1927 | black_point, |
| 1928 | white_point; |
| 1929 | |
| 1930 | p=(const char *) argv[i+1]; |
| 1931 | GetMagickToken(p,&p,token); /* get black point color */ |
| 1932 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1933 | (void) QueryColorCompliance(token,AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1934 | &black_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1935 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1936 | (void) QueryColorCompliance("#000000",AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1937 | &black_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1938 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1939 | GetMagickToken(p,&p,token); |
| 1940 | if (*token == '\0') |
| 1941 | white_point=black_point; /* set everything to that color */ |
| 1942 | else |
| 1943 | { |
| 1944 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 1945 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 1946 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1947 | (void) QueryColorCompliance(token,AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1948 | &white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1949 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1950 | (void) QueryColorCompliance("#ffffff",AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1951 | &white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1952 | } |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 1953 | (void) LevelImageColors(*image,&black_point,&white_point, |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1954 | *option == '+' ? MagickTrue : MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1955 | break; |
| 1956 | } |
| 1957 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 1958 | { |
| 1959 | double |
| 1960 | black_point, |
| 1961 | white_point; |
| 1962 | |
| 1963 | MagickStatusType |
| 1964 | flags; |
| 1965 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1966 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1967 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1968 | black_point=geometry_info.rho; |
| 1969 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 1970 | if ((flags & SigmaValue) != 0) |
| 1971 | white_point=geometry_info.sigma; |
| 1972 | if ((flags & PercentValue) != 0) |
| 1973 | { |
| 1974 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1975 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1976 | } |
| 1977 | if ((flags & SigmaValue) == 0) |
| 1978 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1979 | black_point; |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 1980 | (void) LinearStretchImage(*image,black_point,white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1981 | break; |
| 1982 | } |
| 1983 | if (LocaleCompare("linewidth",option+1) == 0) |
| 1984 | { |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 1985 | draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1986 | break; |
| 1987 | } |
| 1988 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 1989 | { |
| 1990 | /* |
| 1991 | Liquid rescale image. |
| 1992 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1993 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1994 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1995 | if ((flags & XValue) == 0) |
| 1996 | geometry.x=1; |
| 1997 | if ((flags & YValue) == 0) |
| 1998 | geometry.y=0; |
| 1999 | mogrify_image=LiquidRescaleImage(*image,geometry.width, |
| 2000 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 2001 | break; |
| 2002 | } |
| 2003 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 2004 | { |
| 2005 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 2006 | break; |
| 2007 | } |
| 2008 | break; |
| 2009 | } |
| 2010 | case 'm': |
| 2011 | { |
| 2012 | if (LocaleCompare("map",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2013 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2014 | Image |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2015 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2016 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2017 | /* |
| 2018 | Transform image colors to match this set of colors. |
| 2019 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2020 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2021 | if (*option == '+') |
| 2022 | break; |
| 2023 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2024 | if (remap_image == (Image *) NULL) |
| 2025 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2026 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2027 | remap_image=DestroyImage(remap_image); |
| 2028 | break; |
| 2029 | } |
| 2030 | if (LocaleCompare("mask",option+1) == 0) |
| 2031 | { |
| 2032 | Image |
| 2033 | *mask; |
| 2034 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2035 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2036 | if (*option == '+') |
| 2037 | { |
| 2038 | /* |
| 2039 | Remove a mask. |
| 2040 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2041 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2042 | break; |
| 2043 | } |
| 2044 | /* |
| 2045 | Set the image mask. |
| 2046 | */ |
| 2047 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2048 | if (mask == (Image *) NULL) |
| 2049 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2050 | (void) SetImageMask(*image,mask,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2051 | mask=DestroyImage(mask); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2052 | break; |
| 2053 | } |
| 2054 | if (LocaleCompare("matte",option+1) == 0) |
| 2055 | { |
| 2056 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 2057 | SetAlphaChannel : DeactivateAlphaChannel,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2058 | break; |
| 2059 | } |
| 2060 | if (LocaleCompare("median",option+1) == 0) |
| 2061 | { |
| 2062 | /* |
| 2063 | Median filter image. |
| 2064 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2065 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2066 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2067 | if ((flags & SigmaValue) == 0) |
| 2068 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2069 | mogrify_image=StatisticImage(*image,MedianStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2070 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2071 | break; |
| 2072 | } |
| 2073 | if (LocaleCompare("mode",option+1) == 0) |
| 2074 | { |
| 2075 | /* |
| 2076 | Mode image. |
| 2077 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2078 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2079 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2080 | if ((flags & SigmaValue) == 0) |
| 2081 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2082 | mogrify_image=StatisticImage(*image,ModeStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2083 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2084 | break; |
| 2085 | } |
| 2086 | if (LocaleCompare("modulate",option+1) == 0) |
| 2087 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2088 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2089 | (void) ModulateImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2090 | break; |
| 2091 | } |
| 2092 | if (LocaleCompare("monitor",option+1) == 0) |
| 2093 | { |
| 2094 | if (*option == '+') |
| 2095 | { |
| 2096 | (void) SetImageProgressMonitor(*image, |
| 2097 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2098 | break; |
| 2099 | } |
| 2100 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2101 | (void *) NULL); |
| 2102 | break; |
| 2103 | } |
| 2104 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2105 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2106 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2107 | (void) SetImageType(*image,BilevelType,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2108 | break; |
| 2109 | } |
| 2110 | if (LocaleCompare("morphology",option+1) == 0) |
| 2111 | { |
| 2112 | char |
| 2113 | token[MaxTextExtent]; |
| 2114 | |
| 2115 | const char |
| 2116 | *p; |
| 2117 | |
| 2118 | KernelInfo |
| 2119 | *kernel; |
| 2120 | |
| 2121 | MorphologyMethod |
| 2122 | method; |
| 2123 | |
| 2124 | ssize_t |
| 2125 | iterations; |
| 2126 | |
| 2127 | /* |
| 2128 | Morphological Image Operation |
| 2129 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2130 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2131 | p=argv[i+1]; |
| 2132 | GetMagickToken(p,&p,token); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2133 | method=(MorphologyMethod) ParseCommandOption( |
| 2134 | MagickMorphologyOptions,MagickFalse,token); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2135 | iterations=1L; |
| 2136 | GetMagickToken(p,&p,token); |
| 2137 | if ((*p == ':') || (*p == ',')) |
| 2138 | GetMagickToken(p,&p,token); |
| 2139 | if ((*p != '\0')) |
| 2140 | iterations=(ssize_t) StringToLong(p); |
| 2141 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2142 | if (kernel == (KernelInfo *) NULL) |
| 2143 | { |
| 2144 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2145 | OptionError,"UnabletoParseKernel","morphology"); |
| 2146 | status=MagickFalse; |
| 2147 | break; |
| 2148 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2149 | mogrify_image=MorphologyImage(*image,method,iterations,kernel, |
| 2150 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2151 | kernel=DestroyKernelInfo(kernel); |
| 2152 | break; |
| 2153 | } |
| 2154 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2155 | { |
| 2156 | /* |
| 2157 | Motion blur image. |
| 2158 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2159 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2160 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2161 | if ((flags & SigmaValue) == 0) |
| 2162 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2163 | mogrify_image=MotionBlurImage(*image,geometry_info.rho, |
cristy | f7ef025 | 2011-09-09 14:50:06 +0000 | [diff] [blame] | 2164 | geometry_info.sigma,geometry_info.xi,geometry_info.psi, |
| 2165 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2166 | break; |
| 2167 | } |
| 2168 | break; |
| 2169 | } |
| 2170 | case 'n': |
| 2171 | { |
| 2172 | if (LocaleCompare("negate",option+1) == 0) |
| 2173 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2174 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2175 | (void) NegateImage(*image,*option == '+' ? MagickTrue : |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 2176 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2177 | break; |
| 2178 | } |
| 2179 | if (LocaleCompare("noise",option+1) == 0) |
| 2180 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2181 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2182 | if (*option == '-') |
| 2183 | { |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2184 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2185 | if ((flags & SigmaValue) == 0) |
| 2186 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2187 | mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2188 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2189 | } |
| 2190 | else |
| 2191 | { |
| 2192 | NoiseType |
| 2193 | noise; |
| 2194 | |
| 2195 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
| 2196 | MagickFalse,argv[i+1]); |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 2197 | mogrify_image=AddNoiseImage(*image,noise,attenuate,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2198 | } |
| 2199 | break; |
| 2200 | } |
| 2201 | if (LocaleCompare("normalize",option+1) == 0) |
| 2202 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2203 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 2204 | (void) NormalizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2205 | break; |
| 2206 | } |
| 2207 | break; |
| 2208 | } |
| 2209 | case 'o': |
| 2210 | { |
| 2211 | if (LocaleCompare("opaque",option+1) == 0) |
| 2212 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2213 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2214 | target; |
| 2215 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2216 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2217 | (void) QueryColorCompliance(argv[i+1],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2218 | exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 2219 | (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ? |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 2220 | MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2221 | break; |
| 2222 | } |
| 2223 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2224 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2225 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 1302067 | 2011-07-08 02:33:26 +0000 | [diff] [blame] | 2226 | (void) OrderedPosterizeImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2227 | break; |
| 2228 | } |
| 2229 | break; |
| 2230 | } |
| 2231 | case 'p': |
| 2232 | { |
| 2233 | if (LocaleCompare("paint",option+1) == 0) |
| 2234 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2235 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2236 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 14973ba | 2011-08-27 23:48:07 +0000 | [diff] [blame] | 2237 | mogrify_image=OilPaintImage(*image,geometry_info.rho, |
| 2238 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2239 | break; |
| 2240 | } |
| 2241 | if (LocaleCompare("pen",option+1) == 0) |
| 2242 | { |
| 2243 | if (*option == '+') |
| 2244 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2245 | (void) QueryColorCompliance("none",AllCompliance, |
| 2246 | &draw_info->fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2247 | break; |
| 2248 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2249 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 2250 | &draw_info->fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2251 | break; |
| 2252 | } |
| 2253 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2254 | { |
| 2255 | if (*option == '+') |
| 2256 | (void) ParseGeometry("12",&geometry_info); |
| 2257 | else |
| 2258 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2259 | draw_info->pointsize=geometry_info.rho; |
| 2260 | break; |
| 2261 | } |
| 2262 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2263 | { |
| 2264 | double |
| 2265 | angle; |
| 2266 | |
| 2267 | RandomInfo |
| 2268 | *random_info; |
| 2269 | |
| 2270 | /* |
| 2271 | Simulate a Polaroid picture. |
| 2272 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2273 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2274 | random_info=AcquireRandomInfo(); |
| 2275 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2276 | random_info=DestroyRandomInfo(random_info); |
| 2277 | if (*option == '-') |
| 2278 | { |
| 2279 | SetGeometryInfo(&geometry_info); |
| 2280 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2281 | angle=geometry_info.rho; |
| 2282 | } |
cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame] | 2283 | mogrify_image=PolaroidImage(*image,draw_info,angle, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2284 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2285 | break; |
| 2286 | } |
| 2287 | if (LocaleCompare("posterize",option+1) == 0) |
| 2288 | { |
| 2289 | /* |
| 2290 | Posterize image. |
| 2291 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2292 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2293 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2294 | quantize_info->dither,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2295 | break; |
| 2296 | } |
| 2297 | if (LocaleCompare("preview",option+1) == 0) |
| 2298 | { |
| 2299 | PreviewType |
| 2300 | preview_type; |
| 2301 | |
| 2302 | /* |
| 2303 | Preview image. |
| 2304 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2305 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2306 | if (*option == '+') |
| 2307 | preview_type=UndefinedPreview; |
| 2308 | else |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2309 | preview_type=(PreviewType) ParseCommandOption( |
| 2310 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2311 | mogrify_image=PreviewImage(*image,preview_type,exception); |
| 2312 | break; |
| 2313 | } |
| 2314 | if (LocaleCompare("profile",option+1) == 0) |
| 2315 | { |
| 2316 | const char |
| 2317 | *name; |
| 2318 | |
| 2319 | const StringInfo |
| 2320 | *profile; |
| 2321 | |
| 2322 | Image |
| 2323 | *profile_image; |
| 2324 | |
| 2325 | ImageInfo |
| 2326 | *profile_info; |
| 2327 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2328 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2329 | if (*option == '+') |
| 2330 | { |
| 2331 | /* |
| 2332 | Remove a profile from the image. |
| 2333 | */ |
| 2334 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
cristy | 092d71c | 2011-10-14 18:01:29 +0000 | [diff] [blame] | 2335 | NULL,0,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2336 | break; |
| 2337 | } |
| 2338 | /* |
| 2339 | Associate a profile with the image. |
| 2340 | */ |
| 2341 | profile_info=CloneImageInfo(mogrify_info); |
| 2342 | profile=GetImageProfile(*image,"iptc"); |
| 2343 | if (profile != (StringInfo *) NULL) |
| 2344 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2345 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2346 | profile_info=DestroyImageInfo(profile_info); |
| 2347 | if (profile_image == (Image *) NULL) |
| 2348 | { |
| 2349 | StringInfo |
| 2350 | *profile; |
| 2351 | |
| 2352 | profile_info=CloneImageInfo(mogrify_info); |
| 2353 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2354 | MaxTextExtent); |
| 2355 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
| 2356 | if (profile != (StringInfo *) NULL) |
| 2357 | { |
| 2358 | (void) ProfileImage(*image,profile_info->magick, |
| 2359 | GetStringInfoDatum(profile),(size_t) |
| 2360 | GetStringInfoLength(profile),MagickFalse); |
| 2361 | profile=DestroyStringInfo(profile); |
| 2362 | } |
| 2363 | profile_info=DestroyImageInfo(profile_info); |
| 2364 | break; |
| 2365 | } |
| 2366 | ResetImageProfileIterator(profile_image); |
| 2367 | name=GetNextImageProfile(profile_image); |
| 2368 | while (name != (const char *) NULL) |
| 2369 | { |
| 2370 | profile=GetImageProfile(profile_image,name); |
| 2371 | if (profile != (StringInfo *) NULL) |
| 2372 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
| 2373 | (size_t) GetStringInfoLength(profile),MagickFalse); |
| 2374 | name=GetNextImageProfile(profile_image); |
| 2375 | } |
| 2376 | profile_image=DestroyImage(profile_image); |
| 2377 | break; |
| 2378 | } |
| 2379 | break; |
| 2380 | } |
| 2381 | case 'q': |
| 2382 | { |
| 2383 | if (LocaleCompare("quantize",option+1) == 0) |
| 2384 | { |
| 2385 | if (*option == '+') |
| 2386 | { |
| 2387 | quantize_info->colorspace=UndefinedColorspace; |
| 2388 | break; |
| 2389 | } |
| 2390 | quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
| 2391 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2392 | break; |
| 2393 | } |
| 2394 | break; |
| 2395 | } |
| 2396 | case 'r': |
| 2397 | { |
| 2398 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2399 | { |
| 2400 | /* |
| 2401 | Radial blur image. |
| 2402 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2403 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 6435bd9 | 2011-09-10 02:10:07 +0000 | [diff] [blame] | 2404 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2405 | mogrify_image=RadialBlurImage(*image,geometry_info.rho, |
| 2406 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2407 | break; |
| 2408 | } |
| 2409 | if (LocaleCompare("raise",option+1) == 0) |
| 2410 | { |
| 2411 | /* |
| 2412 | Surround image with a raise of solid color. |
| 2413 | */ |
| 2414 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2415 | if ((flags & SigmaValue) == 0) |
| 2416 | geometry.height=geometry.width; |
| 2417 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
cristy | 6170ac3 | 2011-08-28 14:15:37 +0000 | [diff] [blame] | 2418 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2419 | break; |
| 2420 | } |
| 2421 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2422 | { |
| 2423 | /* |
| 2424 | Threshold image. |
| 2425 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2426 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2427 | (void) RandomThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2428 | break; |
| 2429 | } |
| 2430 | if (LocaleCompare("recolor",option+1) == 0) |
| 2431 | { |
| 2432 | KernelInfo |
| 2433 | *kernel; |
| 2434 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2435 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2436 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2437 | if (kernel == (KernelInfo *) NULL) |
| 2438 | break; |
| 2439 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 2440 | kernel=DestroyKernelInfo(kernel); |
| 2441 | break; |
| 2442 | } |
| 2443 | if (LocaleCompare("region",option+1) == 0) |
| 2444 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2445 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2446 | if (region_image != (Image *) NULL) |
| 2447 | { |
| 2448 | /* |
| 2449 | Composite region. |
| 2450 | */ |
| 2451 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2452 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 2453 | region_geometry.x,region_geometry.y,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2454 | *image=DestroyImage(*image); |
| 2455 | *image=region_image; |
| 2456 | region_image = (Image *) NULL; |
| 2457 | } |
| 2458 | if (*option == '+') |
| 2459 | break; |
| 2460 | /* |
| 2461 | Apply transformations to a selected region of the image. |
| 2462 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2463 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2464 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2465 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2466 | if (mogrify_image == (Image *) NULL) |
| 2467 | break; |
| 2468 | region_image=(*image); |
| 2469 | *image=mogrify_image; |
| 2470 | mogrify_image=(Image *) NULL; |
| 2471 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2472 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2473 | if (LocaleCompare("render",option+1) == 0) |
| 2474 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2475 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2476 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2477 | break; |
| 2478 | } |
| 2479 | if (LocaleCompare("remap",option+1) == 0) |
| 2480 | { |
| 2481 | Image |
| 2482 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2483 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2484 | /* |
| 2485 | Transform image colors to match this set of colors. |
| 2486 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2487 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2488 | if (*option == '+') |
| 2489 | break; |
| 2490 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2491 | if (remap_image == (Image *) NULL) |
| 2492 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2493 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2494 | remap_image=DestroyImage(remap_image); |
| 2495 | break; |
| 2496 | } |
| 2497 | if (LocaleCompare("repage",option+1) == 0) |
| 2498 | { |
| 2499 | if (*option == '+') |
| 2500 | { |
| 2501 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2502 | break; |
| 2503 | } |
| 2504 | (void) ResetImagePage(*image,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2505 | break; |
| 2506 | } |
| 2507 | if (LocaleCompare("resample",option+1) == 0) |
| 2508 | { |
| 2509 | /* |
| 2510 | Resample image. |
| 2511 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2512 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2513 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2514 | if ((flags & SigmaValue) == 0) |
| 2515 | geometry_info.sigma=geometry_info.rho; |
| 2516 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
| 2517 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2518 | break; |
| 2519 | } |
| 2520 | if (LocaleCompare("resize",option+1) == 0) |
| 2521 | { |
| 2522 | /* |
| 2523 | Resize image. |
| 2524 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2525 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2526 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2527 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2528 | (*image)->filter,(*image)->blur,exception); |
| 2529 | break; |
| 2530 | } |
| 2531 | if (LocaleCompare("roll",option+1) == 0) |
| 2532 | { |
| 2533 | /* |
| 2534 | Roll image. |
| 2535 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2536 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2537 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2538 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2539 | break; |
| 2540 | } |
| 2541 | if (LocaleCompare("rotate",option+1) == 0) |
| 2542 | { |
| 2543 | char |
| 2544 | *geometry; |
| 2545 | |
| 2546 | /* |
| 2547 | Check for conditional image rotation. |
| 2548 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2549 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2550 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2551 | if ((*image)->columns <= (*image)->rows) |
| 2552 | break; |
| 2553 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2554 | if ((*image)->columns >= (*image)->rows) |
| 2555 | break; |
| 2556 | /* |
| 2557 | Rotate image. |
| 2558 | */ |
| 2559 | geometry=ConstantString(argv[i+1]); |
| 2560 | (void) SubstituteString(&geometry,">",""); |
| 2561 | (void) SubstituteString(&geometry,"<",""); |
| 2562 | (void) ParseGeometry(geometry,&geometry_info); |
| 2563 | geometry=DestroyString(geometry); |
| 2564 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
| 2565 | break; |
| 2566 | } |
| 2567 | break; |
| 2568 | } |
| 2569 | case 's': |
| 2570 | { |
| 2571 | if (LocaleCompare("sample",option+1) == 0) |
| 2572 | { |
| 2573 | /* |
| 2574 | Sample image with pixel replication. |
| 2575 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2576 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2577 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2578 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
| 2579 | exception); |
| 2580 | break; |
| 2581 | } |
| 2582 | if (LocaleCompare("scale",option+1) == 0) |
| 2583 | { |
| 2584 | /* |
| 2585 | Resize image. |
| 2586 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2587 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2588 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2589 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2590 | exception); |
| 2591 | break; |
| 2592 | } |
| 2593 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2594 | { |
| 2595 | /* |
| 2596 | Selectively blur pixels within a contrast threshold. |
| 2597 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2598 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2599 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2600 | if ((flags & PercentValue) != 0) |
| 2601 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2602 | mogrify_image=SelectiveBlurImage(*image,geometry_info.rho, |
cristy | 1e7aa31 | 2011-09-10 20:01:36 +0000 | [diff] [blame] | 2603 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2604 | break; |
| 2605 | } |
| 2606 | if (LocaleCompare("separate",option+1) == 0) |
| 2607 | { |
| 2608 | /* |
| 2609 | Break channels into separate images. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2610 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2611 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 2612 | mogrify_image=SeparateImages(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2613 | break; |
| 2614 | } |
| 2615 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2616 | { |
| 2617 | double |
| 2618 | threshold; |
| 2619 | |
| 2620 | /* |
| 2621 | Sepia-tone image. |
| 2622 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2623 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2624 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 2625 | 1.0); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2626 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
| 2627 | break; |
| 2628 | } |
| 2629 | if (LocaleCompare("segment",option+1) == 0) |
| 2630 | { |
| 2631 | /* |
| 2632 | Segment image. |
| 2633 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2634 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2635 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2636 | if ((flags & SigmaValue) == 0) |
| 2637 | geometry_info.sigma=1.0; |
| 2638 | (void) SegmentImage(*image,(*image)->colorspace, |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2639 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 2640 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2641 | break; |
| 2642 | } |
| 2643 | if (LocaleCompare("set",option+1) == 0) |
| 2644 | { |
| 2645 | char |
| 2646 | *value; |
| 2647 | |
| 2648 | /* |
| 2649 | Set image option. |
| 2650 | */ |
| 2651 | if (*option == '+') |
| 2652 | { |
| 2653 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2654 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2655 | else |
| 2656 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2657 | { |
| 2658 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
| 2659 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2660 | } |
| 2661 | else |
| 2662 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2663 | break; |
| 2664 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2665 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2666 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2667 | if (value == (char *) NULL) |
| 2668 | break; |
| 2669 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2670 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2671 | exception); |
| 2672 | else |
| 2673 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2674 | { |
| 2675 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
| 2676 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
| 2677 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2678 | } |
| 2679 | else |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 2680 | (void) SetImageProperty(*image,argv[i+1],value,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2681 | value=DestroyString(value); |
| 2682 | break; |
| 2683 | } |
| 2684 | if (LocaleCompare("shade",option+1) == 0) |
| 2685 | { |
| 2686 | /* |
| 2687 | Shade image. |
| 2688 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2689 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2690 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2691 | if ((flags & SigmaValue) == 0) |
| 2692 | geometry_info.sigma=1.0; |
| 2693 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2694 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2695 | break; |
| 2696 | } |
| 2697 | if (LocaleCompare("shadow",option+1) == 0) |
| 2698 | { |
| 2699 | /* |
| 2700 | Shadow image. |
| 2701 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2702 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2703 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2704 | if ((flags & SigmaValue) == 0) |
| 2705 | geometry_info.sigma=1.0; |
| 2706 | if ((flags & XiValue) == 0) |
| 2707 | geometry_info.xi=4.0; |
| 2708 | if ((flags & PsiValue) == 0) |
| 2709 | geometry_info.psi=4.0; |
| 2710 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
| 2711 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 2712 | ceil(geometry_info.psi-0.5),exception); |
| 2713 | break; |
| 2714 | } |
| 2715 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2716 | { |
| 2717 | /* |
| 2718 | Sharpen image. |
| 2719 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2720 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2721 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2722 | if ((flags & SigmaValue) == 0) |
| 2723 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2724 | if ((flags & XiValue) == 0) |
| 2725 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2726 | mogrify_image=SharpenImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2727 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2728 | break; |
| 2729 | } |
| 2730 | if (LocaleCompare("shave",option+1) == 0) |
| 2731 | { |
| 2732 | /* |
| 2733 | Shave the image edges. |
| 2734 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2735 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2736 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2737 | mogrify_image=ShaveImage(*image,&geometry,exception); |
| 2738 | break; |
| 2739 | } |
| 2740 | if (LocaleCompare("shear",option+1) == 0) |
| 2741 | { |
| 2742 | /* |
| 2743 | Shear image. |
| 2744 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2745 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2746 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2747 | if ((flags & SigmaValue) == 0) |
| 2748 | geometry_info.sigma=geometry_info.rho; |
| 2749 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2750 | geometry_info.sigma,exception); |
| 2751 | break; |
| 2752 | } |
| 2753 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2754 | { |
| 2755 | /* |
| 2756 | Sigmoidal non-linearity contrast control. |
| 2757 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2758 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2759 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2760 | if ((flags & SigmaValue) == 0) |
| 2761 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 2762 | if ((flags & PercentValue) != 0) |
| 2763 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2764 | 100.0; |
cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 2765 | (void) SigmoidalContrastImage(*image,(*option == '-') ? |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2766 | MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma, |
| 2767 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2768 | break; |
| 2769 | } |
| 2770 | if (LocaleCompare("sketch",option+1) == 0) |
| 2771 | { |
| 2772 | /* |
| 2773 | Sketch image. |
| 2774 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2775 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2776 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2777 | if ((flags & SigmaValue) == 0) |
| 2778 | geometry_info.sigma=1.0; |
| 2779 | mogrify_image=SketchImage(*image,geometry_info.rho, |
cristy | f7ef025 | 2011-09-09 14:50:06 +0000 | [diff] [blame] | 2780 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2781 | break; |
| 2782 | } |
| 2783 | if (LocaleCompare("solarize",option+1) == 0) |
| 2784 | { |
| 2785 | double |
| 2786 | threshold; |
| 2787 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2788 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2789 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 2790 | 1.0); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 2791 | (void) SolarizeImage(*image,threshold,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2792 | break; |
| 2793 | } |
| 2794 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2795 | { |
| 2796 | SparseColorMethod |
| 2797 | method; |
| 2798 | |
| 2799 | char |
| 2800 | *arguments; |
| 2801 | |
| 2802 | /* |
| 2803 | Sparse Color Interpolated Gradient |
| 2804 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2805 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2806 | method=(SparseColorMethod) ParseCommandOption( |
| 2807 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2808 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2809 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2810 | if (arguments == (char *) NULL) |
| 2811 | break; |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 2812 | mogrify_image=SparseColorOption(*image,method,arguments, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2813 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2814 | arguments=DestroyString(arguments); |
| 2815 | break; |
| 2816 | } |
| 2817 | if (LocaleCompare("splice",option+1) == 0) |
| 2818 | { |
| 2819 | /* |
| 2820 | Splice a solid color into the image. |
| 2821 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2822 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2823 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 2824 | mogrify_image=SpliceImage(*image,&geometry,exception); |
| 2825 | break; |
| 2826 | } |
| 2827 | if (LocaleCompare("spread",option+1) == 0) |
| 2828 | { |
| 2829 | /* |
| 2830 | Spread an image. |
| 2831 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2832 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2833 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame] | 2834 | mogrify_image=SpreadImage(*image,geometry_info.rho, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2835 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2836 | break; |
| 2837 | } |
| 2838 | if (LocaleCompare("statistic",option+1) == 0) |
| 2839 | { |
| 2840 | StatisticType |
| 2841 | type; |
| 2842 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2843 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2844 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
| 2845 | MagickFalse,argv[i+1]); |
| 2846 | (void) ParseGeometry(argv[i+2],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2847 | mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho, |
| 2848 | (size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2849 | break; |
| 2850 | } |
| 2851 | if (LocaleCompare("stretch",option+1) == 0) |
| 2852 | { |
| 2853 | if (*option == '+') |
| 2854 | { |
| 2855 | draw_info->stretch=UndefinedStretch; |
| 2856 | break; |
| 2857 | } |
| 2858 | draw_info->stretch=(StretchType) ParseCommandOption( |
| 2859 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2860 | break; |
| 2861 | } |
| 2862 | if (LocaleCompare("strip",option+1) == 0) |
| 2863 | { |
| 2864 | /* |
| 2865 | Strip image of profiles and comments. |
| 2866 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2867 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 2868 | (void) StripImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2869 | break; |
| 2870 | } |
| 2871 | if (LocaleCompare("stroke",option+1) == 0) |
| 2872 | { |
| 2873 | ExceptionInfo |
| 2874 | *sans; |
| 2875 | |
| 2876 | if (*option == '+') |
| 2877 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2878 | (void) QueryColorCompliance("none",AllCompliance, |
| 2879 | &draw_info->stroke,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2880 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2881 | draw_info->stroke_pattern=DestroyImage( |
| 2882 | draw_info->stroke_pattern); |
| 2883 | break; |
| 2884 | } |
| 2885 | sans=AcquireExceptionInfo(); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2886 | status=QueryColorCompliance(argv[i+1],AllCompliance, |
| 2887 | &draw_info->stroke,sans); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2888 | sans=DestroyExceptionInfo(sans); |
| 2889 | if (status == MagickFalse) |
| 2890 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2891 | exception); |
| 2892 | break; |
| 2893 | } |
| 2894 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2895 | { |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2896 | draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2897 | break; |
| 2898 | } |
| 2899 | if (LocaleCompare("style",option+1) == 0) |
| 2900 | { |
| 2901 | if (*option == '+') |
| 2902 | { |
| 2903 | draw_info->style=UndefinedStyle; |
| 2904 | break; |
| 2905 | } |
| 2906 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 2907 | MagickFalse,argv[i+1]); |
| 2908 | break; |
| 2909 | } |
| 2910 | if (LocaleCompare("swirl",option+1) == 0) |
| 2911 | { |
| 2912 | /* |
| 2913 | Swirl image. |
| 2914 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2915 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2916 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 76f512e | 2011-09-12 01:26:56 +0000 | [diff] [blame] | 2917 | mogrify_image=SwirlImage(*image,geometry_info.rho, |
| 2918 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2919 | break; |
| 2920 | } |
| 2921 | break; |
| 2922 | } |
| 2923 | case 't': |
| 2924 | { |
| 2925 | if (LocaleCompare("threshold",option+1) == 0) |
| 2926 | { |
| 2927 | double |
| 2928 | threshold; |
| 2929 | |
| 2930 | /* |
| 2931 | Threshold image. |
| 2932 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2933 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2934 | if (*option == '+') |
anthony | 247a86d | 2011-05-03 13:18:18 +0000 | [diff] [blame] | 2935 | threshold=(double) QuantumRange/2; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2936 | else |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2937 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 2938 | 1.0); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 2939 | (void) BilevelImage(*image,threshold,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2940 | break; |
| 2941 | } |
| 2942 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2943 | { |
| 2944 | /* |
| 2945 | Thumbnail image. |
| 2946 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2947 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2948 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2949 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2950 | exception); |
| 2951 | break; |
| 2952 | } |
| 2953 | if (LocaleCompare("tile",option+1) == 0) |
| 2954 | { |
| 2955 | if (*option == '+') |
| 2956 | { |
| 2957 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2958 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2959 | break; |
| 2960 | } |
| 2961 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2962 | exception); |
| 2963 | break; |
| 2964 | } |
| 2965 | if (LocaleCompare("tint",option+1) == 0) |
| 2966 | { |
| 2967 | /* |
| 2968 | Tint the image. |
| 2969 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2970 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2971 | mogrify_image=TintImage(*image,argv[i+1],&fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2972 | break; |
| 2973 | } |
| 2974 | if (LocaleCompare("transform",option+1) == 0) |
| 2975 | { |
| 2976 | /* |
| 2977 | Affine transform image. |
| 2978 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2979 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2980 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
| 2981 | exception); |
| 2982 | break; |
| 2983 | } |
| 2984 | if (LocaleCompare("transparent",option+1) == 0) |
| 2985 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2986 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2987 | target; |
| 2988 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2989 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2990 | (void) QueryColorCompliance(argv[i+1],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2991 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2992 | (void) TransparentPaintImage(*image,&target,(Quantum) |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 2993 | TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue, |
cristy | 82d7af5 | 2011-10-16 16:26:41 +0000 | [diff] [blame] | 2994 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2995 | break; |
| 2996 | } |
| 2997 | if (LocaleCompare("transpose",option+1) == 0) |
| 2998 | { |
| 2999 | /* |
| 3000 | Transpose image scanlines. |
| 3001 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3002 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3003 | mogrify_image=TransposeImage(*image,exception); |
| 3004 | break; |
| 3005 | } |
| 3006 | if (LocaleCompare("transverse",option+1) == 0) |
| 3007 | { |
| 3008 | /* |
| 3009 | Transverse image scanlines. |
| 3010 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3011 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3012 | mogrify_image=TransverseImage(*image,exception); |
| 3013 | break; |
| 3014 | } |
| 3015 | if (LocaleCompare("treedepth",option+1) == 0) |
| 3016 | { |
| 3017 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
| 3018 | break; |
| 3019 | } |
| 3020 | if (LocaleCompare("trim",option+1) == 0) |
| 3021 | { |
| 3022 | /* |
| 3023 | Trim image. |
| 3024 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3025 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3026 | mogrify_image=TrimImage(*image,exception); |
| 3027 | break; |
| 3028 | } |
| 3029 | if (LocaleCompare("type",option+1) == 0) |
| 3030 | { |
| 3031 | ImageType |
| 3032 | type; |
| 3033 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3034 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3035 | if (*option == '+') |
| 3036 | type=UndefinedType; |
| 3037 | else |
| 3038 | type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 3039 | argv[i+1]); |
| 3040 | (*image)->type=UndefinedType; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3041 | (void) SetImageType(*image,type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3042 | break; |
| 3043 | } |
| 3044 | break; |
| 3045 | } |
| 3046 | case 'u': |
| 3047 | { |
| 3048 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3049 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 3050 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 3051 | &draw_info->undercolor,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3052 | break; |
| 3053 | } |
| 3054 | if (LocaleCompare("unique",option+1) == 0) |
| 3055 | { |
| 3056 | if (*option == '+') |
| 3057 | { |
| 3058 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
| 3059 | break; |
| 3060 | } |
| 3061 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
| 3062 | (void) SetImageArtifact(*image,"verbose","true"); |
| 3063 | break; |
| 3064 | } |
| 3065 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3066 | { |
| 3067 | /* |
| 3068 | Unique image colors. |
| 3069 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3070 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3071 | mogrify_image=UniqueImageColors(*image,exception); |
| 3072 | break; |
| 3073 | } |
| 3074 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3075 | { |
| 3076 | /* |
| 3077 | Unsharp mask image. |
| 3078 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3079 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3080 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3081 | if ((flags & SigmaValue) == 0) |
| 3082 | geometry_info.sigma=1.0; |
| 3083 | if ((flags & XiValue) == 0) |
| 3084 | geometry_info.xi=1.0; |
| 3085 | if ((flags & PsiValue) == 0) |
| 3086 | geometry_info.psi=0.05; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3087 | mogrify_image=UnsharpMaskImage(*image,geometry_info.rho, |
| 3088 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3089 | break; |
| 3090 | } |
| 3091 | break; |
| 3092 | } |
| 3093 | case 'v': |
| 3094 | { |
| 3095 | if (LocaleCompare("verbose",option+1) == 0) |
| 3096 | { |
| 3097 | (void) SetImageArtifact(*image,option+1, |
| 3098 | *option == '+' ? "false" : "true"); |
| 3099 | break; |
| 3100 | } |
| 3101 | if (LocaleCompare("vignette",option+1) == 0) |
| 3102 | { |
| 3103 | /* |
| 3104 | Vignette image. |
| 3105 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3106 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3107 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3108 | if ((flags & SigmaValue) == 0) |
| 3109 | geometry_info.sigma=1.0; |
| 3110 | if ((flags & XiValue) == 0) |
| 3111 | geometry_info.xi=0.1*(*image)->columns; |
| 3112 | if ((flags & PsiValue) == 0) |
| 3113 | geometry_info.psi=0.1*(*image)->rows; |
| 3114 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
| 3115 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3116 | ceil(geometry_info.psi-0.5),exception); |
| 3117 | break; |
| 3118 | } |
| 3119 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3120 | { |
| 3121 | if (*option == '+') |
| 3122 | { |
| 3123 | (void) SetImageVirtualPixelMethod(*image, |
| 3124 | UndefinedVirtualPixelMethod); |
| 3125 | break; |
| 3126 | } |
| 3127 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3128 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 3129 | argv[i+1])); |
| 3130 | break; |
| 3131 | } |
| 3132 | break; |
| 3133 | } |
| 3134 | case 'w': |
| 3135 | { |
| 3136 | if (LocaleCompare("wave",option+1) == 0) |
| 3137 | { |
| 3138 | /* |
| 3139 | Wave image. |
| 3140 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3141 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3142 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3143 | if ((flags & SigmaValue) == 0) |
| 3144 | geometry_info.sigma=1.0; |
| 3145 | mogrify_image=WaveImage(*image,geometry_info.rho, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 3146 | geometry_info.sigma,interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3147 | break; |
| 3148 | } |
| 3149 | if (LocaleCompare("weight",option+1) == 0) |
| 3150 | { |
| 3151 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
| 3152 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3153 | draw_info->weight=0; |
| 3154 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3155 | draw_info->weight=700; |
| 3156 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3157 | if (draw_info->weight <= 800) |
| 3158 | draw_info->weight+=100; |
| 3159 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3160 | if (draw_info->weight >= 100) |
| 3161 | draw_info->weight-=100; |
| 3162 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3163 | draw_info->weight=400; |
| 3164 | break; |
| 3165 | } |
| 3166 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3167 | { |
| 3168 | /* |
| 3169 | White threshold image. |
| 3170 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3171 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3172 | (void) WhiteThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3173 | break; |
| 3174 | } |
| 3175 | break; |
| 3176 | } |
| 3177 | default: |
| 3178 | break; |
| 3179 | } |
| 3180 | /* |
| 3181 | Replace current image with any image that was generated |
| 3182 | */ |
| 3183 | if (mogrify_image != (Image *) NULL) |
| 3184 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3185 | i+=count; |
| 3186 | } |
| 3187 | if (region_image != (Image *) NULL) |
| 3188 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3189 | /* |
| 3190 | Composite transformed region onto image. |
| 3191 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3192 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3193 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3194 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 3195 | region_geometry.x,region_geometry.y,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3196 | *image=DestroyImage(*image); |
| 3197 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3198 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3199 | } |
| 3200 | /* |
| 3201 | Free resources. |
| 3202 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3203 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3204 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3205 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 82d7af5 | 2011-10-16 16:26:41 +0000 | [diff] [blame] | 3206 | status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3207 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3208 | } |
| 3209 | |
| 3210 | /* |
| 3211 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3212 | % % |
| 3213 | % % |
| 3214 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3215 | + M o g r i f y I m a g e C o m m a n d % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3216 | % % |
| 3217 | % % |
| 3218 | % % |
| 3219 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3220 | % |
| 3221 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3222 | % transforms include image scaling, image rotation, color reduction, and |
| 3223 | % others. The transmogrified image overwrites the original image. |
| 3224 | % |
| 3225 | % The format of the MogrifyImageCommand method is: |
| 3226 | % |
| 3227 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3228 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3229 | % |
| 3230 | % A description of each parameter follows: |
| 3231 | % |
| 3232 | % o image_info: the image info. |
| 3233 | % |
| 3234 | % o argc: the number of elements in the argument vector. |
| 3235 | % |
| 3236 | % o argv: A text array containing the command line arguments. |
| 3237 | % |
| 3238 | % o metadata: any metadata is returned here. |
| 3239 | % |
| 3240 | % o exception: return any errors or warnings in this structure. |
| 3241 | % |
| 3242 | */ |
| 3243 | |
| 3244 | static MagickBooleanType MogrifyUsage(void) |
| 3245 | { |
| 3246 | static const char |
| 3247 | *miscellaneous[]= |
| 3248 | { |
| 3249 | "-debug events display copious debugging information", |
| 3250 | "-help print program options", |
| 3251 | "-list type print a list of supported option arguments", |
| 3252 | "-log format format of debugging information", |
| 3253 | "-version print version information", |
| 3254 | (char *) NULL |
| 3255 | }, |
| 3256 | *operators[]= |
| 3257 | { |
| 3258 | "-adaptive-blur geometry", |
| 3259 | " adaptively blur pixels; decrease effect near edges", |
| 3260 | "-adaptive-resize geometry", |
| 3261 | " adaptively resize image using 'mesh' interpolation", |
| 3262 | "-adaptive-sharpen geometry", |
| 3263 | " adaptively sharpen pixels; increase effect near edges", |
| 3264 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3265 | " transparent, extract, background, or shape", |
| 3266 | "-annotate geometry text", |
| 3267 | " annotate the image with text", |
| 3268 | "-auto-gamma automagically adjust gamma level of image", |
| 3269 | "-auto-level automagically adjust color levels of image", |
| 3270 | "-auto-orient automagically orient (rotate) image", |
| 3271 | "-bench iterations measure performance", |
| 3272 | "-black-threshold value", |
| 3273 | " force all pixels below the threshold into black", |
| 3274 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3275 | "-blur geometry reduce image noise and reduce detail levels", |
| 3276 | "-border geometry surround image with a border of color", |
| 3277 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3278 | "-brightness-contrast geometry", |
| 3279 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3280 | "-cdl filename color correct with a color decision list", |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 3281 | "-charcoal geometry simulate a charcoal drawing", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3282 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3283 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3284 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3285 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3286 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3287 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3288 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3289 | "-contrast enhance or reduce the image contrast", |
| 3290 | "-contrast-stretch geometry", |
| 3291 | " improve contrast by `stretching' the intensity range", |
| 3292 | "-convolve coefficients", |
| 3293 | " apply a convolution kernel to the image", |
| 3294 | "-cycle amount cycle the image colormap", |
| 3295 | "-decipher filename convert cipher pixels to plain pixels", |
| 3296 | "-deskew threshold straighten an image", |
| 3297 | "-despeckle reduce the speckles within an image", |
| 3298 | "-distort method args", |
| 3299 | " distort images according to given method ad args", |
| 3300 | "-draw string annotate the image with a graphic primitive", |
| 3301 | "-edge radius apply a filter to detect edges in the image", |
| 3302 | "-encipher filename convert plain pixels to cipher pixels", |
| 3303 | "-emboss radius emboss an image", |
| 3304 | "-enhance apply a digital filter to enhance a noisy image", |
| 3305 | "-equalize perform histogram equalization to an image", |
| 3306 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3307 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3308 | "-extent geometry set the image size", |
| 3309 | "-extract geometry extract area from image", |
| 3310 | "-fft implements the discrete Fourier transform (DFT)", |
| 3311 | "-flip flip image vertically", |
| 3312 | "-floodfill geometry color", |
| 3313 | " floodfill the image with color", |
| 3314 | "-flop flop image horizontally", |
| 3315 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3316 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3317 | " apply function over image values", |
| 3318 | "-gamma value level of gamma correction", |
| 3319 | "-gaussian-blur geometry", |
| 3320 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3321 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3322 | "-identify identify the format and characteristics of the image", |
| 3323 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3324 | "-implode amount implode image pixels about the center", |
| 3325 | "-lat geometry local adaptive thresholding", |
| 3326 | "-layers method optimize, merge, or compare image layers", |
| 3327 | "-level value adjust the level of image contrast", |
| 3328 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3329 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3330 | "-linear-stretch geometry", |
| 3331 | " improve contrast by `stretching with saturation'", |
| 3332 | "-liquid-rescale geometry", |
| 3333 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3334 | "-median geometry apply a median filter to the image", |
glennrp | 30d2dc6 | 2011-06-25 03:17:16 +0000 | [diff] [blame] | 3335 | "-mode geometry make each pixel the 'predominant color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3336 | "-modulate value vary the brightness, saturation, and hue", |
| 3337 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3338 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3339 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3340 | "-motion-blur geometry", |
| 3341 | " simulate motion blur", |
| 3342 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3343 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3344 | "-normalize transform image to span the full range of colors", |
| 3345 | "-opaque color change this color to the fill color", |
| 3346 | "-ordered-dither NxN", |
| 3347 | " add a noise pattern to the image with specific", |
| 3348 | " amplitudes", |
| 3349 | "-paint radius simulate an oil painting", |
| 3350 | "-polaroid angle simulate a Polaroid picture", |
| 3351 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3352 | "-profile filename add, delete, or apply an image profile", |
| 3353 | "-quantize colorspace reduce colors in this colorspace", |
| 3354 | "-radial-blur angle radial blur the image", |
| 3355 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3356 | "-random-threshold low,high", |
| 3357 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3358 | "-region geometry apply options to a portion of the image", |
| 3359 | "-render render vector graphics", |
| 3360 | "-repage geometry size and location of an image canvas", |
| 3361 | "-resample geometry change the resolution of an image", |
| 3362 | "-resize geometry resize the image", |
| 3363 | "-roll geometry roll an image vertically or horizontally", |
| 3364 | "-rotate degrees apply Paeth rotation to the image", |
| 3365 | "-sample geometry scale image with pixel sampling", |
| 3366 | "-scale geometry scale the image", |
| 3367 | "-segment values segment an image", |
| 3368 | "-selective-blur geometry", |
| 3369 | " selectively blur pixels within a contrast threshold", |
| 3370 | "-sepia-tone threshold", |
| 3371 | " simulate a sepia-toned photo", |
| 3372 | "-set property value set an image property", |
| 3373 | "-shade degrees shade the image using a distant light source", |
| 3374 | "-shadow geometry simulate an image shadow", |
| 3375 | "-sharpen geometry sharpen the image", |
| 3376 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3377 | "-shear geometry slide one edge of the image along the X or Y axis", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3378 | "-sigmoidal-contrast geometry", |
| 3379 | " increase the contrast without saturating highlights or shadows", |
| 3380 | "-sketch geometry simulate a pencil sketch", |
| 3381 | "-solarize threshold negate all pixels above the threshold level", |
| 3382 | "-sparse-color method args", |
| 3383 | " fill in a image based on a few color points", |
| 3384 | "-splice geometry splice the background color into the image", |
| 3385 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3386 | "-statistic type radius", |
| 3387 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3388 | "-strip strip image of all profiles and comments", |
| 3389 | "-swirl degrees swirl image pixels about the center", |
| 3390 | "-threshold value threshold the image", |
| 3391 | "-thumbnail geometry create a thumbnail of the image", |
| 3392 | "-tile filename tile image when filling a graphic primitive", |
| 3393 | "-tint value tint the image with the fill color", |
| 3394 | "-transform affine transform image", |
| 3395 | "-transparent color make this color transparent within the image", |
| 3396 | "-transpose flip image vertically and rotate 90 degrees", |
| 3397 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3398 | "-trim trim image edges", |
| 3399 | "-type type image type", |
| 3400 | "-unique-colors discard all but one of any pixel color", |
| 3401 | "-unsharp geometry sharpen the image", |
| 3402 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3403 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3404 | "-white-threshold value", |
| 3405 | " force all pixels above the threshold into white", |
| 3406 | (char *) NULL |
| 3407 | }, |
| 3408 | *sequence_operators[]= |
| 3409 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3410 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3411 | "-clut apply a color lookup table to the image", |
| 3412 | "-coalesce merge a sequence of images", |
| 3413 | "-combine combine a sequence of images", |
| 3414 | "-composite composite image", |
| 3415 | "-crop geometry cut out a rectangular region of the image", |
| 3416 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3417 | "-evaluate-sequence operator", |
| 3418 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3419 | "-flatten flatten a sequence of images", |
| 3420 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3421 | "-hald-clut apply a Hald color lookup table to the image", |
| 3422 | "-morph value morph an image sequence", |
| 3423 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3424 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3425 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3426 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3427 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3428 | "-write filename write images to this file", |
| 3429 | (char *) NULL |
| 3430 | }, |
| 3431 | *settings[]= |
| 3432 | { |
| 3433 | "-adjoin join images into a single multi-image file", |
| 3434 | "-affine matrix affine transform matrix", |
| 3435 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3436 | "-antialias remove pixel-aliasing", |
| 3437 | "-authenticate password", |
| 3438 | " decipher image with this password", |
| 3439 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3440 | "-background color background color", |
| 3441 | "-bias value add bias when convolving an image", |
| 3442 | "-black-point-compensation", |
| 3443 | " use black point compensation", |
| 3444 | "-blue-primary point chromaticity blue primary point", |
| 3445 | "-bordercolor color border color", |
| 3446 | "-caption string assign a caption to an image", |
| 3447 | "-channel type apply option to select image channels", |
| 3448 | "-colors value preferred number of colors in the image", |
| 3449 | "-colorspace type alternate image colorspace", |
| 3450 | "-comment string annotate image with comment", |
| 3451 | "-compose operator set image composite operator", |
| 3452 | "-compress type type of pixel compression when writing the image", |
| 3453 | "-define format:option", |
| 3454 | " define one or more image format options", |
| 3455 | "-delay value display the next image after pausing", |
| 3456 | "-density geometry horizontal and vertical density of the image", |
| 3457 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3458 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3459 | "-display server get image or font from this X server", |
| 3460 | "-dispose method layer disposal method", |
| 3461 | "-dither method apply error diffusion to image", |
| 3462 | "-encoding type text encoding type", |
| 3463 | "-endian type endianness (MSB or LSB) of the image", |
| 3464 | "-family name render text with this font family", |
| 3465 | "-fill color color to use when filling a graphic primitive", |
| 3466 | "-filter type use this filter when resizing an image", |
| 3467 | "-font name render text with this font", |
| 3468 | "-format \"string\" output formatted image characteristics", |
| 3469 | "-fuzz distance colors within this distance are considered equal", |
| 3470 | "-gravity type horizontal and vertical text placement", |
| 3471 | "-green-primary point chromaticity green primary point", |
| 3472 | "-intent type type of rendering intent when managing the image color", |
| 3473 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3474 | "-interline-spacing value", |
| 3475 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3476 | "-interpolate method pixel color interpolation method", |
| 3477 | "-interword-spacing value", |
| 3478 | " set the space between two words", |
| 3479 | "-kerning value set the space between two letters", |
| 3480 | "-label string assign a label to an image", |
| 3481 | "-limit type value pixel cache resource limit", |
| 3482 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3483 | "-mask filename associate a mask with the image", |
| 3484 | "-mattecolor color frame color", |
| 3485 | "-monitor monitor progress", |
| 3486 | "-orient type image orientation", |
| 3487 | "-page geometry size and location of an image canvas (setting)", |
| 3488 | "-ping efficiently determine image attributes", |
| 3489 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3490 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3491 | "-preview type image preview type", |
| 3492 | "-quality value JPEG/MIFF/PNG compression level", |
| 3493 | "-quiet suppress all warning messages", |
| 3494 | "-red-primary point chromaticity red primary point", |
| 3495 | "-regard-warnings pay attention to warning messages", |
| 3496 | "-remap filename transform image colors to match this set of colors", |
| 3497 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3498 | "-sampling-factor geometry", |
| 3499 | " horizontal and vertical sampling factor", |
| 3500 | "-scene value image scene number", |
| 3501 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3502 | "-size geometry width and height of image", |
| 3503 | "-stretch type render text with this font stretch", |
| 3504 | "-stroke color graphic primitive stroke color", |
| 3505 | "-strokewidth value graphic primitive stroke width", |
| 3506 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3507 | "-synchronize synchronize image to storage device", |
| 3508 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3509 | "-texture filename name of texture to tile onto the image background", |
| 3510 | "-tile-offset geometry", |
| 3511 | " tile offset", |
| 3512 | "-treedepth value color tree depth", |
| 3513 | "-transparent-color color", |
| 3514 | " transparent color", |
| 3515 | "-undercolor color annotation bounding box color", |
| 3516 | "-units type the units of image resolution", |
| 3517 | "-verbose print detailed information about the image", |
| 3518 | "-view FlashPix viewing transforms", |
| 3519 | "-virtual-pixel method", |
| 3520 | " virtual pixel access method", |
| 3521 | "-weight type render text with this font weight", |
| 3522 | "-white-point point chromaticity white point", |
| 3523 | (char *) NULL |
| 3524 | }, |
| 3525 | *stack_operators[]= |
| 3526 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3527 | "-delete indexes delete the image from the image sequence", |
| 3528 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3529 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3530 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3531 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3532 | "-swap indexes swap two images in the image sequence", |
| 3533 | (char *) NULL |
| 3534 | }; |
| 3535 | |
| 3536 | const char |
| 3537 | **p; |
| 3538 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3539 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3540 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3541 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3542 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3543 | GetClientName()); |
| 3544 | (void) printf("\nImage Settings:\n"); |
| 3545 | for (p=settings; *p != (char *) NULL; p++) |
| 3546 | (void) printf(" %s\n",*p); |
| 3547 | (void) printf("\nImage Operators:\n"); |
| 3548 | for (p=operators; *p != (char *) NULL; p++) |
| 3549 | (void) printf(" %s\n",*p); |
| 3550 | (void) printf("\nImage Sequence Operators:\n"); |
| 3551 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3552 | (void) printf(" %s\n",*p); |
| 3553 | (void) printf("\nImage Stack Operators:\n"); |
| 3554 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3555 | (void) printf(" %s\n",*p); |
| 3556 | (void) printf("\nMiscellaneous Options:\n"); |
| 3557 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3558 | (void) printf(" %s\n",*p); |
| 3559 | (void) printf( |
| 3560 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3561 | (void) printf( |
| 3562 | "number. To specify a particular image format, precede the filename\n"); |
| 3563 | (void) printf( |
| 3564 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3565 | (void) printf( |
| 3566 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3567 | (void) printf("'-' for standard input or output.\n"); |
| 3568 | return(MagickFalse); |
| 3569 | } |
| 3570 | |
| 3571 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3572 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3573 | { |
| 3574 | #define DestroyMogrify() \ |
| 3575 | { \ |
| 3576 | if (format != (char *) NULL) \ |
| 3577 | format=DestroyString(format); \ |
| 3578 | if (path != (char *) NULL) \ |
| 3579 | path=DestroyString(path); \ |
| 3580 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3581 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3582 | argv[i]=DestroyString(argv[i]); \ |
| 3583 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3584 | } |
| 3585 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3586 | { \ |
| 3587 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3588 | option); \ |
| 3589 | DestroyMogrify(); \ |
| 3590 | return(MagickFalse); \ |
| 3591 | } |
| 3592 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3593 | { \ |
| 3594 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3595 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3596 | DestroyMogrify(); \ |
| 3597 | return(MagickFalse); \ |
| 3598 | } |
| 3599 | |
| 3600 | char |
| 3601 | *format, |
| 3602 | *option, |
| 3603 | *path; |
| 3604 | |
| 3605 | Image |
| 3606 | *image; |
| 3607 | |
| 3608 | ImageStack |
| 3609 | image_stack[MaxImageStackDepth+1]; |
| 3610 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3611 | MagickBooleanType |
| 3612 | global_colormap; |
| 3613 | |
| 3614 | MagickBooleanType |
| 3615 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3616 | pend, |
| 3617 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3618 | |
| 3619 | MagickStatusType |
| 3620 | status; |
| 3621 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3622 | register ssize_t |
| 3623 | i; |
| 3624 | |
| 3625 | ssize_t |
| 3626 | j, |
| 3627 | k; |
| 3628 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3629 | /* |
| 3630 | Set defaults. |
| 3631 | */ |
| 3632 | assert(image_info != (ImageInfo *) NULL); |
| 3633 | assert(image_info->signature == MagickSignature); |
| 3634 | if (image_info->debug != MagickFalse) |
| 3635 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3636 | assert(exception != (ExceptionInfo *) NULL); |
| 3637 | if (argc == 2) |
| 3638 | { |
| 3639 | option=argv[1]; |
| 3640 | if ((LocaleCompare("version",option+1) == 0) || |
| 3641 | (LocaleCompare("-version",option+1) == 0)) |
| 3642 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3643 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3644 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 3645 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 3646 | GetMagickCopyright()); |
| 3647 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 3648 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3649 | return(MagickFalse); |
| 3650 | } |
| 3651 | } |
| 3652 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3653 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3654 | format=(char *) NULL; |
| 3655 | path=(char *) NULL; |
| 3656 | global_colormap=MagickFalse; |
| 3657 | k=0; |
| 3658 | j=1; |
| 3659 | NewImageStack(); |
| 3660 | option=(char *) NULL; |
| 3661 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3662 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3663 | status=MagickTrue; |
| 3664 | /* |
| 3665 | Parse command line. |
| 3666 | */ |
| 3667 | ReadCommandlLine(argc,&argv); |
| 3668 | status=ExpandFilenames(&argc,&argv); |
| 3669 | if (status == MagickFalse) |
| 3670 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3671 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3672 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3673 | { |
| 3674 | option=argv[i]; |
| 3675 | if (LocaleCompare(option,"(") == 0) |
| 3676 | { |
| 3677 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3678 | if (k == MaxImageStackDepth) |
| 3679 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3680 | option); |
| 3681 | PushImageStack(); |
| 3682 | continue; |
| 3683 | } |
| 3684 | if (LocaleCompare(option,")") == 0) |
| 3685 | { |
| 3686 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3687 | if (k == 0) |
| 3688 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3689 | PopImageStack(); |
| 3690 | continue; |
| 3691 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3692 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3693 | { |
| 3694 | char |
| 3695 | backup_filename[MaxTextExtent], |
| 3696 | *filename; |
| 3697 | |
| 3698 | Image |
| 3699 | *images; |
| 3700 | |
| 3701 | /* |
| 3702 | Option is a file name: begin by reading image from specified file. |
| 3703 | */ |
| 3704 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3705 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3706 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3707 | filename=argv[++i]; |
| 3708 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 3709 | images=ReadImages(image_info,exception); |
| 3710 | status&=(images != (Image *) NULL) && |
| 3711 | (exception->severity < ErrorException); |
| 3712 | if (images == (Image *) NULL) |
| 3713 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3714 | if (format != (char *) NULL) |
| 3715 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3716 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3717 | if (path != (char *) NULL) |
| 3718 | { |
| 3719 | GetPathComponent(option,TailPath,filename); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3720 | (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3721 | path,*DirectorySeparator,filename); |
| 3722 | } |
| 3723 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3724 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3725 | AppendImageStack(images); |
| 3726 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3727 | if (global_colormap != MagickFalse) |
| 3728 | { |
| 3729 | QuantizeInfo |
| 3730 | *quantize_info; |
| 3731 | |
| 3732 | quantize_info=AcquireQuantizeInfo(image_info); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3733 | (void) RemapImages(quantize_info,images,(Image *) NULL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3734 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3735 | } |
| 3736 | *backup_filename='\0'; |
| 3737 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3738 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3739 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3740 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3741 | i; |
| 3742 | |
| 3743 | /* |
| 3744 | Rename image file as backup. |
| 3745 | */ |
| 3746 | (void) CopyMagickString(backup_filename,image->filename, |
| 3747 | MaxTextExtent); |
| 3748 | for (i=0; i < 6; i++) |
| 3749 | { |
| 3750 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3751 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3752 | break; |
| 3753 | } |
| 3754 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
cristy | 320684d | 2011-09-23 14:55:47 +0000 | [diff] [blame] | 3755 | (rename_utf8(image->filename,backup_filename) != 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3756 | *backup_filename='\0'; |
| 3757 | } |
| 3758 | /* |
| 3759 | Write transmogrified image to disk. |
| 3760 | */ |
| 3761 | image_info->synchronize=MagickTrue; |
| 3762 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3763 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 3764 | (void) remove_utf8(backup_filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3765 | RemoveAllImageStack(); |
| 3766 | continue; |
| 3767 | } |
| 3768 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3769 | switch (*(option+1)) |
| 3770 | { |
| 3771 | case 'a': |
| 3772 | { |
| 3773 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3774 | { |
| 3775 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3776 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3777 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3778 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3779 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3780 | break; |
| 3781 | } |
| 3782 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3783 | { |
| 3784 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3785 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3786 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3787 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3788 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3789 | break; |
| 3790 | } |
| 3791 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3792 | { |
| 3793 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3794 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3795 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3796 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3797 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3798 | break; |
| 3799 | } |
| 3800 | if (LocaleCompare("affine",option+1) == 0) |
| 3801 | { |
| 3802 | if (*option == '+') |
| 3803 | break; |
| 3804 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3805 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3806 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3807 | break; |
| 3808 | } |
| 3809 | if (LocaleCompare("alpha",option+1) == 0) |
| 3810 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3811 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3812 | type; |
| 3813 | |
| 3814 | if (*option == '+') |
| 3815 | break; |
| 3816 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3817 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3818 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3819 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3820 | if (type < 0) |
| 3821 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3822 | argv[i]); |
| 3823 | break; |
| 3824 | } |
| 3825 | if (LocaleCompare("annotate",option+1) == 0) |
| 3826 | { |
| 3827 | if (*option == '+') |
| 3828 | break; |
| 3829 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3830 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3831 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3832 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3833 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3834 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3835 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3836 | i++; |
| 3837 | break; |
| 3838 | } |
| 3839 | if (LocaleCompare("antialias",option+1) == 0) |
| 3840 | break; |
| 3841 | if (LocaleCompare("append",option+1) == 0) |
| 3842 | break; |
| 3843 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3844 | { |
| 3845 | if (*option == '+') |
| 3846 | break; |
| 3847 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3848 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3849 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3850 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3851 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3852 | break; |
| 3853 | } |
| 3854 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3855 | { |
| 3856 | if (*option == '+') |
| 3857 | break; |
| 3858 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3859 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3860 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3861 | break; |
| 3862 | } |
| 3863 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3864 | break; |
| 3865 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3866 | break; |
| 3867 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3868 | break; |
| 3869 | if (LocaleCompare("average",option+1) == 0) |
| 3870 | break; |
| 3871 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3872 | } |
| 3873 | case 'b': |
| 3874 | { |
| 3875 | if (LocaleCompare("background",option+1) == 0) |
| 3876 | { |
| 3877 | if (*option == '+') |
| 3878 | break; |
| 3879 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3880 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3881 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3882 | break; |
| 3883 | } |
| 3884 | if (LocaleCompare("bias",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-1)) |
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("black-point-compensation",option+1) == 0) |
| 3896 | break; |
| 3897 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 3898 | { |
| 3899 | if (*option == '+') |
| 3900 | break; |
| 3901 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3902 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3903 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3904 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3905 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3906 | break; |
| 3907 | } |
| 3908 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3909 | { |
| 3910 | if (*option == '+') |
| 3911 | break; |
| 3912 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3913 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3914 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3915 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3916 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3917 | break; |
| 3918 | } |
| 3919 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3920 | { |
| 3921 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3922 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3923 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3924 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3925 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3926 | break; |
| 3927 | } |
| 3928 | if (LocaleCompare("blur",option+1) == 0) |
| 3929 | { |
| 3930 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3931 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3932 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3933 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3934 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3935 | break; |
| 3936 | } |
| 3937 | if (LocaleCompare("border",option+1) == 0) |
| 3938 | { |
| 3939 | if (*option == '+') |
| 3940 | break; |
| 3941 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3942 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3943 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3944 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3945 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3946 | break; |
| 3947 | } |
| 3948 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3949 | { |
| 3950 | if (*option == '+') |
| 3951 | break; |
| 3952 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3953 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3954 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3955 | break; |
| 3956 | } |
| 3957 | if (LocaleCompare("box",option+1) == 0) |
| 3958 | { |
| 3959 | if (*option == '+') |
| 3960 | break; |
| 3961 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3962 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3963 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3964 | break; |
| 3965 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3966 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 3967 | { |
| 3968 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3969 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3970 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3971 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3972 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3973 | break; |
| 3974 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3975 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3976 | } |
| 3977 | case 'c': |
| 3978 | { |
| 3979 | if (LocaleCompare("cache",option+1) == 0) |
| 3980 | { |
| 3981 | if (*option == '+') |
| 3982 | break; |
| 3983 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3984 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3985 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3986 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3987 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3988 | break; |
| 3989 | } |
| 3990 | if (LocaleCompare("caption",option+1) == 0) |
| 3991 | { |
| 3992 | if (*option == '+') |
| 3993 | break; |
| 3994 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3995 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3996 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3997 | break; |
| 3998 | } |
| 3999 | if (LocaleCompare("channel",option+1) == 0) |
| 4000 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4001 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4002 | channel; |
| 4003 | |
| 4004 | if (*option == '+') |
| 4005 | break; |
| 4006 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4007 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4008 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4009 | channel=ParseChannelOption(argv[i]); |
| 4010 | if (channel < 0) |
| 4011 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 4012 | argv[i]); |
| 4013 | break; |
| 4014 | } |
| 4015 | if (LocaleCompare("cdl",option+1) == 0) |
| 4016 | { |
| 4017 | if (*option == '+') |
| 4018 | break; |
| 4019 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4020 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4021 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4022 | break; |
| 4023 | } |
| 4024 | if (LocaleCompare("charcoal",option+1) == 0) |
| 4025 | { |
| 4026 | if (*option == '+') |
| 4027 | break; |
| 4028 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4029 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4030 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4031 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4032 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4033 | break; |
| 4034 | } |
| 4035 | if (LocaleCompare("chop",option+1) == 0) |
| 4036 | { |
| 4037 | if (*option == '+') |
| 4038 | break; |
| 4039 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4040 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4041 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4042 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4043 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4044 | break; |
| 4045 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4046 | if (LocaleCompare("clamp",option+1) == 0) |
| 4047 | break; |
| 4048 | if (LocaleCompare("clip",option+1) == 0) |
| 4049 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4050 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4051 | { |
| 4052 | if (*option == '+') |
| 4053 | break; |
| 4054 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4055 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4056 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4057 | break; |
| 4058 | } |
| 4059 | if (LocaleCompare("clut",option+1) == 0) |
| 4060 | break; |
| 4061 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4062 | break; |
| 4063 | if (LocaleCompare("colorize",option+1) == 0) |
| 4064 | { |
| 4065 | if (*option == '+') |
| 4066 | break; |
| 4067 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4068 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4069 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4070 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4071 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4072 | break; |
| 4073 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4074 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4075 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4076 | KernelInfo |
| 4077 | *kernel_info; |
| 4078 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4079 | if (*option == '+') |
| 4080 | break; |
| 4081 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4082 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4083 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4084 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4085 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4086 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4087 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4088 | break; |
| 4089 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4090 | if (LocaleCompare("colors",option+1) == 0) |
| 4091 | { |
| 4092 | if (*option == '+') |
| 4093 | break; |
| 4094 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4095 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4096 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4097 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4098 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4099 | break; |
| 4100 | } |
| 4101 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4102 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4103 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4104 | colorspace; |
| 4105 | |
| 4106 | if (*option == '+') |
| 4107 | break; |
| 4108 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4109 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4110 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4111 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4112 | argv[i]); |
| 4113 | if (colorspace < 0) |
| 4114 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4115 | argv[i]); |
| 4116 | break; |
| 4117 | } |
| 4118 | if (LocaleCompare("combine",option+1) == 0) |
| 4119 | break; |
| 4120 | if (LocaleCompare("comment",option+1) == 0) |
| 4121 | { |
| 4122 | if (*option == '+') |
| 4123 | break; |
| 4124 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4125 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4126 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4127 | break; |
| 4128 | } |
| 4129 | if (LocaleCompare("composite",option+1) == 0) |
| 4130 | break; |
| 4131 | if (LocaleCompare("compress",option+1) == 0) |
| 4132 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4133 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4134 | compress; |
| 4135 | |
| 4136 | if (*option == '+') |
| 4137 | break; |
| 4138 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4139 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4140 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4141 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4142 | argv[i]); |
| 4143 | if (compress < 0) |
| 4144 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4145 | argv[i]); |
| 4146 | break; |
| 4147 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4148 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4149 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4150 | if (LocaleCompare("contrast",option+1) == 0) |
| 4151 | break; |
| 4152 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4153 | { |
| 4154 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4155 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4156 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4157 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4158 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4159 | break; |
| 4160 | } |
| 4161 | if (LocaleCompare("convolve",option+1) == 0) |
| 4162 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4163 | KernelInfo |
| 4164 | *kernel_info; |
| 4165 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4171 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4172 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4173 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4174 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4175 | break; |
| 4176 | } |
| 4177 | if (LocaleCompare("crop",option+1) == 0) |
| 4178 | { |
| 4179 | if (*option == '+') |
| 4180 | break; |
| 4181 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4182 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4183 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4184 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4185 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4186 | break; |
| 4187 | } |
| 4188 | if (LocaleCompare("cycle",option+1) == 0) |
| 4189 | { |
| 4190 | if (*option == '+') |
| 4191 | break; |
| 4192 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4193 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4194 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4195 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4196 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4197 | break; |
| 4198 | } |
| 4199 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4200 | } |
| 4201 | case 'd': |
| 4202 | { |
| 4203 | if (LocaleCompare("decipher",option+1) == 0) |
| 4204 | { |
| 4205 | if (*option == '+') |
| 4206 | break; |
| 4207 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4208 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4209 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4210 | break; |
| 4211 | } |
| 4212 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4213 | break; |
| 4214 | if (LocaleCompare("debug",option+1) == 0) |
| 4215 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4216 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4217 | event; |
| 4218 | |
| 4219 | if (*option == '+') |
| 4220 | break; |
| 4221 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4222 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4223 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4224 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4225 | if (event < 0) |
| 4226 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4227 | argv[i]); |
| 4228 | (void) SetLogEventMask(argv[i]); |
| 4229 | break; |
| 4230 | } |
| 4231 | if (LocaleCompare("define",option+1) == 0) |
| 4232 | { |
| 4233 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4234 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4235 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4236 | if (*option == '+') |
| 4237 | { |
| 4238 | const char |
| 4239 | *define; |
| 4240 | |
| 4241 | define=GetImageOption(image_info,argv[i]); |
| 4242 | if (define == (const char *) NULL) |
| 4243 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4244 | break; |
| 4245 | } |
| 4246 | break; |
| 4247 | } |
| 4248 | if (LocaleCompare("delay",option+1) == 0) |
| 4249 | { |
| 4250 | if (*option == '+') |
| 4251 | break; |
| 4252 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4253 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4254 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4255 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4256 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4257 | break; |
| 4258 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4259 | if (LocaleCompare("delete",option+1) == 0) |
| 4260 | { |
| 4261 | if (*option == '+') |
| 4262 | break; |
| 4263 | i++; |
| 4264 | if (i == (ssize_t) (argc-1)) |
| 4265 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4266 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4267 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4268 | break; |
| 4269 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4270 | if (LocaleCompare("density",option+1) == 0) |
| 4271 | { |
| 4272 | if (*option == '+') |
| 4273 | break; |
| 4274 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4275 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4276 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4277 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4278 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4279 | break; |
| 4280 | } |
| 4281 | if (LocaleCompare("depth",option+1) == 0) |
| 4282 | { |
| 4283 | if (*option == '+') |
| 4284 | break; |
| 4285 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4286 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4287 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4288 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4289 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4290 | break; |
| 4291 | } |
| 4292 | if (LocaleCompare("deskew",option+1) == 0) |
| 4293 | { |
| 4294 | if (*option == '+') |
| 4295 | break; |
| 4296 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4297 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4298 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4299 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4300 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4301 | break; |
| 4302 | } |
| 4303 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4304 | break; |
| 4305 | if (LocaleCompare("dft",option+1) == 0) |
| 4306 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4307 | if (LocaleCompare("direction",option+1) == 0) |
| 4308 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4309 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4310 | direction; |
| 4311 | |
| 4312 | if (*option == '+') |
| 4313 | break; |
| 4314 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4315 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4316 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4317 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4318 | argv[i]); |
| 4319 | if (direction < 0) |
| 4320 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4321 | argv[i]); |
| 4322 | break; |
| 4323 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4324 | if (LocaleCompare("display",option+1) == 0) |
| 4325 | { |
| 4326 | if (*option == '+') |
| 4327 | break; |
| 4328 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4329 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4330 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4331 | break; |
| 4332 | } |
| 4333 | if (LocaleCompare("dispose",option+1) == 0) |
| 4334 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4335 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4336 | dispose; |
| 4337 | |
| 4338 | if (*option == '+') |
| 4339 | break; |
| 4340 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4341 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4342 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4343 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4344 | if (dispose < 0) |
| 4345 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4346 | argv[i]); |
| 4347 | break; |
| 4348 | } |
| 4349 | if (LocaleCompare("distort",option+1) == 0) |
| 4350 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4351 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4352 | op; |
| 4353 | |
| 4354 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4355 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4356 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4357 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4358 | if (op < 0) |
| 4359 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4360 | argv[i]); |
| 4361 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4362 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4363 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4364 | break; |
| 4365 | } |
| 4366 | if (LocaleCompare("dither",option+1) == 0) |
| 4367 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4368 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4369 | method; |
| 4370 | |
| 4371 | if (*option == '+') |
| 4372 | break; |
| 4373 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4374 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4375 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4376 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4377 | if (method < 0) |
| 4378 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4379 | argv[i]); |
| 4380 | break; |
| 4381 | } |
| 4382 | if (LocaleCompare("draw",option+1) == 0) |
| 4383 | { |
| 4384 | if (*option == '+') |
| 4385 | break; |
| 4386 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4387 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4388 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4389 | break; |
| 4390 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4391 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4392 | { |
| 4393 | if (*option == '+') |
| 4394 | break; |
| 4395 | i++; |
| 4396 | if (i == (ssize_t) (argc-1)) |
| 4397 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4398 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4399 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4400 | break; |
| 4401 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4402 | if (LocaleCompare("duration",option+1) == 0) |
| 4403 | { |
| 4404 | if (*option == '+') |
| 4405 | break; |
| 4406 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4407 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4408 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4409 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4410 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4411 | break; |
| 4412 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4413 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4414 | } |
| 4415 | case 'e': |
| 4416 | { |
| 4417 | if (LocaleCompare("edge",option+1) == 0) |
| 4418 | { |
| 4419 | if (*option == '+') |
| 4420 | break; |
| 4421 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4422 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4423 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4424 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4425 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4426 | break; |
| 4427 | } |
| 4428 | if (LocaleCompare("emboss",option+1) == 0) |
| 4429 | { |
| 4430 | if (*option == '+') |
| 4431 | break; |
| 4432 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4433 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4434 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4435 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4436 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4437 | break; |
| 4438 | } |
| 4439 | if (LocaleCompare("encipher",option+1) == 0) |
| 4440 | { |
| 4441 | if (*option == '+') |
| 4442 | break; |
| 4443 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4444 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4445 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4446 | break; |
| 4447 | } |
| 4448 | if (LocaleCompare("encoding",option+1) == 0) |
| 4449 | { |
| 4450 | if (*option == '+') |
| 4451 | break; |
| 4452 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4453 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4454 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4455 | break; |
| 4456 | } |
| 4457 | if (LocaleCompare("endian",option+1) == 0) |
| 4458 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4459 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4460 | endian; |
| 4461 | |
| 4462 | if (*option == '+') |
| 4463 | break; |
| 4464 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4465 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4466 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4467 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4468 | if (endian < 0) |
| 4469 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4470 | argv[i]); |
| 4471 | break; |
| 4472 | } |
| 4473 | if (LocaleCompare("enhance",option+1) == 0) |
| 4474 | break; |
| 4475 | if (LocaleCompare("equalize",option+1) == 0) |
| 4476 | break; |
| 4477 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4478 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4479 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4480 | op; |
| 4481 | |
| 4482 | if (*option == '+') |
| 4483 | break; |
| 4484 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4485 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4486 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4487 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4488 | if (op < 0) |
| 4489 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4490 | argv[i]); |
| 4491 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4492 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4493 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4494 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4495 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4496 | break; |
| 4497 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4498 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4499 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4500 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4501 | op; |
| 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 | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4507 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4508 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4509 | if (op < 0) |
| 4510 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4511 | argv[i]); |
| 4512 | break; |
| 4513 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4514 | if (LocaleCompare("extent",option+1) == 0) |
| 4515 | { |
| 4516 | if (*option == '+') |
| 4517 | break; |
| 4518 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4519 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4520 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4521 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4522 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4523 | break; |
| 4524 | } |
| 4525 | if (LocaleCompare("extract",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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4533 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4534 | break; |
| 4535 | } |
| 4536 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4537 | } |
| 4538 | case 'f': |
| 4539 | { |
| 4540 | if (LocaleCompare("family",option+1) == 0) |
| 4541 | { |
| 4542 | if (*option == '+') |
| 4543 | break; |
| 4544 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4545 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4546 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4547 | break; |
| 4548 | } |
| 4549 | if (LocaleCompare("fill",option+1) == 0) |
| 4550 | { |
| 4551 | if (*option == '+') |
| 4552 | break; |
| 4553 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4554 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4555 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4556 | break; |
| 4557 | } |
| 4558 | if (LocaleCompare("filter",option+1) == 0) |
| 4559 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4560 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4561 | filter; |
| 4562 | |
| 4563 | if (*option == '+') |
| 4564 | break; |
| 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); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4568 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4569 | if (filter < 0) |
| 4570 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4571 | argv[i]); |
| 4572 | break; |
| 4573 | } |
| 4574 | if (LocaleCompare("flatten",option+1) == 0) |
| 4575 | break; |
| 4576 | if (LocaleCompare("flip",option+1) == 0) |
| 4577 | break; |
| 4578 | if (LocaleCompare("flop",option+1) == 0) |
| 4579 | break; |
| 4580 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4581 | { |
| 4582 | if (*option == '+') |
| 4583 | break; |
| 4584 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4585 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4586 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4587 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4588 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4589 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4590 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4591 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4592 | break; |
| 4593 | } |
| 4594 | if (LocaleCompare("font",option+1) == 0) |
| 4595 | { |
| 4596 | if (*option == '+') |
| 4597 | break; |
| 4598 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4599 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4600 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4601 | break; |
| 4602 | } |
| 4603 | if (LocaleCompare("format",option+1) == 0) |
| 4604 | { |
| 4605 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4606 | (void) CloneString(&format,(char *) NULL); |
| 4607 | if (*option == '+') |
| 4608 | break; |
| 4609 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4610 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4611 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4612 | (void) CloneString(&format,argv[i]); |
| 4613 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4614 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4615 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4616 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4617 | if (*image_info->magick == '\0') |
| 4618 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4619 | format); |
| 4620 | break; |
| 4621 | } |
| 4622 | if (LocaleCompare("frame",option+1) == 0) |
| 4623 | { |
| 4624 | if (*option == '+') |
| 4625 | break; |
| 4626 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4627 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4628 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4629 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4630 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4631 | break; |
| 4632 | } |
| 4633 | if (LocaleCompare("function",option+1) == 0) |
| 4634 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4635 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4636 | op; |
| 4637 | |
| 4638 | if (*option == '+') |
| 4639 | break; |
| 4640 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4641 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4642 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4643 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4644 | if (op < 0) |
| 4645 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4646 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4647 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4648 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4649 | break; |
| 4650 | } |
| 4651 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4652 | { |
| 4653 | if (*option == '+') |
| 4654 | break; |
| 4655 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4656 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4657 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4658 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4659 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4660 | break; |
| 4661 | } |
| 4662 | if (LocaleCompare("fx",option+1) == 0) |
| 4663 | { |
| 4664 | if (*option == '+') |
| 4665 | break; |
| 4666 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4667 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4668 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4669 | break; |
| 4670 | } |
| 4671 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4672 | } |
| 4673 | case 'g': |
| 4674 | { |
| 4675 | if (LocaleCompare("gamma",option+1) == 0) |
| 4676 | { |
| 4677 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4678 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4679 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4680 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4681 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4682 | break; |
| 4683 | } |
| 4684 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4685 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4686 | { |
| 4687 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4688 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4689 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4690 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4691 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4692 | break; |
| 4693 | } |
| 4694 | if (LocaleCompare("geometry",option+1) == 0) |
| 4695 | { |
| 4696 | if (*option == '+') |
| 4697 | break; |
| 4698 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4699 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4700 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4701 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4702 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4703 | break; |
| 4704 | } |
| 4705 | if (LocaleCompare("gravity",option+1) == 0) |
| 4706 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4707 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4708 | gravity; |
| 4709 | |
| 4710 | if (*option == '+') |
| 4711 | break; |
| 4712 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4713 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4714 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4715 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4716 | if (gravity < 0) |
| 4717 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4718 | argv[i]); |
| 4719 | break; |
| 4720 | } |
| 4721 | if (LocaleCompare("green-primary",option+1) == 0) |
| 4722 | { |
| 4723 | if (*option == '+') |
| 4724 | break; |
| 4725 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4726 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4727 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4728 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4729 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4730 | break; |
| 4731 | } |
| 4732 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4733 | } |
| 4734 | case 'h': |
| 4735 | { |
| 4736 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4737 | break; |
| 4738 | if ((LocaleCompare("help",option+1) == 0) || |
| 4739 | (LocaleCompare("-help",option+1) == 0)) |
| 4740 | return(MogrifyUsage()); |
| 4741 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4742 | } |
| 4743 | case 'i': |
| 4744 | { |
| 4745 | if (LocaleCompare("identify",option+1) == 0) |
| 4746 | break; |
| 4747 | if (LocaleCompare("idft",option+1) == 0) |
| 4748 | break; |
| 4749 | if (LocaleCompare("implode",option+1) == 0) |
| 4750 | { |
| 4751 | if (*option == '+') |
| 4752 | break; |
| 4753 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4754 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4755 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4756 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4757 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4758 | break; |
| 4759 | } |
| 4760 | if (LocaleCompare("intent",option+1) == 0) |
| 4761 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4762 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4763 | intent; |
| 4764 | |
| 4765 | if (*option == '+') |
| 4766 | break; |
| 4767 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4768 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4769 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4770 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4771 | if (intent < 0) |
| 4772 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4773 | argv[i]); |
| 4774 | break; |
| 4775 | } |
| 4776 | if (LocaleCompare("interlace",option+1) == 0) |
| 4777 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4778 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4779 | interlace; |
| 4780 | |
| 4781 | if (*option == '+') |
| 4782 | break; |
| 4783 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4784 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4785 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4786 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4787 | argv[i]); |
| 4788 | if (interlace < 0) |
| 4789 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4790 | argv[i]); |
| 4791 | break; |
| 4792 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4793 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4794 | { |
| 4795 | if (*option == '+') |
| 4796 | break; |
| 4797 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4798 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4799 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4800 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4801 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4802 | break; |
| 4803 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4804 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4805 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4806 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4807 | interpolate; |
| 4808 | |
| 4809 | if (*option == '+') |
| 4810 | break; |
| 4811 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4812 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4813 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4814 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4815 | argv[i]); |
| 4816 | if (interpolate < 0) |
| 4817 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4818 | argv[i]); |
| 4819 | break; |
| 4820 | } |
| 4821 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4822 | { |
| 4823 | if (*option == '+') |
| 4824 | break; |
| 4825 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4826 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4827 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4828 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4829 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4830 | break; |
| 4831 | } |
| 4832 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4833 | } |
| 4834 | case 'k': |
| 4835 | { |
| 4836 | if (LocaleCompare("kerning",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-1)) |
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 | break; |
| 4846 | } |
| 4847 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4848 | } |
| 4849 | case 'l': |
| 4850 | { |
| 4851 | if (LocaleCompare("label",option+1) == 0) |
| 4852 | { |
| 4853 | if (*option == '+') |
| 4854 | break; |
| 4855 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4856 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4857 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4858 | break; |
| 4859 | } |
| 4860 | if (LocaleCompare("lat",option+1) == 0) |
| 4861 | { |
| 4862 | if (*option == '+') |
| 4863 | break; |
| 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 | } |
| 4870 | if (LocaleCompare("layers",option+1) == 0) |
| 4871 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4872 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4873 | type; |
| 4874 | |
| 4875 | if (*option == '+') |
| 4876 | break; |
| 4877 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4878 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4879 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4880 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4881 | if (type < 0) |
| 4882 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4883 | argv[i]); |
| 4884 | break; |
| 4885 | } |
| 4886 | if (LocaleCompare("level",option+1) == 0) |
| 4887 | { |
| 4888 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4889 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4890 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4891 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4892 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4893 | break; |
| 4894 | } |
| 4895 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4896 | { |
| 4897 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4898 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4899 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4900 | break; |
| 4901 | } |
| 4902 | if (LocaleCompare("linewidth",option+1) == 0) |
| 4903 | { |
| 4904 | if (*option == '+') |
| 4905 | break; |
| 4906 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4907 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4908 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4909 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4910 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4911 | break; |
| 4912 | } |
| 4913 | if (LocaleCompare("limit",option+1) == 0) |
| 4914 | { |
| 4915 | char |
| 4916 | *p; |
| 4917 | |
| 4918 | double |
| 4919 | value; |
| 4920 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4921 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4922 | resource; |
| 4923 | |
| 4924 | if (*option == '+') |
| 4925 | break; |
| 4926 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4927 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4928 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4929 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4930 | argv[i]); |
| 4931 | if (resource < 0) |
| 4932 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4933 | argv[i]); |
| 4934 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4935 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4936 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 4937 | value=StringToDouble(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4938 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4939 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4940 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4941 | break; |
| 4942 | } |
| 4943 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4944 | { |
| 4945 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4946 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4947 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4948 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4949 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4950 | break; |
| 4951 | } |
| 4952 | if (LocaleCompare("list",option+1) == 0) |
| 4953 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4954 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4955 | list; |
| 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); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4962 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4963 | if (list < 0) |
| 4964 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4965 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4966 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4967 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4968 | } |
| 4969 | if (LocaleCompare("log",option+1) == 0) |
| 4970 | { |
| 4971 | if (*option == '+') |
| 4972 | break; |
| 4973 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4974 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4975 | (strchr(argv[i],'%') == (char *) NULL)) |
| 4976 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4977 | break; |
| 4978 | } |
| 4979 | if (LocaleCompare("loop",option+1) == 0) |
| 4980 | { |
| 4981 | if (*option == '+') |
| 4982 | break; |
| 4983 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4984 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4985 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4986 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4987 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4988 | break; |
| 4989 | } |
| 4990 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4991 | } |
| 4992 | case 'm': |
| 4993 | { |
| 4994 | if (LocaleCompare("map",option+1) == 0) |
| 4995 | { |
| 4996 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 4997 | if (*option == '+') |
| 4998 | break; |
| 4999 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5000 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5001 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5002 | break; |
| 5003 | } |
| 5004 | if (LocaleCompare("mask",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 | break; |
| 5012 | } |
| 5013 | if (LocaleCompare("matte",option+1) == 0) |
| 5014 | break; |
| 5015 | if (LocaleCompare("mattecolor",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 | break; |
| 5023 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5024 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5025 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5026 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5027 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5028 | if (LocaleCompare("modulate",option+1) == 0) |
| 5029 | { |
| 5030 | if (*option == '+') |
| 5031 | break; |
| 5032 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5033 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5034 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5035 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5036 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5037 | break; |
| 5038 | } |
| 5039 | if (LocaleCompare("median",option+1) == 0) |
| 5040 | { |
| 5041 | if (*option == '+') |
| 5042 | break; |
| 5043 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5044 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5045 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5046 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5047 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5048 | break; |
| 5049 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5050 | if (LocaleCompare("mode",option+1) == 0) |
| 5051 | { |
| 5052 | if (*option == '+') |
| 5053 | break; |
| 5054 | i++; |
| 5055 | if (i == (ssize_t) argc) |
| 5056 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5057 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5058 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5059 | break; |
| 5060 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5061 | if (LocaleCompare("monitor",option+1) == 0) |
| 5062 | break; |
| 5063 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5064 | break; |
| 5065 | if (LocaleCompare("morph",option+1) == 0) |
| 5066 | { |
| 5067 | if (*option == '+') |
| 5068 | break; |
| 5069 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5070 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5071 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5072 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5073 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5074 | break; |
| 5075 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5076 | if (LocaleCompare("morphology",option+1) == 0) |
| 5077 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5078 | char |
| 5079 | token[MaxTextExtent]; |
| 5080 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5081 | KernelInfo |
| 5082 | *kernel_info; |
| 5083 | |
| 5084 | ssize_t |
| 5085 | op; |
| 5086 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5087 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5088 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5089 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5090 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5091 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5092 | if (op < 0) |
| 5093 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5094 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5095 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5096 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5097 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5098 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5099 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5100 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5101 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5102 | break; |
| 5103 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5104 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5105 | break; |
| 5106 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5107 | { |
| 5108 | if (*option == '+') |
| 5109 | break; |
| 5110 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5111 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5112 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5113 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5114 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5115 | break; |
| 5116 | } |
| 5117 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5118 | } |
| 5119 | case 'n': |
| 5120 | { |
| 5121 | if (LocaleCompare("negate",option+1) == 0) |
| 5122 | break; |
| 5123 | if (LocaleCompare("noise",option+1) == 0) |
| 5124 | { |
| 5125 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5126 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5127 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5128 | if (*option == '+') |
| 5129 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5130 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5131 | noise; |
| 5132 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5133 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5134 | if (noise < 0) |
| 5135 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5136 | argv[i]); |
| 5137 | break; |
| 5138 | } |
| 5139 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5140 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5141 | break; |
| 5142 | } |
| 5143 | if (LocaleCompare("noop",option+1) == 0) |
| 5144 | break; |
| 5145 | if (LocaleCompare("normalize",option+1) == 0) |
| 5146 | break; |
| 5147 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5148 | } |
| 5149 | case 'o': |
| 5150 | { |
| 5151 | if (LocaleCompare("opaque",option+1) == 0) |
| 5152 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5153 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5154 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5155 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5156 | break; |
| 5157 | } |
| 5158 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5159 | { |
| 5160 | if (*option == '+') |
| 5161 | break; |
| 5162 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5163 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5164 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5165 | break; |
| 5166 | } |
| 5167 | if (LocaleCompare("orient",option+1) == 0) |
| 5168 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5169 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5170 | orientation; |
| 5171 | |
| 5172 | orientation=UndefinedOrientation; |
| 5173 | if (*option == '+') |
| 5174 | break; |
| 5175 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5176 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5177 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5178 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5179 | argv[i]); |
| 5180 | if (orientation < 0) |
| 5181 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5182 | argv[i]); |
| 5183 | break; |
| 5184 | } |
| 5185 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5186 | } |
| 5187 | case 'p': |
| 5188 | { |
| 5189 | if (LocaleCompare("page",option+1) == 0) |
| 5190 | { |
| 5191 | if (*option == '+') |
| 5192 | break; |
| 5193 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5194 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5195 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5196 | break; |
| 5197 | } |
| 5198 | if (LocaleCompare("paint",option+1) == 0) |
| 5199 | { |
| 5200 | if (*option == '+') |
| 5201 | break; |
| 5202 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5203 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5204 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5205 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5206 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5207 | break; |
| 5208 | } |
| 5209 | if (LocaleCompare("path",option+1) == 0) |
| 5210 | { |
| 5211 | (void) CloneString(&path,(char *) NULL); |
| 5212 | if (*option == '+') |
| 5213 | break; |
| 5214 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5215 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5216 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5217 | (void) CloneString(&path,argv[i]); |
| 5218 | break; |
| 5219 | } |
| 5220 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5221 | { |
| 5222 | if (*option == '+') |
| 5223 | break; |
| 5224 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5225 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5226 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5227 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5228 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5229 | break; |
| 5230 | } |
| 5231 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5232 | { |
| 5233 | if (*option == '+') |
| 5234 | break; |
| 5235 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5236 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5237 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5238 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5239 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5240 | break; |
| 5241 | } |
| 5242 | if (LocaleCompare("posterize",option+1) == 0) |
| 5243 | { |
| 5244 | if (*option == '+') |
| 5245 | break; |
| 5246 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5247 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5248 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5249 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5250 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5251 | break; |
| 5252 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5253 | if (LocaleCompare("precision",option+1) == 0) |
| 5254 | { |
| 5255 | if (*option == '+') |
| 5256 | break; |
| 5257 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5258 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5259 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5260 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5261 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5262 | break; |
| 5263 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5264 | if (LocaleCompare("print",option+1) == 0) |
| 5265 | { |
| 5266 | if (*option == '+') |
| 5267 | break; |
| 5268 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5269 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5270 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5271 | break; |
| 5272 | } |
| 5273 | if (LocaleCompare("process",option+1) == 0) |
| 5274 | { |
| 5275 | if (*option == '+') |
| 5276 | break; |
| 5277 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5278 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5279 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5280 | break; |
| 5281 | } |
| 5282 | if (LocaleCompare("profile",option+1) == 0) |
| 5283 | { |
| 5284 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5285 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5286 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5287 | break; |
| 5288 | } |
| 5289 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5290 | } |
| 5291 | case 'q': |
| 5292 | { |
| 5293 | if (LocaleCompare("quality",option+1) == 0) |
| 5294 | { |
| 5295 | if (*option == '+') |
| 5296 | break; |
| 5297 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5298 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5299 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5300 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5301 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5302 | break; |
| 5303 | } |
| 5304 | if (LocaleCompare("quantize",option+1) == 0) |
| 5305 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5306 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5307 | colorspace; |
| 5308 | |
| 5309 | if (*option == '+') |
| 5310 | break; |
| 5311 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5312 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5313 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5314 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5315 | argv[i]); |
| 5316 | if (colorspace < 0) |
| 5317 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5318 | argv[i]); |
| 5319 | break; |
| 5320 | } |
| 5321 | if (LocaleCompare("quiet",option+1) == 0) |
| 5322 | break; |
| 5323 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5324 | } |
| 5325 | case 'r': |
| 5326 | { |
| 5327 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5328 | { |
| 5329 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5330 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5331 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5332 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5333 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5334 | break; |
| 5335 | } |
| 5336 | if (LocaleCompare("raise",option+1) == 0) |
| 5337 | { |
| 5338 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5339 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5340 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5341 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5342 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5343 | break; |
| 5344 | } |
| 5345 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5346 | { |
| 5347 | if (*option == '+') |
| 5348 | break; |
| 5349 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5350 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5351 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5352 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5353 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5354 | break; |
| 5355 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5356 | if (LocaleCompare("recolor",option+1) == 0) |
| 5357 | { |
| 5358 | if (*option == '+') |
| 5359 | break; |
| 5360 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5361 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5362 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5363 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5364 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5365 | break; |
| 5366 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5367 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5368 | { |
| 5369 | if (*option == '+') |
| 5370 | break; |
| 5371 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5372 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5373 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5374 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5375 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5376 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5377 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5378 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5379 | if (LocaleCompare("region",option+1) == 0) |
| 5380 | { |
| 5381 | if (*option == '+') |
| 5382 | break; |
| 5383 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5384 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5385 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5386 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5387 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5388 | break; |
| 5389 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5390 | if (LocaleCompare("remap",option+1) == 0) |
| 5391 | { |
| 5392 | if (*option == '+') |
| 5393 | break; |
| 5394 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5395 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5396 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5397 | break; |
| 5398 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5399 | if (LocaleCompare("render",option+1) == 0) |
| 5400 | break; |
| 5401 | if (LocaleCompare("repage",option+1) == 0) |
| 5402 | { |
| 5403 | if (*option == '+') |
| 5404 | break; |
| 5405 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5406 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5407 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5408 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5409 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5410 | break; |
| 5411 | } |
| 5412 | if (LocaleCompare("resample",option+1) == 0) |
| 5413 | { |
| 5414 | if (*option == '+') |
| 5415 | break; |
| 5416 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5417 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5418 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5419 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5420 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5421 | break; |
| 5422 | } |
| 5423 | if (LocaleCompare("resize",option+1) == 0) |
| 5424 | { |
| 5425 | if (*option == '+') |
| 5426 | break; |
| 5427 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5428 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5429 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5430 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5431 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5432 | break; |
| 5433 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5434 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5435 | { |
| 5436 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5437 | break; |
| 5438 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5439 | if (LocaleCompare("reverse",option+1) == 0) |
| 5440 | break; |
| 5441 | if (LocaleCompare("roll",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("rotate",option+1) == 0) |
| 5453 | { |
| 5454 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5455 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5456 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5457 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5458 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5459 | break; |
| 5460 | } |
| 5461 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5462 | } |
| 5463 | case 's': |
| 5464 | { |
| 5465 | if (LocaleCompare("sample",option+1) == 0) |
| 5466 | { |
| 5467 | if (*option == '+') |
| 5468 | break; |
| 5469 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5470 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5471 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5472 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5473 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5474 | break; |
| 5475 | } |
| 5476 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5477 | { |
| 5478 | if (*option == '+') |
| 5479 | break; |
| 5480 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5481 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5482 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5483 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5484 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5485 | break; |
| 5486 | } |
| 5487 | if (LocaleCompare("scale",option+1) == 0) |
| 5488 | { |
| 5489 | if (*option == '+') |
| 5490 | break; |
| 5491 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5492 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5493 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5494 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5495 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5496 | break; |
| 5497 | } |
| 5498 | if (LocaleCompare("scene",option+1) == 0) |
| 5499 | { |
| 5500 | if (*option == '+') |
| 5501 | break; |
| 5502 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5503 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5504 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5505 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5506 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5507 | break; |
| 5508 | } |
| 5509 | if (LocaleCompare("seed",option+1) == 0) |
| 5510 | { |
| 5511 | if (*option == '+') |
| 5512 | break; |
| 5513 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5514 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5515 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5516 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5517 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5518 | break; |
| 5519 | } |
| 5520 | if (LocaleCompare("segment",option+1) == 0) |
| 5521 | { |
| 5522 | if (*option == '+') |
| 5523 | break; |
| 5524 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5525 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5526 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5527 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5528 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5529 | break; |
| 5530 | } |
| 5531 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5532 | { |
| 5533 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5534 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5535 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5536 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5537 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5538 | break; |
| 5539 | } |
| 5540 | if (LocaleCompare("separate",option+1) == 0) |
| 5541 | break; |
| 5542 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5543 | { |
| 5544 | if (*option == '+') |
| 5545 | break; |
| 5546 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5547 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5548 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5549 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5550 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5551 | break; |
| 5552 | } |
| 5553 | if (LocaleCompare("set",option+1) == 0) |
| 5554 | { |
| 5555 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5556 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5557 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5558 | if (*option == '+') |
| 5559 | break; |
| 5560 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5561 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5562 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5563 | break; |
| 5564 | } |
| 5565 | if (LocaleCompare("shade",option+1) == 0) |
| 5566 | { |
| 5567 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5568 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5569 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5570 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5571 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5572 | break; |
| 5573 | } |
| 5574 | if (LocaleCompare("shadow",option+1) == 0) |
| 5575 | { |
| 5576 | if (*option == '+') |
| 5577 | break; |
| 5578 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5579 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5580 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5581 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5582 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5583 | break; |
| 5584 | } |
| 5585 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5586 | { |
| 5587 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5588 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5589 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5590 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5591 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5592 | break; |
| 5593 | } |
| 5594 | if (LocaleCompare("shave",option+1) == 0) |
| 5595 | { |
| 5596 | if (*option == '+') |
| 5597 | break; |
| 5598 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5599 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5600 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5601 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5602 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5603 | break; |
| 5604 | } |
| 5605 | if (LocaleCompare("shear",option+1) == 0) |
| 5606 | { |
| 5607 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5608 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5609 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5610 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5611 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5612 | break; |
| 5613 | } |
| 5614 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5615 | { |
| 5616 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5617 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5618 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5619 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5620 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5621 | break; |
| 5622 | } |
| 5623 | if (LocaleCompare("size",option+1) == 0) |
| 5624 | { |
| 5625 | if (*option == '+') |
| 5626 | break; |
| 5627 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5628 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5629 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5630 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5631 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5632 | break; |
| 5633 | } |
| 5634 | if (LocaleCompare("sketch",option+1) == 0) |
| 5635 | { |
| 5636 | if (*option == '+') |
| 5637 | break; |
| 5638 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5639 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5640 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5641 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5642 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5643 | break; |
| 5644 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5645 | if (LocaleCompare("smush",option+1) == 0) |
| 5646 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5647 | i++; |
| 5648 | if (i == (ssize_t) argc) |
| 5649 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5650 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5651 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5652 | i++; |
| 5653 | break; |
| 5654 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5655 | if (LocaleCompare("solarize",option+1) == 0) |
| 5656 | { |
| 5657 | if (*option == '+') |
| 5658 | break; |
| 5659 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5660 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5661 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5662 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5663 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5664 | break; |
| 5665 | } |
| 5666 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5667 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5668 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5669 | op; |
| 5670 | |
| 5671 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5672 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5673 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5674 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5675 | if (op < 0) |
| 5676 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5677 | argv[i]); |
| 5678 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5679 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5680 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5681 | break; |
| 5682 | } |
| 5683 | if (LocaleCompare("spread",option+1) == 0) |
| 5684 | { |
| 5685 | if (*option == '+') |
| 5686 | break; |
| 5687 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5688 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5689 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5690 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5691 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5692 | break; |
| 5693 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5694 | if (LocaleCompare("statistic",option+1) == 0) |
| 5695 | { |
| 5696 | ssize_t |
| 5697 | op; |
| 5698 | |
| 5699 | if (*option == '+') |
| 5700 | break; |
| 5701 | i++; |
| 5702 | if (i == (ssize_t) argc) |
| 5703 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5704 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5705 | if (op < 0) |
| 5706 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5707 | argv[i]); |
| 5708 | i++; |
| 5709 | if (i == (ssize_t) (argc-1)) |
| 5710 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5711 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5712 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5713 | break; |
| 5714 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5715 | if (LocaleCompare("stretch",option+1) == 0) |
| 5716 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5717 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5718 | stretch; |
| 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-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5724 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5725 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5726 | if (stretch < 0) |
| 5727 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5728 | argv[i]); |
| 5729 | break; |
| 5730 | } |
| 5731 | if (LocaleCompare("strip",option+1) == 0) |
| 5732 | break; |
| 5733 | if (LocaleCompare("stroke",option+1) == 0) |
| 5734 | { |
| 5735 | if (*option == '+') |
| 5736 | break; |
| 5737 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5738 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5739 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5740 | break; |
| 5741 | } |
| 5742 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5743 | { |
| 5744 | if (*option == '+') |
| 5745 | break; |
| 5746 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5747 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5748 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5749 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5750 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5751 | break; |
| 5752 | } |
| 5753 | if (LocaleCompare("style",option+1) == 0) |
| 5754 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5755 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5756 | style; |
| 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-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5762 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5763 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5764 | if (style < 0) |
| 5765 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5766 | argv[i]); |
| 5767 | break; |
| 5768 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5769 | if (LocaleCompare("swap",option+1) == 0) |
| 5770 | { |
| 5771 | if (*option == '+') |
| 5772 | break; |
| 5773 | i++; |
| 5774 | if (i == (ssize_t) (argc-1)) |
| 5775 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5776 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5777 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5778 | break; |
| 5779 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5780 | if (LocaleCompare("swirl",option+1) == 0) |
| 5781 | { |
| 5782 | if (*option == '+') |
| 5783 | break; |
| 5784 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5785 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5786 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5787 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5788 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5789 | break; |
| 5790 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5791 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5792 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5793 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5794 | } |
| 5795 | case 't': |
| 5796 | { |
| 5797 | if (LocaleCompare("taint",option+1) == 0) |
| 5798 | break; |
| 5799 | if (LocaleCompare("texture",option+1) == 0) |
| 5800 | { |
| 5801 | if (*option == '+') |
| 5802 | break; |
| 5803 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5804 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5805 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5806 | break; |
| 5807 | } |
| 5808 | if (LocaleCompare("tile",option+1) == 0) |
| 5809 | { |
| 5810 | if (*option == '+') |
| 5811 | break; |
| 5812 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5813 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5814 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5815 | break; |
| 5816 | } |
| 5817 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5818 | { |
| 5819 | if (*option == '+') |
| 5820 | break; |
| 5821 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5822 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5823 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5824 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5825 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5826 | break; |
| 5827 | } |
| 5828 | if (LocaleCompare("tint",option+1) == 0) |
| 5829 | { |
| 5830 | if (*option == '+') |
| 5831 | break; |
| 5832 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5833 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5834 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5835 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5836 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5837 | break; |
| 5838 | } |
| 5839 | if (LocaleCompare("transform",option+1) == 0) |
| 5840 | break; |
| 5841 | if (LocaleCompare("transpose",option+1) == 0) |
| 5842 | break; |
| 5843 | if (LocaleCompare("transverse",option+1) == 0) |
| 5844 | break; |
| 5845 | if (LocaleCompare("threshold",option+1) == 0) |
| 5846 | { |
| 5847 | if (*option == '+') |
| 5848 | break; |
| 5849 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5850 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5851 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5852 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5853 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5854 | break; |
| 5855 | } |
| 5856 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5857 | { |
| 5858 | if (*option == '+') |
| 5859 | break; |
| 5860 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5861 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5862 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5863 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5864 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5865 | break; |
| 5866 | } |
| 5867 | if (LocaleCompare("transparent",option+1) == 0) |
| 5868 | { |
| 5869 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5870 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5871 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5872 | break; |
| 5873 | } |
| 5874 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 5875 | { |
| 5876 | if (*option == '+') |
| 5877 | break; |
| 5878 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5879 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5880 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5881 | break; |
| 5882 | } |
| 5883 | if (LocaleCompare("treedepth",option+1) == 0) |
| 5884 | { |
| 5885 | if (*option == '+') |
| 5886 | break; |
| 5887 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5888 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5889 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5890 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5891 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5892 | break; |
| 5893 | } |
| 5894 | if (LocaleCompare("trim",option+1) == 0) |
| 5895 | break; |
| 5896 | if (LocaleCompare("type",option+1) == 0) |
| 5897 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5898 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5899 | type; |
| 5900 | |
| 5901 | if (*option == '+') |
| 5902 | break; |
| 5903 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5904 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5905 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5906 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5907 | if (type < 0) |
| 5908 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5909 | argv[i]); |
| 5910 | break; |
| 5911 | } |
| 5912 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5913 | } |
| 5914 | case 'u': |
| 5915 | { |
| 5916 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5917 | { |
| 5918 | if (*option == '+') |
| 5919 | break; |
| 5920 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5921 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5922 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5923 | break; |
| 5924 | } |
| 5925 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5926 | break; |
| 5927 | if (LocaleCompare("units",option+1) == 0) |
| 5928 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5929 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5930 | units; |
| 5931 | |
| 5932 | if (*option == '+') |
| 5933 | break; |
| 5934 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5935 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5936 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5937 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5938 | argv[i]); |
| 5939 | if (units < 0) |
| 5940 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5941 | argv[i]); |
| 5942 | break; |
| 5943 | } |
| 5944 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5945 | { |
| 5946 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5947 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5948 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5949 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5950 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5951 | break; |
| 5952 | } |
| 5953 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5954 | } |
| 5955 | case 'v': |
| 5956 | { |
| 5957 | if (LocaleCompare("verbose",option+1) == 0) |
| 5958 | { |
| 5959 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 5960 | break; |
| 5961 | } |
| 5962 | if ((LocaleCompare("version",option+1) == 0) || |
| 5963 | (LocaleCompare("-version",option+1) == 0)) |
| 5964 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 5965 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5966 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 5967 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 5968 | GetMagickCopyright()); |
| 5969 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 5970 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5971 | break; |
| 5972 | } |
| 5973 | if (LocaleCompare("view",option+1) == 0) |
| 5974 | { |
| 5975 | if (*option == '+') |
| 5976 | break; |
| 5977 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5978 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5979 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5980 | break; |
| 5981 | } |
| 5982 | if (LocaleCompare("vignette",option+1) == 0) |
| 5983 | { |
| 5984 | if (*option == '+') |
| 5985 | break; |
| 5986 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5987 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5988 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5989 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5990 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5991 | break; |
| 5992 | } |
| 5993 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 5994 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5995 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5996 | method; |
| 5997 | |
| 5998 | if (*option == '+') |
| 5999 | break; |
| 6000 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6001 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6002 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6003 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6004 | argv[i]); |
| 6005 | if (method < 0) |
| 6006 | ThrowMogrifyException(OptionError, |
| 6007 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 6008 | break; |
| 6009 | } |
| 6010 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6011 | } |
| 6012 | case 'w': |
| 6013 | { |
| 6014 | if (LocaleCompare("wave",option+1) == 0) |
| 6015 | { |
| 6016 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6017 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6018 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6019 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6020 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6021 | break; |
| 6022 | } |
| 6023 | if (LocaleCompare("weight",option+1) == 0) |
| 6024 | { |
| 6025 | if (*option == '+') |
| 6026 | break; |
| 6027 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6028 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6029 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6030 | break; |
| 6031 | } |
| 6032 | if (LocaleCompare("white-point",option+1) == 0) |
| 6033 | { |
| 6034 | if (*option == '+') |
| 6035 | break; |
| 6036 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6037 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6038 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6039 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6040 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6041 | break; |
| 6042 | } |
| 6043 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6044 | { |
| 6045 | if (*option == '+') |
| 6046 | break; |
| 6047 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6048 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6049 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6050 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6051 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6052 | break; |
| 6053 | } |
| 6054 | if (LocaleCompare("write",option+1) == 0) |
| 6055 | { |
| 6056 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6057 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6058 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6059 | break; |
| 6060 | } |
| 6061 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6062 | } |
| 6063 | case '?': |
| 6064 | break; |
| 6065 | default: |
| 6066 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6067 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6068 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 6069 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6070 | if (fire != MagickFalse) |
| 6071 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6072 | } |
| 6073 | if (k != 0) |
| 6074 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6075 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6076 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6077 | DestroyMogrify(); |
| 6078 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6079 | } |
| 6080 | |
| 6081 | /* |
| 6082 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6083 | % % |
| 6084 | % % |
| 6085 | % % |
| 6086 | + M o g r i f y I m a g e I n f o % |
| 6087 | % % |
| 6088 | % % |
| 6089 | % % |
| 6090 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6091 | % |
| 6092 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6093 | % prescribed by command line options. |
| 6094 | % |
| 6095 | % The format of the MogrifyImageInfo method is: |
| 6096 | % |
| 6097 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6098 | % const char **argv,ExceptionInfo *exception) |
| 6099 | % |
| 6100 | % A description of each parameter follows: |
| 6101 | % |
| 6102 | % o image_info: the image info.. |
| 6103 | % |
| 6104 | % o argc: Specifies a pointer to an integer describing the number of |
| 6105 | % elements in the argument vector. |
| 6106 | % |
| 6107 | % o argv: Specifies a pointer to a text array containing the command line |
| 6108 | % arguments. |
| 6109 | % |
| 6110 | % o exception: return any errors or warnings in this structure. |
| 6111 | % |
| 6112 | */ |
| 6113 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6114 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6115 | { |
| 6116 | const char |
| 6117 | *option; |
| 6118 | |
| 6119 | GeometryInfo |
| 6120 | geometry_info; |
| 6121 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6122 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6123 | count; |
| 6124 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6125 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6126 | i; |
| 6127 | |
| 6128 | /* |
| 6129 | Initialize method variables. |
| 6130 | */ |
| 6131 | assert(image_info != (ImageInfo *) NULL); |
| 6132 | assert(image_info->signature == MagickSignature); |
| 6133 | if (image_info->debug != MagickFalse) |
| 6134 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6135 | image_info->filename); |
| 6136 | if (argc < 0) |
| 6137 | return(MagickTrue); |
| 6138 | /* |
| 6139 | Set the image settings. |
| 6140 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6141 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6142 | { |
| 6143 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6144 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6145 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6146 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6147 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6148 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6149 | break; |
| 6150 | switch (*(option+1)) |
| 6151 | { |
| 6152 | case 'a': |
| 6153 | { |
| 6154 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6155 | { |
| 6156 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6157 | break; |
| 6158 | } |
| 6159 | if (LocaleCompare("antialias",option+1) == 0) |
| 6160 | { |
| 6161 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6162 | break; |
| 6163 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6164 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6165 | { |
| 6166 | if (*option == '+') |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 6167 | (void) DeleteImageOption(image_info,option+1); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6168 | else |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 6169 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6170 | break; |
| 6171 | } |
| 6172 | break; |
| 6173 | } |
| 6174 | case 'b': |
| 6175 | { |
| 6176 | if (LocaleCompare("background",option+1) == 0) |
| 6177 | { |
| 6178 | if (*option == '+') |
| 6179 | { |
| 6180 | (void) DeleteImageOption(image_info,option+1); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6181 | (void) QueryColorCompliance(MogrifyBackgroundColor, |
| 6182 | AllCompliance,&image_info->background_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6183 | break; |
| 6184 | } |
| 6185 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6186 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6187 | &image_info->background_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6188 | break; |
| 6189 | } |
| 6190 | if (LocaleCompare("bias",option+1) == 0) |
| 6191 | { |
| 6192 | if (*option == '+') |
| 6193 | { |
| 6194 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6195 | break; |
| 6196 | } |
| 6197 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6198 | break; |
| 6199 | } |
| 6200 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6201 | { |
| 6202 | if (*option == '+') |
| 6203 | { |
| 6204 | (void) SetImageOption(image_info,option+1,"false"); |
| 6205 | break; |
| 6206 | } |
| 6207 | (void) SetImageOption(image_info,option+1,"true"); |
| 6208 | break; |
| 6209 | } |
| 6210 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6211 | { |
| 6212 | if (*option == '+') |
| 6213 | { |
| 6214 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6215 | break; |
| 6216 | } |
| 6217 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6218 | break; |
| 6219 | } |
| 6220 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6221 | { |
| 6222 | if (*option == '+') |
| 6223 | { |
| 6224 | (void) DeleteImageOption(image_info,option+1); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6225 | (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6226 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6227 | break; |
| 6228 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6229 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6230 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6231 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6232 | break; |
| 6233 | } |
| 6234 | if (LocaleCompare("box",option+1) == 0) |
| 6235 | { |
| 6236 | if (*option == '+') |
| 6237 | { |
| 6238 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6239 | break; |
| 6240 | } |
| 6241 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6242 | break; |
| 6243 | } |
| 6244 | break; |
| 6245 | } |
| 6246 | case 'c': |
| 6247 | { |
| 6248 | if (LocaleCompare("cache",option+1) == 0) |
| 6249 | { |
| 6250 | MagickSizeType |
| 6251 | limit; |
| 6252 | |
| 6253 | limit=MagickResourceInfinity; |
| 6254 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 6255 | limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1], |
| 6256 | 100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6257 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6258 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6259 | break; |
| 6260 | } |
| 6261 | if (LocaleCompare("caption",option+1) == 0) |
| 6262 | { |
| 6263 | if (*option == '+') |
| 6264 | { |
| 6265 | (void) DeleteImageOption(image_info,option+1); |
| 6266 | break; |
| 6267 | } |
| 6268 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6269 | break; |
| 6270 | } |
| 6271 | if (LocaleCompare("channel",option+1) == 0) |
| 6272 | { |
| 6273 | if (*option == '+') |
| 6274 | { |
| 6275 | image_info->channel=DefaultChannels; |
| 6276 | break; |
| 6277 | } |
| 6278 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6279 | break; |
| 6280 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6281 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6282 | { |
| 6283 | if (*option == '+') |
| 6284 | { |
| 6285 | image_info->colorspace=UndefinedColorspace; |
| 6286 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6287 | break; |
| 6288 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6289 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6290 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6291 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6292 | break; |
| 6293 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6294 | if (LocaleCompare("comment",option+1) == 0) |
| 6295 | { |
| 6296 | if (*option == '+') |
| 6297 | { |
| 6298 | (void) DeleteImageOption(image_info,option+1); |
| 6299 | break; |
| 6300 | } |
| 6301 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6302 | break; |
| 6303 | } |
| 6304 | if (LocaleCompare("compose",option+1) == 0) |
| 6305 | { |
| 6306 | if (*option == '+') |
| 6307 | { |
| 6308 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6309 | break; |
| 6310 | } |
| 6311 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6312 | break; |
| 6313 | } |
| 6314 | if (LocaleCompare("compress",option+1) == 0) |
| 6315 | { |
| 6316 | if (*option == '+') |
| 6317 | { |
| 6318 | image_info->compression=UndefinedCompression; |
| 6319 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6320 | break; |
| 6321 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6322 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6323 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6324 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6325 | break; |
| 6326 | } |
| 6327 | break; |
| 6328 | } |
| 6329 | case 'd': |
| 6330 | { |
| 6331 | if (LocaleCompare("debug",option+1) == 0) |
| 6332 | { |
| 6333 | if (*option == '+') |
| 6334 | (void) SetLogEventMask("none"); |
| 6335 | else |
| 6336 | (void) SetLogEventMask(argv[i+1]); |
| 6337 | image_info->debug=IsEventLogging(); |
| 6338 | break; |
| 6339 | } |
| 6340 | if (LocaleCompare("define",option+1) == 0) |
| 6341 | { |
| 6342 | if (*option == '+') |
| 6343 | { |
| 6344 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6345 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6346 | else |
| 6347 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6348 | break; |
| 6349 | } |
| 6350 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6351 | { |
| 6352 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6353 | exception); |
| 6354 | break; |
| 6355 | } |
| 6356 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6357 | break; |
| 6358 | } |
| 6359 | if (LocaleCompare("delay",option+1) == 0) |
| 6360 | { |
| 6361 | if (*option == '+') |
| 6362 | { |
| 6363 | (void) SetImageOption(image_info,option+1,"0"); |
| 6364 | break; |
| 6365 | } |
| 6366 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6367 | break; |
| 6368 | } |
| 6369 | if (LocaleCompare("density",option+1) == 0) |
| 6370 | { |
| 6371 | /* |
| 6372 | Set image density. |
| 6373 | */ |
| 6374 | if (*option == '+') |
| 6375 | { |
| 6376 | if (image_info->density != (char *) NULL) |
| 6377 | image_info->density=DestroyString(image_info->density); |
| 6378 | (void) SetImageOption(image_info,option+1,"72"); |
| 6379 | break; |
| 6380 | } |
| 6381 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6382 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6383 | break; |
| 6384 | } |
| 6385 | if (LocaleCompare("depth",option+1) == 0) |
| 6386 | { |
| 6387 | if (*option == '+') |
| 6388 | { |
| 6389 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6390 | break; |
| 6391 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6392 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6393 | break; |
| 6394 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6395 | if (LocaleCompare("direction",option+1) == 0) |
| 6396 | { |
| 6397 | if (*option == '+') |
| 6398 | { |
| 6399 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6400 | break; |
| 6401 | } |
| 6402 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6403 | break; |
| 6404 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6405 | if (LocaleCompare("display",option+1) == 0) |
| 6406 | { |
| 6407 | if (*option == '+') |
| 6408 | { |
| 6409 | if (image_info->server_name != (char *) NULL) |
| 6410 | image_info->server_name=DestroyString( |
| 6411 | image_info->server_name); |
| 6412 | break; |
| 6413 | } |
| 6414 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6415 | break; |
| 6416 | } |
| 6417 | if (LocaleCompare("dispose",option+1) == 0) |
| 6418 | { |
| 6419 | if (*option == '+') |
| 6420 | { |
| 6421 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6422 | break; |
| 6423 | } |
| 6424 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6425 | break; |
| 6426 | } |
| 6427 | if (LocaleCompare("dither",option+1) == 0) |
| 6428 | { |
| 6429 | if (*option == '+') |
| 6430 | { |
| 6431 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6432 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6433 | break; |
| 6434 | } |
| 6435 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6436 | image_info->dither=MagickTrue; |
| 6437 | break; |
| 6438 | } |
| 6439 | break; |
| 6440 | } |
| 6441 | case 'e': |
| 6442 | { |
| 6443 | if (LocaleCompare("encoding",option+1) == 0) |
| 6444 | { |
| 6445 | if (*option == '+') |
| 6446 | { |
| 6447 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6448 | break; |
| 6449 | } |
| 6450 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6451 | break; |
| 6452 | } |
| 6453 | if (LocaleCompare("endian",option+1) == 0) |
| 6454 | { |
| 6455 | if (*option == '+') |
| 6456 | { |
| 6457 | image_info->endian=UndefinedEndian; |
| 6458 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6459 | break; |
| 6460 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6461 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6462 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6463 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6464 | break; |
| 6465 | } |
| 6466 | if (LocaleCompare("extract",option+1) == 0) |
| 6467 | { |
| 6468 | /* |
| 6469 | Set image extract geometry. |
| 6470 | */ |
| 6471 | if (*option == '+') |
| 6472 | { |
| 6473 | if (image_info->extract != (char *) NULL) |
| 6474 | image_info->extract=DestroyString(image_info->extract); |
| 6475 | break; |
| 6476 | } |
| 6477 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6478 | break; |
| 6479 | } |
| 6480 | break; |
| 6481 | } |
| 6482 | case 'f': |
| 6483 | { |
| 6484 | if (LocaleCompare("fill",option+1) == 0) |
| 6485 | { |
| 6486 | if (*option == '+') |
| 6487 | { |
| 6488 | (void) SetImageOption(image_info,option+1,"none"); |
| 6489 | break; |
| 6490 | } |
| 6491 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6492 | break; |
| 6493 | } |
| 6494 | if (LocaleCompare("filter",option+1) == 0) |
| 6495 | { |
| 6496 | if (*option == '+') |
| 6497 | { |
| 6498 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6499 | break; |
| 6500 | } |
| 6501 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6502 | break; |
| 6503 | } |
| 6504 | if (LocaleCompare("font",option+1) == 0) |
| 6505 | { |
| 6506 | if (*option == '+') |
| 6507 | { |
| 6508 | if (image_info->font != (char *) NULL) |
| 6509 | image_info->font=DestroyString(image_info->font); |
| 6510 | break; |
| 6511 | } |
| 6512 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6513 | break; |
| 6514 | } |
| 6515 | if (LocaleCompare("format",option+1) == 0) |
| 6516 | { |
| 6517 | register const char |
| 6518 | *q; |
| 6519 | |
| 6520 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6521 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6522 | image_info->ping=MagickFalse; |
| 6523 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6524 | break; |
| 6525 | } |
| 6526 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6527 | { |
| 6528 | if (*option == '+') |
| 6529 | { |
| 6530 | image_info->fuzz=0.0; |
| 6531 | (void) SetImageOption(image_info,option+1,"0"); |
| 6532 | break; |
| 6533 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 6534 | image_info->fuzz=StringToDoubleInterval(argv[i+1],(double) |
| 6535 | QuantumRange+1.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6536 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6537 | break; |
| 6538 | } |
| 6539 | break; |
| 6540 | } |
| 6541 | case 'g': |
| 6542 | { |
| 6543 | if (LocaleCompare("gravity",option+1) == 0) |
| 6544 | { |
| 6545 | if (*option == '+') |
| 6546 | { |
| 6547 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6548 | break; |
| 6549 | } |
| 6550 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6551 | break; |
| 6552 | } |
| 6553 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6554 | { |
| 6555 | if (*option == '+') |
| 6556 | { |
| 6557 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6558 | break; |
| 6559 | } |
| 6560 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6561 | break; |
| 6562 | } |
| 6563 | break; |
| 6564 | } |
| 6565 | case 'i': |
| 6566 | { |
| 6567 | if (LocaleCompare("intent",option+1) == 0) |
| 6568 | { |
| 6569 | if (*option == '+') |
| 6570 | { |
| 6571 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6572 | break; |
| 6573 | } |
| 6574 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6575 | break; |
| 6576 | } |
| 6577 | if (LocaleCompare("interlace",option+1) == 0) |
| 6578 | { |
| 6579 | if (*option == '+') |
| 6580 | { |
| 6581 | image_info->interlace=UndefinedInterlace; |
| 6582 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6583 | break; |
| 6584 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6585 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6586 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6587 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6588 | break; |
| 6589 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6590 | if (LocaleCompare("interline-spacing",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 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6600 | if (LocaleCompare("interpolate",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 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6611 | { |
| 6612 | if (*option == '+') |
| 6613 | { |
| 6614 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6615 | break; |
| 6616 | } |
| 6617 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6618 | break; |
| 6619 | } |
| 6620 | break; |
| 6621 | } |
| 6622 | case 'k': |
| 6623 | { |
| 6624 | if (LocaleCompare("kerning",option+1) == 0) |
| 6625 | { |
| 6626 | if (*option == '+') |
| 6627 | { |
| 6628 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6629 | break; |
| 6630 | } |
| 6631 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6632 | break; |
| 6633 | } |
| 6634 | break; |
| 6635 | } |
| 6636 | case 'l': |
| 6637 | { |
| 6638 | if (LocaleCompare("label",option+1) == 0) |
| 6639 | { |
| 6640 | if (*option == '+') |
| 6641 | { |
| 6642 | (void) DeleteImageOption(image_info,option+1); |
| 6643 | break; |
| 6644 | } |
| 6645 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6646 | break; |
| 6647 | } |
| 6648 | if (LocaleCompare("limit",option+1) == 0) |
| 6649 | { |
| 6650 | MagickSizeType |
| 6651 | limit; |
| 6652 | |
| 6653 | ResourceType |
| 6654 | type; |
| 6655 | |
| 6656 | if (*option == '+') |
| 6657 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6658 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6659 | MagickFalse,argv[i+1]); |
| 6660 | limit=MagickResourceInfinity; |
| 6661 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 6662 | limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2], |
| 6663 | 100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6664 | (void) SetMagickResourceLimit(type,limit); |
| 6665 | break; |
| 6666 | } |
| 6667 | if (LocaleCompare("list",option+1) == 0) |
| 6668 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6669 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6670 | list; |
| 6671 | |
| 6672 | /* |
| 6673 | Display configuration list. |
| 6674 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6675 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6676 | switch (list) |
| 6677 | { |
| 6678 | case MagickCoderOptions: |
| 6679 | { |
| 6680 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6681 | break; |
| 6682 | } |
| 6683 | case MagickColorOptions: |
| 6684 | { |
| 6685 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6686 | break; |
| 6687 | } |
| 6688 | case MagickConfigureOptions: |
| 6689 | { |
| 6690 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6691 | break; |
| 6692 | } |
| 6693 | case MagickDelegateOptions: |
| 6694 | { |
| 6695 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6696 | break; |
| 6697 | } |
| 6698 | case MagickFontOptions: |
| 6699 | { |
| 6700 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6701 | break; |
| 6702 | } |
| 6703 | case MagickFormatOptions: |
| 6704 | { |
| 6705 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6706 | break; |
| 6707 | } |
| 6708 | case MagickLocaleOptions: |
| 6709 | { |
| 6710 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6711 | break; |
| 6712 | } |
| 6713 | case MagickLogOptions: |
| 6714 | { |
| 6715 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6716 | break; |
| 6717 | } |
| 6718 | case MagickMagicOptions: |
| 6719 | { |
| 6720 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6721 | break; |
| 6722 | } |
| 6723 | case MagickMimeOptions: |
| 6724 | { |
| 6725 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6726 | break; |
| 6727 | } |
| 6728 | case MagickModuleOptions: |
| 6729 | { |
| 6730 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6731 | break; |
| 6732 | } |
| 6733 | case MagickPolicyOptions: |
| 6734 | { |
| 6735 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6736 | break; |
| 6737 | } |
| 6738 | case MagickResourceOptions: |
| 6739 | { |
| 6740 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6741 | break; |
| 6742 | } |
| 6743 | case MagickThresholdOptions: |
| 6744 | { |
| 6745 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6746 | break; |
| 6747 | } |
| 6748 | default: |
| 6749 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6750 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6751 | exception); |
| 6752 | break; |
| 6753 | } |
| 6754 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6755 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6756 | } |
| 6757 | if (LocaleCompare("log",option+1) == 0) |
| 6758 | { |
| 6759 | if (*option == '+') |
| 6760 | break; |
| 6761 | (void) SetLogFormat(argv[i+1]); |
| 6762 | break; |
| 6763 | } |
| 6764 | if (LocaleCompare("loop",option+1) == 0) |
| 6765 | { |
| 6766 | if (*option == '+') |
| 6767 | { |
| 6768 | (void) SetImageOption(image_info,option+1,"0"); |
| 6769 | break; |
| 6770 | } |
| 6771 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6772 | break; |
| 6773 | } |
| 6774 | break; |
| 6775 | } |
| 6776 | case 'm': |
| 6777 | { |
| 6778 | if (LocaleCompare("matte",option+1) == 0) |
| 6779 | { |
| 6780 | if (*option == '+') |
| 6781 | { |
| 6782 | (void) SetImageOption(image_info,option+1,"false"); |
| 6783 | break; |
| 6784 | } |
| 6785 | (void) SetImageOption(image_info,option+1,"true"); |
| 6786 | break; |
| 6787 | } |
| 6788 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6789 | { |
| 6790 | if (*option == '+') |
| 6791 | { |
| 6792 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6793 | (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance, |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6794 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6795 | break; |
| 6796 | } |
| 6797 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6798 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6799 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6800 | break; |
| 6801 | } |
| 6802 | if (LocaleCompare("monitor",option+1) == 0) |
| 6803 | { |
| 6804 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6805 | (void *) NULL); |
| 6806 | break; |
| 6807 | } |
| 6808 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6809 | { |
| 6810 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6811 | break; |
| 6812 | } |
| 6813 | break; |
| 6814 | } |
| 6815 | case 'o': |
| 6816 | { |
| 6817 | if (LocaleCompare("orient",option+1) == 0) |
| 6818 | { |
| 6819 | if (*option == '+') |
| 6820 | { |
| 6821 | image_info->orientation=UndefinedOrientation; |
| 6822 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6823 | break; |
| 6824 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6825 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6826 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6827 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6828 | break; |
| 6829 | } |
| 6830 | } |
| 6831 | case 'p': |
| 6832 | { |
| 6833 | if (LocaleCompare("page",option+1) == 0) |
| 6834 | { |
| 6835 | char |
| 6836 | *canonical_page, |
| 6837 | page[MaxTextExtent]; |
| 6838 | |
| 6839 | const char |
| 6840 | *image_option; |
| 6841 | |
| 6842 | MagickStatusType |
| 6843 | flags; |
| 6844 | |
| 6845 | RectangleInfo |
| 6846 | geometry; |
| 6847 | |
| 6848 | if (*option == '+') |
| 6849 | { |
| 6850 | (void) DeleteImageOption(image_info,option+1); |
| 6851 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6852 | break; |
| 6853 | } |
| 6854 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6855 | image_option=GetImageOption(image_info,"page"); |
| 6856 | if (image_option != (const char *) NULL) |
| 6857 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6858 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6859 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6860 | canonical_page=DestroyString(canonical_page); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6861 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6862 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6863 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6864 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6865 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6866 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6867 | (void) SetImageOption(image_info,option+1,page); |
| 6868 | (void) CloneString(&image_info->page,page); |
| 6869 | break; |
| 6870 | } |
| 6871 | if (LocaleCompare("pen",option+1) == 0) |
| 6872 | { |
| 6873 | if (*option == '+') |
| 6874 | { |
| 6875 | (void) SetImageOption(image_info,option+1,"none"); |
| 6876 | break; |
| 6877 | } |
| 6878 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6879 | break; |
| 6880 | } |
| 6881 | if (LocaleCompare("ping",option+1) == 0) |
| 6882 | { |
| 6883 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6884 | break; |
| 6885 | } |
| 6886 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6887 | { |
| 6888 | if (*option == '+') |
| 6889 | geometry_info.rho=0.0; |
| 6890 | else |
| 6891 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6892 | image_info->pointsize=geometry_info.rho; |
| 6893 | break; |
| 6894 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6895 | if (LocaleCompare("precision",option+1) == 0) |
| 6896 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6897 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6898 | break; |
| 6899 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6900 | if (LocaleCompare("preview",option+1) == 0) |
| 6901 | { |
| 6902 | /* |
| 6903 | Preview image. |
| 6904 | */ |
| 6905 | if (*option == '+') |
| 6906 | { |
| 6907 | image_info->preview_type=UndefinedPreview; |
| 6908 | break; |
| 6909 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6910 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6911 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6912 | break; |
| 6913 | } |
| 6914 | break; |
| 6915 | } |
| 6916 | case 'q': |
| 6917 | { |
| 6918 | if (LocaleCompare("quality",option+1) == 0) |
| 6919 | { |
| 6920 | /* |
| 6921 | Set image compression quality. |
| 6922 | */ |
| 6923 | if (*option == '+') |
| 6924 | { |
| 6925 | image_info->quality=UndefinedCompressionQuality; |
| 6926 | (void) SetImageOption(image_info,option+1,"0"); |
| 6927 | break; |
| 6928 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6929 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6930 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6931 | break; |
| 6932 | } |
| 6933 | if (LocaleCompare("quiet",option+1) == 0) |
| 6934 | { |
| 6935 | static WarningHandler |
| 6936 | warning_handler = (WarningHandler) NULL; |
| 6937 | |
| 6938 | if (*option == '+') |
| 6939 | { |
| 6940 | /* |
| 6941 | Restore error or warning messages. |
| 6942 | */ |
| 6943 | warning_handler=SetWarningHandler(warning_handler); |
| 6944 | break; |
| 6945 | } |
| 6946 | /* |
| 6947 | Suppress error or warning messages. |
| 6948 | */ |
| 6949 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6950 | break; |
| 6951 | } |
| 6952 | break; |
| 6953 | } |
| 6954 | case 'r': |
| 6955 | { |
| 6956 | if (LocaleCompare("red-primary",option+1) == 0) |
| 6957 | { |
| 6958 | if (*option == '+') |
| 6959 | { |
| 6960 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6961 | break; |
| 6962 | } |
| 6963 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6964 | break; |
| 6965 | } |
| 6966 | break; |
| 6967 | } |
| 6968 | case 's': |
| 6969 | { |
| 6970 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 6971 | { |
| 6972 | /* |
| 6973 | Set image sampling factor. |
| 6974 | */ |
| 6975 | if (*option == '+') |
| 6976 | { |
| 6977 | if (image_info->sampling_factor != (char *) NULL) |
| 6978 | image_info->sampling_factor=DestroyString( |
| 6979 | image_info->sampling_factor); |
| 6980 | break; |
| 6981 | } |
| 6982 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 6983 | break; |
| 6984 | } |
| 6985 | if (LocaleCompare("scene",option+1) == 0) |
| 6986 | { |
| 6987 | /* |
| 6988 | Set image scene. |
| 6989 | */ |
| 6990 | if (*option == '+') |
| 6991 | { |
| 6992 | image_info->scene=0; |
| 6993 | (void) SetImageOption(image_info,option+1,"0"); |
| 6994 | break; |
| 6995 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6996 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6997 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6998 | break; |
| 6999 | } |
| 7000 | if (LocaleCompare("seed",option+1) == 0) |
| 7001 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7002 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7003 | seed; |
| 7004 | |
| 7005 | if (*option == '+') |
| 7006 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7007 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7008 | SeedPseudoRandomGenerator(seed); |
| 7009 | break; |
| 7010 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7011 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7012 | SeedPseudoRandomGenerator(seed); |
| 7013 | break; |
| 7014 | } |
| 7015 | if (LocaleCompare("size",option+1) == 0) |
| 7016 | { |
| 7017 | if (*option == '+') |
| 7018 | { |
| 7019 | if (image_info->size != (char *) NULL) |
| 7020 | image_info->size=DestroyString(image_info->size); |
| 7021 | break; |
| 7022 | } |
| 7023 | (void) CloneString(&image_info->size,argv[i+1]); |
| 7024 | break; |
| 7025 | } |
| 7026 | if (LocaleCompare("stroke",option+1) == 0) |
| 7027 | { |
| 7028 | if (*option == '+') |
| 7029 | { |
| 7030 | (void) SetImageOption(image_info,option+1,"none"); |
| 7031 | break; |
| 7032 | } |
| 7033 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7034 | break; |
| 7035 | } |
| 7036 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7037 | { |
| 7038 | if (*option == '+') |
| 7039 | { |
| 7040 | (void) SetImageOption(image_info,option+1,"0"); |
| 7041 | break; |
| 7042 | } |
| 7043 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7044 | break; |
| 7045 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7046 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7047 | { |
| 7048 | if (*option == '+') |
| 7049 | { |
| 7050 | image_info->synchronize=MagickFalse; |
| 7051 | break; |
| 7052 | } |
| 7053 | image_info->synchronize=MagickTrue; |
| 7054 | break; |
| 7055 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7056 | break; |
| 7057 | } |
| 7058 | case 't': |
| 7059 | { |
| 7060 | if (LocaleCompare("taint",option+1) == 0) |
| 7061 | { |
| 7062 | if (*option == '+') |
| 7063 | { |
| 7064 | (void) SetImageOption(image_info,option+1,"false"); |
| 7065 | break; |
| 7066 | } |
| 7067 | (void) SetImageOption(image_info,option+1,"true"); |
| 7068 | break; |
| 7069 | } |
| 7070 | if (LocaleCompare("texture",option+1) == 0) |
| 7071 | { |
| 7072 | if (*option == '+') |
| 7073 | { |
| 7074 | if (image_info->texture != (char *) NULL) |
| 7075 | image_info->texture=DestroyString(image_info->texture); |
| 7076 | break; |
| 7077 | } |
| 7078 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7079 | break; |
| 7080 | } |
| 7081 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7082 | { |
| 7083 | if (*option == '+') |
| 7084 | { |
| 7085 | (void) SetImageOption(image_info,option+1,"0"); |
| 7086 | break; |
| 7087 | } |
| 7088 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7089 | break; |
| 7090 | } |
| 7091 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7092 | { |
| 7093 | if (*option == '+') |
| 7094 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 7095 | (void) QueryColorCompliance("none",AllCompliance, |
| 7096 | &image_info->transparent_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7097 | (void) SetImageOption(image_info,option+1,"none"); |
| 7098 | break; |
| 7099 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 7100 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 7101 | &image_info->transparent_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7102 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7103 | break; |
| 7104 | } |
| 7105 | if (LocaleCompare("type",option+1) == 0) |
| 7106 | { |
| 7107 | if (*option == '+') |
| 7108 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7109 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7110 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7111 | break; |
| 7112 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7113 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7114 | MagickFalse,argv[i+1]); |
| 7115 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7116 | break; |
| 7117 | } |
| 7118 | break; |
| 7119 | } |
| 7120 | case 'u': |
| 7121 | { |
| 7122 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7123 | { |
| 7124 | if (*option == '+') |
| 7125 | { |
| 7126 | (void) DeleteImageOption(image_info,option+1); |
| 7127 | break; |
| 7128 | } |
| 7129 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7130 | break; |
| 7131 | } |
| 7132 | if (LocaleCompare("units",option+1) == 0) |
| 7133 | { |
| 7134 | if (*option == '+') |
| 7135 | { |
| 7136 | image_info->units=UndefinedResolution; |
| 7137 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7138 | break; |
| 7139 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7140 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7141 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7142 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7143 | break; |
| 7144 | } |
| 7145 | break; |
| 7146 | } |
| 7147 | case 'v': |
| 7148 | { |
| 7149 | if (LocaleCompare("verbose",option+1) == 0) |
| 7150 | { |
| 7151 | if (*option == '+') |
| 7152 | { |
| 7153 | image_info->verbose=MagickFalse; |
| 7154 | break; |
| 7155 | } |
| 7156 | image_info->verbose=MagickTrue; |
| 7157 | image_info->ping=MagickFalse; |
| 7158 | break; |
| 7159 | } |
| 7160 | if (LocaleCompare("view",option+1) == 0) |
| 7161 | { |
| 7162 | if (*option == '+') |
| 7163 | { |
| 7164 | if (image_info->view != (char *) NULL) |
| 7165 | image_info->view=DestroyString(image_info->view); |
| 7166 | break; |
| 7167 | } |
| 7168 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7169 | break; |
| 7170 | } |
| 7171 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7172 | { |
| 7173 | if (*option == '+') |
| 7174 | { |
| 7175 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7176 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7177 | break; |
| 7178 | } |
| 7179 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7180 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7181 | argv[i+1]); |
| 7182 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7183 | break; |
| 7184 | } |
| 7185 | break; |
| 7186 | } |
| 7187 | case 'w': |
| 7188 | { |
| 7189 | if (LocaleCompare("white-point",option+1) == 0) |
| 7190 | { |
| 7191 | if (*option == '+') |
| 7192 | { |
| 7193 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7194 | break; |
| 7195 | } |
| 7196 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7197 | break; |
| 7198 | } |
| 7199 | break; |
| 7200 | } |
| 7201 | default: |
| 7202 | break; |
| 7203 | } |
| 7204 | i+=count; |
| 7205 | } |
| 7206 | return(MagickTrue); |
| 7207 | } |
| 7208 | |
| 7209 | /* |
| 7210 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7211 | % % |
| 7212 | % % |
| 7213 | % % |
| 7214 | + M o g r i f y I m a g e L i s t % |
| 7215 | % % |
| 7216 | % % |
| 7217 | % % |
| 7218 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7219 | % |
| 7220 | % MogrifyImageList() applies any command line options that might affect the |
| 7221 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7222 | % |
| 7223 | % The format of the MogrifyImage method is: |
| 7224 | % |
| 7225 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7226 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7227 | % |
| 7228 | % A description of each parameter follows: |
| 7229 | % |
| 7230 | % o image_info: the image info.. |
| 7231 | % |
| 7232 | % o argc: Specifies a pointer to an integer describing the number of |
| 7233 | % elements in the argument vector. |
| 7234 | % |
| 7235 | % o argv: Specifies a pointer to a text array containing the command line |
| 7236 | % arguments. |
| 7237 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7238 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7239 | % |
| 7240 | % o exception: return any errors or warnings in this structure. |
| 7241 | % |
| 7242 | */ |
| 7243 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7244 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7245 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7246 | const char |
| 7247 | *option; |
| 7248 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7249 | ImageInfo |
| 7250 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7251 | |
| 7252 | MagickStatusType |
| 7253 | status; |
| 7254 | |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7255 | PixelInterpolateMethod |
| 7256 | interpolate_method; |
| 7257 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7258 | QuantizeInfo |
| 7259 | *quantize_info; |
| 7260 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7261 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7262 | i; |
| 7263 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7264 | ssize_t |
| 7265 | count, |
| 7266 | index; |
| 7267 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7268 | /* |
| 7269 | Apply options to the image list. |
| 7270 | */ |
| 7271 | assert(image_info != (ImageInfo *) NULL); |
| 7272 | assert(image_info->signature == MagickSignature); |
| 7273 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7274 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7275 | assert((*images)->signature == MagickSignature); |
| 7276 | if ((*images)->debug != MagickFalse) |
| 7277 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7278 | (*images)->filename); |
| 7279 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7280 | return(MagickTrue); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7281 | interpolate_method=UndefinedInterpolatePixel; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7282 | mogrify_info=CloneImageInfo(image_info); |
| 7283 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7284 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7285 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7286 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7287 | if (*images == (Image *) NULL) |
| 7288 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7289 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7290 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7291 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7292 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7293 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7294 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7295 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7296 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7297 | switch (*(option+1)) |
| 7298 | { |
| 7299 | case 'a': |
| 7300 | { |
| 7301 | if (LocaleCompare("affinity",option+1) == 0) |
| 7302 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7303 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7304 | if (*option == '+') |
| 7305 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7306 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7307 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7308 | break; |
| 7309 | } |
| 7310 | i++; |
| 7311 | break; |
| 7312 | } |
| 7313 | if (LocaleCompare("append",option+1) == 0) |
| 7314 | { |
| 7315 | Image |
| 7316 | *append_image; |
| 7317 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7318 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7319 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7320 | MagickFalse,exception); |
| 7321 | if (append_image == (Image *) NULL) |
| 7322 | { |
| 7323 | status=MagickFalse; |
| 7324 | break; |
| 7325 | } |
| 7326 | *images=DestroyImageList(*images); |
| 7327 | *images=append_image; |
| 7328 | break; |
| 7329 | } |
| 7330 | if (LocaleCompare("average",option+1) == 0) |
| 7331 | { |
| 7332 | Image |
| 7333 | *average_image; |
| 7334 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7335 | /* |
| 7336 | Average an image sequence (deprecated). |
| 7337 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7338 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7339 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7340 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7341 | if (average_image == (Image *) NULL) |
| 7342 | { |
| 7343 | status=MagickFalse; |
| 7344 | break; |
| 7345 | } |
| 7346 | *images=DestroyImageList(*images); |
| 7347 | *images=average_image; |
| 7348 | break; |
| 7349 | } |
| 7350 | break; |
| 7351 | } |
| 7352 | case 'c': |
| 7353 | { |
| 7354 | if (LocaleCompare("channel",option+1) == 0) |
| 7355 | { |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7356 | ChannelType |
| 7357 | channel; |
| 7358 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7359 | if (*option == '+') |
| 7360 | { |
| 7361 | channel=DefaultChannels; |
| 7362 | break; |
| 7363 | } |
| 7364 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 7365 | SetPixelChannelMap(*images,channel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7366 | break; |
| 7367 | } |
| 7368 | if (LocaleCompare("clut",option+1) == 0) |
| 7369 | { |
| 7370 | Image |
| 7371 | *clut_image, |
| 7372 | *image; |
| 7373 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7374 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7375 | image=RemoveFirstImageFromList(images); |
| 7376 | clut_image=RemoveFirstImageFromList(images); |
| 7377 | if (clut_image == (Image *) NULL) |
| 7378 | { |
| 7379 | status=MagickFalse; |
| 7380 | break; |
| 7381 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7382 | (void) ClutImage(image,clut_image,interpolate_method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7383 | clut_image=DestroyImage(clut_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7384 | *images=DestroyImageList(*images); |
| 7385 | *images=image; |
| 7386 | break; |
| 7387 | } |
| 7388 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7389 | { |
| 7390 | Image |
| 7391 | *coalesce_image; |
| 7392 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7393 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7394 | coalesce_image=CoalesceImages(*images,exception); |
| 7395 | if (coalesce_image == (Image *) NULL) |
| 7396 | { |
| 7397 | status=MagickFalse; |
| 7398 | break; |
| 7399 | } |
| 7400 | *images=DestroyImageList(*images); |
| 7401 | *images=coalesce_image; |
| 7402 | break; |
| 7403 | } |
| 7404 | if (LocaleCompare("combine",option+1) == 0) |
| 7405 | { |
| 7406 | Image |
| 7407 | *combine_image; |
| 7408 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7409 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 7410 | combine_image=CombineImages(*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7411 | if (combine_image == (Image *) NULL) |
| 7412 | { |
| 7413 | status=MagickFalse; |
| 7414 | break; |
| 7415 | } |
| 7416 | *images=DestroyImageList(*images); |
| 7417 | *images=combine_image; |
| 7418 | break; |
| 7419 | } |
| 7420 | if (LocaleCompare("composite",option+1) == 0) |
| 7421 | { |
| 7422 | Image |
| 7423 | *mask_image, |
| 7424 | *composite_image, |
| 7425 | *image; |
| 7426 | |
| 7427 | RectangleInfo |
| 7428 | geometry; |
| 7429 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7430 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7431 | image=RemoveFirstImageFromList(images); |
| 7432 | composite_image=RemoveFirstImageFromList(images); |
| 7433 | if (composite_image == (Image *) NULL) |
| 7434 | { |
| 7435 | status=MagickFalse; |
| 7436 | break; |
| 7437 | } |
| 7438 | (void) TransformImage(&composite_image,(char *) NULL, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 7439 | composite_image->geometry,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7440 | SetGeometry(composite_image,&geometry); |
| 7441 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7442 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7443 | &geometry); |
| 7444 | mask_image=RemoveFirstImageFromList(images); |
| 7445 | if (mask_image != (Image *) NULL) |
| 7446 | { |
| 7447 | if ((image->compose == DisplaceCompositeOp) || |
| 7448 | (image->compose == DistortCompositeOp)) |
| 7449 | { |
| 7450 | /* |
| 7451 | Merge Y displacement into X displacement image. |
| 7452 | */ |
| 7453 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 7454 | mask_image,0,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7455 | mask_image=DestroyImage(mask_image); |
| 7456 | } |
| 7457 | else |
| 7458 | { |
| 7459 | /* |
| 7460 | Set a blending mask for the composition. |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7461 | Posible error, what if image->mask already set. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7462 | */ |
| 7463 | image->mask=mask_image; |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 7464 | (void) NegateImage(image->mask,MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7465 | } |
| 7466 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7467 | (void) CompositeImage(image,image->compose,composite_image, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 7468 | geometry.x,geometry.y,exception); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7469 | if (mask_image != (Image *) NULL) |
| 7470 | mask_image=image->mask=DestroyImage(image->mask); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7471 | composite_image=DestroyImage(composite_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7472 | *images=DestroyImageList(*images); |
| 7473 | *images=image; |
| 7474 | break; |
| 7475 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7476 | break; |
| 7477 | } |
| 7478 | case 'd': |
| 7479 | { |
| 7480 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7481 | { |
| 7482 | Image |
| 7483 | *deconstruct_image; |
| 7484 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7485 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7486 | deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer, |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 7487 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7488 | if (deconstruct_image == (Image *) NULL) |
| 7489 | { |
| 7490 | status=MagickFalse; |
| 7491 | break; |
| 7492 | } |
| 7493 | *images=DestroyImageList(*images); |
| 7494 | *images=deconstruct_image; |
| 7495 | break; |
| 7496 | } |
| 7497 | if (LocaleCompare("delete",option+1) == 0) |
| 7498 | { |
| 7499 | if (*option == '+') |
| 7500 | DeleteImages(images,"-1",exception); |
| 7501 | else |
| 7502 | DeleteImages(images,argv[i+1],exception); |
| 7503 | break; |
| 7504 | } |
| 7505 | if (LocaleCompare("dither",option+1) == 0) |
| 7506 | { |
| 7507 | if (*option == '+') |
| 7508 | { |
| 7509 | quantize_info->dither=MagickFalse; |
| 7510 | break; |
| 7511 | } |
| 7512 | quantize_info->dither=MagickTrue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7513 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7514 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7515 | break; |
| 7516 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7517 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7518 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7519 | Image |
| 7520 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7521 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7522 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7523 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7524 | else |
| 7525 | { |
| 7526 | const char |
| 7527 | *p; |
| 7528 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7529 | size_t |
| 7530 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7531 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7532 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7533 | p=strchr(argv[i+1],','); |
| 7534 | if (p == (const char *) NULL) |
| 7535 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7536 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7537 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7538 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7539 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7540 | } |
| 7541 | AppendImageToList(images, duplicate_images); |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7542 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7543 | break; |
| 7544 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7545 | break; |
| 7546 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7547 | case 'e': |
| 7548 | { |
| 7549 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7550 | { |
| 7551 | Image |
| 7552 | *evaluate_image; |
| 7553 | |
| 7554 | MagickEvaluateOperator |
| 7555 | op; |
| 7556 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7557 | (void) SyncImageSettings(mogrify_info,*images,exception); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7558 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 7559 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7560 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7561 | if (evaluate_image == (Image *) NULL) |
| 7562 | { |
| 7563 | status=MagickFalse; |
| 7564 | break; |
| 7565 | } |
| 7566 | *images=DestroyImageList(*images); |
| 7567 | *images=evaluate_image; |
| 7568 | break; |
| 7569 | } |
| 7570 | break; |
| 7571 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7572 | case 'f': |
| 7573 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7574 | if (LocaleCompare("fft",option+1) == 0) |
| 7575 | { |
| 7576 | Image |
| 7577 | *fourier_image; |
| 7578 | |
| 7579 | /* |
| 7580 | Implements the discrete Fourier transform (DFT). |
| 7581 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7582 | (void) SyncImageSettings(mogrify_info,*images,exception); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7583 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7584 | MagickTrue : MagickFalse,exception); |
| 7585 | if (fourier_image == (Image *) NULL) |
| 7586 | break; |
| 7587 | *images=DestroyImage(*images); |
| 7588 | *images=fourier_image; |
| 7589 | break; |
| 7590 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7591 | if (LocaleCompare("flatten",option+1) == 0) |
| 7592 | { |
| 7593 | Image |
| 7594 | *flatten_image; |
| 7595 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7596 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7597 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7598 | if (flatten_image == (Image *) NULL) |
| 7599 | break; |
| 7600 | *images=DestroyImageList(*images); |
| 7601 | *images=flatten_image; |
| 7602 | break; |
| 7603 | } |
| 7604 | if (LocaleCompare("fx",option+1) == 0) |
| 7605 | { |
| 7606 | Image |
| 7607 | *fx_image; |
| 7608 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7609 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 7610 | fx_image=FxImage(*images,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7611 | if (fx_image == (Image *) NULL) |
| 7612 | { |
| 7613 | status=MagickFalse; |
| 7614 | break; |
| 7615 | } |
| 7616 | *images=DestroyImageList(*images); |
| 7617 | *images=fx_image; |
| 7618 | break; |
| 7619 | } |
| 7620 | break; |
| 7621 | } |
| 7622 | case 'h': |
| 7623 | { |
| 7624 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7625 | { |
| 7626 | Image |
| 7627 | *hald_image, |
| 7628 | *image; |
| 7629 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7630 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7631 | image=RemoveFirstImageFromList(images); |
| 7632 | hald_image=RemoveFirstImageFromList(images); |
| 7633 | if (hald_image == (Image *) NULL) |
| 7634 | { |
| 7635 | status=MagickFalse; |
| 7636 | break; |
| 7637 | } |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 7638 | (void) HaldClutImage(image,hald_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7639 | hald_image=DestroyImage(hald_image); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7640 | if (*images != (Image *) NULL) |
| 7641 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7642 | *images=image; |
| 7643 | break; |
| 7644 | } |
| 7645 | break; |
| 7646 | } |
| 7647 | case 'i': |
| 7648 | { |
| 7649 | if (LocaleCompare("ift",option+1) == 0) |
| 7650 | { |
| 7651 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7652 | *fourier_image, |
| 7653 | *magnitude_image, |
| 7654 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7655 | |
| 7656 | /* |
| 7657 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7658 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7659 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7660 | magnitude_image=RemoveFirstImageFromList(images); |
| 7661 | phase_image=RemoveFirstImageFromList(images); |
| 7662 | if (phase_image == (Image *) NULL) |
| 7663 | { |
| 7664 | status=MagickFalse; |
| 7665 | break; |
| 7666 | } |
| 7667 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7668 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7669 | if (fourier_image == (Image *) NULL) |
| 7670 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7671 | if (*images != (Image *) NULL) |
| 7672 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7673 | *images=fourier_image; |
| 7674 | break; |
| 7675 | } |
| 7676 | if (LocaleCompare("insert",option+1) == 0) |
| 7677 | { |
| 7678 | Image |
| 7679 | *p, |
| 7680 | *q; |
| 7681 | |
| 7682 | index=0; |
| 7683 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7684 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7685 | p=RemoveLastImageFromList(images); |
| 7686 | if (p == (Image *) NULL) |
| 7687 | { |
| 7688 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7689 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7690 | status=MagickFalse; |
| 7691 | break; |
| 7692 | } |
| 7693 | q=p; |
| 7694 | if (index == 0) |
| 7695 | PrependImageToList(images,q); |
| 7696 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7697 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7698 | AppendImageToList(images,q); |
| 7699 | else |
| 7700 | { |
| 7701 | q=GetImageFromList(*images,index-1); |
| 7702 | if (q == (Image *) NULL) |
| 7703 | { |
| 7704 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7705 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7706 | status=MagickFalse; |
| 7707 | break; |
| 7708 | } |
| 7709 | InsertImageInList(&q,p); |
| 7710 | } |
| 7711 | *images=GetFirstImageInList(q); |
| 7712 | break; |
| 7713 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7714 | if (LocaleCompare("interpolate",option+1) == 0) |
| 7715 | { |
| 7716 | interpolate_method=(PixelInterpolateMethod) ParseCommandOption( |
| 7717 | MagickInterpolateOptions,MagickFalse,argv[i+1]); |
| 7718 | break; |
| 7719 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7720 | break; |
| 7721 | } |
| 7722 | case 'l': |
| 7723 | { |
| 7724 | if (LocaleCompare("layers",option+1) == 0) |
| 7725 | { |
| 7726 | Image |
| 7727 | *layers; |
| 7728 | |
| 7729 | ImageLayerMethod |
| 7730 | method; |
| 7731 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7732 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7733 | layers=(Image *) NULL; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7734 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7735 | MagickFalse,argv[i+1]); |
| 7736 | switch (method) |
| 7737 | { |
| 7738 | case CoalesceLayer: |
| 7739 | { |
| 7740 | layers=CoalesceImages(*images,exception); |
| 7741 | break; |
| 7742 | } |
| 7743 | case CompareAnyLayer: |
| 7744 | case CompareClearLayer: |
| 7745 | case CompareOverlayLayer: |
| 7746 | default: |
| 7747 | { |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7748 | layers=CompareImagesLayers(*images,method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7749 | break; |
| 7750 | } |
| 7751 | case MergeLayer: |
| 7752 | case FlattenLayer: |
| 7753 | case MosaicLayer: |
| 7754 | case TrimBoundsLayer: |
| 7755 | { |
| 7756 | layers=MergeImageLayers(*images,method,exception); |
| 7757 | break; |
| 7758 | } |
| 7759 | case DisposeLayer: |
| 7760 | { |
| 7761 | layers=DisposeImages(*images,exception); |
| 7762 | break; |
| 7763 | } |
| 7764 | case OptimizeImageLayer: |
| 7765 | { |
| 7766 | layers=OptimizeImageLayers(*images,exception); |
| 7767 | break; |
| 7768 | } |
| 7769 | case OptimizePlusLayer: |
| 7770 | { |
| 7771 | layers=OptimizePlusImageLayers(*images,exception); |
| 7772 | break; |
| 7773 | } |
| 7774 | case OptimizeTransLayer: |
| 7775 | { |
| 7776 | OptimizeImageTransparency(*images,exception); |
| 7777 | break; |
| 7778 | } |
| 7779 | case RemoveDupsLayer: |
| 7780 | { |
| 7781 | RemoveDuplicateLayers(images,exception); |
| 7782 | break; |
| 7783 | } |
| 7784 | case RemoveZeroLayer: |
| 7785 | { |
| 7786 | RemoveZeroDelayLayers(images,exception); |
| 7787 | break; |
| 7788 | } |
| 7789 | case OptimizeLayer: |
| 7790 | { |
| 7791 | /* |
| 7792 | General Purpose, GIF Animation Optimizer. |
| 7793 | */ |
| 7794 | layers=CoalesceImages(*images,exception); |
| 7795 | if (layers == (Image *) NULL) |
| 7796 | { |
| 7797 | status=MagickFalse; |
| 7798 | break; |
| 7799 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7800 | *images=DestroyImageList(*images); |
| 7801 | *images=layers; |
| 7802 | layers=OptimizeImageLayers(*images,exception); |
| 7803 | if (layers == (Image *) NULL) |
| 7804 | { |
| 7805 | status=MagickFalse; |
| 7806 | break; |
| 7807 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7808 | *images=DestroyImageList(*images); |
| 7809 | *images=layers; |
| 7810 | layers=(Image *) NULL; |
| 7811 | OptimizeImageTransparency(*images,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7812 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7813 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7814 | break; |
| 7815 | } |
| 7816 | case CompositeLayer: |
| 7817 | { |
| 7818 | CompositeOperator |
| 7819 | compose; |
| 7820 | |
| 7821 | Image |
| 7822 | *source; |
| 7823 | |
| 7824 | RectangleInfo |
| 7825 | geometry; |
| 7826 | |
| 7827 | /* |
| 7828 | Split image sequence at the first 'NULL:' image. |
| 7829 | */ |
| 7830 | source=(*images); |
| 7831 | while (source != (Image *) NULL) |
| 7832 | { |
| 7833 | source=GetNextImageInList(source); |
| 7834 | if ((source != (Image *) NULL) && |
| 7835 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7836 | break; |
| 7837 | } |
| 7838 | if (source != (Image *) NULL) |
| 7839 | { |
| 7840 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7841 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7842 | source=(Image *) NULL; |
| 7843 | else |
| 7844 | { |
| 7845 | /* |
| 7846 | Separate the two lists, junk the null: image. |
| 7847 | */ |
| 7848 | source=SplitImageList(source->previous); |
| 7849 | DeleteImageFromList(&source); |
| 7850 | } |
| 7851 | } |
| 7852 | if (source == (Image *) NULL) |
| 7853 | { |
| 7854 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7855 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7856 | status=MagickFalse; |
| 7857 | break; |
| 7858 | } |
| 7859 | /* |
| 7860 | Adjust offset with gravity and virtual canvas. |
| 7861 | */ |
| 7862 | SetGeometry(*images,&geometry); |
| 7863 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7864 | geometry.width=source->page.width != 0 ? |
| 7865 | source->page.width : source->columns; |
| 7866 | geometry.height=source->page.height != 0 ? |
| 7867 | source->page.height : source->rows; |
| 7868 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7869 | (*images)->page.width : (*images)->columns, |
| 7870 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7871 | (*images)->rows,(*images)->gravity,&geometry); |
| 7872 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7873 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7874 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7875 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7876 | MagickComposeOptions,MagickFalse,option); |
| 7877 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7878 | exception); |
| 7879 | source=DestroyImageList(source); |
| 7880 | break; |
| 7881 | } |
| 7882 | } |
| 7883 | if (layers == (Image *) NULL) |
| 7884 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7885 | *images=DestroyImageList(*images); |
| 7886 | *images=layers; |
| 7887 | break; |
| 7888 | } |
| 7889 | break; |
| 7890 | } |
| 7891 | case 'm': |
| 7892 | { |
| 7893 | if (LocaleCompare("map",option+1) == 0) |
| 7894 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7895 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7896 | if (*option == '+') |
| 7897 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7898 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7899 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7900 | break; |
| 7901 | } |
| 7902 | i++; |
| 7903 | break; |
| 7904 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7905 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7906 | { |
| 7907 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7908 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7909 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7910 | /* |
| 7911 | Maximum image sequence (deprecated). |
| 7912 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7913 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7914 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7915 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7916 | { |
| 7917 | status=MagickFalse; |
| 7918 | break; |
| 7919 | } |
| 7920 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7921 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7922 | break; |
| 7923 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7924 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7925 | { |
| 7926 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7927 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7928 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7929 | /* |
| 7930 | Minimum image sequence (deprecated). |
| 7931 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7932 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7933 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7934 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7935 | { |
| 7936 | status=MagickFalse; |
| 7937 | break; |
| 7938 | } |
| 7939 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7940 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7941 | break; |
| 7942 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7943 | if (LocaleCompare("morph",option+1) == 0) |
| 7944 | { |
| 7945 | Image |
| 7946 | *morph_image; |
| 7947 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7948 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7949 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7950 | exception); |
| 7951 | if (morph_image == (Image *) NULL) |
| 7952 | { |
| 7953 | status=MagickFalse; |
| 7954 | break; |
| 7955 | } |
| 7956 | *images=DestroyImageList(*images); |
| 7957 | *images=morph_image; |
| 7958 | break; |
| 7959 | } |
| 7960 | if (LocaleCompare("mosaic",option+1) == 0) |
| 7961 | { |
| 7962 | Image |
| 7963 | *mosaic_image; |
| 7964 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7965 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7966 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 7967 | if (mosaic_image == (Image *) NULL) |
| 7968 | { |
| 7969 | status=MagickFalse; |
| 7970 | break; |
| 7971 | } |
| 7972 | *images=DestroyImageList(*images); |
| 7973 | *images=mosaic_image; |
| 7974 | break; |
| 7975 | } |
| 7976 | break; |
| 7977 | } |
| 7978 | case 'p': |
| 7979 | { |
| 7980 | if (LocaleCompare("print",option+1) == 0) |
| 7981 | { |
| 7982 | char |
| 7983 | *string; |
| 7984 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7985 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7986 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1], |
| 7987 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7988 | if (string == (char *) NULL) |
| 7989 | break; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 7990 | (void) FormatLocaleFile(stdout,"%s",string); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7991 | string=DestroyString(string); |
| 7992 | } |
| 7993 | if (LocaleCompare("process",option+1) == 0) |
| 7994 | { |
| 7995 | char |
| 7996 | **arguments; |
| 7997 | |
| 7998 | int |
| 7999 | j, |
| 8000 | number_arguments; |
| 8001 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8002 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8003 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 8004 | if (arguments == (char **) NULL) |
| 8005 | break; |
| 8006 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 8007 | { |
| 8008 | char |
| 8009 | breaker, |
| 8010 | quote, |
| 8011 | *token; |
| 8012 | |
| 8013 | const char |
| 8014 | *arguments; |
| 8015 | |
| 8016 | int |
| 8017 | next, |
| 8018 | status; |
| 8019 | |
| 8020 | size_t |
| 8021 | length; |
| 8022 | |
| 8023 | TokenInfo |
| 8024 | *token_info; |
| 8025 | |
| 8026 | /* |
| 8027 | Support old style syntax, filter="-option arg". |
| 8028 | */ |
| 8029 | length=strlen(argv[i+1]); |
| 8030 | token=(char *) NULL; |
cristy | 37e0b38 | 2011-06-07 13:31:21 +0000 | [diff] [blame] | 8031 | if (~length >= (MaxTextExtent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8032 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8033 | sizeof(*token)); |
| 8034 | if (token == (char *) NULL) |
| 8035 | break; |
| 8036 | next=0; |
| 8037 | arguments=argv[i+1]; |
| 8038 | token_info=AcquireTokenInfo(); |
| 8039 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8040 | "\"",'\0',&breaker,&next,"e); |
| 8041 | token_info=DestroyTokenInfo(token_info); |
| 8042 | if (status == 0) |
| 8043 | { |
| 8044 | const char |
| 8045 | *argv; |
| 8046 | |
| 8047 | argv=(&(arguments[next])); |
| 8048 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8049 | exception); |
| 8050 | } |
| 8051 | token=DestroyString(token); |
| 8052 | break; |
| 8053 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8054 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8055 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8056 | number_arguments-2,(const char **) arguments+2,exception); |
| 8057 | for (j=0; j < number_arguments; j++) |
| 8058 | arguments[j]=DestroyString(arguments[j]); |
| 8059 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8060 | break; |
| 8061 | } |
| 8062 | break; |
| 8063 | } |
| 8064 | case 'r': |
| 8065 | { |
| 8066 | if (LocaleCompare("reverse",option+1) == 0) |
| 8067 | { |
| 8068 | ReverseImageList(images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8069 | break; |
| 8070 | } |
| 8071 | break; |
| 8072 | } |
| 8073 | case 's': |
| 8074 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8075 | if (LocaleCompare("smush",option+1) == 0) |
| 8076 | { |
| 8077 | Image |
| 8078 | *smush_image; |
| 8079 | |
| 8080 | ssize_t |
| 8081 | offset; |
| 8082 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8083 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8084 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8085 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8086 | MagickFalse,offset,exception); |
| 8087 | if (smush_image == (Image *) NULL) |
| 8088 | { |
| 8089 | status=MagickFalse; |
| 8090 | break; |
| 8091 | } |
| 8092 | *images=DestroyImageList(*images); |
| 8093 | *images=smush_image; |
| 8094 | break; |
| 8095 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8096 | if (LocaleCompare("swap",option+1) == 0) |
| 8097 | { |
| 8098 | Image |
| 8099 | *p, |
| 8100 | *q, |
| 8101 | *swap; |
| 8102 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8103 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8104 | swap_index; |
| 8105 | |
| 8106 | index=(-1); |
| 8107 | swap_index=(-2); |
| 8108 | if (*option != '+') |
| 8109 | { |
| 8110 | GeometryInfo |
| 8111 | geometry_info; |
| 8112 | |
| 8113 | MagickStatusType |
| 8114 | flags; |
| 8115 | |
| 8116 | swap_index=(-1); |
| 8117 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8118 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8119 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8120 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8121 | } |
| 8122 | p=GetImageFromList(*images,index); |
| 8123 | q=GetImageFromList(*images,swap_index); |
| 8124 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8125 | { |
| 8126 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8127 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8128 | status=MagickFalse; |
| 8129 | break; |
| 8130 | } |
| 8131 | if (p == q) |
| 8132 | break; |
| 8133 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8134 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8135 | ReplaceImageInList(&q,swap); |
| 8136 | *images=GetFirstImageInList(q); |
| 8137 | break; |
| 8138 | } |
| 8139 | break; |
| 8140 | } |
| 8141 | case 'w': |
| 8142 | { |
| 8143 | if (LocaleCompare("write",option+1) == 0) |
| 8144 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8145 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8146 | key[MaxTextExtent]; |
| 8147 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8148 | Image |
| 8149 | *write_images; |
| 8150 | |
| 8151 | ImageInfo |
| 8152 | *write_info; |
| 8153 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8154 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8155 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8156 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8157 | write_images=(*images); |
| 8158 | if (*option == '+') |
| 8159 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8160 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8161 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8162 | write_info=DestroyImageInfo(write_info); |
| 8163 | if (*option == '+') |
| 8164 | write_images=DestroyImageList(write_images); |
| 8165 | break; |
| 8166 | } |
| 8167 | break; |
| 8168 | } |
| 8169 | default: |
| 8170 | break; |
| 8171 | } |
| 8172 | i+=count; |
| 8173 | } |
| 8174 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8175 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8176 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8177 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8178 | } |
| 8179 | |
| 8180 | /* |
| 8181 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8182 | % % |
| 8183 | % % |
| 8184 | % % |
| 8185 | + M o g r i f y I m a g e s % |
| 8186 | % % |
| 8187 | % % |
| 8188 | % % |
| 8189 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8190 | % |
| 8191 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8192 | % prescribed by command line options. |
| 8193 | % |
| 8194 | % The format of the MogrifyImage method is: |
| 8195 | % |
| 8196 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8197 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8198 | % Image **images,Exceptioninfo *exception) |
| 8199 | % |
| 8200 | % A description of each parameter follows: |
| 8201 | % |
| 8202 | % o image_info: the image info.. |
| 8203 | % |
| 8204 | % o post: If true, post process image list operators otherwise pre-process. |
| 8205 | % |
| 8206 | % o argc: Specifies a pointer to an integer describing the number of |
| 8207 | % elements in the argument vector. |
| 8208 | % |
| 8209 | % o argv: Specifies a pointer to a text array containing the command line |
| 8210 | % arguments. |
| 8211 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8212 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8213 | % |
| 8214 | % o exception: return any errors or warnings in this structure. |
| 8215 | % |
| 8216 | */ |
| 8217 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8218 | const MagickBooleanType post,const int argc,const char **argv, |
| 8219 | Image **images,ExceptionInfo *exception) |
| 8220 | { |
| 8221 | #define MogrifyImageTag "Mogrify/Image" |
| 8222 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8223 | MagickStatusType |
| 8224 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8225 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8226 | MagickBooleanType |
| 8227 | proceed; |
| 8228 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8229 | size_t |
| 8230 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8231 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8232 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8233 | i; |
| 8234 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8235 | assert(image_info != (ImageInfo *) NULL); |
| 8236 | assert(image_info->signature == MagickSignature); |
| 8237 | if (images == (Image **) NULL) |
| 8238 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8239 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8240 | assert((*images)->signature == MagickSignature); |
| 8241 | if ((*images)->debug != MagickFalse) |
| 8242 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8243 | (*images)->filename); |
| 8244 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8245 | return(MagickTrue); |
| 8246 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8247 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8248 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8249 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8250 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8251 | (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc, |
| 8252 | post?"post":"pre"); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8253 | #endif |
| 8254 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8255 | /* |
| 8256 | Pre-process multi-image sequence operators |
| 8257 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8258 | if (post == MagickFalse) |
| 8259 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8260 | /* |
| 8261 | For each image, process simple single image operators |
| 8262 | */ |
| 8263 | i=0; |
| 8264 | n=GetImageListLength(*images); |
cristy | 9f027d1 | 2011-09-21 01:17:17 +0000 | [diff] [blame] | 8265 | for ( ; ; ) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8266 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8267 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8268 | (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long) |
| 8269 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8270 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8271 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8272 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8273 | if (proceed == MagickFalse) |
| 8274 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8275 | if ( (*images)->next == (Image *) NULL ) |
| 8276 | break; |
| 8277 | *images=(*images)->next; |
| 8278 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8279 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8280 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8281 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8282 | (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long) |
| 8283 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8284 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8285 | |
| 8286 | /* |
| 8287 | Post-process, multi-image sequence operators |
| 8288 | */ |
| 8289 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8290 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8291 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8292 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8293 | } |