cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % M M OOO GGGGG RRRR IIIII FFFFF Y Y % |
| 7 | % MM MM O O G R R I F Y Y % |
| 8 | % M M M O O G GGG RRRR I FFF Y % |
| 9 | % M M O O G G R R I F Y % |
| 10 | % M M OOO GGGG R R IIIII F Y % |
| 11 | % % |
| 12 | % % |
| 13 | % MagickWand Module Methods % |
| 14 | % % |
| 15 | % Software Design % |
| 16 | % John Cristy % |
| 17 | % March 2000 % |
| 18 | % % |
| 19 | % % |
cristy | 7e41fe8 | 2010-12-04 23:12:08 +0000 | [diff] [blame] | 20 | % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 21 | % dedicated to making software imaging solutions freely available. % |
| 22 | % % |
| 23 | % You may not use this file except in compliance with the License. You may % |
| 24 | % obtain a copy of the License at % |
| 25 | % % |
| 26 | % http://www.imagemagick.org/script/license.php % |
| 27 | % % |
| 28 | % Unless required by applicable law or agreed to in writing, software % |
| 29 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 30 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 31 | % See the License for the specific language governing permissions and % |
| 32 | % limitations under the License. % |
| 33 | % % |
| 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 35 | % |
| 36 | % Use the mogrify program to resize an image, blur, crop, despeckle, dither, |
| 37 | % draw on, flip, join, re-sample, and much more. This tool is similiar to |
| 38 | % convert except that the original image file is overwritten (unless you |
| 39 | % change the file suffix with the -format option) with any changes you |
cristy | 6a917d9 | 2009-10-06 19:23:54 +0000 | [diff] [blame] | 40 | % request. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 41 | % |
| 42 | */ |
| 43 | |
| 44 | /* |
| 45 | Include declarations. |
| 46 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 47 | #include "MagickWand/studio.h" |
| 48 | #include "MagickWand/MagickWand.h" |
| 49 | #include "MagickWand/mogrify-private.h" |
| 50 | #undef DegreesToRadians |
| 51 | #undef RadiansToDegrees |
| 52 | #include "MagickCore/image-private.h" |
| 53 | #include "MagickCore/monitor-private.h" |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 54 | #include "MagickCore/string-private.h" |
cristy | 0740a98 | 2011-10-13 15:01:01 +0000 | [diff] [blame] | 55 | #include "MagickCore/thread-private.h" |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 56 | #include "MagickCore/utility-private.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 57 | |
| 58 | /* |
cristy | 154fa9d | 2011-08-05 14:25:15 +0000 | [diff] [blame] | 59 | Constant declaration. |
| 60 | */ |
cristy | 3a557c0 | 2011-08-06 19:48:02 +0000 | [diff] [blame] | 61 | static const char |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 62 | MogrifyBackgroundColor[] = "#ffffff", /* white */ |
| 63 | MogrifyBorderColor[] = "#dfdfdf", /* gray */ |
| 64 | MogrifyMatteColor[] = "#bdbdbd"; /* gray */ |
cristy | 154fa9d | 2011-08-05 14:25:15 +0000 | [diff] [blame] | 65 | |
| 66 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 67 | Define declarations. |
| 68 | */ |
| 69 | #define UndefinedCompressionQuality 0UL |
| 70 | |
| 71 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 72 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 73 | % % |
| 74 | % % |
| 75 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 76 | % M a g i c k C o m m a n d G e n e s i s % |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 77 | % % |
| 78 | % % |
| 79 | % % |
| 80 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 81 | % |
| 82 | % MagickCommandGenesis() applies image processing options to an image as |
| 83 | % prescribed by command line options. |
| 84 | % |
| 85 | % The format of the MagickCommandGenesis method is: |
| 86 | % |
| 87 | % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 88 | % MagickCommand command,int argc,char **argv,char **metadata, |
| 89 | % ExceptionInfo *exception) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 90 | % |
| 91 | % A description of each parameter follows: |
| 92 | % |
| 93 | % o image_info: the image info. |
| 94 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 95 | % o command: Choose from ConvertImageCommand, IdentifyImageCommand, |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 96 | % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 97 | % ConjureImageCommand, StreamImageCommand, ImportImageCommand, |
| 98 | % DisplayImageCommand, or AnimateImageCommand. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 99 | % |
| 100 | % o argc: Specifies a pointer to an integer describing the number of |
| 101 | % elements in the argument vector. |
| 102 | % |
| 103 | % o argv: Specifies a pointer to a text array containing the command line |
| 104 | % arguments. |
| 105 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 106 | % o metadata: any metadata is returned here. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 107 | % |
| 108 | % o exception: return any errors or warnings in this structure. |
| 109 | % |
| 110 | */ |
| 111 | WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
| 112 | MagickCommand command,int argc,char **argv,char **metadata, |
| 113 | ExceptionInfo *exception) |
| 114 | { |
| 115 | char |
| 116 | *option; |
| 117 | |
| 118 | double |
| 119 | duration, |
| 120 | elapsed_time, |
| 121 | user_time; |
| 122 | |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 123 | MagickBooleanType |
| 124 | concurrent, |
| 125 | regard_warnings, |
| 126 | status; |
| 127 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 128 | register ssize_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 129 | i; |
| 130 | |
| 131 | TimerInfo |
| 132 | *timer; |
| 133 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 134 | size_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 135 | iterations; |
| 136 | |
cristy | d0a94fa | 2010-03-12 14:18:11 +0000 | [diff] [blame] | 137 | (void) setlocale(LC_ALL,""); |
| 138 | (void) setlocale(LC_NUMERIC,"C"); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 139 | concurrent=MagickFalse; |
| 140 | duration=(-1.0); |
| 141 | iterations=1; |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 142 | status=MagickFalse; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 143 | regard_warnings=MagickFalse; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 144 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 145 | { |
| 146 | option=argv[i]; |
| 147 | if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) |
| 148 | continue; |
| 149 | if (LocaleCompare("bench",option+1) == 0) |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 150 | iterations=StringToUnsignedLong(argv[++i]); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 151 | if (LocaleCompare("concurrent",option+1) == 0) |
| 152 | concurrent=MagickTrue; |
| 153 | if (LocaleCompare("debug",option+1) == 0) |
| 154 | (void) SetLogEventMask(argv[++i]); |
| 155 | if (LocaleCompare("duration",option+1) == 0) |
cristy | 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 | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 537 | (void) QueryColorCompliance(token,AllCompliance,&color,exception); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 538 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 539 | sparse_arguments[x++] = QuantumScale*color.red; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 540 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 541 | sparse_arguments[x++] = QuantumScale*color.green; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 542 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 543 | sparse_arguments[x++] = QuantumScale*color.blue; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 544 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 545 | (image->colorspace == CMYKColorspace)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 546 | sparse_arguments[x++] = QuantumScale*color.black; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 547 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 548 | (image->matte != MagickFalse)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 549 | sparse_arguments[x++] = QuantumScale*color.alpha; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 550 | } |
| 551 | else { |
| 552 | /* Colors given as a set of floating point values - experimental */ |
| 553 | /* NB: token contains the first floating point value to use! */ |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 554 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 555 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 556 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 557 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 558 | break; |
cristy | 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 | 092d71c | 2011-10-14 18:01:29 +0000 | [diff] [blame] | 1053 | (void) ClampImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1054 | break; |
| 1055 | } |
| 1056 | if (LocaleCompare("clip",option+1) == 0) |
| 1057 | { |
| 1058 | (void) SyncImageSettings(mogrify_info,*image); |
| 1059 | if (*option == '+') |
| 1060 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1061 | (void) SetImageClipMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1062 | break; |
| 1063 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1064 | (void) ClipImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1065 | break; |
| 1066 | } |
| 1067 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1068 | { |
| 1069 | CacheView |
| 1070 | *mask_view; |
| 1071 | |
| 1072 | Image |
| 1073 | *mask_image; |
| 1074 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1075 | register Quantum |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1076 | *restrict q; |
| 1077 | |
| 1078 | register ssize_t |
| 1079 | x; |
| 1080 | |
| 1081 | ssize_t |
| 1082 | y; |
| 1083 | |
| 1084 | (void) SyncImageSettings(mogrify_info,*image); |
| 1085 | if (*option == '+') |
| 1086 | { |
| 1087 | /* |
| 1088 | Remove a mask. |
| 1089 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1090 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1091 | break; |
| 1092 | } |
| 1093 | /* |
| 1094 | Set the image mask. |
| 1095 | FUTURE: This Should Be a SetImageAlphaChannel() call, Or two. |
| 1096 | */ |
| 1097 | mask_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1098 | if (mask_image == (Image *) NULL) |
| 1099 | break; |
cristy | 574cc26 | 2011-08-05 01:23:58 +0000 | [diff] [blame] | 1100 | if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1101 | return(MagickFalse); |
| 1102 | mask_view=AcquireCacheView(mask_image); |
| 1103 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1104 | { |
| 1105 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1106 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 1107 | if (q == (Quantum *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1108 | break; |
| 1109 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1110 | { |
| 1111 | if (mask_image->matte == MagickFalse) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1112 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 1113 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1114 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1115 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1116 | q+=GetPixelChannels(mask_image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1117 | } |
| 1118 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
| 1119 | break; |
| 1120 | } |
| 1121 | mask_view=DestroyCacheView(mask_view); |
| 1122 | mask_image->matte=MagickTrue; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1123 | (void) SetImageClipMask(*image,mask_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1124 | InheritException(exception,&(*image)->exception); |
| 1125 | break; |
| 1126 | } |
| 1127 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1128 | { |
| 1129 | (void) SyncImageSettings(mogrify_info,*image); |
| 1130 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1131 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1132 | break; |
| 1133 | } |
| 1134 | if (LocaleCompare("colorize",option+1) == 0) |
| 1135 | { |
| 1136 | /* |
| 1137 | Colorize the image. |
| 1138 | */ |
| 1139 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | c7e6ff6 | 2011-10-03 13:46:11 +0000 | [diff] [blame] | 1140 | mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1141 | break; |
| 1142 | } |
| 1143 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1144 | { |
| 1145 | KernelInfo |
| 1146 | *kernel; |
| 1147 | |
| 1148 | (void) SyncImageSettings(mogrify_info,*image); |
| 1149 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1150 | if (kernel == (KernelInfo *) NULL) |
| 1151 | break; |
| 1152 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 1153 | kernel=DestroyKernelInfo(kernel); |
| 1154 | break; |
| 1155 | } |
| 1156 | if (LocaleCompare("colors",option+1) == 0) |
| 1157 | { |
| 1158 | /* |
| 1159 | Reduce the number of colors in the image. |
| 1160 | */ |
| 1161 | (void) SyncImageSettings(mogrify_info,*image); |
| 1162 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
| 1163 | if (quantize_info->number_colors == 0) |
| 1164 | break; |
| 1165 | if (((*image)->storage_class == DirectClass) || |
| 1166 | (*image)->colors > quantize_info->number_colors) |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1167 | (void) QuantizeImage(quantize_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1168 | else |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1169 | (void) CompressImageColormap(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1170 | break; |
| 1171 | } |
| 1172 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1173 | { |
| 1174 | ColorspaceType |
| 1175 | colorspace; |
| 1176 | |
| 1177 | (void) SyncImageSettings(mogrify_info,*image); |
| 1178 | if (*option == '+') |
| 1179 | { |
| 1180 | (void) TransformImageColorspace(*image,RGBColorspace); |
| 1181 | InheritException(exception,&(*image)->exception); |
| 1182 | break; |
| 1183 | } |
| 1184 | colorspace=(ColorspaceType) ParseCommandOption( |
| 1185 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 1186 | (void) TransformImageColorspace(*image,colorspace); |
| 1187 | InheritException(exception,&(*image)->exception); |
| 1188 | break; |
| 1189 | } |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1190 | if (LocaleCompare("compose",option+1) == 0) |
| 1191 | { |
| 1192 | (void) SyncImageSettings(mogrify_info,*image); |
| 1193 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 1194 | MagickFalse,argv[i+1]); |
| 1195 | break; |
| 1196 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1197 | if (LocaleCompare("contrast",option+1) == 0) |
| 1198 | { |
| 1199 | (void) SyncImageSettings(mogrify_info,*image); |
| 1200 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1201 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1202 | break; |
| 1203 | } |
| 1204 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1205 | { |
| 1206 | double |
| 1207 | black_point, |
| 1208 | white_point; |
| 1209 | |
| 1210 | MagickStatusType |
| 1211 | flags; |
| 1212 | |
| 1213 | /* |
| 1214 | Contrast stretch image. |
| 1215 | */ |
| 1216 | (void) SyncImageSettings(mogrify_info,*image); |
| 1217 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1218 | black_point=geometry_info.rho; |
| 1219 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1220 | black_point; |
| 1221 | if ((flags & PercentValue) != 0) |
| 1222 | { |
| 1223 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1224 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1225 | } |
| 1226 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1227 | white_point; |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1228 | (void) ContrastStretchImage(*image,black_point,white_point, |
| 1229 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1230 | InheritException(exception,&(*image)->exception); |
| 1231 | break; |
| 1232 | } |
| 1233 | if (LocaleCompare("convolve",option+1) == 0) |
| 1234 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1235 | KernelInfo |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1236 | *kernel_info; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1237 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1238 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1239 | kernel_info=AcquireKernelInfo(argv[i+1]); |
| 1240 | if (kernel_info == (KernelInfo *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1241 | break; |
cristy | 0a92238 | 2011-07-16 15:30:34 +0000 | [diff] [blame] | 1242 | kernel_info->bias=(*image)->bias; |
cristy | 5e6be1e | 2011-07-16 01:23:39 +0000 | [diff] [blame] | 1243 | mogrify_image=ConvolveImage(*image,kernel_info,exception); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1244 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1245 | break; |
| 1246 | } |
| 1247 | if (LocaleCompare("crop",option+1) == 0) |
| 1248 | { |
| 1249 | /* |
| 1250 | Crop a image to a smaller size |
| 1251 | */ |
| 1252 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1253 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1254 | break; |
| 1255 | } |
| 1256 | if (LocaleCompare("cycle",option+1) == 0) |
| 1257 | { |
| 1258 | /* |
| 1259 | Cycle an image colormap. |
| 1260 | */ |
| 1261 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1262 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]), |
| 1263 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1264 | break; |
| 1265 | } |
| 1266 | break; |
| 1267 | } |
| 1268 | case 'd': |
| 1269 | { |
| 1270 | if (LocaleCompare("decipher",option+1) == 0) |
| 1271 | { |
| 1272 | StringInfo |
| 1273 | *passkey; |
| 1274 | |
| 1275 | /* |
| 1276 | Decipher pixels. |
| 1277 | */ |
| 1278 | (void) SyncImageSettings(mogrify_info,*image); |
| 1279 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1280 | if (passkey != (StringInfo *) NULL) |
| 1281 | { |
| 1282 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1283 | passkey=DestroyStringInfo(passkey); |
| 1284 | } |
| 1285 | break; |
| 1286 | } |
| 1287 | if (LocaleCompare("density",option+1) == 0) |
| 1288 | { |
| 1289 | /* |
| 1290 | Set image density. |
| 1291 | */ |
| 1292 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1293 | break; |
| 1294 | } |
| 1295 | if (LocaleCompare("depth",option+1) == 0) |
| 1296 | { |
| 1297 | (void) SyncImageSettings(mogrify_info,*image); |
| 1298 | if (*option == '+') |
| 1299 | { |
| 1300 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH); |
| 1301 | break; |
| 1302 | } |
| 1303 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1])); |
| 1304 | break; |
| 1305 | } |
| 1306 | if (LocaleCompare("deskew",option+1) == 0) |
| 1307 | { |
| 1308 | double |
| 1309 | threshold; |
| 1310 | |
| 1311 | /* |
| 1312 | Straighten the image. |
| 1313 | */ |
| 1314 | (void) SyncImageSettings(mogrify_info,*image); |
| 1315 | if (*option == '+') |
| 1316 | threshold=40.0*QuantumRange/100.0; |
| 1317 | else |
| 1318 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 1319 | mogrify_image=DeskewImage(*image,threshold,exception); |
| 1320 | break; |
| 1321 | } |
| 1322 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1323 | { |
| 1324 | /* |
| 1325 | Reduce the speckles within an image. |
| 1326 | */ |
| 1327 | (void) SyncImageSettings(mogrify_info,*image); |
| 1328 | mogrify_image=DespeckleImage(*image,exception); |
| 1329 | break; |
| 1330 | } |
| 1331 | if (LocaleCompare("display",option+1) == 0) |
| 1332 | { |
| 1333 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1334 | break; |
| 1335 | } |
| 1336 | if (LocaleCompare("distort",option+1) == 0) |
| 1337 | { |
| 1338 | char |
| 1339 | *args, |
| 1340 | token[MaxTextExtent]; |
| 1341 | |
| 1342 | const char |
| 1343 | *p; |
| 1344 | |
| 1345 | DistortImageMethod |
| 1346 | method; |
| 1347 | |
| 1348 | double |
| 1349 | *arguments; |
| 1350 | |
| 1351 | register ssize_t |
| 1352 | x; |
| 1353 | |
| 1354 | size_t |
| 1355 | number_arguments; |
| 1356 | |
| 1357 | /* |
| 1358 | Distort image. |
| 1359 | */ |
| 1360 | (void) SyncImageSettings(mogrify_info,*image); |
| 1361 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, |
| 1362 | MagickFalse,argv[i+1]); |
| 1363 | if ( method == ResizeDistortion ) |
| 1364 | { |
| 1365 | /* Special Case - Argument is actually a resize geometry! |
| 1366 | ** Convert that to an appropriate distortion argument array. |
| 1367 | */ |
| 1368 | double |
| 1369 | resize_args[2]; |
| 1370 | (void) ParseRegionGeometry(*image,argv[i+2],&geometry, |
| 1371 | exception); |
| 1372 | resize_args[0]=(double)geometry.width; |
| 1373 | resize_args[1]=(double)geometry.height; |
| 1374 | mogrify_image=DistortImage(*image,method,(size_t)2, |
| 1375 | resize_args,MagickTrue,exception); |
| 1376 | break; |
| 1377 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1378 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1379 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1380 | if (args == (char *) NULL) |
| 1381 | break; |
| 1382 | p=(char *) args; |
| 1383 | for (x=0; *p != '\0'; x++) |
| 1384 | { |
| 1385 | GetMagickToken(p,&p,token); |
| 1386 | if (*token == ',') |
| 1387 | GetMagickToken(p,&p,token); |
| 1388 | } |
| 1389 | number_arguments=(size_t) x; |
| 1390 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1391 | sizeof(*arguments)); |
| 1392 | if (arguments == (double *) NULL) |
| 1393 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1394 | "MemoryAllocationFailed",(*image)->filename); |
| 1395 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1396 | sizeof(*arguments)); |
| 1397 | p=(char *) args; |
| 1398 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 1399 | { |
| 1400 | GetMagickToken(p,&p,token); |
| 1401 | if (*token == ',') |
| 1402 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1403 | arguments[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1404 | } |
| 1405 | args=DestroyString(args); |
| 1406 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
| 1407 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1408 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1409 | break; |
| 1410 | } |
| 1411 | if (LocaleCompare("dither",option+1) == 0) |
| 1412 | { |
| 1413 | if (*option == '+') |
| 1414 | { |
| 1415 | quantize_info->dither=MagickFalse; |
| 1416 | break; |
| 1417 | } |
| 1418 | quantize_info->dither=MagickTrue; |
| 1419 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
| 1420 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1421 | if (quantize_info->dither_method == NoDitherMethod) |
| 1422 | quantize_info->dither=MagickFalse; |
| 1423 | break; |
| 1424 | } |
| 1425 | if (LocaleCompare("draw",option+1) == 0) |
| 1426 | { |
| 1427 | /* |
| 1428 | Draw image. |
| 1429 | */ |
| 1430 | (void) SyncImageSettings(mogrify_info,*image); |
| 1431 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1432 | (void) DrawImage(*image,draw_info,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1433 | break; |
| 1434 | } |
| 1435 | break; |
| 1436 | } |
| 1437 | case 'e': |
| 1438 | { |
| 1439 | if (LocaleCompare("edge",option+1) == 0) |
| 1440 | { |
| 1441 | /* |
| 1442 | Enhance edges in the image. |
| 1443 | */ |
| 1444 | (void) SyncImageSettings(mogrify_info,*image); |
| 1445 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1446 | if ((flags & SigmaValue) == 0) |
| 1447 | geometry_info.sigma=1.0; |
cristy | 8ae632d | 2011-09-05 17:29:53 +0000 | [diff] [blame] | 1448 | mogrify_image=EdgeImage(*image,geometry_info.rho, |
| 1449 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1450 | break; |
| 1451 | } |
| 1452 | if (LocaleCompare("emboss",option+1) == 0) |
| 1453 | { |
| 1454 | /* |
| 1455 | Gaussian embossen image. |
| 1456 | */ |
| 1457 | (void) SyncImageSettings(mogrify_info,*image); |
| 1458 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1459 | if ((flags & SigmaValue) == 0) |
| 1460 | geometry_info.sigma=1.0; |
| 1461 | mogrify_image=EmbossImage(*image,geometry_info.rho, |
| 1462 | geometry_info.sigma,exception); |
| 1463 | break; |
| 1464 | } |
| 1465 | if (LocaleCompare("encipher",option+1) == 0) |
| 1466 | { |
| 1467 | StringInfo |
| 1468 | *passkey; |
| 1469 | |
| 1470 | /* |
| 1471 | Encipher pixels. |
| 1472 | */ |
| 1473 | (void) SyncImageSettings(mogrify_info,*image); |
| 1474 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1475 | if (passkey != (StringInfo *) NULL) |
| 1476 | { |
| 1477 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1478 | passkey=DestroyStringInfo(passkey); |
| 1479 | } |
| 1480 | break; |
| 1481 | } |
| 1482 | if (LocaleCompare("encoding",option+1) == 0) |
| 1483 | { |
| 1484 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1485 | break; |
| 1486 | } |
| 1487 | if (LocaleCompare("enhance",option+1) == 0) |
| 1488 | { |
| 1489 | /* |
| 1490 | Enhance image. |
| 1491 | */ |
| 1492 | (void) SyncImageSettings(mogrify_info,*image); |
| 1493 | mogrify_image=EnhanceImage(*image,exception); |
| 1494 | break; |
| 1495 | } |
| 1496 | if (LocaleCompare("equalize",option+1) == 0) |
| 1497 | { |
| 1498 | /* |
| 1499 | Equalize image. |
| 1500 | */ |
| 1501 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 6d8c3d7 | 2011-08-22 01:20:01 +0000 | [diff] [blame] | 1502 | (void) EqualizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1503 | break; |
| 1504 | } |
| 1505 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1506 | { |
| 1507 | double |
| 1508 | constant; |
| 1509 | |
| 1510 | MagickEvaluateOperator |
| 1511 | op; |
| 1512 | |
| 1513 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1514 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 1515 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1516 | constant=SiPrefixToDouble(argv[i+2],QuantumRange); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1517 | (void) EvaluateImage(*image,op,constant,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1518 | break; |
| 1519 | } |
| 1520 | if (LocaleCompare("extent",option+1) == 0) |
| 1521 | { |
| 1522 | /* |
| 1523 | Set the image extent. |
| 1524 | */ |
| 1525 | (void) SyncImageSettings(mogrify_info,*image); |
| 1526 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1527 | if (geometry.width == 0) |
| 1528 | geometry.width=(*image)->columns; |
| 1529 | if (geometry.height == 0) |
| 1530 | geometry.height=(*image)->rows; |
| 1531 | mogrify_image=ExtentImage(*image,&geometry,exception); |
| 1532 | break; |
| 1533 | } |
| 1534 | break; |
| 1535 | } |
| 1536 | case 'f': |
| 1537 | { |
| 1538 | if (LocaleCompare("family",option+1) == 0) |
| 1539 | { |
| 1540 | if (*option == '+') |
| 1541 | { |
| 1542 | if (draw_info->family != (char *) NULL) |
| 1543 | draw_info->family=DestroyString(draw_info->family); |
| 1544 | break; |
| 1545 | } |
| 1546 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1547 | break; |
| 1548 | } |
| 1549 | if (LocaleCompare("features",option+1) == 0) |
| 1550 | { |
| 1551 | if (*option == '+') |
| 1552 | { |
| 1553 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1554 | break; |
| 1555 | } |
| 1556 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1557 | break; |
| 1558 | } |
| 1559 | if (LocaleCompare("fill",option+1) == 0) |
| 1560 | { |
| 1561 | ExceptionInfo |
| 1562 | *sans; |
| 1563 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1564 | GetPixelInfo(*image,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1565 | if (*option == '+') |
| 1566 | { |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1567 | (void) QueryColorCompliance("none",AllCompliance,&fill, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1568 | exception); |
| 1569 | (void) QueryColorCompliance("none",AllCompliance, |
| 1570 | &draw_info->fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1571 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1572 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1573 | break; |
| 1574 | } |
| 1575 | sans=AcquireExceptionInfo(); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1576 | (void) QueryColorCompliance(argv[i+1],AllCompliance,&fill, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1577 | sans); |
| 1578 | status=QueryColorCompliance(argv[i+1],AllCompliance, |
| 1579 | &draw_info->fill,sans); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1580 | sans=DestroyExceptionInfo(sans); |
| 1581 | if (status == MagickFalse) |
| 1582 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 1583 | exception); |
| 1584 | break; |
| 1585 | } |
| 1586 | if (LocaleCompare("flip",option+1) == 0) |
| 1587 | { |
| 1588 | /* |
| 1589 | Flip image scanlines. |
| 1590 | */ |
| 1591 | (void) SyncImageSettings(mogrify_info,*image); |
| 1592 | mogrify_image=FlipImage(*image,exception); |
| 1593 | break; |
| 1594 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1595 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1596 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1597 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1598 | target; |
| 1599 | |
| 1600 | /* |
| 1601 | Floodfill image. |
| 1602 | */ |
| 1603 | (void) SyncImageSettings(mogrify_info,*image); |
| 1604 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1605 | (void) QueryColorCompliance(argv[i+2],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1606 | exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1607 | (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x, |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 1608 | geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1609 | break; |
| 1610 | } |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1611 | if (LocaleCompare("flop",option+1) == 0) |
| 1612 | { |
| 1613 | /* |
| 1614 | Flop image scanlines. |
| 1615 | */ |
| 1616 | (void) SyncImageSettings(mogrify_info,*image); |
| 1617 | mogrify_image=FlopImage(*image,exception); |
| 1618 | break; |
| 1619 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1620 | if (LocaleCompare("font",option+1) == 0) |
| 1621 | { |
| 1622 | if (*option == '+') |
| 1623 | { |
| 1624 | if (draw_info->font != (char *) NULL) |
| 1625 | draw_info->font=DestroyString(draw_info->font); |
| 1626 | break; |
| 1627 | } |
| 1628 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1629 | break; |
| 1630 | } |
| 1631 | if (LocaleCompare("format",option+1) == 0) |
| 1632 | { |
| 1633 | format=argv[i+1]; |
| 1634 | break; |
| 1635 | } |
| 1636 | if (LocaleCompare("frame",option+1) == 0) |
| 1637 | { |
| 1638 | FrameInfo |
| 1639 | frame_info; |
| 1640 | |
| 1641 | /* |
| 1642 | Surround image with an ornamental border. |
| 1643 | */ |
| 1644 | (void) SyncImageSettings(mogrify_info,*image); |
| 1645 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1646 | frame_info.width=geometry.width; |
| 1647 | frame_info.height=geometry.height; |
| 1648 | if ((flags & HeightValue) == 0) |
| 1649 | frame_info.height=geometry.width; |
| 1650 | frame_info.outer_bevel=geometry.x; |
| 1651 | frame_info.inner_bevel=geometry.y; |
| 1652 | frame_info.x=(ssize_t) frame_info.width; |
| 1653 | frame_info.y=(ssize_t) frame_info.height; |
| 1654 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1655 | frame_info.height=(*image)->rows+2*frame_info.height; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1656 | mogrify_image=FrameImage(*image,&frame_info,compose,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1657 | break; |
| 1658 | } |
| 1659 | if (LocaleCompare("function",option+1) == 0) |
| 1660 | { |
| 1661 | char |
| 1662 | *arguments, |
| 1663 | token[MaxTextExtent]; |
| 1664 | |
| 1665 | const char |
| 1666 | *p; |
| 1667 | |
| 1668 | double |
| 1669 | *parameters; |
| 1670 | |
| 1671 | MagickFunction |
| 1672 | function; |
| 1673 | |
| 1674 | register ssize_t |
| 1675 | x; |
| 1676 | |
| 1677 | size_t |
| 1678 | number_parameters; |
| 1679 | |
| 1680 | /* |
| 1681 | Function Modify Image Values |
| 1682 | */ |
| 1683 | (void) SyncImageSettings(mogrify_info,*image); |
| 1684 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, |
| 1685 | MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1686 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1687 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1688 | if (arguments == (char *) NULL) |
| 1689 | break; |
| 1690 | p=(char *) arguments; |
| 1691 | for (x=0; *p != '\0'; x++) |
| 1692 | { |
| 1693 | GetMagickToken(p,&p,token); |
| 1694 | if (*token == ',') |
| 1695 | GetMagickToken(p,&p,token); |
| 1696 | } |
| 1697 | number_parameters=(size_t) x; |
| 1698 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1699 | sizeof(*parameters)); |
| 1700 | if (parameters == (double *) NULL) |
| 1701 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1702 | "MemoryAllocationFailed",(*image)->filename); |
| 1703 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1704 | sizeof(*parameters)); |
| 1705 | p=(char *) arguments; |
| 1706 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
| 1707 | { |
| 1708 | GetMagickToken(p,&p,token); |
| 1709 | if (*token == ',') |
| 1710 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1711 | parameters[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1712 | } |
| 1713 | arguments=DestroyString(arguments); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1714 | (void) FunctionImage(*image,function,number_parameters,parameters, |
| 1715 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1716 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1717 | break; |
| 1718 | } |
| 1719 | break; |
| 1720 | } |
| 1721 | case 'g': |
| 1722 | { |
| 1723 | if (LocaleCompare("gamma",option+1) == 0) |
| 1724 | { |
| 1725 | /* |
| 1726 | Gamma image. |
| 1727 | */ |
| 1728 | (void) SyncImageSettings(mogrify_info,*image); |
| 1729 | if (*option == '+') |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1730 | (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1731 | else |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 1732 | (void) GammaImage(*image,InterpretLocaleValue(argv[i+1], |
| 1733 | (char **) NULL),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1734 | break; |
| 1735 | } |
| 1736 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1737 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1738 | { |
| 1739 | /* |
| 1740 | Gaussian blur image. |
| 1741 | */ |
| 1742 | (void) SyncImageSettings(mogrify_info,*image); |
| 1743 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1744 | if ((flags & SigmaValue) == 0) |
| 1745 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1746 | if ((flags & XiValue) == 0) |
| 1747 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1748 | mogrify_image=GaussianBlurImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1749 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1750 | break; |
| 1751 | } |
| 1752 | if (LocaleCompare("geometry",option+1) == 0) |
| 1753 | { |
| 1754 | /* |
| 1755 | Record Image offset, Resize last image. |
| 1756 | */ |
| 1757 | (void) SyncImageSettings(mogrify_info,*image); |
| 1758 | if (*option == '+') |
| 1759 | { |
| 1760 | if ((*image)->geometry != (char *) NULL) |
| 1761 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1762 | break; |
| 1763 | } |
| 1764 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1765 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1766 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1767 | else |
| 1768 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 1769 | (*image)->filter,(*image)->blur,exception); |
| 1770 | break; |
| 1771 | } |
| 1772 | if (LocaleCompare("gravity",option+1) == 0) |
| 1773 | { |
| 1774 | if (*option == '+') |
| 1775 | { |
| 1776 | draw_info->gravity=UndefinedGravity; |
| 1777 | break; |
| 1778 | } |
| 1779 | draw_info->gravity=(GravityType) ParseCommandOption( |
| 1780 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1781 | break; |
| 1782 | } |
| 1783 | break; |
| 1784 | } |
| 1785 | case 'h': |
| 1786 | { |
| 1787 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1788 | { |
| 1789 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1790 | break; |
| 1791 | } |
| 1792 | break; |
| 1793 | } |
| 1794 | case 'i': |
| 1795 | { |
| 1796 | if (LocaleCompare("identify",option+1) == 0) |
| 1797 | { |
| 1798 | char |
| 1799 | *text; |
| 1800 | |
| 1801 | (void) SyncImageSettings(mogrify_info,*image); |
| 1802 | if (format == (char *) NULL) |
| 1803 | { |
cristy | a403727 | 2011-08-28 15:11:39 +0000 | [diff] [blame] | 1804 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose, |
| 1805 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1806 | break; |
| 1807 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1808 | text=InterpretImageProperties(mogrify_info,*image,format, |
| 1809 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1810 | if (text == (char *) NULL) |
| 1811 | break; |
| 1812 | (void) fputs(text,stdout); |
| 1813 | (void) fputc('\n',stdout); |
| 1814 | text=DestroyString(text); |
| 1815 | break; |
| 1816 | } |
| 1817 | if (LocaleCompare("implode",option+1) == 0) |
| 1818 | { |
| 1819 | /* |
| 1820 | Implode image. |
| 1821 | */ |
| 1822 | (void) SyncImageSettings(mogrify_info,*image); |
| 1823 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 76f512e | 2011-09-12 01:26:56 +0000 | [diff] [blame] | 1824 | mogrify_image=ImplodeImage(*image,geometry_info.rho, |
| 1825 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1826 | break; |
| 1827 | } |
| 1828 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1829 | { |
| 1830 | if (*option == '+') |
| 1831 | (void) ParseGeometry("0",&geometry_info); |
| 1832 | else |
| 1833 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1834 | draw_info->interline_spacing=geometry_info.rho; |
| 1835 | break; |
| 1836 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 1837 | if (LocaleCompare("interpolate",option+1) == 0) |
| 1838 | { |
| 1839 | interpolate_method=(PixelInterpolateMethod) ParseCommandOption( |
| 1840 | MagickInterpolateOptions,MagickFalse,argv[i+1]); |
| 1841 | break; |
| 1842 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1843 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1844 | { |
| 1845 | if (*option == '+') |
| 1846 | (void) ParseGeometry("0",&geometry_info); |
| 1847 | else |
| 1848 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1849 | draw_info->interword_spacing=geometry_info.rho; |
| 1850 | break; |
| 1851 | } |
| 1852 | break; |
| 1853 | } |
| 1854 | case 'k': |
| 1855 | { |
| 1856 | if (LocaleCompare("kerning",option+1) == 0) |
| 1857 | { |
| 1858 | if (*option == '+') |
| 1859 | (void) ParseGeometry("0",&geometry_info); |
| 1860 | else |
| 1861 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1862 | draw_info->kerning=geometry_info.rho; |
| 1863 | break; |
| 1864 | } |
| 1865 | break; |
| 1866 | } |
| 1867 | case 'l': |
| 1868 | { |
| 1869 | if (LocaleCompare("lat",option+1) == 0) |
| 1870 | { |
| 1871 | /* |
| 1872 | Local adaptive threshold image. |
| 1873 | */ |
| 1874 | (void) SyncImageSettings(mogrify_info,*image); |
| 1875 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1876 | if ((flags & PercentValue) != 0) |
| 1877 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 1878 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
cristy | de5cc63 | 2011-07-18 14:47:00 +0000 | [diff] [blame] | 1879 | geometry_info.rho,(size_t) geometry_info.sigma,(double) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1880 | geometry_info.xi,exception); |
| 1881 | break; |
| 1882 | } |
| 1883 | if (LocaleCompare("level",option+1) == 0) |
| 1884 | { |
| 1885 | MagickRealType |
| 1886 | black_point, |
| 1887 | gamma, |
| 1888 | white_point; |
| 1889 | |
| 1890 | MagickStatusType |
| 1891 | flags; |
| 1892 | |
| 1893 | /* |
| 1894 | Parse levels. |
| 1895 | */ |
| 1896 | (void) SyncImageSettings(mogrify_info,*image); |
| 1897 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1898 | black_point=geometry_info.rho; |
| 1899 | white_point=(MagickRealType) QuantumRange; |
| 1900 | if ((flags & SigmaValue) != 0) |
| 1901 | white_point=geometry_info.sigma; |
| 1902 | gamma=1.0; |
| 1903 | if ((flags & XiValue) != 0) |
| 1904 | gamma=geometry_info.xi; |
| 1905 | if ((flags & PercentValue) != 0) |
| 1906 | { |
| 1907 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 1908 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 1909 | } |
| 1910 | if ((flags & SigmaValue) == 0) |
| 1911 | white_point=(MagickRealType) QuantumRange-black_point; |
| 1912 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1913 | (void) LevelizeImage(*image,black_point,white_point,gamma, |
| 1914 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1915 | else |
cristy | 01e9afd | 2011-08-10 17:38:41 +0000 | [diff] [blame] | 1916 | (void) LevelImage(*image,black_point,white_point,gamma, |
| 1917 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1918 | InheritException(exception,&(*image)->exception); |
| 1919 | break; |
| 1920 | } |
| 1921 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1922 | { |
| 1923 | char |
| 1924 | token[MaxTextExtent]; |
| 1925 | |
| 1926 | const char |
| 1927 | *p; |
| 1928 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1929 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1930 | black_point, |
| 1931 | white_point; |
| 1932 | |
| 1933 | p=(const char *) argv[i+1]; |
| 1934 | GetMagickToken(p,&p,token); /* get black point color */ |
| 1935 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1936 | (void) QueryColorCompliance(token,AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1937 | &black_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1938 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1939 | (void) QueryColorCompliance("#000000",AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1940 | &black_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1941 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1942 | GetMagickToken(p,&p,token); |
| 1943 | if (*token == '\0') |
| 1944 | white_point=black_point; /* set everything to that color */ |
| 1945 | else |
| 1946 | { |
| 1947 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 1948 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 1949 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1950 | (void) QueryColorCompliance(token,AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1951 | &white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1952 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1953 | (void) QueryColorCompliance("#ffffff",AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1954 | &white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1955 | } |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 1956 | (void) LevelImageColors(*image,&black_point,&white_point, |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1957 | *option == '+' ? MagickTrue : MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1958 | break; |
| 1959 | } |
| 1960 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 1961 | { |
| 1962 | double |
| 1963 | black_point, |
| 1964 | white_point; |
| 1965 | |
| 1966 | MagickStatusType |
| 1967 | flags; |
| 1968 | |
| 1969 | (void) SyncImageSettings(mogrify_info,*image); |
| 1970 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1971 | black_point=geometry_info.rho; |
| 1972 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 1973 | if ((flags & SigmaValue) != 0) |
| 1974 | white_point=geometry_info.sigma; |
| 1975 | if ((flags & PercentValue) != 0) |
| 1976 | { |
| 1977 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1978 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1979 | } |
| 1980 | if ((flags & SigmaValue) == 0) |
| 1981 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1982 | black_point; |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 1983 | (void) LinearStretchImage(*image,black_point,white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1984 | InheritException(exception,&(*image)->exception); |
| 1985 | break; |
| 1986 | } |
| 1987 | if (LocaleCompare("linewidth",option+1) == 0) |
| 1988 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1989 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 1990 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1991 | break; |
| 1992 | } |
| 1993 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 1994 | { |
| 1995 | /* |
| 1996 | Liquid rescale image. |
| 1997 | */ |
| 1998 | (void) SyncImageSettings(mogrify_info,*image); |
| 1999 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2000 | if ((flags & XValue) == 0) |
| 2001 | geometry.x=1; |
| 2002 | if ((flags & YValue) == 0) |
| 2003 | geometry.y=0; |
| 2004 | mogrify_image=LiquidRescaleImage(*image,geometry.width, |
| 2005 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 2006 | break; |
| 2007 | } |
| 2008 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 2009 | { |
| 2010 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 2011 | break; |
| 2012 | } |
| 2013 | break; |
| 2014 | } |
| 2015 | case 'm': |
| 2016 | { |
| 2017 | if (LocaleCompare("map",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2018 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2019 | Image |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2020 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2021 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2022 | /* |
| 2023 | Transform image colors to match this set of colors. |
| 2024 | */ |
| 2025 | (void) SyncImageSettings(mogrify_info,*image); |
| 2026 | if (*option == '+') |
| 2027 | break; |
| 2028 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2029 | if (remap_image == (Image *) NULL) |
| 2030 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2031 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2032 | remap_image=DestroyImage(remap_image); |
| 2033 | break; |
| 2034 | } |
| 2035 | if (LocaleCompare("mask",option+1) == 0) |
| 2036 | { |
| 2037 | Image |
| 2038 | *mask; |
| 2039 | |
| 2040 | (void) SyncImageSettings(mogrify_info,*image); |
| 2041 | if (*option == '+') |
| 2042 | { |
| 2043 | /* |
| 2044 | Remove a mask. |
| 2045 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2046 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2047 | break; |
| 2048 | } |
| 2049 | /* |
| 2050 | Set the image mask. |
| 2051 | */ |
| 2052 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2053 | if (mask == (Image *) NULL) |
| 2054 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2055 | (void) SetImageMask(*image,mask,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2056 | mask=DestroyImage(mask); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2057 | break; |
| 2058 | } |
| 2059 | if (LocaleCompare("matte",option+1) == 0) |
| 2060 | { |
| 2061 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 2062 | SetAlphaChannel : DeactivateAlphaChannel,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2063 | break; |
| 2064 | } |
| 2065 | if (LocaleCompare("median",option+1) == 0) |
| 2066 | { |
| 2067 | /* |
| 2068 | Median filter image. |
| 2069 | */ |
| 2070 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2071 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2072 | if ((flags & SigmaValue) == 0) |
| 2073 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2074 | mogrify_image=StatisticImage(*image,MedianStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2075 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2076 | break; |
| 2077 | } |
| 2078 | if (LocaleCompare("mode",option+1) == 0) |
| 2079 | { |
| 2080 | /* |
| 2081 | Mode image. |
| 2082 | */ |
| 2083 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2084 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2085 | if ((flags & SigmaValue) == 0) |
| 2086 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2087 | mogrify_image=StatisticImage(*image,ModeStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2088 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2089 | break; |
| 2090 | } |
| 2091 | if (LocaleCompare("modulate",option+1) == 0) |
| 2092 | { |
| 2093 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2094 | (void) ModulateImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2095 | break; |
| 2096 | } |
| 2097 | if (LocaleCompare("monitor",option+1) == 0) |
| 2098 | { |
| 2099 | if (*option == '+') |
| 2100 | { |
| 2101 | (void) SetImageProgressMonitor(*image, |
| 2102 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2103 | break; |
| 2104 | } |
| 2105 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2106 | (void *) NULL); |
| 2107 | break; |
| 2108 | } |
| 2109 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2110 | { |
| 2111 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2112 | (void) SetImageType(*image,BilevelType,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2113 | break; |
| 2114 | } |
| 2115 | if (LocaleCompare("morphology",option+1) == 0) |
| 2116 | { |
| 2117 | char |
| 2118 | token[MaxTextExtent]; |
| 2119 | |
| 2120 | const char |
| 2121 | *p; |
| 2122 | |
| 2123 | KernelInfo |
| 2124 | *kernel; |
| 2125 | |
| 2126 | MorphologyMethod |
| 2127 | method; |
| 2128 | |
| 2129 | ssize_t |
| 2130 | iterations; |
| 2131 | |
| 2132 | /* |
| 2133 | Morphological Image Operation |
| 2134 | */ |
| 2135 | (void) SyncImageSettings(mogrify_info,*image); |
| 2136 | p=argv[i+1]; |
| 2137 | GetMagickToken(p,&p,token); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2138 | method=(MorphologyMethod) ParseCommandOption( |
| 2139 | MagickMorphologyOptions,MagickFalse,token); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2140 | iterations=1L; |
| 2141 | GetMagickToken(p,&p,token); |
| 2142 | if ((*p == ':') || (*p == ',')) |
| 2143 | GetMagickToken(p,&p,token); |
| 2144 | if ((*p != '\0')) |
| 2145 | iterations=(ssize_t) StringToLong(p); |
| 2146 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2147 | if (kernel == (KernelInfo *) NULL) |
| 2148 | { |
| 2149 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2150 | OptionError,"UnabletoParseKernel","morphology"); |
| 2151 | status=MagickFalse; |
| 2152 | break; |
| 2153 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2154 | mogrify_image=MorphologyImage(*image,method,iterations,kernel, |
| 2155 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2156 | kernel=DestroyKernelInfo(kernel); |
| 2157 | break; |
| 2158 | } |
| 2159 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2160 | { |
| 2161 | /* |
| 2162 | Motion blur image. |
| 2163 | */ |
| 2164 | (void) SyncImageSettings(mogrify_info,*image); |
| 2165 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2166 | if ((flags & SigmaValue) == 0) |
| 2167 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2168 | mogrify_image=MotionBlurImage(*image,geometry_info.rho, |
cristy | f7ef025 | 2011-09-09 14:50:06 +0000 | [diff] [blame] | 2169 | geometry_info.sigma,geometry_info.xi,geometry_info.psi, |
| 2170 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2171 | break; |
| 2172 | } |
| 2173 | break; |
| 2174 | } |
| 2175 | case 'n': |
| 2176 | { |
| 2177 | if (LocaleCompare("negate",option+1) == 0) |
| 2178 | { |
| 2179 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2180 | (void) NegateImage(*image,*option == '+' ? MagickTrue : |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 2181 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2182 | break; |
| 2183 | } |
| 2184 | if (LocaleCompare("noise",option+1) == 0) |
| 2185 | { |
| 2186 | (void) SyncImageSettings(mogrify_info,*image); |
| 2187 | if (*option == '-') |
| 2188 | { |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2189 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2190 | if ((flags & SigmaValue) == 0) |
| 2191 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2192 | mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2193 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2194 | } |
| 2195 | else |
| 2196 | { |
| 2197 | NoiseType |
| 2198 | noise; |
| 2199 | |
| 2200 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
| 2201 | MagickFalse,argv[i+1]); |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 2202 | mogrify_image=AddNoiseImage(*image,noise,attenuate,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2203 | } |
| 2204 | break; |
| 2205 | } |
| 2206 | if (LocaleCompare("normalize",option+1) == 0) |
| 2207 | { |
| 2208 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 2209 | (void) NormalizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2210 | break; |
| 2211 | } |
| 2212 | break; |
| 2213 | } |
| 2214 | case 'o': |
| 2215 | { |
| 2216 | if (LocaleCompare("opaque",option+1) == 0) |
| 2217 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2218 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2219 | target; |
| 2220 | |
| 2221 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2222 | (void) QueryColorCompliance(argv[i+1],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2223 | exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 2224 | (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ? |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 2225 | MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2226 | break; |
| 2227 | } |
| 2228 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2229 | { |
| 2230 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 1302067 | 2011-07-08 02:33:26 +0000 | [diff] [blame] | 2231 | (void) OrderedPosterizeImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2232 | break; |
| 2233 | } |
| 2234 | break; |
| 2235 | } |
| 2236 | case 'p': |
| 2237 | { |
| 2238 | if (LocaleCompare("paint",option+1) == 0) |
| 2239 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2240 | (void) SyncImageSettings(mogrify_info,*image); |
| 2241 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 14973ba | 2011-08-27 23:48:07 +0000 | [diff] [blame] | 2242 | mogrify_image=OilPaintImage(*image,geometry_info.rho, |
| 2243 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2244 | break; |
| 2245 | } |
| 2246 | if (LocaleCompare("pen",option+1) == 0) |
| 2247 | { |
| 2248 | if (*option == '+') |
| 2249 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2250 | (void) QueryColorCompliance("none",AllCompliance, |
| 2251 | &draw_info->fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2252 | break; |
| 2253 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2254 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 2255 | &draw_info->fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2256 | break; |
| 2257 | } |
| 2258 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2259 | { |
| 2260 | if (*option == '+') |
| 2261 | (void) ParseGeometry("12",&geometry_info); |
| 2262 | else |
| 2263 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2264 | draw_info->pointsize=geometry_info.rho; |
| 2265 | break; |
| 2266 | } |
| 2267 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2268 | { |
| 2269 | double |
| 2270 | angle; |
| 2271 | |
| 2272 | RandomInfo |
| 2273 | *random_info; |
| 2274 | |
| 2275 | /* |
| 2276 | Simulate a Polaroid picture. |
| 2277 | */ |
| 2278 | (void) SyncImageSettings(mogrify_info,*image); |
| 2279 | random_info=AcquireRandomInfo(); |
| 2280 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2281 | random_info=DestroyRandomInfo(random_info); |
| 2282 | if (*option == '-') |
| 2283 | { |
| 2284 | SetGeometryInfo(&geometry_info); |
| 2285 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2286 | angle=geometry_info.rho; |
| 2287 | } |
cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame] | 2288 | mogrify_image=PolaroidImage(*image,draw_info,angle, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2289 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2290 | break; |
| 2291 | } |
| 2292 | if (LocaleCompare("posterize",option+1) == 0) |
| 2293 | { |
| 2294 | /* |
| 2295 | Posterize image. |
| 2296 | */ |
| 2297 | (void) SyncImageSettings(mogrify_info,*image); |
| 2298 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2299 | quantize_info->dither,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2300 | break; |
| 2301 | } |
| 2302 | if (LocaleCompare("preview",option+1) == 0) |
| 2303 | { |
| 2304 | PreviewType |
| 2305 | preview_type; |
| 2306 | |
| 2307 | /* |
| 2308 | Preview image. |
| 2309 | */ |
| 2310 | (void) SyncImageSettings(mogrify_info,*image); |
| 2311 | if (*option == '+') |
| 2312 | preview_type=UndefinedPreview; |
| 2313 | else |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2314 | preview_type=(PreviewType) ParseCommandOption( |
| 2315 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2316 | mogrify_image=PreviewImage(*image,preview_type,exception); |
| 2317 | break; |
| 2318 | } |
| 2319 | if (LocaleCompare("profile",option+1) == 0) |
| 2320 | { |
| 2321 | const char |
| 2322 | *name; |
| 2323 | |
| 2324 | const StringInfo |
| 2325 | *profile; |
| 2326 | |
| 2327 | Image |
| 2328 | *profile_image; |
| 2329 | |
| 2330 | ImageInfo |
| 2331 | *profile_info; |
| 2332 | |
| 2333 | (void) SyncImageSettings(mogrify_info,*image); |
| 2334 | if (*option == '+') |
| 2335 | { |
| 2336 | /* |
| 2337 | Remove a profile from the image. |
| 2338 | */ |
| 2339 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
cristy | 092d71c | 2011-10-14 18:01:29 +0000 | [diff] [blame] | 2340 | NULL,0,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2341 | break; |
| 2342 | } |
| 2343 | /* |
| 2344 | Associate a profile with the image. |
| 2345 | */ |
| 2346 | profile_info=CloneImageInfo(mogrify_info); |
| 2347 | profile=GetImageProfile(*image,"iptc"); |
| 2348 | if (profile != (StringInfo *) NULL) |
| 2349 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2350 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2351 | profile_info=DestroyImageInfo(profile_info); |
| 2352 | if (profile_image == (Image *) NULL) |
| 2353 | { |
| 2354 | StringInfo |
| 2355 | *profile; |
| 2356 | |
| 2357 | profile_info=CloneImageInfo(mogrify_info); |
| 2358 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2359 | MaxTextExtent); |
| 2360 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
| 2361 | if (profile != (StringInfo *) NULL) |
| 2362 | { |
| 2363 | (void) ProfileImage(*image,profile_info->magick, |
| 2364 | GetStringInfoDatum(profile),(size_t) |
| 2365 | GetStringInfoLength(profile),MagickFalse); |
| 2366 | profile=DestroyStringInfo(profile); |
| 2367 | } |
| 2368 | profile_info=DestroyImageInfo(profile_info); |
| 2369 | break; |
| 2370 | } |
| 2371 | ResetImageProfileIterator(profile_image); |
| 2372 | name=GetNextImageProfile(profile_image); |
| 2373 | while (name != (const char *) NULL) |
| 2374 | { |
| 2375 | profile=GetImageProfile(profile_image,name); |
| 2376 | if (profile != (StringInfo *) NULL) |
| 2377 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
| 2378 | (size_t) GetStringInfoLength(profile),MagickFalse); |
| 2379 | name=GetNextImageProfile(profile_image); |
| 2380 | } |
| 2381 | profile_image=DestroyImage(profile_image); |
| 2382 | break; |
| 2383 | } |
| 2384 | break; |
| 2385 | } |
| 2386 | case 'q': |
| 2387 | { |
| 2388 | if (LocaleCompare("quantize",option+1) == 0) |
| 2389 | { |
| 2390 | if (*option == '+') |
| 2391 | { |
| 2392 | quantize_info->colorspace=UndefinedColorspace; |
| 2393 | break; |
| 2394 | } |
| 2395 | quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
| 2396 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2397 | break; |
| 2398 | } |
| 2399 | break; |
| 2400 | } |
| 2401 | case 'r': |
| 2402 | { |
| 2403 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2404 | { |
| 2405 | /* |
| 2406 | Radial blur image. |
| 2407 | */ |
| 2408 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 6435bd9 | 2011-09-10 02:10:07 +0000 | [diff] [blame] | 2409 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2410 | mogrify_image=RadialBlurImage(*image,geometry_info.rho, |
| 2411 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2412 | break; |
| 2413 | } |
| 2414 | if (LocaleCompare("raise",option+1) == 0) |
| 2415 | { |
| 2416 | /* |
| 2417 | Surround image with a raise of solid color. |
| 2418 | */ |
| 2419 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2420 | if ((flags & SigmaValue) == 0) |
| 2421 | geometry.height=geometry.width; |
| 2422 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
cristy | 6170ac3 | 2011-08-28 14:15:37 +0000 | [diff] [blame] | 2423 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2424 | break; |
| 2425 | } |
| 2426 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2427 | { |
| 2428 | /* |
| 2429 | Threshold image. |
| 2430 | */ |
| 2431 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2432 | (void) RandomThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2433 | break; |
| 2434 | } |
| 2435 | if (LocaleCompare("recolor",option+1) == 0) |
| 2436 | { |
| 2437 | KernelInfo |
| 2438 | *kernel; |
| 2439 | |
| 2440 | (void) SyncImageSettings(mogrify_info,*image); |
| 2441 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2442 | if (kernel == (KernelInfo *) NULL) |
| 2443 | break; |
| 2444 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 2445 | kernel=DestroyKernelInfo(kernel); |
| 2446 | break; |
| 2447 | } |
| 2448 | if (LocaleCompare("region",option+1) == 0) |
| 2449 | { |
| 2450 | (void) SyncImageSettings(mogrify_info,*image); |
| 2451 | if (region_image != (Image *) NULL) |
| 2452 | { |
| 2453 | /* |
| 2454 | Composite region. |
| 2455 | */ |
| 2456 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2457 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 2458 | region_geometry.x,region_geometry.y); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2459 | InheritException(exception,®ion_image->exception); |
| 2460 | *image=DestroyImage(*image); |
| 2461 | *image=region_image; |
| 2462 | region_image = (Image *) NULL; |
| 2463 | } |
| 2464 | if (*option == '+') |
| 2465 | break; |
| 2466 | /* |
| 2467 | Apply transformations to a selected region of the image. |
| 2468 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2469 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2470 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2471 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2472 | if (mogrify_image == (Image *) NULL) |
| 2473 | break; |
| 2474 | region_image=(*image); |
| 2475 | *image=mogrify_image; |
| 2476 | mogrify_image=(Image *) NULL; |
| 2477 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2478 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2479 | if (LocaleCompare("render",option+1) == 0) |
| 2480 | { |
| 2481 | (void) SyncImageSettings(mogrify_info,*image); |
| 2482 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2483 | break; |
| 2484 | } |
| 2485 | if (LocaleCompare("remap",option+1) == 0) |
| 2486 | { |
| 2487 | Image |
| 2488 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2489 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2490 | /* |
| 2491 | Transform image colors to match this set of colors. |
| 2492 | */ |
| 2493 | (void) SyncImageSettings(mogrify_info,*image); |
| 2494 | if (*option == '+') |
| 2495 | break; |
| 2496 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2497 | if (remap_image == (Image *) NULL) |
| 2498 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2499 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2500 | remap_image=DestroyImage(remap_image); |
| 2501 | break; |
| 2502 | } |
| 2503 | if (LocaleCompare("repage",option+1) == 0) |
| 2504 | { |
| 2505 | if (*option == '+') |
| 2506 | { |
| 2507 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2508 | break; |
| 2509 | } |
| 2510 | (void) ResetImagePage(*image,argv[i+1]); |
| 2511 | InheritException(exception,&(*image)->exception); |
| 2512 | break; |
| 2513 | } |
| 2514 | if (LocaleCompare("resample",option+1) == 0) |
| 2515 | { |
| 2516 | /* |
| 2517 | Resample image. |
| 2518 | */ |
| 2519 | (void) SyncImageSettings(mogrify_info,*image); |
| 2520 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2521 | if ((flags & SigmaValue) == 0) |
| 2522 | geometry_info.sigma=geometry_info.rho; |
| 2523 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
| 2524 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2525 | break; |
| 2526 | } |
| 2527 | if (LocaleCompare("resize",option+1) == 0) |
| 2528 | { |
| 2529 | /* |
| 2530 | Resize image. |
| 2531 | */ |
| 2532 | (void) SyncImageSettings(mogrify_info,*image); |
| 2533 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2534 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2535 | (*image)->filter,(*image)->blur,exception); |
| 2536 | break; |
| 2537 | } |
| 2538 | if (LocaleCompare("roll",option+1) == 0) |
| 2539 | { |
| 2540 | /* |
| 2541 | Roll image. |
| 2542 | */ |
| 2543 | (void) SyncImageSettings(mogrify_info,*image); |
| 2544 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2545 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2546 | break; |
| 2547 | } |
| 2548 | if (LocaleCompare("rotate",option+1) == 0) |
| 2549 | { |
| 2550 | char |
| 2551 | *geometry; |
| 2552 | |
| 2553 | /* |
| 2554 | Check for conditional image rotation. |
| 2555 | */ |
| 2556 | (void) SyncImageSettings(mogrify_info,*image); |
| 2557 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2558 | if ((*image)->columns <= (*image)->rows) |
| 2559 | break; |
| 2560 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2561 | if ((*image)->columns >= (*image)->rows) |
| 2562 | break; |
| 2563 | /* |
| 2564 | Rotate image. |
| 2565 | */ |
| 2566 | geometry=ConstantString(argv[i+1]); |
| 2567 | (void) SubstituteString(&geometry,">",""); |
| 2568 | (void) SubstituteString(&geometry,"<",""); |
| 2569 | (void) ParseGeometry(geometry,&geometry_info); |
| 2570 | geometry=DestroyString(geometry); |
| 2571 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
| 2572 | break; |
| 2573 | } |
| 2574 | break; |
| 2575 | } |
| 2576 | case 's': |
| 2577 | { |
| 2578 | if (LocaleCompare("sample",option+1) == 0) |
| 2579 | { |
| 2580 | /* |
| 2581 | Sample image with pixel replication. |
| 2582 | */ |
| 2583 | (void) SyncImageSettings(mogrify_info,*image); |
| 2584 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2585 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
| 2586 | exception); |
| 2587 | break; |
| 2588 | } |
| 2589 | if (LocaleCompare("scale",option+1) == 0) |
| 2590 | { |
| 2591 | /* |
| 2592 | Resize image. |
| 2593 | */ |
| 2594 | (void) SyncImageSettings(mogrify_info,*image); |
| 2595 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2596 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2597 | exception); |
| 2598 | break; |
| 2599 | } |
| 2600 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2601 | { |
| 2602 | /* |
| 2603 | Selectively blur pixels within a contrast threshold. |
| 2604 | */ |
| 2605 | (void) SyncImageSettings(mogrify_info,*image); |
| 2606 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2607 | if ((flags & PercentValue) != 0) |
| 2608 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2609 | mogrify_image=SelectiveBlurImage(*image,geometry_info.rho, |
cristy | 1e7aa31 | 2011-09-10 20:01:36 +0000 | [diff] [blame] | 2610 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2611 | break; |
| 2612 | } |
| 2613 | if (LocaleCompare("separate",option+1) == 0) |
| 2614 | { |
| 2615 | /* |
| 2616 | Break channels into separate images. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2617 | */ |
| 2618 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 2619 | mogrify_image=SeparateImages(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2620 | break; |
| 2621 | } |
| 2622 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2623 | { |
| 2624 | double |
| 2625 | threshold; |
| 2626 | |
| 2627 | /* |
| 2628 | Sepia-tone image. |
| 2629 | */ |
| 2630 | (void) SyncImageSettings(mogrify_info,*image); |
| 2631 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2632 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
| 2633 | break; |
| 2634 | } |
| 2635 | if (LocaleCompare("segment",option+1) == 0) |
| 2636 | { |
| 2637 | /* |
| 2638 | Segment image. |
| 2639 | */ |
| 2640 | (void) SyncImageSettings(mogrify_info,*image); |
| 2641 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2642 | if ((flags & SigmaValue) == 0) |
| 2643 | geometry_info.sigma=1.0; |
| 2644 | (void) SegmentImage(*image,(*image)->colorspace, |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2645 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 2646 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2647 | break; |
| 2648 | } |
| 2649 | if (LocaleCompare("set",option+1) == 0) |
| 2650 | { |
| 2651 | char |
| 2652 | *value; |
| 2653 | |
| 2654 | /* |
| 2655 | Set image option. |
| 2656 | */ |
| 2657 | if (*option == '+') |
| 2658 | { |
| 2659 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2660 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2661 | else |
| 2662 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2663 | { |
| 2664 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
| 2665 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2666 | } |
| 2667 | else |
| 2668 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2669 | break; |
| 2670 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2671 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2672 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2673 | if (value == (char *) NULL) |
| 2674 | break; |
| 2675 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2676 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2677 | exception); |
| 2678 | else |
| 2679 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2680 | { |
| 2681 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
| 2682 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
| 2683 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2684 | } |
| 2685 | else |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame^] | 2686 | (void) SetImageProperty(*image,argv[i+1],value,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2687 | value=DestroyString(value); |
| 2688 | break; |
| 2689 | } |
| 2690 | if (LocaleCompare("shade",option+1) == 0) |
| 2691 | { |
| 2692 | /* |
| 2693 | Shade image. |
| 2694 | */ |
| 2695 | (void) SyncImageSettings(mogrify_info,*image); |
| 2696 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2697 | if ((flags & SigmaValue) == 0) |
| 2698 | geometry_info.sigma=1.0; |
| 2699 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2700 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2701 | break; |
| 2702 | } |
| 2703 | if (LocaleCompare("shadow",option+1) == 0) |
| 2704 | { |
| 2705 | /* |
| 2706 | Shadow image. |
| 2707 | */ |
| 2708 | (void) SyncImageSettings(mogrify_info,*image); |
| 2709 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2710 | if ((flags & SigmaValue) == 0) |
| 2711 | geometry_info.sigma=1.0; |
| 2712 | if ((flags & XiValue) == 0) |
| 2713 | geometry_info.xi=4.0; |
| 2714 | if ((flags & PsiValue) == 0) |
| 2715 | geometry_info.psi=4.0; |
| 2716 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
| 2717 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 2718 | ceil(geometry_info.psi-0.5),exception); |
| 2719 | break; |
| 2720 | } |
| 2721 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2722 | { |
| 2723 | /* |
| 2724 | Sharpen image. |
| 2725 | */ |
| 2726 | (void) SyncImageSettings(mogrify_info,*image); |
| 2727 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2728 | if ((flags & SigmaValue) == 0) |
| 2729 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2730 | if ((flags & XiValue) == 0) |
| 2731 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2732 | mogrify_image=SharpenImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2733 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2734 | break; |
| 2735 | } |
| 2736 | if (LocaleCompare("shave",option+1) == 0) |
| 2737 | { |
| 2738 | /* |
| 2739 | Shave the image edges. |
| 2740 | */ |
| 2741 | (void) SyncImageSettings(mogrify_info,*image); |
| 2742 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2743 | mogrify_image=ShaveImage(*image,&geometry,exception); |
| 2744 | break; |
| 2745 | } |
| 2746 | if (LocaleCompare("shear",option+1) == 0) |
| 2747 | { |
| 2748 | /* |
| 2749 | Shear image. |
| 2750 | */ |
| 2751 | (void) SyncImageSettings(mogrify_info,*image); |
| 2752 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2753 | if ((flags & SigmaValue) == 0) |
| 2754 | geometry_info.sigma=geometry_info.rho; |
| 2755 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2756 | geometry_info.sigma,exception); |
| 2757 | break; |
| 2758 | } |
| 2759 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2760 | { |
| 2761 | /* |
| 2762 | Sigmoidal non-linearity contrast control. |
| 2763 | */ |
| 2764 | (void) SyncImageSettings(mogrify_info,*image); |
| 2765 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2766 | if ((flags & SigmaValue) == 0) |
| 2767 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 2768 | if ((flags & PercentValue) != 0) |
| 2769 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2770 | 100.0; |
cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 2771 | (void) SigmoidalContrastImage(*image,(*option == '-') ? |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2772 | MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma, |
| 2773 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2774 | break; |
| 2775 | } |
| 2776 | if (LocaleCompare("sketch",option+1) == 0) |
| 2777 | { |
| 2778 | /* |
| 2779 | Sketch image. |
| 2780 | */ |
| 2781 | (void) SyncImageSettings(mogrify_info,*image); |
| 2782 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2783 | if ((flags & SigmaValue) == 0) |
| 2784 | geometry_info.sigma=1.0; |
| 2785 | mogrify_image=SketchImage(*image,geometry_info.rho, |
cristy | f7ef025 | 2011-09-09 14:50:06 +0000 | [diff] [blame] | 2786 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2787 | break; |
| 2788 | } |
| 2789 | if (LocaleCompare("solarize",option+1) == 0) |
| 2790 | { |
| 2791 | double |
| 2792 | threshold; |
| 2793 | |
| 2794 | (void) SyncImageSettings(mogrify_info,*image); |
| 2795 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 2796 | (void) SolarizeImage(*image,threshold,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2797 | break; |
| 2798 | } |
| 2799 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2800 | { |
| 2801 | SparseColorMethod |
| 2802 | method; |
| 2803 | |
| 2804 | char |
| 2805 | *arguments; |
| 2806 | |
| 2807 | /* |
| 2808 | Sparse Color Interpolated Gradient |
| 2809 | */ |
| 2810 | (void) SyncImageSettings(mogrify_info,*image); |
| 2811 | method=(SparseColorMethod) ParseCommandOption( |
| 2812 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2813 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2814 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2815 | if (arguments == (char *) NULL) |
| 2816 | break; |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 2817 | mogrify_image=SparseColorOption(*image,method,arguments, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2818 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2819 | arguments=DestroyString(arguments); |
| 2820 | break; |
| 2821 | } |
| 2822 | if (LocaleCompare("splice",option+1) == 0) |
| 2823 | { |
| 2824 | /* |
| 2825 | Splice a solid color into the image. |
| 2826 | */ |
| 2827 | (void) SyncImageSettings(mogrify_info,*image); |
| 2828 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 2829 | mogrify_image=SpliceImage(*image,&geometry,exception); |
| 2830 | break; |
| 2831 | } |
| 2832 | if (LocaleCompare("spread",option+1) == 0) |
| 2833 | { |
| 2834 | /* |
| 2835 | Spread an image. |
| 2836 | */ |
| 2837 | (void) SyncImageSettings(mogrify_info,*image); |
| 2838 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame] | 2839 | mogrify_image=SpreadImage(*image,geometry_info.rho, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2840 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2841 | break; |
| 2842 | } |
| 2843 | if (LocaleCompare("statistic",option+1) == 0) |
| 2844 | { |
| 2845 | StatisticType |
| 2846 | type; |
| 2847 | |
| 2848 | (void) SyncImageSettings(mogrify_info,*image); |
| 2849 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
| 2850 | MagickFalse,argv[i+1]); |
| 2851 | (void) ParseGeometry(argv[i+2],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2852 | mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho, |
| 2853 | (size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2854 | break; |
| 2855 | } |
| 2856 | if (LocaleCompare("stretch",option+1) == 0) |
| 2857 | { |
| 2858 | if (*option == '+') |
| 2859 | { |
| 2860 | draw_info->stretch=UndefinedStretch; |
| 2861 | break; |
| 2862 | } |
| 2863 | draw_info->stretch=(StretchType) ParseCommandOption( |
| 2864 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2865 | break; |
| 2866 | } |
| 2867 | if (LocaleCompare("strip",option+1) == 0) |
| 2868 | { |
| 2869 | /* |
| 2870 | Strip image of profiles and comments. |
| 2871 | */ |
| 2872 | (void) SyncImageSettings(mogrify_info,*image); |
| 2873 | (void) StripImage(*image); |
| 2874 | InheritException(exception,&(*image)->exception); |
| 2875 | break; |
| 2876 | } |
| 2877 | if (LocaleCompare("stroke",option+1) == 0) |
| 2878 | { |
| 2879 | ExceptionInfo |
| 2880 | *sans; |
| 2881 | |
| 2882 | if (*option == '+') |
| 2883 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2884 | (void) QueryColorCompliance("none",AllCompliance, |
| 2885 | &draw_info->stroke,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2886 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2887 | draw_info->stroke_pattern=DestroyImage( |
| 2888 | draw_info->stroke_pattern); |
| 2889 | break; |
| 2890 | } |
| 2891 | sans=AcquireExceptionInfo(); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2892 | status=QueryColorCompliance(argv[i+1],AllCompliance, |
| 2893 | &draw_info->stroke,sans); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2894 | sans=DestroyExceptionInfo(sans); |
| 2895 | if (status == MagickFalse) |
| 2896 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2897 | exception); |
| 2898 | break; |
| 2899 | } |
| 2900 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2901 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 2902 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 2903 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2904 | break; |
| 2905 | } |
| 2906 | if (LocaleCompare("style",option+1) == 0) |
| 2907 | { |
| 2908 | if (*option == '+') |
| 2909 | { |
| 2910 | draw_info->style=UndefinedStyle; |
| 2911 | break; |
| 2912 | } |
| 2913 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 2914 | MagickFalse,argv[i+1]); |
| 2915 | break; |
| 2916 | } |
| 2917 | if (LocaleCompare("swirl",option+1) == 0) |
| 2918 | { |
| 2919 | /* |
| 2920 | Swirl image. |
| 2921 | */ |
| 2922 | (void) SyncImageSettings(mogrify_info,*image); |
| 2923 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 76f512e | 2011-09-12 01:26:56 +0000 | [diff] [blame] | 2924 | mogrify_image=SwirlImage(*image,geometry_info.rho, |
| 2925 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2926 | break; |
| 2927 | } |
| 2928 | break; |
| 2929 | } |
| 2930 | case 't': |
| 2931 | { |
| 2932 | if (LocaleCompare("threshold",option+1) == 0) |
| 2933 | { |
| 2934 | double |
| 2935 | threshold; |
| 2936 | |
| 2937 | /* |
| 2938 | Threshold image. |
| 2939 | */ |
| 2940 | (void) SyncImageSettings(mogrify_info,*image); |
| 2941 | if (*option == '+') |
anthony | 247a86d | 2011-05-03 13:18:18 +0000 | [diff] [blame] | 2942 | threshold=(double) QuantumRange/2; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2943 | else |
| 2944 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2945 | (void) BilevelImage(*image,threshold); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2946 | InheritException(exception,&(*image)->exception); |
| 2947 | break; |
| 2948 | } |
| 2949 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2950 | { |
| 2951 | /* |
| 2952 | Thumbnail image. |
| 2953 | */ |
| 2954 | (void) SyncImageSettings(mogrify_info,*image); |
| 2955 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2956 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2957 | exception); |
| 2958 | break; |
| 2959 | } |
| 2960 | if (LocaleCompare("tile",option+1) == 0) |
| 2961 | { |
| 2962 | if (*option == '+') |
| 2963 | { |
| 2964 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2965 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2966 | break; |
| 2967 | } |
| 2968 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2969 | exception); |
| 2970 | break; |
| 2971 | } |
| 2972 | if (LocaleCompare("tint",option+1) == 0) |
| 2973 | { |
| 2974 | /* |
| 2975 | Tint the image. |
| 2976 | */ |
| 2977 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2978 | mogrify_image=TintImage(*image,argv[i+1],&fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2979 | break; |
| 2980 | } |
| 2981 | if (LocaleCompare("transform",option+1) == 0) |
| 2982 | { |
| 2983 | /* |
| 2984 | Affine transform image. |
| 2985 | */ |
| 2986 | (void) SyncImageSettings(mogrify_info,*image); |
| 2987 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
| 2988 | exception); |
| 2989 | break; |
| 2990 | } |
| 2991 | if (LocaleCompare("transparent",option+1) == 0) |
| 2992 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2993 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2994 | target; |
| 2995 | |
| 2996 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2997 | (void) QueryColorCompliance(argv[i+1],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2998 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2999 | (void) TransparentPaintImage(*image,&target,(Quantum) |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 3000 | TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue, |
| 3001 | &(*image)->exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3002 | break; |
| 3003 | } |
| 3004 | if (LocaleCompare("transpose",option+1) == 0) |
| 3005 | { |
| 3006 | /* |
| 3007 | Transpose image scanlines. |
| 3008 | */ |
| 3009 | (void) SyncImageSettings(mogrify_info,*image); |
| 3010 | mogrify_image=TransposeImage(*image,exception); |
| 3011 | break; |
| 3012 | } |
| 3013 | if (LocaleCompare("transverse",option+1) == 0) |
| 3014 | { |
| 3015 | /* |
| 3016 | Transverse image scanlines. |
| 3017 | */ |
| 3018 | (void) SyncImageSettings(mogrify_info,*image); |
| 3019 | mogrify_image=TransverseImage(*image,exception); |
| 3020 | break; |
| 3021 | } |
| 3022 | if (LocaleCompare("treedepth",option+1) == 0) |
| 3023 | { |
| 3024 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
| 3025 | break; |
| 3026 | } |
| 3027 | if (LocaleCompare("trim",option+1) == 0) |
| 3028 | { |
| 3029 | /* |
| 3030 | Trim image. |
| 3031 | */ |
| 3032 | (void) SyncImageSettings(mogrify_info,*image); |
| 3033 | mogrify_image=TrimImage(*image,exception); |
| 3034 | break; |
| 3035 | } |
| 3036 | if (LocaleCompare("type",option+1) == 0) |
| 3037 | { |
| 3038 | ImageType |
| 3039 | type; |
| 3040 | |
| 3041 | (void) SyncImageSettings(mogrify_info,*image); |
| 3042 | if (*option == '+') |
| 3043 | type=UndefinedType; |
| 3044 | else |
| 3045 | type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 3046 | argv[i+1]); |
| 3047 | (*image)->type=UndefinedType; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3048 | (void) SetImageType(*image,type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3049 | break; |
| 3050 | } |
| 3051 | break; |
| 3052 | } |
| 3053 | case 'u': |
| 3054 | { |
| 3055 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3056 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 3057 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 3058 | &draw_info->undercolor,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3059 | break; |
| 3060 | } |
| 3061 | if (LocaleCompare("unique",option+1) == 0) |
| 3062 | { |
| 3063 | if (*option == '+') |
| 3064 | { |
| 3065 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
| 3066 | break; |
| 3067 | } |
| 3068 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
| 3069 | (void) SetImageArtifact(*image,"verbose","true"); |
| 3070 | break; |
| 3071 | } |
| 3072 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3073 | { |
| 3074 | /* |
| 3075 | Unique image colors. |
| 3076 | */ |
| 3077 | (void) SyncImageSettings(mogrify_info,*image); |
| 3078 | mogrify_image=UniqueImageColors(*image,exception); |
| 3079 | break; |
| 3080 | } |
| 3081 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3082 | { |
| 3083 | /* |
| 3084 | Unsharp mask image. |
| 3085 | */ |
| 3086 | (void) SyncImageSettings(mogrify_info,*image); |
| 3087 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3088 | if ((flags & SigmaValue) == 0) |
| 3089 | geometry_info.sigma=1.0; |
| 3090 | if ((flags & XiValue) == 0) |
| 3091 | geometry_info.xi=1.0; |
| 3092 | if ((flags & PsiValue) == 0) |
| 3093 | geometry_info.psi=0.05; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3094 | mogrify_image=UnsharpMaskImage(*image,geometry_info.rho, |
| 3095 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3096 | break; |
| 3097 | } |
| 3098 | break; |
| 3099 | } |
| 3100 | case 'v': |
| 3101 | { |
| 3102 | if (LocaleCompare("verbose",option+1) == 0) |
| 3103 | { |
| 3104 | (void) SetImageArtifact(*image,option+1, |
| 3105 | *option == '+' ? "false" : "true"); |
| 3106 | break; |
| 3107 | } |
| 3108 | if (LocaleCompare("vignette",option+1) == 0) |
| 3109 | { |
| 3110 | /* |
| 3111 | Vignette image. |
| 3112 | */ |
| 3113 | (void) SyncImageSettings(mogrify_info,*image); |
| 3114 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3115 | if ((flags & SigmaValue) == 0) |
| 3116 | geometry_info.sigma=1.0; |
| 3117 | if ((flags & XiValue) == 0) |
| 3118 | geometry_info.xi=0.1*(*image)->columns; |
| 3119 | if ((flags & PsiValue) == 0) |
| 3120 | geometry_info.psi=0.1*(*image)->rows; |
| 3121 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
| 3122 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3123 | ceil(geometry_info.psi-0.5),exception); |
| 3124 | break; |
| 3125 | } |
| 3126 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3127 | { |
| 3128 | if (*option == '+') |
| 3129 | { |
| 3130 | (void) SetImageVirtualPixelMethod(*image, |
| 3131 | UndefinedVirtualPixelMethod); |
| 3132 | break; |
| 3133 | } |
| 3134 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3135 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 3136 | argv[i+1])); |
| 3137 | break; |
| 3138 | } |
| 3139 | break; |
| 3140 | } |
| 3141 | case 'w': |
| 3142 | { |
| 3143 | if (LocaleCompare("wave",option+1) == 0) |
| 3144 | { |
| 3145 | /* |
| 3146 | Wave image. |
| 3147 | */ |
| 3148 | (void) SyncImageSettings(mogrify_info,*image); |
| 3149 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3150 | if ((flags & SigmaValue) == 0) |
| 3151 | geometry_info.sigma=1.0; |
| 3152 | mogrify_image=WaveImage(*image,geometry_info.rho, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 3153 | geometry_info.sigma,interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3154 | break; |
| 3155 | } |
| 3156 | if (LocaleCompare("weight",option+1) == 0) |
| 3157 | { |
| 3158 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
| 3159 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3160 | draw_info->weight=0; |
| 3161 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3162 | draw_info->weight=700; |
| 3163 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3164 | if (draw_info->weight <= 800) |
| 3165 | draw_info->weight+=100; |
| 3166 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3167 | if (draw_info->weight >= 100) |
| 3168 | draw_info->weight-=100; |
| 3169 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3170 | draw_info->weight=400; |
| 3171 | break; |
| 3172 | } |
| 3173 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3174 | { |
| 3175 | /* |
| 3176 | White threshold image. |
| 3177 | */ |
| 3178 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3179 | (void) WhiteThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3180 | InheritException(exception,&(*image)->exception); |
| 3181 | break; |
| 3182 | } |
| 3183 | break; |
| 3184 | } |
| 3185 | default: |
| 3186 | break; |
| 3187 | } |
| 3188 | /* |
| 3189 | Replace current image with any image that was generated |
| 3190 | */ |
| 3191 | if (mogrify_image != (Image *) NULL) |
| 3192 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3193 | i+=count; |
| 3194 | } |
| 3195 | if (region_image != (Image *) NULL) |
| 3196 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3197 | /* |
| 3198 | Composite transformed region onto image. |
| 3199 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3200 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3201 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3202 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 3203 | region_geometry.x,region_geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3204 | InheritException(exception,®ion_image->exception); |
| 3205 | *image=DestroyImage(*image); |
| 3206 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3207 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3208 | } |
| 3209 | /* |
| 3210 | Free resources. |
| 3211 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3212 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3213 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3214 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 3215 | status=(MagickStatusType) ((*image)->exception.severity == |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 3216 | UndefinedException ? 1 : 0); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3217 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3218 | } |
| 3219 | |
| 3220 | /* |
| 3221 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3222 | % % |
| 3223 | % % |
| 3224 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3225 | + 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] | 3226 | % % |
| 3227 | % % |
| 3228 | % % |
| 3229 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3230 | % |
| 3231 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3232 | % transforms include image scaling, image rotation, color reduction, and |
| 3233 | % others. The transmogrified image overwrites the original image. |
| 3234 | % |
| 3235 | % The format of the MogrifyImageCommand method is: |
| 3236 | % |
| 3237 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3238 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3239 | % |
| 3240 | % A description of each parameter follows: |
| 3241 | % |
| 3242 | % o image_info: the image info. |
| 3243 | % |
| 3244 | % o argc: the number of elements in the argument vector. |
| 3245 | % |
| 3246 | % o argv: A text array containing the command line arguments. |
| 3247 | % |
| 3248 | % o metadata: any metadata is returned here. |
| 3249 | % |
| 3250 | % o exception: return any errors or warnings in this structure. |
| 3251 | % |
| 3252 | */ |
| 3253 | |
| 3254 | static MagickBooleanType MogrifyUsage(void) |
| 3255 | { |
| 3256 | static const char |
| 3257 | *miscellaneous[]= |
| 3258 | { |
| 3259 | "-debug events display copious debugging information", |
| 3260 | "-help print program options", |
| 3261 | "-list type print a list of supported option arguments", |
| 3262 | "-log format format of debugging information", |
| 3263 | "-version print version information", |
| 3264 | (char *) NULL |
| 3265 | }, |
| 3266 | *operators[]= |
| 3267 | { |
| 3268 | "-adaptive-blur geometry", |
| 3269 | " adaptively blur pixels; decrease effect near edges", |
| 3270 | "-adaptive-resize geometry", |
| 3271 | " adaptively resize image using 'mesh' interpolation", |
| 3272 | "-adaptive-sharpen geometry", |
| 3273 | " adaptively sharpen pixels; increase effect near edges", |
| 3274 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3275 | " transparent, extract, background, or shape", |
| 3276 | "-annotate geometry text", |
| 3277 | " annotate the image with text", |
| 3278 | "-auto-gamma automagically adjust gamma level of image", |
| 3279 | "-auto-level automagically adjust color levels of image", |
| 3280 | "-auto-orient automagically orient (rotate) image", |
| 3281 | "-bench iterations measure performance", |
| 3282 | "-black-threshold value", |
| 3283 | " force all pixels below the threshold into black", |
| 3284 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3285 | "-blur geometry reduce image noise and reduce detail levels", |
| 3286 | "-border geometry surround image with a border of color", |
| 3287 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3288 | "-brightness-contrast geometry", |
| 3289 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3290 | "-cdl filename color correct with a color decision list", |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 3291 | "-charcoal geometry simulate a charcoal drawing", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3292 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3293 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3294 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3295 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3296 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3297 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3298 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3299 | "-contrast enhance or reduce the image contrast", |
| 3300 | "-contrast-stretch geometry", |
| 3301 | " improve contrast by `stretching' the intensity range", |
| 3302 | "-convolve coefficients", |
| 3303 | " apply a convolution kernel to the image", |
| 3304 | "-cycle amount cycle the image colormap", |
| 3305 | "-decipher filename convert cipher pixels to plain pixels", |
| 3306 | "-deskew threshold straighten an image", |
| 3307 | "-despeckle reduce the speckles within an image", |
| 3308 | "-distort method args", |
| 3309 | " distort images according to given method ad args", |
| 3310 | "-draw string annotate the image with a graphic primitive", |
| 3311 | "-edge radius apply a filter to detect edges in the image", |
| 3312 | "-encipher filename convert plain pixels to cipher pixels", |
| 3313 | "-emboss radius emboss an image", |
| 3314 | "-enhance apply a digital filter to enhance a noisy image", |
| 3315 | "-equalize perform histogram equalization to an image", |
| 3316 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3317 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3318 | "-extent geometry set the image size", |
| 3319 | "-extract geometry extract area from image", |
| 3320 | "-fft implements the discrete Fourier transform (DFT)", |
| 3321 | "-flip flip image vertically", |
| 3322 | "-floodfill geometry color", |
| 3323 | " floodfill the image with color", |
| 3324 | "-flop flop image horizontally", |
| 3325 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3326 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3327 | " apply function over image values", |
| 3328 | "-gamma value level of gamma correction", |
| 3329 | "-gaussian-blur geometry", |
| 3330 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3331 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3332 | "-identify identify the format and characteristics of the image", |
| 3333 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3334 | "-implode amount implode image pixels about the center", |
| 3335 | "-lat geometry local adaptive thresholding", |
| 3336 | "-layers method optimize, merge, or compare image layers", |
| 3337 | "-level value adjust the level of image contrast", |
| 3338 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3339 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3340 | "-linear-stretch geometry", |
| 3341 | " improve contrast by `stretching with saturation'", |
| 3342 | "-liquid-rescale geometry", |
| 3343 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3344 | "-median geometry apply a median filter to the image", |
glennrp | 30d2dc6 | 2011-06-25 03:17:16 +0000 | [diff] [blame] | 3345 | "-mode geometry make each pixel the 'predominant color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3346 | "-modulate value vary the brightness, saturation, and hue", |
| 3347 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3348 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3349 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3350 | "-motion-blur geometry", |
| 3351 | " simulate motion blur", |
| 3352 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3353 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3354 | "-normalize transform image to span the full range of colors", |
| 3355 | "-opaque color change this color to the fill color", |
| 3356 | "-ordered-dither NxN", |
| 3357 | " add a noise pattern to the image with specific", |
| 3358 | " amplitudes", |
| 3359 | "-paint radius simulate an oil painting", |
| 3360 | "-polaroid angle simulate a Polaroid picture", |
| 3361 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3362 | "-profile filename add, delete, or apply an image profile", |
| 3363 | "-quantize colorspace reduce colors in this colorspace", |
| 3364 | "-radial-blur angle radial blur the image", |
| 3365 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3366 | "-random-threshold low,high", |
| 3367 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3368 | "-region geometry apply options to a portion of the image", |
| 3369 | "-render render vector graphics", |
| 3370 | "-repage geometry size and location of an image canvas", |
| 3371 | "-resample geometry change the resolution of an image", |
| 3372 | "-resize geometry resize the image", |
| 3373 | "-roll geometry roll an image vertically or horizontally", |
| 3374 | "-rotate degrees apply Paeth rotation to the image", |
| 3375 | "-sample geometry scale image with pixel sampling", |
| 3376 | "-scale geometry scale the image", |
| 3377 | "-segment values segment an image", |
| 3378 | "-selective-blur geometry", |
| 3379 | " selectively blur pixels within a contrast threshold", |
| 3380 | "-sepia-tone threshold", |
| 3381 | " simulate a sepia-toned photo", |
| 3382 | "-set property value set an image property", |
| 3383 | "-shade degrees shade the image using a distant light source", |
| 3384 | "-shadow geometry simulate an image shadow", |
| 3385 | "-sharpen geometry sharpen the image", |
| 3386 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3387 | "-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] | 3388 | "-sigmoidal-contrast geometry", |
| 3389 | " increase the contrast without saturating highlights or shadows", |
| 3390 | "-sketch geometry simulate a pencil sketch", |
| 3391 | "-solarize threshold negate all pixels above the threshold level", |
| 3392 | "-sparse-color method args", |
| 3393 | " fill in a image based on a few color points", |
| 3394 | "-splice geometry splice the background color into the image", |
| 3395 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3396 | "-statistic type radius", |
| 3397 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3398 | "-strip strip image of all profiles and comments", |
| 3399 | "-swirl degrees swirl image pixels about the center", |
| 3400 | "-threshold value threshold the image", |
| 3401 | "-thumbnail geometry create a thumbnail of the image", |
| 3402 | "-tile filename tile image when filling a graphic primitive", |
| 3403 | "-tint value tint the image with the fill color", |
| 3404 | "-transform affine transform image", |
| 3405 | "-transparent color make this color transparent within the image", |
| 3406 | "-transpose flip image vertically and rotate 90 degrees", |
| 3407 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3408 | "-trim trim image edges", |
| 3409 | "-type type image type", |
| 3410 | "-unique-colors discard all but one of any pixel color", |
| 3411 | "-unsharp geometry sharpen the image", |
| 3412 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3413 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3414 | "-white-threshold value", |
| 3415 | " force all pixels above the threshold into white", |
| 3416 | (char *) NULL |
| 3417 | }, |
| 3418 | *sequence_operators[]= |
| 3419 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3420 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3421 | "-clut apply a color lookup table to the image", |
| 3422 | "-coalesce merge a sequence of images", |
| 3423 | "-combine combine a sequence of images", |
| 3424 | "-composite composite image", |
| 3425 | "-crop geometry cut out a rectangular region of the image", |
| 3426 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3427 | "-evaluate-sequence operator", |
| 3428 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3429 | "-flatten flatten a sequence of images", |
| 3430 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3431 | "-hald-clut apply a Hald color lookup table to the image", |
| 3432 | "-morph value morph an image sequence", |
| 3433 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3434 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3435 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3436 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3437 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3438 | "-write filename write images to this file", |
| 3439 | (char *) NULL |
| 3440 | }, |
| 3441 | *settings[]= |
| 3442 | { |
| 3443 | "-adjoin join images into a single multi-image file", |
| 3444 | "-affine matrix affine transform matrix", |
| 3445 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3446 | "-antialias remove pixel-aliasing", |
| 3447 | "-authenticate password", |
| 3448 | " decipher image with this password", |
| 3449 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3450 | "-background color background color", |
| 3451 | "-bias value add bias when convolving an image", |
| 3452 | "-black-point-compensation", |
| 3453 | " use black point compensation", |
| 3454 | "-blue-primary point chromaticity blue primary point", |
| 3455 | "-bordercolor color border color", |
| 3456 | "-caption string assign a caption to an image", |
| 3457 | "-channel type apply option to select image channels", |
| 3458 | "-colors value preferred number of colors in the image", |
| 3459 | "-colorspace type alternate image colorspace", |
| 3460 | "-comment string annotate image with comment", |
| 3461 | "-compose operator set image composite operator", |
| 3462 | "-compress type type of pixel compression when writing the image", |
| 3463 | "-define format:option", |
| 3464 | " define one or more image format options", |
| 3465 | "-delay value display the next image after pausing", |
| 3466 | "-density geometry horizontal and vertical density of the image", |
| 3467 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3468 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3469 | "-display server get image or font from this X server", |
| 3470 | "-dispose method layer disposal method", |
| 3471 | "-dither method apply error diffusion to image", |
| 3472 | "-encoding type text encoding type", |
| 3473 | "-endian type endianness (MSB or LSB) of the image", |
| 3474 | "-family name render text with this font family", |
| 3475 | "-fill color color to use when filling a graphic primitive", |
| 3476 | "-filter type use this filter when resizing an image", |
| 3477 | "-font name render text with this font", |
| 3478 | "-format \"string\" output formatted image characteristics", |
| 3479 | "-fuzz distance colors within this distance are considered equal", |
| 3480 | "-gravity type horizontal and vertical text placement", |
| 3481 | "-green-primary point chromaticity green primary point", |
| 3482 | "-intent type type of rendering intent when managing the image color", |
| 3483 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3484 | "-interline-spacing value", |
| 3485 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3486 | "-interpolate method pixel color interpolation method", |
| 3487 | "-interword-spacing value", |
| 3488 | " set the space between two words", |
| 3489 | "-kerning value set the space between two letters", |
| 3490 | "-label string assign a label to an image", |
| 3491 | "-limit type value pixel cache resource limit", |
| 3492 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3493 | "-mask filename associate a mask with the image", |
| 3494 | "-mattecolor color frame color", |
| 3495 | "-monitor monitor progress", |
| 3496 | "-orient type image orientation", |
| 3497 | "-page geometry size and location of an image canvas (setting)", |
| 3498 | "-ping efficiently determine image attributes", |
| 3499 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3500 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3501 | "-preview type image preview type", |
| 3502 | "-quality value JPEG/MIFF/PNG compression level", |
| 3503 | "-quiet suppress all warning messages", |
| 3504 | "-red-primary point chromaticity red primary point", |
| 3505 | "-regard-warnings pay attention to warning messages", |
| 3506 | "-remap filename transform image colors to match this set of colors", |
| 3507 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3508 | "-sampling-factor geometry", |
| 3509 | " horizontal and vertical sampling factor", |
| 3510 | "-scene value image scene number", |
| 3511 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3512 | "-size geometry width and height of image", |
| 3513 | "-stretch type render text with this font stretch", |
| 3514 | "-stroke color graphic primitive stroke color", |
| 3515 | "-strokewidth value graphic primitive stroke width", |
| 3516 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3517 | "-synchronize synchronize image to storage device", |
| 3518 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3519 | "-texture filename name of texture to tile onto the image background", |
| 3520 | "-tile-offset geometry", |
| 3521 | " tile offset", |
| 3522 | "-treedepth value color tree depth", |
| 3523 | "-transparent-color color", |
| 3524 | " transparent color", |
| 3525 | "-undercolor color annotation bounding box color", |
| 3526 | "-units type the units of image resolution", |
| 3527 | "-verbose print detailed information about the image", |
| 3528 | "-view FlashPix viewing transforms", |
| 3529 | "-virtual-pixel method", |
| 3530 | " virtual pixel access method", |
| 3531 | "-weight type render text with this font weight", |
| 3532 | "-white-point point chromaticity white point", |
| 3533 | (char *) NULL |
| 3534 | }, |
| 3535 | *stack_operators[]= |
| 3536 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3537 | "-delete indexes delete the image from the image sequence", |
| 3538 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3539 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3540 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3541 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3542 | "-swap indexes swap two images in the image sequence", |
| 3543 | (char *) NULL |
| 3544 | }; |
| 3545 | |
| 3546 | const char |
| 3547 | **p; |
| 3548 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3549 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3550 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3551 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3552 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3553 | GetClientName()); |
| 3554 | (void) printf("\nImage Settings:\n"); |
| 3555 | for (p=settings; *p != (char *) NULL; p++) |
| 3556 | (void) printf(" %s\n",*p); |
| 3557 | (void) printf("\nImage Operators:\n"); |
| 3558 | for (p=operators; *p != (char *) NULL; p++) |
| 3559 | (void) printf(" %s\n",*p); |
| 3560 | (void) printf("\nImage Sequence Operators:\n"); |
| 3561 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3562 | (void) printf(" %s\n",*p); |
| 3563 | (void) printf("\nImage Stack Operators:\n"); |
| 3564 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3565 | (void) printf(" %s\n",*p); |
| 3566 | (void) printf("\nMiscellaneous Options:\n"); |
| 3567 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3568 | (void) printf(" %s\n",*p); |
| 3569 | (void) printf( |
| 3570 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3571 | (void) printf( |
| 3572 | "number. To specify a particular image format, precede the filename\n"); |
| 3573 | (void) printf( |
| 3574 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3575 | (void) printf( |
| 3576 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3577 | (void) printf("'-' for standard input or output.\n"); |
| 3578 | return(MagickFalse); |
| 3579 | } |
| 3580 | |
| 3581 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3582 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3583 | { |
| 3584 | #define DestroyMogrify() \ |
| 3585 | { \ |
| 3586 | if (format != (char *) NULL) \ |
| 3587 | format=DestroyString(format); \ |
| 3588 | if (path != (char *) NULL) \ |
| 3589 | path=DestroyString(path); \ |
| 3590 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3591 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3592 | argv[i]=DestroyString(argv[i]); \ |
| 3593 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3594 | } |
| 3595 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3596 | { \ |
| 3597 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3598 | option); \ |
| 3599 | DestroyMogrify(); \ |
| 3600 | return(MagickFalse); \ |
| 3601 | } |
| 3602 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3603 | { \ |
| 3604 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3605 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3606 | DestroyMogrify(); \ |
| 3607 | return(MagickFalse); \ |
| 3608 | } |
| 3609 | |
| 3610 | char |
| 3611 | *format, |
| 3612 | *option, |
| 3613 | *path; |
| 3614 | |
| 3615 | Image |
| 3616 | *image; |
| 3617 | |
| 3618 | ImageStack |
| 3619 | image_stack[MaxImageStackDepth+1]; |
| 3620 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3621 | MagickBooleanType |
| 3622 | global_colormap; |
| 3623 | |
| 3624 | MagickBooleanType |
| 3625 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3626 | pend, |
| 3627 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3628 | |
| 3629 | MagickStatusType |
| 3630 | status; |
| 3631 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3632 | register ssize_t |
| 3633 | i; |
| 3634 | |
| 3635 | ssize_t |
| 3636 | j, |
| 3637 | k; |
| 3638 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3639 | /* |
| 3640 | Set defaults. |
| 3641 | */ |
| 3642 | assert(image_info != (ImageInfo *) NULL); |
| 3643 | assert(image_info->signature == MagickSignature); |
| 3644 | if (image_info->debug != MagickFalse) |
| 3645 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3646 | assert(exception != (ExceptionInfo *) NULL); |
| 3647 | if (argc == 2) |
| 3648 | { |
| 3649 | option=argv[1]; |
| 3650 | if ((LocaleCompare("version",option+1) == 0) || |
| 3651 | (LocaleCompare("-version",option+1) == 0)) |
| 3652 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3653 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3654 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 3655 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 3656 | GetMagickCopyright()); |
| 3657 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 3658 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3659 | return(MagickFalse); |
| 3660 | } |
| 3661 | } |
| 3662 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3663 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3664 | format=(char *) NULL; |
| 3665 | path=(char *) NULL; |
| 3666 | global_colormap=MagickFalse; |
| 3667 | k=0; |
| 3668 | j=1; |
| 3669 | NewImageStack(); |
| 3670 | option=(char *) NULL; |
| 3671 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3672 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3673 | status=MagickTrue; |
| 3674 | /* |
| 3675 | Parse command line. |
| 3676 | */ |
| 3677 | ReadCommandlLine(argc,&argv); |
| 3678 | status=ExpandFilenames(&argc,&argv); |
| 3679 | if (status == MagickFalse) |
| 3680 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3681 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3682 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3683 | { |
| 3684 | option=argv[i]; |
| 3685 | if (LocaleCompare(option,"(") == 0) |
| 3686 | { |
| 3687 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3688 | if (k == MaxImageStackDepth) |
| 3689 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3690 | option); |
| 3691 | PushImageStack(); |
| 3692 | continue; |
| 3693 | } |
| 3694 | if (LocaleCompare(option,")") == 0) |
| 3695 | { |
| 3696 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3697 | if (k == 0) |
| 3698 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3699 | PopImageStack(); |
| 3700 | continue; |
| 3701 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3702 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3703 | { |
| 3704 | char |
| 3705 | backup_filename[MaxTextExtent], |
| 3706 | *filename; |
| 3707 | |
| 3708 | Image |
| 3709 | *images; |
| 3710 | |
| 3711 | /* |
| 3712 | Option is a file name: begin by reading image from specified file. |
| 3713 | */ |
| 3714 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3715 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3716 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3717 | filename=argv[++i]; |
| 3718 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 3719 | images=ReadImages(image_info,exception); |
| 3720 | status&=(images != (Image *) NULL) && |
| 3721 | (exception->severity < ErrorException); |
| 3722 | if (images == (Image *) NULL) |
| 3723 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3724 | if (format != (char *) NULL) |
| 3725 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3726 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3727 | if (path != (char *) NULL) |
| 3728 | { |
| 3729 | GetPathComponent(option,TailPath,filename); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3730 | (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3731 | path,*DirectorySeparator,filename); |
| 3732 | } |
| 3733 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3734 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3735 | AppendImageStack(images); |
| 3736 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3737 | if (global_colormap != MagickFalse) |
| 3738 | { |
| 3739 | QuantizeInfo |
| 3740 | *quantize_info; |
| 3741 | |
| 3742 | quantize_info=AcquireQuantizeInfo(image_info); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3743 | (void) RemapImages(quantize_info,images,(Image *) NULL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3744 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3745 | } |
| 3746 | *backup_filename='\0'; |
| 3747 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3748 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3749 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3750 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3751 | i; |
| 3752 | |
| 3753 | /* |
| 3754 | Rename image file as backup. |
| 3755 | */ |
| 3756 | (void) CopyMagickString(backup_filename,image->filename, |
| 3757 | MaxTextExtent); |
| 3758 | for (i=0; i < 6; i++) |
| 3759 | { |
| 3760 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3761 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3762 | break; |
| 3763 | } |
| 3764 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
cristy | 320684d | 2011-09-23 14:55:47 +0000 | [diff] [blame] | 3765 | (rename_utf8(image->filename,backup_filename) != 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3766 | *backup_filename='\0'; |
| 3767 | } |
| 3768 | /* |
| 3769 | Write transmogrified image to disk. |
| 3770 | */ |
| 3771 | image_info->synchronize=MagickTrue; |
| 3772 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3773 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 3774 | (void) remove_utf8(backup_filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3775 | RemoveAllImageStack(); |
| 3776 | continue; |
| 3777 | } |
| 3778 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3779 | switch (*(option+1)) |
| 3780 | { |
| 3781 | case 'a': |
| 3782 | { |
| 3783 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3784 | { |
| 3785 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3786 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3787 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3788 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3789 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3790 | break; |
| 3791 | } |
| 3792 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3793 | { |
| 3794 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3795 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3796 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3797 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3798 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3799 | break; |
| 3800 | } |
| 3801 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3802 | { |
| 3803 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3804 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3805 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3806 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3807 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3808 | break; |
| 3809 | } |
| 3810 | if (LocaleCompare("affine",option+1) == 0) |
| 3811 | { |
| 3812 | if (*option == '+') |
| 3813 | break; |
| 3814 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3815 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3816 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3817 | break; |
| 3818 | } |
| 3819 | if (LocaleCompare("alpha",option+1) == 0) |
| 3820 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3821 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3822 | type; |
| 3823 | |
| 3824 | if (*option == '+') |
| 3825 | break; |
| 3826 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3827 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3828 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3829 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3830 | if (type < 0) |
| 3831 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3832 | argv[i]); |
| 3833 | break; |
| 3834 | } |
| 3835 | if (LocaleCompare("annotate",option+1) == 0) |
| 3836 | { |
| 3837 | if (*option == '+') |
| 3838 | break; |
| 3839 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3840 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3841 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3842 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3843 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3844 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3845 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3846 | i++; |
| 3847 | break; |
| 3848 | } |
| 3849 | if (LocaleCompare("antialias",option+1) == 0) |
| 3850 | break; |
| 3851 | if (LocaleCompare("append",option+1) == 0) |
| 3852 | break; |
| 3853 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3854 | { |
| 3855 | if (*option == '+') |
| 3856 | break; |
| 3857 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3858 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3859 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3860 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3861 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3862 | break; |
| 3863 | } |
| 3864 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3865 | { |
| 3866 | if (*option == '+') |
| 3867 | break; |
| 3868 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3869 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3870 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3871 | break; |
| 3872 | } |
| 3873 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3874 | break; |
| 3875 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3876 | break; |
| 3877 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3878 | break; |
| 3879 | if (LocaleCompare("average",option+1) == 0) |
| 3880 | break; |
| 3881 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3882 | } |
| 3883 | case 'b': |
| 3884 | { |
| 3885 | if (LocaleCompare("background",option+1) == 0) |
| 3886 | { |
| 3887 | if (*option == '+') |
| 3888 | break; |
| 3889 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3890 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3891 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3892 | break; |
| 3893 | } |
| 3894 | if (LocaleCompare("bias",option+1) == 0) |
| 3895 | { |
| 3896 | if (*option == '+') |
| 3897 | break; |
| 3898 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3899 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3900 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3901 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3902 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3903 | break; |
| 3904 | } |
| 3905 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 3906 | break; |
| 3907 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 3908 | { |
| 3909 | if (*option == '+') |
| 3910 | break; |
| 3911 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3912 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3913 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3914 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3915 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3916 | break; |
| 3917 | } |
| 3918 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3919 | { |
| 3920 | if (*option == '+') |
| 3921 | break; |
| 3922 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3923 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3924 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3925 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3926 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3927 | break; |
| 3928 | } |
| 3929 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3930 | { |
| 3931 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3932 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3933 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3934 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3935 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3936 | break; |
| 3937 | } |
| 3938 | if (LocaleCompare("blur",option+1) == 0) |
| 3939 | { |
| 3940 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3941 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3942 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3943 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3944 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3945 | break; |
| 3946 | } |
| 3947 | if (LocaleCompare("border",option+1) == 0) |
| 3948 | { |
| 3949 | if (*option == '+') |
| 3950 | break; |
| 3951 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3952 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3953 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3954 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3955 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3956 | break; |
| 3957 | } |
| 3958 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3959 | { |
| 3960 | if (*option == '+') |
| 3961 | break; |
| 3962 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3963 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3964 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3965 | break; |
| 3966 | } |
| 3967 | if (LocaleCompare("box",option+1) == 0) |
| 3968 | { |
| 3969 | if (*option == '+') |
| 3970 | break; |
| 3971 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3972 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3973 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3974 | break; |
| 3975 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3976 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 3977 | { |
| 3978 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3979 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3980 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3981 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3982 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3983 | break; |
| 3984 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3985 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3986 | } |
| 3987 | case 'c': |
| 3988 | { |
| 3989 | if (LocaleCompare("cache",option+1) == 0) |
| 3990 | { |
| 3991 | if (*option == '+') |
| 3992 | break; |
| 3993 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3994 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3995 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3996 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3997 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3998 | break; |
| 3999 | } |
| 4000 | if (LocaleCompare("caption",option+1) == 0) |
| 4001 | { |
| 4002 | if (*option == '+') |
| 4003 | break; |
| 4004 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4005 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4006 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4007 | break; |
| 4008 | } |
| 4009 | if (LocaleCompare("channel",option+1) == 0) |
| 4010 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4011 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4012 | channel; |
| 4013 | |
| 4014 | if (*option == '+') |
| 4015 | break; |
| 4016 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4017 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4018 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4019 | channel=ParseChannelOption(argv[i]); |
| 4020 | if (channel < 0) |
| 4021 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 4022 | argv[i]); |
| 4023 | break; |
| 4024 | } |
| 4025 | if (LocaleCompare("cdl",option+1) == 0) |
| 4026 | { |
| 4027 | if (*option == '+') |
| 4028 | break; |
| 4029 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4030 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4031 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4032 | break; |
| 4033 | } |
| 4034 | if (LocaleCompare("charcoal",option+1) == 0) |
| 4035 | { |
| 4036 | if (*option == '+') |
| 4037 | break; |
| 4038 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4039 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4040 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4041 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4042 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4043 | break; |
| 4044 | } |
| 4045 | if (LocaleCompare("chop",option+1) == 0) |
| 4046 | { |
| 4047 | if (*option == '+') |
| 4048 | break; |
| 4049 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4050 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4051 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4052 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4053 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4054 | break; |
| 4055 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4056 | if (LocaleCompare("clamp",option+1) == 0) |
| 4057 | break; |
| 4058 | if (LocaleCompare("clip",option+1) == 0) |
| 4059 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4060 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4061 | { |
| 4062 | if (*option == '+') |
| 4063 | break; |
| 4064 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4065 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4066 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4067 | break; |
| 4068 | } |
| 4069 | if (LocaleCompare("clut",option+1) == 0) |
| 4070 | break; |
| 4071 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4072 | break; |
| 4073 | if (LocaleCompare("colorize",option+1) == 0) |
| 4074 | { |
| 4075 | if (*option == '+') |
| 4076 | break; |
| 4077 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4078 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4079 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4080 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4081 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4082 | break; |
| 4083 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4084 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4085 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4086 | KernelInfo |
| 4087 | *kernel_info; |
| 4088 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4089 | if (*option == '+') |
| 4090 | break; |
| 4091 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4092 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4093 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4094 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4095 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4096 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4097 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4098 | break; |
| 4099 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4100 | if (LocaleCompare("colors",option+1) == 0) |
| 4101 | { |
| 4102 | if (*option == '+') |
| 4103 | break; |
| 4104 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4105 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4106 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4107 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4108 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4109 | break; |
| 4110 | } |
| 4111 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4112 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4113 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4114 | colorspace; |
| 4115 | |
| 4116 | if (*option == '+') |
| 4117 | break; |
| 4118 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4119 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4120 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4121 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4122 | argv[i]); |
| 4123 | if (colorspace < 0) |
| 4124 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4125 | argv[i]); |
| 4126 | break; |
| 4127 | } |
| 4128 | if (LocaleCompare("combine",option+1) == 0) |
| 4129 | break; |
| 4130 | if (LocaleCompare("comment",option+1) == 0) |
| 4131 | { |
| 4132 | if (*option == '+') |
| 4133 | break; |
| 4134 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4135 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4136 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4137 | break; |
| 4138 | } |
| 4139 | if (LocaleCompare("composite",option+1) == 0) |
| 4140 | break; |
| 4141 | if (LocaleCompare("compress",option+1) == 0) |
| 4142 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4143 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4144 | compress; |
| 4145 | |
| 4146 | if (*option == '+') |
| 4147 | break; |
| 4148 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4149 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4150 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4151 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4152 | argv[i]); |
| 4153 | if (compress < 0) |
| 4154 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4155 | argv[i]); |
| 4156 | break; |
| 4157 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4158 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4159 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4160 | if (LocaleCompare("contrast",option+1) == 0) |
| 4161 | break; |
| 4162 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4163 | { |
| 4164 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4165 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4166 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4167 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4168 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4169 | break; |
| 4170 | } |
| 4171 | if (LocaleCompare("convolve",option+1) == 0) |
| 4172 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4173 | KernelInfo |
| 4174 | *kernel_info; |
| 4175 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4176 | if (*option == '+') |
| 4177 | break; |
| 4178 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4179 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4180 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4181 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4182 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4183 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4184 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4185 | break; |
| 4186 | } |
| 4187 | if (LocaleCompare("crop",option+1) == 0) |
| 4188 | { |
| 4189 | if (*option == '+') |
| 4190 | break; |
| 4191 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4192 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4193 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4194 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4195 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4196 | break; |
| 4197 | } |
| 4198 | if (LocaleCompare("cycle",option+1) == 0) |
| 4199 | { |
| 4200 | if (*option == '+') |
| 4201 | break; |
| 4202 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4203 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4204 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4205 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4206 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4207 | break; |
| 4208 | } |
| 4209 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4210 | } |
| 4211 | case 'd': |
| 4212 | { |
| 4213 | if (LocaleCompare("decipher",option+1) == 0) |
| 4214 | { |
| 4215 | if (*option == '+') |
| 4216 | break; |
| 4217 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4218 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4219 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4220 | break; |
| 4221 | } |
| 4222 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4223 | break; |
| 4224 | if (LocaleCompare("debug",option+1) == 0) |
| 4225 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4226 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4227 | event; |
| 4228 | |
| 4229 | if (*option == '+') |
| 4230 | break; |
| 4231 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4232 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4233 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4234 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4235 | if (event < 0) |
| 4236 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4237 | argv[i]); |
| 4238 | (void) SetLogEventMask(argv[i]); |
| 4239 | break; |
| 4240 | } |
| 4241 | if (LocaleCompare("define",option+1) == 0) |
| 4242 | { |
| 4243 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4244 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4245 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4246 | if (*option == '+') |
| 4247 | { |
| 4248 | const char |
| 4249 | *define; |
| 4250 | |
| 4251 | define=GetImageOption(image_info,argv[i]); |
| 4252 | if (define == (const char *) NULL) |
| 4253 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4254 | break; |
| 4255 | } |
| 4256 | break; |
| 4257 | } |
| 4258 | if (LocaleCompare("delay",option+1) == 0) |
| 4259 | { |
| 4260 | if (*option == '+') |
| 4261 | break; |
| 4262 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4263 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4264 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4265 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4266 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4267 | break; |
| 4268 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4269 | if (LocaleCompare("delete",option+1) == 0) |
| 4270 | { |
| 4271 | if (*option == '+') |
| 4272 | break; |
| 4273 | i++; |
| 4274 | if (i == (ssize_t) (argc-1)) |
| 4275 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4276 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4277 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4278 | break; |
| 4279 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4280 | if (LocaleCompare("density",option+1) == 0) |
| 4281 | { |
| 4282 | if (*option == '+') |
| 4283 | break; |
| 4284 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4285 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4286 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4287 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4288 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4289 | break; |
| 4290 | } |
| 4291 | if (LocaleCompare("depth",option+1) == 0) |
| 4292 | { |
| 4293 | if (*option == '+') |
| 4294 | break; |
| 4295 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4296 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4297 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4298 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4299 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4300 | break; |
| 4301 | } |
| 4302 | if (LocaleCompare("deskew",option+1) == 0) |
| 4303 | { |
| 4304 | if (*option == '+') |
| 4305 | break; |
| 4306 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4307 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4308 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4309 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4310 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4311 | break; |
| 4312 | } |
| 4313 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4314 | break; |
| 4315 | if (LocaleCompare("dft",option+1) == 0) |
| 4316 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4317 | if (LocaleCompare("direction",option+1) == 0) |
| 4318 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4319 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4320 | direction; |
| 4321 | |
| 4322 | if (*option == '+') |
| 4323 | break; |
| 4324 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4325 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4326 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4327 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4328 | argv[i]); |
| 4329 | if (direction < 0) |
| 4330 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4331 | argv[i]); |
| 4332 | break; |
| 4333 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4334 | if (LocaleCompare("display",option+1) == 0) |
| 4335 | { |
| 4336 | if (*option == '+') |
| 4337 | break; |
| 4338 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4339 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4340 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4341 | break; |
| 4342 | } |
| 4343 | if (LocaleCompare("dispose",option+1) == 0) |
| 4344 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4345 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4346 | dispose; |
| 4347 | |
| 4348 | if (*option == '+') |
| 4349 | break; |
| 4350 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4351 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4352 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4353 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4354 | if (dispose < 0) |
| 4355 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4356 | argv[i]); |
| 4357 | break; |
| 4358 | } |
| 4359 | if (LocaleCompare("distort",option+1) == 0) |
| 4360 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4361 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4362 | op; |
| 4363 | |
| 4364 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4365 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4366 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4367 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4368 | if (op < 0) |
| 4369 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4370 | argv[i]); |
| 4371 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4372 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4373 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4374 | break; |
| 4375 | } |
| 4376 | if (LocaleCompare("dither",option+1) == 0) |
| 4377 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4378 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4379 | method; |
| 4380 | |
| 4381 | if (*option == '+') |
| 4382 | break; |
| 4383 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4384 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4385 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4386 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4387 | if (method < 0) |
| 4388 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4389 | argv[i]); |
| 4390 | break; |
| 4391 | } |
| 4392 | if (LocaleCompare("draw",option+1) == 0) |
| 4393 | { |
| 4394 | if (*option == '+') |
| 4395 | break; |
| 4396 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4397 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4398 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4399 | break; |
| 4400 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4401 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4402 | { |
| 4403 | if (*option == '+') |
| 4404 | break; |
| 4405 | i++; |
| 4406 | if (i == (ssize_t) (argc-1)) |
| 4407 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4408 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4409 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4410 | break; |
| 4411 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4412 | if (LocaleCompare("duration",option+1) == 0) |
| 4413 | { |
| 4414 | if (*option == '+') |
| 4415 | break; |
| 4416 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4417 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4418 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4419 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4420 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4421 | break; |
| 4422 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4423 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4424 | } |
| 4425 | case 'e': |
| 4426 | { |
| 4427 | if (LocaleCompare("edge",option+1) == 0) |
| 4428 | { |
| 4429 | if (*option == '+') |
| 4430 | break; |
| 4431 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4432 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4433 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4434 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4435 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4436 | break; |
| 4437 | } |
| 4438 | if (LocaleCompare("emboss",option+1) == 0) |
| 4439 | { |
| 4440 | if (*option == '+') |
| 4441 | break; |
| 4442 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4443 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4444 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4445 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4446 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4447 | break; |
| 4448 | } |
| 4449 | if (LocaleCompare("encipher",option+1) == 0) |
| 4450 | { |
| 4451 | if (*option == '+') |
| 4452 | break; |
| 4453 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4454 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4455 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4456 | break; |
| 4457 | } |
| 4458 | if (LocaleCompare("encoding",option+1) == 0) |
| 4459 | { |
| 4460 | if (*option == '+') |
| 4461 | break; |
| 4462 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4463 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4464 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4465 | break; |
| 4466 | } |
| 4467 | if (LocaleCompare("endian",option+1) == 0) |
| 4468 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4469 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4470 | endian; |
| 4471 | |
| 4472 | if (*option == '+') |
| 4473 | break; |
| 4474 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4475 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4476 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4477 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4478 | if (endian < 0) |
| 4479 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4480 | argv[i]); |
| 4481 | break; |
| 4482 | } |
| 4483 | if (LocaleCompare("enhance",option+1) == 0) |
| 4484 | break; |
| 4485 | if (LocaleCompare("equalize",option+1) == 0) |
| 4486 | break; |
| 4487 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4488 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4489 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4490 | op; |
| 4491 | |
| 4492 | if (*option == '+') |
| 4493 | break; |
| 4494 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4495 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4496 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4497 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4498 | if (op < 0) |
| 4499 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4500 | argv[i]); |
| 4501 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4502 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4503 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4504 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4505 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4506 | break; |
| 4507 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4508 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4509 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4510 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4511 | op; |
| 4512 | |
| 4513 | if (*option == '+') |
| 4514 | break; |
| 4515 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4516 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4517 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4518 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4519 | if (op < 0) |
| 4520 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4521 | argv[i]); |
| 4522 | break; |
| 4523 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4524 | if (LocaleCompare("extent",option+1) == 0) |
| 4525 | { |
| 4526 | if (*option == '+') |
| 4527 | break; |
| 4528 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4529 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4530 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4531 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4532 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4533 | break; |
| 4534 | } |
| 4535 | if (LocaleCompare("extract",option+1) == 0) |
| 4536 | { |
| 4537 | if (*option == '+') |
| 4538 | break; |
| 4539 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4540 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4541 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4542 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4543 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4544 | break; |
| 4545 | } |
| 4546 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4547 | } |
| 4548 | case 'f': |
| 4549 | { |
| 4550 | if (LocaleCompare("family",option+1) == 0) |
| 4551 | { |
| 4552 | if (*option == '+') |
| 4553 | break; |
| 4554 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4555 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4556 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4557 | break; |
| 4558 | } |
| 4559 | if (LocaleCompare("fill",option+1) == 0) |
| 4560 | { |
| 4561 | if (*option == '+') |
| 4562 | break; |
| 4563 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4564 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4565 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4566 | break; |
| 4567 | } |
| 4568 | if (LocaleCompare("filter",option+1) == 0) |
| 4569 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4570 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4571 | filter; |
| 4572 | |
| 4573 | if (*option == '+') |
| 4574 | break; |
| 4575 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4576 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4577 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4578 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4579 | if (filter < 0) |
| 4580 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4581 | argv[i]); |
| 4582 | break; |
| 4583 | } |
| 4584 | if (LocaleCompare("flatten",option+1) == 0) |
| 4585 | break; |
| 4586 | if (LocaleCompare("flip",option+1) == 0) |
| 4587 | break; |
| 4588 | if (LocaleCompare("flop",option+1) == 0) |
| 4589 | break; |
| 4590 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4591 | { |
| 4592 | if (*option == '+') |
| 4593 | break; |
| 4594 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4595 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4596 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4597 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4598 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4599 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4600 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4601 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4602 | break; |
| 4603 | } |
| 4604 | if (LocaleCompare("font",option+1) == 0) |
| 4605 | { |
| 4606 | if (*option == '+') |
| 4607 | break; |
| 4608 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4609 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4610 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4611 | break; |
| 4612 | } |
| 4613 | if (LocaleCompare("format",option+1) == 0) |
| 4614 | { |
| 4615 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4616 | (void) CloneString(&format,(char *) NULL); |
| 4617 | if (*option == '+') |
| 4618 | break; |
| 4619 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4620 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4621 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4622 | (void) CloneString(&format,argv[i]); |
| 4623 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4624 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4625 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4626 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4627 | if (*image_info->magick == '\0') |
| 4628 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4629 | format); |
| 4630 | break; |
| 4631 | } |
| 4632 | if (LocaleCompare("frame",option+1) == 0) |
| 4633 | { |
| 4634 | if (*option == '+') |
| 4635 | break; |
| 4636 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4637 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4638 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4639 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4640 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4641 | break; |
| 4642 | } |
| 4643 | if (LocaleCompare("function",option+1) == 0) |
| 4644 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4645 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4646 | op; |
| 4647 | |
| 4648 | if (*option == '+') |
| 4649 | break; |
| 4650 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4651 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4652 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4653 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4654 | if (op < 0) |
| 4655 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4656 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4657 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4658 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4659 | break; |
| 4660 | } |
| 4661 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4662 | { |
| 4663 | if (*option == '+') |
| 4664 | break; |
| 4665 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4666 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4667 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4668 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4669 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4670 | break; |
| 4671 | } |
| 4672 | if (LocaleCompare("fx",option+1) == 0) |
| 4673 | { |
| 4674 | if (*option == '+') |
| 4675 | break; |
| 4676 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4677 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4678 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4679 | break; |
| 4680 | } |
| 4681 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4682 | } |
| 4683 | case 'g': |
| 4684 | { |
| 4685 | if (LocaleCompare("gamma",option+1) == 0) |
| 4686 | { |
| 4687 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4688 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4689 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4690 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4691 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4692 | break; |
| 4693 | } |
| 4694 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4695 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4696 | { |
| 4697 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4698 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4699 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4700 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4701 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4702 | break; |
| 4703 | } |
| 4704 | if (LocaleCompare("geometry",option+1) == 0) |
| 4705 | { |
| 4706 | if (*option == '+') |
| 4707 | break; |
| 4708 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4709 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4710 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4711 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4712 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4713 | break; |
| 4714 | } |
| 4715 | if (LocaleCompare("gravity",option+1) == 0) |
| 4716 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4717 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4718 | gravity; |
| 4719 | |
| 4720 | if (*option == '+') |
| 4721 | break; |
| 4722 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4723 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4724 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4725 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4726 | if (gravity < 0) |
| 4727 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4728 | argv[i]); |
| 4729 | break; |
| 4730 | } |
| 4731 | if (LocaleCompare("green-primary",option+1) == 0) |
| 4732 | { |
| 4733 | if (*option == '+') |
| 4734 | break; |
| 4735 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4736 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4737 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4738 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4739 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4740 | break; |
| 4741 | } |
| 4742 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4743 | } |
| 4744 | case 'h': |
| 4745 | { |
| 4746 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4747 | break; |
| 4748 | if ((LocaleCompare("help",option+1) == 0) || |
| 4749 | (LocaleCompare("-help",option+1) == 0)) |
| 4750 | return(MogrifyUsage()); |
| 4751 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4752 | } |
| 4753 | case 'i': |
| 4754 | { |
| 4755 | if (LocaleCompare("identify",option+1) == 0) |
| 4756 | break; |
| 4757 | if (LocaleCompare("idft",option+1) == 0) |
| 4758 | break; |
| 4759 | if (LocaleCompare("implode",option+1) == 0) |
| 4760 | { |
| 4761 | if (*option == '+') |
| 4762 | break; |
| 4763 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4764 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4765 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4766 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4767 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4768 | break; |
| 4769 | } |
| 4770 | if (LocaleCompare("intent",option+1) == 0) |
| 4771 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4772 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4773 | intent; |
| 4774 | |
| 4775 | if (*option == '+') |
| 4776 | break; |
| 4777 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4778 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4779 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4780 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4781 | if (intent < 0) |
| 4782 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4783 | argv[i]); |
| 4784 | break; |
| 4785 | } |
| 4786 | if (LocaleCompare("interlace",option+1) == 0) |
| 4787 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4788 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4789 | interlace; |
| 4790 | |
| 4791 | if (*option == '+') |
| 4792 | break; |
| 4793 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4794 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4795 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4796 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4797 | argv[i]); |
| 4798 | if (interlace < 0) |
| 4799 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4800 | argv[i]); |
| 4801 | break; |
| 4802 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4803 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4804 | { |
| 4805 | if (*option == '+') |
| 4806 | break; |
| 4807 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4808 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4809 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4810 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4811 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4812 | break; |
| 4813 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4814 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4815 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4816 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4817 | interpolate; |
| 4818 | |
| 4819 | if (*option == '+') |
| 4820 | break; |
| 4821 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4822 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4823 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4824 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4825 | argv[i]); |
| 4826 | if (interpolate < 0) |
| 4827 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4828 | argv[i]); |
| 4829 | break; |
| 4830 | } |
| 4831 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4832 | { |
| 4833 | if (*option == '+') |
| 4834 | break; |
| 4835 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4836 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4837 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4838 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4839 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4840 | break; |
| 4841 | } |
| 4842 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4843 | } |
| 4844 | case 'k': |
| 4845 | { |
| 4846 | if (LocaleCompare("kerning",option+1) == 0) |
| 4847 | { |
| 4848 | if (*option == '+') |
| 4849 | break; |
| 4850 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4851 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4852 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4853 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4854 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4855 | break; |
| 4856 | } |
| 4857 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4858 | } |
| 4859 | case 'l': |
| 4860 | { |
| 4861 | if (LocaleCompare("label",option+1) == 0) |
| 4862 | { |
| 4863 | if (*option == '+') |
| 4864 | break; |
| 4865 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4866 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4867 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4868 | break; |
| 4869 | } |
| 4870 | if (LocaleCompare("lat",option+1) == 0) |
| 4871 | { |
| 4872 | if (*option == '+') |
| 4873 | break; |
| 4874 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4875 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4876 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4877 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4878 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4879 | } |
| 4880 | if (LocaleCompare("layers",option+1) == 0) |
| 4881 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4882 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4883 | type; |
| 4884 | |
| 4885 | if (*option == '+') |
| 4886 | break; |
| 4887 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4888 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4889 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4890 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4891 | if (type < 0) |
| 4892 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4893 | argv[i]); |
| 4894 | break; |
| 4895 | } |
| 4896 | if (LocaleCompare("level",option+1) == 0) |
| 4897 | { |
| 4898 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4899 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4900 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4901 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4902 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4903 | break; |
| 4904 | } |
| 4905 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4906 | { |
| 4907 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4908 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4909 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4910 | break; |
| 4911 | } |
| 4912 | if (LocaleCompare("linewidth",option+1) == 0) |
| 4913 | { |
| 4914 | if (*option == '+') |
| 4915 | break; |
| 4916 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4917 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4918 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4919 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4920 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4921 | break; |
| 4922 | } |
| 4923 | if (LocaleCompare("limit",option+1) == 0) |
| 4924 | { |
| 4925 | char |
| 4926 | *p; |
| 4927 | |
| 4928 | double |
| 4929 | value; |
| 4930 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4931 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4932 | resource; |
| 4933 | |
| 4934 | if (*option == '+') |
| 4935 | break; |
| 4936 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4937 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4938 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4939 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4940 | argv[i]); |
| 4941 | if (resource < 0) |
| 4942 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4943 | argv[i]); |
| 4944 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4945 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4946 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 4947 | value=InterpretLocaleValue(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4948 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4949 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4950 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4951 | break; |
| 4952 | } |
| 4953 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4954 | { |
| 4955 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4956 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4957 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4958 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4959 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4960 | break; |
| 4961 | } |
| 4962 | if (LocaleCompare("list",option+1) == 0) |
| 4963 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4964 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4965 | list; |
| 4966 | |
| 4967 | if (*option == '+') |
| 4968 | break; |
| 4969 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4970 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4971 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4972 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4973 | if (list < 0) |
| 4974 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4975 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4976 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4977 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4978 | } |
| 4979 | if (LocaleCompare("log",option+1) == 0) |
| 4980 | { |
| 4981 | if (*option == '+') |
| 4982 | break; |
| 4983 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4984 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4985 | (strchr(argv[i],'%') == (char *) NULL)) |
| 4986 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4987 | break; |
| 4988 | } |
| 4989 | if (LocaleCompare("loop",option+1) == 0) |
| 4990 | { |
| 4991 | if (*option == '+') |
| 4992 | break; |
| 4993 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4994 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4995 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4996 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4997 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4998 | break; |
| 4999 | } |
| 5000 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5001 | } |
| 5002 | case 'm': |
| 5003 | { |
| 5004 | if (LocaleCompare("map",option+1) == 0) |
| 5005 | { |
| 5006 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 5007 | if (*option == '+') |
| 5008 | break; |
| 5009 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5010 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5011 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5012 | break; |
| 5013 | } |
| 5014 | if (LocaleCompare("mask",option+1) == 0) |
| 5015 | { |
| 5016 | if (*option == '+') |
| 5017 | break; |
| 5018 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5019 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5020 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5021 | break; |
| 5022 | } |
| 5023 | if (LocaleCompare("matte",option+1) == 0) |
| 5024 | break; |
| 5025 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 5026 | { |
| 5027 | if (*option == '+') |
| 5028 | break; |
| 5029 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5030 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5031 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5032 | break; |
| 5033 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5034 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5035 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5036 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5037 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5038 | if (LocaleCompare("modulate",option+1) == 0) |
| 5039 | { |
| 5040 | if (*option == '+') |
| 5041 | break; |
| 5042 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5043 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5044 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5045 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5046 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5047 | break; |
| 5048 | } |
| 5049 | if (LocaleCompare("median",option+1) == 0) |
| 5050 | { |
| 5051 | if (*option == '+') |
| 5052 | break; |
| 5053 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5054 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5055 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5056 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5057 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5058 | break; |
| 5059 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5060 | if (LocaleCompare("mode",option+1) == 0) |
| 5061 | { |
| 5062 | if (*option == '+') |
| 5063 | break; |
| 5064 | i++; |
| 5065 | if (i == (ssize_t) argc) |
| 5066 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5067 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5068 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5069 | break; |
| 5070 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5071 | if (LocaleCompare("monitor",option+1) == 0) |
| 5072 | break; |
| 5073 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5074 | break; |
| 5075 | if (LocaleCompare("morph",option+1) == 0) |
| 5076 | { |
| 5077 | if (*option == '+') |
| 5078 | break; |
| 5079 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5080 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5081 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5082 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5083 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5084 | break; |
| 5085 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5086 | if (LocaleCompare("morphology",option+1) == 0) |
| 5087 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5088 | char |
| 5089 | token[MaxTextExtent]; |
| 5090 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5091 | KernelInfo |
| 5092 | *kernel_info; |
| 5093 | |
| 5094 | ssize_t |
| 5095 | op; |
| 5096 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5097 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5098 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5099 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5100 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5101 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5102 | if (op < 0) |
| 5103 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5104 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5105 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5106 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5107 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5108 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5109 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5110 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5111 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5112 | break; |
| 5113 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5114 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5115 | break; |
| 5116 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5117 | { |
| 5118 | if (*option == '+') |
| 5119 | break; |
| 5120 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5121 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5122 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5123 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5124 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5125 | break; |
| 5126 | } |
| 5127 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5128 | } |
| 5129 | case 'n': |
| 5130 | { |
| 5131 | if (LocaleCompare("negate",option+1) == 0) |
| 5132 | break; |
| 5133 | if (LocaleCompare("noise",option+1) == 0) |
| 5134 | { |
| 5135 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5136 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5137 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5138 | if (*option == '+') |
| 5139 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5140 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5141 | noise; |
| 5142 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5143 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5144 | if (noise < 0) |
| 5145 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5146 | argv[i]); |
| 5147 | break; |
| 5148 | } |
| 5149 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5150 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5151 | break; |
| 5152 | } |
| 5153 | if (LocaleCompare("noop",option+1) == 0) |
| 5154 | break; |
| 5155 | if (LocaleCompare("normalize",option+1) == 0) |
| 5156 | break; |
| 5157 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5158 | } |
| 5159 | case 'o': |
| 5160 | { |
| 5161 | if (LocaleCompare("opaque",option+1) == 0) |
| 5162 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5163 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5164 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5165 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5166 | break; |
| 5167 | } |
| 5168 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5169 | { |
| 5170 | if (*option == '+') |
| 5171 | break; |
| 5172 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5173 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5174 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5175 | break; |
| 5176 | } |
| 5177 | if (LocaleCompare("orient",option+1) == 0) |
| 5178 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5179 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5180 | orientation; |
| 5181 | |
| 5182 | orientation=UndefinedOrientation; |
| 5183 | if (*option == '+') |
| 5184 | break; |
| 5185 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5186 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5187 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5188 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5189 | argv[i]); |
| 5190 | if (orientation < 0) |
| 5191 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5192 | argv[i]); |
| 5193 | break; |
| 5194 | } |
| 5195 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5196 | } |
| 5197 | case 'p': |
| 5198 | { |
| 5199 | if (LocaleCompare("page",option+1) == 0) |
| 5200 | { |
| 5201 | if (*option == '+') |
| 5202 | break; |
| 5203 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5204 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5205 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5206 | break; |
| 5207 | } |
| 5208 | if (LocaleCompare("paint",option+1) == 0) |
| 5209 | { |
| 5210 | if (*option == '+') |
| 5211 | break; |
| 5212 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5213 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5214 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5215 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5216 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5217 | break; |
| 5218 | } |
| 5219 | if (LocaleCompare("path",option+1) == 0) |
| 5220 | { |
| 5221 | (void) CloneString(&path,(char *) NULL); |
| 5222 | if (*option == '+') |
| 5223 | break; |
| 5224 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5225 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5226 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5227 | (void) CloneString(&path,argv[i]); |
| 5228 | break; |
| 5229 | } |
| 5230 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5231 | { |
| 5232 | if (*option == '+') |
| 5233 | break; |
| 5234 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5235 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5236 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5237 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5238 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5239 | break; |
| 5240 | } |
| 5241 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5242 | { |
| 5243 | if (*option == '+') |
| 5244 | break; |
| 5245 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5246 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5247 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5248 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5249 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5250 | break; |
| 5251 | } |
| 5252 | if (LocaleCompare("posterize",option+1) == 0) |
| 5253 | { |
| 5254 | if (*option == '+') |
| 5255 | break; |
| 5256 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5257 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5258 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5259 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5260 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5261 | break; |
| 5262 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5263 | if (LocaleCompare("precision",option+1) == 0) |
| 5264 | { |
| 5265 | if (*option == '+') |
| 5266 | break; |
| 5267 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5268 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5269 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5270 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5271 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5272 | break; |
| 5273 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5274 | if (LocaleCompare("print",option+1) == 0) |
| 5275 | { |
| 5276 | if (*option == '+') |
| 5277 | break; |
| 5278 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5279 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5280 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5281 | break; |
| 5282 | } |
| 5283 | if (LocaleCompare("process",option+1) == 0) |
| 5284 | { |
| 5285 | if (*option == '+') |
| 5286 | break; |
| 5287 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5288 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5289 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5290 | break; |
| 5291 | } |
| 5292 | if (LocaleCompare("profile",option+1) == 0) |
| 5293 | { |
| 5294 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5295 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5296 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5297 | break; |
| 5298 | } |
| 5299 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5300 | } |
| 5301 | case 'q': |
| 5302 | { |
| 5303 | if (LocaleCompare("quality",option+1) == 0) |
| 5304 | { |
| 5305 | if (*option == '+') |
| 5306 | break; |
| 5307 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5308 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5309 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5310 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5311 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5312 | break; |
| 5313 | } |
| 5314 | if (LocaleCompare("quantize",option+1) == 0) |
| 5315 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5316 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5317 | colorspace; |
| 5318 | |
| 5319 | if (*option == '+') |
| 5320 | break; |
| 5321 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5322 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5323 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5324 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5325 | argv[i]); |
| 5326 | if (colorspace < 0) |
| 5327 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5328 | argv[i]); |
| 5329 | break; |
| 5330 | } |
| 5331 | if (LocaleCompare("quiet",option+1) == 0) |
| 5332 | break; |
| 5333 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5334 | } |
| 5335 | case 'r': |
| 5336 | { |
| 5337 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5338 | { |
| 5339 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5340 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5341 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5342 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5343 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5344 | break; |
| 5345 | } |
| 5346 | if (LocaleCompare("raise",option+1) == 0) |
| 5347 | { |
| 5348 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5349 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5350 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5351 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5352 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5353 | break; |
| 5354 | } |
| 5355 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5356 | { |
| 5357 | if (*option == '+') |
| 5358 | break; |
| 5359 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5360 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5361 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5362 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5363 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5364 | break; |
| 5365 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5366 | if (LocaleCompare("recolor",option+1) == 0) |
| 5367 | { |
| 5368 | if (*option == '+') |
| 5369 | break; |
| 5370 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5371 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5372 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5373 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5374 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5375 | break; |
| 5376 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5377 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5378 | { |
| 5379 | if (*option == '+') |
| 5380 | break; |
| 5381 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5382 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5383 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5384 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5385 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5386 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5387 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5388 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5389 | if (LocaleCompare("region",option+1) == 0) |
| 5390 | { |
| 5391 | if (*option == '+') |
| 5392 | break; |
| 5393 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5394 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5395 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5396 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5397 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5398 | break; |
| 5399 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5400 | if (LocaleCompare("remap",option+1) == 0) |
| 5401 | { |
| 5402 | if (*option == '+') |
| 5403 | break; |
| 5404 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5405 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5406 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5407 | break; |
| 5408 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5409 | if (LocaleCompare("render",option+1) == 0) |
| 5410 | break; |
| 5411 | if (LocaleCompare("repage",option+1) == 0) |
| 5412 | { |
| 5413 | if (*option == '+') |
| 5414 | break; |
| 5415 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5416 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5417 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5418 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5419 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5420 | break; |
| 5421 | } |
| 5422 | if (LocaleCompare("resample",option+1) == 0) |
| 5423 | { |
| 5424 | if (*option == '+') |
| 5425 | break; |
| 5426 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5427 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5428 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5429 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5430 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5431 | break; |
| 5432 | } |
| 5433 | if (LocaleCompare("resize",option+1) == 0) |
| 5434 | { |
| 5435 | if (*option == '+') |
| 5436 | break; |
| 5437 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5438 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5439 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5440 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5441 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5442 | break; |
| 5443 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5444 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5445 | { |
| 5446 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5447 | break; |
| 5448 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5449 | if (LocaleCompare("reverse",option+1) == 0) |
| 5450 | break; |
| 5451 | if (LocaleCompare("roll",option+1) == 0) |
| 5452 | { |
| 5453 | if (*option == '+') |
| 5454 | break; |
| 5455 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5456 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5457 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5458 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5459 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5460 | break; |
| 5461 | } |
| 5462 | if (LocaleCompare("rotate",option+1) == 0) |
| 5463 | { |
| 5464 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5465 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5466 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5467 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5468 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5469 | break; |
| 5470 | } |
| 5471 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5472 | } |
| 5473 | case 's': |
| 5474 | { |
| 5475 | if (LocaleCompare("sample",option+1) == 0) |
| 5476 | { |
| 5477 | if (*option == '+') |
| 5478 | break; |
| 5479 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5480 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5481 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5482 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5483 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5484 | break; |
| 5485 | } |
| 5486 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5487 | { |
| 5488 | if (*option == '+') |
| 5489 | break; |
| 5490 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5491 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5492 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5493 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5494 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5495 | break; |
| 5496 | } |
| 5497 | if (LocaleCompare("scale",option+1) == 0) |
| 5498 | { |
| 5499 | if (*option == '+') |
| 5500 | break; |
| 5501 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5502 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5503 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5504 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5505 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5506 | break; |
| 5507 | } |
| 5508 | if (LocaleCompare("scene",option+1) == 0) |
| 5509 | { |
| 5510 | if (*option == '+') |
| 5511 | break; |
| 5512 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5513 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5514 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5515 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5516 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5517 | break; |
| 5518 | } |
| 5519 | if (LocaleCompare("seed",option+1) == 0) |
| 5520 | { |
| 5521 | if (*option == '+') |
| 5522 | break; |
| 5523 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5524 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5525 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5526 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5527 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5528 | break; |
| 5529 | } |
| 5530 | if (LocaleCompare("segment",option+1) == 0) |
| 5531 | { |
| 5532 | if (*option == '+') |
| 5533 | break; |
| 5534 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5535 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5536 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5537 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5538 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5539 | break; |
| 5540 | } |
| 5541 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5542 | { |
| 5543 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5544 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5545 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5546 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5547 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5548 | break; |
| 5549 | } |
| 5550 | if (LocaleCompare("separate",option+1) == 0) |
| 5551 | break; |
| 5552 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5553 | { |
| 5554 | if (*option == '+') |
| 5555 | break; |
| 5556 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5557 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5558 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5559 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5560 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5561 | break; |
| 5562 | } |
| 5563 | if (LocaleCompare("set",option+1) == 0) |
| 5564 | { |
| 5565 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5566 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5567 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5568 | if (*option == '+') |
| 5569 | break; |
| 5570 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5571 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5572 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5573 | break; |
| 5574 | } |
| 5575 | if (LocaleCompare("shade",option+1) == 0) |
| 5576 | { |
| 5577 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5578 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5579 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5580 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5581 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5582 | break; |
| 5583 | } |
| 5584 | if (LocaleCompare("shadow",option+1) == 0) |
| 5585 | { |
| 5586 | if (*option == '+') |
| 5587 | break; |
| 5588 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5589 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5590 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5591 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5592 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5593 | break; |
| 5594 | } |
| 5595 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5596 | { |
| 5597 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5598 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5599 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5600 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5601 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5602 | break; |
| 5603 | } |
| 5604 | if (LocaleCompare("shave",option+1) == 0) |
| 5605 | { |
| 5606 | if (*option == '+') |
| 5607 | break; |
| 5608 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5609 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5610 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5611 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5612 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5613 | break; |
| 5614 | } |
| 5615 | if (LocaleCompare("shear",option+1) == 0) |
| 5616 | { |
| 5617 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5618 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5619 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5620 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5621 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5622 | break; |
| 5623 | } |
| 5624 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5625 | { |
| 5626 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5627 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5628 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5629 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5630 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5631 | break; |
| 5632 | } |
| 5633 | if (LocaleCompare("size",option+1) == 0) |
| 5634 | { |
| 5635 | if (*option == '+') |
| 5636 | break; |
| 5637 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5638 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5639 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5640 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5641 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5642 | break; |
| 5643 | } |
| 5644 | if (LocaleCompare("sketch",option+1) == 0) |
| 5645 | { |
| 5646 | if (*option == '+') |
| 5647 | break; |
| 5648 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5649 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5650 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5651 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5652 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5653 | break; |
| 5654 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5655 | if (LocaleCompare("smush",option+1) == 0) |
| 5656 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5657 | i++; |
| 5658 | if (i == (ssize_t) argc) |
| 5659 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5660 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5661 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5662 | i++; |
| 5663 | break; |
| 5664 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5665 | if (LocaleCompare("solarize",option+1) == 0) |
| 5666 | { |
| 5667 | if (*option == '+') |
| 5668 | break; |
| 5669 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5670 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5671 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5672 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5673 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5674 | break; |
| 5675 | } |
| 5676 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5677 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5678 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5679 | op; |
| 5680 | |
| 5681 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5682 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5683 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5684 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5685 | if (op < 0) |
| 5686 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5687 | argv[i]); |
| 5688 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5689 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5690 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5691 | break; |
| 5692 | } |
| 5693 | if (LocaleCompare("spread",option+1) == 0) |
| 5694 | { |
| 5695 | if (*option == '+') |
| 5696 | break; |
| 5697 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5698 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5699 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5700 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5701 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5702 | break; |
| 5703 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5704 | if (LocaleCompare("statistic",option+1) == 0) |
| 5705 | { |
| 5706 | ssize_t |
| 5707 | op; |
| 5708 | |
| 5709 | if (*option == '+') |
| 5710 | break; |
| 5711 | i++; |
| 5712 | if (i == (ssize_t) argc) |
| 5713 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5714 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5715 | if (op < 0) |
| 5716 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5717 | argv[i]); |
| 5718 | i++; |
| 5719 | if (i == (ssize_t) (argc-1)) |
| 5720 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5721 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5722 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5723 | break; |
| 5724 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5725 | if (LocaleCompare("stretch",option+1) == 0) |
| 5726 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5727 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5728 | stretch; |
| 5729 | |
| 5730 | if (*option == '+') |
| 5731 | break; |
| 5732 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5733 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5734 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5735 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5736 | if (stretch < 0) |
| 5737 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5738 | argv[i]); |
| 5739 | break; |
| 5740 | } |
| 5741 | if (LocaleCompare("strip",option+1) == 0) |
| 5742 | break; |
| 5743 | if (LocaleCompare("stroke",option+1) == 0) |
| 5744 | { |
| 5745 | if (*option == '+') |
| 5746 | break; |
| 5747 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5748 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5749 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5750 | break; |
| 5751 | } |
| 5752 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5753 | { |
| 5754 | if (*option == '+') |
| 5755 | break; |
| 5756 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5757 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5758 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5759 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5760 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5761 | break; |
| 5762 | } |
| 5763 | if (LocaleCompare("style",option+1) == 0) |
| 5764 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5765 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5766 | style; |
| 5767 | |
| 5768 | if (*option == '+') |
| 5769 | break; |
| 5770 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5771 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5772 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5773 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5774 | if (style < 0) |
| 5775 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5776 | argv[i]); |
| 5777 | break; |
| 5778 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5779 | if (LocaleCompare("swap",option+1) == 0) |
| 5780 | { |
| 5781 | if (*option == '+') |
| 5782 | break; |
| 5783 | i++; |
| 5784 | if (i == (ssize_t) (argc-1)) |
| 5785 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5786 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5787 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5788 | break; |
| 5789 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5790 | if (LocaleCompare("swirl",option+1) == 0) |
| 5791 | { |
| 5792 | if (*option == '+') |
| 5793 | break; |
| 5794 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5795 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5796 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5797 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5798 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5799 | break; |
| 5800 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5801 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5802 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5803 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5804 | } |
| 5805 | case 't': |
| 5806 | { |
| 5807 | if (LocaleCompare("taint",option+1) == 0) |
| 5808 | break; |
| 5809 | if (LocaleCompare("texture",option+1) == 0) |
| 5810 | { |
| 5811 | if (*option == '+') |
| 5812 | break; |
| 5813 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5814 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5815 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5816 | break; |
| 5817 | } |
| 5818 | if (LocaleCompare("tile",option+1) == 0) |
| 5819 | { |
| 5820 | if (*option == '+') |
| 5821 | break; |
| 5822 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5823 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5824 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5825 | break; |
| 5826 | } |
| 5827 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5828 | { |
| 5829 | if (*option == '+') |
| 5830 | break; |
| 5831 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5832 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5833 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5834 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5835 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5836 | break; |
| 5837 | } |
| 5838 | if (LocaleCompare("tint",option+1) == 0) |
| 5839 | { |
| 5840 | if (*option == '+') |
| 5841 | break; |
| 5842 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5843 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5844 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5845 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5846 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5847 | break; |
| 5848 | } |
| 5849 | if (LocaleCompare("transform",option+1) == 0) |
| 5850 | break; |
| 5851 | if (LocaleCompare("transpose",option+1) == 0) |
| 5852 | break; |
| 5853 | if (LocaleCompare("transverse",option+1) == 0) |
| 5854 | break; |
| 5855 | if (LocaleCompare("threshold",option+1) == 0) |
| 5856 | { |
| 5857 | if (*option == '+') |
| 5858 | break; |
| 5859 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5860 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5861 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5862 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5863 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5864 | break; |
| 5865 | } |
| 5866 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5867 | { |
| 5868 | if (*option == '+') |
| 5869 | break; |
| 5870 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5871 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5872 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5873 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5874 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5875 | break; |
| 5876 | } |
| 5877 | if (LocaleCompare("transparent",option+1) == 0) |
| 5878 | { |
| 5879 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5880 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5881 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5882 | break; |
| 5883 | } |
| 5884 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 5885 | { |
| 5886 | if (*option == '+') |
| 5887 | break; |
| 5888 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5889 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5890 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5891 | break; |
| 5892 | } |
| 5893 | if (LocaleCompare("treedepth",option+1) == 0) |
| 5894 | { |
| 5895 | if (*option == '+') |
| 5896 | break; |
| 5897 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5898 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5899 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5900 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5901 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5902 | break; |
| 5903 | } |
| 5904 | if (LocaleCompare("trim",option+1) == 0) |
| 5905 | break; |
| 5906 | if (LocaleCompare("type",option+1) == 0) |
| 5907 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5908 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5909 | type; |
| 5910 | |
| 5911 | if (*option == '+') |
| 5912 | break; |
| 5913 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5914 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5915 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5916 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5917 | if (type < 0) |
| 5918 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5919 | argv[i]); |
| 5920 | break; |
| 5921 | } |
| 5922 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5923 | } |
| 5924 | case 'u': |
| 5925 | { |
| 5926 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5927 | { |
| 5928 | if (*option == '+') |
| 5929 | break; |
| 5930 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5931 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5932 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5933 | break; |
| 5934 | } |
| 5935 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5936 | break; |
| 5937 | if (LocaleCompare("units",option+1) == 0) |
| 5938 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5939 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5940 | units; |
| 5941 | |
| 5942 | if (*option == '+') |
| 5943 | break; |
| 5944 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5945 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5946 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5947 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5948 | argv[i]); |
| 5949 | if (units < 0) |
| 5950 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5951 | argv[i]); |
| 5952 | break; |
| 5953 | } |
| 5954 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5955 | { |
| 5956 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5957 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5958 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5959 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5960 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5961 | break; |
| 5962 | } |
| 5963 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5964 | } |
| 5965 | case 'v': |
| 5966 | { |
| 5967 | if (LocaleCompare("verbose",option+1) == 0) |
| 5968 | { |
| 5969 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 5970 | break; |
| 5971 | } |
| 5972 | if ((LocaleCompare("version",option+1) == 0) || |
| 5973 | (LocaleCompare("-version",option+1) == 0)) |
| 5974 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 5975 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5976 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 5977 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 5978 | GetMagickCopyright()); |
| 5979 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 5980 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5981 | break; |
| 5982 | } |
| 5983 | if (LocaleCompare("view",option+1) == 0) |
| 5984 | { |
| 5985 | if (*option == '+') |
| 5986 | break; |
| 5987 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5988 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5989 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5990 | break; |
| 5991 | } |
| 5992 | if (LocaleCompare("vignette",option+1) == 0) |
| 5993 | { |
| 5994 | if (*option == '+') |
| 5995 | break; |
| 5996 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5997 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5998 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5999 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6000 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6001 | break; |
| 6002 | } |
| 6003 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 6004 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6005 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6006 | method; |
| 6007 | |
| 6008 | if (*option == '+') |
| 6009 | break; |
| 6010 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6011 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6012 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6013 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6014 | argv[i]); |
| 6015 | if (method < 0) |
| 6016 | ThrowMogrifyException(OptionError, |
| 6017 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 6018 | break; |
| 6019 | } |
| 6020 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6021 | } |
| 6022 | case 'w': |
| 6023 | { |
| 6024 | if (LocaleCompare("wave",option+1) == 0) |
| 6025 | { |
| 6026 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6027 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6028 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6029 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6030 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6031 | break; |
| 6032 | } |
| 6033 | if (LocaleCompare("weight",option+1) == 0) |
| 6034 | { |
| 6035 | if (*option == '+') |
| 6036 | break; |
| 6037 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6038 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6039 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6040 | break; |
| 6041 | } |
| 6042 | if (LocaleCompare("white-point",option+1) == 0) |
| 6043 | { |
| 6044 | if (*option == '+') |
| 6045 | break; |
| 6046 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6047 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6048 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6049 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6050 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6051 | break; |
| 6052 | } |
| 6053 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6054 | { |
| 6055 | if (*option == '+') |
| 6056 | break; |
| 6057 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6058 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6059 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6060 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6061 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6062 | break; |
| 6063 | } |
| 6064 | if (LocaleCompare("write",option+1) == 0) |
| 6065 | { |
| 6066 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6067 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6068 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6069 | break; |
| 6070 | } |
| 6071 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6072 | } |
| 6073 | case '?': |
| 6074 | break; |
| 6075 | default: |
| 6076 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6077 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6078 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 6079 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6080 | if (fire != MagickFalse) |
| 6081 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6082 | } |
| 6083 | if (k != 0) |
| 6084 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6085 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6086 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6087 | DestroyMogrify(); |
| 6088 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6089 | } |
| 6090 | |
| 6091 | /* |
| 6092 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6093 | % % |
| 6094 | % % |
| 6095 | % % |
| 6096 | + M o g r i f y I m a g e I n f o % |
| 6097 | % % |
| 6098 | % % |
| 6099 | % % |
| 6100 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6101 | % |
| 6102 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6103 | % prescribed by command line options. |
| 6104 | % |
| 6105 | % The format of the MogrifyImageInfo method is: |
| 6106 | % |
| 6107 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6108 | % const char **argv,ExceptionInfo *exception) |
| 6109 | % |
| 6110 | % A description of each parameter follows: |
| 6111 | % |
| 6112 | % o image_info: the image info.. |
| 6113 | % |
| 6114 | % o argc: Specifies a pointer to an integer describing the number of |
| 6115 | % elements in the argument vector. |
| 6116 | % |
| 6117 | % o argv: Specifies a pointer to a text array containing the command line |
| 6118 | % arguments. |
| 6119 | % |
| 6120 | % o exception: return any errors or warnings in this structure. |
| 6121 | % |
| 6122 | */ |
| 6123 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6124 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6125 | { |
| 6126 | const char |
| 6127 | *option; |
| 6128 | |
| 6129 | GeometryInfo |
| 6130 | geometry_info; |
| 6131 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6132 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6133 | count; |
| 6134 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6135 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6136 | i; |
| 6137 | |
| 6138 | /* |
| 6139 | Initialize method variables. |
| 6140 | */ |
| 6141 | assert(image_info != (ImageInfo *) NULL); |
| 6142 | assert(image_info->signature == MagickSignature); |
| 6143 | if (image_info->debug != MagickFalse) |
| 6144 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6145 | image_info->filename); |
| 6146 | if (argc < 0) |
| 6147 | return(MagickTrue); |
| 6148 | /* |
| 6149 | Set the image settings. |
| 6150 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6151 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6152 | { |
| 6153 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6154 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6155 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6156 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6157 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6158 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6159 | break; |
| 6160 | switch (*(option+1)) |
| 6161 | { |
| 6162 | case 'a': |
| 6163 | { |
| 6164 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6165 | { |
| 6166 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6167 | break; |
| 6168 | } |
| 6169 | if (LocaleCompare("antialias",option+1) == 0) |
| 6170 | { |
| 6171 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6172 | break; |
| 6173 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6174 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6175 | { |
| 6176 | if (*option == '+') |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 6177 | (void) DeleteImageOption(image_info,option+1); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6178 | else |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 6179 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6180 | break; |
| 6181 | } |
| 6182 | break; |
| 6183 | } |
| 6184 | case 'b': |
| 6185 | { |
| 6186 | if (LocaleCompare("background",option+1) == 0) |
| 6187 | { |
| 6188 | if (*option == '+') |
| 6189 | { |
| 6190 | (void) DeleteImageOption(image_info,option+1); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6191 | (void) QueryColorCompliance(MogrifyBackgroundColor, |
| 6192 | AllCompliance,&image_info->background_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6193 | break; |
| 6194 | } |
| 6195 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6196 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6197 | &image_info->background_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6198 | break; |
| 6199 | } |
| 6200 | if (LocaleCompare("bias",option+1) == 0) |
| 6201 | { |
| 6202 | if (*option == '+') |
| 6203 | { |
| 6204 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6205 | break; |
| 6206 | } |
| 6207 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6208 | break; |
| 6209 | } |
| 6210 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6211 | { |
| 6212 | if (*option == '+') |
| 6213 | { |
| 6214 | (void) SetImageOption(image_info,option+1,"false"); |
| 6215 | break; |
| 6216 | } |
| 6217 | (void) SetImageOption(image_info,option+1,"true"); |
| 6218 | break; |
| 6219 | } |
| 6220 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6221 | { |
| 6222 | if (*option == '+') |
| 6223 | { |
| 6224 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6225 | break; |
| 6226 | } |
| 6227 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6228 | break; |
| 6229 | } |
| 6230 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6231 | { |
| 6232 | if (*option == '+') |
| 6233 | { |
| 6234 | (void) DeleteImageOption(image_info,option+1); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6235 | (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6236 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6237 | break; |
| 6238 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6239 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6240 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6241 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6242 | break; |
| 6243 | } |
| 6244 | if (LocaleCompare("box",option+1) == 0) |
| 6245 | { |
| 6246 | if (*option == '+') |
| 6247 | { |
| 6248 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6249 | break; |
| 6250 | } |
| 6251 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6252 | break; |
| 6253 | } |
| 6254 | break; |
| 6255 | } |
| 6256 | case 'c': |
| 6257 | { |
| 6258 | if (LocaleCompare("cache",option+1) == 0) |
| 6259 | { |
| 6260 | MagickSizeType |
| 6261 | limit; |
| 6262 | |
| 6263 | limit=MagickResourceInfinity; |
| 6264 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6265 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6266 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6267 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6268 | break; |
| 6269 | } |
| 6270 | if (LocaleCompare("caption",option+1) == 0) |
| 6271 | { |
| 6272 | if (*option == '+') |
| 6273 | { |
| 6274 | (void) DeleteImageOption(image_info,option+1); |
| 6275 | break; |
| 6276 | } |
| 6277 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6278 | break; |
| 6279 | } |
| 6280 | if (LocaleCompare("channel",option+1) == 0) |
| 6281 | { |
| 6282 | if (*option == '+') |
| 6283 | { |
| 6284 | image_info->channel=DefaultChannels; |
| 6285 | break; |
| 6286 | } |
| 6287 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6288 | break; |
| 6289 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6290 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6291 | { |
| 6292 | if (*option == '+') |
| 6293 | { |
| 6294 | image_info->colorspace=UndefinedColorspace; |
| 6295 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6296 | break; |
| 6297 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6298 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6299 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6300 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6301 | break; |
| 6302 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6303 | if (LocaleCompare("comment",option+1) == 0) |
| 6304 | { |
| 6305 | if (*option == '+') |
| 6306 | { |
| 6307 | (void) DeleteImageOption(image_info,option+1); |
| 6308 | break; |
| 6309 | } |
| 6310 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6311 | break; |
| 6312 | } |
| 6313 | if (LocaleCompare("compose",option+1) == 0) |
| 6314 | { |
| 6315 | if (*option == '+') |
| 6316 | { |
| 6317 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6318 | break; |
| 6319 | } |
| 6320 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6321 | break; |
| 6322 | } |
| 6323 | if (LocaleCompare("compress",option+1) == 0) |
| 6324 | { |
| 6325 | if (*option == '+') |
| 6326 | { |
| 6327 | image_info->compression=UndefinedCompression; |
| 6328 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6329 | break; |
| 6330 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6331 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6332 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6333 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6334 | break; |
| 6335 | } |
| 6336 | break; |
| 6337 | } |
| 6338 | case 'd': |
| 6339 | { |
| 6340 | if (LocaleCompare("debug",option+1) == 0) |
| 6341 | { |
| 6342 | if (*option == '+') |
| 6343 | (void) SetLogEventMask("none"); |
| 6344 | else |
| 6345 | (void) SetLogEventMask(argv[i+1]); |
| 6346 | image_info->debug=IsEventLogging(); |
| 6347 | break; |
| 6348 | } |
| 6349 | if (LocaleCompare("define",option+1) == 0) |
| 6350 | { |
| 6351 | if (*option == '+') |
| 6352 | { |
| 6353 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6354 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6355 | else |
| 6356 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6357 | break; |
| 6358 | } |
| 6359 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6360 | { |
| 6361 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6362 | exception); |
| 6363 | break; |
| 6364 | } |
| 6365 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6366 | break; |
| 6367 | } |
| 6368 | if (LocaleCompare("delay",option+1) == 0) |
| 6369 | { |
| 6370 | if (*option == '+') |
| 6371 | { |
| 6372 | (void) SetImageOption(image_info,option+1,"0"); |
| 6373 | break; |
| 6374 | } |
| 6375 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6376 | break; |
| 6377 | } |
| 6378 | if (LocaleCompare("density",option+1) == 0) |
| 6379 | { |
| 6380 | /* |
| 6381 | Set image density. |
| 6382 | */ |
| 6383 | if (*option == '+') |
| 6384 | { |
| 6385 | if (image_info->density != (char *) NULL) |
| 6386 | image_info->density=DestroyString(image_info->density); |
| 6387 | (void) SetImageOption(image_info,option+1,"72"); |
| 6388 | break; |
| 6389 | } |
| 6390 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6391 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6392 | break; |
| 6393 | } |
| 6394 | if (LocaleCompare("depth",option+1) == 0) |
| 6395 | { |
| 6396 | if (*option == '+') |
| 6397 | { |
| 6398 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6399 | break; |
| 6400 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6401 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6402 | break; |
| 6403 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6404 | if (LocaleCompare("direction",option+1) == 0) |
| 6405 | { |
| 6406 | if (*option == '+') |
| 6407 | { |
| 6408 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6409 | break; |
| 6410 | } |
| 6411 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6412 | break; |
| 6413 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6414 | if (LocaleCompare("display",option+1) == 0) |
| 6415 | { |
| 6416 | if (*option == '+') |
| 6417 | { |
| 6418 | if (image_info->server_name != (char *) NULL) |
| 6419 | image_info->server_name=DestroyString( |
| 6420 | image_info->server_name); |
| 6421 | break; |
| 6422 | } |
| 6423 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6424 | break; |
| 6425 | } |
| 6426 | if (LocaleCompare("dispose",option+1) == 0) |
| 6427 | { |
| 6428 | if (*option == '+') |
| 6429 | { |
| 6430 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6431 | break; |
| 6432 | } |
| 6433 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6434 | break; |
| 6435 | } |
| 6436 | if (LocaleCompare("dither",option+1) == 0) |
| 6437 | { |
| 6438 | if (*option == '+') |
| 6439 | { |
| 6440 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6441 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6442 | break; |
| 6443 | } |
| 6444 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6445 | image_info->dither=MagickTrue; |
| 6446 | break; |
| 6447 | } |
| 6448 | break; |
| 6449 | } |
| 6450 | case 'e': |
| 6451 | { |
| 6452 | if (LocaleCompare("encoding",option+1) == 0) |
| 6453 | { |
| 6454 | if (*option == '+') |
| 6455 | { |
| 6456 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6457 | break; |
| 6458 | } |
| 6459 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6460 | break; |
| 6461 | } |
| 6462 | if (LocaleCompare("endian",option+1) == 0) |
| 6463 | { |
| 6464 | if (*option == '+') |
| 6465 | { |
| 6466 | image_info->endian=UndefinedEndian; |
| 6467 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6468 | break; |
| 6469 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6470 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6471 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6472 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6473 | break; |
| 6474 | } |
| 6475 | if (LocaleCompare("extract",option+1) == 0) |
| 6476 | { |
| 6477 | /* |
| 6478 | Set image extract geometry. |
| 6479 | */ |
| 6480 | if (*option == '+') |
| 6481 | { |
| 6482 | if (image_info->extract != (char *) NULL) |
| 6483 | image_info->extract=DestroyString(image_info->extract); |
| 6484 | break; |
| 6485 | } |
| 6486 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6487 | break; |
| 6488 | } |
| 6489 | break; |
| 6490 | } |
| 6491 | case 'f': |
| 6492 | { |
| 6493 | if (LocaleCompare("fill",option+1) == 0) |
| 6494 | { |
| 6495 | if (*option == '+') |
| 6496 | { |
| 6497 | (void) SetImageOption(image_info,option+1,"none"); |
| 6498 | break; |
| 6499 | } |
| 6500 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6501 | break; |
| 6502 | } |
| 6503 | if (LocaleCompare("filter",option+1) == 0) |
| 6504 | { |
| 6505 | if (*option == '+') |
| 6506 | { |
| 6507 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6508 | break; |
| 6509 | } |
| 6510 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6511 | break; |
| 6512 | } |
| 6513 | if (LocaleCompare("font",option+1) == 0) |
| 6514 | { |
| 6515 | if (*option == '+') |
| 6516 | { |
| 6517 | if (image_info->font != (char *) NULL) |
| 6518 | image_info->font=DestroyString(image_info->font); |
| 6519 | break; |
| 6520 | } |
| 6521 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6522 | break; |
| 6523 | } |
| 6524 | if (LocaleCompare("format",option+1) == 0) |
| 6525 | { |
| 6526 | register const char |
| 6527 | *q; |
| 6528 | |
| 6529 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6530 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6531 | image_info->ping=MagickFalse; |
| 6532 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6533 | break; |
| 6534 | } |
| 6535 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6536 | { |
| 6537 | if (*option == '+') |
| 6538 | { |
| 6539 | image_info->fuzz=0.0; |
| 6540 | (void) SetImageOption(image_info,option+1,"0"); |
| 6541 | break; |
| 6542 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6543 | image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6544 | 1.0); |
| 6545 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6546 | break; |
| 6547 | } |
| 6548 | break; |
| 6549 | } |
| 6550 | case 'g': |
| 6551 | { |
| 6552 | if (LocaleCompare("gravity",option+1) == 0) |
| 6553 | { |
| 6554 | if (*option == '+') |
| 6555 | { |
| 6556 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6557 | break; |
| 6558 | } |
| 6559 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6560 | break; |
| 6561 | } |
| 6562 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6563 | { |
| 6564 | if (*option == '+') |
| 6565 | { |
| 6566 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6567 | break; |
| 6568 | } |
| 6569 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6570 | break; |
| 6571 | } |
| 6572 | break; |
| 6573 | } |
| 6574 | case 'i': |
| 6575 | { |
| 6576 | if (LocaleCompare("intent",option+1) == 0) |
| 6577 | { |
| 6578 | if (*option == '+') |
| 6579 | { |
| 6580 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6581 | break; |
| 6582 | } |
| 6583 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6584 | break; |
| 6585 | } |
| 6586 | if (LocaleCompare("interlace",option+1) == 0) |
| 6587 | { |
| 6588 | if (*option == '+') |
| 6589 | { |
| 6590 | image_info->interlace=UndefinedInterlace; |
| 6591 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6592 | break; |
| 6593 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6594 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6595 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6596 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6597 | break; |
| 6598 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6599 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6600 | { |
| 6601 | if (*option == '+') |
| 6602 | { |
| 6603 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6604 | break; |
| 6605 | } |
| 6606 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6607 | break; |
| 6608 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6609 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6610 | { |
| 6611 | if (*option == '+') |
| 6612 | { |
| 6613 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6614 | break; |
| 6615 | } |
| 6616 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6617 | break; |
| 6618 | } |
| 6619 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6620 | { |
| 6621 | if (*option == '+') |
| 6622 | { |
| 6623 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6624 | break; |
| 6625 | } |
| 6626 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6627 | break; |
| 6628 | } |
| 6629 | break; |
| 6630 | } |
| 6631 | case 'k': |
| 6632 | { |
| 6633 | if (LocaleCompare("kerning",option+1) == 0) |
| 6634 | { |
| 6635 | if (*option == '+') |
| 6636 | { |
| 6637 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6638 | break; |
| 6639 | } |
| 6640 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6641 | break; |
| 6642 | } |
| 6643 | break; |
| 6644 | } |
| 6645 | case 'l': |
| 6646 | { |
| 6647 | if (LocaleCompare("label",option+1) == 0) |
| 6648 | { |
| 6649 | if (*option == '+') |
| 6650 | { |
| 6651 | (void) DeleteImageOption(image_info,option+1); |
| 6652 | break; |
| 6653 | } |
| 6654 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6655 | break; |
| 6656 | } |
| 6657 | if (LocaleCompare("limit",option+1) == 0) |
| 6658 | { |
| 6659 | MagickSizeType |
| 6660 | limit; |
| 6661 | |
| 6662 | ResourceType |
| 6663 | type; |
| 6664 | |
| 6665 | if (*option == '+') |
| 6666 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6667 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6668 | MagickFalse,argv[i+1]); |
| 6669 | limit=MagickResourceInfinity; |
| 6670 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6671 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6672 | (void) SetMagickResourceLimit(type,limit); |
| 6673 | break; |
| 6674 | } |
| 6675 | if (LocaleCompare("list",option+1) == 0) |
| 6676 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6677 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6678 | list; |
| 6679 | |
| 6680 | /* |
| 6681 | Display configuration list. |
| 6682 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6683 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6684 | switch (list) |
| 6685 | { |
| 6686 | case MagickCoderOptions: |
| 6687 | { |
| 6688 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6689 | break; |
| 6690 | } |
| 6691 | case MagickColorOptions: |
| 6692 | { |
| 6693 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6694 | break; |
| 6695 | } |
| 6696 | case MagickConfigureOptions: |
| 6697 | { |
| 6698 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6699 | break; |
| 6700 | } |
| 6701 | case MagickDelegateOptions: |
| 6702 | { |
| 6703 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6704 | break; |
| 6705 | } |
| 6706 | case MagickFontOptions: |
| 6707 | { |
| 6708 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6709 | break; |
| 6710 | } |
| 6711 | case MagickFormatOptions: |
| 6712 | { |
| 6713 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6714 | break; |
| 6715 | } |
| 6716 | case MagickLocaleOptions: |
| 6717 | { |
| 6718 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6719 | break; |
| 6720 | } |
| 6721 | case MagickLogOptions: |
| 6722 | { |
| 6723 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6724 | break; |
| 6725 | } |
| 6726 | case MagickMagicOptions: |
| 6727 | { |
| 6728 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6729 | break; |
| 6730 | } |
| 6731 | case MagickMimeOptions: |
| 6732 | { |
| 6733 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6734 | break; |
| 6735 | } |
| 6736 | case MagickModuleOptions: |
| 6737 | { |
| 6738 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6739 | break; |
| 6740 | } |
| 6741 | case MagickPolicyOptions: |
| 6742 | { |
| 6743 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6744 | break; |
| 6745 | } |
| 6746 | case MagickResourceOptions: |
| 6747 | { |
| 6748 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6749 | break; |
| 6750 | } |
| 6751 | case MagickThresholdOptions: |
| 6752 | { |
| 6753 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6754 | break; |
| 6755 | } |
| 6756 | default: |
| 6757 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6758 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6759 | exception); |
| 6760 | break; |
| 6761 | } |
| 6762 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6763 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6764 | } |
| 6765 | if (LocaleCompare("log",option+1) == 0) |
| 6766 | { |
| 6767 | if (*option == '+') |
| 6768 | break; |
| 6769 | (void) SetLogFormat(argv[i+1]); |
| 6770 | break; |
| 6771 | } |
| 6772 | if (LocaleCompare("loop",option+1) == 0) |
| 6773 | { |
| 6774 | if (*option == '+') |
| 6775 | { |
| 6776 | (void) SetImageOption(image_info,option+1,"0"); |
| 6777 | break; |
| 6778 | } |
| 6779 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6780 | break; |
| 6781 | } |
| 6782 | break; |
| 6783 | } |
| 6784 | case 'm': |
| 6785 | { |
| 6786 | if (LocaleCompare("matte",option+1) == 0) |
| 6787 | { |
| 6788 | if (*option == '+') |
| 6789 | { |
| 6790 | (void) SetImageOption(image_info,option+1,"false"); |
| 6791 | break; |
| 6792 | } |
| 6793 | (void) SetImageOption(image_info,option+1,"true"); |
| 6794 | break; |
| 6795 | } |
| 6796 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6797 | { |
| 6798 | if (*option == '+') |
| 6799 | { |
| 6800 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6801 | (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance, |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6802 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6803 | break; |
| 6804 | } |
| 6805 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6806 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6807 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6808 | break; |
| 6809 | } |
| 6810 | if (LocaleCompare("monitor",option+1) == 0) |
| 6811 | { |
| 6812 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6813 | (void *) NULL); |
| 6814 | break; |
| 6815 | } |
| 6816 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6817 | { |
| 6818 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6819 | break; |
| 6820 | } |
| 6821 | break; |
| 6822 | } |
| 6823 | case 'o': |
| 6824 | { |
| 6825 | if (LocaleCompare("orient",option+1) == 0) |
| 6826 | { |
| 6827 | if (*option == '+') |
| 6828 | { |
| 6829 | image_info->orientation=UndefinedOrientation; |
| 6830 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6831 | break; |
| 6832 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6833 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6834 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6835 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6836 | break; |
| 6837 | } |
| 6838 | } |
| 6839 | case 'p': |
| 6840 | { |
| 6841 | if (LocaleCompare("page",option+1) == 0) |
| 6842 | { |
| 6843 | char |
| 6844 | *canonical_page, |
| 6845 | page[MaxTextExtent]; |
| 6846 | |
| 6847 | const char |
| 6848 | *image_option; |
| 6849 | |
| 6850 | MagickStatusType |
| 6851 | flags; |
| 6852 | |
| 6853 | RectangleInfo |
| 6854 | geometry; |
| 6855 | |
| 6856 | if (*option == '+') |
| 6857 | { |
| 6858 | (void) DeleteImageOption(image_info,option+1); |
| 6859 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6860 | break; |
| 6861 | } |
| 6862 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6863 | image_option=GetImageOption(image_info,"page"); |
| 6864 | if (image_option != (const char *) NULL) |
| 6865 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6866 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6867 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6868 | canonical_page=DestroyString(canonical_page); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6869 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6870 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6871 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6872 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6873 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6874 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6875 | (void) SetImageOption(image_info,option+1,page); |
| 6876 | (void) CloneString(&image_info->page,page); |
| 6877 | break; |
| 6878 | } |
| 6879 | if (LocaleCompare("pen",option+1) == 0) |
| 6880 | { |
| 6881 | if (*option == '+') |
| 6882 | { |
| 6883 | (void) SetImageOption(image_info,option+1,"none"); |
| 6884 | break; |
| 6885 | } |
| 6886 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6887 | break; |
| 6888 | } |
| 6889 | if (LocaleCompare("ping",option+1) == 0) |
| 6890 | { |
| 6891 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6892 | break; |
| 6893 | } |
| 6894 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6895 | { |
| 6896 | if (*option == '+') |
| 6897 | geometry_info.rho=0.0; |
| 6898 | else |
| 6899 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6900 | image_info->pointsize=geometry_info.rho; |
| 6901 | break; |
| 6902 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6903 | if (LocaleCompare("precision",option+1) == 0) |
| 6904 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6905 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6906 | break; |
| 6907 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6908 | if (LocaleCompare("preview",option+1) == 0) |
| 6909 | { |
| 6910 | /* |
| 6911 | Preview image. |
| 6912 | */ |
| 6913 | if (*option == '+') |
| 6914 | { |
| 6915 | image_info->preview_type=UndefinedPreview; |
| 6916 | break; |
| 6917 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6918 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6919 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6920 | break; |
| 6921 | } |
| 6922 | break; |
| 6923 | } |
| 6924 | case 'q': |
| 6925 | { |
| 6926 | if (LocaleCompare("quality",option+1) == 0) |
| 6927 | { |
| 6928 | /* |
| 6929 | Set image compression quality. |
| 6930 | */ |
| 6931 | if (*option == '+') |
| 6932 | { |
| 6933 | image_info->quality=UndefinedCompressionQuality; |
| 6934 | (void) SetImageOption(image_info,option+1,"0"); |
| 6935 | break; |
| 6936 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6937 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6938 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6939 | break; |
| 6940 | } |
| 6941 | if (LocaleCompare("quiet",option+1) == 0) |
| 6942 | { |
| 6943 | static WarningHandler |
| 6944 | warning_handler = (WarningHandler) NULL; |
| 6945 | |
| 6946 | if (*option == '+') |
| 6947 | { |
| 6948 | /* |
| 6949 | Restore error or warning messages. |
| 6950 | */ |
| 6951 | warning_handler=SetWarningHandler(warning_handler); |
| 6952 | break; |
| 6953 | } |
| 6954 | /* |
| 6955 | Suppress error or warning messages. |
| 6956 | */ |
| 6957 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6958 | break; |
| 6959 | } |
| 6960 | break; |
| 6961 | } |
| 6962 | case 'r': |
| 6963 | { |
| 6964 | if (LocaleCompare("red-primary",option+1) == 0) |
| 6965 | { |
| 6966 | if (*option == '+') |
| 6967 | { |
| 6968 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6969 | break; |
| 6970 | } |
| 6971 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6972 | break; |
| 6973 | } |
| 6974 | break; |
| 6975 | } |
| 6976 | case 's': |
| 6977 | { |
| 6978 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 6979 | { |
| 6980 | /* |
| 6981 | Set image sampling factor. |
| 6982 | */ |
| 6983 | if (*option == '+') |
| 6984 | { |
| 6985 | if (image_info->sampling_factor != (char *) NULL) |
| 6986 | image_info->sampling_factor=DestroyString( |
| 6987 | image_info->sampling_factor); |
| 6988 | break; |
| 6989 | } |
| 6990 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 6991 | break; |
| 6992 | } |
| 6993 | if (LocaleCompare("scene",option+1) == 0) |
| 6994 | { |
| 6995 | /* |
| 6996 | Set image scene. |
| 6997 | */ |
| 6998 | if (*option == '+') |
| 6999 | { |
| 7000 | image_info->scene=0; |
| 7001 | (void) SetImageOption(image_info,option+1,"0"); |
| 7002 | break; |
| 7003 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7004 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7005 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7006 | break; |
| 7007 | } |
| 7008 | if (LocaleCompare("seed",option+1) == 0) |
| 7009 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7010 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7011 | seed; |
| 7012 | |
| 7013 | if (*option == '+') |
| 7014 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7015 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7016 | SeedPseudoRandomGenerator(seed); |
| 7017 | break; |
| 7018 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7019 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7020 | SeedPseudoRandomGenerator(seed); |
| 7021 | break; |
| 7022 | } |
| 7023 | if (LocaleCompare("size",option+1) == 0) |
| 7024 | { |
| 7025 | if (*option == '+') |
| 7026 | { |
| 7027 | if (image_info->size != (char *) NULL) |
| 7028 | image_info->size=DestroyString(image_info->size); |
| 7029 | break; |
| 7030 | } |
| 7031 | (void) CloneString(&image_info->size,argv[i+1]); |
| 7032 | break; |
| 7033 | } |
| 7034 | if (LocaleCompare("stroke",option+1) == 0) |
| 7035 | { |
| 7036 | if (*option == '+') |
| 7037 | { |
| 7038 | (void) SetImageOption(image_info,option+1,"none"); |
| 7039 | break; |
| 7040 | } |
| 7041 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7042 | break; |
| 7043 | } |
| 7044 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7045 | { |
| 7046 | if (*option == '+') |
| 7047 | { |
| 7048 | (void) SetImageOption(image_info,option+1,"0"); |
| 7049 | break; |
| 7050 | } |
| 7051 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7052 | break; |
| 7053 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7054 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7055 | { |
| 7056 | if (*option == '+') |
| 7057 | { |
| 7058 | image_info->synchronize=MagickFalse; |
| 7059 | break; |
| 7060 | } |
| 7061 | image_info->synchronize=MagickTrue; |
| 7062 | break; |
| 7063 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7064 | break; |
| 7065 | } |
| 7066 | case 't': |
| 7067 | { |
| 7068 | if (LocaleCompare("taint",option+1) == 0) |
| 7069 | { |
| 7070 | if (*option == '+') |
| 7071 | { |
| 7072 | (void) SetImageOption(image_info,option+1,"false"); |
| 7073 | break; |
| 7074 | } |
| 7075 | (void) SetImageOption(image_info,option+1,"true"); |
| 7076 | break; |
| 7077 | } |
| 7078 | if (LocaleCompare("texture",option+1) == 0) |
| 7079 | { |
| 7080 | if (*option == '+') |
| 7081 | { |
| 7082 | if (image_info->texture != (char *) NULL) |
| 7083 | image_info->texture=DestroyString(image_info->texture); |
| 7084 | break; |
| 7085 | } |
| 7086 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7087 | break; |
| 7088 | } |
| 7089 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7090 | { |
| 7091 | if (*option == '+') |
| 7092 | { |
| 7093 | (void) SetImageOption(image_info,option+1,"0"); |
| 7094 | break; |
| 7095 | } |
| 7096 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7097 | break; |
| 7098 | } |
| 7099 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7100 | { |
| 7101 | if (*option == '+') |
| 7102 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 7103 | (void) QueryColorCompliance("none",AllCompliance, |
| 7104 | &image_info->transparent_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7105 | (void) SetImageOption(image_info,option+1,"none"); |
| 7106 | break; |
| 7107 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 7108 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 7109 | &image_info->transparent_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7110 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7111 | break; |
| 7112 | } |
| 7113 | if (LocaleCompare("type",option+1) == 0) |
| 7114 | { |
| 7115 | if (*option == '+') |
| 7116 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7117 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7118 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7119 | break; |
| 7120 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7121 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7122 | MagickFalse,argv[i+1]); |
| 7123 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7124 | break; |
| 7125 | } |
| 7126 | break; |
| 7127 | } |
| 7128 | case 'u': |
| 7129 | { |
| 7130 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7131 | { |
| 7132 | if (*option == '+') |
| 7133 | { |
| 7134 | (void) DeleteImageOption(image_info,option+1); |
| 7135 | break; |
| 7136 | } |
| 7137 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7138 | break; |
| 7139 | } |
| 7140 | if (LocaleCompare("units",option+1) == 0) |
| 7141 | { |
| 7142 | if (*option == '+') |
| 7143 | { |
| 7144 | image_info->units=UndefinedResolution; |
| 7145 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7146 | break; |
| 7147 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7148 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7149 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7150 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7151 | break; |
| 7152 | } |
| 7153 | break; |
| 7154 | } |
| 7155 | case 'v': |
| 7156 | { |
| 7157 | if (LocaleCompare("verbose",option+1) == 0) |
| 7158 | { |
| 7159 | if (*option == '+') |
| 7160 | { |
| 7161 | image_info->verbose=MagickFalse; |
| 7162 | break; |
| 7163 | } |
| 7164 | image_info->verbose=MagickTrue; |
| 7165 | image_info->ping=MagickFalse; |
| 7166 | break; |
| 7167 | } |
| 7168 | if (LocaleCompare("view",option+1) == 0) |
| 7169 | { |
| 7170 | if (*option == '+') |
| 7171 | { |
| 7172 | if (image_info->view != (char *) NULL) |
| 7173 | image_info->view=DestroyString(image_info->view); |
| 7174 | break; |
| 7175 | } |
| 7176 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7177 | break; |
| 7178 | } |
| 7179 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7180 | { |
| 7181 | if (*option == '+') |
| 7182 | { |
| 7183 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7184 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7185 | break; |
| 7186 | } |
| 7187 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7188 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7189 | argv[i+1]); |
| 7190 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7191 | break; |
| 7192 | } |
| 7193 | break; |
| 7194 | } |
| 7195 | case 'w': |
| 7196 | { |
| 7197 | if (LocaleCompare("white-point",option+1) == 0) |
| 7198 | { |
| 7199 | if (*option == '+') |
| 7200 | { |
| 7201 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7202 | break; |
| 7203 | } |
| 7204 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7205 | break; |
| 7206 | } |
| 7207 | break; |
| 7208 | } |
| 7209 | default: |
| 7210 | break; |
| 7211 | } |
| 7212 | i+=count; |
| 7213 | } |
| 7214 | return(MagickTrue); |
| 7215 | } |
| 7216 | |
| 7217 | /* |
| 7218 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7219 | % % |
| 7220 | % % |
| 7221 | % % |
| 7222 | + M o g r i f y I m a g e L i s t % |
| 7223 | % % |
| 7224 | % % |
| 7225 | % % |
| 7226 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7227 | % |
| 7228 | % MogrifyImageList() applies any command line options that might affect the |
| 7229 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7230 | % |
| 7231 | % The format of the MogrifyImage method is: |
| 7232 | % |
| 7233 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7234 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7235 | % |
| 7236 | % A description of each parameter follows: |
| 7237 | % |
| 7238 | % o image_info: the image info.. |
| 7239 | % |
| 7240 | % o argc: Specifies a pointer to an integer describing the number of |
| 7241 | % elements in the argument vector. |
| 7242 | % |
| 7243 | % o argv: Specifies a pointer to a text array containing the command line |
| 7244 | % arguments. |
| 7245 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7246 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7247 | % |
| 7248 | % o exception: return any errors or warnings in this structure. |
| 7249 | % |
| 7250 | */ |
| 7251 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7252 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7253 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7254 | const char |
| 7255 | *option; |
| 7256 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7257 | ImageInfo |
| 7258 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7259 | |
| 7260 | MagickStatusType |
| 7261 | status; |
| 7262 | |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7263 | PixelInterpolateMethod |
| 7264 | interpolate_method; |
| 7265 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7266 | QuantizeInfo |
| 7267 | *quantize_info; |
| 7268 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7269 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7270 | i; |
| 7271 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7272 | ssize_t |
| 7273 | count, |
| 7274 | index; |
| 7275 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7276 | /* |
| 7277 | Apply options to the image list. |
| 7278 | */ |
| 7279 | assert(image_info != (ImageInfo *) NULL); |
| 7280 | assert(image_info->signature == MagickSignature); |
| 7281 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7282 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7283 | assert((*images)->signature == MagickSignature); |
| 7284 | if ((*images)->debug != MagickFalse) |
| 7285 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7286 | (*images)->filename); |
| 7287 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7288 | return(MagickTrue); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7289 | interpolate_method=UndefinedInterpolatePixel; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7290 | mogrify_info=CloneImageInfo(image_info); |
| 7291 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7292 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7293 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7294 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7295 | if (*images == (Image *) NULL) |
| 7296 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7297 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7298 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7299 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7300 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7301 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7302 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7303 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7304 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7305 | switch (*(option+1)) |
| 7306 | { |
| 7307 | case 'a': |
| 7308 | { |
| 7309 | if (LocaleCompare("affinity",option+1) == 0) |
| 7310 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7311 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7312 | if (*option == '+') |
| 7313 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7314 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7315 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7316 | break; |
| 7317 | } |
| 7318 | i++; |
| 7319 | break; |
| 7320 | } |
| 7321 | if (LocaleCompare("append",option+1) == 0) |
| 7322 | { |
| 7323 | Image |
| 7324 | *append_image; |
| 7325 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7326 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7327 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7328 | MagickFalse,exception); |
| 7329 | if (append_image == (Image *) NULL) |
| 7330 | { |
| 7331 | status=MagickFalse; |
| 7332 | break; |
| 7333 | } |
| 7334 | *images=DestroyImageList(*images); |
| 7335 | *images=append_image; |
| 7336 | break; |
| 7337 | } |
| 7338 | if (LocaleCompare("average",option+1) == 0) |
| 7339 | { |
| 7340 | Image |
| 7341 | *average_image; |
| 7342 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7343 | /* |
| 7344 | Average an image sequence (deprecated). |
| 7345 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7346 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7347 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7348 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7349 | if (average_image == (Image *) NULL) |
| 7350 | { |
| 7351 | status=MagickFalse; |
| 7352 | break; |
| 7353 | } |
| 7354 | *images=DestroyImageList(*images); |
| 7355 | *images=average_image; |
| 7356 | break; |
| 7357 | } |
| 7358 | break; |
| 7359 | } |
| 7360 | case 'c': |
| 7361 | { |
| 7362 | if (LocaleCompare("channel",option+1) == 0) |
| 7363 | { |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7364 | ChannelType |
| 7365 | channel; |
| 7366 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7367 | if (*option == '+') |
| 7368 | { |
| 7369 | channel=DefaultChannels; |
| 7370 | break; |
| 7371 | } |
| 7372 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 7373 | SetPixelChannelMap(*images,channel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7374 | break; |
| 7375 | } |
| 7376 | if (LocaleCompare("clut",option+1) == 0) |
| 7377 | { |
| 7378 | Image |
| 7379 | *clut_image, |
| 7380 | *image; |
| 7381 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7382 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7383 | image=RemoveFirstImageFromList(images); |
| 7384 | clut_image=RemoveFirstImageFromList(images); |
| 7385 | if (clut_image == (Image *) NULL) |
| 7386 | { |
| 7387 | status=MagickFalse; |
| 7388 | break; |
| 7389 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7390 | (void) ClutImage(image,clut_image,interpolate_method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7391 | clut_image=DestroyImage(clut_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7392 | *images=DestroyImageList(*images); |
| 7393 | *images=image; |
| 7394 | break; |
| 7395 | } |
| 7396 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7397 | { |
| 7398 | Image |
| 7399 | *coalesce_image; |
| 7400 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7401 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7402 | coalesce_image=CoalesceImages(*images,exception); |
| 7403 | if (coalesce_image == (Image *) NULL) |
| 7404 | { |
| 7405 | status=MagickFalse; |
| 7406 | break; |
| 7407 | } |
| 7408 | *images=DestroyImageList(*images); |
| 7409 | *images=coalesce_image; |
| 7410 | break; |
| 7411 | } |
| 7412 | if (LocaleCompare("combine",option+1) == 0) |
| 7413 | { |
| 7414 | Image |
| 7415 | *combine_image; |
| 7416 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7417 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 7418 | combine_image=CombineImages(*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7419 | if (combine_image == (Image *) NULL) |
| 7420 | { |
| 7421 | status=MagickFalse; |
| 7422 | break; |
| 7423 | } |
| 7424 | *images=DestroyImageList(*images); |
| 7425 | *images=combine_image; |
| 7426 | break; |
| 7427 | } |
| 7428 | if (LocaleCompare("composite",option+1) == 0) |
| 7429 | { |
| 7430 | Image |
| 7431 | *mask_image, |
| 7432 | *composite_image, |
| 7433 | *image; |
| 7434 | |
| 7435 | RectangleInfo |
| 7436 | geometry; |
| 7437 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7438 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7439 | image=RemoveFirstImageFromList(images); |
| 7440 | composite_image=RemoveFirstImageFromList(images); |
| 7441 | if (composite_image == (Image *) NULL) |
| 7442 | { |
| 7443 | status=MagickFalse; |
| 7444 | break; |
| 7445 | } |
| 7446 | (void) TransformImage(&composite_image,(char *) NULL, |
| 7447 | composite_image->geometry); |
| 7448 | SetGeometry(composite_image,&geometry); |
| 7449 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7450 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7451 | &geometry); |
| 7452 | mask_image=RemoveFirstImageFromList(images); |
| 7453 | if (mask_image != (Image *) NULL) |
| 7454 | { |
| 7455 | if ((image->compose == DisplaceCompositeOp) || |
| 7456 | (image->compose == DistortCompositeOp)) |
| 7457 | { |
| 7458 | /* |
| 7459 | Merge Y displacement into X displacement image. |
| 7460 | */ |
| 7461 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
| 7462 | mask_image,0,0); |
| 7463 | mask_image=DestroyImage(mask_image); |
| 7464 | } |
| 7465 | else |
| 7466 | { |
| 7467 | /* |
| 7468 | Set a blending mask for the composition. |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7469 | Posible error, what if image->mask already set. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7470 | */ |
| 7471 | image->mask=mask_image; |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 7472 | (void) NegateImage(image->mask,MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7473 | } |
| 7474 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7475 | (void) CompositeImage(image,image->compose,composite_image, |
| 7476 | geometry.x,geometry.y); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7477 | if (mask_image != (Image *) NULL) |
| 7478 | mask_image=image->mask=DestroyImage(image->mask); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7479 | composite_image=DestroyImage(composite_image); |
| 7480 | InheritException(exception,&image->exception); |
| 7481 | *images=DestroyImageList(*images); |
| 7482 | *images=image; |
| 7483 | break; |
| 7484 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7485 | break; |
| 7486 | } |
| 7487 | case 'd': |
| 7488 | { |
| 7489 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7490 | { |
| 7491 | Image |
| 7492 | *deconstruct_image; |
| 7493 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7494 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7495 | deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer, |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 7496 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7497 | if (deconstruct_image == (Image *) NULL) |
| 7498 | { |
| 7499 | status=MagickFalse; |
| 7500 | break; |
| 7501 | } |
| 7502 | *images=DestroyImageList(*images); |
| 7503 | *images=deconstruct_image; |
| 7504 | break; |
| 7505 | } |
| 7506 | if (LocaleCompare("delete",option+1) == 0) |
| 7507 | { |
| 7508 | if (*option == '+') |
| 7509 | DeleteImages(images,"-1",exception); |
| 7510 | else |
| 7511 | DeleteImages(images,argv[i+1],exception); |
| 7512 | break; |
| 7513 | } |
| 7514 | if (LocaleCompare("dither",option+1) == 0) |
| 7515 | { |
| 7516 | if (*option == '+') |
| 7517 | { |
| 7518 | quantize_info->dither=MagickFalse; |
| 7519 | break; |
| 7520 | } |
| 7521 | quantize_info->dither=MagickTrue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7522 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7523 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7524 | break; |
| 7525 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7526 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7527 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7528 | Image |
| 7529 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7530 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7531 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7532 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7533 | else |
| 7534 | { |
| 7535 | const char |
| 7536 | *p; |
| 7537 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7538 | size_t |
| 7539 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7540 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7541 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7542 | p=strchr(argv[i+1],','); |
| 7543 | if (p == (const char *) NULL) |
| 7544 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7545 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7546 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7547 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7548 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7549 | } |
| 7550 | AppendImageToList(images, duplicate_images); |
| 7551 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7552 | break; |
| 7553 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7554 | break; |
| 7555 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7556 | case 'e': |
| 7557 | { |
| 7558 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7559 | { |
| 7560 | Image |
| 7561 | *evaluate_image; |
| 7562 | |
| 7563 | MagickEvaluateOperator |
| 7564 | op; |
| 7565 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7566 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7567 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 7568 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7569 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7570 | if (evaluate_image == (Image *) NULL) |
| 7571 | { |
| 7572 | status=MagickFalse; |
| 7573 | break; |
| 7574 | } |
| 7575 | *images=DestroyImageList(*images); |
| 7576 | *images=evaluate_image; |
| 7577 | break; |
| 7578 | } |
| 7579 | break; |
| 7580 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7581 | case 'f': |
| 7582 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7583 | if (LocaleCompare("fft",option+1) == 0) |
| 7584 | { |
| 7585 | Image |
| 7586 | *fourier_image; |
| 7587 | |
| 7588 | /* |
| 7589 | Implements the discrete Fourier transform (DFT). |
| 7590 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7591 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7592 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7593 | MagickTrue : MagickFalse,exception); |
| 7594 | if (fourier_image == (Image *) NULL) |
| 7595 | break; |
| 7596 | *images=DestroyImage(*images); |
| 7597 | *images=fourier_image; |
| 7598 | break; |
| 7599 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7600 | if (LocaleCompare("flatten",option+1) == 0) |
| 7601 | { |
| 7602 | Image |
| 7603 | *flatten_image; |
| 7604 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7605 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7606 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7607 | if (flatten_image == (Image *) NULL) |
| 7608 | break; |
| 7609 | *images=DestroyImageList(*images); |
| 7610 | *images=flatten_image; |
| 7611 | break; |
| 7612 | } |
| 7613 | if (LocaleCompare("fx",option+1) == 0) |
| 7614 | { |
| 7615 | Image |
| 7616 | *fx_image; |
| 7617 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7618 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 7619 | fx_image=FxImage(*images,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7620 | if (fx_image == (Image *) NULL) |
| 7621 | { |
| 7622 | status=MagickFalse; |
| 7623 | break; |
| 7624 | } |
| 7625 | *images=DestroyImageList(*images); |
| 7626 | *images=fx_image; |
| 7627 | break; |
| 7628 | } |
| 7629 | break; |
| 7630 | } |
| 7631 | case 'h': |
| 7632 | { |
| 7633 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7634 | { |
| 7635 | Image |
| 7636 | *hald_image, |
| 7637 | *image; |
| 7638 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7639 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7640 | image=RemoveFirstImageFromList(images); |
| 7641 | hald_image=RemoveFirstImageFromList(images); |
| 7642 | if (hald_image == (Image *) NULL) |
| 7643 | { |
| 7644 | status=MagickFalse; |
| 7645 | break; |
| 7646 | } |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 7647 | (void) HaldClutImage(image,hald_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7648 | hald_image=DestroyImage(hald_image); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7649 | if (*images != (Image *) NULL) |
| 7650 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7651 | *images=image; |
| 7652 | break; |
| 7653 | } |
| 7654 | break; |
| 7655 | } |
| 7656 | case 'i': |
| 7657 | { |
| 7658 | if (LocaleCompare("ift",option+1) == 0) |
| 7659 | { |
| 7660 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7661 | *fourier_image, |
| 7662 | *magnitude_image, |
| 7663 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7664 | |
| 7665 | /* |
| 7666 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7667 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7668 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7669 | magnitude_image=RemoveFirstImageFromList(images); |
| 7670 | phase_image=RemoveFirstImageFromList(images); |
| 7671 | if (phase_image == (Image *) NULL) |
| 7672 | { |
| 7673 | status=MagickFalse; |
| 7674 | break; |
| 7675 | } |
| 7676 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7677 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7678 | if (fourier_image == (Image *) NULL) |
| 7679 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7680 | if (*images != (Image *) NULL) |
| 7681 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7682 | *images=fourier_image; |
| 7683 | break; |
| 7684 | } |
| 7685 | if (LocaleCompare("insert",option+1) == 0) |
| 7686 | { |
| 7687 | Image |
| 7688 | *p, |
| 7689 | *q; |
| 7690 | |
| 7691 | index=0; |
| 7692 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7693 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7694 | p=RemoveLastImageFromList(images); |
| 7695 | if (p == (Image *) NULL) |
| 7696 | { |
| 7697 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7698 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7699 | status=MagickFalse; |
| 7700 | break; |
| 7701 | } |
| 7702 | q=p; |
| 7703 | if (index == 0) |
| 7704 | PrependImageToList(images,q); |
| 7705 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7706 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7707 | AppendImageToList(images,q); |
| 7708 | else |
| 7709 | { |
| 7710 | q=GetImageFromList(*images,index-1); |
| 7711 | if (q == (Image *) NULL) |
| 7712 | { |
| 7713 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7714 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7715 | status=MagickFalse; |
| 7716 | break; |
| 7717 | } |
| 7718 | InsertImageInList(&q,p); |
| 7719 | } |
| 7720 | *images=GetFirstImageInList(q); |
| 7721 | break; |
| 7722 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7723 | if (LocaleCompare("interpolate",option+1) == 0) |
| 7724 | { |
| 7725 | interpolate_method=(PixelInterpolateMethod) ParseCommandOption( |
| 7726 | MagickInterpolateOptions,MagickFalse,argv[i+1]); |
| 7727 | break; |
| 7728 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7729 | break; |
| 7730 | } |
| 7731 | case 'l': |
| 7732 | { |
| 7733 | if (LocaleCompare("layers",option+1) == 0) |
| 7734 | { |
| 7735 | Image |
| 7736 | *layers; |
| 7737 | |
| 7738 | ImageLayerMethod |
| 7739 | method; |
| 7740 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7741 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7742 | layers=(Image *) NULL; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7743 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7744 | MagickFalse,argv[i+1]); |
| 7745 | switch (method) |
| 7746 | { |
| 7747 | case CoalesceLayer: |
| 7748 | { |
| 7749 | layers=CoalesceImages(*images,exception); |
| 7750 | break; |
| 7751 | } |
| 7752 | case CompareAnyLayer: |
| 7753 | case CompareClearLayer: |
| 7754 | case CompareOverlayLayer: |
| 7755 | default: |
| 7756 | { |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7757 | layers=CompareImagesLayers(*images,method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7758 | break; |
| 7759 | } |
| 7760 | case MergeLayer: |
| 7761 | case FlattenLayer: |
| 7762 | case MosaicLayer: |
| 7763 | case TrimBoundsLayer: |
| 7764 | { |
| 7765 | layers=MergeImageLayers(*images,method,exception); |
| 7766 | break; |
| 7767 | } |
| 7768 | case DisposeLayer: |
| 7769 | { |
| 7770 | layers=DisposeImages(*images,exception); |
| 7771 | break; |
| 7772 | } |
| 7773 | case OptimizeImageLayer: |
| 7774 | { |
| 7775 | layers=OptimizeImageLayers(*images,exception); |
| 7776 | break; |
| 7777 | } |
| 7778 | case OptimizePlusLayer: |
| 7779 | { |
| 7780 | layers=OptimizePlusImageLayers(*images,exception); |
| 7781 | break; |
| 7782 | } |
| 7783 | case OptimizeTransLayer: |
| 7784 | { |
| 7785 | OptimizeImageTransparency(*images,exception); |
| 7786 | break; |
| 7787 | } |
| 7788 | case RemoveDupsLayer: |
| 7789 | { |
| 7790 | RemoveDuplicateLayers(images,exception); |
| 7791 | break; |
| 7792 | } |
| 7793 | case RemoveZeroLayer: |
| 7794 | { |
| 7795 | RemoveZeroDelayLayers(images,exception); |
| 7796 | break; |
| 7797 | } |
| 7798 | case OptimizeLayer: |
| 7799 | { |
| 7800 | /* |
| 7801 | General Purpose, GIF Animation Optimizer. |
| 7802 | */ |
| 7803 | layers=CoalesceImages(*images,exception); |
| 7804 | if (layers == (Image *) NULL) |
| 7805 | { |
| 7806 | status=MagickFalse; |
| 7807 | break; |
| 7808 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7809 | *images=DestroyImageList(*images); |
| 7810 | *images=layers; |
| 7811 | layers=OptimizeImageLayers(*images,exception); |
| 7812 | if (layers == (Image *) NULL) |
| 7813 | { |
| 7814 | status=MagickFalse; |
| 7815 | break; |
| 7816 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7817 | *images=DestroyImageList(*images); |
| 7818 | *images=layers; |
| 7819 | layers=(Image *) NULL; |
| 7820 | OptimizeImageTransparency(*images,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7821 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7822 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7823 | break; |
| 7824 | } |
| 7825 | case CompositeLayer: |
| 7826 | { |
| 7827 | CompositeOperator |
| 7828 | compose; |
| 7829 | |
| 7830 | Image |
| 7831 | *source; |
| 7832 | |
| 7833 | RectangleInfo |
| 7834 | geometry; |
| 7835 | |
| 7836 | /* |
| 7837 | Split image sequence at the first 'NULL:' image. |
| 7838 | */ |
| 7839 | source=(*images); |
| 7840 | while (source != (Image *) NULL) |
| 7841 | { |
| 7842 | source=GetNextImageInList(source); |
| 7843 | if ((source != (Image *) NULL) && |
| 7844 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7845 | break; |
| 7846 | } |
| 7847 | if (source != (Image *) NULL) |
| 7848 | { |
| 7849 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7850 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7851 | source=(Image *) NULL; |
| 7852 | else |
| 7853 | { |
| 7854 | /* |
| 7855 | Separate the two lists, junk the null: image. |
| 7856 | */ |
| 7857 | source=SplitImageList(source->previous); |
| 7858 | DeleteImageFromList(&source); |
| 7859 | } |
| 7860 | } |
| 7861 | if (source == (Image *) NULL) |
| 7862 | { |
| 7863 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7864 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7865 | status=MagickFalse; |
| 7866 | break; |
| 7867 | } |
| 7868 | /* |
| 7869 | Adjust offset with gravity and virtual canvas. |
| 7870 | */ |
| 7871 | SetGeometry(*images,&geometry); |
| 7872 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7873 | geometry.width=source->page.width != 0 ? |
| 7874 | source->page.width : source->columns; |
| 7875 | geometry.height=source->page.height != 0 ? |
| 7876 | source->page.height : source->rows; |
| 7877 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7878 | (*images)->page.width : (*images)->columns, |
| 7879 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7880 | (*images)->rows,(*images)->gravity,&geometry); |
| 7881 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7882 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7883 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7884 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7885 | MagickComposeOptions,MagickFalse,option); |
| 7886 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7887 | exception); |
| 7888 | source=DestroyImageList(source); |
| 7889 | break; |
| 7890 | } |
| 7891 | } |
| 7892 | if (layers == (Image *) NULL) |
| 7893 | break; |
| 7894 | InheritException(exception,&layers->exception); |
| 7895 | *images=DestroyImageList(*images); |
| 7896 | *images=layers; |
| 7897 | break; |
| 7898 | } |
| 7899 | break; |
| 7900 | } |
| 7901 | case 'm': |
| 7902 | { |
| 7903 | if (LocaleCompare("map",option+1) == 0) |
| 7904 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7905 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7906 | if (*option == '+') |
| 7907 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7908 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7909 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7910 | break; |
| 7911 | } |
| 7912 | i++; |
| 7913 | break; |
| 7914 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7915 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7916 | { |
| 7917 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7918 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7919 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7920 | /* |
| 7921 | Maximum image sequence (deprecated). |
| 7922 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7923 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7924 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7925 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7926 | { |
| 7927 | status=MagickFalse; |
| 7928 | break; |
| 7929 | } |
| 7930 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7931 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7932 | break; |
| 7933 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7934 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7935 | { |
| 7936 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7937 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7938 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7939 | /* |
| 7940 | Minimum image sequence (deprecated). |
| 7941 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7942 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7943 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7944 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7945 | { |
| 7946 | status=MagickFalse; |
| 7947 | break; |
| 7948 | } |
| 7949 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7950 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7951 | break; |
| 7952 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7953 | if (LocaleCompare("morph",option+1) == 0) |
| 7954 | { |
| 7955 | Image |
| 7956 | *morph_image; |
| 7957 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7958 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7959 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7960 | exception); |
| 7961 | if (morph_image == (Image *) NULL) |
| 7962 | { |
| 7963 | status=MagickFalse; |
| 7964 | break; |
| 7965 | } |
| 7966 | *images=DestroyImageList(*images); |
| 7967 | *images=morph_image; |
| 7968 | break; |
| 7969 | } |
| 7970 | if (LocaleCompare("mosaic",option+1) == 0) |
| 7971 | { |
| 7972 | Image |
| 7973 | *mosaic_image; |
| 7974 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7975 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7976 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 7977 | if (mosaic_image == (Image *) NULL) |
| 7978 | { |
| 7979 | status=MagickFalse; |
| 7980 | break; |
| 7981 | } |
| 7982 | *images=DestroyImageList(*images); |
| 7983 | *images=mosaic_image; |
| 7984 | break; |
| 7985 | } |
| 7986 | break; |
| 7987 | } |
| 7988 | case 'p': |
| 7989 | { |
| 7990 | if (LocaleCompare("print",option+1) == 0) |
| 7991 | { |
| 7992 | char |
| 7993 | *string; |
| 7994 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7995 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7996 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1], |
| 7997 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7998 | if (string == (char *) NULL) |
| 7999 | break; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8000 | (void) FormatLocaleFile(stdout,"%s",string); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8001 | string=DestroyString(string); |
| 8002 | } |
| 8003 | if (LocaleCompare("process",option+1) == 0) |
| 8004 | { |
| 8005 | char |
| 8006 | **arguments; |
| 8007 | |
| 8008 | int |
| 8009 | j, |
| 8010 | number_arguments; |
| 8011 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8012 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8013 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 8014 | if (arguments == (char **) NULL) |
| 8015 | break; |
| 8016 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 8017 | { |
| 8018 | char |
| 8019 | breaker, |
| 8020 | quote, |
| 8021 | *token; |
| 8022 | |
| 8023 | const char |
| 8024 | *arguments; |
| 8025 | |
| 8026 | int |
| 8027 | next, |
| 8028 | status; |
| 8029 | |
| 8030 | size_t |
| 8031 | length; |
| 8032 | |
| 8033 | TokenInfo |
| 8034 | *token_info; |
| 8035 | |
| 8036 | /* |
| 8037 | Support old style syntax, filter="-option arg". |
| 8038 | */ |
| 8039 | length=strlen(argv[i+1]); |
| 8040 | token=(char *) NULL; |
cristy | 37e0b38 | 2011-06-07 13:31:21 +0000 | [diff] [blame] | 8041 | if (~length >= (MaxTextExtent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8042 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8043 | sizeof(*token)); |
| 8044 | if (token == (char *) NULL) |
| 8045 | break; |
| 8046 | next=0; |
| 8047 | arguments=argv[i+1]; |
| 8048 | token_info=AcquireTokenInfo(); |
| 8049 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8050 | "\"",'\0',&breaker,&next,"e); |
| 8051 | token_info=DestroyTokenInfo(token_info); |
| 8052 | if (status == 0) |
| 8053 | { |
| 8054 | const char |
| 8055 | *argv; |
| 8056 | |
| 8057 | argv=(&(arguments[next])); |
| 8058 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8059 | exception); |
| 8060 | } |
| 8061 | token=DestroyString(token); |
| 8062 | break; |
| 8063 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8064 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8065 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8066 | number_arguments-2,(const char **) arguments+2,exception); |
| 8067 | for (j=0; j < number_arguments; j++) |
| 8068 | arguments[j]=DestroyString(arguments[j]); |
| 8069 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8070 | break; |
| 8071 | } |
| 8072 | break; |
| 8073 | } |
| 8074 | case 'r': |
| 8075 | { |
| 8076 | if (LocaleCompare("reverse",option+1) == 0) |
| 8077 | { |
| 8078 | ReverseImageList(images); |
| 8079 | InheritException(exception,&(*images)->exception); |
| 8080 | break; |
| 8081 | } |
| 8082 | break; |
| 8083 | } |
| 8084 | case 's': |
| 8085 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8086 | if (LocaleCompare("smush",option+1) == 0) |
| 8087 | { |
| 8088 | Image |
| 8089 | *smush_image; |
| 8090 | |
| 8091 | ssize_t |
| 8092 | offset; |
| 8093 | |
| 8094 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8095 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8096 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8097 | MagickFalse,offset,exception); |
| 8098 | if (smush_image == (Image *) NULL) |
| 8099 | { |
| 8100 | status=MagickFalse; |
| 8101 | break; |
| 8102 | } |
| 8103 | *images=DestroyImageList(*images); |
| 8104 | *images=smush_image; |
| 8105 | break; |
| 8106 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8107 | if (LocaleCompare("swap",option+1) == 0) |
| 8108 | { |
| 8109 | Image |
| 8110 | *p, |
| 8111 | *q, |
| 8112 | *swap; |
| 8113 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8114 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8115 | swap_index; |
| 8116 | |
| 8117 | index=(-1); |
| 8118 | swap_index=(-2); |
| 8119 | if (*option != '+') |
| 8120 | { |
| 8121 | GeometryInfo |
| 8122 | geometry_info; |
| 8123 | |
| 8124 | MagickStatusType |
| 8125 | flags; |
| 8126 | |
| 8127 | swap_index=(-1); |
| 8128 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8129 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8130 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8131 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8132 | } |
| 8133 | p=GetImageFromList(*images,index); |
| 8134 | q=GetImageFromList(*images,swap_index); |
| 8135 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8136 | { |
| 8137 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8138 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8139 | status=MagickFalse; |
| 8140 | break; |
| 8141 | } |
| 8142 | if (p == q) |
| 8143 | break; |
| 8144 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8145 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8146 | ReplaceImageInList(&q,swap); |
| 8147 | *images=GetFirstImageInList(q); |
| 8148 | break; |
| 8149 | } |
| 8150 | break; |
| 8151 | } |
| 8152 | case 'w': |
| 8153 | { |
| 8154 | if (LocaleCompare("write",option+1) == 0) |
| 8155 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8156 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8157 | key[MaxTextExtent]; |
| 8158 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8159 | Image |
| 8160 | *write_images; |
| 8161 | |
| 8162 | ImageInfo |
| 8163 | *write_info; |
| 8164 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8165 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8166 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8167 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8168 | write_images=(*images); |
| 8169 | if (*option == '+') |
| 8170 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8171 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8172 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8173 | write_info=DestroyImageInfo(write_info); |
| 8174 | if (*option == '+') |
| 8175 | write_images=DestroyImageList(write_images); |
| 8176 | break; |
| 8177 | } |
| 8178 | break; |
| 8179 | } |
| 8180 | default: |
| 8181 | break; |
| 8182 | } |
| 8183 | i+=count; |
| 8184 | } |
| 8185 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8186 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8187 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8188 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8189 | } |
| 8190 | |
| 8191 | /* |
| 8192 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8193 | % % |
| 8194 | % % |
| 8195 | % % |
| 8196 | + M o g r i f y I m a g e s % |
| 8197 | % % |
| 8198 | % % |
| 8199 | % % |
| 8200 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8201 | % |
| 8202 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8203 | % prescribed by command line options. |
| 8204 | % |
| 8205 | % The format of the MogrifyImage method is: |
| 8206 | % |
| 8207 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8208 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8209 | % Image **images,Exceptioninfo *exception) |
| 8210 | % |
| 8211 | % A description of each parameter follows: |
| 8212 | % |
| 8213 | % o image_info: the image info.. |
| 8214 | % |
| 8215 | % o post: If true, post process image list operators otherwise pre-process. |
| 8216 | % |
| 8217 | % o argc: Specifies a pointer to an integer describing the number of |
| 8218 | % elements in the argument vector. |
| 8219 | % |
| 8220 | % o argv: Specifies a pointer to a text array containing the command line |
| 8221 | % arguments. |
| 8222 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8223 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8224 | % |
| 8225 | % o exception: return any errors or warnings in this structure. |
| 8226 | % |
| 8227 | */ |
| 8228 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8229 | const MagickBooleanType post,const int argc,const char **argv, |
| 8230 | Image **images,ExceptionInfo *exception) |
| 8231 | { |
| 8232 | #define MogrifyImageTag "Mogrify/Image" |
| 8233 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8234 | MagickStatusType |
| 8235 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8236 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8237 | MagickBooleanType |
| 8238 | proceed; |
| 8239 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8240 | size_t |
| 8241 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8242 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8243 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8244 | i; |
| 8245 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8246 | assert(image_info != (ImageInfo *) NULL); |
| 8247 | assert(image_info->signature == MagickSignature); |
| 8248 | if (images == (Image **) NULL) |
| 8249 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8250 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8251 | assert((*images)->signature == MagickSignature); |
| 8252 | if ((*images)->debug != MagickFalse) |
| 8253 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8254 | (*images)->filename); |
| 8255 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8256 | return(MagickTrue); |
| 8257 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8258 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8259 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8260 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8261 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8262 | (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc, |
| 8263 | post?"post":"pre"); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8264 | #endif |
| 8265 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8266 | /* |
| 8267 | Pre-process multi-image sequence operators |
| 8268 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8269 | if (post == MagickFalse) |
| 8270 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8271 | /* |
| 8272 | For each image, process simple single image operators |
| 8273 | */ |
| 8274 | i=0; |
| 8275 | n=GetImageListLength(*images); |
cristy | 9f027d1 | 2011-09-21 01:17:17 +0000 | [diff] [blame] | 8276 | for ( ; ; ) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8277 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8278 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8279 | (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long) |
| 8280 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8281 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8282 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8283 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8284 | if (proceed == MagickFalse) |
| 8285 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8286 | if ( (*images)->next == (Image *) NULL ) |
| 8287 | break; |
| 8288 | *images=(*images)->next; |
| 8289 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8290 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8291 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8292 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8293 | (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long) |
| 8294 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8295 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8296 | |
| 8297 | /* |
| 8298 | Post-process, multi-image sequence operators |
| 8299 | */ |
| 8300 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8301 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8302 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8303 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8304 | } |