cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % M M OOO GGGGG RRRR IIIII FFFFF Y Y % |
| 7 | % MM MM O O G R R I F Y Y % |
| 8 | % M M M O O G GGG RRRR I FFF Y % |
| 9 | % M M O O G G R R I F Y % |
| 10 | % M M OOO GGGG R R IIIII F Y % |
| 11 | % % |
| 12 | % % |
| 13 | % MagickWand Module Methods % |
| 14 | % % |
| 15 | % Software Design % |
| 16 | % John Cristy % |
| 17 | % March 2000 % |
| 18 | % % |
| 19 | % % |
cristy | 7e41fe8 | 2010-12-04 23:12:08 +0000 | [diff] [blame] | 20 | % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 21 | % dedicated to making software imaging solutions freely available. % |
| 22 | % % |
| 23 | % You may not use this file except in compliance with the License. You may % |
| 24 | % obtain a copy of the License at % |
| 25 | % % |
| 26 | % http://www.imagemagick.org/script/license.php % |
| 27 | % % |
| 28 | % Unless required by applicable law or agreed to in writing, software % |
| 29 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 30 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 31 | % See the License for the specific language governing permissions and % |
| 32 | % limitations under the License. % |
| 33 | % % |
| 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 35 | % |
| 36 | % Use the mogrify program to resize an image, blur, crop, despeckle, dither, |
| 37 | % draw on, flip, join, re-sample, and much more. This tool is similiar to |
| 38 | % convert except that the original image file is overwritten (unless you |
| 39 | % change the file suffix with the -format option) with any changes you |
cristy | 6a917d9 | 2009-10-06 19:23:54 +0000 | [diff] [blame] | 40 | % request. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 41 | % |
| 42 | */ |
| 43 | |
| 44 | /* |
| 45 | Include declarations. |
| 46 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 47 | #include "MagickWand/studio.h" |
| 48 | #include "MagickWand/MagickWand.h" |
| 49 | #include "MagickWand/mogrify-private.h" |
| 50 | #undef DegreesToRadians |
| 51 | #undef RadiansToDegrees |
| 52 | #include "MagickCore/image-private.h" |
| 53 | #include "MagickCore/monitor-private.h" |
| 54 | #include "MagickCore/thread-private.h" |
| 55 | #include "MagickCore/string-private.h" |
cristy | 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 | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 156 | duration=InterpretLocaleValue(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 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 300 | /* |
anthony | 0d0fd35 | 2011-10-04 11:09:07 +0000 | [diff] [blame] | 301 | GetImageCache() will read an image into a image cache if not already |
| 302 | present then return the image that is in the cache under that filename. |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 303 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 304 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 305 | ExceptionInfo *exception) |
| 306 | { |
| 307 | char |
| 308 | key[MaxTextExtent]; |
| 309 | |
| 310 | ExceptionInfo |
| 311 | *sans_exception; |
| 312 | |
| 313 | Image |
| 314 | *image; |
| 315 | |
| 316 | ImageInfo |
| 317 | *read_info; |
| 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 | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 511 | sparse_arguments[x++]=InterpretLocaleValue(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 | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 522 | sparse_arguments[x++]=InterpretLocaleValue(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 | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 537 | (void) QueryMagickColorCompliance(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 | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 559 | sparse_arguments[x++]=InterpretLocaleValue(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 | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 567 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 568 | token[0] = ','; /* used this token - get another */ |
| 569 | } |
cristy | 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 | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 575 | sparse_arguments[x++]=InterpretLocaleValue(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 | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 584 | sparse_arguments[x++]=InterpretLocaleValue(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 | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 593 | sparse_arguments[x++]=InterpretLocaleValue(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); |
| 681 | SetPixelInfoPacket(*image,&(*image)->background_color,&fill); |
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 | */ |
| 718 | (void) SyncImageSettings(mogrify_info,*image); |
| 719 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 720 | if ((flags & SigmaValue) == 0) |
| 721 | geometry_info.sigma=1.0; |
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 | */ |
| 733 | (void) SyncImageSettings(mogrify_info,*image); |
| 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 | */ |
| 744 | (void) SyncImageSettings(mogrify_info,*image); |
| 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 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 772 | (void) SyncImageSettings(mogrify_info,*image); |
| 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 | */ |
| 787 | (void) SyncImageSettings(mogrify_info,*image); |
| 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 | } |
| 827 | attenuate=InterpretLocaleValue(argv[i+1],(char **) NULL); |
| 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 | */ |
| 835 | (void) SyncImageSettings(mogrify_info,*image); |
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 | */ |
| 844 | (void) SyncImageSettings(mogrify_info,*image); |
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 | { |
| 850 | (void) SyncImageSettings(mogrify_info,*image); |
| 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 | */ |
| 904 | (void) SyncImageSettings(mogrify_info,*image); |
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 | InheritException(exception,&(*image)->exception); |
| 907 | break; |
| 908 | } |
| 909 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 910 | { |
| 911 | /* |
| 912 | Blue shift image. |
| 913 | */ |
| 914 | (void) SyncImageSettings(mogrify_info,*image); |
| 915 | geometry_info.rho=1.5; |
| 916 | if (*option == '-') |
| 917 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 918 | mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception); |
| 919 | break; |
| 920 | } |
| 921 | if (LocaleCompare("blur",option+1) == 0) |
| 922 | { |
| 923 | /* |
| 924 | Gaussian blur image. |
| 925 | */ |
| 926 | (void) SyncImageSettings(mogrify_info,*image); |
| 927 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 928 | if ((flags & SigmaValue) == 0) |
| 929 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 930 | if ((flags & XiValue) == 0) |
| 931 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 932 | mogrify_image=BlurImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 933 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 934 | break; |
| 935 | } |
| 936 | if (LocaleCompare("border",option+1) == 0) |
| 937 | { |
| 938 | /* |
| 939 | Surround image with a border of solid color. |
| 940 | */ |
| 941 | (void) SyncImageSettings(mogrify_info,*image); |
| 942 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 943 | if ((flags & SigmaValue) == 0) |
| 944 | geometry.height=geometry.width; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 945 | mogrify_image=BorderImage(*image,&geometry,compose,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 946 | break; |
| 947 | } |
| 948 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 949 | { |
| 950 | if (*option == '+') |
| 951 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 952 | (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 953 | &draw_info->border_color,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 954 | break; |
| 955 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 956 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 957 | &draw_info->border_color,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 958 | break; |
| 959 | } |
| 960 | if (LocaleCompare("box",option+1) == 0) |
| 961 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 962 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 963 | &draw_info->undercolor,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 964 | break; |
| 965 | } |
| 966 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 967 | { |
| 968 | double |
| 969 | brightness, |
| 970 | contrast; |
| 971 | |
| 972 | GeometryInfo |
| 973 | geometry_info; |
| 974 | |
| 975 | MagickStatusType |
| 976 | flags; |
| 977 | |
| 978 | /* |
| 979 | Brightness / contrast image. |
| 980 | */ |
| 981 | (void) SyncImageSettings(mogrify_info,*image); |
| 982 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 983 | brightness=geometry_info.rho; |
| 984 | contrast=0.0; |
| 985 | if ((flags & SigmaValue) != 0) |
| 986 | contrast=geometry_info.sigma; |
cristy | 444eda6 | 2011-08-10 02:07:46 +0000 | [diff] [blame] | 987 | (void) BrightnessContrastImage(*image,brightness,contrast, |
| 988 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 989 | InheritException(exception,&(*image)->exception); |
| 990 | break; |
| 991 | } |
| 992 | break; |
| 993 | } |
| 994 | case 'c': |
| 995 | { |
| 996 | if (LocaleCompare("cdl",option+1) == 0) |
| 997 | { |
| 998 | char |
| 999 | *color_correction_collection; |
| 1000 | |
| 1001 | /* |
| 1002 | Color correct with a color decision list. |
| 1003 | */ |
| 1004 | (void) SyncImageSettings(mogrify_info,*image); |
| 1005 | color_correction_collection=FileToString(argv[i+1],~0,exception); |
| 1006 | if (color_correction_collection == (char *) NULL) |
| 1007 | break; |
cristy | 1bfa9f0 | 2011-08-11 02:35:43 +0000 | [diff] [blame] | 1008 | (void) ColorDecisionListImage(*image,color_correction_collection, |
| 1009 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1010 | InheritException(exception,&(*image)->exception); |
| 1011 | break; |
| 1012 | } |
| 1013 | if (LocaleCompare("channel",option+1) == 0) |
| 1014 | { |
| 1015 | if (*option == '+') |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 1016 | channel=DefaultChannels; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1017 | else |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 1018 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1019 | SetPixelChannelMap(*image,channel); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1020 | break; |
| 1021 | } |
| 1022 | if (LocaleCompare("charcoal",option+1) == 0) |
| 1023 | { |
| 1024 | /* |
| 1025 | Charcoal image. |
| 1026 | */ |
| 1027 | (void) SyncImageSettings(mogrify_info,*image); |
| 1028 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1029 | if ((flags & SigmaValue) == 0) |
| 1030 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1031 | if ((flags & XiValue) == 0) |
| 1032 | geometry_info.xi=1.0; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1033 | mogrify_image=CharcoalImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1034 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1035 | break; |
| 1036 | } |
| 1037 | if (LocaleCompare("chop",option+1) == 0) |
| 1038 | { |
| 1039 | /* |
| 1040 | Chop the image. |
| 1041 | */ |
| 1042 | (void) SyncImageSettings(mogrify_info,*image); |
| 1043 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1044 | mogrify_image=ChopImage(*image,&geometry,exception); |
| 1045 | break; |
| 1046 | } |
| 1047 | if (LocaleCompare("clamp",option+1) == 0) |
| 1048 | { |
| 1049 | /* |
| 1050 | Clamp image. |
| 1051 | */ |
| 1052 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1053 | (void) ClampImage(*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1054 | InheritException(exception,&(*image)->exception); |
| 1055 | break; |
| 1056 | } |
| 1057 | if (LocaleCompare("clip",option+1) == 0) |
| 1058 | { |
| 1059 | (void) SyncImageSettings(mogrify_info,*image); |
| 1060 | if (*option == '+') |
| 1061 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1062 | (void) SetImageClipMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1063 | break; |
| 1064 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1065 | (void) ClipImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1066 | break; |
| 1067 | } |
| 1068 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1069 | { |
| 1070 | CacheView |
| 1071 | *mask_view; |
| 1072 | |
| 1073 | Image |
| 1074 | *mask_image; |
| 1075 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1076 | register Quantum |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1077 | *restrict q; |
| 1078 | |
| 1079 | register ssize_t |
| 1080 | x; |
| 1081 | |
| 1082 | ssize_t |
| 1083 | y; |
| 1084 | |
| 1085 | (void) SyncImageSettings(mogrify_info,*image); |
| 1086 | if (*option == '+') |
| 1087 | { |
| 1088 | /* |
| 1089 | Remove a mask. |
| 1090 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1091 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1092 | break; |
| 1093 | } |
| 1094 | /* |
| 1095 | Set the image mask. |
| 1096 | FUTURE: This Should Be a SetImageAlphaChannel() call, Or two. |
| 1097 | */ |
| 1098 | mask_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1099 | if (mask_image == (Image *) NULL) |
| 1100 | break; |
cristy | 574cc26 | 2011-08-05 01:23:58 +0000 | [diff] [blame] | 1101 | if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1102 | return(MagickFalse); |
| 1103 | mask_view=AcquireCacheView(mask_image); |
| 1104 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1105 | { |
| 1106 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1107 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 1108 | if (q == (Quantum *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1109 | break; |
| 1110 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1111 | { |
| 1112 | if (mask_image->matte == MagickFalse) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1113 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 1114 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1115 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1116 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1117 | q+=GetPixelChannels(mask_image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1118 | } |
| 1119 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
| 1120 | break; |
| 1121 | } |
| 1122 | mask_view=DestroyCacheView(mask_view); |
| 1123 | mask_image->matte=MagickTrue; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1124 | (void) SetImageClipMask(*image,mask_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1125 | InheritException(exception,&(*image)->exception); |
| 1126 | break; |
| 1127 | } |
| 1128 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1129 | { |
| 1130 | (void) SyncImageSettings(mogrify_info,*image); |
| 1131 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1132 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1133 | break; |
| 1134 | } |
| 1135 | if (LocaleCompare("colorize",option+1) == 0) |
| 1136 | { |
| 1137 | /* |
| 1138 | Colorize the image. |
| 1139 | */ |
| 1140 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | c7e6ff6 | 2011-10-03 13:46:11 +0000 | [diff] [blame] | 1141 | mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1142 | break; |
| 1143 | } |
| 1144 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1145 | { |
| 1146 | KernelInfo |
| 1147 | *kernel; |
| 1148 | |
| 1149 | (void) SyncImageSettings(mogrify_info,*image); |
| 1150 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1151 | if (kernel == (KernelInfo *) NULL) |
| 1152 | break; |
| 1153 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 1154 | kernel=DestroyKernelInfo(kernel); |
| 1155 | break; |
| 1156 | } |
| 1157 | if (LocaleCompare("colors",option+1) == 0) |
| 1158 | { |
| 1159 | /* |
| 1160 | Reduce the number of colors in the image. |
| 1161 | */ |
| 1162 | (void) SyncImageSettings(mogrify_info,*image); |
| 1163 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
| 1164 | if (quantize_info->number_colors == 0) |
| 1165 | break; |
| 1166 | if (((*image)->storage_class == DirectClass) || |
| 1167 | (*image)->colors > quantize_info->number_colors) |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1168 | (void) QuantizeImage(quantize_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1169 | else |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1170 | (void) CompressImageColormap(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1171 | break; |
| 1172 | } |
| 1173 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1174 | { |
| 1175 | ColorspaceType |
| 1176 | colorspace; |
| 1177 | |
| 1178 | (void) SyncImageSettings(mogrify_info,*image); |
| 1179 | if (*option == '+') |
| 1180 | { |
| 1181 | (void) TransformImageColorspace(*image,RGBColorspace); |
| 1182 | InheritException(exception,&(*image)->exception); |
| 1183 | break; |
| 1184 | } |
| 1185 | colorspace=(ColorspaceType) ParseCommandOption( |
| 1186 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 1187 | (void) TransformImageColorspace(*image,colorspace); |
| 1188 | InheritException(exception,&(*image)->exception); |
| 1189 | break; |
| 1190 | } |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1191 | if (LocaleCompare("compose",option+1) == 0) |
| 1192 | { |
| 1193 | (void) SyncImageSettings(mogrify_info,*image); |
| 1194 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 1195 | MagickFalse,argv[i+1]); |
| 1196 | break; |
| 1197 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1198 | if (LocaleCompare("contrast",option+1) == 0) |
| 1199 | { |
| 1200 | (void) SyncImageSettings(mogrify_info,*image); |
| 1201 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1202 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1203 | break; |
| 1204 | } |
| 1205 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1206 | { |
| 1207 | double |
| 1208 | black_point, |
| 1209 | white_point; |
| 1210 | |
| 1211 | MagickStatusType |
| 1212 | flags; |
| 1213 | |
| 1214 | /* |
| 1215 | Contrast stretch image. |
| 1216 | */ |
| 1217 | (void) SyncImageSettings(mogrify_info,*image); |
| 1218 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1219 | black_point=geometry_info.rho; |
| 1220 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1221 | black_point; |
| 1222 | if ((flags & PercentValue) != 0) |
| 1223 | { |
| 1224 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1225 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1226 | } |
| 1227 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1228 | white_point; |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1229 | (void) ContrastStretchImage(*image,black_point,white_point, |
| 1230 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1231 | InheritException(exception,&(*image)->exception); |
| 1232 | break; |
| 1233 | } |
| 1234 | if (LocaleCompare("convolve",option+1) == 0) |
| 1235 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1236 | KernelInfo |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1237 | *kernel_info; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1238 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1239 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1240 | kernel_info=AcquireKernelInfo(argv[i+1]); |
| 1241 | if (kernel_info == (KernelInfo *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1242 | break; |
cristy | 0a92238 | 2011-07-16 15:30:34 +0000 | [diff] [blame] | 1243 | kernel_info->bias=(*image)->bias; |
cristy | 5e6be1e | 2011-07-16 01:23:39 +0000 | [diff] [blame] | 1244 | mogrify_image=ConvolveImage(*image,kernel_info,exception); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1245 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1246 | break; |
| 1247 | } |
| 1248 | if (LocaleCompare("crop",option+1) == 0) |
| 1249 | { |
| 1250 | /* |
| 1251 | Crop a image to a smaller size |
| 1252 | */ |
| 1253 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1254 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1255 | break; |
| 1256 | } |
| 1257 | if (LocaleCompare("cycle",option+1) == 0) |
| 1258 | { |
| 1259 | /* |
| 1260 | Cycle an image colormap. |
| 1261 | */ |
| 1262 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1263 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]), |
| 1264 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1265 | break; |
| 1266 | } |
| 1267 | break; |
| 1268 | } |
| 1269 | case 'd': |
| 1270 | { |
| 1271 | if (LocaleCompare("decipher",option+1) == 0) |
| 1272 | { |
| 1273 | StringInfo |
| 1274 | *passkey; |
| 1275 | |
| 1276 | /* |
| 1277 | Decipher pixels. |
| 1278 | */ |
| 1279 | (void) SyncImageSettings(mogrify_info,*image); |
| 1280 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1281 | if (passkey != (StringInfo *) NULL) |
| 1282 | { |
| 1283 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1284 | passkey=DestroyStringInfo(passkey); |
| 1285 | } |
| 1286 | break; |
| 1287 | } |
| 1288 | if (LocaleCompare("density",option+1) == 0) |
| 1289 | { |
| 1290 | /* |
| 1291 | Set image density. |
| 1292 | */ |
| 1293 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1294 | break; |
| 1295 | } |
| 1296 | if (LocaleCompare("depth",option+1) == 0) |
| 1297 | { |
| 1298 | (void) SyncImageSettings(mogrify_info,*image); |
| 1299 | if (*option == '+') |
| 1300 | { |
| 1301 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH); |
| 1302 | break; |
| 1303 | } |
| 1304 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1])); |
| 1305 | break; |
| 1306 | } |
| 1307 | if (LocaleCompare("deskew",option+1) == 0) |
| 1308 | { |
| 1309 | double |
| 1310 | threshold; |
| 1311 | |
| 1312 | /* |
| 1313 | Straighten the image. |
| 1314 | */ |
| 1315 | (void) SyncImageSettings(mogrify_info,*image); |
| 1316 | if (*option == '+') |
| 1317 | threshold=40.0*QuantumRange/100.0; |
| 1318 | else |
| 1319 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 1320 | mogrify_image=DeskewImage(*image,threshold,exception); |
| 1321 | break; |
| 1322 | } |
| 1323 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1324 | { |
| 1325 | /* |
| 1326 | Reduce the speckles within an image. |
| 1327 | */ |
| 1328 | (void) SyncImageSettings(mogrify_info,*image); |
| 1329 | mogrify_image=DespeckleImage(*image,exception); |
| 1330 | break; |
| 1331 | } |
| 1332 | if (LocaleCompare("display",option+1) == 0) |
| 1333 | { |
| 1334 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1335 | break; |
| 1336 | } |
| 1337 | if (LocaleCompare("distort",option+1) == 0) |
| 1338 | { |
| 1339 | char |
| 1340 | *args, |
| 1341 | token[MaxTextExtent]; |
| 1342 | |
| 1343 | const char |
| 1344 | *p; |
| 1345 | |
| 1346 | DistortImageMethod |
| 1347 | method; |
| 1348 | |
| 1349 | double |
| 1350 | *arguments; |
| 1351 | |
| 1352 | register ssize_t |
| 1353 | x; |
| 1354 | |
| 1355 | size_t |
| 1356 | number_arguments; |
| 1357 | |
| 1358 | /* |
| 1359 | Distort image. |
| 1360 | */ |
| 1361 | (void) SyncImageSettings(mogrify_info,*image); |
| 1362 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, |
| 1363 | MagickFalse,argv[i+1]); |
| 1364 | if ( method == ResizeDistortion ) |
| 1365 | { |
| 1366 | /* Special Case - Argument is actually a resize geometry! |
| 1367 | ** Convert that to an appropriate distortion argument array. |
| 1368 | */ |
| 1369 | double |
| 1370 | resize_args[2]; |
| 1371 | (void) ParseRegionGeometry(*image,argv[i+2],&geometry, |
| 1372 | exception); |
| 1373 | resize_args[0]=(double)geometry.width; |
| 1374 | resize_args[1]=(double)geometry.height; |
| 1375 | mogrify_image=DistortImage(*image,method,(size_t)2, |
| 1376 | resize_args,MagickTrue,exception); |
| 1377 | break; |
| 1378 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1379 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1380 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1381 | if (args == (char *) NULL) |
| 1382 | break; |
| 1383 | p=(char *) args; |
| 1384 | for (x=0; *p != '\0'; x++) |
| 1385 | { |
| 1386 | GetMagickToken(p,&p,token); |
| 1387 | if (*token == ',') |
| 1388 | GetMagickToken(p,&p,token); |
| 1389 | } |
| 1390 | number_arguments=(size_t) x; |
| 1391 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1392 | sizeof(*arguments)); |
| 1393 | if (arguments == (double *) NULL) |
| 1394 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1395 | "MemoryAllocationFailed",(*image)->filename); |
| 1396 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1397 | sizeof(*arguments)); |
| 1398 | p=(char *) args; |
| 1399 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 1400 | { |
| 1401 | GetMagickToken(p,&p,token); |
| 1402 | if (*token == ',') |
| 1403 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1404 | arguments[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1405 | } |
| 1406 | args=DestroyString(args); |
| 1407 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
| 1408 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1409 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1410 | break; |
| 1411 | } |
| 1412 | if (LocaleCompare("dither",option+1) == 0) |
| 1413 | { |
| 1414 | if (*option == '+') |
| 1415 | { |
| 1416 | quantize_info->dither=MagickFalse; |
| 1417 | break; |
| 1418 | } |
| 1419 | quantize_info->dither=MagickTrue; |
| 1420 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
| 1421 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1422 | if (quantize_info->dither_method == NoDitherMethod) |
| 1423 | quantize_info->dither=MagickFalse; |
| 1424 | break; |
| 1425 | } |
| 1426 | if (LocaleCompare("draw",option+1) == 0) |
| 1427 | { |
| 1428 | /* |
| 1429 | Draw image. |
| 1430 | */ |
| 1431 | (void) SyncImageSettings(mogrify_info,*image); |
| 1432 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1433 | (void) DrawImage(*image,draw_info,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1434 | break; |
| 1435 | } |
| 1436 | break; |
| 1437 | } |
| 1438 | case 'e': |
| 1439 | { |
| 1440 | if (LocaleCompare("edge",option+1) == 0) |
| 1441 | { |
| 1442 | /* |
| 1443 | Enhance edges in the image. |
| 1444 | */ |
| 1445 | (void) SyncImageSettings(mogrify_info,*image); |
| 1446 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1447 | if ((flags & SigmaValue) == 0) |
| 1448 | geometry_info.sigma=1.0; |
cristy | 8ae632d | 2011-09-05 17:29:53 +0000 | [diff] [blame] | 1449 | mogrify_image=EdgeImage(*image,geometry_info.rho, |
| 1450 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1451 | break; |
| 1452 | } |
| 1453 | if (LocaleCompare("emboss",option+1) == 0) |
| 1454 | { |
| 1455 | /* |
| 1456 | Gaussian embossen image. |
| 1457 | */ |
| 1458 | (void) SyncImageSettings(mogrify_info,*image); |
| 1459 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1460 | if ((flags & SigmaValue) == 0) |
| 1461 | geometry_info.sigma=1.0; |
| 1462 | mogrify_image=EmbossImage(*image,geometry_info.rho, |
| 1463 | geometry_info.sigma,exception); |
| 1464 | break; |
| 1465 | } |
| 1466 | if (LocaleCompare("encipher",option+1) == 0) |
| 1467 | { |
| 1468 | StringInfo |
| 1469 | *passkey; |
| 1470 | |
| 1471 | /* |
| 1472 | Encipher pixels. |
| 1473 | */ |
| 1474 | (void) SyncImageSettings(mogrify_info,*image); |
| 1475 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1476 | if (passkey != (StringInfo *) NULL) |
| 1477 | { |
| 1478 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1479 | passkey=DestroyStringInfo(passkey); |
| 1480 | } |
| 1481 | break; |
| 1482 | } |
| 1483 | if (LocaleCompare("encoding",option+1) == 0) |
| 1484 | { |
| 1485 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1486 | break; |
| 1487 | } |
| 1488 | if (LocaleCompare("enhance",option+1) == 0) |
| 1489 | { |
| 1490 | /* |
| 1491 | Enhance image. |
| 1492 | */ |
| 1493 | (void) SyncImageSettings(mogrify_info,*image); |
| 1494 | mogrify_image=EnhanceImage(*image,exception); |
| 1495 | break; |
| 1496 | } |
| 1497 | if (LocaleCompare("equalize",option+1) == 0) |
| 1498 | { |
| 1499 | /* |
| 1500 | Equalize image. |
| 1501 | */ |
| 1502 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 6d8c3d7 | 2011-08-22 01:20:01 +0000 | [diff] [blame] | 1503 | (void) EqualizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1504 | break; |
| 1505 | } |
| 1506 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1507 | { |
| 1508 | double |
| 1509 | constant; |
| 1510 | |
| 1511 | MagickEvaluateOperator |
| 1512 | op; |
| 1513 | |
| 1514 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1515 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 1516 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1517 | constant=SiPrefixToDouble(argv[i+2],QuantumRange); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1518 | (void) EvaluateImage(*image,op,constant,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1519 | break; |
| 1520 | } |
| 1521 | if (LocaleCompare("extent",option+1) == 0) |
| 1522 | { |
| 1523 | /* |
| 1524 | Set the image extent. |
| 1525 | */ |
| 1526 | (void) SyncImageSettings(mogrify_info,*image); |
| 1527 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1528 | if (geometry.width == 0) |
| 1529 | geometry.width=(*image)->columns; |
| 1530 | if (geometry.height == 0) |
| 1531 | geometry.height=(*image)->rows; |
| 1532 | mogrify_image=ExtentImage(*image,&geometry,exception); |
| 1533 | break; |
| 1534 | } |
| 1535 | break; |
| 1536 | } |
| 1537 | case 'f': |
| 1538 | { |
| 1539 | if (LocaleCompare("family",option+1) == 0) |
| 1540 | { |
| 1541 | if (*option == '+') |
| 1542 | { |
| 1543 | if (draw_info->family != (char *) NULL) |
| 1544 | draw_info->family=DestroyString(draw_info->family); |
| 1545 | break; |
| 1546 | } |
| 1547 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1548 | break; |
| 1549 | } |
| 1550 | if (LocaleCompare("features",option+1) == 0) |
| 1551 | { |
| 1552 | if (*option == '+') |
| 1553 | { |
| 1554 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1555 | break; |
| 1556 | } |
| 1557 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1558 | break; |
| 1559 | } |
| 1560 | if (LocaleCompare("fill",option+1) == 0) |
| 1561 | { |
| 1562 | ExceptionInfo |
| 1563 | *sans; |
| 1564 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1565 | GetPixelInfo(*image,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1566 | if (*option == '+') |
| 1567 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1568 | (void) QueryMagickColorCompliance("none",AllCompliance,&fill, |
| 1569 | exception); |
| 1570 | (void) QueryColorCompliance("none",AllCompliance, |
| 1571 | &draw_info->fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1572 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1573 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1574 | break; |
| 1575 | } |
| 1576 | sans=AcquireExceptionInfo(); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1577 | (void) QueryMagickColorCompliance(argv[i+1],AllCompliance,&fill, |
| 1578 | sans); |
| 1579 | status=QueryColorCompliance(argv[i+1],AllCompliance, |
| 1580 | &draw_info->fill,sans); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1581 | sans=DestroyExceptionInfo(sans); |
| 1582 | if (status == MagickFalse) |
| 1583 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 1584 | exception); |
| 1585 | break; |
| 1586 | } |
| 1587 | if (LocaleCompare("flip",option+1) == 0) |
| 1588 | { |
| 1589 | /* |
| 1590 | Flip image scanlines. |
| 1591 | */ |
| 1592 | (void) SyncImageSettings(mogrify_info,*image); |
| 1593 | mogrify_image=FlipImage(*image,exception); |
| 1594 | break; |
| 1595 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1596 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1597 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1598 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1599 | target; |
| 1600 | |
| 1601 | /* |
| 1602 | Floodfill image. |
| 1603 | */ |
| 1604 | (void) SyncImageSettings(mogrify_info,*image); |
| 1605 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1606 | (void) QueryMagickColorCompliance(argv[i+2],AllCompliance,&target, |
| 1607 | exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1608 | (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x, |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 1609 | geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1610 | break; |
| 1611 | } |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1612 | if (LocaleCompare("flop",option+1) == 0) |
| 1613 | { |
| 1614 | /* |
| 1615 | Flop image scanlines. |
| 1616 | */ |
| 1617 | (void) SyncImageSettings(mogrify_info,*image); |
| 1618 | mogrify_image=FlopImage(*image,exception); |
| 1619 | break; |
| 1620 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1621 | if (LocaleCompare("font",option+1) == 0) |
| 1622 | { |
| 1623 | if (*option == '+') |
| 1624 | { |
| 1625 | if (draw_info->font != (char *) NULL) |
| 1626 | draw_info->font=DestroyString(draw_info->font); |
| 1627 | break; |
| 1628 | } |
| 1629 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1630 | break; |
| 1631 | } |
| 1632 | if (LocaleCompare("format",option+1) == 0) |
| 1633 | { |
| 1634 | format=argv[i+1]; |
| 1635 | break; |
| 1636 | } |
| 1637 | if (LocaleCompare("frame",option+1) == 0) |
| 1638 | { |
| 1639 | FrameInfo |
| 1640 | frame_info; |
| 1641 | |
| 1642 | /* |
| 1643 | Surround image with an ornamental border. |
| 1644 | */ |
| 1645 | (void) SyncImageSettings(mogrify_info,*image); |
| 1646 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1647 | frame_info.width=geometry.width; |
| 1648 | frame_info.height=geometry.height; |
| 1649 | if ((flags & HeightValue) == 0) |
| 1650 | frame_info.height=geometry.width; |
| 1651 | frame_info.outer_bevel=geometry.x; |
| 1652 | frame_info.inner_bevel=geometry.y; |
| 1653 | frame_info.x=(ssize_t) frame_info.width; |
| 1654 | frame_info.y=(ssize_t) frame_info.height; |
| 1655 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1656 | frame_info.height=(*image)->rows+2*frame_info.height; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1657 | mogrify_image=FrameImage(*image,&frame_info,compose,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1658 | break; |
| 1659 | } |
| 1660 | if (LocaleCompare("function",option+1) == 0) |
| 1661 | { |
| 1662 | char |
| 1663 | *arguments, |
| 1664 | token[MaxTextExtent]; |
| 1665 | |
| 1666 | const char |
| 1667 | *p; |
| 1668 | |
| 1669 | double |
| 1670 | *parameters; |
| 1671 | |
| 1672 | MagickFunction |
| 1673 | function; |
| 1674 | |
| 1675 | register ssize_t |
| 1676 | x; |
| 1677 | |
| 1678 | size_t |
| 1679 | number_parameters; |
| 1680 | |
| 1681 | /* |
| 1682 | Function Modify Image Values |
| 1683 | */ |
| 1684 | (void) SyncImageSettings(mogrify_info,*image); |
| 1685 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, |
| 1686 | MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1687 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1688 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1689 | if (arguments == (char *) NULL) |
| 1690 | break; |
| 1691 | p=(char *) arguments; |
| 1692 | for (x=0; *p != '\0'; x++) |
| 1693 | { |
| 1694 | GetMagickToken(p,&p,token); |
| 1695 | if (*token == ',') |
| 1696 | GetMagickToken(p,&p,token); |
| 1697 | } |
| 1698 | number_parameters=(size_t) x; |
| 1699 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1700 | sizeof(*parameters)); |
| 1701 | if (parameters == (double *) NULL) |
| 1702 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1703 | "MemoryAllocationFailed",(*image)->filename); |
| 1704 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1705 | sizeof(*parameters)); |
| 1706 | p=(char *) arguments; |
| 1707 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
| 1708 | { |
| 1709 | GetMagickToken(p,&p,token); |
| 1710 | if (*token == ',') |
| 1711 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1712 | parameters[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1713 | } |
| 1714 | arguments=DestroyString(arguments); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1715 | (void) FunctionImage(*image,function,number_parameters,parameters, |
| 1716 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1717 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1718 | break; |
| 1719 | } |
| 1720 | break; |
| 1721 | } |
| 1722 | case 'g': |
| 1723 | { |
| 1724 | if (LocaleCompare("gamma",option+1) == 0) |
| 1725 | { |
| 1726 | /* |
| 1727 | Gamma image. |
| 1728 | */ |
| 1729 | (void) SyncImageSettings(mogrify_info,*image); |
| 1730 | if (*option == '+') |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1731 | (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1732 | else |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 1733 | (void) GammaImage(*image,InterpretLocaleValue(argv[i+1], |
| 1734 | (char **) NULL),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1735 | break; |
| 1736 | } |
| 1737 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1738 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1739 | { |
| 1740 | /* |
| 1741 | Gaussian blur image. |
| 1742 | */ |
| 1743 | (void) SyncImageSettings(mogrify_info,*image); |
| 1744 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1745 | if ((flags & SigmaValue) == 0) |
| 1746 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1747 | if ((flags & XiValue) == 0) |
| 1748 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1749 | mogrify_image=GaussianBlurImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1750 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1751 | break; |
| 1752 | } |
| 1753 | if (LocaleCompare("geometry",option+1) == 0) |
| 1754 | { |
| 1755 | /* |
| 1756 | Record Image offset, Resize last image. |
| 1757 | */ |
| 1758 | (void) SyncImageSettings(mogrify_info,*image); |
| 1759 | if (*option == '+') |
| 1760 | { |
| 1761 | if ((*image)->geometry != (char *) NULL) |
| 1762 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1763 | break; |
| 1764 | } |
| 1765 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1766 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1767 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1768 | else |
| 1769 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 1770 | (*image)->filter,(*image)->blur,exception); |
| 1771 | break; |
| 1772 | } |
| 1773 | if (LocaleCompare("gravity",option+1) == 0) |
| 1774 | { |
| 1775 | if (*option == '+') |
| 1776 | { |
| 1777 | draw_info->gravity=UndefinedGravity; |
| 1778 | break; |
| 1779 | } |
| 1780 | draw_info->gravity=(GravityType) ParseCommandOption( |
| 1781 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1782 | break; |
| 1783 | } |
| 1784 | break; |
| 1785 | } |
| 1786 | case 'h': |
| 1787 | { |
| 1788 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1789 | { |
| 1790 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1791 | break; |
| 1792 | } |
| 1793 | break; |
| 1794 | } |
| 1795 | case 'i': |
| 1796 | { |
| 1797 | if (LocaleCompare("identify",option+1) == 0) |
| 1798 | { |
| 1799 | char |
| 1800 | *text; |
| 1801 | |
| 1802 | (void) SyncImageSettings(mogrify_info,*image); |
| 1803 | if (format == (char *) NULL) |
| 1804 | { |
cristy | a403727 | 2011-08-28 15:11:39 +0000 | [diff] [blame] | 1805 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose, |
| 1806 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1807 | break; |
| 1808 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1809 | text=InterpretImageProperties(mogrify_info,*image,format, |
| 1810 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1811 | if (text == (char *) NULL) |
| 1812 | break; |
| 1813 | (void) fputs(text,stdout); |
| 1814 | (void) fputc('\n',stdout); |
| 1815 | text=DestroyString(text); |
| 1816 | break; |
| 1817 | } |
| 1818 | if (LocaleCompare("implode",option+1) == 0) |
| 1819 | { |
| 1820 | /* |
| 1821 | Implode image. |
| 1822 | */ |
| 1823 | (void) SyncImageSettings(mogrify_info,*image); |
| 1824 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 76f512e | 2011-09-12 01:26:56 +0000 | [diff] [blame] | 1825 | mogrify_image=ImplodeImage(*image,geometry_info.rho, |
| 1826 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1827 | break; |
| 1828 | } |
| 1829 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1830 | { |
| 1831 | if (*option == '+') |
| 1832 | (void) ParseGeometry("0",&geometry_info); |
| 1833 | else |
| 1834 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1835 | draw_info->interline_spacing=geometry_info.rho; |
| 1836 | break; |
| 1837 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 1838 | if (LocaleCompare("interpolate",option+1) == 0) |
| 1839 | { |
| 1840 | interpolate_method=(PixelInterpolateMethod) ParseCommandOption( |
| 1841 | MagickInterpolateOptions,MagickFalse,argv[i+1]); |
| 1842 | break; |
| 1843 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1844 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1845 | { |
| 1846 | if (*option == '+') |
| 1847 | (void) ParseGeometry("0",&geometry_info); |
| 1848 | else |
| 1849 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1850 | draw_info->interword_spacing=geometry_info.rho; |
| 1851 | break; |
| 1852 | } |
| 1853 | break; |
| 1854 | } |
| 1855 | case 'k': |
| 1856 | { |
| 1857 | if (LocaleCompare("kerning",option+1) == 0) |
| 1858 | { |
| 1859 | if (*option == '+') |
| 1860 | (void) ParseGeometry("0",&geometry_info); |
| 1861 | else |
| 1862 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1863 | draw_info->kerning=geometry_info.rho; |
| 1864 | break; |
| 1865 | } |
| 1866 | break; |
| 1867 | } |
| 1868 | case 'l': |
| 1869 | { |
| 1870 | if (LocaleCompare("lat",option+1) == 0) |
| 1871 | { |
| 1872 | /* |
| 1873 | Local adaptive threshold image. |
| 1874 | */ |
| 1875 | (void) SyncImageSettings(mogrify_info,*image); |
| 1876 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1877 | if ((flags & PercentValue) != 0) |
| 1878 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 1879 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
cristy | de5cc63 | 2011-07-18 14:47:00 +0000 | [diff] [blame] | 1880 | geometry_info.rho,(size_t) geometry_info.sigma,(double) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1881 | geometry_info.xi,exception); |
| 1882 | break; |
| 1883 | } |
| 1884 | if (LocaleCompare("level",option+1) == 0) |
| 1885 | { |
| 1886 | MagickRealType |
| 1887 | black_point, |
| 1888 | gamma, |
| 1889 | white_point; |
| 1890 | |
| 1891 | MagickStatusType |
| 1892 | flags; |
| 1893 | |
| 1894 | /* |
| 1895 | Parse levels. |
| 1896 | */ |
| 1897 | (void) SyncImageSettings(mogrify_info,*image); |
| 1898 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1899 | black_point=geometry_info.rho; |
| 1900 | white_point=(MagickRealType) QuantumRange; |
| 1901 | if ((flags & SigmaValue) != 0) |
| 1902 | white_point=geometry_info.sigma; |
| 1903 | gamma=1.0; |
| 1904 | if ((flags & XiValue) != 0) |
| 1905 | gamma=geometry_info.xi; |
| 1906 | if ((flags & PercentValue) != 0) |
| 1907 | { |
| 1908 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 1909 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 1910 | } |
| 1911 | if ((flags & SigmaValue) == 0) |
| 1912 | white_point=(MagickRealType) QuantumRange-black_point; |
| 1913 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1914 | (void) LevelizeImage(*image,black_point,white_point,gamma, |
| 1915 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1916 | else |
cristy | 01e9afd | 2011-08-10 17:38:41 +0000 | [diff] [blame] | 1917 | (void) LevelImage(*image,black_point,white_point,gamma, |
| 1918 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1919 | InheritException(exception,&(*image)->exception); |
| 1920 | break; |
| 1921 | } |
| 1922 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1923 | { |
| 1924 | char |
| 1925 | token[MaxTextExtent]; |
| 1926 | |
| 1927 | const char |
| 1928 | *p; |
| 1929 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1930 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1931 | black_point, |
| 1932 | white_point; |
| 1933 | |
| 1934 | p=(const char *) argv[i+1]; |
| 1935 | GetMagickToken(p,&p,token); /* get black point color */ |
| 1936 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1937 | (void) QueryMagickColorCompliance(token,AllCompliance, |
| 1938 | &black_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1939 | else |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1940 | (void) QueryMagickColorCompliance("#000000",AllCompliance, |
| 1941 | &black_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1942 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1943 | GetMagickToken(p,&p,token); |
| 1944 | if (*token == '\0') |
| 1945 | white_point=black_point; /* set everything to that color */ |
| 1946 | else |
| 1947 | { |
| 1948 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 1949 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 1950 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1951 | (void) QueryMagickColorCompliance(token,AllCompliance, |
| 1952 | &white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1953 | else |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1954 | (void) QueryMagickColorCompliance("#ffffff",AllCompliance, |
| 1955 | &white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1956 | } |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 1957 | (void) LevelImageColors(*image,&black_point,&white_point, |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1958 | *option == '+' ? MagickTrue : MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1959 | break; |
| 1960 | } |
| 1961 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 1962 | { |
| 1963 | double |
| 1964 | black_point, |
| 1965 | white_point; |
| 1966 | |
| 1967 | MagickStatusType |
| 1968 | flags; |
| 1969 | |
| 1970 | (void) SyncImageSettings(mogrify_info,*image); |
| 1971 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1972 | black_point=geometry_info.rho; |
| 1973 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 1974 | if ((flags & SigmaValue) != 0) |
| 1975 | white_point=geometry_info.sigma; |
| 1976 | if ((flags & PercentValue) != 0) |
| 1977 | { |
| 1978 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1979 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1980 | } |
| 1981 | if ((flags & SigmaValue) == 0) |
| 1982 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1983 | black_point; |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 1984 | (void) LinearStretchImage(*image,black_point,white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1985 | InheritException(exception,&(*image)->exception); |
| 1986 | break; |
| 1987 | } |
| 1988 | if (LocaleCompare("linewidth",option+1) == 0) |
| 1989 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1990 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 1991 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1992 | break; |
| 1993 | } |
| 1994 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 1995 | { |
| 1996 | /* |
| 1997 | Liquid rescale image. |
| 1998 | */ |
| 1999 | (void) SyncImageSettings(mogrify_info,*image); |
| 2000 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2001 | if ((flags & XValue) == 0) |
| 2002 | geometry.x=1; |
| 2003 | if ((flags & YValue) == 0) |
| 2004 | geometry.y=0; |
| 2005 | mogrify_image=LiquidRescaleImage(*image,geometry.width, |
| 2006 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 2007 | break; |
| 2008 | } |
| 2009 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 2010 | { |
| 2011 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 2012 | break; |
| 2013 | } |
| 2014 | break; |
| 2015 | } |
| 2016 | case 'm': |
| 2017 | { |
| 2018 | if (LocaleCompare("map",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2019 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2020 | Image |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2021 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2022 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2023 | /* |
| 2024 | Transform image colors to match this set of colors. |
| 2025 | */ |
| 2026 | (void) SyncImageSettings(mogrify_info,*image); |
| 2027 | if (*option == '+') |
| 2028 | break; |
| 2029 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2030 | if (remap_image == (Image *) NULL) |
| 2031 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2032 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2033 | remap_image=DestroyImage(remap_image); |
| 2034 | break; |
| 2035 | } |
| 2036 | if (LocaleCompare("mask",option+1) == 0) |
| 2037 | { |
| 2038 | Image |
| 2039 | *mask; |
| 2040 | |
| 2041 | (void) SyncImageSettings(mogrify_info,*image); |
| 2042 | if (*option == '+') |
| 2043 | { |
| 2044 | /* |
| 2045 | Remove a mask. |
| 2046 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2047 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2048 | break; |
| 2049 | } |
| 2050 | /* |
| 2051 | Set the image mask. |
| 2052 | */ |
| 2053 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2054 | if (mask == (Image *) NULL) |
| 2055 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2056 | (void) SetImageMask(*image,mask,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2057 | mask=DestroyImage(mask); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2058 | break; |
| 2059 | } |
| 2060 | if (LocaleCompare("matte",option+1) == 0) |
| 2061 | { |
| 2062 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 2063 | SetAlphaChannel : DeactivateAlphaChannel,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2064 | break; |
| 2065 | } |
| 2066 | if (LocaleCompare("median",option+1) == 0) |
| 2067 | { |
| 2068 | /* |
| 2069 | Median filter image. |
| 2070 | */ |
| 2071 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2072 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2073 | if ((flags & SigmaValue) == 0) |
| 2074 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2075 | mogrify_image=StatisticImage(*image,MedianStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2076 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2077 | break; |
| 2078 | } |
| 2079 | if (LocaleCompare("mode",option+1) == 0) |
| 2080 | { |
| 2081 | /* |
| 2082 | Mode image. |
| 2083 | */ |
| 2084 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2085 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2086 | if ((flags & SigmaValue) == 0) |
| 2087 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2088 | mogrify_image=StatisticImage(*image,ModeStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2089 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2090 | break; |
| 2091 | } |
| 2092 | if (LocaleCompare("modulate",option+1) == 0) |
| 2093 | { |
| 2094 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2095 | (void) ModulateImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2096 | break; |
| 2097 | } |
| 2098 | if (LocaleCompare("monitor",option+1) == 0) |
| 2099 | { |
| 2100 | if (*option == '+') |
| 2101 | { |
| 2102 | (void) SetImageProgressMonitor(*image, |
| 2103 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2104 | break; |
| 2105 | } |
| 2106 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2107 | (void *) NULL); |
| 2108 | break; |
| 2109 | } |
| 2110 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2111 | { |
| 2112 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2113 | (void) SetImageType(*image,BilevelType,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2114 | break; |
| 2115 | } |
| 2116 | if (LocaleCompare("morphology",option+1) == 0) |
| 2117 | { |
| 2118 | char |
| 2119 | token[MaxTextExtent]; |
| 2120 | |
| 2121 | const char |
| 2122 | *p; |
| 2123 | |
| 2124 | KernelInfo |
| 2125 | *kernel; |
| 2126 | |
| 2127 | MorphologyMethod |
| 2128 | method; |
| 2129 | |
| 2130 | ssize_t |
| 2131 | iterations; |
| 2132 | |
| 2133 | /* |
| 2134 | Morphological Image Operation |
| 2135 | */ |
| 2136 | (void) SyncImageSettings(mogrify_info,*image); |
| 2137 | p=argv[i+1]; |
| 2138 | GetMagickToken(p,&p,token); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2139 | method=(MorphologyMethod) ParseCommandOption( |
| 2140 | MagickMorphologyOptions,MagickFalse,token); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2141 | iterations=1L; |
| 2142 | GetMagickToken(p,&p,token); |
| 2143 | if ((*p == ':') || (*p == ',')) |
| 2144 | GetMagickToken(p,&p,token); |
| 2145 | if ((*p != '\0')) |
| 2146 | iterations=(ssize_t) StringToLong(p); |
| 2147 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2148 | if (kernel == (KernelInfo *) NULL) |
| 2149 | { |
| 2150 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2151 | OptionError,"UnabletoParseKernel","morphology"); |
| 2152 | status=MagickFalse; |
| 2153 | break; |
| 2154 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2155 | mogrify_image=MorphologyImage(*image,method,iterations,kernel, |
| 2156 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2157 | kernel=DestroyKernelInfo(kernel); |
| 2158 | break; |
| 2159 | } |
| 2160 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2161 | { |
| 2162 | /* |
| 2163 | Motion blur image. |
| 2164 | */ |
| 2165 | (void) SyncImageSettings(mogrify_info,*image); |
| 2166 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2167 | if ((flags & SigmaValue) == 0) |
| 2168 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2169 | mogrify_image=MotionBlurImage(*image,geometry_info.rho, |
cristy | f7ef025 | 2011-09-09 14:50:06 +0000 | [diff] [blame] | 2170 | geometry_info.sigma,geometry_info.xi,geometry_info.psi, |
| 2171 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2172 | break; |
| 2173 | } |
| 2174 | break; |
| 2175 | } |
| 2176 | case 'n': |
| 2177 | { |
| 2178 | if (LocaleCompare("negate",option+1) == 0) |
| 2179 | { |
| 2180 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2181 | (void) NegateImage(*image,*option == '+' ? MagickTrue : |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 2182 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2183 | break; |
| 2184 | } |
| 2185 | if (LocaleCompare("noise",option+1) == 0) |
| 2186 | { |
| 2187 | (void) SyncImageSettings(mogrify_info,*image); |
| 2188 | if (*option == '-') |
| 2189 | { |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2190 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2191 | if ((flags & SigmaValue) == 0) |
| 2192 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2193 | mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2194 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2195 | } |
| 2196 | else |
| 2197 | { |
| 2198 | NoiseType |
| 2199 | noise; |
| 2200 | |
| 2201 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
| 2202 | MagickFalse,argv[i+1]); |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame^] | 2203 | mogrify_image=AddNoiseImage(*image,noise,attenuate,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2204 | } |
| 2205 | break; |
| 2206 | } |
| 2207 | if (LocaleCompare("normalize",option+1) == 0) |
| 2208 | { |
| 2209 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 2210 | (void) NormalizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2211 | break; |
| 2212 | } |
| 2213 | break; |
| 2214 | } |
| 2215 | case 'o': |
| 2216 | { |
| 2217 | if (LocaleCompare("opaque",option+1) == 0) |
| 2218 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2219 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2220 | target; |
| 2221 | |
| 2222 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2223 | (void) QueryMagickColorCompliance(argv[i+1],AllCompliance,&target, |
| 2224 | exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 2225 | (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ? |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 2226 | MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2227 | break; |
| 2228 | } |
| 2229 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2230 | { |
| 2231 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 1302067 | 2011-07-08 02:33:26 +0000 | [diff] [blame] | 2232 | (void) OrderedPosterizeImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2233 | break; |
| 2234 | } |
| 2235 | break; |
| 2236 | } |
| 2237 | case 'p': |
| 2238 | { |
| 2239 | if (LocaleCompare("paint",option+1) == 0) |
| 2240 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2241 | (void) SyncImageSettings(mogrify_info,*image); |
| 2242 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 14973ba | 2011-08-27 23:48:07 +0000 | [diff] [blame] | 2243 | mogrify_image=OilPaintImage(*image,geometry_info.rho, |
| 2244 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2245 | break; |
| 2246 | } |
| 2247 | if (LocaleCompare("pen",option+1) == 0) |
| 2248 | { |
| 2249 | if (*option == '+') |
| 2250 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2251 | (void) QueryColorCompliance("none",AllCompliance, |
| 2252 | &draw_info->fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2253 | break; |
| 2254 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2255 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 2256 | &draw_info->fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2257 | break; |
| 2258 | } |
| 2259 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2260 | { |
| 2261 | if (*option == '+') |
| 2262 | (void) ParseGeometry("12",&geometry_info); |
| 2263 | else |
| 2264 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2265 | draw_info->pointsize=geometry_info.rho; |
| 2266 | break; |
| 2267 | } |
| 2268 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2269 | { |
| 2270 | double |
| 2271 | angle; |
| 2272 | |
| 2273 | RandomInfo |
| 2274 | *random_info; |
| 2275 | |
| 2276 | /* |
| 2277 | Simulate a Polaroid picture. |
| 2278 | */ |
| 2279 | (void) SyncImageSettings(mogrify_info,*image); |
| 2280 | random_info=AcquireRandomInfo(); |
| 2281 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2282 | random_info=DestroyRandomInfo(random_info); |
| 2283 | if (*option == '-') |
| 2284 | { |
| 2285 | SetGeometryInfo(&geometry_info); |
| 2286 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2287 | angle=geometry_info.rho; |
| 2288 | } |
cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame] | 2289 | mogrify_image=PolaroidImage(*image,draw_info,angle, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2290 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2291 | break; |
| 2292 | } |
| 2293 | if (LocaleCompare("posterize",option+1) == 0) |
| 2294 | { |
| 2295 | /* |
| 2296 | Posterize image. |
| 2297 | */ |
| 2298 | (void) SyncImageSettings(mogrify_info,*image); |
| 2299 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2300 | quantize_info->dither,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2301 | break; |
| 2302 | } |
| 2303 | if (LocaleCompare("preview",option+1) == 0) |
| 2304 | { |
| 2305 | PreviewType |
| 2306 | preview_type; |
| 2307 | |
| 2308 | /* |
| 2309 | Preview image. |
| 2310 | */ |
| 2311 | (void) SyncImageSettings(mogrify_info,*image); |
| 2312 | if (*option == '+') |
| 2313 | preview_type=UndefinedPreview; |
| 2314 | else |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2315 | preview_type=(PreviewType) ParseCommandOption( |
| 2316 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2317 | mogrify_image=PreviewImage(*image,preview_type,exception); |
| 2318 | break; |
| 2319 | } |
| 2320 | if (LocaleCompare("profile",option+1) == 0) |
| 2321 | { |
| 2322 | const char |
| 2323 | *name; |
| 2324 | |
| 2325 | const StringInfo |
| 2326 | *profile; |
| 2327 | |
| 2328 | Image |
| 2329 | *profile_image; |
| 2330 | |
| 2331 | ImageInfo |
| 2332 | *profile_info; |
| 2333 | |
| 2334 | (void) SyncImageSettings(mogrify_info,*image); |
| 2335 | if (*option == '+') |
| 2336 | { |
| 2337 | /* |
| 2338 | Remove a profile from the image. |
| 2339 | */ |
| 2340 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
| 2341 | NULL,0,MagickTrue); |
| 2342 | InheritException(exception,&(*image)->exception); |
| 2343 | break; |
| 2344 | } |
| 2345 | /* |
| 2346 | Associate a profile with the image. |
| 2347 | */ |
| 2348 | profile_info=CloneImageInfo(mogrify_info); |
| 2349 | profile=GetImageProfile(*image,"iptc"); |
| 2350 | if (profile != (StringInfo *) NULL) |
| 2351 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2352 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2353 | profile_info=DestroyImageInfo(profile_info); |
| 2354 | if (profile_image == (Image *) NULL) |
| 2355 | { |
| 2356 | StringInfo |
| 2357 | *profile; |
| 2358 | |
| 2359 | profile_info=CloneImageInfo(mogrify_info); |
| 2360 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2361 | MaxTextExtent); |
| 2362 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
| 2363 | if (profile != (StringInfo *) NULL) |
| 2364 | { |
| 2365 | (void) ProfileImage(*image,profile_info->magick, |
| 2366 | GetStringInfoDatum(profile),(size_t) |
| 2367 | GetStringInfoLength(profile),MagickFalse); |
| 2368 | profile=DestroyStringInfo(profile); |
| 2369 | } |
| 2370 | profile_info=DestroyImageInfo(profile_info); |
| 2371 | break; |
| 2372 | } |
| 2373 | ResetImageProfileIterator(profile_image); |
| 2374 | name=GetNextImageProfile(profile_image); |
| 2375 | while (name != (const char *) NULL) |
| 2376 | { |
| 2377 | profile=GetImageProfile(profile_image,name); |
| 2378 | if (profile != (StringInfo *) NULL) |
| 2379 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
| 2380 | (size_t) GetStringInfoLength(profile),MagickFalse); |
| 2381 | name=GetNextImageProfile(profile_image); |
| 2382 | } |
| 2383 | profile_image=DestroyImage(profile_image); |
| 2384 | break; |
| 2385 | } |
| 2386 | break; |
| 2387 | } |
| 2388 | case 'q': |
| 2389 | { |
| 2390 | if (LocaleCompare("quantize",option+1) == 0) |
| 2391 | { |
| 2392 | if (*option == '+') |
| 2393 | { |
| 2394 | quantize_info->colorspace=UndefinedColorspace; |
| 2395 | break; |
| 2396 | } |
| 2397 | quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
| 2398 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2399 | break; |
| 2400 | } |
| 2401 | break; |
| 2402 | } |
| 2403 | case 'r': |
| 2404 | { |
| 2405 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2406 | { |
| 2407 | /* |
| 2408 | Radial blur image. |
| 2409 | */ |
| 2410 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 6435bd9 | 2011-09-10 02:10:07 +0000 | [diff] [blame] | 2411 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2412 | mogrify_image=RadialBlurImage(*image,geometry_info.rho, |
| 2413 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2414 | break; |
| 2415 | } |
| 2416 | if (LocaleCompare("raise",option+1) == 0) |
| 2417 | { |
| 2418 | /* |
| 2419 | Surround image with a raise of solid color. |
| 2420 | */ |
| 2421 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2422 | if ((flags & SigmaValue) == 0) |
| 2423 | geometry.height=geometry.width; |
| 2424 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
cristy | 6170ac3 | 2011-08-28 14:15:37 +0000 | [diff] [blame] | 2425 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2426 | break; |
| 2427 | } |
| 2428 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2429 | { |
| 2430 | /* |
| 2431 | Threshold image. |
| 2432 | */ |
| 2433 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2434 | (void) RandomThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2435 | break; |
| 2436 | } |
| 2437 | if (LocaleCompare("recolor",option+1) == 0) |
| 2438 | { |
| 2439 | KernelInfo |
| 2440 | *kernel; |
| 2441 | |
| 2442 | (void) SyncImageSettings(mogrify_info,*image); |
| 2443 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2444 | if (kernel == (KernelInfo *) NULL) |
| 2445 | break; |
| 2446 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 2447 | kernel=DestroyKernelInfo(kernel); |
| 2448 | break; |
| 2449 | } |
| 2450 | if (LocaleCompare("region",option+1) == 0) |
| 2451 | { |
| 2452 | (void) SyncImageSettings(mogrify_info,*image); |
| 2453 | if (region_image != (Image *) NULL) |
| 2454 | { |
| 2455 | /* |
| 2456 | Composite region. |
| 2457 | */ |
| 2458 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2459 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 2460 | region_geometry.x,region_geometry.y); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2461 | InheritException(exception,®ion_image->exception); |
| 2462 | *image=DestroyImage(*image); |
| 2463 | *image=region_image; |
| 2464 | region_image = (Image *) NULL; |
| 2465 | } |
| 2466 | if (*option == '+') |
| 2467 | break; |
| 2468 | /* |
| 2469 | Apply transformations to a selected region of the image. |
| 2470 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2471 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2472 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2473 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2474 | if (mogrify_image == (Image *) NULL) |
| 2475 | break; |
| 2476 | region_image=(*image); |
| 2477 | *image=mogrify_image; |
| 2478 | mogrify_image=(Image *) NULL; |
| 2479 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2480 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2481 | if (LocaleCompare("render",option+1) == 0) |
| 2482 | { |
| 2483 | (void) SyncImageSettings(mogrify_info,*image); |
| 2484 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2485 | break; |
| 2486 | } |
| 2487 | if (LocaleCompare("remap",option+1) == 0) |
| 2488 | { |
| 2489 | Image |
| 2490 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2491 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2492 | /* |
| 2493 | Transform image colors to match this set of colors. |
| 2494 | */ |
| 2495 | (void) SyncImageSettings(mogrify_info,*image); |
| 2496 | if (*option == '+') |
| 2497 | break; |
| 2498 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2499 | if (remap_image == (Image *) NULL) |
| 2500 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2501 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2502 | remap_image=DestroyImage(remap_image); |
| 2503 | break; |
| 2504 | } |
| 2505 | if (LocaleCompare("repage",option+1) == 0) |
| 2506 | { |
| 2507 | if (*option == '+') |
| 2508 | { |
| 2509 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2510 | break; |
| 2511 | } |
| 2512 | (void) ResetImagePage(*image,argv[i+1]); |
| 2513 | InheritException(exception,&(*image)->exception); |
| 2514 | break; |
| 2515 | } |
| 2516 | if (LocaleCompare("resample",option+1) == 0) |
| 2517 | { |
| 2518 | /* |
| 2519 | Resample image. |
| 2520 | */ |
| 2521 | (void) SyncImageSettings(mogrify_info,*image); |
| 2522 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2523 | if ((flags & SigmaValue) == 0) |
| 2524 | geometry_info.sigma=geometry_info.rho; |
| 2525 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
| 2526 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2527 | break; |
| 2528 | } |
| 2529 | if (LocaleCompare("resize",option+1) == 0) |
| 2530 | { |
| 2531 | /* |
| 2532 | Resize image. |
| 2533 | */ |
| 2534 | (void) SyncImageSettings(mogrify_info,*image); |
| 2535 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2536 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2537 | (*image)->filter,(*image)->blur,exception); |
| 2538 | break; |
| 2539 | } |
| 2540 | if (LocaleCompare("roll",option+1) == 0) |
| 2541 | { |
| 2542 | /* |
| 2543 | Roll image. |
| 2544 | */ |
| 2545 | (void) SyncImageSettings(mogrify_info,*image); |
| 2546 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2547 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2548 | break; |
| 2549 | } |
| 2550 | if (LocaleCompare("rotate",option+1) == 0) |
| 2551 | { |
| 2552 | char |
| 2553 | *geometry; |
| 2554 | |
| 2555 | /* |
| 2556 | Check for conditional image rotation. |
| 2557 | */ |
| 2558 | (void) SyncImageSettings(mogrify_info,*image); |
| 2559 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2560 | if ((*image)->columns <= (*image)->rows) |
| 2561 | break; |
| 2562 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2563 | if ((*image)->columns >= (*image)->rows) |
| 2564 | break; |
| 2565 | /* |
| 2566 | Rotate image. |
| 2567 | */ |
| 2568 | geometry=ConstantString(argv[i+1]); |
| 2569 | (void) SubstituteString(&geometry,">",""); |
| 2570 | (void) SubstituteString(&geometry,"<",""); |
| 2571 | (void) ParseGeometry(geometry,&geometry_info); |
| 2572 | geometry=DestroyString(geometry); |
| 2573 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
| 2574 | break; |
| 2575 | } |
| 2576 | break; |
| 2577 | } |
| 2578 | case 's': |
| 2579 | { |
| 2580 | if (LocaleCompare("sample",option+1) == 0) |
| 2581 | { |
| 2582 | /* |
| 2583 | Sample image with pixel replication. |
| 2584 | */ |
| 2585 | (void) SyncImageSettings(mogrify_info,*image); |
| 2586 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2587 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
| 2588 | exception); |
| 2589 | break; |
| 2590 | } |
| 2591 | if (LocaleCompare("scale",option+1) == 0) |
| 2592 | { |
| 2593 | /* |
| 2594 | Resize image. |
| 2595 | */ |
| 2596 | (void) SyncImageSettings(mogrify_info,*image); |
| 2597 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2598 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2599 | exception); |
| 2600 | break; |
| 2601 | } |
| 2602 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2603 | { |
| 2604 | /* |
| 2605 | Selectively blur pixels within a contrast threshold. |
| 2606 | */ |
| 2607 | (void) SyncImageSettings(mogrify_info,*image); |
| 2608 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2609 | if ((flags & PercentValue) != 0) |
| 2610 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2611 | mogrify_image=SelectiveBlurImage(*image,geometry_info.rho, |
cristy | 1e7aa31 | 2011-09-10 20:01:36 +0000 | [diff] [blame] | 2612 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2613 | break; |
| 2614 | } |
| 2615 | if (LocaleCompare("separate",option+1) == 0) |
| 2616 | { |
| 2617 | /* |
| 2618 | Break channels into separate images. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2619 | */ |
| 2620 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 2621 | mogrify_image=SeparateImages(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2622 | break; |
| 2623 | } |
| 2624 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2625 | { |
| 2626 | double |
| 2627 | threshold; |
| 2628 | |
| 2629 | /* |
| 2630 | Sepia-tone image. |
| 2631 | */ |
| 2632 | (void) SyncImageSettings(mogrify_info,*image); |
| 2633 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2634 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
| 2635 | break; |
| 2636 | } |
| 2637 | if (LocaleCompare("segment",option+1) == 0) |
| 2638 | { |
| 2639 | /* |
| 2640 | Segment image. |
| 2641 | */ |
| 2642 | (void) SyncImageSettings(mogrify_info,*image); |
| 2643 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2644 | if ((flags & SigmaValue) == 0) |
| 2645 | geometry_info.sigma=1.0; |
| 2646 | (void) SegmentImage(*image,(*image)->colorspace, |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2647 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 2648 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2649 | break; |
| 2650 | } |
| 2651 | if (LocaleCompare("set",option+1) == 0) |
| 2652 | { |
| 2653 | char |
| 2654 | *value; |
| 2655 | |
| 2656 | /* |
| 2657 | Set image option. |
| 2658 | */ |
| 2659 | if (*option == '+') |
| 2660 | { |
| 2661 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2662 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2663 | else |
| 2664 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2665 | { |
| 2666 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
| 2667 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2668 | } |
| 2669 | else |
| 2670 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2671 | break; |
| 2672 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2673 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2674 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2675 | if (value == (char *) NULL) |
| 2676 | break; |
| 2677 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2678 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2679 | exception); |
| 2680 | else |
| 2681 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2682 | { |
| 2683 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
| 2684 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
| 2685 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2686 | } |
| 2687 | else |
| 2688 | (void) SetImageProperty(*image,argv[i+1],value); |
| 2689 | value=DestroyString(value); |
| 2690 | break; |
| 2691 | } |
| 2692 | if (LocaleCompare("shade",option+1) == 0) |
| 2693 | { |
| 2694 | /* |
| 2695 | Shade image. |
| 2696 | */ |
| 2697 | (void) SyncImageSettings(mogrify_info,*image); |
| 2698 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2699 | if ((flags & SigmaValue) == 0) |
| 2700 | geometry_info.sigma=1.0; |
| 2701 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2702 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2703 | break; |
| 2704 | } |
| 2705 | if (LocaleCompare("shadow",option+1) == 0) |
| 2706 | { |
| 2707 | /* |
| 2708 | Shadow image. |
| 2709 | */ |
| 2710 | (void) SyncImageSettings(mogrify_info,*image); |
| 2711 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2712 | if ((flags & SigmaValue) == 0) |
| 2713 | geometry_info.sigma=1.0; |
| 2714 | if ((flags & XiValue) == 0) |
| 2715 | geometry_info.xi=4.0; |
| 2716 | if ((flags & PsiValue) == 0) |
| 2717 | geometry_info.psi=4.0; |
| 2718 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
| 2719 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 2720 | ceil(geometry_info.psi-0.5),exception); |
| 2721 | break; |
| 2722 | } |
| 2723 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2724 | { |
| 2725 | /* |
| 2726 | Sharpen image. |
| 2727 | */ |
| 2728 | (void) SyncImageSettings(mogrify_info,*image); |
| 2729 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2730 | if ((flags & SigmaValue) == 0) |
| 2731 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2732 | if ((flags & XiValue) == 0) |
| 2733 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2734 | mogrify_image=SharpenImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2735 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2736 | break; |
| 2737 | } |
| 2738 | if (LocaleCompare("shave",option+1) == 0) |
| 2739 | { |
| 2740 | /* |
| 2741 | Shave the image edges. |
| 2742 | */ |
| 2743 | (void) SyncImageSettings(mogrify_info,*image); |
| 2744 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2745 | mogrify_image=ShaveImage(*image,&geometry,exception); |
| 2746 | break; |
| 2747 | } |
| 2748 | if (LocaleCompare("shear",option+1) == 0) |
| 2749 | { |
| 2750 | /* |
| 2751 | Shear image. |
| 2752 | */ |
| 2753 | (void) SyncImageSettings(mogrify_info,*image); |
| 2754 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2755 | if ((flags & SigmaValue) == 0) |
| 2756 | geometry_info.sigma=geometry_info.rho; |
| 2757 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2758 | geometry_info.sigma,exception); |
| 2759 | break; |
| 2760 | } |
| 2761 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2762 | { |
| 2763 | /* |
| 2764 | Sigmoidal non-linearity contrast control. |
| 2765 | */ |
| 2766 | (void) SyncImageSettings(mogrify_info,*image); |
| 2767 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2768 | if ((flags & SigmaValue) == 0) |
| 2769 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 2770 | if ((flags & PercentValue) != 0) |
| 2771 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2772 | 100.0; |
cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 2773 | (void) SigmoidalContrastImage(*image,(*option == '-') ? |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2774 | MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma, |
| 2775 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2776 | break; |
| 2777 | } |
| 2778 | if (LocaleCompare("sketch",option+1) == 0) |
| 2779 | { |
| 2780 | /* |
| 2781 | Sketch image. |
| 2782 | */ |
| 2783 | (void) SyncImageSettings(mogrify_info,*image); |
| 2784 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2785 | if ((flags & SigmaValue) == 0) |
| 2786 | geometry_info.sigma=1.0; |
| 2787 | mogrify_image=SketchImage(*image,geometry_info.rho, |
cristy | f7ef025 | 2011-09-09 14:50:06 +0000 | [diff] [blame] | 2788 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2789 | break; |
| 2790 | } |
| 2791 | if (LocaleCompare("solarize",option+1) == 0) |
| 2792 | { |
| 2793 | double |
| 2794 | threshold; |
| 2795 | |
| 2796 | (void) SyncImageSettings(mogrify_info,*image); |
| 2797 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 2798 | (void) SolarizeImage(*image,threshold,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2799 | break; |
| 2800 | } |
| 2801 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2802 | { |
| 2803 | SparseColorMethod |
| 2804 | method; |
| 2805 | |
| 2806 | char |
| 2807 | *arguments; |
| 2808 | |
| 2809 | /* |
| 2810 | Sparse Color Interpolated Gradient |
| 2811 | */ |
| 2812 | (void) SyncImageSettings(mogrify_info,*image); |
| 2813 | method=(SparseColorMethod) ParseCommandOption( |
| 2814 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2815 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2816 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2817 | if (arguments == (char *) NULL) |
| 2818 | break; |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 2819 | mogrify_image=SparseColorOption(*image,method,arguments, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2820 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2821 | arguments=DestroyString(arguments); |
| 2822 | break; |
| 2823 | } |
| 2824 | if (LocaleCompare("splice",option+1) == 0) |
| 2825 | { |
| 2826 | /* |
| 2827 | Splice a solid color into the image. |
| 2828 | */ |
| 2829 | (void) SyncImageSettings(mogrify_info,*image); |
| 2830 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 2831 | mogrify_image=SpliceImage(*image,&geometry,exception); |
| 2832 | break; |
| 2833 | } |
| 2834 | if (LocaleCompare("spread",option+1) == 0) |
| 2835 | { |
| 2836 | /* |
| 2837 | Spread an image. |
| 2838 | */ |
| 2839 | (void) SyncImageSettings(mogrify_info,*image); |
| 2840 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame] | 2841 | mogrify_image=SpreadImage(*image,geometry_info.rho, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2842 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2843 | break; |
| 2844 | } |
| 2845 | if (LocaleCompare("statistic",option+1) == 0) |
| 2846 | { |
| 2847 | StatisticType |
| 2848 | type; |
| 2849 | |
| 2850 | (void) SyncImageSettings(mogrify_info,*image); |
| 2851 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
| 2852 | MagickFalse,argv[i+1]); |
| 2853 | (void) ParseGeometry(argv[i+2],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2854 | mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho, |
| 2855 | (size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2856 | break; |
| 2857 | } |
| 2858 | if (LocaleCompare("stretch",option+1) == 0) |
| 2859 | { |
| 2860 | if (*option == '+') |
| 2861 | { |
| 2862 | draw_info->stretch=UndefinedStretch; |
| 2863 | break; |
| 2864 | } |
| 2865 | draw_info->stretch=(StretchType) ParseCommandOption( |
| 2866 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2867 | break; |
| 2868 | } |
| 2869 | if (LocaleCompare("strip",option+1) == 0) |
| 2870 | { |
| 2871 | /* |
| 2872 | Strip image of profiles and comments. |
| 2873 | */ |
| 2874 | (void) SyncImageSettings(mogrify_info,*image); |
| 2875 | (void) StripImage(*image); |
| 2876 | InheritException(exception,&(*image)->exception); |
| 2877 | break; |
| 2878 | } |
| 2879 | if (LocaleCompare("stroke",option+1) == 0) |
| 2880 | { |
| 2881 | ExceptionInfo |
| 2882 | *sans; |
| 2883 | |
| 2884 | if (*option == '+') |
| 2885 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2886 | (void) QueryColorCompliance("none",AllCompliance, |
| 2887 | &draw_info->stroke,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2888 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2889 | draw_info->stroke_pattern=DestroyImage( |
| 2890 | draw_info->stroke_pattern); |
| 2891 | break; |
| 2892 | } |
| 2893 | sans=AcquireExceptionInfo(); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2894 | status=QueryColorCompliance(argv[i+1],AllCompliance, |
| 2895 | &draw_info->stroke,sans); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2896 | sans=DestroyExceptionInfo(sans); |
| 2897 | if (status == MagickFalse) |
| 2898 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2899 | exception); |
| 2900 | break; |
| 2901 | } |
| 2902 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2903 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 2904 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 2905 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2906 | break; |
| 2907 | } |
| 2908 | if (LocaleCompare("style",option+1) == 0) |
| 2909 | { |
| 2910 | if (*option == '+') |
| 2911 | { |
| 2912 | draw_info->style=UndefinedStyle; |
| 2913 | break; |
| 2914 | } |
| 2915 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 2916 | MagickFalse,argv[i+1]); |
| 2917 | break; |
| 2918 | } |
| 2919 | if (LocaleCompare("swirl",option+1) == 0) |
| 2920 | { |
| 2921 | /* |
| 2922 | Swirl image. |
| 2923 | */ |
| 2924 | (void) SyncImageSettings(mogrify_info,*image); |
| 2925 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 76f512e | 2011-09-12 01:26:56 +0000 | [diff] [blame] | 2926 | mogrify_image=SwirlImage(*image,geometry_info.rho, |
| 2927 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2928 | break; |
| 2929 | } |
| 2930 | break; |
| 2931 | } |
| 2932 | case 't': |
| 2933 | { |
| 2934 | if (LocaleCompare("threshold",option+1) == 0) |
| 2935 | { |
| 2936 | double |
| 2937 | threshold; |
| 2938 | |
| 2939 | /* |
| 2940 | Threshold image. |
| 2941 | */ |
| 2942 | (void) SyncImageSettings(mogrify_info,*image); |
| 2943 | if (*option == '+') |
anthony | 247a86d | 2011-05-03 13:18:18 +0000 | [diff] [blame] | 2944 | threshold=(double) QuantumRange/2; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2945 | else |
| 2946 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2947 | (void) BilevelImage(*image,threshold); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2948 | InheritException(exception,&(*image)->exception); |
| 2949 | break; |
| 2950 | } |
| 2951 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2952 | { |
| 2953 | /* |
| 2954 | Thumbnail image. |
| 2955 | */ |
| 2956 | (void) SyncImageSettings(mogrify_info,*image); |
| 2957 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2958 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2959 | exception); |
| 2960 | break; |
| 2961 | } |
| 2962 | if (LocaleCompare("tile",option+1) == 0) |
| 2963 | { |
| 2964 | if (*option == '+') |
| 2965 | { |
| 2966 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2967 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2968 | break; |
| 2969 | } |
| 2970 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2971 | exception); |
| 2972 | break; |
| 2973 | } |
| 2974 | if (LocaleCompare("tint",option+1) == 0) |
| 2975 | { |
| 2976 | /* |
| 2977 | Tint the image. |
| 2978 | */ |
| 2979 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2980 | mogrify_image=TintImage(*image,argv[i+1],&fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2981 | break; |
| 2982 | } |
| 2983 | if (LocaleCompare("transform",option+1) == 0) |
| 2984 | { |
| 2985 | /* |
| 2986 | Affine transform image. |
| 2987 | */ |
| 2988 | (void) SyncImageSettings(mogrify_info,*image); |
| 2989 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
| 2990 | exception); |
| 2991 | break; |
| 2992 | } |
| 2993 | if (LocaleCompare("transparent",option+1) == 0) |
| 2994 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2995 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2996 | target; |
| 2997 | |
| 2998 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2999 | (void) QueryMagickColorCompliance(argv[i+1],AllCompliance,&target, |
| 3000 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3001 | (void) TransparentPaintImage(*image,&target,(Quantum) |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 3002 | TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue, |
| 3003 | &(*image)->exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3004 | break; |
| 3005 | } |
| 3006 | if (LocaleCompare("transpose",option+1) == 0) |
| 3007 | { |
| 3008 | /* |
| 3009 | Transpose image scanlines. |
| 3010 | */ |
| 3011 | (void) SyncImageSettings(mogrify_info,*image); |
| 3012 | mogrify_image=TransposeImage(*image,exception); |
| 3013 | break; |
| 3014 | } |
| 3015 | if (LocaleCompare("transverse",option+1) == 0) |
| 3016 | { |
| 3017 | /* |
| 3018 | Transverse image scanlines. |
| 3019 | */ |
| 3020 | (void) SyncImageSettings(mogrify_info,*image); |
| 3021 | mogrify_image=TransverseImage(*image,exception); |
| 3022 | break; |
| 3023 | } |
| 3024 | if (LocaleCompare("treedepth",option+1) == 0) |
| 3025 | { |
| 3026 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
| 3027 | break; |
| 3028 | } |
| 3029 | if (LocaleCompare("trim",option+1) == 0) |
| 3030 | { |
| 3031 | /* |
| 3032 | Trim image. |
| 3033 | */ |
| 3034 | (void) SyncImageSettings(mogrify_info,*image); |
| 3035 | mogrify_image=TrimImage(*image,exception); |
| 3036 | break; |
| 3037 | } |
| 3038 | if (LocaleCompare("type",option+1) == 0) |
| 3039 | { |
| 3040 | ImageType |
| 3041 | type; |
| 3042 | |
| 3043 | (void) SyncImageSettings(mogrify_info,*image); |
| 3044 | if (*option == '+') |
| 3045 | type=UndefinedType; |
| 3046 | else |
| 3047 | type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 3048 | argv[i+1]); |
| 3049 | (*image)->type=UndefinedType; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3050 | (void) SetImageType(*image,type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3051 | break; |
| 3052 | } |
| 3053 | break; |
| 3054 | } |
| 3055 | case 'u': |
| 3056 | { |
| 3057 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3058 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 3059 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 3060 | &draw_info->undercolor,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3061 | break; |
| 3062 | } |
| 3063 | if (LocaleCompare("unique",option+1) == 0) |
| 3064 | { |
| 3065 | if (*option == '+') |
| 3066 | { |
| 3067 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
| 3068 | break; |
| 3069 | } |
| 3070 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
| 3071 | (void) SetImageArtifact(*image,"verbose","true"); |
| 3072 | break; |
| 3073 | } |
| 3074 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3075 | { |
| 3076 | /* |
| 3077 | Unique image colors. |
| 3078 | */ |
| 3079 | (void) SyncImageSettings(mogrify_info,*image); |
| 3080 | mogrify_image=UniqueImageColors(*image,exception); |
| 3081 | break; |
| 3082 | } |
| 3083 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3084 | { |
| 3085 | /* |
| 3086 | Unsharp mask image. |
| 3087 | */ |
| 3088 | (void) SyncImageSettings(mogrify_info,*image); |
| 3089 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3090 | if ((flags & SigmaValue) == 0) |
| 3091 | geometry_info.sigma=1.0; |
| 3092 | if ((flags & XiValue) == 0) |
| 3093 | geometry_info.xi=1.0; |
| 3094 | if ((flags & PsiValue) == 0) |
| 3095 | geometry_info.psi=0.05; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3096 | mogrify_image=UnsharpMaskImage(*image,geometry_info.rho, |
| 3097 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3098 | break; |
| 3099 | } |
| 3100 | break; |
| 3101 | } |
| 3102 | case 'v': |
| 3103 | { |
| 3104 | if (LocaleCompare("verbose",option+1) == 0) |
| 3105 | { |
| 3106 | (void) SetImageArtifact(*image,option+1, |
| 3107 | *option == '+' ? "false" : "true"); |
| 3108 | break; |
| 3109 | } |
| 3110 | if (LocaleCompare("vignette",option+1) == 0) |
| 3111 | { |
| 3112 | /* |
| 3113 | Vignette image. |
| 3114 | */ |
| 3115 | (void) SyncImageSettings(mogrify_info,*image); |
| 3116 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3117 | if ((flags & SigmaValue) == 0) |
| 3118 | geometry_info.sigma=1.0; |
| 3119 | if ((flags & XiValue) == 0) |
| 3120 | geometry_info.xi=0.1*(*image)->columns; |
| 3121 | if ((flags & PsiValue) == 0) |
| 3122 | geometry_info.psi=0.1*(*image)->rows; |
| 3123 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
| 3124 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3125 | ceil(geometry_info.psi-0.5),exception); |
| 3126 | break; |
| 3127 | } |
| 3128 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3129 | { |
| 3130 | if (*option == '+') |
| 3131 | { |
| 3132 | (void) SetImageVirtualPixelMethod(*image, |
| 3133 | UndefinedVirtualPixelMethod); |
| 3134 | break; |
| 3135 | } |
| 3136 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3137 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 3138 | argv[i+1])); |
| 3139 | break; |
| 3140 | } |
| 3141 | break; |
| 3142 | } |
| 3143 | case 'w': |
| 3144 | { |
| 3145 | if (LocaleCompare("wave",option+1) == 0) |
| 3146 | { |
| 3147 | /* |
| 3148 | Wave image. |
| 3149 | */ |
| 3150 | (void) SyncImageSettings(mogrify_info,*image); |
| 3151 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3152 | if ((flags & SigmaValue) == 0) |
| 3153 | geometry_info.sigma=1.0; |
| 3154 | mogrify_image=WaveImage(*image,geometry_info.rho, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 3155 | geometry_info.sigma,interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3156 | break; |
| 3157 | } |
| 3158 | if (LocaleCompare("weight",option+1) == 0) |
| 3159 | { |
| 3160 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
| 3161 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3162 | draw_info->weight=0; |
| 3163 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3164 | draw_info->weight=700; |
| 3165 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3166 | if (draw_info->weight <= 800) |
| 3167 | draw_info->weight+=100; |
| 3168 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3169 | if (draw_info->weight >= 100) |
| 3170 | draw_info->weight-=100; |
| 3171 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3172 | draw_info->weight=400; |
| 3173 | break; |
| 3174 | } |
| 3175 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3176 | { |
| 3177 | /* |
| 3178 | White threshold image. |
| 3179 | */ |
| 3180 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3181 | (void) WhiteThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3182 | InheritException(exception,&(*image)->exception); |
| 3183 | break; |
| 3184 | } |
| 3185 | break; |
| 3186 | } |
| 3187 | default: |
| 3188 | break; |
| 3189 | } |
| 3190 | /* |
| 3191 | Replace current image with any image that was generated |
| 3192 | */ |
| 3193 | if (mogrify_image != (Image *) NULL) |
| 3194 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3195 | i+=count; |
| 3196 | } |
| 3197 | if (region_image != (Image *) NULL) |
| 3198 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3199 | /* |
| 3200 | Composite transformed region onto image. |
| 3201 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3202 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3203 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3204 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 3205 | region_geometry.x,region_geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3206 | InheritException(exception,®ion_image->exception); |
| 3207 | *image=DestroyImage(*image); |
| 3208 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3209 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3210 | } |
| 3211 | /* |
| 3212 | Free resources. |
| 3213 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3214 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3215 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3216 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 3217 | status=(MagickStatusType) ((*image)->exception.severity == |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 3218 | UndefinedException ? 1 : 0); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3219 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3220 | } |
| 3221 | |
| 3222 | /* |
| 3223 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3224 | % % |
| 3225 | % % |
| 3226 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3227 | + 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] | 3228 | % % |
| 3229 | % % |
| 3230 | % % |
| 3231 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3232 | % |
| 3233 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3234 | % transforms include image scaling, image rotation, color reduction, and |
| 3235 | % others. The transmogrified image overwrites the original image. |
| 3236 | % |
| 3237 | % The format of the MogrifyImageCommand method is: |
| 3238 | % |
| 3239 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3240 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3241 | % |
| 3242 | % A description of each parameter follows: |
| 3243 | % |
| 3244 | % o image_info: the image info. |
| 3245 | % |
| 3246 | % o argc: the number of elements in the argument vector. |
| 3247 | % |
| 3248 | % o argv: A text array containing the command line arguments. |
| 3249 | % |
| 3250 | % o metadata: any metadata is returned here. |
| 3251 | % |
| 3252 | % o exception: return any errors or warnings in this structure. |
| 3253 | % |
| 3254 | */ |
| 3255 | |
| 3256 | static MagickBooleanType MogrifyUsage(void) |
| 3257 | { |
| 3258 | static const char |
| 3259 | *miscellaneous[]= |
| 3260 | { |
| 3261 | "-debug events display copious debugging information", |
| 3262 | "-help print program options", |
| 3263 | "-list type print a list of supported option arguments", |
| 3264 | "-log format format of debugging information", |
| 3265 | "-version print version information", |
| 3266 | (char *) NULL |
| 3267 | }, |
| 3268 | *operators[]= |
| 3269 | { |
| 3270 | "-adaptive-blur geometry", |
| 3271 | " adaptively blur pixels; decrease effect near edges", |
| 3272 | "-adaptive-resize geometry", |
| 3273 | " adaptively resize image using 'mesh' interpolation", |
| 3274 | "-adaptive-sharpen geometry", |
| 3275 | " adaptively sharpen pixels; increase effect near edges", |
| 3276 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3277 | " transparent, extract, background, or shape", |
| 3278 | "-annotate geometry text", |
| 3279 | " annotate the image with text", |
| 3280 | "-auto-gamma automagically adjust gamma level of image", |
| 3281 | "-auto-level automagically adjust color levels of image", |
| 3282 | "-auto-orient automagically orient (rotate) image", |
| 3283 | "-bench iterations measure performance", |
| 3284 | "-black-threshold value", |
| 3285 | " force all pixels below the threshold into black", |
| 3286 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3287 | "-blur geometry reduce image noise and reduce detail levels", |
| 3288 | "-border geometry surround image with a border of color", |
| 3289 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3290 | "-brightness-contrast geometry", |
| 3291 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3292 | "-cdl filename color correct with a color decision list", |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 3293 | "-charcoal geometry simulate a charcoal drawing", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3294 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3295 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3296 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3297 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3298 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3299 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3300 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3301 | "-contrast enhance or reduce the image contrast", |
| 3302 | "-contrast-stretch geometry", |
| 3303 | " improve contrast by `stretching' the intensity range", |
| 3304 | "-convolve coefficients", |
| 3305 | " apply a convolution kernel to the image", |
| 3306 | "-cycle amount cycle the image colormap", |
| 3307 | "-decipher filename convert cipher pixels to plain pixels", |
| 3308 | "-deskew threshold straighten an image", |
| 3309 | "-despeckle reduce the speckles within an image", |
| 3310 | "-distort method args", |
| 3311 | " distort images according to given method ad args", |
| 3312 | "-draw string annotate the image with a graphic primitive", |
| 3313 | "-edge radius apply a filter to detect edges in the image", |
| 3314 | "-encipher filename convert plain pixels to cipher pixels", |
| 3315 | "-emboss radius emboss an image", |
| 3316 | "-enhance apply a digital filter to enhance a noisy image", |
| 3317 | "-equalize perform histogram equalization to an image", |
| 3318 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3319 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3320 | "-extent geometry set the image size", |
| 3321 | "-extract geometry extract area from image", |
| 3322 | "-fft implements the discrete Fourier transform (DFT)", |
| 3323 | "-flip flip image vertically", |
| 3324 | "-floodfill geometry color", |
| 3325 | " floodfill the image with color", |
| 3326 | "-flop flop image horizontally", |
| 3327 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3328 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3329 | " apply function over image values", |
| 3330 | "-gamma value level of gamma correction", |
| 3331 | "-gaussian-blur geometry", |
| 3332 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3333 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3334 | "-identify identify the format and characteristics of the image", |
| 3335 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3336 | "-implode amount implode image pixels about the center", |
| 3337 | "-lat geometry local adaptive thresholding", |
| 3338 | "-layers method optimize, merge, or compare image layers", |
| 3339 | "-level value adjust the level of image contrast", |
| 3340 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3341 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3342 | "-linear-stretch geometry", |
| 3343 | " improve contrast by `stretching with saturation'", |
| 3344 | "-liquid-rescale geometry", |
| 3345 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3346 | "-median geometry apply a median filter to the image", |
glennrp | 30d2dc6 | 2011-06-25 03:17:16 +0000 | [diff] [blame] | 3347 | "-mode geometry make each pixel the 'predominant color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3348 | "-modulate value vary the brightness, saturation, and hue", |
| 3349 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3350 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3351 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3352 | "-motion-blur geometry", |
| 3353 | " simulate motion blur", |
| 3354 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3355 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3356 | "-normalize transform image to span the full range of colors", |
| 3357 | "-opaque color change this color to the fill color", |
| 3358 | "-ordered-dither NxN", |
| 3359 | " add a noise pattern to the image with specific", |
| 3360 | " amplitudes", |
| 3361 | "-paint radius simulate an oil painting", |
| 3362 | "-polaroid angle simulate a Polaroid picture", |
| 3363 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3364 | "-profile filename add, delete, or apply an image profile", |
| 3365 | "-quantize colorspace reduce colors in this colorspace", |
| 3366 | "-radial-blur angle radial blur the image", |
| 3367 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3368 | "-random-threshold low,high", |
| 3369 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3370 | "-region geometry apply options to a portion of the image", |
| 3371 | "-render render vector graphics", |
| 3372 | "-repage geometry size and location of an image canvas", |
| 3373 | "-resample geometry change the resolution of an image", |
| 3374 | "-resize geometry resize the image", |
| 3375 | "-roll geometry roll an image vertically or horizontally", |
| 3376 | "-rotate degrees apply Paeth rotation to the image", |
| 3377 | "-sample geometry scale image with pixel sampling", |
| 3378 | "-scale geometry scale the image", |
| 3379 | "-segment values segment an image", |
| 3380 | "-selective-blur geometry", |
| 3381 | " selectively blur pixels within a contrast threshold", |
| 3382 | "-sepia-tone threshold", |
| 3383 | " simulate a sepia-toned photo", |
| 3384 | "-set property value set an image property", |
| 3385 | "-shade degrees shade the image using a distant light source", |
| 3386 | "-shadow geometry simulate an image shadow", |
| 3387 | "-sharpen geometry sharpen the image", |
| 3388 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3389 | "-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] | 3390 | "-sigmoidal-contrast geometry", |
| 3391 | " increase the contrast without saturating highlights or shadows", |
| 3392 | "-sketch geometry simulate a pencil sketch", |
| 3393 | "-solarize threshold negate all pixels above the threshold level", |
| 3394 | "-sparse-color method args", |
| 3395 | " fill in a image based on a few color points", |
| 3396 | "-splice geometry splice the background color into the image", |
| 3397 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3398 | "-statistic type radius", |
| 3399 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3400 | "-strip strip image of all profiles and comments", |
| 3401 | "-swirl degrees swirl image pixels about the center", |
| 3402 | "-threshold value threshold the image", |
| 3403 | "-thumbnail geometry create a thumbnail of the image", |
| 3404 | "-tile filename tile image when filling a graphic primitive", |
| 3405 | "-tint value tint the image with the fill color", |
| 3406 | "-transform affine transform image", |
| 3407 | "-transparent color make this color transparent within the image", |
| 3408 | "-transpose flip image vertically and rotate 90 degrees", |
| 3409 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3410 | "-trim trim image edges", |
| 3411 | "-type type image type", |
| 3412 | "-unique-colors discard all but one of any pixel color", |
| 3413 | "-unsharp geometry sharpen the image", |
| 3414 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3415 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3416 | "-white-threshold value", |
| 3417 | " force all pixels above the threshold into white", |
| 3418 | (char *) NULL |
| 3419 | }, |
| 3420 | *sequence_operators[]= |
| 3421 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3422 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3423 | "-clut apply a color lookup table to the image", |
| 3424 | "-coalesce merge a sequence of images", |
| 3425 | "-combine combine a sequence of images", |
| 3426 | "-composite composite image", |
| 3427 | "-crop geometry cut out a rectangular region of the image", |
| 3428 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3429 | "-evaluate-sequence operator", |
| 3430 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3431 | "-flatten flatten a sequence of images", |
| 3432 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3433 | "-hald-clut apply a Hald color lookup table to the image", |
| 3434 | "-morph value morph an image sequence", |
| 3435 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3436 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3437 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3438 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3439 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3440 | "-write filename write images to this file", |
| 3441 | (char *) NULL |
| 3442 | }, |
| 3443 | *settings[]= |
| 3444 | { |
| 3445 | "-adjoin join images into a single multi-image file", |
| 3446 | "-affine matrix affine transform matrix", |
| 3447 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3448 | "-antialias remove pixel-aliasing", |
| 3449 | "-authenticate password", |
| 3450 | " decipher image with this password", |
| 3451 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3452 | "-background color background color", |
| 3453 | "-bias value add bias when convolving an image", |
| 3454 | "-black-point-compensation", |
| 3455 | " use black point compensation", |
| 3456 | "-blue-primary point chromaticity blue primary point", |
| 3457 | "-bordercolor color border color", |
| 3458 | "-caption string assign a caption to an image", |
| 3459 | "-channel type apply option to select image channels", |
| 3460 | "-colors value preferred number of colors in the image", |
| 3461 | "-colorspace type alternate image colorspace", |
| 3462 | "-comment string annotate image with comment", |
| 3463 | "-compose operator set image composite operator", |
| 3464 | "-compress type type of pixel compression when writing the image", |
| 3465 | "-define format:option", |
| 3466 | " define one or more image format options", |
| 3467 | "-delay value display the next image after pausing", |
| 3468 | "-density geometry horizontal and vertical density of the image", |
| 3469 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3470 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3471 | "-display server get image or font from this X server", |
| 3472 | "-dispose method layer disposal method", |
| 3473 | "-dither method apply error diffusion to image", |
| 3474 | "-encoding type text encoding type", |
| 3475 | "-endian type endianness (MSB or LSB) of the image", |
| 3476 | "-family name render text with this font family", |
| 3477 | "-fill color color to use when filling a graphic primitive", |
| 3478 | "-filter type use this filter when resizing an image", |
| 3479 | "-font name render text with this font", |
| 3480 | "-format \"string\" output formatted image characteristics", |
| 3481 | "-fuzz distance colors within this distance are considered equal", |
| 3482 | "-gravity type horizontal and vertical text placement", |
| 3483 | "-green-primary point chromaticity green primary point", |
| 3484 | "-intent type type of rendering intent when managing the image color", |
| 3485 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3486 | "-interline-spacing value", |
| 3487 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3488 | "-interpolate method pixel color interpolation method", |
| 3489 | "-interword-spacing value", |
| 3490 | " set the space between two words", |
| 3491 | "-kerning value set the space between two letters", |
| 3492 | "-label string assign a label to an image", |
| 3493 | "-limit type value pixel cache resource limit", |
| 3494 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3495 | "-mask filename associate a mask with the image", |
| 3496 | "-mattecolor color frame color", |
| 3497 | "-monitor monitor progress", |
| 3498 | "-orient type image orientation", |
| 3499 | "-page geometry size and location of an image canvas (setting)", |
| 3500 | "-ping efficiently determine image attributes", |
| 3501 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3502 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3503 | "-preview type image preview type", |
| 3504 | "-quality value JPEG/MIFF/PNG compression level", |
| 3505 | "-quiet suppress all warning messages", |
| 3506 | "-red-primary point chromaticity red primary point", |
| 3507 | "-regard-warnings pay attention to warning messages", |
| 3508 | "-remap filename transform image colors to match this set of colors", |
| 3509 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3510 | "-sampling-factor geometry", |
| 3511 | " horizontal and vertical sampling factor", |
| 3512 | "-scene value image scene number", |
| 3513 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3514 | "-size geometry width and height of image", |
| 3515 | "-stretch type render text with this font stretch", |
| 3516 | "-stroke color graphic primitive stroke color", |
| 3517 | "-strokewidth value graphic primitive stroke width", |
| 3518 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3519 | "-synchronize synchronize image to storage device", |
| 3520 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3521 | "-texture filename name of texture to tile onto the image background", |
| 3522 | "-tile-offset geometry", |
| 3523 | " tile offset", |
| 3524 | "-treedepth value color tree depth", |
| 3525 | "-transparent-color color", |
| 3526 | " transparent color", |
| 3527 | "-undercolor color annotation bounding box color", |
| 3528 | "-units type the units of image resolution", |
| 3529 | "-verbose print detailed information about the image", |
| 3530 | "-view FlashPix viewing transforms", |
| 3531 | "-virtual-pixel method", |
| 3532 | " virtual pixel access method", |
| 3533 | "-weight type render text with this font weight", |
| 3534 | "-white-point point chromaticity white point", |
| 3535 | (char *) NULL |
| 3536 | }, |
| 3537 | *stack_operators[]= |
| 3538 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3539 | "-delete indexes delete the image from the image sequence", |
| 3540 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3541 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3542 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3543 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3544 | "-swap indexes swap two images in the image sequence", |
| 3545 | (char *) NULL |
| 3546 | }; |
| 3547 | |
| 3548 | const char |
| 3549 | **p; |
| 3550 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3551 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3552 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3553 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3554 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3555 | GetClientName()); |
| 3556 | (void) printf("\nImage Settings:\n"); |
| 3557 | for (p=settings; *p != (char *) NULL; p++) |
| 3558 | (void) printf(" %s\n",*p); |
| 3559 | (void) printf("\nImage Operators:\n"); |
| 3560 | for (p=operators; *p != (char *) NULL; p++) |
| 3561 | (void) printf(" %s\n",*p); |
| 3562 | (void) printf("\nImage Sequence Operators:\n"); |
| 3563 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3564 | (void) printf(" %s\n",*p); |
| 3565 | (void) printf("\nImage Stack Operators:\n"); |
| 3566 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3567 | (void) printf(" %s\n",*p); |
| 3568 | (void) printf("\nMiscellaneous Options:\n"); |
| 3569 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3570 | (void) printf(" %s\n",*p); |
| 3571 | (void) printf( |
| 3572 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3573 | (void) printf( |
| 3574 | "number. To specify a particular image format, precede the filename\n"); |
| 3575 | (void) printf( |
| 3576 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3577 | (void) printf( |
| 3578 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3579 | (void) printf("'-' for standard input or output.\n"); |
| 3580 | return(MagickFalse); |
| 3581 | } |
| 3582 | |
| 3583 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3584 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3585 | { |
| 3586 | #define DestroyMogrify() \ |
| 3587 | { \ |
| 3588 | if (format != (char *) NULL) \ |
| 3589 | format=DestroyString(format); \ |
| 3590 | if (path != (char *) NULL) \ |
| 3591 | path=DestroyString(path); \ |
| 3592 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3593 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3594 | argv[i]=DestroyString(argv[i]); \ |
| 3595 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3596 | } |
| 3597 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3598 | { \ |
| 3599 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3600 | option); \ |
| 3601 | DestroyMogrify(); \ |
| 3602 | return(MagickFalse); \ |
| 3603 | } |
| 3604 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3605 | { \ |
| 3606 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3607 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3608 | DestroyMogrify(); \ |
| 3609 | return(MagickFalse); \ |
| 3610 | } |
| 3611 | |
| 3612 | char |
| 3613 | *format, |
| 3614 | *option, |
| 3615 | *path; |
| 3616 | |
| 3617 | Image |
| 3618 | *image; |
| 3619 | |
| 3620 | ImageStack |
| 3621 | image_stack[MaxImageStackDepth+1]; |
| 3622 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3623 | MagickBooleanType |
| 3624 | global_colormap; |
| 3625 | |
| 3626 | MagickBooleanType |
| 3627 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3628 | pend, |
| 3629 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3630 | |
| 3631 | MagickStatusType |
| 3632 | status; |
| 3633 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3634 | register ssize_t |
| 3635 | i; |
| 3636 | |
| 3637 | ssize_t |
| 3638 | j, |
| 3639 | k; |
| 3640 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3641 | /* |
| 3642 | Set defaults. |
| 3643 | */ |
| 3644 | assert(image_info != (ImageInfo *) NULL); |
| 3645 | assert(image_info->signature == MagickSignature); |
| 3646 | if (image_info->debug != MagickFalse) |
| 3647 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3648 | assert(exception != (ExceptionInfo *) NULL); |
| 3649 | if (argc == 2) |
| 3650 | { |
| 3651 | option=argv[1]; |
| 3652 | if ((LocaleCompare("version",option+1) == 0) || |
| 3653 | (LocaleCompare("-version",option+1) == 0)) |
| 3654 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3655 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3656 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 3657 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 3658 | GetMagickCopyright()); |
| 3659 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 3660 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3661 | return(MagickFalse); |
| 3662 | } |
| 3663 | } |
| 3664 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3665 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3666 | format=(char *) NULL; |
| 3667 | path=(char *) NULL; |
| 3668 | global_colormap=MagickFalse; |
| 3669 | k=0; |
| 3670 | j=1; |
| 3671 | NewImageStack(); |
| 3672 | option=(char *) NULL; |
| 3673 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3674 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3675 | status=MagickTrue; |
| 3676 | /* |
| 3677 | Parse command line. |
| 3678 | */ |
| 3679 | ReadCommandlLine(argc,&argv); |
| 3680 | status=ExpandFilenames(&argc,&argv); |
| 3681 | if (status == MagickFalse) |
| 3682 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3683 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3684 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3685 | { |
| 3686 | option=argv[i]; |
| 3687 | if (LocaleCompare(option,"(") == 0) |
| 3688 | { |
| 3689 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3690 | if (k == MaxImageStackDepth) |
| 3691 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3692 | option); |
| 3693 | PushImageStack(); |
| 3694 | continue; |
| 3695 | } |
| 3696 | if (LocaleCompare(option,")") == 0) |
| 3697 | { |
| 3698 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3699 | if (k == 0) |
| 3700 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3701 | PopImageStack(); |
| 3702 | continue; |
| 3703 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3704 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3705 | { |
| 3706 | char |
| 3707 | backup_filename[MaxTextExtent], |
| 3708 | *filename; |
| 3709 | |
| 3710 | Image |
| 3711 | *images; |
| 3712 | |
| 3713 | /* |
| 3714 | Option is a file name: begin by reading image from specified file. |
| 3715 | */ |
| 3716 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3717 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3718 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3719 | filename=argv[++i]; |
| 3720 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 3721 | images=ReadImages(image_info,exception); |
| 3722 | status&=(images != (Image *) NULL) && |
| 3723 | (exception->severity < ErrorException); |
| 3724 | if (images == (Image *) NULL) |
| 3725 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3726 | if (format != (char *) NULL) |
| 3727 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3728 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3729 | if (path != (char *) NULL) |
| 3730 | { |
| 3731 | GetPathComponent(option,TailPath,filename); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3732 | (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3733 | path,*DirectorySeparator,filename); |
| 3734 | } |
| 3735 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3736 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3737 | AppendImageStack(images); |
| 3738 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3739 | if (global_colormap != MagickFalse) |
| 3740 | { |
| 3741 | QuantizeInfo |
| 3742 | *quantize_info; |
| 3743 | |
| 3744 | quantize_info=AcquireQuantizeInfo(image_info); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3745 | (void) RemapImages(quantize_info,images,(Image *) NULL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3746 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3747 | } |
| 3748 | *backup_filename='\0'; |
| 3749 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3750 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3751 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3752 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3753 | i; |
| 3754 | |
| 3755 | /* |
| 3756 | Rename image file as backup. |
| 3757 | */ |
| 3758 | (void) CopyMagickString(backup_filename,image->filename, |
| 3759 | MaxTextExtent); |
| 3760 | for (i=0; i < 6; i++) |
| 3761 | { |
| 3762 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3763 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3764 | break; |
| 3765 | } |
| 3766 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
cristy | 320684d | 2011-09-23 14:55:47 +0000 | [diff] [blame] | 3767 | (rename_utf8(image->filename,backup_filename) != 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3768 | *backup_filename='\0'; |
| 3769 | } |
| 3770 | /* |
| 3771 | Write transmogrified image to disk. |
| 3772 | */ |
| 3773 | image_info->synchronize=MagickTrue; |
| 3774 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3775 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 3776 | (void) remove_utf8(backup_filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3777 | RemoveAllImageStack(); |
| 3778 | continue; |
| 3779 | } |
| 3780 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3781 | switch (*(option+1)) |
| 3782 | { |
| 3783 | case 'a': |
| 3784 | { |
| 3785 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3786 | { |
| 3787 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3788 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3789 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3790 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3791 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3792 | break; |
| 3793 | } |
| 3794 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3795 | { |
| 3796 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3797 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3798 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3799 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3800 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3801 | break; |
| 3802 | } |
| 3803 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3804 | { |
| 3805 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3806 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3807 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3808 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3809 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3810 | break; |
| 3811 | } |
| 3812 | if (LocaleCompare("affine",option+1) == 0) |
| 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 | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3819 | break; |
| 3820 | } |
| 3821 | if (LocaleCompare("alpha",option+1) == 0) |
| 3822 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3823 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3824 | type; |
| 3825 | |
| 3826 | if (*option == '+') |
| 3827 | break; |
| 3828 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3829 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3830 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3831 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3832 | if (type < 0) |
| 3833 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3834 | argv[i]); |
| 3835 | break; |
| 3836 | } |
| 3837 | if (LocaleCompare("annotate",option+1) == 0) |
| 3838 | { |
| 3839 | if (*option == '+') |
| 3840 | break; |
| 3841 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3842 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3843 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3844 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3845 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3846 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3847 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3848 | i++; |
| 3849 | break; |
| 3850 | } |
| 3851 | if (LocaleCompare("antialias",option+1) == 0) |
| 3852 | break; |
| 3853 | if (LocaleCompare("append",option+1) == 0) |
| 3854 | break; |
| 3855 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3856 | { |
| 3857 | if (*option == '+') |
| 3858 | break; |
| 3859 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3860 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3861 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3862 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3863 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3864 | break; |
| 3865 | } |
| 3866 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3867 | { |
| 3868 | if (*option == '+') |
| 3869 | break; |
| 3870 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3871 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3872 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3873 | break; |
| 3874 | } |
| 3875 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3876 | break; |
| 3877 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3878 | break; |
| 3879 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3880 | break; |
| 3881 | if (LocaleCompare("average",option+1) == 0) |
| 3882 | break; |
| 3883 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3884 | } |
| 3885 | case 'b': |
| 3886 | { |
| 3887 | if (LocaleCompare("background",option+1) == 0) |
| 3888 | { |
| 3889 | if (*option == '+') |
| 3890 | break; |
| 3891 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3892 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3893 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3894 | break; |
| 3895 | } |
| 3896 | if (LocaleCompare("bias",option+1) == 0) |
| 3897 | { |
| 3898 | if (*option == '+') |
| 3899 | break; |
| 3900 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3901 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3902 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3903 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3904 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3905 | break; |
| 3906 | } |
| 3907 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 3908 | break; |
| 3909 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 3910 | { |
| 3911 | if (*option == '+') |
| 3912 | break; |
| 3913 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3914 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3915 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3916 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3917 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3918 | break; |
| 3919 | } |
| 3920 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3921 | { |
| 3922 | if (*option == '+') |
| 3923 | break; |
| 3924 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3925 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3926 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3927 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3928 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3929 | break; |
| 3930 | } |
| 3931 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3932 | { |
| 3933 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3934 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3935 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3936 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3937 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3938 | break; |
| 3939 | } |
| 3940 | if (LocaleCompare("blur",option+1) == 0) |
| 3941 | { |
| 3942 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3943 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3944 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3945 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3946 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3947 | break; |
| 3948 | } |
| 3949 | if (LocaleCompare("border",option+1) == 0) |
| 3950 | { |
| 3951 | if (*option == '+') |
| 3952 | break; |
| 3953 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3954 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3955 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3956 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3957 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3958 | break; |
| 3959 | } |
| 3960 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3961 | { |
| 3962 | if (*option == '+') |
| 3963 | break; |
| 3964 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3965 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3966 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3967 | break; |
| 3968 | } |
| 3969 | if (LocaleCompare("box",option+1) == 0) |
| 3970 | { |
| 3971 | if (*option == '+') |
| 3972 | break; |
| 3973 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3974 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3975 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3976 | break; |
| 3977 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3978 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 3979 | { |
| 3980 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3981 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3982 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3983 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3984 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3985 | break; |
| 3986 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3987 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3988 | } |
| 3989 | case 'c': |
| 3990 | { |
| 3991 | if (LocaleCompare("cache",option+1) == 0) |
| 3992 | { |
| 3993 | if (*option == '+') |
| 3994 | break; |
| 3995 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3996 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3997 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3998 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3999 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4000 | break; |
| 4001 | } |
| 4002 | if (LocaleCompare("caption",option+1) == 0) |
| 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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4008 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4009 | break; |
| 4010 | } |
| 4011 | if (LocaleCompare("channel",option+1) == 0) |
| 4012 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4013 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4014 | channel; |
| 4015 | |
| 4016 | if (*option == '+') |
| 4017 | break; |
| 4018 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4019 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4020 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4021 | channel=ParseChannelOption(argv[i]); |
| 4022 | if (channel < 0) |
| 4023 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 4024 | argv[i]); |
| 4025 | break; |
| 4026 | } |
| 4027 | if (LocaleCompare("cdl",option+1) == 0) |
| 4028 | { |
| 4029 | if (*option == '+') |
| 4030 | break; |
| 4031 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4032 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4033 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4034 | break; |
| 4035 | } |
| 4036 | if (LocaleCompare("charcoal",option+1) == 0) |
| 4037 | { |
| 4038 | if (*option == '+') |
| 4039 | break; |
| 4040 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4041 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4042 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4043 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4044 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4045 | break; |
| 4046 | } |
| 4047 | if (LocaleCompare("chop",option+1) == 0) |
| 4048 | { |
| 4049 | if (*option == '+') |
| 4050 | break; |
| 4051 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4052 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4053 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4054 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4055 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4056 | break; |
| 4057 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4058 | if (LocaleCompare("clamp",option+1) == 0) |
| 4059 | break; |
| 4060 | if (LocaleCompare("clip",option+1) == 0) |
| 4061 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4062 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4063 | { |
| 4064 | if (*option == '+') |
| 4065 | break; |
| 4066 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4067 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4068 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4069 | break; |
| 4070 | } |
| 4071 | if (LocaleCompare("clut",option+1) == 0) |
| 4072 | break; |
| 4073 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4074 | break; |
| 4075 | if (LocaleCompare("colorize",option+1) == 0) |
| 4076 | { |
| 4077 | if (*option == '+') |
| 4078 | break; |
| 4079 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4080 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4081 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4082 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4083 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4084 | break; |
| 4085 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4086 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4087 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4088 | KernelInfo |
| 4089 | *kernel_info; |
| 4090 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4091 | if (*option == '+') |
| 4092 | break; |
| 4093 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4094 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4095 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4096 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4097 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4098 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4099 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4100 | break; |
| 4101 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4102 | if (LocaleCompare("colors",option+1) == 0) |
| 4103 | { |
| 4104 | if (*option == '+') |
| 4105 | break; |
| 4106 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4107 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4108 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4109 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4110 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4111 | break; |
| 4112 | } |
| 4113 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4114 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4115 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4116 | colorspace; |
| 4117 | |
| 4118 | if (*option == '+') |
| 4119 | break; |
| 4120 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4121 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4122 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4123 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4124 | argv[i]); |
| 4125 | if (colorspace < 0) |
| 4126 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4127 | argv[i]); |
| 4128 | break; |
| 4129 | } |
| 4130 | if (LocaleCompare("combine",option+1) == 0) |
| 4131 | break; |
| 4132 | if (LocaleCompare("comment",option+1) == 0) |
| 4133 | { |
| 4134 | if (*option == '+') |
| 4135 | break; |
| 4136 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4137 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4138 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4139 | break; |
| 4140 | } |
| 4141 | if (LocaleCompare("composite",option+1) == 0) |
| 4142 | break; |
| 4143 | if (LocaleCompare("compress",option+1) == 0) |
| 4144 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4145 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4146 | compress; |
| 4147 | |
| 4148 | if (*option == '+') |
| 4149 | break; |
| 4150 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4151 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4152 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4153 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4154 | argv[i]); |
| 4155 | if (compress < 0) |
| 4156 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4157 | argv[i]); |
| 4158 | break; |
| 4159 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4160 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4161 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4162 | if (LocaleCompare("contrast",option+1) == 0) |
| 4163 | break; |
| 4164 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4165 | { |
| 4166 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4167 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4168 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4169 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4170 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4171 | break; |
| 4172 | } |
| 4173 | if (LocaleCompare("convolve",option+1) == 0) |
| 4174 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4175 | KernelInfo |
| 4176 | *kernel_info; |
| 4177 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4178 | if (*option == '+') |
| 4179 | break; |
| 4180 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4181 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4182 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4183 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4184 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4185 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4186 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4187 | break; |
| 4188 | } |
| 4189 | if (LocaleCompare("crop",option+1) == 0) |
| 4190 | { |
| 4191 | if (*option == '+') |
| 4192 | break; |
| 4193 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4194 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4195 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4196 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4197 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4198 | break; |
| 4199 | } |
| 4200 | if (LocaleCompare("cycle",option+1) == 0) |
| 4201 | { |
| 4202 | if (*option == '+') |
| 4203 | break; |
| 4204 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4205 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4206 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4207 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4208 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4209 | break; |
| 4210 | } |
| 4211 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4212 | } |
| 4213 | case 'd': |
| 4214 | { |
| 4215 | if (LocaleCompare("decipher",option+1) == 0) |
| 4216 | { |
| 4217 | if (*option == '+') |
| 4218 | break; |
| 4219 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4220 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4221 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4222 | break; |
| 4223 | } |
| 4224 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4225 | break; |
| 4226 | if (LocaleCompare("debug",option+1) == 0) |
| 4227 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4228 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4229 | event; |
| 4230 | |
| 4231 | if (*option == '+') |
| 4232 | break; |
| 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); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4236 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4237 | if (event < 0) |
| 4238 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4239 | argv[i]); |
| 4240 | (void) SetLogEventMask(argv[i]); |
| 4241 | break; |
| 4242 | } |
| 4243 | if (LocaleCompare("define",option+1) == 0) |
| 4244 | { |
| 4245 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4246 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4247 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4248 | if (*option == '+') |
| 4249 | { |
| 4250 | const char |
| 4251 | *define; |
| 4252 | |
| 4253 | define=GetImageOption(image_info,argv[i]); |
| 4254 | if (define == (const char *) NULL) |
| 4255 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4256 | break; |
| 4257 | } |
| 4258 | break; |
| 4259 | } |
| 4260 | if (LocaleCompare("delay",option+1) == 0) |
| 4261 | { |
| 4262 | if (*option == '+') |
| 4263 | break; |
| 4264 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4265 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4266 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4267 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4268 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4269 | break; |
| 4270 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4271 | if (LocaleCompare("delete",option+1) == 0) |
| 4272 | { |
| 4273 | if (*option == '+') |
| 4274 | break; |
| 4275 | i++; |
| 4276 | if (i == (ssize_t) (argc-1)) |
| 4277 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4278 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4279 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4280 | break; |
| 4281 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4282 | if (LocaleCompare("density",option+1) == 0) |
| 4283 | { |
| 4284 | if (*option == '+') |
| 4285 | break; |
| 4286 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4287 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4288 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4289 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4290 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4291 | break; |
| 4292 | } |
| 4293 | if (LocaleCompare("depth",option+1) == 0) |
| 4294 | { |
| 4295 | if (*option == '+') |
| 4296 | break; |
| 4297 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4298 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4299 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4300 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4301 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4302 | break; |
| 4303 | } |
| 4304 | if (LocaleCompare("deskew",option+1) == 0) |
| 4305 | { |
| 4306 | if (*option == '+') |
| 4307 | break; |
| 4308 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4309 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4310 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4311 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4312 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4313 | break; |
| 4314 | } |
| 4315 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4316 | break; |
| 4317 | if (LocaleCompare("dft",option+1) == 0) |
| 4318 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4319 | if (LocaleCompare("direction",option+1) == 0) |
| 4320 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4321 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4322 | direction; |
| 4323 | |
| 4324 | if (*option == '+') |
| 4325 | break; |
| 4326 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4327 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4328 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4329 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4330 | argv[i]); |
| 4331 | if (direction < 0) |
| 4332 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4333 | argv[i]); |
| 4334 | break; |
| 4335 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4336 | if (LocaleCompare("display",option+1) == 0) |
| 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); |
| 4343 | break; |
| 4344 | } |
| 4345 | if (LocaleCompare("dispose",option+1) == 0) |
| 4346 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4347 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4348 | dispose; |
| 4349 | |
| 4350 | if (*option == '+') |
| 4351 | break; |
| 4352 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4353 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4354 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4355 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4356 | if (dispose < 0) |
| 4357 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4358 | argv[i]); |
| 4359 | break; |
| 4360 | } |
| 4361 | if (LocaleCompare("distort",option+1) == 0) |
| 4362 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4363 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4364 | op; |
| 4365 | |
| 4366 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4367 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4368 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4369 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4370 | if (op < 0) |
| 4371 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4372 | argv[i]); |
| 4373 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4374 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4375 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4376 | break; |
| 4377 | } |
| 4378 | if (LocaleCompare("dither",option+1) == 0) |
| 4379 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4380 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4381 | method; |
| 4382 | |
| 4383 | if (*option == '+') |
| 4384 | break; |
| 4385 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4386 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4387 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4388 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4389 | if (method < 0) |
| 4390 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4391 | argv[i]); |
| 4392 | break; |
| 4393 | } |
| 4394 | if (LocaleCompare("draw",option+1) == 0) |
| 4395 | { |
| 4396 | if (*option == '+') |
| 4397 | break; |
| 4398 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4399 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4400 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4401 | break; |
| 4402 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4403 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4404 | { |
| 4405 | if (*option == '+') |
| 4406 | break; |
| 4407 | i++; |
| 4408 | if (i == (ssize_t) (argc-1)) |
| 4409 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4410 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4411 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4412 | break; |
| 4413 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4414 | if (LocaleCompare("duration",option+1) == 0) |
| 4415 | { |
| 4416 | if (*option == '+') |
| 4417 | break; |
| 4418 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4419 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4420 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4421 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4422 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4423 | break; |
| 4424 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4425 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4426 | } |
| 4427 | case 'e': |
| 4428 | { |
| 4429 | if (LocaleCompare("edge",option+1) == 0) |
| 4430 | { |
| 4431 | if (*option == '+') |
| 4432 | break; |
| 4433 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4434 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4435 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4436 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4437 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4438 | break; |
| 4439 | } |
| 4440 | if (LocaleCompare("emboss",option+1) == 0) |
| 4441 | { |
| 4442 | if (*option == '+') |
| 4443 | break; |
| 4444 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4445 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4446 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4447 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4448 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4449 | break; |
| 4450 | } |
| 4451 | if (LocaleCompare("encipher",option+1) == 0) |
| 4452 | { |
| 4453 | if (*option == '+') |
| 4454 | break; |
| 4455 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4456 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4457 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4458 | break; |
| 4459 | } |
| 4460 | if (LocaleCompare("encoding",option+1) == 0) |
| 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); |
| 4467 | break; |
| 4468 | } |
| 4469 | if (LocaleCompare("endian",option+1) == 0) |
| 4470 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4471 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4472 | endian; |
| 4473 | |
| 4474 | if (*option == '+') |
| 4475 | break; |
| 4476 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4477 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4478 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4479 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4480 | if (endian < 0) |
| 4481 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4482 | argv[i]); |
| 4483 | break; |
| 4484 | } |
| 4485 | if (LocaleCompare("enhance",option+1) == 0) |
| 4486 | break; |
| 4487 | if (LocaleCompare("equalize",option+1) == 0) |
| 4488 | break; |
| 4489 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4490 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4491 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4492 | op; |
| 4493 | |
| 4494 | if (*option == '+') |
| 4495 | break; |
| 4496 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4497 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4498 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4499 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4500 | if (op < 0) |
| 4501 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4502 | argv[i]); |
| 4503 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4504 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4505 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4506 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4507 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4508 | break; |
| 4509 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4510 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4511 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4512 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4513 | op; |
| 4514 | |
| 4515 | if (*option == '+') |
| 4516 | break; |
| 4517 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4518 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4519 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4520 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4521 | if (op < 0) |
| 4522 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4523 | argv[i]); |
| 4524 | break; |
| 4525 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4526 | if (LocaleCompare("extent",option+1) == 0) |
| 4527 | { |
| 4528 | if (*option == '+') |
| 4529 | break; |
| 4530 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4531 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4532 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4533 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4534 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4535 | break; |
| 4536 | } |
| 4537 | if (LocaleCompare("extract",option+1) == 0) |
| 4538 | { |
| 4539 | if (*option == '+') |
| 4540 | break; |
| 4541 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4542 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4543 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4544 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4545 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4546 | break; |
| 4547 | } |
| 4548 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4549 | } |
| 4550 | case 'f': |
| 4551 | { |
| 4552 | if (LocaleCompare("family",option+1) == 0) |
| 4553 | { |
| 4554 | if (*option == '+') |
| 4555 | break; |
| 4556 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4557 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4558 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4559 | break; |
| 4560 | } |
| 4561 | if (LocaleCompare("fill",option+1) == 0) |
| 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); |
| 4568 | break; |
| 4569 | } |
| 4570 | if (LocaleCompare("filter",option+1) == 0) |
| 4571 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4572 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4573 | filter; |
| 4574 | |
| 4575 | if (*option == '+') |
| 4576 | break; |
| 4577 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4578 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4579 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4580 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4581 | if (filter < 0) |
| 4582 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4583 | argv[i]); |
| 4584 | break; |
| 4585 | } |
| 4586 | if (LocaleCompare("flatten",option+1) == 0) |
| 4587 | break; |
| 4588 | if (LocaleCompare("flip",option+1) == 0) |
| 4589 | break; |
| 4590 | if (LocaleCompare("flop",option+1) == 0) |
| 4591 | break; |
| 4592 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4593 | { |
| 4594 | if (*option == '+') |
| 4595 | break; |
| 4596 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4597 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4598 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4599 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4600 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4601 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4602 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4603 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4604 | break; |
| 4605 | } |
| 4606 | if (LocaleCompare("font",option+1) == 0) |
| 4607 | { |
| 4608 | if (*option == '+') |
| 4609 | break; |
| 4610 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4611 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4612 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4613 | break; |
| 4614 | } |
| 4615 | if (LocaleCompare("format",option+1) == 0) |
| 4616 | { |
| 4617 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4618 | (void) CloneString(&format,(char *) NULL); |
| 4619 | if (*option == '+') |
| 4620 | break; |
| 4621 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4622 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4623 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4624 | (void) CloneString(&format,argv[i]); |
| 4625 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4626 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4627 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4628 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4629 | if (*image_info->magick == '\0') |
| 4630 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4631 | format); |
| 4632 | break; |
| 4633 | } |
| 4634 | if (LocaleCompare("frame",option+1) == 0) |
| 4635 | { |
| 4636 | if (*option == '+') |
| 4637 | break; |
| 4638 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4639 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4640 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4641 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4642 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4643 | break; |
| 4644 | } |
| 4645 | if (LocaleCompare("function",option+1) == 0) |
| 4646 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4647 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4648 | op; |
| 4649 | |
| 4650 | if (*option == '+') |
| 4651 | break; |
| 4652 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4653 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4654 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4655 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4656 | if (op < 0) |
| 4657 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4658 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4659 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4660 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4661 | break; |
| 4662 | } |
| 4663 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4664 | { |
| 4665 | if (*option == '+') |
| 4666 | break; |
| 4667 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4668 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4669 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4670 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4671 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4672 | break; |
| 4673 | } |
| 4674 | if (LocaleCompare("fx",option+1) == 0) |
| 4675 | { |
| 4676 | if (*option == '+') |
| 4677 | break; |
| 4678 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4679 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4680 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4681 | break; |
| 4682 | } |
| 4683 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4684 | } |
| 4685 | case 'g': |
| 4686 | { |
| 4687 | if (LocaleCompare("gamma",option+1) == 0) |
| 4688 | { |
| 4689 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4690 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4691 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4692 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4693 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4694 | break; |
| 4695 | } |
| 4696 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4697 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4698 | { |
| 4699 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4700 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4701 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4702 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4703 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4704 | break; |
| 4705 | } |
| 4706 | if (LocaleCompare("geometry",option+1) == 0) |
| 4707 | { |
| 4708 | if (*option == '+') |
| 4709 | break; |
| 4710 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4711 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4712 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4713 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4714 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4715 | break; |
| 4716 | } |
| 4717 | if (LocaleCompare("gravity",option+1) == 0) |
| 4718 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4719 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4720 | gravity; |
| 4721 | |
| 4722 | if (*option == '+') |
| 4723 | break; |
| 4724 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4725 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4726 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4727 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4728 | if (gravity < 0) |
| 4729 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4730 | argv[i]); |
| 4731 | break; |
| 4732 | } |
| 4733 | if (LocaleCompare("green-primary",option+1) == 0) |
| 4734 | { |
| 4735 | if (*option == '+') |
| 4736 | break; |
| 4737 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4738 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4739 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4740 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4741 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4742 | break; |
| 4743 | } |
| 4744 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4745 | } |
| 4746 | case 'h': |
| 4747 | { |
| 4748 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4749 | break; |
| 4750 | if ((LocaleCompare("help",option+1) == 0) || |
| 4751 | (LocaleCompare("-help",option+1) == 0)) |
| 4752 | return(MogrifyUsage()); |
| 4753 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4754 | } |
| 4755 | case 'i': |
| 4756 | { |
| 4757 | if (LocaleCompare("identify",option+1) == 0) |
| 4758 | break; |
| 4759 | if (LocaleCompare("idft",option+1) == 0) |
| 4760 | break; |
| 4761 | if (LocaleCompare("implode",option+1) == 0) |
| 4762 | { |
| 4763 | if (*option == '+') |
| 4764 | break; |
| 4765 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4766 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4767 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4768 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4769 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4770 | break; |
| 4771 | } |
| 4772 | if (LocaleCompare("intent",option+1) == 0) |
| 4773 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4774 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4775 | intent; |
| 4776 | |
| 4777 | if (*option == '+') |
| 4778 | break; |
| 4779 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4780 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4781 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4782 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4783 | if (intent < 0) |
| 4784 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4785 | argv[i]); |
| 4786 | break; |
| 4787 | } |
| 4788 | if (LocaleCompare("interlace",option+1) == 0) |
| 4789 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4790 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4791 | interlace; |
| 4792 | |
| 4793 | if (*option == '+') |
| 4794 | break; |
| 4795 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4796 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4797 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4798 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4799 | argv[i]); |
| 4800 | if (interlace < 0) |
| 4801 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4802 | argv[i]); |
| 4803 | break; |
| 4804 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4805 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4806 | { |
| 4807 | if (*option == '+') |
| 4808 | break; |
| 4809 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4810 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4811 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4812 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4813 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4814 | break; |
| 4815 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4816 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4817 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4818 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4819 | interpolate; |
| 4820 | |
| 4821 | if (*option == '+') |
| 4822 | break; |
| 4823 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4824 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4825 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4826 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4827 | argv[i]); |
| 4828 | if (interpolate < 0) |
| 4829 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4830 | argv[i]); |
| 4831 | break; |
| 4832 | } |
| 4833 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4834 | { |
| 4835 | if (*option == '+') |
| 4836 | break; |
| 4837 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4838 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4839 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4840 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4841 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4842 | break; |
| 4843 | } |
| 4844 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4845 | } |
| 4846 | case 'k': |
| 4847 | { |
| 4848 | if (LocaleCompare("kerning",option+1) == 0) |
| 4849 | { |
| 4850 | if (*option == '+') |
| 4851 | break; |
| 4852 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4853 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4854 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4855 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4856 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4857 | break; |
| 4858 | } |
| 4859 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4860 | } |
| 4861 | case 'l': |
| 4862 | { |
| 4863 | if (LocaleCompare("label",option+1) == 0) |
| 4864 | { |
| 4865 | if (*option == '+') |
| 4866 | break; |
| 4867 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4868 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4869 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4870 | break; |
| 4871 | } |
| 4872 | if (LocaleCompare("lat",option+1) == 0) |
| 4873 | { |
| 4874 | if (*option == '+') |
| 4875 | break; |
| 4876 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4877 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4878 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4879 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4880 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4881 | } |
| 4882 | if (LocaleCompare("layers",option+1) == 0) |
| 4883 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4884 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4885 | type; |
| 4886 | |
| 4887 | if (*option == '+') |
| 4888 | break; |
| 4889 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4890 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4891 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4892 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4893 | if (type < 0) |
| 4894 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4895 | argv[i]); |
| 4896 | break; |
| 4897 | } |
| 4898 | if (LocaleCompare("level",option+1) == 0) |
| 4899 | { |
| 4900 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4901 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4902 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4903 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4904 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4905 | break; |
| 4906 | } |
| 4907 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4908 | { |
| 4909 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4910 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4911 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4912 | break; |
| 4913 | } |
| 4914 | if (LocaleCompare("linewidth",option+1) == 0) |
| 4915 | { |
| 4916 | if (*option == '+') |
| 4917 | break; |
| 4918 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4919 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4920 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4921 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4922 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4923 | break; |
| 4924 | } |
| 4925 | if (LocaleCompare("limit",option+1) == 0) |
| 4926 | { |
| 4927 | char |
| 4928 | *p; |
| 4929 | |
| 4930 | double |
| 4931 | value; |
| 4932 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4933 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4934 | resource; |
| 4935 | |
| 4936 | if (*option == '+') |
| 4937 | break; |
| 4938 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4939 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4940 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4941 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4942 | argv[i]); |
| 4943 | if (resource < 0) |
| 4944 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4945 | argv[i]); |
| 4946 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4947 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4948 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 4949 | value=InterpretLocaleValue(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4950 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4951 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4952 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4953 | break; |
| 4954 | } |
| 4955 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4956 | { |
| 4957 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4958 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4959 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4960 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4961 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4962 | break; |
| 4963 | } |
| 4964 | if (LocaleCompare("list",option+1) == 0) |
| 4965 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4966 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4967 | list; |
| 4968 | |
| 4969 | if (*option == '+') |
| 4970 | break; |
| 4971 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4972 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4973 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4974 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4975 | if (list < 0) |
| 4976 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4977 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4978 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4979 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4980 | } |
| 4981 | if (LocaleCompare("log",option+1) == 0) |
| 4982 | { |
| 4983 | if (*option == '+') |
| 4984 | break; |
| 4985 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4986 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4987 | (strchr(argv[i],'%') == (char *) NULL)) |
| 4988 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4989 | break; |
| 4990 | } |
| 4991 | if (LocaleCompare("loop",option+1) == 0) |
| 4992 | { |
| 4993 | if (*option == '+') |
| 4994 | break; |
| 4995 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4996 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4997 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4998 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4999 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5000 | break; |
| 5001 | } |
| 5002 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5003 | } |
| 5004 | case 'm': |
| 5005 | { |
| 5006 | if (LocaleCompare("map",option+1) == 0) |
| 5007 | { |
| 5008 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 5009 | if (*option == '+') |
| 5010 | break; |
| 5011 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5012 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5013 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5014 | break; |
| 5015 | } |
| 5016 | if (LocaleCompare("mask",option+1) == 0) |
| 5017 | { |
| 5018 | if (*option == '+') |
| 5019 | break; |
| 5020 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5021 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5022 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5023 | break; |
| 5024 | } |
| 5025 | if (LocaleCompare("matte",option+1) == 0) |
| 5026 | break; |
| 5027 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 5028 | { |
| 5029 | if (*option == '+') |
| 5030 | break; |
| 5031 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5032 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5033 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5034 | break; |
| 5035 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5036 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5037 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5038 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5039 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5040 | if (LocaleCompare("modulate",option+1) == 0) |
| 5041 | { |
| 5042 | if (*option == '+') |
| 5043 | break; |
| 5044 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5045 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5046 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5047 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5048 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5049 | break; |
| 5050 | } |
| 5051 | if (LocaleCompare("median",option+1) == 0) |
| 5052 | { |
| 5053 | if (*option == '+') |
| 5054 | break; |
| 5055 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5056 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5057 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5058 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5059 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5060 | break; |
| 5061 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5062 | if (LocaleCompare("mode",option+1) == 0) |
| 5063 | { |
| 5064 | if (*option == '+') |
| 5065 | break; |
| 5066 | i++; |
| 5067 | if (i == (ssize_t) argc) |
| 5068 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5069 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5070 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5071 | break; |
| 5072 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5073 | if (LocaleCompare("monitor",option+1) == 0) |
| 5074 | break; |
| 5075 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5076 | break; |
| 5077 | if (LocaleCompare("morph",option+1) == 0) |
| 5078 | { |
| 5079 | if (*option == '+') |
| 5080 | break; |
| 5081 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5082 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5083 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5084 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5085 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5086 | break; |
| 5087 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5088 | if (LocaleCompare("morphology",option+1) == 0) |
| 5089 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5090 | char |
| 5091 | token[MaxTextExtent]; |
| 5092 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5093 | KernelInfo |
| 5094 | *kernel_info; |
| 5095 | |
| 5096 | ssize_t |
| 5097 | op; |
| 5098 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5099 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5100 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5101 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5102 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5103 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5104 | if (op < 0) |
| 5105 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5106 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5107 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5108 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5109 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5110 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5111 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5112 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5113 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5114 | break; |
| 5115 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5116 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5117 | break; |
| 5118 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5119 | { |
| 5120 | if (*option == '+') |
| 5121 | break; |
| 5122 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5123 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5124 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5125 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5126 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5127 | break; |
| 5128 | } |
| 5129 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5130 | } |
| 5131 | case 'n': |
| 5132 | { |
| 5133 | if (LocaleCompare("negate",option+1) == 0) |
| 5134 | break; |
| 5135 | if (LocaleCompare("noise",option+1) == 0) |
| 5136 | { |
| 5137 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5138 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5139 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5140 | if (*option == '+') |
| 5141 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5142 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5143 | noise; |
| 5144 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5145 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5146 | if (noise < 0) |
| 5147 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5148 | argv[i]); |
| 5149 | break; |
| 5150 | } |
| 5151 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5152 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5153 | break; |
| 5154 | } |
| 5155 | if (LocaleCompare("noop",option+1) == 0) |
| 5156 | break; |
| 5157 | if (LocaleCompare("normalize",option+1) == 0) |
| 5158 | break; |
| 5159 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5160 | } |
| 5161 | case 'o': |
| 5162 | { |
| 5163 | if (LocaleCompare("opaque",option+1) == 0) |
| 5164 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5165 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5166 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5167 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5168 | break; |
| 5169 | } |
| 5170 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5171 | { |
| 5172 | if (*option == '+') |
| 5173 | break; |
| 5174 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5175 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5176 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5177 | break; |
| 5178 | } |
| 5179 | if (LocaleCompare("orient",option+1) == 0) |
| 5180 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5181 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5182 | orientation; |
| 5183 | |
| 5184 | orientation=UndefinedOrientation; |
| 5185 | if (*option == '+') |
| 5186 | break; |
| 5187 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5188 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5189 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5190 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5191 | argv[i]); |
| 5192 | if (orientation < 0) |
| 5193 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5194 | argv[i]); |
| 5195 | break; |
| 5196 | } |
| 5197 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5198 | } |
| 5199 | case 'p': |
| 5200 | { |
| 5201 | if (LocaleCompare("page",option+1) == 0) |
| 5202 | { |
| 5203 | if (*option == '+') |
| 5204 | break; |
| 5205 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5206 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5207 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5208 | break; |
| 5209 | } |
| 5210 | if (LocaleCompare("paint",option+1) == 0) |
| 5211 | { |
| 5212 | if (*option == '+') |
| 5213 | break; |
| 5214 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5215 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5216 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5217 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5218 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5219 | break; |
| 5220 | } |
| 5221 | if (LocaleCompare("path",option+1) == 0) |
| 5222 | { |
| 5223 | (void) CloneString(&path,(char *) NULL); |
| 5224 | if (*option == '+') |
| 5225 | break; |
| 5226 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5227 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5228 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5229 | (void) CloneString(&path,argv[i]); |
| 5230 | break; |
| 5231 | } |
| 5232 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5233 | { |
| 5234 | if (*option == '+') |
| 5235 | break; |
| 5236 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5237 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5238 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5239 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5240 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5241 | break; |
| 5242 | } |
| 5243 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5244 | { |
| 5245 | if (*option == '+') |
| 5246 | break; |
| 5247 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5248 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5249 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5250 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5251 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5252 | break; |
| 5253 | } |
| 5254 | if (LocaleCompare("posterize",option+1) == 0) |
| 5255 | { |
| 5256 | if (*option == '+') |
| 5257 | break; |
| 5258 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5259 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5260 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5261 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5262 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5263 | break; |
| 5264 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5265 | if (LocaleCompare("precision",option+1) == 0) |
| 5266 | { |
| 5267 | if (*option == '+') |
| 5268 | break; |
| 5269 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5270 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5271 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5272 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5273 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5274 | break; |
| 5275 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5276 | if (LocaleCompare("print",option+1) == 0) |
| 5277 | { |
| 5278 | if (*option == '+') |
| 5279 | break; |
| 5280 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5281 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5282 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5283 | break; |
| 5284 | } |
| 5285 | if (LocaleCompare("process",option+1) == 0) |
| 5286 | { |
| 5287 | if (*option == '+') |
| 5288 | break; |
| 5289 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5290 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5291 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5292 | break; |
| 5293 | } |
| 5294 | if (LocaleCompare("profile",option+1) == 0) |
| 5295 | { |
| 5296 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5297 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5298 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5299 | break; |
| 5300 | } |
| 5301 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5302 | } |
| 5303 | case 'q': |
| 5304 | { |
| 5305 | if (LocaleCompare("quality",option+1) == 0) |
| 5306 | { |
| 5307 | if (*option == '+') |
| 5308 | break; |
| 5309 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5310 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5311 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5312 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5313 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5314 | break; |
| 5315 | } |
| 5316 | if (LocaleCompare("quantize",option+1) == 0) |
| 5317 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5318 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5319 | colorspace; |
| 5320 | |
| 5321 | if (*option == '+') |
| 5322 | break; |
| 5323 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5324 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5325 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5326 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5327 | argv[i]); |
| 5328 | if (colorspace < 0) |
| 5329 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5330 | argv[i]); |
| 5331 | break; |
| 5332 | } |
| 5333 | if (LocaleCompare("quiet",option+1) == 0) |
| 5334 | break; |
| 5335 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5336 | } |
| 5337 | case 'r': |
| 5338 | { |
| 5339 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5340 | { |
| 5341 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5342 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5343 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5344 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5345 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5346 | break; |
| 5347 | } |
| 5348 | if (LocaleCompare("raise",option+1) == 0) |
| 5349 | { |
| 5350 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5351 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5352 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5353 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5354 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5355 | break; |
| 5356 | } |
| 5357 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5358 | { |
| 5359 | if (*option == '+') |
| 5360 | break; |
| 5361 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5362 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5363 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5364 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5365 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5366 | break; |
| 5367 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5368 | if (LocaleCompare("recolor",option+1) == 0) |
| 5369 | { |
| 5370 | if (*option == '+') |
| 5371 | break; |
| 5372 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5373 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5374 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5375 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5376 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5377 | break; |
| 5378 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5379 | if (LocaleCompare("red-primary",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 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5389 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5390 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5391 | if (LocaleCompare("region",option+1) == 0) |
| 5392 | { |
| 5393 | if (*option == '+') |
| 5394 | break; |
| 5395 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5396 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5397 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5398 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5399 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5400 | break; |
| 5401 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5402 | if (LocaleCompare("remap",option+1) == 0) |
| 5403 | { |
| 5404 | if (*option == '+') |
| 5405 | break; |
| 5406 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5407 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5408 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5409 | break; |
| 5410 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5411 | if (LocaleCompare("render",option+1) == 0) |
| 5412 | break; |
| 5413 | if (LocaleCompare("repage",option+1) == 0) |
| 5414 | { |
| 5415 | if (*option == '+') |
| 5416 | break; |
| 5417 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5418 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5419 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5420 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5421 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5422 | break; |
| 5423 | } |
| 5424 | if (LocaleCompare("resample",option+1) == 0) |
| 5425 | { |
| 5426 | if (*option == '+') |
| 5427 | break; |
| 5428 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5429 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5430 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5431 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5432 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5433 | break; |
| 5434 | } |
| 5435 | if (LocaleCompare("resize",option+1) == 0) |
| 5436 | { |
| 5437 | if (*option == '+') |
| 5438 | break; |
| 5439 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5440 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5441 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5442 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5443 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5444 | break; |
| 5445 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5446 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5447 | { |
| 5448 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5449 | break; |
| 5450 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5451 | if (LocaleCompare("reverse",option+1) == 0) |
| 5452 | break; |
| 5453 | if (LocaleCompare("roll",option+1) == 0) |
| 5454 | { |
| 5455 | if (*option == '+') |
| 5456 | break; |
| 5457 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5458 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5459 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5460 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5461 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5462 | break; |
| 5463 | } |
| 5464 | if (LocaleCompare("rotate",option+1) == 0) |
| 5465 | { |
| 5466 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5467 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5468 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5469 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5470 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5471 | break; |
| 5472 | } |
| 5473 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5474 | } |
| 5475 | case 's': |
| 5476 | { |
| 5477 | if (LocaleCompare("sample",option+1) == 0) |
| 5478 | { |
| 5479 | if (*option == '+') |
| 5480 | break; |
| 5481 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5482 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5483 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5484 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5485 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5486 | break; |
| 5487 | } |
| 5488 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5489 | { |
| 5490 | if (*option == '+') |
| 5491 | break; |
| 5492 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5493 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5494 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5495 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5496 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5497 | break; |
| 5498 | } |
| 5499 | if (LocaleCompare("scale",option+1) == 0) |
| 5500 | { |
| 5501 | if (*option == '+') |
| 5502 | break; |
| 5503 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5504 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5505 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5506 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5507 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5508 | break; |
| 5509 | } |
| 5510 | if (LocaleCompare("scene",option+1) == 0) |
| 5511 | { |
| 5512 | if (*option == '+') |
| 5513 | break; |
| 5514 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5515 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5516 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5517 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5518 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5519 | break; |
| 5520 | } |
| 5521 | if (LocaleCompare("seed",option+1) == 0) |
| 5522 | { |
| 5523 | if (*option == '+') |
| 5524 | break; |
| 5525 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5526 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5527 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5528 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5529 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5530 | break; |
| 5531 | } |
| 5532 | if (LocaleCompare("segment",option+1) == 0) |
| 5533 | { |
| 5534 | if (*option == '+') |
| 5535 | break; |
| 5536 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5537 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5538 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5539 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5540 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5541 | break; |
| 5542 | } |
| 5543 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5544 | { |
| 5545 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5546 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5547 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5548 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5549 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5550 | break; |
| 5551 | } |
| 5552 | if (LocaleCompare("separate",option+1) == 0) |
| 5553 | break; |
| 5554 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5555 | { |
| 5556 | if (*option == '+') |
| 5557 | break; |
| 5558 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5559 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5560 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5561 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5562 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5563 | break; |
| 5564 | } |
| 5565 | if (LocaleCompare("set",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 (*option == '+') |
| 5571 | break; |
| 5572 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5573 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5574 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5575 | break; |
| 5576 | } |
| 5577 | if (LocaleCompare("shade",option+1) == 0) |
| 5578 | { |
| 5579 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5580 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5581 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5582 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5583 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5584 | break; |
| 5585 | } |
| 5586 | if (LocaleCompare("shadow",option+1) == 0) |
| 5587 | { |
| 5588 | if (*option == '+') |
| 5589 | break; |
| 5590 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5591 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5592 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5593 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5594 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5595 | break; |
| 5596 | } |
| 5597 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5598 | { |
| 5599 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5600 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5601 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5602 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5603 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5604 | break; |
| 5605 | } |
| 5606 | if (LocaleCompare("shave",option+1) == 0) |
| 5607 | { |
| 5608 | if (*option == '+') |
| 5609 | break; |
| 5610 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5611 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5612 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5613 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5614 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5615 | break; |
| 5616 | } |
| 5617 | if (LocaleCompare("shear",option+1) == 0) |
| 5618 | { |
| 5619 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5620 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5621 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5622 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5623 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5624 | break; |
| 5625 | } |
| 5626 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5627 | { |
| 5628 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5629 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5630 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5631 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5632 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5633 | break; |
| 5634 | } |
| 5635 | if (LocaleCompare("size",option+1) == 0) |
| 5636 | { |
| 5637 | if (*option == '+') |
| 5638 | break; |
| 5639 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5640 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5641 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5642 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5643 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5644 | break; |
| 5645 | } |
| 5646 | if (LocaleCompare("sketch",option+1) == 0) |
| 5647 | { |
| 5648 | if (*option == '+') |
| 5649 | break; |
| 5650 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5651 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5652 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5653 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5654 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5655 | break; |
| 5656 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5657 | if (LocaleCompare("smush",option+1) == 0) |
| 5658 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5659 | i++; |
| 5660 | if (i == (ssize_t) argc) |
| 5661 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5662 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5663 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5664 | i++; |
| 5665 | break; |
| 5666 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5667 | if (LocaleCompare("solarize",option+1) == 0) |
| 5668 | { |
| 5669 | if (*option == '+') |
| 5670 | break; |
| 5671 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5672 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5673 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5674 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5675 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5676 | break; |
| 5677 | } |
| 5678 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5679 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5680 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5681 | op; |
| 5682 | |
| 5683 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5684 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5685 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5686 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5687 | if (op < 0) |
| 5688 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5689 | argv[i]); |
| 5690 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5691 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5692 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5693 | break; |
| 5694 | } |
| 5695 | if (LocaleCompare("spread",option+1) == 0) |
| 5696 | { |
| 5697 | if (*option == '+') |
| 5698 | break; |
| 5699 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5700 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5701 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5702 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5703 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5704 | break; |
| 5705 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5706 | if (LocaleCompare("statistic",option+1) == 0) |
| 5707 | { |
| 5708 | ssize_t |
| 5709 | op; |
| 5710 | |
| 5711 | if (*option == '+') |
| 5712 | break; |
| 5713 | i++; |
| 5714 | if (i == (ssize_t) argc) |
| 5715 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5716 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5717 | if (op < 0) |
| 5718 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5719 | argv[i]); |
| 5720 | i++; |
| 5721 | if (i == (ssize_t) (argc-1)) |
| 5722 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5723 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5724 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5725 | break; |
| 5726 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5727 | if (LocaleCompare("stretch",option+1) == 0) |
| 5728 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5729 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5730 | stretch; |
| 5731 | |
| 5732 | if (*option == '+') |
| 5733 | break; |
| 5734 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5735 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5736 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5737 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5738 | if (stretch < 0) |
| 5739 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5740 | argv[i]); |
| 5741 | break; |
| 5742 | } |
| 5743 | if (LocaleCompare("strip",option+1) == 0) |
| 5744 | break; |
| 5745 | if (LocaleCompare("stroke",option+1) == 0) |
| 5746 | { |
| 5747 | if (*option == '+') |
| 5748 | break; |
| 5749 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5750 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5751 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5752 | break; |
| 5753 | } |
| 5754 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5755 | { |
| 5756 | if (*option == '+') |
| 5757 | break; |
| 5758 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5759 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5760 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5761 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5762 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5763 | break; |
| 5764 | } |
| 5765 | if (LocaleCompare("style",option+1) == 0) |
| 5766 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5767 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5768 | style; |
| 5769 | |
| 5770 | if (*option == '+') |
| 5771 | break; |
| 5772 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5773 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5774 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5775 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5776 | if (style < 0) |
| 5777 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5778 | argv[i]); |
| 5779 | break; |
| 5780 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5781 | if (LocaleCompare("swap",option+1) == 0) |
| 5782 | { |
| 5783 | if (*option == '+') |
| 5784 | break; |
| 5785 | i++; |
| 5786 | if (i == (ssize_t) (argc-1)) |
| 5787 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5788 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5789 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5790 | break; |
| 5791 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5792 | if (LocaleCompare("swirl",option+1) == 0) |
| 5793 | { |
| 5794 | if (*option == '+') |
| 5795 | break; |
| 5796 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5797 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5798 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5799 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5800 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5801 | break; |
| 5802 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5803 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5804 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5805 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5806 | } |
| 5807 | case 't': |
| 5808 | { |
| 5809 | if (LocaleCompare("taint",option+1) == 0) |
| 5810 | break; |
| 5811 | if (LocaleCompare("texture",option+1) == 0) |
| 5812 | { |
| 5813 | if (*option == '+') |
| 5814 | break; |
| 5815 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5816 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5817 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5818 | break; |
| 5819 | } |
| 5820 | if (LocaleCompare("tile",option+1) == 0) |
| 5821 | { |
| 5822 | if (*option == '+') |
| 5823 | break; |
| 5824 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5825 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5826 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5827 | break; |
| 5828 | } |
| 5829 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5830 | { |
| 5831 | if (*option == '+') |
| 5832 | break; |
| 5833 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5834 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5835 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5836 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5837 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5838 | break; |
| 5839 | } |
| 5840 | if (LocaleCompare("tint",option+1) == 0) |
| 5841 | { |
| 5842 | if (*option == '+') |
| 5843 | break; |
| 5844 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5845 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5846 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5847 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5848 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5849 | break; |
| 5850 | } |
| 5851 | if (LocaleCompare("transform",option+1) == 0) |
| 5852 | break; |
| 5853 | if (LocaleCompare("transpose",option+1) == 0) |
| 5854 | break; |
| 5855 | if (LocaleCompare("transverse",option+1) == 0) |
| 5856 | break; |
| 5857 | if (LocaleCompare("threshold",option+1) == 0) |
| 5858 | { |
| 5859 | if (*option == '+') |
| 5860 | break; |
| 5861 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5862 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5863 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5864 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5865 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5866 | break; |
| 5867 | } |
| 5868 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5869 | { |
| 5870 | if (*option == '+') |
| 5871 | break; |
| 5872 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5873 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5874 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5875 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5876 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5877 | break; |
| 5878 | } |
| 5879 | if (LocaleCompare("transparent",option+1) == 0) |
| 5880 | { |
| 5881 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5882 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5883 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5884 | break; |
| 5885 | } |
| 5886 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 5887 | { |
| 5888 | if (*option == '+') |
| 5889 | break; |
| 5890 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5891 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5892 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5893 | break; |
| 5894 | } |
| 5895 | if (LocaleCompare("treedepth",option+1) == 0) |
| 5896 | { |
| 5897 | if (*option == '+') |
| 5898 | break; |
| 5899 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5900 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5901 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5902 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5903 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5904 | break; |
| 5905 | } |
| 5906 | if (LocaleCompare("trim",option+1) == 0) |
| 5907 | break; |
| 5908 | if (LocaleCompare("type",option+1) == 0) |
| 5909 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5910 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5911 | type; |
| 5912 | |
| 5913 | if (*option == '+') |
| 5914 | break; |
| 5915 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5916 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5917 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5918 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5919 | if (type < 0) |
| 5920 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5921 | argv[i]); |
| 5922 | break; |
| 5923 | } |
| 5924 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5925 | } |
| 5926 | case 'u': |
| 5927 | { |
| 5928 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5929 | { |
| 5930 | if (*option == '+') |
| 5931 | break; |
| 5932 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5933 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5934 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5935 | break; |
| 5936 | } |
| 5937 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5938 | break; |
| 5939 | if (LocaleCompare("units",option+1) == 0) |
| 5940 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5941 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5942 | units; |
| 5943 | |
| 5944 | if (*option == '+') |
| 5945 | break; |
| 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); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5949 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5950 | argv[i]); |
| 5951 | if (units < 0) |
| 5952 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5953 | argv[i]); |
| 5954 | break; |
| 5955 | } |
| 5956 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5957 | { |
| 5958 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5959 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5960 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5961 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5962 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5963 | break; |
| 5964 | } |
| 5965 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5966 | } |
| 5967 | case 'v': |
| 5968 | { |
| 5969 | if (LocaleCompare("verbose",option+1) == 0) |
| 5970 | { |
| 5971 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 5972 | break; |
| 5973 | } |
| 5974 | if ((LocaleCompare("version",option+1) == 0) || |
| 5975 | (LocaleCompare("-version",option+1) == 0)) |
| 5976 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 5977 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5978 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 5979 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 5980 | GetMagickCopyright()); |
| 5981 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 5982 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5983 | break; |
| 5984 | } |
| 5985 | if (LocaleCompare("view",option+1) == 0) |
| 5986 | { |
| 5987 | if (*option == '+') |
| 5988 | break; |
| 5989 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5990 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5991 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5992 | break; |
| 5993 | } |
| 5994 | if (LocaleCompare("vignette",option+1) == 0) |
| 5995 | { |
| 5996 | if (*option == '+') |
| 5997 | break; |
| 5998 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5999 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6000 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6001 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6002 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6003 | break; |
| 6004 | } |
| 6005 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 6006 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6007 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6008 | method; |
| 6009 | |
| 6010 | if (*option == '+') |
| 6011 | break; |
| 6012 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6013 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6014 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6015 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6016 | argv[i]); |
| 6017 | if (method < 0) |
| 6018 | ThrowMogrifyException(OptionError, |
| 6019 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 6020 | break; |
| 6021 | } |
| 6022 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6023 | } |
| 6024 | case 'w': |
| 6025 | { |
| 6026 | if (LocaleCompare("wave",option+1) == 0) |
| 6027 | { |
| 6028 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6029 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6030 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6031 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6032 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6033 | break; |
| 6034 | } |
| 6035 | if (LocaleCompare("weight",option+1) == 0) |
| 6036 | { |
| 6037 | if (*option == '+') |
| 6038 | break; |
| 6039 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6040 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6041 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6042 | break; |
| 6043 | } |
| 6044 | if (LocaleCompare("white-point",option+1) == 0) |
| 6045 | { |
| 6046 | if (*option == '+') |
| 6047 | break; |
| 6048 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6049 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6050 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6051 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6052 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6053 | break; |
| 6054 | } |
| 6055 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6056 | { |
| 6057 | if (*option == '+') |
| 6058 | break; |
| 6059 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6060 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6061 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6062 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6063 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6064 | break; |
| 6065 | } |
| 6066 | if (LocaleCompare("write",option+1) == 0) |
| 6067 | { |
| 6068 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6069 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6070 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6071 | break; |
| 6072 | } |
| 6073 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6074 | } |
| 6075 | case '?': |
| 6076 | break; |
| 6077 | default: |
| 6078 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6079 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6080 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 6081 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6082 | if (fire != MagickFalse) |
| 6083 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6084 | } |
| 6085 | if (k != 0) |
| 6086 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6087 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6088 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6089 | DestroyMogrify(); |
| 6090 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6091 | } |
| 6092 | |
| 6093 | /* |
| 6094 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6095 | % % |
| 6096 | % % |
| 6097 | % % |
| 6098 | + M o g r i f y I m a g e I n f o % |
| 6099 | % % |
| 6100 | % % |
| 6101 | % % |
| 6102 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6103 | % |
| 6104 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6105 | % prescribed by command line options. |
| 6106 | % |
| 6107 | % The format of the MogrifyImageInfo method is: |
| 6108 | % |
| 6109 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6110 | % const char **argv,ExceptionInfo *exception) |
| 6111 | % |
| 6112 | % A description of each parameter follows: |
| 6113 | % |
| 6114 | % o image_info: the image info.. |
| 6115 | % |
| 6116 | % o argc: Specifies a pointer to an integer describing the number of |
| 6117 | % elements in the argument vector. |
| 6118 | % |
| 6119 | % o argv: Specifies a pointer to a text array containing the command line |
| 6120 | % arguments. |
| 6121 | % |
| 6122 | % o exception: return any errors or warnings in this structure. |
| 6123 | % |
| 6124 | */ |
| 6125 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6126 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6127 | { |
| 6128 | const char |
| 6129 | *option; |
| 6130 | |
| 6131 | GeometryInfo |
| 6132 | geometry_info; |
| 6133 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6134 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6135 | count; |
| 6136 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6137 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6138 | i; |
| 6139 | |
| 6140 | /* |
| 6141 | Initialize method variables. |
| 6142 | */ |
| 6143 | assert(image_info != (ImageInfo *) NULL); |
| 6144 | assert(image_info->signature == MagickSignature); |
| 6145 | if (image_info->debug != MagickFalse) |
| 6146 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6147 | image_info->filename); |
| 6148 | if (argc < 0) |
| 6149 | return(MagickTrue); |
| 6150 | /* |
| 6151 | Set the image settings. |
| 6152 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6153 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6154 | { |
| 6155 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6156 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6157 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6158 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6159 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6160 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6161 | break; |
| 6162 | switch (*(option+1)) |
| 6163 | { |
| 6164 | case 'a': |
| 6165 | { |
| 6166 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6167 | { |
| 6168 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6169 | break; |
| 6170 | } |
| 6171 | if (LocaleCompare("antialias",option+1) == 0) |
| 6172 | { |
| 6173 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6174 | break; |
| 6175 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6176 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6177 | { |
| 6178 | if (*option == '+') |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 6179 | (void) DeleteImageOption(image_info,option+1); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6180 | else |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 6181 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6182 | break; |
| 6183 | } |
| 6184 | break; |
| 6185 | } |
| 6186 | case 'b': |
| 6187 | { |
| 6188 | if (LocaleCompare("background",option+1) == 0) |
| 6189 | { |
| 6190 | if (*option == '+') |
| 6191 | { |
| 6192 | (void) DeleteImageOption(image_info,option+1); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6193 | (void) QueryColorCompliance(MogrifyBackgroundColor, |
| 6194 | AllCompliance,&image_info->background_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6195 | break; |
| 6196 | } |
| 6197 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6198 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6199 | &image_info->background_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6200 | break; |
| 6201 | } |
| 6202 | if (LocaleCompare("bias",option+1) == 0) |
| 6203 | { |
| 6204 | if (*option == '+') |
| 6205 | { |
| 6206 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6207 | break; |
| 6208 | } |
| 6209 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6210 | break; |
| 6211 | } |
| 6212 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6213 | { |
| 6214 | if (*option == '+') |
| 6215 | { |
| 6216 | (void) SetImageOption(image_info,option+1,"false"); |
| 6217 | break; |
| 6218 | } |
| 6219 | (void) SetImageOption(image_info,option+1,"true"); |
| 6220 | break; |
| 6221 | } |
| 6222 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6223 | { |
| 6224 | if (*option == '+') |
| 6225 | { |
| 6226 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6227 | break; |
| 6228 | } |
| 6229 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6230 | break; |
| 6231 | } |
| 6232 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6233 | { |
| 6234 | if (*option == '+') |
| 6235 | { |
| 6236 | (void) DeleteImageOption(image_info,option+1); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6237 | (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6238 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6239 | break; |
| 6240 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6241 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6242 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6243 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6244 | break; |
| 6245 | } |
| 6246 | if (LocaleCompare("box",option+1) == 0) |
| 6247 | { |
| 6248 | if (*option == '+') |
| 6249 | { |
| 6250 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6251 | break; |
| 6252 | } |
| 6253 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6254 | break; |
| 6255 | } |
| 6256 | break; |
| 6257 | } |
| 6258 | case 'c': |
| 6259 | { |
| 6260 | if (LocaleCompare("cache",option+1) == 0) |
| 6261 | { |
| 6262 | MagickSizeType |
| 6263 | limit; |
| 6264 | |
| 6265 | limit=MagickResourceInfinity; |
| 6266 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6267 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6268 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6269 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6270 | break; |
| 6271 | } |
| 6272 | if (LocaleCompare("caption",option+1) == 0) |
| 6273 | { |
| 6274 | if (*option == '+') |
| 6275 | { |
| 6276 | (void) DeleteImageOption(image_info,option+1); |
| 6277 | break; |
| 6278 | } |
| 6279 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6280 | break; |
| 6281 | } |
| 6282 | if (LocaleCompare("channel",option+1) == 0) |
| 6283 | { |
| 6284 | if (*option == '+') |
| 6285 | { |
| 6286 | image_info->channel=DefaultChannels; |
| 6287 | break; |
| 6288 | } |
| 6289 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6290 | break; |
| 6291 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6292 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6293 | { |
| 6294 | if (*option == '+') |
| 6295 | { |
| 6296 | image_info->colorspace=UndefinedColorspace; |
| 6297 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6298 | break; |
| 6299 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6300 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6301 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6302 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6303 | break; |
| 6304 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6305 | if (LocaleCompare("comment",option+1) == 0) |
| 6306 | { |
| 6307 | if (*option == '+') |
| 6308 | { |
| 6309 | (void) DeleteImageOption(image_info,option+1); |
| 6310 | break; |
| 6311 | } |
| 6312 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6313 | break; |
| 6314 | } |
| 6315 | if (LocaleCompare("compose",option+1) == 0) |
| 6316 | { |
| 6317 | if (*option == '+') |
| 6318 | { |
| 6319 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6320 | break; |
| 6321 | } |
| 6322 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6323 | break; |
| 6324 | } |
| 6325 | if (LocaleCompare("compress",option+1) == 0) |
| 6326 | { |
| 6327 | if (*option == '+') |
| 6328 | { |
| 6329 | image_info->compression=UndefinedCompression; |
| 6330 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6331 | break; |
| 6332 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6333 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6334 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6335 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6336 | break; |
| 6337 | } |
| 6338 | break; |
| 6339 | } |
| 6340 | case 'd': |
| 6341 | { |
| 6342 | if (LocaleCompare("debug",option+1) == 0) |
| 6343 | { |
| 6344 | if (*option == '+') |
| 6345 | (void) SetLogEventMask("none"); |
| 6346 | else |
| 6347 | (void) SetLogEventMask(argv[i+1]); |
| 6348 | image_info->debug=IsEventLogging(); |
| 6349 | break; |
| 6350 | } |
| 6351 | if (LocaleCompare("define",option+1) == 0) |
| 6352 | { |
| 6353 | if (*option == '+') |
| 6354 | { |
| 6355 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6356 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6357 | else |
| 6358 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6359 | break; |
| 6360 | } |
| 6361 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6362 | { |
| 6363 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6364 | exception); |
| 6365 | break; |
| 6366 | } |
| 6367 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6368 | break; |
| 6369 | } |
| 6370 | if (LocaleCompare("delay",option+1) == 0) |
| 6371 | { |
| 6372 | if (*option == '+') |
| 6373 | { |
| 6374 | (void) SetImageOption(image_info,option+1,"0"); |
| 6375 | break; |
| 6376 | } |
| 6377 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6378 | break; |
| 6379 | } |
| 6380 | if (LocaleCompare("density",option+1) == 0) |
| 6381 | { |
| 6382 | /* |
| 6383 | Set image density. |
| 6384 | */ |
| 6385 | if (*option == '+') |
| 6386 | { |
| 6387 | if (image_info->density != (char *) NULL) |
| 6388 | image_info->density=DestroyString(image_info->density); |
| 6389 | (void) SetImageOption(image_info,option+1,"72"); |
| 6390 | break; |
| 6391 | } |
| 6392 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6393 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6394 | break; |
| 6395 | } |
| 6396 | if (LocaleCompare("depth",option+1) == 0) |
| 6397 | { |
| 6398 | if (*option == '+') |
| 6399 | { |
| 6400 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6401 | break; |
| 6402 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6403 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6404 | break; |
| 6405 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6406 | if (LocaleCompare("direction",option+1) == 0) |
| 6407 | { |
| 6408 | if (*option == '+') |
| 6409 | { |
| 6410 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6411 | break; |
| 6412 | } |
| 6413 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6414 | break; |
| 6415 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6416 | if (LocaleCompare("display",option+1) == 0) |
| 6417 | { |
| 6418 | if (*option == '+') |
| 6419 | { |
| 6420 | if (image_info->server_name != (char *) NULL) |
| 6421 | image_info->server_name=DestroyString( |
| 6422 | image_info->server_name); |
| 6423 | break; |
| 6424 | } |
| 6425 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6426 | break; |
| 6427 | } |
| 6428 | if (LocaleCompare("dispose",option+1) == 0) |
| 6429 | { |
| 6430 | if (*option == '+') |
| 6431 | { |
| 6432 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6433 | break; |
| 6434 | } |
| 6435 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6436 | break; |
| 6437 | } |
| 6438 | if (LocaleCompare("dither",option+1) == 0) |
| 6439 | { |
| 6440 | if (*option == '+') |
| 6441 | { |
| 6442 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6443 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6444 | break; |
| 6445 | } |
| 6446 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6447 | image_info->dither=MagickTrue; |
| 6448 | break; |
| 6449 | } |
| 6450 | break; |
| 6451 | } |
| 6452 | case 'e': |
| 6453 | { |
| 6454 | if (LocaleCompare("encoding",option+1) == 0) |
| 6455 | { |
| 6456 | if (*option == '+') |
| 6457 | { |
| 6458 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6459 | break; |
| 6460 | } |
| 6461 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6462 | break; |
| 6463 | } |
| 6464 | if (LocaleCompare("endian",option+1) == 0) |
| 6465 | { |
| 6466 | if (*option == '+') |
| 6467 | { |
| 6468 | image_info->endian=UndefinedEndian; |
| 6469 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6470 | break; |
| 6471 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6472 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6473 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6474 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6475 | break; |
| 6476 | } |
| 6477 | if (LocaleCompare("extract",option+1) == 0) |
| 6478 | { |
| 6479 | /* |
| 6480 | Set image extract geometry. |
| 6481 | */ |
| 6482 | if (*option == '+') |
| 6483 | { |
| 6484 | if (image_info->extract != (char *) NULL) |
| 6485 | image_info->extract=DestroyString(image_info->extract); |
| 6486 | break; |
| 6487 | } |
| 6488 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6489 | break; |
| 6490 | } |
| 6491 | break; |
| 6492 | } |
| 6493 | case 'f': |
| 6494 | { |
| 6495 | if (LocaleCompare("fill",option+1) == 0) |
| 6496 | { |
| 6497 | if (*option == '+') |
| 6498 | { |
| 6499 | (void) SetImageOption(image_info,option+1,"none"); |
| 6500 | break; |
| 6501 | } |
| 6502 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6503 | break; |
| 6504 | } |
| 6505 | if (LocaleCompare("filter",option+1) == 0) |
| 6506 | { |
| 6507 | if (*option == '+') |
| 6508 | { |
| 6509 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6510 | break; |
| 6511 | } |
| 6512 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6513 | break; |
| 6514 | } |
| 6515 | if (LocaleCompare("font",option+1) == 0) |
| 6516 | { |
| 6517 | if (*option == '+') |
| 6518 | { |
| 6519 | if (image_info->font != (char *) NULL) |
| 6520 | image_info->font=DestroyString(image_info->font); |
| 6521 | break; |
| 6522 | } |
| 6523 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6524 | break; |
| 6525 | } |
| 6526 | if (LocaleCompare("format",option+1) == 0) |
| 6527 | { |
| 6528 | register const char |
| 6529 | *q; |
| 6530 | |
| 6531 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6532 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6533 | image_info->ping=MagickFalse; |
| 6534 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6535 | break; |
| 6536 | } |
| 6537 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6538 | { |
| 6539 | if (*option == '+') |
| 6540 | { |
| 6541 | image_info->fuzz=0.0; |
| 6542 | (void) SetImageOption(image_info,option+1,"0"); |
| 6543 | break; |
| 6544 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6545 | image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6546 | 1.0); |
| 6547 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6548 | break; |
| 6549 | } |
| 6550 | break; |
| 6551 | } |
| 6552 | case 'g': |
| 6553 | { |
| 6554 | if (LocaleCompare("gravity",option+1) == 0) |
| 6555 | { |
| 6556 | if (*option == '+') |
| 6557 | { |
| 6558 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6559 | break; |
| 6560 | } |
| 6561 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6562 | break; |
| 6563 | } |
| 6564 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6565 | { |
| 6566 | if (*option == '+') |
| 6567 | { |
| 6568 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6569 | break; |
| 6570 | } |
| 6571 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6572 | break; |
| 6573 | } |
| 6574 | break; |
| 6575 | } |
| 6576 | case 'i': |
| 6577 | { |
| 6578 | if (LocaleCompare("intent",option+1) == 0) |
| 6579 | { |
| 6580 | if (*option == '+') |
| 6581 | { |
| 6582 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6583 | break; |
| 6584 | } |
| 6585 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6586 | break; |
| 6587 | } |
| 6588 | if (LocaleCompare("interlace",option+1) == 0) |
| 6589 | { |
| 6590 | if (*option == '+') |
| 6591 | { |
| 6592 | image_info->interlace=UndefinedInterlace; |
| 6593 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6594 | break; |
| 6595 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6596 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6597 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6598 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6599 | break; |
| 6600 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6601 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6602 | { |
| 6603 | if (*option == '+') |
| 6604 | { |
| 6605 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6606 | break; |
| 6607 | } |
| 6608 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6609 | break; |
| 6610 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6611 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6612 | { |
| 6613 | if (*option == '+') |
| 6614 | { |
| 6615 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6616 | break; |
| 6617 | } |
| 6618 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6619 | break; |
| 6620 | } |
| 6621 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6622 | { |
| 6623 | if (*option == '+') |
| 6624 | { |
| 6625 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6626 | break; |
| 6627 | } |
| 6628 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6629 | break; |
| 6630 | } |
| 6631 | break; |
| 6632 | } |
| 6633 | case 'k': |
| 6634 | { |
| 6635 | if (LocaleCompare("kerning",option+1) == 0) |
| 6636 | { |
| 6637 | if (*option == '+') |
| 6638 | { |
| 6639 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6640 | break; |
| 6641 | } |
| 6642 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6643 | break; |
| 6644 | } |
| 6645 | break; |
| 6646 | } |
| 6647 | case 'l': |
| 6648 | { |
| 6649 | if (LocaleCompare("label",option+1) == 0) |
| 6650 | { |
| 6651 | if (*option == '+') |
| 6652 | { |
| 6653 | (void) DeleteImageOption(image_info,option+1); |
| 6654 | break; |
| 6655 | } |
| 6656 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6657 | break; |
| 6658 | } |
| 6659 | if (LocaleCompare("limit",option+1) == 0) |
| 6660 | { |
| 6661 | MagickSizeType |
| 6662 | limit; |
| 6663 | |
| 6664 | ResourceType |
| 6665 | type; |
| 6666 | |
| 6667 | if (*option == '+') |
| 6668 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6669 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6670 | MagickFalse,argv[i+1]); |
| 6671 | limit=MagickResourceInfinity; |
| 6672 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6673 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6674 | (void) SetMagickResourceLimit(type,limit); |
| 6675 | break; |
| 6676 | } |
| 6677 | if (LocaleCompare("list",option+1) == 0) |
| 6678 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6679 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6680 | list; |
| 6681 | |
| 6682 | /* |
| 6683 | Display configuration list. |
| 6684 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6685 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6686 | switch (list) |
| 6687 | { |
| 6688 | case MagickCoderOptions: |
| 6689 | { |
| 6690 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6691 | break; |
| 6692 | } |
| 6693 | case MagickColorOptions: |
| 6694 | { |
| 6695 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6696 | break; |
| 6697 | } |
| 6698 | case MagickConfigureOptions: |
| 6699 | { |
| 6700 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6701 | break; |
| 6702 | } |
| 6703 | case MagickDelegateOptions: |
| 6704 | { |
| 6705 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6706 | break; |
| 6707 | } |
| 6708 | case MagickFontOptions: |
| 6709 | { |
| 6710 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6711 | break; |
| 6712 | } |
| 6713 | case MagickFormatOptions: |
| 6714 | { |
| 6715 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6716 | break; |
| 6717 | } |
| 6718 | case MagickLocaleOptions: |
| 6719 | { |
| 6720 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6721 | break; |
| 6722 | } |
| 6723 | case MagickLogOptions: |
| 6724 | { |
| 6725 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6726 | break; |
| 6727 | } |
| 6728 | case MagickMagicOptions: |
| 6729 | { |
| 6730 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6731 | break; |
| 6732 | } |
| 6733 | case MagickMimeOptions: |
| 6734 | { |
| 6735 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6736 | break; |
| 6737 | } |
| 6738 | case MagickModuleOptions: |
| 6739 | { |
| 6740 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6741 | break; |
| 6742 | } |
| 6743 | case MagickPolicyOptions: |
| 6744 | { |
| 6745 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6746 | break; |
| 6747 | } |
| 6748 | case MagickResourceOptions: |
| 6749 | { |
| 6750 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6751 | break; |
| 6752 | } |
| 6753 | case MagickThresholdOptions: |
| 6754 | { |
| 6755 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6756 | break; |
| 6757 | } |
| 6758 | default: |
| 6759 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6760 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6761 | exception); |
| 6762 | break; |
| 6763 | } |
| 6764 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6765 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6766 | } |
| 6767 | if (LocaleCompare("log",option+1) == 0) |
| 6768 | { |
| 6769 | if (*option == '+') |
| 6770 | break; |
| 6771 | (void) SetLogFormat(argv[i+1]); |
| 6772 | break; |
| 6773 | } |
| 6774 | if (LocaleCompare("loop",option+1) == 0) |
| 6775 | { |
| 6776 | if (*option == '+') |
| 6777 | { |
| 6778 | (void) SetImageOption(image_info,option+1,"0"); |
| 6779 | break; |
| 6780 | } |
| 6781 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6782 | break; |
| 6783 | } |
| 6784 | break; |
| 6785 | } |
| 6786 | case 'm': |
| 6787 | { |
| 6788 | if (LocaleCompare("matte",option+1) == 0) |
| 6789 | { |
| 6790 | if (*option == '+') |
| 6791 | { |
| 6792 | (void) SetImageOption(image_info,option+1,"false"); |
| 6793 | break; |
| 6794 | } |
| 6795 | (void) SetImageOption(image_info,option+1,"true"); |
| 6796 | break; |
| 6797 | } |
| 6798 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6799 | { |
| 6800 | if (*option == '+') |
| 6801 | { |
| 6802 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6803 | (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance, |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6804 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6805 | break; |
| 6806 | } |
| 6807 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6808 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6809 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6810 | break; |
| 6811 | } |
| 6812 | if (LocaleCompare("monitor",option+1) == 0) |
| 6813 | { |
| 6814 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6815 | (void *) NULL); |
| 6816 | break; |
| 6817 | } |
| 6818 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6819 | { |
| 6820 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6821 | break; |
| 6822 | } |
| 6823 | break; |
| 6824 | } |
| 6825 | case 'o': |
| 6826 | { |
| 6827 | if (LocaleCompare("orient",option+1) == 0) |
| 6828 | { |
| 6829 | if (*option == '+') |
| 6830 | { |
| 6831 | image_info->orientation=UndefinedOrientation; |
| 6832 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6833 | break; |
| 6834 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6835 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6836 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6837 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6838 | break; |
| 6839 | } |
| 6840 | } |
| 6841 | case 'p': |
| 6842 | { |
| 6843 | if (LocaleCompare("page",option+1) == 0) |
| 6844 | { |
| 6845 | char |
| 6846 | *canonical_page, |
| 6847 | page[MaxTextExtent]; |
| 6848 | |
| 6849 | const char |
| 6850 | *image_option; |
| 6851 | |
| 6852 | MagickStatusType |
| 6853 | flags; |
| 6854 | |
| 6855 | RectangleInfo |
| 6856 | geometry; |
| 6857 | |
| 6858 | if (*option == '+') |
| 6859 | { |
| 6860 | (void) DeleteImageOption(image_info,option+1); |
| 6861 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6862 | break; |
| 6863 | } |
| 6864 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6865 | image_option=GetImageOption(image_info,"page"); |
| 6866 | if (image_option != (const char *) NULL) |
| 6867 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6868 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6869 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6870 | canonical_page=DestroyString(canonical_page); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6871 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6872 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6873 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6874 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6875 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6876 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6877 | (void) SetImageOption(image_info,option+1,page); |
| 6878 | (void) CloneString(&image_info->page,page); |
| 6879 | break; |
| 6880 | } |
| 6881 | if (LocaleCompare("pen",option+1) == 0) |
| 6882 | { |
| 6883 | if (*option == '+') |
| 6884 | { |
| 6885 | (void) SetImageOption(image_info,option+1,"none"); |
| 6886 | break; |
| 6887 | } |
| 6888 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6889 | break; |
| 6890 | } |
| 6891 | if (LocaleCompare("ping",option+1) == 0) |
| 6892 | { |
| 6893 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6894 | break; |
| 6895 | } |
| 6896 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6897 | { |
| 6898 | if (*option == '+') |
| 6899 | geometry_info.rho=0.0; |
| 6900 | else |
| 6901 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6902 | image_info->pointsize=geometry_info.rho; |
| 6903 | break; |
| 6904 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6905 | if (LocaleCompare("precision",option+1) == 0) |
| 6906 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6907 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6908 | break; |
| 6909 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6910 | if (LocaleCompare("preview",option+1) == 0) |
| 6911 | { |
| 6912 | /* |
| 6913 | Preview image. |
| 6914 | */ |
| 6915 | if (*option == '+') |
| 6916 | { |
| 6917 | image_info->preview_type=UndefinedPreview; |
| 6918 | break; |
| 6919 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6920 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6921 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6922 | break; |
| 6923 | } |
| 6924 | break; |
| 6925 | } |
| 6926 | case 'q': |
| 6927 | { |
| 6928 | if (LocaleCompare("quality",option+1) == 0) |
| 6929 | { |
| 6930 | /* |
| 6931 | Set image compression quality. |
| 6932 | */ |
| 6933 | if (*option == '+') |
| 6934 | { |
| 6935 | image_info->quality=UndefinedCompressionQuality; |
| 6936 | (void) SetImageOption(image_info,option+1,"0"); |
| 6937 | break; |
| 6938 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6939 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6940 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6941 | break; |
| 6942 | } |
| 6943 | if (LocaleCompare("quiet",option+1) == 0) |
| 6944 | { |
| 6945 | static WarningHandler |
| 6946 | warning_handler = (WarningHandler) NULL; |
| 6947 | |
| 6948 | if (*option == '+') |
| 6949 | { |
| 6950 | /* |
| 6951 | Restore error or warning messages. |
| 6952 | */ |
| 6953 | warning_handler=SetWarningHandler(warning_handler); |
| 6954 | break; |
| 6955 | } |
| 6956 | /* |
| 6957 | Suppress error or warning messages. |
| 6958 | */ |
| 6959 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6960 | break; |
| 6961 | } |
| 6962 | break; |
| 6963 | } |
| 6964 | case 'r': |
| 6965 | { |
| 6966 | if (LocaleCompare("red-primary",option+1) == 0) |
| 6967 | { |
| 6968 | if (*option == '+') |
| 6969 | { |
| 6970 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6971 | break; |
| 6972 | } |
| 6973 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6974 | break; |
| 6975 | } |
| 6976 | break; |
| 6977 | } |
| 6978 | case 's': |
| 6979 | { |
| 6980 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 6981 | { |
| 6982 | /* |
| 6983 | Set image sampling factor. |
| 6984 | */ |
| 6985 | if (*option == '+') |
| 6986 | { |
| 6987 | if (image_info->sampling_factor != (char *) NULL) |
| 6988 | image_info->sampling_factor=DestroyString( |
| 6989 | image_info->sampling_factor); |
| 6990 | break; |
| 6991 | } |
| 6992 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 6993 | break; |
| 6994 | } |
| 6995 | if (LocaleCompare("scene",option+1) == 0) |
| 6996 | { |
| 6997 | /* |
| 6998 | Set image scene. |
| 6999 | */ |
| 7000 | if (*option == '+') |
| 7001 | { |
| 7002 | image_info->scene=0; |
| 7003 | (void) SetImageOption(image_info,option+1,"0"); |
| 7004 | break; |
| 7005 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7006 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7007 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7008 | break; |
| 7009 | } |
| 7010 | if (LocaleCompare("seed",option+1) == 0) |
| 7011 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7012 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7013 | seed; |
| 7014 | |
| 7015 | if (*option == '+') |
| 7016 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7017 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7018 | SeedPseudoRandomGenerator(seed); |
| 7019 | break; |
| 7020 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7021 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7022 | SeedPseudoRandomGenerator(seed); |
| 7023 | break; |
| 7024 | } |
| 7025 | if (LocaleCompare("size",option+1) == 0) |
| 7026 | { |
| 7027 | if (*option == '+') |
| 7028 | { |
| 7029 | if (image_info->size != (char *) NULL) |
| 7030 | image_info->size=DestroyString(image_info->size); |
| 7031 | break; |
| 7032 | } |
| 7033 | (void) CloneString(&image_info->size,argv[i+1]); |
| 7034 | break; |
| 7035 | } |
| 7036 | if (LocaleCompare("stroke",option+1) == 0) |
| 7037 | { |
| 7038 | if (*option == '+') |
| 7039 | { |
| 7040 | (void) SetImageOption(image_info,option+1,"none"); |
| 7041 | break; |
| 7042 | } |
| 7043 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7044 | break; |
| 7045 | } |
| 7046 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7047 | { |
| 7048 | if (*option == '+') |
| 7049 | { |
| 7050 | (void) SetImageOption(image_info,option+1,"0"); |
| 7051 | break; |
| 7052 | } |
| 7053 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7054 | break; |
| 7055 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7056 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7057 | { |
| 7058 | if (*option == '+') |
| 7059 | { |
| 7060 | image_info->synchronize=MagickFalse; |
| 7061 | break; |
| 7062 | } |
| 7063 | image_info->synchronize=MagickTrue; |
| 7064 | break; |
| 7065 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7066 | break; |
| 7067 | } |
| 7068 | case 't': |
| 7069 | { |
| 7070 | if (LocaleCompare("taint",option+1) == 0) |
| 7071 | { |
| 7072 | if (*option == '+') |
| 7073 | { |
| 7074 | (void) SetImageOption(image_info,option+1,"false"); |
| 7075 | break; |
| 7076 | } |
| 7077 | (void) SetImageOption(image_info,option+1,"true"); |
| 7078 | break; |
| 7079 | } |
| 7080 | if (LocaleCompare("texture",option+1) == 0) |
| 7081 | { |
| 7082 | if (*option == '+') |
| 7083 | { |
| 7084 | if (image_info->texture != (char *) NULL) |
| 7085 | image_info->texture=DestroyString(image_info->texture); |
| 7086 | break; |
| 7087 | } |
| 7088 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7089 | break; |
| 7090 | } |
| 7091 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7092 | { |
| 7093 | if (*option == '+') |
| 7094 | { |
| 7095 | (void) SetImageOption(image_info,option+1,"0"); |
| 7096 | break; |
| 7097 | } |
| 7098 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7099 | break; |
| 7100 | } |
| 7101 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7102 | { |
| 7103 | if (*option == '+') |
| 7104 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 7105 | (void) QueryColorCompliance("none",AllCompliance, |
| 7106 | &image_info->transparent_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7107 | (void) SetImageOption(image_info,option+1,"none"); |
| 7108 | break; |
| 7109 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 7110 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 7111 | &image_info->transparent_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7112 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7113 | break; |
| 7114 | } |
| 7115 | if (LocaleCompare("type",option+1) == 0) |
| 7116 | { |
| 7117 | if (*option == '+') |
| 7118 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7119 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7120 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7121 | break; |
| 7122 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7123 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7124 | MagickFalse,argv[i+1]); |
| 7125 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7126 | break; |
| 7127 | } |
| 7128 | break; |
| 7129 | } |
| 7130 | case 'u': |
| 7131 | { |
| 7132 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7133 | { |
| 7134 | if (*option == '+') |
| 7135 | { |
| 7136 | (void) DeleteImageOption(image_info,option+1); |
| 7137 | break; |
| 7138 | } |
| 7139 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7140 | break; |
| 7141 | } |
| 7142 | if (LocaleCompare("units",option+1) == 0) |
| 7143 | { |
| 7144 | if (*option == '+') |
| 7145 | { |
| 7146 | image_info->units=UndefinedResolution; |
| 7147 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7148 | break; |
| 7149 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7150 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7151 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7152 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7153 | break; |
| 7154 | } |
| 7155 | break; |
| 7156 | } |
| 7157 | case 'v': |
| 7158 | { |
| 7159 | if (LocaleCompare("verbose",option+1) == 0) |
| 7160 | { |
| 7161 | if (*option == '+') |
| 7162 | { |
| 7163 | image_info->verbose=MagickFalse; |
| 7164 | break; |
| 7165 | } |
| 7166 | image_info->verbose=MagickTrue; |
| 7167 | image_info->ping=MagickFalse; |
| 7168 | break; |
| 7169 | } |
| 7170 | if (LocaleCompare("view",option+1) == 0) |
| 7171 | { |
| 7172 | if (*option == '+') |
| 7173 | { |
| 7174 | if (image_info->view != (char *) NULL) |
| 7175 | image_info->view=DestroyString(image_info->view); |
| 7176 | break; |
| 7177 | } |
| 7178 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7179 | break; |
| 7180 | } |
| 7181 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7182 | { |
| 7183 | if (*option == '+') |
| 7184 | { |
| 7185 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7186 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7187 | break; |
| 7188 | } |
| 7189 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7190 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7191 | argv[i+1]); |
| 7192 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7193 | break; |
| 7194 | } |
| 7195 | break; |
| 7196 | } |
| 7197 | case 'w': |
| 7198 | { |
| 7199 | if (LocaleCompare("white-point",option+1) == 0) |
| 7200 | { |
| 7201 | if (*option == '+') |
| 7202 | { |
| 7203 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7204 | break; |
| 7205 | } |
| 7206 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7207 | break; |
| 7208 | } |
| 7209 | break; |
| 7210 | } |
| 7211 | default: |
| 7212 | break; |
| 7213 | } |
| 7214 | i+=count; |
| 7215 | } |
| 7216 | return(MagickTrue); |
| 7217 | } |
| 7218 | |
| 7219 | /* |
| 7220 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7221 | % % |
| 7222 | % % |
| 7223 | % % |
| 7224 | + M o g r i f y I m a g e L i s t % |
| 7225 | % % |
| 7226 | % % |
| 7227 | % % |
| 7228 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7229 | % |
| 7230 | % MogrifyImageList() applies any command line options that might affect the |
| 7231 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7232 | % |
| 7233 | % The format of the MogrifyImage method is: |
| 7234 | % |
| 7235 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7236 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7237 | % |
| 7238 | % A description of each parameter follows: |
| 7239 | % |
| 7240 | % o image_info: the image info.. |
| 7241 | % |
| 7242 | % o argc: Specifies a pointer to an integer describing the number of |
| 7243 | % elements in the argument vector. |
| 7244 | % |
| 7245 | % o argv: Specifies a pointer to a text array containing the command line |
| 7246 | % arguments. |
| 7247 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7248 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7249 | % |
| 7250 | % o exception: return any errors or warnings in this structure. |
| 7251 | % |
| 7252 | */ |
| 7253 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7254 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7255 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7256 | const char |
| 7257 | *option; |
| 7258 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7259 | ImageInfo |
| 7260 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7261 | |
| 7262 | MagickStatusType |
| 7263 | status; |
| 7264 | |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7265 | PixelInterpolateMethod |
| 7266 | interpolate_method; |
| 7267 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7268 | QuantizeInfo |
| 7269 | *quantize_info; |
| 7270 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7271 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7272 | i; |
| 7273 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7274 | ssize_t |
| 7275 | count, |
| 7276 | index; |
| 7277 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7278 | /* |
| 7279 | Apply options to the image list. |
| 7280 | */ |
| 7281 | assert(image_info != (ImageInfo *) NULL); |
| 7282 | assert(image_info->signature == MagickSignature); |
| 7283 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7284 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7285 | assert((*images)->signature == MagickSignature); |
| 7286 | if ((*images)->debug != MagickFalse) |
| 7287 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7288 | (*images)->filename); |
| 7289 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7290 | return(MagickTrue); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7291 | interpolate_method=UndefinedInterpolatePixel; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7292 | mogrify_info=CloneImageInfo(image_info); |
| 7293 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7294 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7295 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7296 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7297 | if (*images == (Image *) NULL) |
| 7298 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7299 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7300 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7301 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7302 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7303 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7304 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7305 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7306 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7307 | switch (*(option+1)) |
| 7308 | { |
| 7309 | case 'a': |
| 7310 | { |
| 7311 | if (LocaleCompare("affinity",option+1) == 0) |
| 7312 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7313 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7314 | if (*option == '+') |
| 7315 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7316 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7317 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7318 | break; |
| 7319 | } |
| 7320 | i++; |
| 7321 | break; |
| 7322 | } |
| 7323 | if (LocaleCompare("append",option+1) == 0) |
| 7324 | { |
| 7325 | Image |
| 7326 | *append_image; |
| 7327 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7328 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7329 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7330 | MagickFalse,exception); |
| 7331 | if (append_image == (Image *) NULL) |
| 7332 | { |
| 7333 | status=MagickFalse; |
| 7334 | break; |
| 7335 | } |
| 7336 | *images=DestroyImageList(*images); |
| 7337 | *images=append_image; |
| 7338 | break; |
| 7339 | } |
| 7340 | if (LocaleCompare("average",option+1) == 0) |
| 7341 | { |
| 7342 | Image |
| 7343 | *average_image; |
| 7344 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7345 | /* |
| 7346 | Average an image sequence (deprecated). |
| 7347 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7348 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7349 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7350 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7351 | if (average_image == (Image *) NULL) |
| 7352 | { |
| 7353 | status=MagickFalse; |
| 7354 | break; |
| 7355 | } |
| 7356 | *images=DestroyImageList(*images); |
| 7357 | *images=average_image; |
| 7358 | break; |
| 7359 | } |
| 7360 | break; |
| 7361 | } |
| 7362 | case 'c': |
| 7363 | { |
| 7364 | if (LocaleCompare("channel",option+1) == 0) |
| 7365 | { |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7366 | ChannelType |
| 7367 | channel; |
| 7368 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7369 | if (*option == '+') |
| 7370 | { |
| 7371 | channel=DefaultChannels; |
| 7372 | break; |
| 7373 | } |
| 7374 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 7375 | SetPixelChannelMap(*images,channel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7376 | break; |
| 7377 | } |
| 7378 | if (LocaleCompare("clut",option+1) == 0) |
| 7379 | { |
| 7380 | Image |
| 7381 | *clut_image, |
| 7382 | *image; |
| 7383 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7384 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7385 | image=RemoveFirstImageFromList(images); |
| 7386 | clut_image=RemoveFirstImageFromList(images); |
| 7387 | if (clut_image == (Image *) NULL) |
| 7388 | { |
| 7389 | status=MagickFalse; |
| 7390 | break; |
| 7391 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7392 | (void) ClutImage(image,clut_image,interpolate_method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7393 | clut_image=DestroyImage(clut_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7394 | *images=DestroyImageList(*images); |
| 7395 | *images=image; |
| 7396 | break; |
| 7397 | } |
| 7398 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7399 | { |
| 7400 | Image |
| 7401 | *coalesce_image; |
| 7402 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7403 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7404 | coalesce_image=CoalesceImages(*images,exception); |
| 7405 | if (coalesce_image == (Image *) NULL) |
| 7406 | { |
| 7407 | status=MagickFalse; |
| 7408 | break; |
| 7409 | } |
| 7410 | *images=DestroyImageList(*images); |
| 7411 | *images=coalesce_image; |
| 7412 | break; |
| 7413 | } |
| 7414 | if (LocaleCompare("combine",option+1) == 0) |
| 7415 | { |
| 7416 | Image |
| 7417 | *combine_image; |
| 7418 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7419 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 7420 | combine_image=CombineImages(*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7421 | if (combine_image == (Image *) NULL) |
| 7422 | { |
| 7423 | status=MagickFalse; |
| 7424 | break; |
| 7425 | } |
| 7426 | *images=DestroyImageList(*images); |
| 7427 | *images=combine_image; |
| 7428 | break; |
| 7429 | } |
| 7430 | if (LocaleCompare("composite",option+1) == 0) |
| 7431 | { |
| 7432 | Image |
| 7433 | *mask_image, |
| 7434 | *composite_image, |
| 7435 | *image; |
| 7436 | |
| 7437 | RectangleInfo |
| 7438 | geometry; |
| 7439 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7440 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7441 | image=RemoveFirstImageFromList(images); |
| 7442 | composite_image=RemoveFirstImageFromList(images); |
| 7443 | if (composite_image == (Image *) NULL) |
| 7444 | { |
| 7445 | status=MagickFalse; |
| 7446 | break; |
| 7447 | } |
| 7448 | (void) TransformImage(&composite_image,(char *) NULL, |
| 7449 | composite_image->geometry); |
| 7450 | SetGeometry(composite_image,&geometry); |
| 7451 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7452 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7453 | &geometry); |
| 7454 | mask_image=RemoveFirstImageFromList(images); |
| 7455 | if (mask_image != (Image *) NULL) |
| 7456 | { |
| 7457 | if ((image->compose == DisplaceCompositeOp) || |
| 7458 | (image->compose == DistortCompositeOp)) |
| 7459 | { |
| 7460 | /* |
| 7461 | Merge Y displacement into X displacement image. |
| 7462 | */ |
| 7463 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
| 7464 | mask_image,0,0); |
| 7465 | mask_image=DestroyImage(mask_image); |
| 7466 | } |
| 7467 | else |
| 7468 | { |
| 7469 | /* |
| 7470 | Set a blending mask for the composition. |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7471 | Posible error, what if image->mask already set. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7472 | */ |
| 7473 | image->mask=mask_image; |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 7474 | (void) NegateImage(image->mask,MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7475 | } |
| 7476 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7477 | (void) CompositeImage(image,image->compose,composite_image, |
| 7478 | geometry.x,geometry.y); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7479 | if (mask_image != (Image *) NULL) |
| 7480 | mask_image=image->mask=DestroyImage(image->mask); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7481 | composite_image=DestroyImage(composite_image); |
| 7482 | InheritException(exception,&image->exception); |
| 7483 | *images=DestroyImageList(*images); |
| 7484 | *images=image; |
| 7485 | break; |
| 7486 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7487 | break; |
| 7488 | } |
| 7489 | case 'd': |
| 7490 | { |
| 7491 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7492 | { |
| 7493 | Image |
| 7494 | *deconstruct_image; |
| 7495 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7496 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7497 | deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer, |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 7498 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7499 | if (deconstruct_image == (Image *) NULL) |
| 7500 | { |
| 7501 | status=MagickFalse; |
| 7502 | break; |
| 7503 | } |
| 7504 | *images=DestroyImageList(*images); |
| 7505 | *images=deconstruct_image; |
| 7506 | break; |
| 7507 | } |
| 7508 | if (LocaleCompare("delete",option+1) == 0) |
| 7509 | { |
| 7510 | if (*option == '+') |
| 7511 | DeleteImages(images,"-1",exception); |
| 7512 | else |
| 7513 | DeleteImages(images,argv[i+1],exception); |
| 7514 | break; |
| 7515 | } |
| 7516 | if (LocaleCompare("dither",option+1) == 0) |
| 7517 | { |
| 7518 | if (*option == '+') |
| 7519 | { |
| 7520 | quantize_info->dither=MagickFalse; |
| 7521 | break; |
| 7522 | } |
| 7523 | quantize_info->dither=MagickTrue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7524 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7525 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7526 | break; |
| 7527 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7528 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7529 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7530 | Image |
| 7531 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7532 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7533 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7534 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7535 | else |
| 7536 | { |
| 7537 | const char |
| 7538 | *p; |
| 7539 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7540 | size_t |
| 7541 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7542 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7543 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7544 | p=strchr(argv[i+1],','); |
| 7545 | if (p == (const char *) NULL) |
| 7546 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7547 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7548 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7549 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7550 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7551 | } |
| 7552 | AppendImageToList(images, duplicate_images); |
| 7553 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7554 | break; |
| 7555 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7556 | break; |
| 7557 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7558 | case 'e': |
| 7559 | { |
| 7560 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7561 | { |
| 7562 | Image |
| 7563 | *evaluate_image; |
| 7564 | |
| 7565 | MagickEvaluateOperator |
| 7566 | op; |
| 7567 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7568 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7569 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 7570 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7571 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7572 | if (evaluate_image == (Image *) NULL) |
| 7573 | { |
| 7574 | status=MagickFalse; |
| 7575 | break; |
| 7576 | } |
| 7577 | *images=DestroyImageList(*images); |
| 7578 | *images=evaluate_image; |
| 7579 | break; |
| 7580 | } |
| 7581 | break; |
| 7582 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7583 | case 'f': |
| 7584 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7585 | if (LocaleCompare("fft",option+1) == 0) |
| 7586 | { |
| 7587 | Image |
| 7588 | *fourier_image; |
| 7589 | |
| 7590 | /* |
| 7591 | Implements the discrete Fourier transform (DFT). |
| 7592 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7593 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7594 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7595 | MagickTrue : MagickFalse,exception); |
| 7596 | if (fourier_image == (Image *) NULL) |
| 7597 | break; |
| 7598 | *images=DestroyImage(*images); |
| 7599 | *images=fourier_image; |
| 7600 | break; |
| 7601 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7602 | if (LocaleCompare("flatten",option+1) == 0) |
| 7603 | { |
| 7604 | Image |
| 7605 | *flatten_image; |
| 7606 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7607 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7608 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7609 | if (flatten_image == (Image *) NULL) |
| 7610 | break; |
| 7611 | *images=DestroyImageList(*images); |
| 7612 | *images=flatten_image; |
| 7613 | break; |
| 7614 | } |
| 7615 | if (LocaleCompare("fx",option+1) == 0) |
| 7616 | { |
| 7617 | Image |
| 7618 | *fx_image; |
| 7619 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7620 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 7621 | fx_image=FxImage(*images,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7622 | if (fx_image == (Image *) NULL) |
| 7623 | { |
| 7624 | status=MagickFalse; |
| 7625 | break; |
| 7626 | } |
| 7627 | *images=DestroyImageList(*images); |
| 7628 | *images=fx_image; |
| 7629 | break; |
| 7630 | } |
| 7631 | break; |
| 7632 | } |
| 7633 | case 'h': |
| 7634 | { |
| 7635 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7636 | { |
| 7637 | Image |
| 7638 | *hald_image, |
| 7639 | *image; |
| 7640 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7641 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7642 | image=RemoveFirstImageFromList(images); |
| 7643 | hald_image=RemoveFirstImageFromList(images); |
| 7644 | if (hald_image == (Image *) NULL) |
| 7645 | { |
| 7646 | status=MagickFalse; |
| 7647 | break; |
| 7648 | } |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 7649 | (void) HaldClutImage(image,hald_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7650 | hald_image=DestroyImage(hald_image); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7651 | if (*images != (Image *) NULL) |
| 7652 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7653 | *images=image; |
| 7654 | break; |
| 7655 | } |
| 7656 | break; |
| 7657 | } |
| 7658 | case 'i': |
| 7659 | { |
| 7660 | if (LocaleCompare("ift",option+1) == 0) |
| 7661 | { |
| 7662 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7663 | *fourier_image, |
| 7664 | *magnitude_image, |
| 7665 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7666 | |
| 7667 | /* |
| 7668 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7669 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7670 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7671 | magnitude_image=RemoveFirstImageFromList(images); |
| 7672 | phase_image=RemoveFirstImageFromList(images); |
| 7673 | if (phase_image == (Image *) NULL) |
| 7674 | { |
| 7675 | status=MagickFalse; |
| 7676 | break; |
| 7677 | } |
| 7678 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7679 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7680 | if (fourier_image == (Image *) NULL) |
| 7681 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7682 | if (*images != (Image *) NULL) |
| 7683 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7684 | *images=fourier_image; |
| 7685 | break; |
| 7686 | } |
| 7687 | if (LocaleCompare("insert",option+1) == 0) |
| 7688 | { |
| 7689 | Image |
| 7690 | *p, |
| 7691 | *q; |
| 7692 | |
| 7693 | index=0; |
| 7694 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7695 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7696 | p=RemoveLastImageFromList(images); |
| 7697 | if (p == (Image *) NULL) |
| 7698 | { |
| 7699 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7700 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7701 | status=MagickFalse; |
| 7702 | break; |
| 7703 | } |
| 7704 | q=p; |
| 7705 | if (index == 0) |
| 7706 | PrependImageToList(images,q); |
| 7707 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7708 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7709 | AppendImageToList(images,q); |
| 7710 | else |
| 7711 | { |
| 7712 | q=GetImageFromList(*images,index-1); |
| 7713 | if (q == (Image *) NULL) |
| 7714 | { |
| 7715 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7716 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7717 | status=MagickFalse; |
| 7718 | break; |
| 7719 | } |
| 7720 | InsertImageInList(&q,p); |
| 7721 | } |
| 7722 | *images=GetFirstImageInList(q); |
| 7723 | break; |
| 7724 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7725 | if (LocaleCompare("interpolate",option+1) == 0) |
| 7726 | { |
| 7727 | interpolate_method=(PixelInterpolateMethod) ParseCommandOption( |
| 7728 | MagickInterpolateOptions,MagickFalse,argv[i+1]); |
| 7729 | break; |
| 7730 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7731 | break; |
| 7732 | } |
| 7733 | case 'l': |
| 7734 | { |
| 7735 | if (LocaleCompare("layers",option+1) == 0) |
| 7736 | { |
| 7737 | Image |
| 7738 | *layers; |
| 7739 | |
| 7740 | ImageLayerMethod |
| 7741 | method; |
| 7742 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7743 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7744 | layers=(Image *) NULL; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7745 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7746 | MagickFalse,argv[i+1]); |
| 7747 | switch (method) |
| 7748 | { |
| 7749 | case CoalesceLayer: |
| 7750 | { |
| 7751 | layers=CoalesceImages(*images,exception); |
| 7752 | break; |
| 7753 | } |
| 7754 | case CompareAnyLayer: |
| 7755 | case CompareClearLayer: |
| 7756 | case CompareOverlayLayer: |
| 7757 | default: |
| 7758 | { |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7759 | layers=CompareImagesLayers(*images,method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7760 | break; |
| 7761 | } |
| 7762 | case MergeLayer: |
| 7763 | case FlattenLayer: |
| 7764 | case MosaicLayer: |
| 7765 | case TrimBoundsLayer: |
| 7766 | { |
| 7767 | layers=MergeImageLayers(*images,method,exception); |
| 7768 | break; |
| 7769 | } |
| 7770 | case DisposeLayer: |
| 7771 | { |
| 7772 | layers=DisposeImages(*images,exception); |
| 7773 | break; |
| 7774 | } |
| 7775 | case OptimizeImageLayer: |
| 7776 | { |
| 7777 | layers=OptimizeImageLayers(*images,exception); |
| 7778 | break; |
| 7779 | } |
| 7780 | case OptimizePlusLayer: |
| 7781 | { |
| 7782 | layers=OptimizePlusImageLayers(*images,exception); |
| 7783 | break; |
| 7784 | } |
| 7785 | case OptimizeTransLayer: |
| 7786 | { |
| 7787 | OptimizeImageTransparency(*images,exception); |
| 7788 | break; |
| 7789 | } |
| 7790 | case RemoveDupsLayer: |
| 7791 | { |
| 7792 | RemoveDuplicateLayers(images,exception); |
| 7793 | break; |
| 7794 | } |
| 7795 | case RemoveZeroLayer: |
| 7796 | { |
| 7797 | RemoveZeroDelayLayers(images,exception); |
| 7798 | break; |
| 7799 | } |
| 7800 | case OptimizeLayer: |
| 7801 | { |
| 7802 | /* |
| 7803 | General Purpose, GIF Animation Optimizer. |
| 7804 | */ |
| 7805 | layers=CoalesceImages(*images,exception); |
| 7806 | if (layers == (Image *) NULL) |
| 7807 | { |
| 7808 | status=MagickFalse; |
| 7809 | break; |
| 7810 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7811 | *images=DestroyImageList(*images); |
| 7812 | *images=layers; |
| 7813 | layers=OptimizeImageLayers(*images,exception); |
| 7814 | if (layers == (Image *) NULL) |
| 7815 | { |
| 7816 | status=MagickFalse; |
| 7817 | break; |
| 7818 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7819 | *images=DestroyImageList(*images); |
| 7820 | *images=layers; |
| 7821 | layers=(Image *) NULL; |
| 7822 | OptimizeImageTransparency(*images,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7823 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7824 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7825 | break; |
| 7826 | } |
| 7827 | case CompositeLayer: |
| 7828 | { |
| 7829 | CompositeOperator |
| 7830 | compose; |
| 7831 | |
| 7832 | Image |
| 7833 | *source; |
| 7834 | |
| 7835 | RectangleInfo |
| 7836 | geometry; |
| 7837 | |
| 7838 | /* |
| 7839 | Split image sequence at the first 'NULL:' image. |
| 7840 | */ |
| 7841 | source=(*images); |
| 7842 | while (source != (Image *) NULL) |
| 7843 | { |
| 7844 | source=GetNextImageInList(source); |
| 7845 | if ((source != (Image *) NULL) && |
| 7846 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7847 | break; |
| 7848 | } |
| 7849 | if (source != (Image *) NULL) |
| 7850 | { |
| 7851 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7852 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7853 | source=(Image *) NULL; |
| 7854 | else |
| 7855 | { |
| 7856 | /* |
| 7857 | Separate the two lists, junk the null: image. |
| 7858 | */ |
| 7859 | source=SplitImageList(source->previous); |
| 7860 | DeleteImageFromList(&source); |
| 7861 | } |
| 7862 | } |
| 7863 | if (source == (Image *) NULL) |
| 7864 | { |
| 7865 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7866 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7867 | status=MagickFalse; |
| 7868 | break; |
| 7869 | } |
| 7870 | /* |
| 7871 | Adjust offset with gravity and virtual canvas. |
| 7872 | */ |
| 7873 | SetGeometry(*images,&geometry); |
| 7874 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7875 | geometry.width=source->page.width != 0 ? |
| 7876 | source->page.width : source->columns; |
| 7877 | geometry.height=source->page.height != 0 ? |
| 7878 | source->page.height : source->rows; |
| 7879 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7880 | (*images)->page.width : (*images)->columns, |
| 7881 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7882 | (*images)->rows,(*images)->gravity,&geometry); |
| 7883 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7884 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7885 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7886 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7887 | MagickComposeOptions,MagickFalse,option); |
| 7888 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7889 | exception); |
| 7890 | source=DestroyImageList(source); |
| 7891 | break; |
| 7892 | } |
| 7893 | } |
| 7894 | if (layers == (Image *) NULL) |
| 7895 | break; |
| 7896 | InheritException(exception,&layers->exception); |
| 7897 | *images=DestroyImageList(*images); |
| 7898 | *images=layers; |
| 7899 | break; |
| 7900 | } |
| 7901 | break; |
| 7902 | } |
| 7903 | case 'm': |
| 7904 | { |
| 7905 | if (LocaleCompare("map",option+1) == 0) |
| 7906 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7907 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7908 | if (*option == '+') |
| 7909 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7910 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7911 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7912 | break; |
| 7913 | } |
| 7914 | i++; |
| 7915 | break; |
| 7916 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7917 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7918 | { |
| 7919 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7920 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7921 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7922 | /* |
| 7923 | Maximum image sequence (deprecated). |
| 7924 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7925 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7926 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7927 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7928 | { |
| 7929 | status=MagickFalse; |
| 7930 | break; |
| 7931 | } |
| 7932 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7933 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7934 | break; |
| 7935 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7936 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7937 | { |
| 7938 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7939 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7940 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7941 | /* |
| 7942 | Minimum image sequence (deprecated). |
| 7943 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7944 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7945 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7946 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7947 | { |
| 7948 | status=MagickFalse; |
| 7949 | break; |
| 7950 | } |
| 7951 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7952 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7953 | break; |
| 7954 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7955 | if (LocaleCompare("morph",option+1) == 0) |
| 7956 | { |
| 7957 | Image |
| 7958 | *morph_image; |
| 7959 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7960 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7961 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7962 | exception); |
| 7963 | if (morph_image == (Image *) NULL) |
| 7964 | { |
| 7965 | status=MagickFalse; |
| 7966 | break; |
| 7967 | } |
| 7968 | *images=DestroyImageList(*images); |
| 7969 | *images=morph_image; |
| 7970 | break; |
| 7971 | } |
| 7972 | if (LocaleCompare("mosaic",option+1) == 0) |
| 7973 | { |
| 7974 | Image |
| 7975 | *mosaic_image; |
| 7976 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7977 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7978 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 7979 | if (mosaic_image == (Image *) NULL) |
| 7980 | { |
| 7981 | status=MagickFalse; |
| 7982 | break; |
| 7983 | } |
| 7984 | *images=DestroyImageList(*images); |
| 7985 | *images=mosaic_image; |
| 7986 | break; |
| 7987 | } |
| 7988 | break; |
| 7989 | } |
| 7990 | case 'p': |
| 7991 | { |
| 7992 | if (LocaleCompare("print",option+1) == 0) |
| 7993 | { |
| 7994 | char |
| 7995 | *string; |
| 7996 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7997 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7998 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1], |
| 7999 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8000 | if (string == (char *) NULL) |
| 8001 | break; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8002 | (void) FormatLocaleFile(stdout,"%s",string); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8003 | string=DestroyString(string); |
| 8004 | } |
| 8005 | if (LocaleCompare("process",option+1) == 0) |
| 8006 | { |
| 8007 | char |
| 8008 | **arguments; |
| 8009 | |
| 8010 | int |
| 8011 | j, |
| 8012 | number_arguments; |
| 8013 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8014 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8015 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 8016 | if (arguments == (char **) NULL) |
| 8017 | break; |
| 8018 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 8019 | { |
| 8020 | char |
| 8021 | breaker, |
| 8022 | quote, |
| 8023 | *token; |
| 8024 | |
| 8025 | const char |
| 8026 | *arguments; |
| 8027 | |
| 8028 | int |
| 8029 | next, |
| 8030 | status; |
| 8031 | |
| 8032 | size_t |
| 8033 | length; |
| 8034 | |
| 8035 | TokenInfo |
| 8036 | *token_info; |
| 8037 | |
| 8038 | /* |
| 8039 | Support old style syntax, filter="-option arg". |
| 8040 | */ |
| 8041 | length=strlen(argv[i+1]); |
| 8042 | token=(char *) NULL; |
cristy | 37e0b38 | 2011-06-07 13:31:21 +0000 | [diff] [blame] | 8043 | if (~length >= (MaxTextExtent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8044 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8045 | sizeof(*token)); |
| 8046 | if (token == (char *) NULL) |
| 8047 | break; |
| 8048 | next=0; |
| 8049 | arguments=argv[i+1]; |
| 8050 | token_info=AcquireTokenInfo(); |
| 8051 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8052 | "\"",'\0',&breaker,&next,"e); |
| 8053 | token_info=DestroyTokenInfo(token_info); |
| 8054 | if (status == 0) |
| 8055 | { |
| 8056 | const char |
| 8057 | *argv; |
| 8058 | |
| 8059 | argv=(&(arguments[next])); |
| 8060 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8061 | exception); |
| 8062 | } |
| 8063 | token=DestroyString(token); |
| 8064 | break; |
| 8065 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8066 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8067 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8068 | number_arguments-2,(const char **) arguments+2,exception); |
| 8069 | for (j=0; j < number_arguments; j++) |
| 8070 | arguments[j]=DestroyString(arguments[j]); |
| 8071 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8072 | break; |
| 8073 | } |
| 8074 | break; |
| 8075 | } |
| 8076 | case 'r': |
| 8077 | { |
| 8078 | if (LocaleCompare("reverse",option+1) == 0) |
| 8079 | { |
| 8080 | ReverseImageList(images); |
| 8081 | InheritException(exception,&(*images)->exception); |
| 8082 | break; |
| 8083 | } |
| 8084 | break; |
| 8085 | } |
| 8086 | case 's': |
| 8087 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8088 | if (LocaleCompare("smush",option+1) == 0) |
| 8089 | { |
| 8090 | Image |
| 8091 | *smush_image; |
| 8092 | |
| 8093 | ssize_t |
| 8094 | offset; |
| 8095 | |
| 8096 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8097 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8098 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8099 | MagickFalse,offset,exception); |
| 8100 | if (smush_image == (Image *) NULL) |
| 8101 | { |
| 8102 | status=MagickFalse; |
| 8103 | break; |
| 8104 | } |
| 8105 | *images=DestroyImageList(*images); |
| 8106 | *images=smush_image; |
| 8107 | break; |
| 8108 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8109 | if (LocaleCompare("swap",option+1) == 0) |
| 8110 | { |
| 8111 | Image |
| 8112 | *p, |
| 8113 | *q, |
| 8114 | *swap; |
| 8115 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8116 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8117 | swap_index; |
| 8118 | |
| 8119 | index=(-1); |
| 8120 | swap_index=(-2); |
| 8121 | if (*option != '+') |
| 8122 | { |
| 8123 | GeometryInfo |
| 8124 | geometry_info; |
| 8125 | |
| 8126 | MagickStatusType |
| 8127 | flags; |
| 8128 | |
| 8129 | swap_index=(-1); |
| 8130 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8131 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8132 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8133 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8134 | } |
| 8135 | p=GetImageFromList(*images,index); |
| 8136 | q=GetImageFromList(*images,swap_index); |
| 8137 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8138 | { |
| 8139 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8140 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8141 | status=MagickFalse; |
| 8142 | break; |
| 8143 | } |
| 8144 | if (p == q) |
| 8145 | break; |
| 8146 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8147 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8148 | ReplaceImageInList(&q,swap); |
| 8149 | *images=GetFirstImageInList(q); |
| 8150 | break; |
| 8151 | } |
| 8152 | break; |
| 8153 | } |
| 8154 | case 'w': |
| 8155 | { |
| 8156 | if (LocaleCompare("write",option+1) == 0) |
| 8157 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8158 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8159 | key[MaxTextExtent]; |
| 8160 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8161 | Image |
| 8162 | *write_images; |
| 8163 | |
| 8164 | ImageInfo |
| 8165 | *write_info; |
| 8166 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8167 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8168 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8169 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8170 | write_images=(*images); |
| 8171 | if (*option == '+') |
| 8172 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8173 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8174 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8175 | write_info=DestroyImageInfo(write_info); |
| 8176 | if (*option == '+') |
| 8177 | write_images=DestroyImageList(write_images); |
| 8178 | break; |
| 8179 | } |
| 8180 | break; |
| 8181 | } |
| 8182 | default: |
| 8183 | break; |
| 8184 | } |
| 8185 | i+=count; |
| 8186 | } |
| 8187 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8188 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8189 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8190 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8191 | } |
| 8192 | |
| 8193 | /* |
| 8194 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8195 | % % |
| 8196 | % % |
| 8197 | % % |
| 8198 | + M o g r i f y I m a g e s % |
| 8199 | % % |
| 8200 | % % |
| 8201 | % % |
| 8202 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8203 | % |
| 8204 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8205 | % prescribed by command line options. |
| 8206 | % |
| 8207 | % The format of the MogrifyImage method is: |
| 8208 | % |
| 8209 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8210 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8211 | % Image **images,Exceptioninfo *exception) |
| 8212 | % |
| 8213 | % A description of each parameter follows: |
| 8214 | % |
| 8215 | % o image_info: the image info.. |
| 8216 | % |
| 8217 | % o post: If true, post process image list operators otherwise pre-process. |
| 8218 | % |
| 8219 | % o argc: Specifies a pointer to an integer describing the number of |
| 8220 | % elements in the argument vector. |
| 8221 | % |
| 8222 | % o argv: Specifies a pointer to a text array containing the command line |
| 8223 | % arguments. |
| 8224 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8225 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8226 | % |
| 8227 | % o exception: return any errors or warnings in this structure. |
| 8228 | % |
| 8229 | */ |
| 8230 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8231 | const MagickBooleanType post,const int argc,const char **argv, |
| 8232 | Image **images,ExceptionInfo *exception) |
| 8233 | { |
| 8234 | #define MogrifyImageTag "Mogrify/Image" |
| 8235 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8236 | MagickStatusType |
| 8237 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8238 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8239 | MagickBooleanType |
| 8240 | proceed; |
| 8241 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8242 | size_t |
| 8243 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8244 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8245 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8246 | i; |
| 8247 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8248 | assert(image_info != (ImageInfo *) NULL); |
| 8249 | assert(image_info->signature == MagickSignature); |
| 8250 | if (images == (Image **) NULL) |
| 8251 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8252 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8253 | assert((*images)->signature == MagickSignature); |
| 8254 | if ((*images)->debug != MagickFalse) |
| 8255 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8256 | (*images)->filename); |
| 8257 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8258 | return(MagickTrue); |
| 8259 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8260 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8261 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8262 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8263 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8264 | (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc, |
| 8265 | post?"post":"pre"); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8266 | #endif |
| 8267 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8268 | /* |
| 8269 | Pre-process multi-image sequence operators |
| 8270 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8271 | if (post == MagickFalse) |
| 8272 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8273 | /* |
| 8274 | For each image, process simple single image operators |
| 8275 | */ |
| 8276 | i=0; |
| 8277 | n=GetImageListLength(*images); |
cristy | 9f027d1 | 2011-09-21 01:17:17 +0000 | [diff] [blame] | 8278 | for ( ; ; ) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8279 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8280 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8281 | (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long) |
| 8282 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8283 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8284 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8285 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8286 | if (proceed == MagickFalse) |
| 8287 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8288 | if ( (*images)->next == (Image *) NULL ) |
| 8289 | break; |
| 8290 | *images=(*images)->next; |
| 8291 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8292 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8293 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8294 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8295 | (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long) |
| 8296 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8297 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8298 | |
| 8299 | /* |
| 8300 | Post-process, multi-image sequence operators |
| 8301 | */ |
| 8302 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8303 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8304 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8305 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8306 | } |