cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % M M OOO GGGGG RRRR IIIII FFFFF Y Y % |
| 7 | % MM MM O O G R R I F Y Y % |
| 8 | % M M M O O G GGG RRRR I FFF Y % |
| 9 | % M M O O G G R R I F Y % |
| 10 | % M M OOO GGGG R R IIIII F Y % |
| 11 | % % |
| 12 | % % |
| 13 | % MagickWand Module Methods % |
| 14 | % % |
| 15 | % Software Design % |
| 16 | % John Cristy % |
| 17 | % March 2000 % |
| 18 | % % |
| 19 | % % |
cristy | 7e41fe8 | 2010-12-04 23:12:08 +0000 | [diff] [blame] | 20 | % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 21 | % dedicated to making software imaging solutions freely available. % |
| 22 | % % |
| 23 | % You may not use this file except in compliance with the License. You may % |
| 24 | % obtain a copy of the License at % |
| 25 | % % |
| 26 | % http://www.imagemagick.org/script/license.php % |
| 27 | % % |
| 28 | % Unless required by applicable law or agreed to in writing, software % |
| 29 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 30 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 31 | % See the License for the specific language governing permissions and % |
| 32 | % limitations under the License. % |
| 33 | % % |
| 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 35 | % |
| 36 | % Use the mogrify program to resize an image, blur, crop, despeckle, dither, |
| 37 | % draw on, flip, join, re-sample, and much more. This tool is similiar to |
| 38 | % convert except that the original image file is overwritten (unless you |
| 39 | % change the file suffix with the -format option) with any changes you |
cristy | 6a917d9 | 2009-10-06 19:23:54 +0000 | [diff] [blame] | 40 | % request. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 41 | % |
| 42 | */ |
| 43 | |
| 44 | /* |
| 45 | Include declarations. |
| 46 | */ |
| 47 | #include "wand/studio.h" |
| 48 | #include "wand/MagickWand.h" |
| 49 | #include "wand/mogrify-private.h" |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame^] | 50 | #include "wand/operation.h" |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 51 | #include "magick/monitor-private.h" |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 52 | #include "magick/thread-private.h" |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 53 | #include "magick/string-private.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 54 | |
| 55 | /* |
| 56 | Define declarations. |
| 57 | */ |
| 58 | #define UndefinedCompressionQuality 0UL |
| 59 | |
| 60 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 61 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 62 | % % |
| 63 | % % |
| 64 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 65 | % 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] | 66 | % % |
| 67 | % % |
| 68 | % % |
| 69 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 70 | % |
| 71 | % MagickCommandGenesis() applies image processing options to an image as |
| 72 | % prescribed by command line options. |
| 73 | % |
| 74 | % The format of the MagickCommandGenesis method is: |
| 75 | % |
| 76 | % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 77 | % MagickCommand command,int argc,char **argv,char **metadata, |
| 78 | % ExceptionInfo *exception) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 79 | % |
| 80 | % A description of each parameter follows: |
| 81 | % |
| 82 | % o image_info: the image info. |
| 83 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 84 | % o command: Choose from ConvertImageCommand, IdentifyImageCommand, |
| 85 | % MogrifyImageCommand, CompositeImageCommand, CompareImageCommand, |
| 86 | % ConjureImageCommand, StreamImageCommand, ImportImageCommand, |
| 87 | % DisplayImageCommand, or AnimateImageCommand. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 88 | % |
| 89 | % o argc: Specifies a pointer to an integer describing the number of |
| 90 | % elements in the argument vector. |
| 91 | % |
| 92 | % o argv: Specifies a pointer to a text array containing the command line |
| 93 | % arguments. |
| 94 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 95 | % o metadata: any metadata is returned here. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 96 | % |
| 97 | % o exception: return any errors or warnings in this structure. |
| 98 | % |
| 99 | */ |
| 100 | WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
| 101 | MagickCommand command,int argc,char **argv,char **metadata, |
| 102 | ExceptionInfo *exception) |
| 103 | { |
| 104 | char |
| 105 | *option; |
| 106 | |
| 107 | double |
| 108 | duration, |
| 109 | elapsed_time, |
| 110 | user_time; |
| 111 | |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 112 | MagickBooleanType |
| 113 | concurrent, |
| 114 | regard_warnings, |
| 115 | status; |
| 116 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 117 | register ssize_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 118 | i; |
| 119 | |
| 120 | TimerInfo |
| 121 | *timer; |
| 122 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 123 | size_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 124 | iterations; |
| 125 | |
cristy | d0a94fa | 2010-03-12 14:18:11 +0000 | [diff] [blame] | 126 | (void) setlocale(LC_ALL,""); |
| 127 | (void) setlocale(LC_NUMERIC,"C"); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 128 | concurrent=MagickFalse; |
| 129 | duration=(-1.0); |
| 130 | iterations=1; |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 131 | status=MagickFalse; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 132 | regard_warnings=MagickFalse; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 133 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 134 | { |
| 135 | option=argv[i]; |
| 136 | if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) |
| 137 | continue; |
| 138 | if (LocaleCompare("bench",option+1) == 0) |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 139 | iterations=StringToUnsignedLong(argv[++i]); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 140 | if (LocaleCompare("concurrent",option+1) == 0) |
| 141 | concurrent=MagickTrue; |
| 142 | if (LocaleCompare("debug",option+1) == 0) |
| 143 | (void) SetLogEventMask(argv[++i]); |
| 144 | if (LocaleCompare("duration",option+1) == 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 145 | duration=StringToDouble(argv[++i]); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 146 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 147 | regard_warnings=MagickTrue; |
| 148 | } |
| 149 | timer=AcquireTimerInfo(); |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 150 | if (concurrent == MagickFalse) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 151 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 152 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 153 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 154 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 155 | continue; |
| 156 | if (duration > 0) |
| 157 | { |
| 158 | if (GetElapsedTime(timer) > duration) |
| 159 | continue; |
| 160 | (void) ContinueTimer(timer); |
| 161 | } |
| 162 | status=command(image_info,argc,argv,metadata,exception); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 163 | if (exception->severity != UndefinedException) |
| 164 | { |
| 165 | if ((exception->severity > ErrorException) || |
| 166 | (regard_warnings != MagickFalse)) |
| 167 | status=MagickTrue; |
| 168 | CatchException(exception); |
| 169 | } |
cristy | 3d1a551 | 2009-10-25 21:23:27 +0000 | [diff] [blame] | 170 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 171 | { |
| 172 | (void) fputs(*metadata,stdout); |
| 173 | (void) fputc('\n',stdout); |
| 174 | *metadata=DestroyString(*metadata); |
| 175 | } |
| 176 | } |
| 177 | } |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 178 | else |
| 179 | { |
| 180 | SetOpenMPNested(1); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 181 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 182 | # pragma omp parallel for shared(status) |
| 183 | #endif |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 184 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 185 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 186 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 187 | continue; |
| 188 | if (duration > 0) |
| 189 | { |
| 190 | if (GetElapsedTime(timer) > duration) |
| 191 | continue; |
| 192 | (void) ContinueTimer(timer); |
| 193 | } |
| 194 | status=command(image_info,argc,argv,metadata,exception); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 195 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 196 | # pragma omp critical (MagickCore_CommandGenesis) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 197 | #endif |
| 198 | { |
| 199 | if (exception->severity != UndefinedException) |
| 200 | { |
| 201 | if ((exception->severity > ErrorException) || |
| 202 | (regard_warnings != MagickFalse)) |
| 203 | status=MagickTrue; |
| 204 | CatchException(exception); |
| 205 | } |
| 206 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 207 | { |
| 208 | (void) fputs(*metadata,stdout); |
| 209 | (void) fputc('\n',stdout); |
| 210 | *metadata=DestroyString(*metadata); |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | } |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 215 | if (iterations > 1) |
| 216 | { |
| 217 | elapsed_time=GetElapsedTime(timer); |
| 218 | user_time=GetUserTime(timer); |
cristy | 8cd5b31 | 2010-01-07 01:10:24 +0000 | [diff] [blame] | 219 | (void) fprintf(stderr, |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 220 | "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double) |
| 221 | iterations,1.0*iterations/elapsed_time,user_time,(double) |
| 222 | (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double) |
| 223 | (1000.0*(elapsed_time-floor(elapsed_time)))); |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 224 | (void) fflush(stderr); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 225 | } |
| 226 | timer=DestroyTimerInfo(timer); |
cristy | 1f9e1ed | 2009-11-18 04:09:38 +0000 | [diff] [blame] | 227 | return(status); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | /* |
| 231 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 232 | % % |
| 233 | % % |
| 234 | % % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 235 | + M o g r i f y I m a g e % |
| 236 | % % |
| 237 | % % |
| 238 | % % |
| 239 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 240 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 241 | % MogrifyImage() applies simple single image processing options to a single |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame^] | 242 | % image, but also hanles any 'region' image handling. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 243 | % |
| 244 | % The image in the list may be modified in three different ways... |
| 245 | % |
| 246 | % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 247 | % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 248 | % * replace by a list of images (only the -separate option!) |
| 249 | % |
| 250 | % In each case the result is returned into the list, and a pointer to the |
| 251 | % modified image (last image added if replaced by a list of images) is |
| 252 | % returned. |
| 253 | % |
| 254 | % ASIDE: The -crop is present but restricted to non-tile single image crops |
| 255 | % |
| 256 | % This means if all the images are being processed (such as by |
| 257 | % MogrifyImages(), next image to be processed will be as per the pointer |
| 258 | % (*image)->next. Also the image list may grow as a result of some specific |
| 259 | % operations but as images are never merged or deleted, it will never shrink |
| 260 | % in length. Typically the list will remain the same length. |
| 261 | % |
| 262 | % WARNING: As the image pointed to may be replaced, the first image in the |
| 263 | % list may also change. GetFirstImageInList() should be used by caller if |
| 264 | % they wish return the Image pointer to the first image in list. |
| 265 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 266 | % |
| 267 | % The format of the MogrifyImage method is: |
| 268 | % |
| 269 | % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 270 | % const char **argv,Image **image) |
| 271 | % |
| 272 | % A description of each parameter follows: |
| 273 | % |
| 274 | % o image_info: the image info.. |
| 275 | % |
| 276 | % o argc: Specifies a pointer to an integer describing the number of |
| 277 | % elements in the argument vector. |
| 278 | % |
| 279 | % o argv: Specifies a pointer to a text array containing the command line |
| 280 | % arguments. |
| 281 | % |
| 282 | % o image: the image. |
| 283 | % |
| 284 | % o exception: return any errors or warnings in this structure. |
| 285 | % |
| 286 | */ |
| 287 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 288 | static MagickBooleanType IsPathWritable(const char *path) |
| 289 | { |
| 290 | if (IsPathAccessible(path) == MagickFalse) |
| 291 | return(MagickFalse); |
| 292 | if (access(path,W_OK) != 0) |
| 293 | return(MagickFalse); |
| 294 | return(MagickTrue); |
| 295 | } |
| 296 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 297 | static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 298 | { |
| 299 | if (x > y) |
| 300 | return(x); |
| 301 | return(y); |
| 302 | } |
| 303 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 304 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 305 | const char **argv,Image **image,ExceptionInfo *exception) |
| 306 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 307 | Image |
| 308 | *region_image; |
| 309 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 310 | MagickStatusType |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 311 | status; |
| 312 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 313 | RectangleInfo |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 314 | region_geometry; |
| 315 | |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame^] | 316 | ImageInfo |
| 317 | *mogrify_info; |
| 318 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 319 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 320 | i; |
| 321 | |
| 322 | /* |
| 323 | Initialize method variables. |
| 324 | */ |
| 325 | assert(image_info != (const ImageInfo *) NULL); |
| 326 | assert(image_info->signature == MagickSignature); |
| 327 | assert(image != (Image **) NULL); |
| 328 | assert((*image)->signature == MagickSignature); |
| 329 | if ((*image)->debug != MagickFalse) |
| 330 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); |
| 331 | if (argc < 0) |
| 332 | return(MagickTrue); |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame^] | 333 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 334 | mogrify_info=CloneImageInfo(image_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 335 | SetGeometry(*image,®ion_geometry); |
| 336 | region_image=NewImageList(); |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame^] | 337 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 338 | /* |
| 339 | Transmogrify the image. |
| 340 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 341 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 342 | { |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 343 | ssize_t |
| 344 | count; |
| 345 | |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame^] | 346 | if (IsCommandOption(argv[i]) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 347 | continue; |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame^] | 348 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,argv[i]); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 349 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 350 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 351 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 352 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame^] | 353 | |
| 354 | if (LocaleCompare("region",argv[i]+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 355 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 356 | |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame^] | 357 | /* |
| 358 | Merge any existing region image back into saved original image |
| 359 | */ |
| 360 | (void) SyncImageSettings(mogrify_info,*image); |
| 361 | if (region_image != (Image *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 362 | { |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame^] | 363 | (void) CompositeImage(region_image,region_image->matte != |
| 364 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 365 | region_geometry.x,region_geometry.y); |
| 366 | InheritException(exception,®ion_image->exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 367 | *image=DestroyImage(*image); |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame^] | 368 | *image=region_image; |
| 369 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 370 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 371 | |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame^] | 372 | /* |
| 373 | Set up a new region image |
| 374 | */ |
| 375 | if (*(argv[i]) != '+') |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 376 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 377 | Image |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame^] | 378 | *crop_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 379 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 380 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 381 | exception); |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame^] | 382 | crop_image=CropImage(*image,®ion_geometry,exception); |
| 383 | if (crop_image != (Image *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 384 | { |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame^] | 385 | region_image=(*image); |
| 386 | *image=crop_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 387 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 388 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 389 | } |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame^] | 390 | else |
| 391 | status=SimpleOperationImage(mogrify_info,count,argv+i,image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 392 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 393 | i+=count; |
| 394 | } |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame^] | 395 | |
| 396 | /* |
| 397 | Merge any existing region image back into saved original image |
| 398 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 399 | if (region_image != (Image *) NULL) |
| 400 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 401 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 402 | (void) CompositeImage(region_image,region_image->matte != |
| 403 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 404 | region_geometry.x,region_geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 405 | InheritException(exception,®ion_image->exception); |
| 406 | *image=DestroyImage(*image); |
| 407 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 408 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 409 | } |
| 410 | /* |
| 411 | Free resources. |
| 412 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 413 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 414 | status=(*image)->exception.severity == UndefinedException ? 1 : 0; |
| 415 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | /* |
| 419 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 420 | % % |
| 421 | % % |
| 422 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 423 | + 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] | 424 | % % |
| 425 | % % |
| 426 | % % |
| 427 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 428 | % |
| 429 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 430 | % transforms include image scaling, image rotation, color reduction, and |
| 431 | % others. The transmogrified image overwrites the original image. |
| 432 | % |
| 433 | % The format of the MogrifyImageCommand method is: |
| 434 | % |
| 435 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 436 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 437 | % |
| 438 | % A description of each parameter follows: |
| 439 | % |
| 440 | % o image_info: the image info. |
| 441 | % |
| 442 | % o argc: the number of elements in the argument vector. |
| 443 | % |
| 444 | % o argv: A text array containing the command line arguments. |
| 445 | % |
| 446 | % o metadata: any metadata is returned here. |
| 447 | % |
| 448 | % o exception: return any errors or warnings in this structure. |
| 449 | % |
| 450 | */ |
| 451 | |
| 452 | static MagickBooleanType MogrifyUsage(void) |
| 453 | { |
| 454 | static const char |
| 455 | *miscellaneous[]= |
| 456 | { |
| 457 | "-debug events display copious debugging information", |
| 458 | "-help print program options", |
| 459 | "-list type print a list of supported option arguments", |
| 460 | "-log format format of debugging information", |
| 461 | "-version print version information", |
| 462 | (char *) NULL |
| 463 | }, |
| 464 | *operators[]= |
| 465 | { |
| 466 | "-adaptive-blur geometry", |
| 467 | " adaptively blur pixels; decrease effect near edges", |
| 468 | "-adaptive-resize geometry", |
| 469 | " adaptively resize image using 'mesh' interpolation", |
| 470 | "-adaptive-sharpen geometry", |
| 471 | " adaptively sharpen pixels; increase effect near edges", |
| 472 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 473 | " transparent, extract, background, or shape", |
| 474 | "-annotate geometry text", |
| 475 | " annotate the image with text", |
| 476 | "-auto-gamma automagically adjust gamma level of image", |
| 477 | "-auto-level automagically adjust color levels of image", |
| 478 | "-auto-orient automagically orient (rotate) image", |
| 479 | "-bench iterations measure performance", |
| 480 | "-black-threshold value", |
| 481 | " force all pixels below the threshold into black", |
| 482 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 483 | "-blur geometry reduce image noise and reduce detail levels", |
| 484 | "-border geometry surround image with a border of color", |
| 485 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 486 | "-brightness-contrast geometry", |
| 487 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 488 | "-cdl filename color correct with a color decision list", |
| 489 | "-charcoal radius simulate a charcoal drawing", |
| 490 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 491 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 492 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 493 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 494 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 495 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 496 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 497 | "-contrast enhance or reduce the image contrast", |
| 498 | "-contrast-stretch geometry", |
| 499 | " improve contrast by `stretching' the intensity range", |
| 500 | "-convolve coefficients", |
| 501 | " apply a convolution kernel to the image", |
| 502 | "-cycle amount cycle the image colormap", |
| 503 | "-decipher filename convert cipher pixels to plain pixels", |
| 504 | "-deskew threshold straighten an image", |
| 505 | "-despeckle reduce the speckles within an image", |
| 506 | "-distort method args", |
| 507 | " distort images according to given method ad args", |
| 508 | "-draw string annotate the image with a graphic primitive", |
| 509 | "-edge radius apply a filter to detect edges in the image", |
| 510 | "-encipher filename convert plain pixels to cipher pixels", |
| 511 | "-emboss radius emboss an image", |
| 512 | "-enhance apply a digital filter to enhance a noisy image", |
| 513 | "-equalize perform histogram equalization to an image", |
| 514 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 515 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 516 | "-extent geometry set the image size", |
| 517 | "-extract geometry extract area from image", |
| 518 | "-fft implements the discrete Fourier transform (DFT)", |
| 519 | "-flip flip image vertically", |
| 520 | "-floodfill geometry color", |
| 521 | " floodfill the image with color", |
| 522 | "-flop flop image horizontally", |
| 523 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 524 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 525 | " apply function over image values", |
| 526 | "-gamma value level of gamma correction", |
| 527 | "-gaussian-blur geometry", |
| 528 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 529 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 530 | "-identify identify the format and characteristics of the image", |
| 531 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 532 | "-implode amount implode image pixels about the center", |
| 533 | "-lat geometry local adaptive thresholding", |
| 534 | "-layers method optimize, merge, or compare image layers", |
| 535 | "-level value adjust the level of image contrast", |
| 536 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 537 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 538 | "-linear-stretch geometry", |
| 539 | " improve contrast by `stretching with saturation'", |
| 540 | "-liquid-rescale geometry", |
| 541 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 542 | "-median geometry apply a median filter to the image", |
| 543 | "-mode geometry make each pixel the 'predominate color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 544 | "-modulate value vary the brightness, saturation, and hue", |
| 545 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 546 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 547 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 548 | "-motion-blur geometry", |
| 549 | " simulate motion blur", |
| 550 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 551 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 552 | "-normalize transform image to span the full range of colors", |
| 553 | "-opaque color change this color to the fill color", |
| 554 | "-ordered-dither NxN", |
| 555 | " add a noise pattern to the image with specific", |
| 556 | " amplitudes", |
| 557 | "-paint radius simulate an oil painting", |
| 558 | "-polaroid angle simulate a Polaroid picture", |
| 559 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 560 | "-profile filename add, delete, or apply an image profile", |
| 561 | "-quantize colorspace reduce colors in this colorspace", |
| 562 | "-radial-blur angle radial blur the image", |
| 563 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 564 | "-random-threshold low,high", |
| 565 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 566 | "-region geometry apply options to a portion of the image", |
| 567 | "-render render vector graphics", |
| 568 | "-repage geometry size and location of an image canvas", |
| 569 | "-resample geometry change the resolution of an image", |
| 570 | "-resize geometry resize the image", |
| 571 | "-roll geometry roll an image vertically or horizontally", |
| 572 | "-rotate degrees apply Paeth rotation to the image", |
| 573 | "-sample geometry scale image with pixel sampling", |
| 574 | "-scale geometry scale the image", |
| 575 | "-segment values segment an image", |
| 576 | "-selective-blur geometry", |
| 577 | " selectively blur pixels within a contrast threshold", |
| 578 | "-sepia-tone threshold", |
| 579 | " simulate a sepia-toned photo", |
| 580 | "-set property value set an image property", |
| 581 | "-shade degrees shade the image using a distant light source", |
| 582 | "-shadow geometry simulate an image shadow", |
| 583 | "-sharpen geometry sharpen the image", |
| 584 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 585 | "-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] | 586 | "-sigmoidal-contrast geometry", |
| 587 | " increase the contrast without saturating highlights or shadows", |
| 588 | "-sketch geometry simulate a pencil sketch", |
| 589 | "-solarize threshold negate all pixels above the threshold level", |
| 590 | "-sparse-color method args", |
| 591 | " fill in a image based on a few color points", |
| 592 | "-splice geometry splice the background color into the image", |
| 593 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 594 | "-statistic type radius", |
| 595 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 596 | "-strip strip image of all profiles and comments", |
| 597 | "-swirl degrees swirl image pixels about the center", |
| 598 | "-threshold value threshold the image", |
| 599 | "-thumbnail geometry create a thumbnail of the image", |
| 600 | "-tile filename tile image when filling a graphic primitive", |
| 601 | "-tint value tint the image with the fill color", |
| 602 | "-transform affine transform image", |
| 603 | "-transparent color make this color transparent within the image", |
| 604 | "-transpose flip image vertically and rotate 90 degrees", |
| 605 | "-transverse flop image horizontally and rotate 270 degrees", |
| 606 | "-trim trim image edges", |
| 607 | "-type type image type", |
| 608 | "-unique-colors discard all but one of any pixel color", |
| 609 | "-unsharp geometry sharpen the image", |
| 610 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 611 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 612 | "-white-threshold value", |
| 613 | " force all pixels above the threshold into white", |
| 614 | (char *) NULL |
| 615 | }, |
| 616 | *sequence_operators[]= |
| 617 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 618 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 619 | "-clut apply a color lookup table to the image", |
| 620 | "-coalesce merge a sequence of images", |
| 621 | "-combine combine a sequence of images", |
| 622 | "-composite composite image", |
| 623 | "-crop geometry cut out a rectangular region of the image", |
| 624 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 625 | "-evaluate-sequence operator", |
| 626 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 627 | "-flatten flatten a sequence of images", |
| 628 | "-fx expression apply mathematical expression to an image channel(s)", |
| 629 | "-hald-clut apply a Hald color lookup table to the image", |
| 630 | "-morph value morph an image sequence", |
| 631 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 632 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 633 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 634 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 635 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 636 | "-write filename write images to this file", |
| 637 | (char *) NULL |
| 638 | }, |
| 639 | *settings[]= |
| 640 | { |
| 641 | "-adjoin join images into a single multi-image file", |
| 642 | "-affine matrix affine transform matrix", |
| 643 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 644 | "-antialias remove pixel-aliasing", |
| 645 | "-authenticate password", |
| 646 | " decipher image with this password", |
| 647 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 648 | "-background color background color", |
| 649 | "-bias value add bias when convolving an image", |
| 650 | "-black-point-compensation", |
| 651 | " use black point compensation", |
| 652 | "-blue-primary point chromaticity blue primary point", |
| 653 | "-bordercolor color border color", |
| 654 | "-caption string assign a caption to an image", |
| 655 | "-channel type apply option to select image channels", |
| 656 | "-colors value preferred number of colors in the image", |
| 657 | "-colorspace type alternate image colorspace", |
| 658 | "-comment string annotate image with comment", |
| 659 | "-compose operator set image composite operator", |
| 660 | "-compress type type of pixel compression when writing the image", |
| 661 | "-define format:option", |
| 662 | " define one or more image format options", |
| 663 | "-delay value display the next image after pausing", |
| 664 | "-density geometry horizontal and vertical density of the image", |
| 665 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 666 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 667 | "-display server get image or font from this X server", |
| 668 | "-dispose method layer disposal method", |
| 669 | "-dither method apply error diffusion to image", |
| 670 | "-encoding type text encoding type", |
| 671 | "-endian type endianness (MSB or LSB) of the image", |
| 672 | "-family name render text with this font family", |
| 673 | "-fill color color to use when filling a graphic primitive", |
| 674 | "-filter type use this filter when resizing an image", |
| 675 | "-font name render text with this font", |
| 676 | "-format \"string\" output formatted image characteristics", |
| 677 | "-fuzz distance colors within this distance are considered equal", |
| 678 | "-gravity type horizontal and vertical text placement", |
| 679 | "-green-primary point chromaticity green primary point", |
| 680 | "-intent type type of rendering intent when managing the image color", |
| 681 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 682 | "-interline-spacing value", |
| 683 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 684 | "-interpolate method pixel color interpolation method", |
| 685 | "-interword-spacing value", |
| 686 | " set the space between two words", |
| 687 | "-kerning value set the space between two letters", |
| 688 | "-label string assign a label to an image", |
| 689 | "-limit type value pixel cache resource limit", |
| 690 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 691 | "-mask filename associate a mask with the image", |
| 692 | "-mattecolor color frame color", |
| 693 | "-monitor monitor progress", |
| 694 | "-orient type image orientation", |
| 695 | "-page geometry size and location of an image canvas (setting)", |
| 696 | "-ping efficiently determine image attributes", |
| 697 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 698 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 699 | "-preview type image preview type", |
| 700 | "-quality value JPEG/MIFF/PNG compression level", |
| 701 | "-quiet suppress all warning messages", |
| 702 | "-red-primary point chromaticity red primary point", |
| 703 | "-regard-warnings pay attention to warning messages", |
| 704 | "-remap filename transform image colors to match this set of colors", |
| 705 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 706 | "-sampling-factor geometry", |
| 707 | " horizontal and vertical sampling factor", |
| 708 | "-scene value image scene number", |
| 709 | "-seed value seed a new sequence of pseudo-random numbers", |
| 710 | "-size geometry width and height of image", |
| 711 | "-stretch type render text with this font stretch", |
| 712 | "-stroke color graphic primitive stroke color", |
| 713 | "-strokewidth value graphic primitive stroke width", |
| 714 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 715 | "-synchronize synchronize image to storage device", |
| 716 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 717 | "-texture filename name of texture to tile onto the image background", |
| 718 | "-tile-offset geometry", |
| 719 | " tile offset", |
| 720 | "-treedepth value color tree depth", |
| 721 | "-transparent-color color", |
| 722 | " transparent color", |
| 723 | "-undercolor color annotation bounding box color", |
| 724 | "-units type the units of image resolution", |
| 725 | "-verbose print detailed information about the image", |
| 726 | "-view FlashPix viewing transforms", |
| 727 | "-virtual-pixel method", |
| 728 | " virtual pixel access method", |
| 729 | "-weight type render text with this font weight", |
| 730 | "-white-point point chromaticity white point", |
| 731 | (char *) NULL |
| 732 | }, |
| 733 | *stack_operators[]= |
| 734 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 735 | "-delete indexes delete the image from the image sequence", |
| 736 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 737 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 738 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 739 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 740 | "-swap indexes swap two images in the image sequence", |
| 741 | (char *) NULL |
| 742 | }; |
| 743 | |
| 744 | const char |
| 745 | **p; |
| 746 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 747 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 748 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 749 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 750 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 751 | GetClientName()); |
| 752 | (void) printf("\nImage Settings:\n"); |
| 753 | for (p=settings; *p != (char *) NULL; p++) |
| 754 | (void) printf(" %s\n",*p); |
| 755 | (void) printf("\nImage Operators:\n"); |
| 756 | for (p=operators; *p != (char *) NULL; p++) |
| 757 | (void) printf(" %s\n",*p); |
| 758 | (void) printf("\nImage Sequence Operators:\n"); |
| 759 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 760 | (void) printf(" %s\n",*p); |
| 761 | (void) printf("\nImage Stack Operators:\n"); |
| 762 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 763 | (void) printf(" %s\n",*p); |
| 764 | (void) printf("\nMiscellaneous Options:\n"); |
| 765 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 766 | (void) printf(" %s\n",*p); |
| 767 | (void) printf( |
| 768 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 769 | (void) printf( |
| 770 | "number. To specify a particular image format, precede the filename\n"); |
| 771 | (void) printf( |
| 772 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 773 | (void) printf( |
| 774 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 775 | (void) printf("'-' for standard input or output.\n"); |
| 776 | return(MagickFalse); |
| 777 | } |
| 778 | |
| 779 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 780 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 781 | { |
| 782 | #define DestroyMogrify() \ |
| 783 | { \ |
| 784 | if (format != (char *) NULL) \ |
| 785 | format=DestroyString(format); \ |
| 786 | if (path != (char *) NULL) \ |
| 787 | path=DestroyString(path); \ |
| 788 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 789 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 790 | argv[i]=DestroyString(argv[i]); \ |
| 791 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 792 | } |
| 793 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 794 | { \ |
| 795 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 796 | option); \ |
| 797 | DestroyMogrify(); \ |
| 798 | return(MagickFalse); \ |
| 799 | } |
| 800 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 801 | { \ |
| 802 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 803 | "InvalidArgument","`%s': %s",argument,option); \ |
| 804 | DestroyMogrify(); \ |
| 805 | return(MagickFalse); \ |
| 806 | } |
| 807 | |
| 808 | char |
| 809 | *format, |
| 810 | *option, |
| 811 | *path; |
| 812 | |
| 813 | Image |
| 814 | *image; |
| 815 | |
| 816 | ImageStack |
| 817 | image_stack[MaxImageStackDepth+1]; |
| 818 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 819 | MagickBooleanType |
| 820 | global_colormap; |
| 821 | |
| 822 | MagickBooleanType |
| 823 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 824 | pend, |
| 825 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 826 | |
| 827 | MagickStatusType |
| 828 | status; |
| 829 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 830 | register ssize_t |
| 831 | i; |
| 832 | |
| 833 | ssize_t |
| 834 | j, |
| 835 | k; |
| 836 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 837 | /* |
| 838 | Set defaults. |
| 839 | */ |
| 840 | assert(image_info != (ImageInfo *) NULL); |
| 841 | assert(image_info->signature == MagickSignature); |
| 842 | if (image_info->debug != MagickFalse) |
| 843 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 844 | assert(exception != (ExceptionInfo *) NULL); |
| 845 | if (argc == 2) |
| 846 | { |
| 847 | option=argv[1]; |
| 848 | if ((LocaleCompare("version",option+1) == 0) || |
| 849 | (LocaleCompare("-version",option+1) == 0)) |
| 850 | { |
| 851 | (void) fprintf(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 852 | GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 853 | (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright()); |
| 854 | (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 855 | return(MagickFalse); |
| 856 | } |
| 857 | } |
| 858 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 859 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 860 | format=(char *) NULL; |
| 861 | path=(char *) NULL; |
| 862 | global_colormap=MagickFalse; |
| 863 | k=0; |
| 864 | j=1; |
| 865 | NewImageStack(); |
| 866 | option=(char *) NULL; |
| 867 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 868 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 869 | status=MagickTrue; |
| 870 | /* |
| 871 | Parse command line. |
| 872 | */ |
| 873 | ReadCommandlLine(argc,&argv); |
| 874 | status=ExpandFilenames(&argc,&argv); |
| 875 | if (status == MagickFalse) |
| 876 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 877 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 878 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 879 | { |
| 880 | option=argv[i]; |
| 881 | if (LocaleCompare(option,"(") == 0) |
| 882 | { |
| 883 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 884 | if (k == MaxImageStackDepth) |
| 885 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 886 | option); |
| 887 | PushImageStack(); |
| 888 | continue; |
| 889 | } |
| 890 | if (LocaleCompare(option,")") == 0) |
| 891 | { |
| 892 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 893 | if (k == 0) |
| 894 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 895 | PopImageStack(); |
| 896 | continue; |
| 897 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 898 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 899 | { |
| 900 | char |
| 901 | backup_filename[MaxTextExtent], |
| 902 | *filename; |
| 903 | |
| 904 | Image |
| 905 | *images; |
| 906 | |
| 907 | /* |
| 908 | Option is a file name: begin by reading image from specified file. |
| 909 | */ |
| 910 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 911 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 912 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 913 | filename=argv[++i]; |
| 914 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 915 | images=ReadImages(image_info,exception); |
| 916 | status&=(images != (Image *) NULL) && |
| 917 | (exception->severity < ErrorException); |
| 918 | if (images == (Image *) NULL) |
| 919 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 920 | if (format != (char *) NULL) |
| 921 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 922 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 923 | if (path != (char *) NULL) |
| 924 | { |
| 925 | GetPathComponent(option,TailPath,filename); |
| 926 | (void) FormatMagickString(images->filename,MaxTextExtent,"%s%c%s", |
| 927 | path,*DirectorySeparator,filename); |
| 928 | } |
| 929 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 930 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 931 | AppendImageStack(images); |
| 932 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 933 | if (global_colormap != MagickFalse) |
| 934 | { |
| 935 | QuantizeInfo |
| 936 | *quantize_info; |
| 937 | |
| 938 | quantize_info=AcquireQuantizeInfo(image_info); |
| 939 | (void) RemapImages(quantize_info,images,(Image *) NULL); |
| 940 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 941 | } |
| 942 | *backup_filename='\0'; |
| 943 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 944 | (IsPathWritable(image->filename) != MagickFalse)) |
| 945 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 946 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 947 | i; |
| 948 | |
| 949 | /* |
| 950 | Rename image file as backup. |
| 951 | */ |
| 952 | (void) CopyMagickString(backup_filename,image->filename, |
| 953 | MaxTextExtent); |
| 954 | for (i=0; i < 6; i++) |
| 955 | { |
| 956 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 957 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 958 | break; |
| 959 | } |
| 960 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
| 961 | (rename(image->filename,backup_filename) != 0)) |
| 962 | *backup_filename='\0'; |
| 963 | } |
| 964 | /* |
| 965 | Write transmogrified image to disk. |
| 966 | */ |
| 967 | image_info->synchronize=MagickTrue; |
| 968 | status&=WriteImages(image_info,image,image->filename,exception); |
| 969 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
| 970 | (void) remove(backup_filename); |
| 971 | RemoveAllImageStack(); |
| 972 | continue; |
| 973 | } |
| 974 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 975 | switch (*(option+1)) |
| 976 | { |
| 977 | case 'a': |
| 978 | { |
| 979 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 980 | { |
| 981 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 982 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 983 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 984 | if (IsGeometry(argv[i]) == MagickFalse) |
| 985 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 986 | break; |
| 987 | } |
| 988 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 989 | { |
| 990 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 991 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 992 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 993 | if (IsGeometry(argv[i]) == MagickFalse) |
| 994 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 995 | break; |
| 996 | } |
| 997 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 998 | { |
| 999 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1000 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1001 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1002 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1003 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1004 | break; |
| 1005 | } |
| 1006 | if (LocaleCompare("affine",option+1) == 0) |
| 1007 | { |
| 1008 | if (*option == '+') |
| 1009 | break; |
| 1010 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1011 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1012 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1013 | break; |
| 1014 | } |
| 1015 | if (LocaleCompare("alpha",option+1) == 0) |
| 1016 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1017 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1018 | type; |
| 1019 | |
| 1020 | if (*option == '+') |
| 1021 | break; |
| 1022 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1023 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1024 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1025 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1026 | if (type < 0) |
| 1027 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 1028 | argv[i]); |
| 1029 | break; |
| 1030 | } |
| 1031 | if (LocaleCompare("annotate",option+1) == 0) |
| 1032 | { |
| 1033 | if (*option == '+') |
| 1034 | break; |
| 1035 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1036 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1037 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1038 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1039 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1040 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1041 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1042 | i++; |
| 1043 | break; |
| 1044 | } |
| 1045 | if (LocaleCompare("antialias",option+1) == 0) |
| 1046 | break; |
| 1047 | if (LocaleCompare("append",option+1) == 0) |
| 1048 | break; |
| 1049 | if (LocaleCompare("attenuate",option+1) == 0) |
| 1050 | { |
| 1051 | if (*option == '+') |
| 1052 | break; |
| 1053 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1054 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1055 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1056 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1057 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1058 | break; |
| 1059 | } |
| 1060 | if (LocaleCompare("authenticate",option+1) == 0) |
| 1061 | { |
| 1062 | if (*option == '+') |
| 1063 | break; |
| 1064 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1065 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1066 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1067 | break; |
| 1068 | } |
| 1069 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 1070 | break; |
| 1071 | if (LocaleCompare("auto-level",option+1) == 0) |
| 1072 | break; |
| 1073 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 1074 | break; |
| 1075 | if (LocaleCompare("average",option+1) == 0) |
| 1076 | break; |
| 1077 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 1078 | } |
| 1079 | case 'b': |
| 1080 | { |
| 1081 | if (LocaleCompare("background",option+1) == 0) |
| 1082 | { |
| 1083 | if (*option == '+') |
| 1084 | break; |
| 1085 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1086 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1087 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1088 | break; |
| 1089 | } |
| 1090 | if (LocaleCompare("bias",option+1) == 0) |
| 1091 | { |
| 1092 | if (*option == '+') |
| 1093 | break; |
| 1094 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1095 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1096 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1097 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1098 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1099 | break; |
| 1100 | } |
| 1101 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 1102 | break; |
| 1103 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 1104 | { |
| 1105 | if (*option == '+') |
| 1106 | break; |
| 1107 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1108 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1109 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1110 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1111 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1112 | break; |
| 1113 | } |
| 1114 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 1115 | { |
| 1116 | if (*option == '+') |
| 1117 | break; |
| 1118 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1119 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1120 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1121 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1122 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1123 | break; |
| 1124 | } |
| 1125 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 1126 | { |
| 1127 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1128 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1129 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1130 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1131 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1132 | break; |
| 1133 | } |
| 1134 | if (LocaleCompare("blur",option+1) == 0) |
| 1135 | { |
| 1136 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1137 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1138 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1139 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1140 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1141 | break; |
| 1142 | } |
| 1143 | if (LocaleCompare("border",option+1) == 0) |
| 1144 | { |
| 1145 | if (*option == '+') |
| 1146 | break; |
| 1147 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1148 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1149 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1150 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1151 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1152 | break; |
| 1153 | } |
| 1154 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 1155 | { |
| 1156 | if (*option == '+') |
| 1157 | break; |
| 1158 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1159 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1160 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1161 | break; |
| 1162 | } |
| 1163 | if (LocaleCompare("box",option+1) == 0) |
| 1164 | { |
| 1165 | if (*option == '+') |
| 1166 | break; |
| 1167 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1168 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1169 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1170 | break; |
| 1171 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 1172 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 1173 | { |
| 1174 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1175 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 1176 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1177 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1178 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1179 | break; |
| 1180 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1181 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 1182 | } |
| 1183 | case 'c': |
| 1184 | { |
| 1185 | if (LocaleCompare("cache",option+1) == 0) |
| 1186 | { |
| 1187 | if (*option == '+') |
| 1188 | break; |
| 1189 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1190 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1191 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1192 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1193 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1194 | break; |
| 1195 | } |
| 1196 | if (LocaleCompare("caption",option+1) == 0) |
| 1197 | { |
| 1198 | if (*option == '+') |
| 1199 | break; |
| 1200 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1201 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1202 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1203 | break; |
| 1204 | } |
| 1205 | if (LocaleCompare("channel",option+1) == 0) |
| 1206 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1207 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1208 | channel; |
| 1209 | |
| 1210 | if (*option == '+') |
| 1211 | break; |
| 1212 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1213 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1214 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1215 | channel=ParseChannelOption(argv[i]); |
| 1216 | if (channel < 0) |
| 1217 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 1218 | argv[i]); |
| 1219 | break; |
| 1220 | } |
| 1221 | if (LocaleCompare("cdl",option+1) == 0) |
| 1222 | { |
| 1223 | if (*option == '+') |
| 1224 | break; |
| 1225 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1226 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1227 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1228 | break; |
| 1229 | } |
| 1230 | if (LocaleCompare("charcoal",option+1) == 0) |
| 1231 | { |
| 1232 | if (*option == '+') |
| 1233 | break; |
| 1234 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1235 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1236 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1237 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1238 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1239 | break; |
| 1240 | } |
| 1241 | if (LocaleCompare("chop",option+1) == 0) |
| 1242 | { |
| 1243 | if (*option == '+') |
| 1244 | break; |
| 1245 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1246 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1247 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1248 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1249 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1250 | break; |
| 1251 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 1252 | if (LocaleCompare("clamp",option+1) == 0) |
| 1253 | break; |
| 1254 | if (LocaleCompare("clip",option+1) == 0) |
| 1255 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1256 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1257 | { |
| 1258 | if (*option == '+') |
| 1259 | break; |
| 1260 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1261 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1262 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1263 | break; |
| 1264 | } |
| 1265 | if (LocaleCompare("clut",option+1) == 0) |
| 1266 | break; |
| 1267 | if (LocaleCompare("coalesce",option+1) == 0) |
| 1268 | break; |
| 1269 | if (LocaleCompare("colorize",option+1) == 0) |
| 1270 | { |
| 1271 | if (*option == '+') |
| 1272 | break; |
| 1273 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1274 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1275 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1276 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1277 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1278 | break; |
| 1279 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 1280 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1281 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 1282 | KernelInfo |
| 1283 | *kernel_info; |
| 1284 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 1285 | if (*option == '+') |
| 1286 | break; |
| 1287 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1288 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 1289 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 1290 | kernel_info=AcquireKernelInfo(argv[i]); |
| 1291 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 1292 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 1293 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 1294 | break; |
| 1295 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1296 | if (LocaleCompare("colors",option+1) == 0) |
| 1297 | { |
| 1298 | if (*option == '+') |
| 1299 | break; |
| 1300 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1301 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1302 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1303 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1304 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1305 | break; |
| 1306 | } |
| 1307 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1308 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1309 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1310 | colorspace; |
| 1311 | |
| 1312 | if (*option == '+') |
| 1313 | break; |
| 1314 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1315 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1316 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1317 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1318 | argv[i]); |
| 1319 | if (colorspace < 0) |
| 1320 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 1321 | argv[i]); |
| 1322 | break; |
| 1323 | } |
| 1324 | if (LocaleCompare("combine",option+1) == 0) |
| 1325 | break; |
| 1326 | if (LocaleCompare("comment",option+1) == 0) |
| 1327 | { |
| 1328 | if (*option == '+') |
| 1329 | break; |
| 1330 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1331 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1332 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1333 | break; |
| 1334 | } |
| 1335 | if (LocaleCompare("composite",option+1) == 0) |
| 1336 | break; |
| 1337 | if (LocaleCompare("compress",option+1) == 0) |
| 1338 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1339 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1340 | compress; |
| 1341 | |
| 1342 | if (*option == '+') |
| 1343 | break; |
| 1344 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1345 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1346 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1347 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1348 | argv[i]); |
| 1349 | if (compress < 0) |
| 1350 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 1351 | argv[i]); |
| 1352 | break; |
| 1353 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 1354 | if (LocaleCompare("concurrent",option+1) == 0) |
| 1355 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1356 | if (LocaleCompare("contrast",option+1) == 0) |
| 1357 | break; |
| 1358 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1359 | { |
| 1360 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1361 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1362 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1363 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1364 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1365 | break; |
| 1366 | } |
| 1367 | if (LocaleCompare("convolve",option+1) == 0) |
| 1368 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 1369 | KernelInfo |
| 1370 | *kernel_info; |
| 1371 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1372 | if (*option == '+') |
| 1373 | break; |
| 1374 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1375 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1376 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 1377 | kernel_info=AcquireKernelInfo(argv[i]); |
| 1378 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 1379 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 1380 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1381 | break; |
| 1382 | } |
| 1383 | if (LocaleCompare("crop",option+1) == 0) |
| 1384 | { |
| 1385 | if (*option == '+') |
| 1386 | break; |
| 1387 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1388 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1389 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1390 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1391 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1392 | break; |
| 1393 | } |
| 1394 | if (LocaleCompare("cycle",option+1) == 0) |
| 1395 | { |
| 1396 | if (*option == '+') |
| 1397 | break; |
| 1398 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1399 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1400 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1401 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1402 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1403 | break; |
| 1404 | } |
| 1405 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 1406 | } |
| 1407 | case 'd': |
| 1408 | { |
| 1409 | if (LocaleCompare("decipher",option+1) == 0) |
| 1410 | { |
| 1411 | if (*option == '+') |
| 1412 | break; |
| 1413 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1414 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1415 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1416 | break; |
| 1417 | } |
| 1418 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 1419 | break; |
| 1420 | if (LocaleCompare("debug",option+1) == 0) |
| 1421 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1422 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1423 | event; |
| 1424 | |
| 1425 | if (*option == '+') |
| 1426 | break; |
| 1427 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1428 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1429 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1430 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1431 | if (event < 0) |
| 1432 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 1433 | argv[i]); |
| 1434 | (void) SetLogEventMask(argv[i]); |
| 1435 | break; |
| 1436 | } |
| 1437 | if (LocaleCompare("define",option+1) == 0) |
| 1438 | { |
| 1439 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1440 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1441 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1442 | if (*option == '+') |
| 1443 | { |
| 1444 | const char |
| 1445 | *define; |
| 1446 | |
| 1447 | define=GetImageOption(image_info,argv[i]); |
| 1448 | if (define == (const char *) NULL) |
| 1449 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 1450 | break; |
| 1451 | } |
| 1452 | break; |
| 1453 | } |
| 1454 | if (LocaleCompare("delay",option+1) == 0) |
| 1455 | { |
| 1456 | if (*option == '+') |
| 1457 | break; |
| 1458 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1459 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1460 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1461 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1462 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1463 | break; |
| 1464 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 1465 | if (LocaleCompare("delete",option+1) == 0) |
| 1466 | { |
| 1467 | if (*option == '+') |
| 1468 | break; |
| 1469 | i++; |
| 1470 | if (i == (ssize_t) (argc-1)) |
| 1471 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1472 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1473 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1474 | break; |
| 1475 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1476 | if (LocaleCompare("density",option+1) == 0) |
| 1477 | { |
| 1478 | if (*option == '+') |
| 1479 | break; |
| 1480 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1481 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1482 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1483 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1484 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1485 | break; |
| 1486 | } |
| 1487 | if (LocaleCompare("depth",option+1) == 0) |
| 1488 | { |
| 1489 | if (*option == '+') |
| 1490 | break; |
| 1491 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1492 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1493 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1494 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1495 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1496 | break; |
| 1497 | } |
| 1498 | if (LocaleCompare("deskew",option+1) == 0) |
| 1499 | { |
| 1500 | if (*option == '+') |
| 1501 | break; |
| 1502 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1503 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1504 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1505 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1506 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1507 | break; |
| 1508 | } |
| 1509 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1510 | break; |
| 1511 | if (LocaleCompare("dft",option+1) == 0) |
| 1512 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 1513 | if (LocaleCompare("direction",option+1) == 0) |
| 1514 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1515 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 1516 | direction; |
| 1517 | |
| 1518 | if (*option == '+') |
| 1519 | break; |
| 1520 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1521 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 1522 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1523 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 1524 | argv[i]); |
| 1525 | if (direction < 0) |
| 1526 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 1527 | argv[i]); |
| 1528 | break; |
| 1529 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1530 | if (LocaleCompare("display",option+1) == 0) |
| 1531 | { |
| 1532 | if (*option == '+') |
| 1533 | break; |
| 1534 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1535 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1536 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1537 | break; |
| 1538 | } |
| 1539 | if (LocaleCompare("dispose",option+1) == 0) |
| 1540 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1541 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1542 | dispose; |
| 1543 | |
| 1544 | if (*option == '+') |
| 1545 | break; |
| 1546 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1547 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1548 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1549 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1550 | if (dispose < 0) |
| 1551 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 1552 | argv[i]); |
| 1553 | break; |
| 1554 | } |
| 1555 | if (LocaleCompare("distort",option+1) == 0) |
| 1556 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1557 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1558 | op; |
| 1559 | |
| 1560 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1561 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1562 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1563 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1564 | if (op < 0) |
| 1565 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 1566 | argv[i]); |
| 1567 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1568 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1569 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1570 | break; |
| 1571 | } |
| 1572 | if (LocaleCompare("dither",option+1) == 0) |
| 1573 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1574 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1575 | method; |
| 1576 | |
| 1577 | if (*option == '+') |
| 1578 | break; |
| 1579 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1580 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1581 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1582 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1583 | if (method < 0) |
| 1584 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 1585 | argv[i]); |
| 1586 | break; |
| 1587 | } |
| 1588 | if (LocaleCompare("draw",option+1) == 0) |
| 1589 | { |
| 1590 | if (*option == '+') |
| 1591 | break; |
| 1592 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1593 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1594 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1595 | break; |
| 1596 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 1597 | if (LocaleCompare("duplicate",option+1) == 0) |
| 1598 | { |
| 1599 | if (*option == '+') |
| 1600 | break; |
| 1601 | i++; |
| 1602 | if (i == (ssize_t) (argc-1)) |
| 1603 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1604 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1605 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1606 | break; |
| 1607 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 1608 | if (LocaleCompare("duration",option+1) == 0) |
| 1609 | { |
| 1610 | if (*option == '+') |
| 1611 | break; |
| 1612 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1613 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 1614 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1615 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1616 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1617 | break; |
| 1618 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1619 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 1620 | } |
| 1621 | case 'e': |
| 1622 | { |
| 1623 | if (LocaleCompare("edge",option+1) == 0) |
| 1624 | { |
| 1625 | if (*option == '+') |
| 1626 | break; |
| 1627 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1628 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1629 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1630 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1631 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1632 | break; |
| 1633 | } |
| 1634 | if (LocaleCompare("emboss",option+1) == 0) |
| 1635 | { |
| 1636 | if (*option == '+') |
| 1637 | break; |
| 1638 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1639 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1640 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1641 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1642 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1643 | break; |
| 1644 | } |
| 1645 | if (LocaleCompare("encipher",option+1) == 0) |
| 1646 | { |
| 1647 | if (*option == '+') |
| 1648 | break; |
| 1649 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1650 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1651 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1652 | break; |
| 1653 | } |
| 1654 | if (LocaleCompare("encoding",option+1) == 0) |
| 1655 | { |
| 1656 | if (*option == '+') |
| 1657 | break; |
| 1658 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1659 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1660 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1661 | break; |
| 1662 | } |
| 1663 | if (LocaleCompare("endian",option+1) == 0) |
| 1664 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1665 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1666 | endian; |
| 1667 | |
| 1668 | if (*option == '+') |
| 1669 | break; |
| 1670 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1671 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1672 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1673 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1674 | if (endian < 0) |
| 1675 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 1676 | argv[i]); |
| 1677 | break; |
| 1678 | } |
| 1679 | if (LocaleCompare("enhance",option+1) == 0) |
| 1680 | break; |
| 1681 | if (LocaleCompare("equalize",option+1) == 0) |
| 1682 | break; |
| 1683 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1684 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1685 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1686 | op; |
| 1687 | |
| 1688 | if (*option == '+') |
| 1689 | break; |
| 1690 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1691 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1692 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1693 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1694 | if (op < 0) |
| 1695 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 1696 | argv[i]); |
| 1697 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1698 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1699 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1700 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1701 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1702 | break; |
| 1703 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 1704 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 1705 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1706 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 1707 | op; |
| 1708 | |
| 1709 | if (*option == '+') |
| 1710 | break; |
| 1711 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1712 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 1713 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1714 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 1715 | if (op < 0) |
| 1716 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 1717 | argv[i]); |
| 1718 | break; |
| 1719 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1720 | if (LocaleCompare("extent",option+1) == 0) |
| 1721 | { |
| 1722 | if (*option == '+') |
| 1723 | break; |
| 1724 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1725 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1726 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1727 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1728 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1729 | break; |
| 1730 | } |
| 1731 | if (LocaleCompare("extract",option+1) == 0) |
| 1732 | { |
| 1733 | if (*option == '+') |
| 1734 | break; |
| 1735 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1736 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1737 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1738 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1739 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1740 | break; |
| 1741 | } |
| 1742 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 1743 | } |
| 1744 | case 'f': |
| 1745 | { |
| 1746 | if (LocaleCompare("family",option+1) == 0) |
| 1747 | { |
| 1748 | if (*option == '+') |
| 1749 | break; |
| 1750 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1751 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1752 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1753 | break; |
| 1754 | } |
| 1755 | if (LocaleCompare("fill",option+1) == 0) |
| 1756 | { |
| 1757 | if (*option == '+') |
| 1758 | break; |
| 1759 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1760 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1761 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1762 | break; |
| 1763 | } |
| 1764 | if (LocaleCompare("filter",option+1) == 0) |
| 1765 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1766 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1767 | filter; |
| 1768 | |
| 1769 | if (*option == '+') |
| 1770 | break; |
| 1771 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1772 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1773 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1774 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1775 | if (filter < 0) |
| 1776 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 1777 | argv[i]); |
| 1778 | break; |
| 1779 | } |
| 1780 | if (LocaleCompare("flatten",option+1) == 0) |
| 1781 | break; |
| 1782 | if (LocaleCompare("flip",option+1) == 0) |
| 1783 | break; |
| 1784 | if (LocaleCompare("flop",option+1) == 0) |
| 1785 | break; |
| 1786 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1787 | { |
| 1788 | if (*option == '+') |
| 1789 | break; |
| 1790 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1791 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1792 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1793 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1794 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1795 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1796 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1797 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1798 | break; |
| 1799 | } |
| 1800 | if (LocaleCompare("font",option+1) == 0) |
| 1801 | { |
| 1802 | if (*option == '+') |
| 1803 | break; |
| 1804 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1805 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1806 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1807 | break; |
| 1808 | } |
| 1809 | if (LocaleCompare("format",option+1) == 0) |
| 1810 | { |
| 1811 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 1812 | (void) CloneString(&format,(char *) NULL); |
| 1813 | if (*option == '+') |
| 1814 | break; |
| 1815 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1816 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1817 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1818 | (void) CloneString(&format,argv[i]); |
| 1819 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 1820 | (void) ConcatenateMagickString(image_info->filename,":", |
| 1821 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 1822 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1823 | if (*image_info->magick == '\0') |
| 1824 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 1825 | format); |
| 1826 | break; |
| 1827 | } |
| 1828 | if (LocaleCompare("frame",option+1) == 0) |
| 1829 | { |
| 1830 | if (*option == '+') |
| 1831 | break; |
| 1832 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1833 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1834 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1835 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1836 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1837 | break; |
| 1838 | } |
| 1839 | if (LocaleCompare("function",option+1) == 0) |
| 1840 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1841 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1842 | op; |
| 1843 | |
| 1844 | if (*option == '+') |
| 1845 | break; |
| 1846 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1847 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1848 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1849 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1850 | if (op < 0) |
| 1851 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 1852 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1853 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1854 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1855 | break; |
| 1856 | } |
| 1857 | if (LocaleCompare("fuzz",option+1) == 0) |
| 1858 | { |
| 1859 | if (*option == '+') |
| 1860 | break; |
| 1861 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1862 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1863 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1864 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1865 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1866 | break; |
| 1867 | } |
| 1868 | if (LocaleCompare("fx",option+1) == 0) |
| 1869 | { |
| 1870 | if (*option == '+') |
| 1871 | break; |
| 1872 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1873 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1874 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1875 | break; |
| 1876 | } |
| 1877 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 1878 | } |
| 1879 | case 'g': |
| 1880 | { |
| 1881 | if (LocaleCompare("gamma",option+1) == 0) |
| 1882 | { |
| 1883 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1884 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1885 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1886 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1887 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1888 | break; |
| 1889 | } |
| 1890 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1891 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1892 | { |
| 1893 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1894 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1895 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1896 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1897 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1898 | break; |
| 1899 | } |
| 1900 | if (LocaleCompare("geometry",option+1) == 0) |
| 1901 | { |
| 1902 | if (*option == '+') |
| 1903 | break; |
| 1904 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1905 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1906 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1907 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1908 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1909 | break; |
| 1910 | } |
| 1911 | if (LocaleCompare("gravity",option+1) == 0) |
| 1912 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1913 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1914 | gravity; |
| 1915 | |
| 1916 | if (*option == '+') |
| 1917 | break; |
| 1918 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1919 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1920 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1921 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1922 | if (gravity < 0) |
| 1923 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 1924 | argv[i]); |
| 1925 | break; |
| 1926 | } |
| 1927 | if (LocaleCompare("green-primary",option+1) == 0) |
| 1928 | { |
| 1929 | if (*option == '+') |
| 1930 | break; |
| 1931 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1932 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1933 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1934 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1935 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1936 | break; |
| 1937 | } |
| 1938 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 1939 | } |
| 1940 | case 'h': |
| 1941 | { |
| 1942 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 1943 | break; |
| 1944 | if ((LocaleCompare("help",option+1) == 0) || |
| 1945 | (LocaleCompare("-help",option+1) == 0)) |
| 1946 | return(MogrifyUsage()); |
| 1947 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 1948 | } |
| 1949 | case 'i': |
| 1950 | { |
| 1951 | if (LocaleCompare("identify",option+1) == 0) |
| 1952 | break; |
| 1953 | if (LocaleCompare("idft",option+1) == 0) |
| 1954 | break; |
| 1955 | if (LocaleCompare("implode",option+1) == 0) |
| 1956 | { |
| 1957 | if (*option == '+') |
| 1958 | break; |
| 1959 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1960 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1961 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 1962 | if (IsGeometry(argv[i]) == MagickFalse) |
| 1963 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 1964 | break; |
| 1965 | } |
| 1966 | if (LocaleCompare("intent",option+1) == 0) |
| 1967 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1968 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1969 | intent; |
| 1970 | |
| 1971 | if (*option == '+') |
| 1972 | break; |
| 1973 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1974 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1975 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1976 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1977 | if (intent < 0) |
| 1978 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 1979 | argv[i]); |
| 1980 | break; |
| 1981 | } |
| 1982 | if (LocaleCompare("interlace",option+1) == 0) |
| 1983 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1984 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1985 | interlace; |
| 1986 | |
| 1987 | if (*option == '+') |
| 1988 | break; |
| 1989 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1990 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1991 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1992 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1993 | argv[i]); |
| 1994 | if (interlace < 0) |
| 1995 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 1996 | argv[i]); |
| 1997 | break; |
| 1998 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 1999 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 2000 | { |
| 2001 | if (*option == '+') |
| 2002 | break; |
| 2003 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2004 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 2005 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2006 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2007 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2008 | break; |
| 2009 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2010 | if (LocaleCompare("interpolate",option+1) == 0) |
| 2011 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2012 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2013 | interpolate; |
| 2014 | |
| 2015 | if (*option == '+') |
| 2016 | break; |
| 2017 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2018 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2019 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 2020 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2021 | argv[i]); |
| 2022 | if (interpolate < 0) |
| 2023 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 2024 | argv[i]); |
| 2025 | break; |
| 2026 | } |
| 2027 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 2028 | { |
| 2029 | if (*option == '+') |
| 2030 | break; |
| 2031 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2032 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2033 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2034 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2035 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2036 | break; |
| 2037 | } |
| 2038 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 2039 | } |
| 2040 | case 'k': |
| 2041 | { |
| 2042 | if (LocaleCompare("kerning",option+1) == 0) |
| 2043 | { |
| 2044 | if (*option == '+') |
| 2045 | break; |
| 2046 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2047 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2048 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2049 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2050 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2051 | break; |
| 2052 | } |
| 2053 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 2054 | } |
| 2055 | case 'l': |
| 2056 | { |
| 2057 | if (LocaleCompare("label",option+1) == 0) |
| 2058 | { |
| 2059 | if (*option == '+') |
| 2060 | break; |
| 2061 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2062 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2063 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2064 | break; |
| 2065 | } |
| 2066 | if (LocaleCompare("lat",option+1) == 0) |
| 2067 | { |
| 2068 | if (*option == '+') |
| 2069 | break; |
| 2070 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2071 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2072 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2073 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2074 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2075 | } |
| 2076 | if (LocaleCompare("layers",option+1) == 0) |
| 2077 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2078 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2079 | type; |
| 2080 | |
| 2081 | if (*option == '+') |
| 2082 | break; |
| 2083 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2084 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2085 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 2086 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2087 | if (type < 0) |
| 2088 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 2089 | argv[i]); |
| 2090 | break; |
| 2091 | } |
| 2092 | if (LocaleCompare("level",option+1) == 0) |
| 2093 | { |
| 2094 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2095 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2096 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2097 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2098 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2099 | break; |
| 2100 | } |
| 2101 | if (LocaleCompare("level-colors",option+1) == 0) |
| 2102 | { |
| 2103 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2104 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2105 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2106 | break; |
| 2107 | } |
| 2108 | if (LocaleCompare("linewidth",option+1) == 0) |
| 2109 | { |
| 2110 | if (*option == '+') |
| 2111 | break; |
| 2112 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2113 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2114 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2115 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2116 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2117 | break; |
| 2118 | } |
| 2119 | if (LocaleCompare("limit",option+1) == 0) |
| 2120 | { |
| 2121 | char |
| 2122 | *p; |
| 2123 | |
| 2124 | double |
| 2125 | value; |
| 2126 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2127 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2128 | resource; |
| 2129 | |
| 2130 | if (*option == '+') |
| 2131 | break; |
| 2132 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2133 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2134 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 2135 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2136 | argv[i]); |
| 2137 | if (resource < 0) |
| 2138 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 2139 | argv[i]); |
| 2140 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2141 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2142 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2143 | value=strtod(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 2144 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2145 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 2146 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2147 | break; |
| 2148 | } |
| 2149 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 2150 | { |
| 2151 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2152 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2153 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2154 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2155 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2156 | break; |
| 2157 | } |
| 2158 | if (LocaleCompare("list",option+1) == 0) |
| 2159 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2160 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2161 | list; |
| 2162 | |
| 2163 | if (*option == '+') |
| 2164 | break; |
| 2165 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2166 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2167 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 2168 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2169 | if (list < 0) |
| 2170 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 2171 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2172 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 2173 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2174 | } |
| 2175 | if (LocaleCompare("log",option+1) == 0) |
| 2176 | { |
| 2177 | if (*option == '+') |
| 2178 | break; |
| 2179 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2180 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2181 | (strchr(argv[i],'%') == (char *) NULL)) |
| 2182 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2183 | break; |
| 2184 | } |
| 2185 | if (LocaleCompare("loop",option+1) == 0) |
| 2186 | { |
| 2187 | if (*option == '+') |
| 2188 | break; |
| 2189 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2190 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2191 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2192 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2193 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2194 | break; |
| 2195 | } |
| 2196 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 2197 | } |
| 2198 | case 'm': |
| 2199 | { |
| 2200 | if (LocaleCompare("map",option+1) == 0) |
| 2201 | { |
| 2202 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 2203 | if (*option == '+') |
| 2204 | break; |
| 2205 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2206 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2207 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2208 | break; |
| 2209 | } |
| 2210 | if (LocaleCompare("mask",option+1) == 0) |
| 2211 | { |
| 2212 | if (*option == '+') |
| 2213 | break; |
| 2214 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2215 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2216 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2217 | break; |
| 2218 | } |
| 2219 | if (LocaleCompare("matte",option+1) == 0) |
| 2220 | break; |
| 2221 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 2222 | { |
| 2223 | if (*option == '+') |
| 2224 | break; |
| 2225 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2226 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2227 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2228 | break; |
| 2229 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 2230 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 2231 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 2232 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 2233 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2234 | if (LocaleCompare("modulate",option+1) == 0) |
| 2235 | { |
| 2236 | if (*option == '+') |
| 2237 | break; |
| 2238 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2239 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2240 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2241 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2242 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2243 | break; |
| 2244 | } |
| 2245 | if (LocaleCompare("median",option+1) == 0) |
| 2246 | { |
| 2247 | if (*option == '+') |
| 2248 | break; |
| 2249 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2250 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2251 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2252 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2253 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2254 | break; |
| 2255 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 2256 | if (LocaleCompare("mode",option+1) == 0) |
| 2257 | { |
| 2258 | if (*option == '+') |
| 2259 | break; |
| 2260 | i++; |
| 2261 | if (i == (ssize_t) argc) |
| 2262 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2263 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2264 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2265 | break; |
| 2266 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2267 | if (LocaleCompare("monitor",option+1) == 0) |
| 2268 | break; |
| 2269 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2270 | break; |
| 2271 | if (LocaleCompare("morph",option+1) == 0) |
| 2272 | { |
| 2273 | if (*option == '+') |
| 2274 | break; |
| 2275 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2276 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2277 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2278 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2279 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2280 | break; |
| 2281 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2282 | if (LocaleCompare("morphology",option+1) == 0) |
| 2283 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2284 | char |
| 2285 | token[MaxTextExtent]; |
| 2286 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 2287 | KernelInfo |
| 2288 | *kernel_info; |
| 2289 | |
| 2290 | ssize_t |
| 2291 | op; |
| 2292 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2293 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2294 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2295 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2296 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 2297 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2298 | if (op < 0) |
| 2299 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 2300 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2301 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2302 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2303 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 2304 | kernel_info=AcquireKernelInfo(argv[i]); |
| 2305 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 2306 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 2307 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2308 | break; |
| 2309 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2310 | if (LocaleCompare("mosaic",option+1) == 0) |
| 2311 | break; |
| 2312 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2313 | { |
| 2314 | if (*option == '+') |
| 2315 | break; |
| 2316 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2317 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2318 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2319 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2320 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2321 | break; |
| 2322 | } |
| 2323 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 2324 | } |
| 2325 | case 'n': |
| 2326 | { |
| 2327 | if (LocaleCompare("negate",option+1) == 0) |
| 2328 | break; |
| 2329 | if (LocaleCompare("noise",option+1) == 0) |
| 2330 | { |
| 2331 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2332 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2333 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2334 | if (*option == '+') |
| 2335 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2336 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2337 | noise; |
| 2338 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 2339 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2340 | if (noise < 0) |
| 2341 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 2342 | argv[i]); |
| 2343 | break; |
| 2344 | } |
| 2345 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2346 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2347 | break; |
| 2348 | } |
| 2349 | if (LocaleCompare("noop",option+1) == 0) |
| 2350 | break; |
| 2351 | if (LocaleCompare("normalize",option+1) == 0) |
| 2352 | break; |
| 2353 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 2354 | } |
| 2355 | case 'o': |
| 2356 | { |
| 2357 | if (LocaleCompare("opaque",option+1) == 0) |
| 2358 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2359 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2360 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2361 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2362 | break; |
| 2363 | } |
| 2364 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2365 | { |
| 2366 | if (*option == '+') |
| 2367 | break; |
| 2368 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2369 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2370 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2371 | break; |
| 2372 | } |
| 2373 | if (LocaleCompare("orient",option+1) == 0) |
| 2374 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2375 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2376 | orientation; |
| 2377 | |
| 2378 | orientation=UndefinedOrientation; |
| 2379 | if (*option == '+') |
| 2380 | break; |
| 2381 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2382 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2383 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 2384 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2385 | argv[i]); |
| 2386 | if (orientation < 0) |
| 2387 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 2388 | argv[i]); |
| 2389 | break; |
| 2390 | } |
| 2391 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 2392 | } |
| 2393 | case 'p': |
| 2394 | { |
| 2395 | if (LocaleCompare("page",option+1) == 0) |
| 2396 | { |
| 2397 | if (*option == '+') |
| 2398 | break; |
| 2399 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2400 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2401 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2402 | break; |
| 2403 | } |
| 2404 | if (LocaleCompare("paint",option+1) == 0) |
| 2405 | { |
| 2406 | if (*option == '+') |
| 2407 | break; |
| 2408 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2409 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2410 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2411 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2412 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2413 | break; |
| 2414 | } |
| 2415 | if (LocaleCompare("path",option+1) == 0) |
| 2416 | { |
| 2417 | (void) CloneString(&path,(char *) NULL); |
| 2418 | if (*option == '+') |
| 2419 | break; |
| 2420 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2421 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2422 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2423 | (void) CloneString(&path,argv[i]); |
| 2424 | break; |
| 2425 | } |
| 2426 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2427 | { |
| 2428 | if (*option == '+') |
| 2429 | break; |
| 2430 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2431 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2432 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2433 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2434 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2435 | break; |
| 2436 | } |
| 2437 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2438 | { |
| 2439 | if (*option == '+') |
| 2440 | break; |
| 2441 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2442 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2443 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2444 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2445 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2446 | break; |
| 2447 | } |
| 2448 | if (LocaleCompare("posterize",option+1) == 0) |
| 2449 | { |
| 2450 | if (*option == '+') |
| 2451 | break; |
| 2452 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2453 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2454 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2455 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2456 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2457 | break; |
| 2458 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 2459 | if (LocaleCompare("precision",option+1) == 0) |
| 2460 | { |
| 2461 | if (*option == '+') |
| 2462 | break; |
| 2463 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2464 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 2465 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2466 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2467 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2468 | break; |
| 2469 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2470 | if (LocaleCompare("print",option+1) == 0) |
| 2471 | { |
| 2472 | if (*option == '+') |
| 2473 | break; |
| 2474 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2475 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2476 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2477 | break; |
| 2478 | } |
| 2479 | if (LocaleCompare("process",option+1) == 0) |
| 2480 | { |
| 2481 | if (*option == '+') |
| 2482 | break; |
| 2483 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2484 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2485 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2486 | break; |
| 2487 | } |
| 2488 | if (LocaleCompare("profile",option+1) == 0) |
| 2489 | { |
| 2490 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2491 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2492 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2493 | break; |
| 2494 | } |
| 2495 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 2496 | } |
| 2497 | case 'q': |
| 2498 | { |
| 2499 | if (LocaleCompare("quality",option+1) == 0) |
| 2500 | { |
| 2501 | if (*option == '+') |
| 2502 | break; |
| 2503 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2504 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2505 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2506 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2507 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2508 | break; |
| 2509 | } |
| 2510 | if (LocaleCompare("quantize",option+1) == 0) |
| 2511 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2512 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2513 | colorspace; |
| 2514 | |
| 2515 | if (*option == '+') |
| 2516 | break; |
| 2517 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2518 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2519 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 2520 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2521 | argv[i]); |
| 2522 | if (colorspace < 0) |
| 2523 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 2524 | argv[i]); |
| 2525 | break; |
| 2526 | } |
| 2527 | if (LocaleCompare("quiet",option+1) == 0) |
| 2528 | break; |
| 2529 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 2530 | } |
| 2531 | case 'r': |
| 2532 | { |
| 2533 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2534 | { |
| 2535 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2536 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2537 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2538 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2539 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2540 | break; |
| 2541 | } |
| 2542 | if (LocaleCompare("raise",option+1) == 0) |
| 2543 | { |
| 2544 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2545 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2546 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2547 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2548 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2549 | break; |
| 2550 | } |
| 2551 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2552 | { |
| 2553 | if (*option == '+') |
| 2554 | break; |
| 2555 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2556 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2557 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2558 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2559 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2560 | break; |
| 2561 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 2562 | if (LocaleCompare("recolor",option+1) == 0) |
| 2563 | { |
| 2564 | if (*option == '+') |
| 2565 | break; |
| 2566 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2567 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 2568 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2569 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2570 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2571 | break; |
| 2572 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2573 | if (LocaleCompare("red-primary",option+1) == 0) |
| 2574 | { |
| 2575 | if (*option == '+') |
| 2576 | break; |
| 2577 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2578 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2579 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2580 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2581 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2582 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 2583 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 2584 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2585 | if (LocaleCompare("region",option+1) == 0) |
| 2586 | { |
| 2587 | if (*option == '+') |
| 2588 | break; |
| 2589 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2590 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2591 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2592 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2593 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2594 | break; |
| 2595 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 2596 | if (LocaleCompare("remap",option+1) == 0) |
| 2597 | { |
| 2598 | if (*option == '+') |
| 2599 | break; |
| 2600 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2601 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 2602 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2603 | break; |
| 2604 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2605 | if (LocaleCompare("render",option+1) == 0) |
| 2606 | break; |
| 2607 | if (LocaleCompare("repage",option+1) == 0) |
| 2608 | { |
| 2609 | if (*option == '+') |
| 2610 | break; |
| 2611 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2612 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2613 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2614 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2615 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2616 | break; |
| 2617 | } |
| 2618 | if (LocaleCompare("resample",option+1) == 0) |
| 2619 | { |
| 2620 | if (*option == '+') |
| 2621 | break; |
| 2622 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2623 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2624 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2625 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2626 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2627 | break; |
| 2628 | } |
| 2629 | if (LocaleCompare("resize",option+1) == 0) |
| 2630 | { |
| 2631 | if (*option == '+') |
| 2632 | break; |
| 2633 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2634 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2635 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2636 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2637 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2638 | break; |
| 2639 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 2640 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 2641 | { |
| 2642 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 2643 | break; |
| 2644 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2645 | if (LocaleCompare("reverse",option+1) == 0) |
| 2646 | break; |
| 2647 | if (LocaleCompare("roll",option+1) == 0) |
| 2648 | { |
| 2649 | if (*option == '+') |
| 2650 | break; |
| 2651 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2652 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2653 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2654 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2655 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2656 | break; |
| 2657 | } |
| 2658 | if (LocaleCompare("rotate",option+1) == 0) |
| 2659 | { |
| 2660 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2661 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2662 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2663 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2664 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2665 | break; |
| 2666 | } |
| 2667 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 2668 | } |
| 2669 | case 's': |
| 2670 | { |
| 2671 | if (LocaleCompare("sample",option+1) == 0) |
| 2672 | { |
| 2673 | if (*option == '+') |
| 2674 | break; |
| 2675 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2676 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2677 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2678 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2679 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2680 | break; |
| 2681 | } |
| 2682 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 2683 | { |
| 2684 | if (*option == '+') |
| 2685 | break; |
| 2686 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2687 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2688 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2689 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2690 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2691 | break; |
| 2692 | } |
| 2693 | if (LocaleCompare("scale",option+1) == 0) |
| 2694 | { |
| 2695 | if (*option == '+') |
| 2696 | break; |
| 2697 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2698 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2699 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2700 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2701 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2702 | break; |
| 2703 | } |
| 2704 | if (LocaleCompare("scene",option+1) == 0) |
| 2705 | { |
| 2706 | if (*option == '+') |
| 2707 | break; |
| 2708 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2709 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2710 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2711 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2712 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2713 | break; |
| 2714 | } |
| 2715 | if (LocaleCompare("seed",option+1) == 0) |
| 2716 | { |
| 2717 | if (*option == '+') |
| 2718 | break; |
| 2719 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2720 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2721 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2722 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2723 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2724 | break; |
| 2725 | } |
| 2726 | if (LocaleCompare("segment",option+1) == 0) |
| 2727 | { |
| 2728 | if (*option == '+') |
| 2729 | break; |
| 2730 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2731 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2732 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2733 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2734 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2735 | break; |
| 2736 | } |
| 2737 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2738 | { |
| 2739 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2740 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2741 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2742 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2743 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2744 | break; |
| 2745 | } |
| 2746 | if (LocaleCompare("separate",option+1) == 0) |
| 2747 | break; |
| 2748 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2749 | { |
| 2750 | if (*option == '+') |
| 2751 | break; |
| 2752 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2753 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2754 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2755 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2756 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2757 | break; |
| 2758 | } |
| 2759 | if (LocaleCompare("set",option+1) == 0) |
| 2760 | { |
| 2761 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2762 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2763 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2764 | if (*option == '+') |
| 2765 | break; |
| 2766 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2767 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2768 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2769 | break; |
| 2770 | } |
| 2771 | if (LocaleCompare("shade",option+1) == 0) |
| 2772 | { |
| 2773 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2774 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2775 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2776 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2777 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2778 | break; |
| 2779 | } |
| 2780 | if (LocaleCompare("shadow",option+1) == 0) |
| 2781 | { |
| 2782 | if (*option == '+') |
| 2783 | break; |
| 2784 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2785 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2786 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2787 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2788 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2789 | break; |
| 2790 | } |
| 2791 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2792 | { |
| 2793 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2794 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2795 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2796 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2797 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2798 | break; |
| 2799 | } |
| 2800 | if (LocaleCompare("shave",option+1) == 0) |
| 2801 | { |
| 2802 | if (*option == '+') |
| 2803 | break; |
| 2804 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2805 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2806 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2807 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2808 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2809 | break; |
| 2810 | } |
| 2811 | if (LocaleCompare("shear",option+1) == 0) |
| 2812 | { |
| 2813 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2814 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2815 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2816 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2817 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2818 | break; |
| 2819 | } |
| 2820 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2821 | { |
| 2822 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2823 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2824 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2825 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2826 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2827 | break; |
| 2828 | } |
| 2829 | if (LocaleCompare("size",option+1) == 0) |
| 2830 | { |
| 2831 | if (*option == '+') |
| 2832 | break; |
| 2833 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2834 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2835 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2836 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2837 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2838 | break; |
| 2839 | } |
| 2840 | if (LocaleCompare("sketch",option+1) == 0) |
| 2841 | { |
| 2842 | if (*option == '+') |
| 2843 | break; |
| 2844 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2845 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2846 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2847 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2848 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2849 | break; |
| 2850 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 2851 | if (LocaleCompare("smush",option+1) == 0) |
| 2852 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 2853 | i++; |
| 2854 | if (i == (ssize_t) argc) |
| 2855 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2856 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2857 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 2858 | i++; |
| 2859 | break; |
| 2860 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2861 | if (LocaleCompare("solarize",option+1) == 0) |
| 2862 | { |
| 2863 | if (*option == '+') |
| 2864 | break; |
| 2865 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2866 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2867 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2868 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2869 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2870 | break; |
| 2871 | } |
| 2872 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2873 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2874 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2875 | op; |
| 2876 | |
| 2877 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2878 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2879 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 2880 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2881 | if (op < 0) |
| 2882 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 2883 | argv[i]); |
| 2884 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2885 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2886 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2887 | break; |
| 2888 | } |
| 2889 | if (LocaleCompare("spread",option+1) == 0) |
| 2890 | { |
| 2891 | if (*option == '+') |
| 2892 | break; |
| 2893 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2894 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2895 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2896 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2897 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2898 | break; |
| 2899 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 2900 | if (LocaleCompare("statistic",option+1) == 0) |
| 2901 | { |
| 2902 | ssize_t |
| 2903 | op; |
| 2904 | |
| 2905 | if (*option == '+') |
| 2906 | break; |
| 2907 | i++; |
| 2908 | if (i == (ssize_t) argc) |
| 2909 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 2910 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 2911 | if (op < 0) |
| 2912 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 2913 | argv[i]); |
| 2914 | i++; |
| 2915 | if (i == (ssize_t) (argc-1)) |
| 2916 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2917 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2918 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2919 | break; |
| 2920 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2921 | if (LocaleCompare("stretch",option+1) == 0) |
| 2922 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2923 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2924 | stretch; |
| 2925 | |
| 2926 | if (*option == '+') |
| 2927 | break; |
| 2928 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2929 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2930 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 2931 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2932 | if (stretch < 0) |
| 2933 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 2934 | argv[i]); |
| 2935 | break; |
| 2936 | } |
| 2937 | if (LocaleCompare("strip",option+1) == 0) |
| 2938 | break; |
| 2939 | if (LocaleCompare("stroke",option+1) == 0) |
| 2940 | { |
| 2941 | if (*option == '+') |
| 2942 | break; |
| 2943 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2944 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2945 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2946 | break; |
| 2947 | } |
| 2948 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2949 | { |
| 2950 | if (*option == '+') |
| 2951 | break; |
| 2952 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2953 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2954 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2955 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2956 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2957 | break; |
| 2958 | } |
| 2959 | if (LocaleCompare("style",option+1) == 0) |
| 2960 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2961 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2962 | style; |
| 2963 | |
| 2964 | if (*option == '+') |
| 2965 | break; |
| 2966 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2967 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2968 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 2969 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2970 | if (style < 0) |
| 2971 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 2972 | argv[i]); |
| 2973 | break; |
| 2974 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 2975 | if (LocaleCompare("swap",option+1) == 0) |
| 2976 | { |
| 2977 | if (*option == '+') |
| 2978 | break; |
| 2979 | i++; |
| 2980 | if (i == (ssize_t) (argc-1)) |
| 2981 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2982 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2983 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2984 | break; |
| 2985 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2986 | if (LocaleCompare("swirl",option+1) == 0) |
| 2987 | { |
| 2988 | if (*option == '+') |
| 2989 | break; |
| 2990 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2991 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2992 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 2993 | if (IsGeometry(argv[i]) == MagickFalse) |
| 2994 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 2995 | break; |
| 2996 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 2997 | if (LocaleCompare("synchronize",option+1) == 0) |
| 2998 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2999 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3000 | } |
| 3001 | case 't': |
| 3002 | { |
| 3003 | if (LocaleCompare("taint",option+1) == 0) |
| 3004 | break; |
| 3005 | if (LocaleCompare("texture",option+1) == 0) |
| 3006 | { |
| 3007 | if (*option == '+') |
| 3008 | break; |
| 3009 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3010 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3011 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3012 | break; |
| 3013 | } |
| 3014 | if (LocaleCompare("tile",option+1) == 0) |
| 3015 | { |
| 3016 | if (*option == '+') |
| 3017 | break; |
| 3018 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3019 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3020 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3021 | break; |
| 3022 | } |
| 3023 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 3024 | { |
| 3025 | if (*option == '+') |
| 3026 | break; |
| 3027 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3028 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3029 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3030 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3031 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3032 | break; |
| 3033 | } |
| 3034 | if (LocaleCompare("tint",option+1) == 0) |
| 3035 | { |
| 3036 | if (*option == '+') |
| 3037 | break; |
| 3038 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3039 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3040 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3041 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3042 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3043 | break; |
| 3044 | } |
| 3045 | if (LocaleCompare("transform",option+1) == 0) |
| 3046 | break; |
| 3047 | if (LocaleCompare("transpose",option+1) == 0) |
| 3048 | break; |
| 3049 | if (LocaleCompare("transverse",option+1) == 0) |
| 3050 | break; |
| 3051 | if (LocaleCompare("threshold",option+1) == 0) |
| 3052 | { |
| 3053 | if (*option == '+') |
| 3054 | break; |
| 3055 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3056 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3057 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3058 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3059 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3060 | break; |
| 3061 | } |
| 3062 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 3063 | { |
| 3064 | if (*option == '+') |
| 3065 | break; |
| 3066 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3067 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3068 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3069 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3070 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3071 | break; |
| 3072 | } |
| 3073 | if (LocaleCompare("transparent",option+1) == 0) |
| 3074 | { |
| 3075 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3076 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3077 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3078 | break; |
| 3079 | } |
| 3080 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 3081 | { |
| 3082 | if (*option == '+') |
| 3083 | break; |
| 3084 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3085 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3086 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3087 | break; |
| 3088 | } |
| 3089 | if (LocaleCompare("treedepth",option+1) == 0) |
| 3090 | { |
| 3091 | if (*option == '+') |
| 3092 | break; |
| 3093 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3094 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3095 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3096 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3097 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3098 | break; |
| 3099 | } |
| 3100 | if (LocaleCompare("trim",option+1) == 0) |
| 3101 | break; |
| 3102 | if (LocaleCompare("type",option+1) == 0) |
| 3103 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3104 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3105 | type; |
| 3106 | |
| 3107 | if (*option == '+') |
| 3108 | break; |
| 3109 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3110 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3111 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3112 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3113 | if (type < 0) |
| 3114 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 3115 | argv[i]); |
| 3116 | break; |
| 3117 | } |
| 3118 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3119 | } |
| 3120 | case 'u': |
| 3121 | { |
| 3122 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3123 | { |
| 3124 | if (*option == '+') |
| 3125 | break; |
| 3126 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3127 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3128 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3129 | break; |
| 3130 | } |
| 3131 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3132 | break; |
| 3133 | if (LocaleCompare("units",option+1) == 0) |
| 3134 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3135 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3136 | units; |
| 3137 | |
| 3138 | if (*option == '+') |
| 3139 | break; |
| 3140 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3141 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3142 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3143 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3144 | argv[i]); |
| 3145 | if (units < 0) |
| 3146 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 3147 | argv[i]); |
| 3148 | break; |
| 3149 | } |
| 3150 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3151 | { |
| 3152 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3153 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3154 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3155 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3156 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3157 | break; |
| 3158 | } |
| 3159 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3160 | } |
| 3161 | case 'v': |
| 3162 | { |
| 3163 | if (LocaleCompare("verbose",option+1) == 0) |
| 3164 | { |
| 3165 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 3166 | break; |
| 3167 | } |
| 3168 | if ((LocaleCompare("version",option+1) == 0) || |
| 3169 | (LocaleCompare("-version",option+1) == 0)) |
| 3170 | { |
| 3171 | (void) fprintf(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3172 | GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3173 | (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright()); |
| 3174 | (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3175 | break; |
| 3176 | } |
| 3177 | if (LocaleCompare("view",option+1) == 0) |
| 3178 | { |
| 3179 | if (*option == '+') |
| 3180 | break; |
| 3181 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3182 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3183 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3184 | break; |
| 3185 | } |
| 3186 | if (LocaleCompare("vignette",option+1) == 0) |
| 3187 | { |
| 3188 | if (*option == '+') |
| 3189 | break; |
| 3190 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3191 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3192 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3193 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3194 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3195 | break; |
| 3196 | } |
| 3197 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3198 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3199 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3200 | method; |
| 3201 | |
| 3202 | if (*option == '+') |
| 3203 | break; |
| 3204 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3205 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3206 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3207 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3208 | argv[i]); |
| 3209 | if (method < 0) |
| 3210 | ThrowMogrifyException(OptionError, |
| 3211 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 3212 | break; |
| 3213 | } |
| 3214 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3215 | } |
| 3216 | case 'w': |
| 3217 | { |
| 3218 | if (LocaleCompare("wave",option+1) == 0) |
| 3219 | { |
| 3220 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3221 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3222 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3223 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3224 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3225 | break; |
| 3226 | } |
| 3227 | if (LocaleCompare("weight",option+1) == 0) |
| 3228 | { |
| 3229 | if (*option == '+') |
| 3230 | break; |
| 3231 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3232 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3233 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3234 | break; |
| 3235 | } |
| 3236 | if (LocaleCompare("white-point",option+1) == 0) |
| 3237 | { |
| 3238 | if (*option == '+') |
| 3239 | break; |
| 3240 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3241 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3242 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3243 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3244 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3245 | break; |
| 3246 | } |
| 3247 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3248 | { |
| 3249 | if (*option == '+') |
| 3250 | break; |
| 3251 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3252 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3253 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3254 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3255 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3256 | break; |
| 3257 | } |
| 3258 | if (LocaleCompare("write",option+1) == 0) |
| 3259 | { |
| 3260 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3261 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3262 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3263 | break; |
| 3264 | } |
| 3265 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3266 | } |
| 3267 | case '?': |
| 3268 | break; |
| 3269 | default: |
| 3270 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3271 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3272 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 3273 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3274 | if (fire != MagickFalse) |
| 3275 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3276 | } |
| 3277 | if (k != 0) |
| 3278 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3279 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3280 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 3281 | DestroyMogrify(); |
| 3282 | return(status != 0 ? MagickTrue : MagickFalse); |
| 3283 | } |
| 3284 | |
| 3285 | /* |
| 3286 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3287 | % % |
| 3288 | % % |
| 3289 | % % |
| 3290 | + M o g r i f y I m a g e I n f o % |
| 3291 | % % |
| 3292 | % % |
| 3293 | % % |
| 3294 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3295 | % |
| 3296 | % MogrifyImageInfo() applies image processing settings to the image as |
| 3297 | % prescribed by command line options. |
| 3298 | % |
| 3299 | % The format of the MogrifyImageInfo method is: |
| 3300 | % |
| 3301 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 3302 | % const char **argv,ExceptionInfo *exception) |
| 3303 | % |
| 3304 | % A description of each parameter follows: |
| 3305 | % |
| 3306 | % o image_info: the image info.. |
| 3307 | % |
| 3308 | % o argc: Specifies a pointer to an integer describing the number of |
| 3309 | % elements in the argument vector. |
| 3310 | % |
| 3311 | % o argv: Specifies a pointer to a text array containing the command line |
| 3312 | % arguments. |
| 3313 | % |
| 3314 | % o exception: return any errors or warnings in this structure. |
| 3315 | % |
| 3316 | */ |
| 3317 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 3318 | const int argc,const char **argv,ExceptionInfo *exception) |
| 3319 | { |
| 3320 | const char |
| 3321 | *option; |
| 3322 | |
| 3323 | GeometryInfo |
| 3324 | geometry_info; |
| 3325 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3326 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3327 | count; |
| 3328 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3329 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3330 | i; |
| 3331 | |
| 3332 | /* |
| 3333 | Initialize method variables. |
| 3334 | */ |
| 3335 | assert(image_info != (ImageInfo *) NULL); |
| 3336 | assert(image_info->signature == MagickSignature); |
| 3337 | if (image_info->debug != MagickFalse) |
| 3338 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 3339 | image_info->filename); |
| 3340 | if (argc < 0) |
| 3341 | return(MagickTrue); |
| 3342 | /* |
| 3343 | Set the image settings. |
| 3344 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3345 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3346 | { |
| 3347 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3348 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3349 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3350 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 3351 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3352 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3353 | break; |
| 3354 | switch (*(option+1)) |
| 3355 | { |
| 3356 | case 'a': |
| 3357 | { |
| 3358 | if (LocaleCompare("adjoin",option+1) == 0) |
| 3359 | { |
| 3360 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 3361 | break; |
| 3362 | } |
| 3363 | if (LocaleCompare("antialias",option+1) == 0) |
| 3364 | { |
| 3365 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 3366 | break; |
| 3367 | } |
| 3368 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3369 | { |
| 3370 | if (*option == '+') |
| 3371 | { |
| 3372 | (void) DeleteImageOption(image_info,option+1); |
| 3373 | break; |
| 3374 | } |
| 3375 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3376 | break; |
| 3377 | } |
| 3378 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3379 | { |
| 3380 | if (*option == '+') |
| 3381 | (void) CloneString(&image_info->authenticate,(char *) NULL); |
| 3382 | else |
| 3383 | (void) CloneString(&image_info->authenticate,argv[i+1]); |
| 3384 | break; |
| 3385 | } |
| 3386 | break; |
| 3387 | } |
| 3388 | case 'b': |
| 3389 | { |
| 3390 | if (LocaleCompare("background",option+1) == 0) |
| 3391 | { |
| 3392 | if (*option == '+') |
| 3393 | { |
| 3394 | (void) DeleteImageOption(image_info,option+1); |
| 3395 | (void) QueryColorDatabase(BackgroundColor, |
| 3396 | &image_info->background_color,exception); |
| 3397 | break; |
| 3398 | } |
| 3399 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3400 | (void) QueryColorDatabase(argv[i+1],&image_info->background_color, |
| 3401 | exception); |
| 3402 | break; |
| 3403 | } |
| 3404 | if (LocaleCompare("bias",option+1) == 0) |
| 3405 | { |
| 3406 | if (*option == '+') |
| 3407 | { |
| 3408 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 3409 | break; |
| 3410 | } |
| 3411 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3412 | break; |
| 3413 | } |
| 3414 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 3415 | { |
| 3416 | if (*option == '+') |
| 3417 | { |
| 3418 | (void) SetImageOption(image_info,option+1,"false"); |
| 3419 | break; |
| 3420 | } |
| 3421 | (void) SetImageOption(image_info,option+1,"true"); |
| 3422 | break; |
| 3423 | } |
| 3424 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3425 | { |
| 3426 | if (*option == '+') |
| 3427 | { |
| 3428 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 3429 | break; |
| 3430 | } |
| 3431 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3432 | break; |
| 3433 | } |
| 3434 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3435 | { |
| 3436 | if (*option == '+') |
| 3437 | { |
| 3438 | (void) DeleteImageOption(image_info,option+1); |
| 3439 | (void) QueryColorDatabase(BorderColor,&image_info->border_color, |
| 3440 | exception); |
| 3441 | break; |
| 3442 | } |
| 3443 | (void) QueryColorDatabase(argv[i+1],&image_info->border_color, |
| 3444 | exception); |
| 3445 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3446 | break; |
| 3447 | } |
| 3448 | if (LocaleCompare("box",option+1) == 0) |
| 3449 | { |
| 3450 | if (*option == '+') |
| 3451 | { |
| 3452 | (void) SetImageOption(image_info,"undercolor","none"); |
| 3453 | break; |
| 3454 | } |
| 3455 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 3456 | break; |
| 3457 | } |
| 3458 | break; |
| 3459 | } |
| 3460 | case 'c': |
| 3461 | { |
| 3462 | if (LocaleCompare("cache",option+1) == 0) |
| 3463 | { |
| 3464 | MagickSizeType |
| 3465 | limit; |
| 3466 | |
| 3467 | limit=MagickResourceInfinity; |
| 3468 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 3469 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3470 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 3471 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 3472 | break; |
| 3473 | } |
| 3474 | if (LocaleCompare("caption",option+1) == 0) |
| 3475 | { |
| 3476 | if (*option == '+') |
| 3477 | { |
| 3478 | (void) DeleteImageOption(image_info,option+1); |
| 3479 | break; |
| 3480 | } |
| 3481 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3482 | break; |
| 3483 | } |
| 3484 | if (LocaleCompare("channel",option+1) == 0) |
| 3485 | { |
| 3486 | if (*option == '+') |
| 3487 | { |
| 3488 | image_info->channel=DefaultChannels; |
| 3489 | break; |
| 3490 | } |
| 3491 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 3492 | break; |
| 3493 | } |
| 3494 | if (LocaleCompare("colors",option+1) == 0) |
| 3495 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 3496 | image_info->colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3497 | break; |
| 3498 | } |
| 3499 | if (LocaleCompare("colorspace",option+1) == 0) |
| 3500 | { |
| 3501 | if (*option == '+') |
| 3502 | { |
| 3503 | image_info->colorspace=UndefinedColorspace; |
| 3504 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 3505 | break; |
| 3506 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3507 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3508 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 3509 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3510 | break; |
| 3511 | } |
| 3512 | if (LocaleCompare("compress",option+1) == 0) |
| 3513 | { |
| 3514 | if (*option == '+') |
| 3515 | { |
| 3516 | image_info->compression=UndefinedCompression; |
| 3517 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 3518 | break; |
| 3519 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3520 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3521 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 3522 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3523 | break; |
| 3524 | } |
| 3525 | if (LocaleCompare("comment",option+1) == 0) |
| 3526 | { |
| 3527 | if (*option == '+') |
| 3528 | { |
| 3529 | (void) DeleteImageOption(image_info,option+1); |
| 3530 | break; |
| 3531 | } |
| 3532 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3533 | break; |
| 3534 | } |
| 3535 | if (LocaleCompare("compose",option+1) == 0) |
| 3536 | { |
| 3537 | if (*option == '+') |
| 3538 | { |
| 3539 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 3540 | break; |
| 3541 | } |
| 3542 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3543 | break; |
| 3544 | } |
| 3545 | if (LocaleCompare("compress",option+1) == 0) |
| 3546 | { |
| 3547 | if (*option == '+') |
| 3548 | { |
| 3549 | image_info->compression=UndefinedCompression; |
| 3550 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 3551 | break; |
| 3552 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3553 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3554 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 3555 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3556 | break; |
| 3557 | } |
| 3558 | break; |
| 3559 | } |
| 3560 | case 'd': |
| 3561 | { |
| 3562 | if (LocaleCompare("debug",option+1) == 0) |
| 3563 | { |
| 3564 | if (*option == '+') |
| 3565 | (void) SetLogEventMask("none"); |
| 3566 | else |
| 3567 | (void) SetLogEventMask(argv[i+1]); |
| 3568 | image_info->debug=IsEventLogging(); |
| 3569 | break; |
| 3570 | } |
| 3571 | if (LocaleCompare("define",option+1) == 0) |
| 3572 | { |
| 3573 | if (*option == '+') |
| 3574 | { |
| 3575 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 3576 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 3577 | else |
| 3578 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 3579 | break; |
| 3580 | } |
| 3581 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 3582 | { |
| 3583 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 3584 | exception); |
| 3585 | break; |
| 3586 | } |
| 3587 | (void) DefineImageOption(image_info,argv[i+1]); |
| 3588 | break; |
| 3589 | } |
| 3590 | if (LocaleCompare("delay",option+1) == 0) |
| 3591 | { |
| 3592 | if (*option == '+') |
| 3593 | { |
| 3594 | (void) SetImageOption(image_info,option+1,"0"); |
| 3595 | break; |
| 3596 | } |
| 3597 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3598 | break; |
| 3599 | } |
| 3600 | if (LocaleCompare("density",option+1) == 0) |
| 3601 | { |
| 3602 | /* |
| 3603 | Set image density. |
| 3604 | */ |
| 3605 | if (*option == '+') |
| 3606 | { |
| 3607 | if (image_info->density != (char *) NULL) |
| 3608 | image_info->density=DestroyString(image_info->density); |
| 3609 | (void) SetImageOption(image_info,option+1,"72"); |
| 3610 | break; |
| 3611 | } |
| 3612 | (void) CloneString(&image_info->density,argv[i+1]); |
| 3613 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3614 | break; |
| 3615 | } |
| 3616 | if (LocaleCompare("depth",option+1) == 0) |
| 3617 | { |
| 3618 | if (*option == '+') |
| 3619 | { |
| 3620 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 3621 | break; |
| 3622 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 3623 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3624 | break; |
| 3625 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3626 | if (LocaleCompare("direction",option+1) == 0) |
| 3627 | { |
| 3628 | if (*option == '+') |
| 3629 | { |
| 3630 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 3631 | break; |
| 3632 | } |
| 3633 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3634 | break; |
| 3635 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3636 | if (LocaleCompare("display",option+1) == 0) |
| 3637 | { |
| 3638 | if (*option == '+') |
| 3639 | { |
| 3640 | if (image_info->server_name != (char *) NULL) |
| 3641 | image_info->server_name=DestroyString( |
| 3642 | image_info->server_name); |
| 3643 | break; |
| 3644 | } |
| 3645 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 3646 | break; |
| 3647 | } |
| 3648 | if (LocaleCompare("dispose",option+1) == 0) |
| 3649 | { |
| 3650 | if (*option == '+') |
| 3651 | { |
| 3652 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 3653 | break; |
| 3654 | } |
| 3655 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3656 | break; |
| 3657 | } |
| 3658 | if (LocaleCompare("dither",option+1) == 0) |
| 3659 | { |
| 3660 | if (*option == '+') |
| 3661 | { |
| 3662 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 3663 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3664 | break; |
| 3665 | } |
| 3666 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3667 | image_info->dither=MagickTrue; |
| 3668 | break; |
| 3669 | } |
| 3670 | break; |
| 3671 | } |
| 3672 | case 'e': |
| 3673 | { |
| 3674 | if (LocaleCompare("encoding",option+1) == 0) |
| 3675 | { |
| 3676 | if (*option == '+') |
| 3677 | { |
| 3678 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 3679 | break; |
| 3680 | } |
| 3681 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3682 | break; |
| 3683 | } |
| 3684 | if (LocaleCompare("endian",option+1) == 0) |
| 3685 | { |
| 3686 | if (*option == '+') |
| 3687 | { |
| 3688 | image_info->endian=UndefinedEndian; |
| 3689 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 3690 | break; |
| 3691 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3692 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3693 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 3694 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3695 | break; |
| 3696 | } |
| 3697 | if (LocaleCompare("extract",option+1) == 0) |
| 3698 | { |
| 3699 | /* |
| 3700 | Set image extract geometry. |
| 3701 | */ |
| 3702 | if (*option == '+') |
| 3703 | { |
| 3704 | if (image_info->extract != (char *) NULL) |
| 3705 | image_info->extract=DestroyString(image_info->extract); |
| 3706 | break; |
| 3707 | } |
| 3708 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 3709 | break; |
| 3710 | } |
| 3711 | break; |
| 3712 | } |
| 3713 | case 'f': |
| 3714 | { |
| 3715 | if (LocaleCompare("fill",option+1) == 0) |
| 3716 | { |
| 3717 | if (*option == '+') |
| 3718 | { |
| 3719 | (void) SetImageOption(image_info,option+1,"none"); |
| 3720 | break; |
| 3721 | } |
| 3722 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3723 | break; |
| 3724 | } |
| 3725 | if (LocaleCompare("filter",option+1) == 0) |
| 3726 | { |
| 3727 | if (*option == '+') |
| 3728 | { |
| 3729 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 3730 | break; |
| 3731 | } |
| 3732 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3733 | break; |
| 3734 | } |
| 3735 | if (LocaleCompare("font",option+1) == 0) |
| 3736 | { |
| 3737 | if (*option == '+') |
| 3738 | { |
| 3739 | if (image_info->font != (char *) NULL) |
| 3740 | image_info->font=DestroyString(image_info->font); |
| 3741 | break; |
| 3742 | } |
| 3743 | (void) CloneString(&image_info->font,argv[i+1]); |
| 3744 | break; |
| 3745 | } |
| 3746 | if (LocaleCompare("format",option+1) == 0) |
| 3747 | { |
| 3748 | register const char |
| 3749 | *q; |
| 3750 | |
| 3751 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 3752 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3753 | image_info->ping=MagickFalse; |
| 3754 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3755 | break; |
| 3756 | } |
| 3757 | if (LocaleCompare("fuzz",option+1) == 0) |
| 3758 | { |
| 3759 | if (*option == '+') |
| 3760 | { |
| 3761 | image_info->fuzz=0.0; |
| 3762 | (void) SetImageOption(image_info,option+1,"0"); |
| 3763 | break; |
| 3764 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 3765 | image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3766 | 1.0); |
| 3767 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3768 | break; |
| 3769 | } |
| 3770 | break; |
| 3771 | } |
| 3772 | case 'g': |
| 3773 | { |
| 3774 | if (LocaleCompare("gravity",option+1) == 0) |
| 3775 | { |
| 3776 | if (*option == '+') |
| 3777 | { |
| 3778 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 3779 | break; |
| 3780 | } |
| 3781 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3782 | break; |
| 3783 | } |
| 3784 | if (LocaleCompare("green-primary",option+1) == 0) |
| 3785 | { |
| 3786 | if (*option == '+') |
| 3787 | { |
| 3788 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 3789 | break; |
| 3790 | } |
| 3791 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3792 | break; |
| 3793 | } |
| 3794 | break; |
| 3795 | } |
| 3796 | case 'i': |
| 3797 | { |
| 3798 | if (LocaleCompare("intent",option+1) == 0) |
| 3799 | { |
| 3800 | if (*option == '+') |
| 3801 | { |
| 3802 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 3803 | break; |
| 3804 | } |
| 3805 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3806 | break; |
| 3807 | } |
| 3808 | if (LocaleCompare("interlace",option+1) == 0) |
| 3809 | { |
| 3810 | if (*option == '+') |
| 3811 | { |
| 3812 | image_info->interlace=UndefinedInterlace; |
| 3813 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 3814 | break; |
| 3815 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3816 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3817 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 3818 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3819 | break; |
| 3820 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3821 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 3822 | { |
| 3823 | if (*option == '+') |
| 3824 | { |
| 3825 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 3826 | break; |
| 3827 | } |
| 3828 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3829 | break; |
| 3830 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3831 | if (LocaleCompare("interpolate",option+1) == 0) |
| 3832 | { |
| 3833 | if (*option == '+') |
| 3834 | { |
| 3835 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 3836 | break; |
| 3837 | } |
| 3838 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3839 | break; |
| 3840 | } |
| 3841 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 3842 | { |
| 3843 | if (*option == '+') |
| 3844 | { |
| 3845 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 3846 | break; |
| 3847 | } |
| 3848 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3849 | break; |
| 3850 | } |
| 3851 | break; |
| 3852 | } |
| 3853 | case 'k': |
| 3854 | { |
| 3855 | if (LocaleCompare("kerning",option+1) == 0) |
| 3856 | { |
| 3857 | if (*option == '+') |
| 3858 | { |
| 3859 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 3860 | break; |
| 3861 | } |
| 3862 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3863 | break; |
| 3864 | } |
| 3865 | break; |
| 3866 | } |
| 3867 | case 'l': |
| 3868 | { |
| 3869 | if (LocaleCompare("label",option+1) == 0) |
| 3870 | { |
| 3871 | if (*option == '+') |
| 3872 | { |
| 3873 | (void) DeleteImageOption(image_info,option+1); |
| 3874 | break; |
| 3875 | } |
| 3876 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 3877 | break; |
| 3878 | } |
| 3879 | if (LocaleCompare("limit",option+1) == 0) |
| 3880 | { |
| 3881 | MagickSizeType |
| 3882 | limit; |
| 3883 | |
| 3884 | ResourceType |
| 3885 | type; |
| 3886 | |
| 3887 | if (*option == '+') |
| 3888 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3889 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3890 | MagickFalse,argv[i+1]); |
| 3891 | limit=MagickResourceInfinity; |
| 3892 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 3893 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3894 | (void) SetMagickResourceLimit(type,limit); |
| 3895 | break; |
| 3896 | } |
| 3897 | if (LocaleCompare("list",option+1) == 0) |
| 3898 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3899 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3900 | list; |
| 3901 | |
| 3902 | /* |
| 3903 | Display configuration list. |
| 3904 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3905 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3906 | switch (list) |
| 3907 | { |
| 3908 | case MagickCoderOptions: |
| 3909 | { |
| 3910 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 3911 | break; |
| 3912 | } |
| 3913 | case MagickColorOptions: |
| 3914 | { |
| 3915 | (void) ListColorInfo((FILE *) NULL,exception); |
| 3916 | break; |
| 3917 | } |
| 3918 | case MagickConfigureOptions: |
| 3919 | { |
| 3920 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 3921 | break; |
| 3922 | } |
| 3923 | case MagickDelegateOptions: |
| 3924 | { |
| 3925 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 3926 | break; |
| 3927 | } |
| 3928 | case MagickFontOptions: |
| 3929 | { |
| 3930 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 3931 | break; |
| 3932 | } |
| 3933 | case MagickFormatOptions: |
| 3934 | { |
| 3935 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 3936 | break; |
| 3937 | } |
| 3938 | case MagickLocaleOptions: |
| 3939 | { |
| 3940 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 3941 | break; |
| 3942 | } |
| 3943 | case MagickLogOptions: |
| 3944 | { |
| 3945 | (void) ListLogInfo((FILE *) NULL,exception); |
| 3946 | break; |
| 3947 | } |
| 3948 | case MagickMagicOptions: |
| 3949 | { |
| 3950 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 3951 | break; |
| 3952 | } |
| 3953 | case MagickMimeOptions: |
| 3954 | { |
| 3955 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 3956 | break; |
| 3957 | } |
| 3958 | case MagickModuleOptions: |
| 3959 | { |
| 3960 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 3961 | break; |
| 3962 | } |
| 3963 | case MagickPolicyOptions: |
| 3964 | { |
| 3965 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 3966 | break; |
| 3967 | } |
| 3968 | case MagickResourceOptions: |
| 3969 | { |
| 3970 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 3971 | break; |
| 3972 | } |
| 3973 | case MagickThresholdOptions: |
| 3974 | { |
| 3975 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 3976 | break; |
| 3977 | } |
| 3978 | default: |
| 3979 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3980 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3981 | exception); |
| 3982 | break; |
| 3983 | } |
| 3984 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 3985 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3986 | } |
| 3987 | if (LocaleCompare("log",option+1) == 0) |
| 3988 | { |
| 3989 | if (*option == '+') |
| 3990 | break; |
| 3991 | (void) SetLogFormat(argv[i+1]); |
| 3992 | break; |
| 3993 | } |
| 3994 | if (LocaleCompare("loop",option+1) == 0) |
| 3995 | { |
| 3996 | if (*option == '+') |
| 3997 | { |
| 3998 | (void) SetImageOption(image_info,option+1,"0"); |
| 3999 | break; |
| 4000 | } |
| 4001 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 4002 | break; |
| 4003 | } |
| 4004 | break; |
| 4005 | } |
| 4006 | case 'm': |
| 4007 | { |
| 4008 | if (LocaleCompare("matte",option+1) == 0) |
| 4009 | { |
| 4010 | if (*option == '+') |
| 4011 | { |
| 4012 | (void) SetImageOption(image_info,option+1,"false"); |
| 4013 | break; |
| 4014 | } |
| 4015 | (void) SetImageOption(image_info,option+1,"true"); |
| 4016 | break; |
| 4017 | } |
| 4018 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 4019 | { |
| 4020 | if (*option == '+') |
| 4021 | { |
| 4022 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 4023 | (void) QueryColorDatabase(MatteColor,&image_info->matte_color, |
| 4024 | exception); |
| 4025 | break; |
| 4026 | } |
| 4027 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 4028 | (void) QueryColorDatabase(argv[i+1],&image_info->matte_color, |
| 4029 | exception); |
| 4030 | break; |
| 4031 | } |
| 4032 | if (LocaleCompare("monitor",option+1) == 0) |
| 4033 | { |
| 4034 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 4035 | (void *) NULL); |
| 4036 | break; |
| 4037 | } |
| 4038 | if (LocaleCompare("monochrome",option+1) == 0) |
| 4039 | { |
| 4040 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 4041 | break; |
| 4042 | } |
| 4043 | break; |
| 4044 | } |
| 4045 | case 'o': |
| 4046 | { |
| 4047 | if (LocaleCompare("orient",option+1) == 0) |
| 4048 | { |
| 4049 | if (*option == '+') |
| 4050 | { |
| 4051 | image_info->orientation=UndefinedOrientation; |
| 4052 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 4053 | break; |
| 4054 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4055 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4056 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 4057 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4058 | break; |
| 4059 | } |
| 4060 | } |
| 4061 | case 'p': |
| 4062 | { |
| 4063 | if (LocaleCompare("page",option+1) == 0) |
| 4064 | { |
| 4065 | char |
| 4066 | *canonical_page, |
| 4067 | page[MaxTextExtent]; |
| 4068 | |
| 4069 | const char |
| 4070 | *image_option; |
| 4071 | |
| 4072 | MagickStatusType |
| 4073 | flags; |
| 4074 | |
| 4075 | RectangleInfo |
| 4076 | geometry; |
| 4077 | |
| 4078 | if (*option == '+') |
| 4079 | { |
| 4080 | (void) DeleteImageOption(image_info,option+1); |
| 4081 | (void) CloneString(&image_info->page,(char *) NULL); |
| 4082 | break; |
| 4083 | } |
| 4084 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 4085 | image_option=GetImageOption(image_info,"page"); |
| 4086 | if (image_option != (const char *) NULL) |
| 4087 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 4088 | canonical_page=GetPageGeometry(argv[i+1]); |
| 4089 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 4090 | canonical_page=DestroyString(canonical_page); |
| 4091 | (void) FormatMagickString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 4092 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4093 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 4094 | (void) FormatMagickString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 4095 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 4096 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4097 | (void) SetImageOption(image_info,option+1,page); |
| 4098 | (void) CloneString(&image_info->page,page); |
| 4099 | break; |
| 4100 | } |
| 4101 | if (LocaleCompare("pen",option+1) == 0) |
| 4102 | { |
| 4103 | if (*option == '+') |
| 4104 | { |
| 4105 | (void) SetImageOption(image_info,option+1,"none"); |
| 4106 | break; |
| 4107 | } |
| 4108 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 4109 | break; |
| 4110 | } |
| 4111 | if (LocaleCompare("ping",option+1) == 0) |
| 4112 | { |
| 4113 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 4114 | break; |
| 4115 | } |
| 4116 | if (LocaleCompare("pointsize",option+1) == 0) |
| 4117 | { |
| 4118 | if (*option == '+') |
| 4119 | geometry_info.rho=0.0; |
| 4120 | else |
| 4121 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 4122 | image_info->pointsize=geometry_info.rho; |
| 4123 | break; |
| 4124 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 4125 | if (LocaleCompare("precision",option+1) == 0) |
| 4126 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 4127 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 4128 | break; |
| 4129 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4130 | if (LocaleCompare("preview",option+1) == 0) |
| 4131 | { |
| 4132 | /* |
| 4133 | Preview image. |
| 4134 | */ |
| 4135 | if (*option == '+') |
| 4136 | { |
| 4137 | image_info->preview_type=UndefinedPreview; |
| 4138 | break; |
| 4139 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4140 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4141 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 4142 | break; |
| 4143 | } |
| 4144 | break; |
| 4145 | } |
| 4146 | case 'q': |
| 4147 | { |
| 4148 | if (LocaleCompare("quality",option+1) == 0) |
| 4149 | { |
| 4150 | /* |
| 4151 | Set image compression quality. |
| 4152 | */ |
| 4153 | if (*option == '+') |
| 4154 | { |
| 4155 | image_info->quality=UndefinedCompressionQuality; |
| 4156 | (void) SetImageOption(image_info,option+1,"0"); |
| 4157 | break; |
| 4158 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 4159 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4160 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 4161 | break; |
| 4162 | } |
| 4163 | if (LocaleCompare("quiet",option+1) == 0) |
| 4164 | { |
| 4165 | static WarningHandler |
| 4166 | warning_handler = (WarningHandler) NULL; |
| 4167 | |
| 4168 | if (*option == '+') |
| 4169 | { |
| 4170 | /* |
| 4171 | Restore error or warning messages. |
| 4172 | */ |
| 4173 | warning_handler=SetWarningHandler(warning_handler); |
| 4174 | break; |
| 4175 | } |
| 4176 | /* |
| 4177 | Suppress error or warning messages. |
| 4178 | */ |
| 4179 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 4180 | break; |
| 4181 | } |
| 4182 | break; |
| 4183 | } |
| 4184 | case 'r': |
| 4185 | { |
| 4186 | if (LocaleCompare("red-primary",option+1) == 0) |
| 4187 | { |
| 4188 | if (*option == '+') |
| 4189 | { |
| 4190 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 4191 | break; |
| 4192 | } |
| 4193 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 4194 | break; |
| 4195 | } |
| 4196 | break; |
| 4197 | } |
| 4198 | case 's': |
| 4199 | { |
| 4200 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 4201 | { |
| 4202 | /* |
| 4203 | Set image sampling factor. |
| 4204 | */ |
| 4205 | if (*option == '+') |
| 4206 | { |
| 4207 | if (image_info->sampling_factor != (char *) NULL) |
| 4208 | image_info->sampling_factor=DestroyString( |
| 4209 | image_info->sampling_factor); |
| 4210 | break; |
| 4211 | } |
| 4212 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 4213 | break; |
| 4214 | } |
| 4215 | if (LocaleCompare("scene",option+1) == 0) |
| 4216 | { |
| 4217 | /* |
| 4218 | Set image scene. |
| 4219 | */ |
| 4220 | if (*option == '+') |
| 4221 | { |
| 4222 | image_info->scene=0; |
| 4223 | (void) SetImageOption(image_info,option+1,"0"); |
| 4224 | break; |
| 4225 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 4226 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4227 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 4228 | break; |
| 4229 | } |
| 4230 | if (LocaleCompare("seed",option+1) == 0) |
| 4231 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4232 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4233 | seed; |
| 4234 | |
| 4235 | if (*option == '+') |
| 4236 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4237 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4238 | SeedPseudoRandomGenerator(seed); |
| 4239 | break; |
| 4240 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 4241 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4242 | SeedPseudoRandomGenerator(seed); |
| 4243 | break; |
| 4244 | } |
| 4245 | if (LocaleCompare("size",option+1) == 0) |
| 4246 | { |
| 4247 | if (*option == '+') |
| 4248 | { |
| 4249 | if (image_info->size != (char *) NULL) |
| 4250 | image_info->size=DestroyString(image_info->size); |
| 4251 | break; |
| 4252 | } |
| 4253 | (void) CloneString(&image_info->size,argv[i+1]); |
| 4254 | break; |
| 4255 | } |
| 4256 | if (LocaleCompare("stroke",option+1) == 0) |
| 4257 | { |
| 4258 | if (*option == '+') |
| 4259 | { |
| 4260 | (void) SetImageOption(image_info,option+1,"none"); |
| 4261 | break; |
| 4262 | } |
| 4263 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 4264 | break; |
| 4265 | } |
| 4266 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 4267 | { |
| 4268 | if (*option == '+') |
| 4269 | { |
| 4270 | (void) SetImageOption(image_info,option+1,"0"); |
| 4271 | break; |
| 4272 | } |
| 4273 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 4274 | break; |
| 4275 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 4276 | if (LocaleCompare("synchronize",option+1) == 0) |
| 4277 | { |
| 4278 | if (*option == '+') |
| 4279 | { |
| 4280 | image_info->synchronize=MagickFalse; |
| 4281 | break; |
| 4282 | } |
| 4283 | image_info->synchronize=MagickTrue; |
| 4284 | break; |
| 4285 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4286 | break; |
| 4287 | } |
| 4288 | case 't': |
| 4289 | { |
| 4290 | if (LocaleCompare("taint",option+1) == 0) |
| 4291 | { |
| 4292 | if (*option == '+') |
| 4293 | { |
| 4294 | (void) SetImageOption(image_info,option+1,"false"); |
| 4295 | break; |
| 4296 | } |
| 4297 | (void) SetImageOption(image_info,option+1,"true"); |
| 4298 | break; |
| 4299 | } |
| 4300 | if (LocaleCompare("texture",option+1) == 0) |
| 4301 | { |
| 4302 | if (*option == '+') |
| 4303 | { |
| 4304 | if (image_info->texture != (char *) NULL) |
| 4305 | image_info->texture=DestroyString(image_info->texture); |
| 4306 | break; |
| 4307 | } |
| 4308 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 4309 | break; |
| 4310 | } |
| 4311 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 4312 | { |
| 4313 | if (*option == '+') |
| 4314 | { |
| 4315 | (void) SetImageOption(image_info,option+1,"0"); |
| 4316 | break; |
| 4317 | } |
| 4318 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 4319 | break; |
| 4320 | } |
| 4321 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 4322 | { |
| 4323 | if (*option == '+') |
| 4324 | { |
| 4325 | (void) QueryColorDatabase("none",&image_info->transparent_color, exception); |
| 4326 | (void) SetImageOption(image_info,option+1,"none"); |
| 4327 | break; |
| 4328 | } |
| 4329 | (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color, |
| 4330 | exception); |
| 4331 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 4332 | break; |
| 4333 | } |
| 4334 | if (LocaleCompare("type",option+1) == 0) |
| 4335 | { |
| 4336 | if (*option == '+') |
| 4337 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 4338 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4339 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 4340 | break; |
| 4341 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4342 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4343 | MagickFalse,argv[i+1]); |
| 4344 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 4345 | break; |
| 4346 | } |
| 4347 | break; |
| 4348 | } |
| 4349 | case 'u': |
| 4350 | { |
| 4351 | if (LocaleCompare("undercolor",option+1) == 0) |
| 4352 | { |
| 4353 | if (*option == '+') |
| 4354 | { |
| 4355 | (void) DeleteImageOption(image_info,option+1); |
| 4356 | break; |
| 4357 | } |
| 4358 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 4359 | break; |
| 4360 | } |
| 4361 | if (LocaleCompare("units",option+1) == 0) |
| 4362 | { |
| 4363 | if (*option == '+') |
| 4364 | { |
| 4365 | image_info->units=UndefinedResolution; |
| 4366 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 4367 | break; |
| 4368 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4369 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4370 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 4371 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 4372 | break; |
| 4373 | } |
| 4374 | break; |
| 4375 | } |
| 4376 | case 'v': |
| 4377 | { |
| 4378 | if (LocaleCompare("verbose",option+1) == 0) |
| 4379 | { |
| 4380 | if (*option == '+') |
| 4381 | { |
| 4382 | image_info->verbose=MagickFalse; |
| 4383 | break; |
| 4384 | } |
| 4385 | image_info->verbose=MagickTrue; |
| 4386 | image_info->ping=MagickFalse; |
| 4387 | break; |
| 4388 | } |
| 4389 | if (LocaleCompare("view",option+1) == 0) |
| 4390 | { |
| 4391 | if (*option == '+') |
| 4392 | { |
| 4393 | if (image_info->view != (char *) NULL) |
| 4394 | image_info->view=DestroyString(image_info->view); |
| 4395 | break; |
| 4396 | } |
| 4397 | (void) CloneString(&image_info->view,argv[i+1]); |
| 4398 | break; |
| 4399 | } |
| 4400 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 4401 | { |
| 4402 | if (*option == '+') |
| 4403 | { |
| 4404 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 4405 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 4406 | break; |
| 4407 | } |
| 4408 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4409 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4410 | argv[i+1]); |
| 4411 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 4412 | break; |
| 4413 | } |
| 4414 | break; |
| 4415 | } |
| 4416 | case 'w': |
| 4417 | { |
| 4418 | if (LocaleCompare("white-point",option+1) == 0) |
| 4419 | { |
| 4420 | if (*option == '+') |
| 4421 | { |
| 4422 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 4423 | break; |
| 4424 | } |
| 4425 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 4426 | break; |
| 4427 | } |
| 4428 | break; |
| 4429 | } |
| 4430 | default: |
| 4431 | break; |
| 4432 | } |
| 4433 | i+=count; |
| 4434 | } |
| 4435 | return(MagickTrue); |
| 4436 | } |
| 4437 | |
| 4438 | /* |
| 4439 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4440 | % % |
| 4441 | % % |
| 4442 | % % |
| 4443 | + M o g r i f y I m a g e L i s t % |
| 4444 | % % |
| 4445 | % % |
| 4446 | % % |
| 4447 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4448 | % |
| 4449 | % MogrifyImageList() applies any command line options that might affect the |
| 4450 | % entire image list (e.g. -append, -coalesce, etc.). |
| 4451 | % |
| 4452 | % The format of the MogrifyImage method is: |
| 4453 | % |
| 4454 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 4455 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 4456 | % |
| 4457 | % A description of each parameter follows: |
| 4458 | % |
| 4459 | % o image_info: the image info.. |
| 4460 | % |
| 4461 | % o argc: Specifies a pointer to an integer describing the number of |
| 4462 | % elements in the argument vector. |
| 4463 | % |
| 4464 | % o argv: Specifies a pointer to a text array containing the command line |
| 4465 | % arguments. |
| 4466 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 4467 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4468 | % |
| 4469 | % o exception: return any errors or warnings in this structure. |
| 4470 | % |
| 4471 | */ |
| 4472 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 4473 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 4474 | { |
| 4475 | ChannelType |
| 4476 | channel; |
| 4477 | |
| 4478 | const char |
| 4479 | *option; |
| 4480 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4481 | ImageInfo |
| 4482 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4483 | |
| 4484 | MagickStatusType |
| 4485 | status; |
| 4486 | |
| 4487 | QuantizeInfo |
| 4488 | *quantize_info; |
| 4489 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4490 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4491 | i; |
| 4492 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4493 | ssize_t |
| 4494 | count, |
| 4495 | index; |
| 4496 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4497 | /* |
| 4498 | Apply options to the image list. |
| 4499 | */ |
| 4500 | assert(image_info != (ImageInfo *) NULL); |
| 4501 | assert(image_info->signature == MagickSignature); |
| 4502 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 4503 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4504 | assert((*images)->signature == MagickSignature); |
| 4505 | if ((*images)->debug != MagickFalse) |
| 4506 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 4507 | (*images)->filename); |
| 4508 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 4509 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4510 | mogrify_info=CloneImageInfo(image_info); |
| 4511 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 4512 | channel=mogrify_info->channel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4513 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4514 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4515 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 4516 | if (*images == (Image *) NULL) |
| 4517 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4518 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4519 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4520 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4521 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 4522 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 4523 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4524 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4525 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4526 | switch (*(option+1)) |
| 4527 | { |
| 4528 | case 'a': |
| 4529 | { |
| 4530 | if (LocaleCompare("affinity",option+1) == 0) |
| 4531 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4532 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4533 | if (*option == '+') |
| 4534 | { |
| 4535 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 4536 | InheritException(exception,&(*images)->exception); |
| 4537 | break; |
| 4538 | } |
| 4539 | i++; |
| 4540 | break; |
| 4541 | } |
| 4542 | if (LocaleCompare("append",option+1) == 0) |
| 4543 | { |
| 4544 | Image |
| 4545 | *append_image; |
| 4546 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4547 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4548 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 4549 | MagickFalse,exception); |
| 4550 | if (append_image == (Image *) NULL) |
| 4551 | { |
| 4552 | status=MagickFalse; |
| 4553 | break; |
| 4554 | } |
| 4555 | *images=DestroyImageList(*images); |
| 4556 | *images=append_image; |
| 4557 | break; |
| 4558 | } |
| 4559 | if (LocaleCompare("average",option+1) == 0) |
| 4560 | { |
| 4561 | Image |
| 4562 | *average_image; |
| 4563 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4564 | /* |
| 4565 | Average an image sequence (deprecated). |
| 4566 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4567 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4568 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 4569 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4570 | if (average_image == (Image *) NULL) |
| 4571 | { |
| 4572 | status=MagickFalse; |
| 4573 | break; |
| 4574 | } |
| 4575 | *images=DestroyImageList(*images); |
| 4576 | *images=average_image; |
| 4577 | break; |
| 4578 | } |
| 4579 | break; |
| 4580 | } |
| 4581 | case 'c': |
| 4582 | { |
| 4583 | if (LocaleCompare("channel",option+1) == 0) |
| 4584 | { |
| 4585 | if (*option == '+') |
| 4586 | { |
| 4587 | channel=DefaultChannels; |
| 4588 | break; |
| 4589 | } |
| 4590 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 4591 | break; |
| 4592 | } |
| 4593 | if (LocaleCompare("clut",option+1) == 0) |
| 4594 | { |
| 4595 | Image |
| 4596 | *clut_image, |
| 4597 | *image; |
| 4598 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4599 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4600 | image=RemoveFirstImageFromList(images); |
| 4601 | clut_image=RemoveFirstImageFromList(images); |
| 4602 | if (clut_image == (Image *) NULL) |
| 4603 | { |
| 4604 | status=MagickFalse; |
| 4605 | break; |
| 4606 | } |
| 4607 | (void) ClutImageChannel(image,channel,clut_image); |
| 4608 | clut_image=DestroyImage(clut_image); |
| 4609 | InheritException(exception,&image->exception); |
| 4610 | *images=DestroyImageList(*images); |
| 4611 | *images=image; |
| 4612 | break; |
| 4613 | } |
| 4614 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4615 | { |
| 4616 | Image |
| 4617 | *coalesce_image; |
| 4618 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4619 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4620 | coalesce_image=CoalesceImages(*images,exception); |
| 4621 | if (coalesce_image == (Image *) NULL) |
| 4622 | { |
| 4623 | status=MagickFalse; |
| 4624 | break; |
| 4625 | } |
| 4626 | *images=DestroyImageList(*images); |
| 4627 | *images=coalesce_image; |
| 4628 | break; |
| 4629 | } |
| 4630 | if (LocaleCompare("combine",option+1) == 0) |
| 4631 | { |
| 4632 | Image |
| 4633 | *combine_image; |
| 4634 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4635 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4636 | combine_image=CombineImages(*images,channel,exception); |
| 4637 | if (combine_image == (Image *) NULL) |
| 4638 | { |
| 4639 | status=MagickFalse; |
| 4640 | break; |
| 4641 | } |
| 4642 | *images=DestroyImageList(*images); |
| 4643 | *images=combine_image; |
| 4644 | break; |
| 4645 | } |
| 4646 | if (LocaleCompare("composite",option+1) == 0) |
| 4647 | { |
| 4648 | Image |
| 4649 | *mask_image, |
| 4650 | *composite_image, |
| 4651 | *image; |
| 4652 | |
| 4653 | RectangleInfo |
| 4654 | geometry; |
| 4655 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4656 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4657 | image=RemoveFirstImageFromList(images); |
| 4658 | composite_image=RemoveFirstImageFromList(images); |
| 4659 | if (composite_image == (Image *) NULL) |
| 4660 | { |
| 4661 | status=MagickFalse; |
| 4662 | break; |
| 4663 | } |
| 4664 | (void) TransformImage(&composite_image,(char *) NULL, |
| 4665 | composite_image->geometry); |
| 4666 | SetGeometry(composite_image,&geometry); |
| 4667 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 4668 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 4669 | &geometry); |
| 4670 | mask_image=RemoveFirstImageFromList(images); |
| 4671 | if (mask_image != (Image *) NULL) |
| 4672 | { |
| 4673 | if ((image->compose == DisplaceCompositeOp) || |
| 4674 | (image->compose == DistortCompositeOp)) |
| 4675 | { |
| 4676 | /* |
| 4677 | Merge Y displacement into X displacement image. |
| 4678 | */ |
| 4679 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
| 4680 | mask_image,0,0); |
| 4681 | mask_image=DestroyImage(mask_image); |
| 4682 | } |
| 4683 | else |
| 4684 | { |
| 4685 | /* |
| 4686 | Set a blending mask for the composition. |
| 4687 | */ |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 4688 | /* POSIBLE ERROR; what if image->mask already set */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4689 | image->mask=mask_image; |
| 4690 | (void) NegateImage(image->mask,MagickFalse); |
| 4691 | } |
| 4692 | } |
| 4693 | (void) CompositeImageChannel(image,channel,image->compose, |
| 4694 | composite_image,geometry.x,geometry.y); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 4695 | if (mask_image != (Image *) NULL) |
| 4696 | mask_image=image->mask=DestroyImage(image->mask); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4697 | composite_image=DestroyImage(composite_image); |
| 4698 | InheritException(exception,&image->exception); |
| 4699 | *images=DestroyImageList(*images); |
| 4700 | *images=image; |
| 4701 | break; |
| 4702 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 4703 | #if 0 |
| 4704 | This has been merged completely into MogrifyImage() |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4705 | if (LocaleCompare("crop",option+1) == 0) |
| 4706 | { |
| 4707 | MagickStatusType |
| 4708 | flags; |
| 4709 | |
| 4710 | RectangleInfo |
| 4711 | geometry; |
| 4712 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 4713 | /* |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 4714 | Crop Image. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 4715 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4716 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4717 | flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception); |
| 4718 | if (((geometry.width == 0) && (geometry.height == 0)) || |
| 4719 | ((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 4720 | break; |
| 4721 | (void) TransformImages(images,argv[i+1],(char *) NULL); |
| 4722 | InheritException(exception,&(*images)->exception); |
| 4723 | break; |
| 4724 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 4725 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4726 | break; |
| 4727 | } |
| 4728 | case 'd': |
| 4729 | { |
| 4730 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4731 | { |
| 4732 | Image |
| 4733 | *deconstruct_image; |
| 4734 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4735 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4736 | deconstruct_image=DeconstructImages(*images,exception); |
| 4737 | if (deconstruct_image == (Image *) NULL) |
| 4738 | { |
| 4739 | status=MagickFalse; |
| 4740 | break; |
| 4741 | } |
| 4742 | *images=DestroyImageList(*images); |
| 4743 | *images=deconstruct_image; |
| 4744 | break; |
| 4745 | } |
| 4746 | if (LocaleCompare("delete",option+1) == 0) |
| 4747 | { |
| 4748 | if (*option == '+') |
| 4749 | DeleteImages(images,"-1",exception); |
| 4750 | else |
| 4751 | DeleteImages(images,argv[i+1],exception); |
| 4752 | break; |
| 4753 | } |
| 4754 | if (LocaleCompare("dither",option+1) == 0) |
| 4755 | { |
| 4756 | if (*option == '+') |
| 4757 | { |
| 4758 | quantize_info->dither=MagickFalse; |
| 4759 | break; |
| 4760 | } |
| 4761 | quantize_info->dither=MagickTrue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4762 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4763 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 4764 | break; |
| 4765 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4766 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4767 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 4768 | Image |
| 4769 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 4770 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 4771 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 4772 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 4773 | else |
| 4774 | { |
| 4775 | const char |
| 4776 | *p; |
| 4777 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 4778 | size_t |
| 4779 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 4780 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 4781 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 4782 | p=strchr(argv[i+1],','); |
| 4783 | if (p == (const char *) NULL) |
| 4784 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 4785 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 4786 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 4787 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 4788 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 4789 | } |
| 4790 | AppendImageToList(images, duplicate_images); |
| 4791 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4792 | break; |
| 4793 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4794 | break; |
| 4795 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4796 | case 'e': |
| 4797 | { |
| 4798 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4799 | { |
| 4800 | Image |
| 4801 | *evaluate_image; |
| 4802 | |
| 4803 | MagickEvaluateOperator |
| 4804 | op; |
| 4805 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4806 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4807 | op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions, |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4808 | MagickFalse,argv[i+1]); |
| 4809 | evaluate_image=EvaluateImages(*images,op,exception); |
| 4810 | if (evaluate_image == (Image *) NULL) |
| 4811 | { |
| 4812 | status=MagickFalse; |
| 4813 | break; |
| 4814 | } |
| 4815 | *images=DestroyImageList(*images); |
| 4816 | *images=evaluate_image; |
| 4817 | break; |
| 4818 | } |
| 4819 | break; |
| 4820 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4821 | case 'f': |
| 4822 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 4823 | if (LocaleCompare("fft",option+1) == 0) |
| 4824 | { |
| 4825 | Image |
| 4826 | *fourier_image; |
| 4827 | |
| 4828 | /* |
| 4829 | Implements the discrete Fourier transform (DFT). |
| 4830 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4831 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 4832 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 4833 | MagickTrue : MagickFalse,exception); |
| 4834 | if (fourier_image == (Image *) NULL) |
| 4835 | break; |
| 4836 | *images=DestroyImage(*images); |
| 4837 | *images=fourier_image; |
| 4838 | break; |
| 4839 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4840 | if (LocaleCompare("flatten",option+1) == 0) |
| 4841 | { |
| 4842 | Image |
| 4843 | *flatten_image; |
| 4844 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4845 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4846 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 4847 | if (flatten_image == (Image *) NULL) |
| 4848 | break; |
| 4849 | *images=DestroyImageList(*images); |
| 4850 | *images=flatten_image; |
| 4851 | break; |
| 4852 | } |
| 4853 | if (LocaleCompare("fx",option+1) == 0) |
| 4854 | { |
| 4855 | Image |
| 4856 | *fx_image; |
| 4857 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4858 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4859 | fx_image=FxImageChannel(*images,channel,argv[i+1],exception); |
| 4860 | if (fx_image == (Image *) NULL) |
| 4861 | { |
| 4862 | status=MagickFalse; |
| 4863 | break; |
| 4864 | } |
| 4865 | *images=DestroyImageList(*images); |
| 4866 | *images=fx_image; |
| 4867 | break; |
| 4868 | } |
| 4869 | break; |
| 4870 | } |
| 4871 | case 'h': |
| 4872 | { |
| 4873 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4874 | { |
| 4875 | Image |
| 4876 | *hald_image, |
| 4877 | *image; |
| 4878 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4879 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4880 | image=RemoveFirstImageFromList(images); |
| 4881 | hald_image=RemoveFirstImageFromList(images); |
| 4882 | if (hald_image == (Image *) NULL) |
| 4883 | { |
| 4884 | status=MagickFalse; |
| 4885 | break; |
| 4886 | } |
| 4887 | (void) HaldClutImageChannel(image,channel,hald_image); |
| 4888 | hald_image=DestroyImage(hald_image); |
| 4889 | InheritException(exception,&image->exception); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 4890 | if (*images != (Image *) NULL) |
| 4891 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4892 | *images=image; |
| 4893 | break; |
| 4894 | } |
| 4895 | break; |
| 4896 | } |
| 4897 | case 'i': |
| 4898 | { |
| 4899 | if (LocaleCompare("ift",option+1) == 0) |
| 4900 | { |
| 4901 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 4902 | *fourier_image, |
| 4903 | *magnitude_image, |
| 4904 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4905 | |
| 4906 | /* |
| 4907 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 4908 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4909 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 4910 | magnitude_image=RemoveFirstImageFromList(images); |
| 4911 | phase_image=RemoveFirstImageFromList(images); |
| 4912 | if (phase_image == (Image *) NULL) |
| 4913 | { |
| 4914 | status=MagickFalse; |
| 4915 | break; |
| 4916 | } |
| 4917 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 4918 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4919 | if (fourier_image == (Image *) NULL) |
| 4920 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 4921 | if (*images != (Image *) NULL) |
| 4922 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4923 | *images=fourier_image; |
| 4924 | break; |
| 4925 | } |
| 4926 | if (LocaleCompare("insert",option+1) == 0) |
| 4927 | { |
| 4928 | Image |
| 4929 | *p, |
| 4930 | *q; |
| 4931 | |
| 4932 | index=0; |
| 4933 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 4934 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4935 | p=RemoveLastImageFromList(images); |
| 4936 | if (p == (Image *) NULL) |
| 4937 | { |
| 4938 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 4939 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 4940 | status=MagickFalse; |
| 4941 | break; |
| 4942 | } |
| 4943 | q=p; |
| 4944 | if (index == 0) |
| 4945 | PrependImageToList(images,q); |
| 4946 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4947 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4948 | AppendImageToList(images,q); |
| 4949 | else |
| 4950 | { |
| 4951 | q=GetImageFromList(*images,index-1); |
| 4952 | if (q == (Image *) NULL) |
| 4953 | { |
| 4954 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 4955 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 4956 | status=MagickFalse; |
| 4957 | break; |
| 4958 | } |
| 4959 | InsertImageInList(&q,p); |
| 4960 | } |
| 4961 | *images=GetFirstImageInList(q); |
| 4962 | break; |
| 4963 | } |
| 4964 | break; |
| 4965 | } |
| 4966 | case 'l': |
| 4967 | { |
| 4968 | if (LocaleCompare("layers",option+1) == 0) |
| 4969 | { |
| 4970 | Image |
| 4971 | *layers; |
| 4972 | |
| 4973 | ImageLayerMethod |
| 4974 | method; |
| 4975 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 4976 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4977 | layers=(Image *) NULL; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4978 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4979 | MagickFalse,argv[i+1]); |
| 4980 | switch (method) |
| 4981 | { |
| 4982 | case CoalesceLayer: |
| 4983 | { |
| 4984 | layers=CoalesceImages(*images,exception); |
| 4985 | break; |
| 4986 | } |
| 4987 | case CompareAnyLayer: |
| 4988 | case CompareClearLayer: |
| 4989 | case CompareOverlayLayer: |
| 4990 | default: |
| 4991 | { |
| 4992 | layers=CompareImageLayers(*images,method,exception); |
| 4993 | break; |
| 4994 | } |
| 4995 | case MergeLayer: |
| 4996 | case FlattenLayer: |
| 4997 | case MosaicLayer: |
| 4998 | case TrimBoundsLayer: |
| 4999 | { |
| 5000 | layers=MergeImageLayers(*images,method,exception); |
| 5001 | break; |
| 5002 | } |
| 5003 | case DisposeLayer: |
| 5004 | { |
| 5005 | layers=DisposeImages(*images,exception); |
| 5006 | break; |
| 5007 | } |
| 5008 | case OptimizeImageLayer: |
| 5009 | { |
| 5010 | layers=OptimizeImageLayers(*images,exception); |
| 5011 | break; |
| 5012 | } |
| 5013 | case OptimizePlusLayer: |
| 5014 | { |
| 5015 | layers=OptimizePlusImageLayers(*images,exception); |
| 5016 | break; |
| 5017 | } |
| 5018 | case OptimizeTransLayer: |
| 5019 | { |
| 5020 | OptimizeImageTransparency(*images,exception); |
| 5021 | break; |
| 5022 | } |
| 5023 | case RemoveDupsLayer: |
| 5024 | { |
| 5025 | RemoveDuplicateLayers(images,exception); |
| 5026 | break; |
| 5027 | } |
| 5028 | case RemoveZeroLayer: |
| 5029 | { |
| 5030 | RemoveZeroDelayLayers(images,exception); |
| 5031 | break; |
| 5032 | } |
| 5033 | case OptimizeLayer: |
| 5034 | { |
| 5035 | /* |
| 5036 | General Purpose, GIF Animation Optimizer. |
| 5037 | */ |
| 5038 | layers=CoalesceImages(*images,exception); |
| 5039 | if (layers == (Image *) NULL) |
| 5040 | { |
| 5041 | status=MagickFalse; |
| 5042 | break; |
| 5043 | } |
| 5044 | InheritException(exception,&layers->exception); |
| 5045 | *images=DestroyImageList(*images); |
| 5046 | *images=layers; |
| 5047 | layers=OptimizeImageLayers(*images,exception); |
| 5048 | if (layers == (Image *) NULL) |
| 5049 | { |
| 5050 | status=MagickFalse; |
| 5051 | break; |
| 5052 | } |
| 5053 | InheritException(exception,&layers->exception); |
| 5054 | *images=DestroyImageList(*images); |
| 5055 | *images=layers; |
| 5056 | layers=(Image *) NULL; |
| 5057 | OptimizeImageTransparency(*images,exception); |
| 5058 | InheritException(exception,&(*images)->exception); |
| 5059 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 5060 | break; |
| 5061 | } |
| 5062 | case CompositeLayer: |
| 5063 | { |
| 5064 | CompositeOperator |
| 5065 | compose; |
| 5066 | |
| 5067 | Image |
| 5068 | *source; |
| 5069 | |
| 5070 | RectangleInfo |
| 5071 | geometry; |
| 5072 | |
| 5073 | /* |
| 5074 | Split image sequence at the first 'NULL:' image. |
| 5075 | */ |
| 5076 | source=(*images); |
| 5077 | while (source != (Image *) NULL) |
| 5078 | { |
| 5079 | source=GetNextImageInList(source); |
| 5080 | if ((source != (Image *) NULL) && |
| 5081 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 5082 | break; |
| 5083 | } |
| 5084 | if (source != (Image *) NULL) |
| 5085 | { |
| 5086 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 5087 | (GetNextImageInList(source) == (Image *) NULL)) |
| 5088 | source=(Image *) NULL; |
| 5089 | else |
| 5090 | { |
| 5091 | /* |
| 5092 | Separate the two lists, junk the null: image. |
| 5093 | */ |
| 5094 | source=SplitImageList(source->previous); |
| 5095 | DeleteImageFromList(&source); |
| 5096 | } |
| 5097 | } |
| 5098 | if (source == (Image *) NULL) |
| 5099 | { |
| 5100 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 5101 | OptionError,"MissingNullSeparator","layers Composite"); |
| 5102 | status=MagickFalse; |
| 5103 | break; |
| 5104 | } |
| 5105 | /* |
| 5106 | Adjust offset with gravity and virtual canvas. |
| 5107 | */ |
| 5108 | SetGeometry(*images,&geometry); |
| 5109 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 5110 | geometry.width=source->page.width != 0 ? |
| 5111 | source->page.width : source->columns; |
| 5112 | geometry.height=source->page.height != 0 ? |
| 5113 | source->page.height : source->rows; |
| 5114 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 5115 | (*images)->page.width : (*images)->columns, |
| 5116 | (*images)->page.height != 0 ? (*images)->page.height : |
| 5117 | (*images)->rows,(*images)->gravity,&geometry); |
| 5118 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 5119 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5120 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5121 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5122 | MagickComposeOptions,MagickFalse,option); |
| 5123 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 5124 | exception); |
| 5125 | source=DestroyImageList(source); |
| 5126 | break; |
| 5127 | } |
| 5128 | } |
| 5129 | if (layers == (Image *) NULL) |
| 5130 | break; |
| 5131 | InheritException(exception,&layers->exception); |
| 5132 | *images=DestroyImageList(*images); |
| 5133 | *images=layers; |
| 5134 | break; |
| 5135 | } |
| 5136 | break; |
| 5137 | } |
| 5138 | case 'm': |
| 5139 | { |
| 5140 | if (LocaleCompare("map",option+1) == 0) |
| 5141 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 5142 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5143 | if (*option == '+') |
| 5144 | { |
| 5145 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 5146 | InheritException(exception,&(*images)->exception); |
| 5147 | break; |
| 5148 | } |
| 5149 | i++; |
| 5150 | break; |
| 5151 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5152 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5153 | { |
| 5154 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5155 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5156 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 5157 | /* |
| 5158 | Maximum image sequence (deprecated). |
| 5159 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 5160 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 5161 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5162 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5163 | { |
| 5164 | status=MagickFalse; |
| 5165 | break; |
| 5166 | } |
| 5167 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5168 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5169 | break; |
| 5170 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5171 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5172 | { |
| 5173 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5174 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5175 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 5176 | /* |
| 5177 | Minimum image sequence (deprecated). |
| 5178 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 5179 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 5180 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5181 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5182 | { |
| 5183 | status=MagickFalse; |
| 5184 | break; |
| 5185 | } |
| 5186 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5187 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5188 | break; |
| 5189 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5190 | if (LocaleCompare("morph",option+1) == 0) |
| 5191 | { |
| 5192 | Image |
| 5193 | *morph_image; |
| 5194 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 5195 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 5196 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5197 | exception); |
| 5198 | if (morph_image == (Image *) NULL) |
| 5199 | { |
| 5200 | status=MagickFalse; |
| 5201 | break; |
| 5202 | } |
| 5203 | *images=DestroyImageList(*images); |
| 5204 | *images=morph_image; |
| 5205 | break; |
| 5206 | } |
| 5207 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5208 | { |
| 5209 | Image |
| 5210 | *mosaic_image; |
| 5211 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 5212 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5213 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 5214 | if (mosaic_image == (Image *) NULL) |
| 5215 | { |
| 5216 | status=MagickFalse; |
| 5217 | break; |
| 5218 | } |
| 5219 | *images=DestroyImageList(*images); |
| 5220 | *images=mosaic_image; |
| 5221 | break; |
| 5222 | } |
| 5223 | break; |
| 5224 | } |
| 5225 | case 'p': |
| 5226 | { |
| 5227 | if (LocaleCompare("print",option+1) == 0) |
| 5228 | { |
| 5229 | char |
| 5230 | *string; |
| 5231 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 5232 | (void) SyncImagesSettings(mogrify_info,*images); |
| 5233 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5234 | if (string == (char *) NULL) |
| 5235 | break; |
| 5236 | InheritException(exception,&(*images)->exception); |
| 5237 | (void) fprintf(stdout,"%s",string); |
| 5238 | string=DestroyString(string); |
| 5239 | } |
| 5240 | if (LocaleCompare("process",option+1) == 0) |
| 5241 | { |
| 5242 | char |
| 5243 | **arguments; |
| 5244 | |
| 5245 | int |
| 5246 | j, |
| 5247 | number_arguments; |
| 5248 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 5249 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5250 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 5251 | if (arguments == (char **) NULL) |
| 5252 | break; |
| 5253 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 5254 | { |
| 5255 | char |
| 5256 | breaker, |
| 5257 | quote, |
| 5258 | *token; |
| 5259 | |
| 5260 | const char |
| 5261 | *arguments; |
| 5262 | |
| 5263 | int |
| 5264 | next, |
| 5265 | status; |
| 5266 | |
| 5267 | size_t |
| 5268 | length; |
| 5269 | |
| 5270 | TokenInfo |
| 5271 | *token_info; |
| 5272 | |
| 5273 | /* |
| 5274 | Support old style syntax, filter="-option arg". |
| 5275 | */ |
| 5276 | length=strlen(argv[i+1]); |
| 5277 | token=(char *) NULL; |
| 5278 | if (~length >= MaxTextExtent) |
| 5279 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 5280 | sizeof(*token)); |
| 5281 | if (token == (char *) NULL) |
| 5282 | break; |
| 5283 | next=0; |
| 5284 | arguments=argv[i+1]; |
| 5285 | token_info=AcquireTokenInfo(); |
| 5286 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 5287 | "\"",'\0',&breaker,&next,"e); |
| 5288 | token_info=DestroyTokenInfo(token_info); |
| 5289 | if (status == 0) |
| 5290 | { |
| 5291 | const char |
| 5292 | *argv; |
| 5293 | |
| 5294 | argv=(&(arguments[next])); |
| 5295 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 5296 | exception); |
| 5297 | } |
| 5298 | token=DestroyString(token); |
| 5299 | break; |
| 5300 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 5301 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5302 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 5303 | number_arguments-2,(const char **) arguments+2,exception); |
| 5304 | for (j=0; j < number_arguments; j++) |
| 5305 | arguments[j]=DestroyString(arguments[j]); |
| 5306 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 5307 | break; |
| 5308 | } |
| 5309 | break; |
| 5310 | } |
| 5311 | case 'r': |
| 5312 | { |
| 5313 | if (LocaleCompare("reverse",option+1) == 0) |
| 5314 | { |
| 5315 | ReverseImageList(images); |
| 5316 | InheritException(exception,&(*images)->exception); |
| 5317 | break; |
| 5318 | } |
| 5319 | break; |
| 5320 | } |
| 5321 | case 's': |
| 5322 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5323 | if (LocaleCompare("smush",option+1) == 0) |
| 5324 | { |
| 5325 | Image |
| 5326 | *smush_image; |
| 5327 | |
| 5328 | ssize_t |
| 5329 | offset; |
| 5330 | |
| 5331 | (void) SyncImagesSettings(mogrify_info,*images); |
| 5332 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 5333 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 5334 | MagickFalse,offset,exception); |
| 5335 | if (smush_image == (Image *) NULL) |
| 5336 | { |
| 5337 | status=MagickFalse; |
| 5338 | break; |
| 5339 | } |
| 5340 | *images=DestroyImageList(*images); |
| 5341 | *images=smush_image; |
| 5342 | break; |
| 5343 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5344 | if (LocaleCompare("swap",option+1) == 0) |
| 5345 | { |
| 5346 | Image |
| 5347 | *p, |
| 5348 | *q, |
| 5349 | *swap; |
| 5350 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5351 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5352 | swap_index; |
| 5353 | |
| 5354 | index=(-1); |
| 5355 | swap_index=(-2); |
| 5356 | if (*option != '+') |
| 5357 | { |
| 5358 | GeometryInfo |
| 5359 | geometry_info; |
| 5360 | |
| 5361 | MagickStatusType |
| 5362 | flags; |
| 5363 | |
| 5364 | swap_index=(-1); |
| 5365 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5366 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5367 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5368 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5369 | } |
| 5370 | p=GetImageFromList(*images,index); |
| 5371 | q=GetImageFromList(*images,swap_index); |
| 5372 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 5373 | { |
| 5374 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 5375 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 5376 | status=MagickFalse; |
| 5377 | break; |
| 5378 | } |
| 5379 | if (p == q) |
| 5380 | break; |
| 5381 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 5382 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 5383 | ReplaceImageInList(&q,swap); |
| 5384 | *images=GetFirstImageInList(q); |
| 5385 | break; |
| 5386 | } |
| 5387 | break; |
| 5388 | } |
| 5389 | case 'w': |
| 5390 | { |
| 5391 | if (LocaleCompare("write",option+1) == 0) |
| 5392 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 5393 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 5394 | key[MaxTextExtent]; |
| 5395 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5396 | Image |
| 5397 | *write_images; |
| 5398 | |
| 5399 | ImageInfo |
| 5400 | *write_info; |
| 5401 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 5402 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 5403 | (void) FormatMagickString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
| 5404 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5405 | write_images=(*images); |
| 5406 | if (*option == '+') |
| 5407 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 5408 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5409 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 5410 | write_info=DestroyImageInfo(write_info); |
| 5411 | if (*option == '+') |
| 5412 | write_images=DestroyImageList(write_images); |
| 5413 | break; |
| 5414 | } |
| 5415 | break; |
| 5416 | } |
| 5417 | default: |
| 5418 | break; |
| 5419 | } |
| 5420 | i+=count; |
| 5421 | } |
| 5422 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 5423 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 5424 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5425 | return(status != 0 ? MagickTrue : MagickFalse); |
| 5426 | } |
| 5427 | |
| 5428 | /* |
| 5429 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 5430 | % % |
| 5431 | % % |
| 5432 | % % |
| 5433 | + M o g r i f y I m a g e s % |
| 5434 | % % |
| 5435 | % % |
| 5436 | % % |
| 5437 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 5438 | % |
| 5439 | % MogrifyImages() applies image processing options to a sequence of images as |
| 5440 | % prescribed by command line options. |
| 5441 | % |
| 5442 | % The format of the MogrifyImage method is: |
| 5443 | % |
| 5444 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 5445 | % const MagickBooleanType post,const int argc,const char **argv, |
| 5446 | % Image **images,Exceptioninfo *exception) |
| 5447 | % |
| 5448 | % A description of each parameter follows: |
| 5449 | % |
| 5450 | % o image_info: the image info.. |
| 5451 | % |
| 5452 | % o post: If true, post process image list operators otherwise pre-process. |
| 5453 | % |
| 5454 | % o argc: Specifies a pointer to an integer describing the number of |
| 5455 | % elements in the argument vector. |
| 5456 | % |
| 5457 | % o argv: Specifies a pointer to a text array containing the command line |
| 5458 | % arguments. |
| 5459 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 5460 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5461 | % |
| 5462 | % o exception: return any errors or warnings in this structure. |
| 5463 | % |
| 5464 | */ |
| 5465 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 5466 | const MagickBooleanType post,const int argc,const char **argv, |
| 5467 | Image **images,ExceptionInfo *exception) |
| 5468 | { |
| 5469 | #define MogrifyImageTag "Mogrify/Image" |
| 5470 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 5471 | MagickStatusType |
| 5472 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5473 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 5474 | MagickBooleanType |
| 5475 | proceed; |
| 5476 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 5477 | size_t |
| 5478 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5479 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5480 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5481 | i; |
| 5482 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5483 | assert(image_info != (ImageInfo *) NULL); |
| 5484 | assert(image_info->signature == MagickSignature); |
| 5485 | if (images == (Image **) NULL) |
| 5486 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 5487 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5488 | assert((*images)->signature == MagickSignature); |
| 5489 | if ((*images)->debug != MagickFalse) |
| 5490 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 5491 | (*images)->filename); |
| 5492 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 5493 | return(MagickTrue); |
| 5494 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 5495 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5496 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 5497 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 5498 | #if 0 |
| 5499 | fprintf(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,post?"post":"pre"); |
| 5500 | #endif |
| 5501 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 5502 | /* |
| 5503 | Pre-process multi-image sequence operators |
| 5504 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5505 | if (post == MagickFalse) |
| 5506 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 5507 | |
| 5508 | /* |
| 5509 | For each image, process simple single image operators |
| 5510 | */ |
| 5511 | i=0; |
| 5512 | n=GetImageListLength(*images); |
| 5513 | for (;;) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5514 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 5515 | #if 0 |
| 5516 | fprintf(stderr, "mogrify %ld of %ld\n", |
| 5517 | (long)GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
| 5518 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 5519 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 5520 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 5521 | if (proceed == MagickFalse) |
| 5522 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 5523 | if ( (*images)->next == (Image *) NULL ) |
| 5524 | break; |
| 5525 | *images=(*images)->next; |
| 5526 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5527 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 5528 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 5529 | #if 0 |
| 5530 | fprintf(stderr, "mogrify end %ld of %ld\n", |
| 5531 | (long)GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
| 5532 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 5533 | |
| 5534 | /* |
| 5535 | Post-process, multi-image sequence operators |
| 5536 | */ |
| 5537 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5538 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 5539 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5540 | return(status != 0 ? MagickTrue : MagickFalse); |
| 5541 | } |