cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % M M OOO GGGGG RRRR IIIII FFFFF Y Y % |
| 7 | % MM MM O O G R R I F Y Y % |
| 8 | % M M M O O G GGG RRRR I FFF Y % |
| 9 | % M M O O G G R R I F Y % |
| 10 | % M M OOO GGGG R R IIIII F Y % |
| 11 | % % |
| 12 | % % |
| 13 | % MagickWand Module Methods % |
| 14 | % % |
| 15 | % Software Design % |
| 16 | % John Cristy % |
| 17 | % March 2000 % |
| 18 | % % |
| 19 | % % |
cristy | 7e41fe8 | 2010-12-04 23:12:08 +0000 | [diff] [blame] | 20 | % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 21 | % dedicated to making software imaging solutions freely available. % |
| 22 | % % |
| 23 | % You may not use this file except in compliance with the License. You may % |
| 24 | % obtain a copy of the License at % |
| 25 | % % |
| 26 | % http://www.imagemagick.org/script/license.php % |
| 27 | % % |
| 28 | % Unless required by applicable law or agreed to in writing, software % |
| 29 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 30 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 31 | % See the License for the specific language governing permissions and % |
| 32 | % limitations under the License. % |
| 33 | % % |
| 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 35 | % |
| 36 | % Use the mogrify program to resize an image, blur, crop, despeckle, dither, |
| 37 | % draw on, flip, join, re-sample, and much more. This tool is similiar to |
| 38 | % convert except that the original image file is overwritten (unless you |
| 39 | % change the file suffix with the -format option) with any changes you |
cristy | 6a917d9 | 2009-10-06 19:23:54 +0000 | [diff] [blame] | 40 | % request. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 41 | % |
| 42 | */ |
| 43 | |
| 44 | /* |
| 45 | Include declarations. |
| 46 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 47 | #include "MagickWand/studio.h" |
| 48 | #include "MagickWand/MagickWand.h" |
| 49 | #include "MagickWand/mogrify-private.h" |
| 50 | #undef DegreesToRadians |
| 51 | #undef RadiansToDegrees |
| 52 | #include "MagickCore/image-private.h" |
| 53 | #include "MagickCore/monitor-private.h" |
| 54 | #include "MagickCore/thread-private.h" |
| 55 | #include "MagickCore/string-private.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 56 | |
| 57 | /* |
cristy | 154fa9d | 2011-08-05 14:25:15 +0000 | [diff] [blame] | 58 | Constant declaration. |
| 59 | */ |
cristy | 3a557c0 | 2011-08-06 19:48:02 +0000 | [diff] [blame] | 60 | static const char |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 61 | MogrifyBackgroundColor[] = "#ffffff", /* white */ |
| 62 | MogrifyBorderColor[] = "#dfdfdf", /* gray */ |
| 63 | MogrifyMatteColor[] = "#bdbdbd"; /* gray */ |
cristy | 154fa9d | 2011-08-05 14:25:15 +0000 | [diff] [blame] | 64 | |
| 65 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 66 | Define declarations. |
| 67 | */ |
| 68 | #define UndefinedCompressionQuality 0UL |
| 69 | |
| 70 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 71 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 72 | % % |
| 73 | % % |
| 74 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 75 | % 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] | 76 | % % |
| 77 | % % |
| 78 | % % |
| 79 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 80 | % |
| 81 | % MagickCommandGenesis() applies image processing options to an image as |
| 82 | % prescribed by command line options. |
| 83 | % |
| 84 | % The format of the MagickCommandGenesis method is: |
| 85 | % |
| 86 | % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 87 | % MagickCommand command,int argc,char **argv,char **metadata, |
| 88 | % ExceptionInfo *exception) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 89 | % |
| 90 | % A description of each parameter follows: |
| 91 | % |
| 92 | % o image_info: the image info. |
| 93 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 94 | % o command: Choose from ConvertImageCommand, IdentifyImageCommand, |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 95 | % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 96 | % ConjureImageCommand, StreamImageCommand, ImportImageCommand, |
| 97 | % DisplayImageCommand, or AnimateImageCommand. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 98 | % |
| 99 | % o argc: Specifies a pointer to an integer describing the number of |
| 100 | % elements in the argument vector. |
| 101 | % |
| 102 | % o argv: Specifies a pointer to a text array containing the command line |
| 103 | % arguments. |
| 104 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 105 | % o metadata: any metadata is returned here. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 106 | % |
| 107 | % o exception: return any errors or warnings in this structure. |
| 108 | % |
| 109 | */ |
| 110 | WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
| 111 | MagickCommand command,int argc,char **argv,char **metadata, |
| 112 | ExceptionInfo *exception) |
| 113 | { |
| 114 | char |
| 115 | *option; |
| 116 | |
| 117 | double |
| 118 | duration, |
| 119 | elapsed_time, |
| 120 | user_time; |
| 121 | |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 122 | MagickBooleanType |
| 123 | concurrent, |
| 124 | regard_warnings, |
| 125 | status; |
| 126 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 127 | register ssize_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 128 | i; |
| 129 | |
| 130 | TimerInfo |
| 131 | *timer; |
| 132 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 133 | size_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 134 | iterations; |
| 135 | |
cristy | d0a94fa | 2010-03-12 14:18:11 +0000 | [diff] [blame] | 136 | (void) setlocale(LC_ALL,""); |
| 137 | (void) setlocale(LC_NUMERIC,"C"); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 138 | concurrent=MagickFalse; |
| 139 | duration=(-1.0); |
| 140 | iterations=1; |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 141 | status=MagickFalse; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 142 | regard_warnings=MagickFalse; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 143 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 144 | { |
| 145 | option=argv[i]; |
| 146 | if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) |
| 147 | continue; |
| 148 | if (LocaleCompare("bench",option+1) == 0) |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 149 | iterations=StringToUnsignedLong(argv[++i]); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 150 | if (LocaleCompare("concurrent",option+1) == 0) |
| 151 | concurrent=MagickTrue; |
| 152 | if (LocaleCompare("debug",option+1) == 0) |
| 153 | (void) SetLogEventMask(argv[++i]); |
| 154 | if (LocaleCompare("duration",option+1) == 0) |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 155 | duration=InterpretLocaleValue(argv[++i],(char **) NULL); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 156 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 157 | regard_warnings=MagickTrue; |
| 158 | } |
| 159 | timer=AcquireTimerInfo(); |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 160 | if (concurrent == MagickFalse) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 161 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 162 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 163 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 164 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 165 | continue; |
| 166 | if (duration > 0) |
| 167 | { |
| 168 | if (GetElapsedTime(timer) > duration) |
| 169 | continue; |
| 170 | (void) ContinueTimer(timer); |
| 171 | } |
| 172 | status=command(image_info,argc,argv,metadata,exception); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 173 | if (exception->severity != UndefinedException) |
| 174 | { |
| 175 | if ((exception->severity > ErrorException) || |
| 176 | (regard_warnings != MagickFalse)) |
| 177 | status=MagickTrue; |
| 178 | CatchException(exception); |
| 179 | } |
cristy | 3d1a551 | 2009-10-25 21:23:27 +0000 | [diff] [blame] | 180 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 181 | { |
| 182 | (void) fputs(*metadata,stdout); |
| 183 | (void) fputc('\n',stdout); |
| 184 | *metadata=DestroyString(*metadata); |
| 185 | } |
| 186 | } |
| 187 | } |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 188 | else |
| 189 | { |
| 190 | SetOpenMPNested(1); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 191 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 192 | # pragma omp parallel for shared(status) |
| 193 | #endif |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 194 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 195 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 196 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 197 | continue; |
| 198 | if (duration > 0) |
| 199 | { |
| 200 | if (GetElapsedTime(timer) > duration) |
| 201 | continue; |
| 202 | (void) ContinueTimer(timer); |
| 203 | } |
| 204 | status=command(image_info,argc,argv,metadata,exception); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 205 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 206 | # pragma omp critical (MagickCore_CommandGenesis) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 207 | #endif |
| 208 | { |
| 209 | if (exception->severity != UndefinedException) |
| 210 | { |
| 211 | if ((exception->severity > ErrorException) || |
| 212 | (regard_warnings != MagickFalse)) |
| 213 | status=MagickTrue; |
| 214 | CatchException(exception); |
| 215 | } |
| 216 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 217 | { |
| 218 | (void) fputs(*metadata,stdout); |
| 219 | (void) fputc('\n',stdout); |
| 220 | *metadata=DestroyString(*metadata); |
| 221 | } |
| 222 | } |
| 223 | } |
| 224 | } |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 225 | if (iterations > 1) |
| 226 | { |
| 227 | elapsed_time=GetElapsedTime(timer); |
| 228 | user_time=GetUserTime(timer); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 229 | (void) FormatLocaleFile(stderr, |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 230 | "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double) |
| 231 | iterations,1.0*iterations/elapsed_time,user_time,(double) |
| 232 | (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double) |
| 233 | (1000.0*(elapsed_time-floor(elapsed_time)))); |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 234 | (void) fflush(stderr); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 235 | } |
| 236 | timer=DestroyTimerInfo(timer); |
cristy | 1f9e1ed | 2009-11-18 04:09:38 +0000 | [diff] [blame] | 237 | return(status); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | /* |
| 241 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 242 | % % |
| 243 | % % |
| 244 | % % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 245 | + M o g r i f y I m a g e % |
| 246 | % % |
| 247 | % % |
| 248 | % % |
| 249 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 250 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 251 | % MogrifyImage() applies simple single image processing options to a single |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 252 | % image that may be part of a large list, but also handles any 'region' |
| 253 | % image handling. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 254 | % |
| 255 | % The image in the list may be modified in three different ways... |
| 256 | % |
| 257 | % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 258 | % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 259 | % * replace by a list of images (only the -separate option!) |
| 260 | % |
| 261 | % In each case the result is returned into the list, and a pointer to the |
| 262 | % modified image (last image added if replaced by a list of images) is |
| 263 | % returned. |
| 264 | % |
| 265 | % ASIDE: The -crop is present but restricted to non-tile single image crops |
| 266 | % |
| 267 | % This means if all the images are being processed (such as by |
| 268 | % MogrifyImages(), next image to be processed will be as per the pointer |
| 269 | % (*image)->next. Also the image list may grow as a result of some specific |
| 270 | % operations but as images are never merged or deleted, it will never shrink |
| 271 | % in length. Typically the list will remain the same length. |
| 272 | % |
| 273 | % WARNING: As the image pointed to may be replaced, the first image in the |
| 274 | % list may also change. GetFirstImageInList() should be used by caller if |
| 275 | % they wish return the Image pointer to the first image in list. |
| 276 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 277 | % |
| 278 | % The format of the MogrifyImage method is: |
| 279 | % |
| 280 | % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 281 | % const char **argv,Image **image) |
| 282 | % |
| 283 | % A description of each parameter follows: |
| 284 | % |
| 285 | % o image_info: the image info.. |
| 286 | % |
| 287 | % o argc: Specifies a pointer to an integer describing the number of |
| 288 | % elements in the argument vector. |
| 289 | % |
| 290 | % o argv: Specifies a pointer to a text array containing the command line |
| 291 | % arguments. |
| 292 | % |
| 293 | % o image: the image. |
| 294 | % |
| 295 | % o exception: return any errors or warnings in this structure. |
| 296 | % |
| 297 | */ |
| 298 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 299 | /* |
| 300 | ** GetImageCache() will read an image into a image cache if not already |
| 301 | ** present then return the image that is in the cache under that filename. |
| 302 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 303 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 304 | ExceptionInfo *exception) |
| 305 | { |
| 306 | char |
| 307 | key[MaxTextExtent]; |
| 308 | |
| 309 | ExceptionInfo |
| 310 | *sans_exception; |
| 311 | |
| 312 | Image |
| 313 | *image; |
| 314 | |
| 315 | ImageInfo |
| 316 | *read_info; |
| 317 | |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 318 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 319 | sans_exception=AcquireExceptionInfo(); |
| 320 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 321 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 322 | if (image != (Image *) NULL) |
| 323 | return(image); |
| 324 | read_info=CloneImageInfo(image_info); |
| 325 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 326 | image=ReadImage(read_info,exception); |
| 327 | read_info=DestroyImageInfo(read_info); |
| 328 | if (image != (Image *) NULL) |
| 329 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 330 | return(image); |
| 331 | } |
| 332 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 333 | static MagickBooleanType IsPathWritable(const char *path) |
| 334 | { |
| 335 | if (IsPathAccessible(path) == MagickFalse) |
| 336 | return(MagickFalse); |
| 337 | if (access(path,W_OK) != 0) |
| 338 | return(MagickFalse); |
| 339 | return(MagickTrue); |
| 340 | } |
| 341 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 342 | static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 343 | { |
| 344 | if (x > y) |
| 345 | return(x); |
| 346 | return(y); |
| 347 | } |
| 348 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 349 | static MagickBooleanType MonitorProgress(const char *text, |
| 350 | const MagickOffsetType offset,const MagickSizeType extent, |
| 351 | void *wand_unused(client_data)) |
| 352 | { |
| 353 | char |
| 354 | message[MaxTextExtent], |
| 355 | tag[MaxTextExtent]; |
| 356 | |
| 357 | const char |
| 358 | *locale_message; |
| 359 | |
| 360 | register char |
| 361 | *p; |
| 362 | |
| 363 | if (extent < 2) |
| 364 | return(MagickTrue); |
| 365 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 366 | p=strrchr(tag,'/'); |
| 367 | if (p != (char *) NULL) |
| 368 | *p='\0'; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 369 | (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 370 | locale_message=GetLocaleMessage(message); |
| 371 | if (locale_message == message) |
| 372 | locale_message=tag; |
| 373 | if (p == (char *) NULL) |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 374 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", |
| 375 | locale_message,(long) offset,(unsigned long) extent,(long) |
| 376 | (100L*offset/(extent-1))); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 377 | else |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 378 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 379 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 380 | (100L*offset/(extent-1))); |
| 381 | if (offset == (MagickOffsetType) (extent-1)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 382 | (void) FormatLocaleFile(stderr,"\n"); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 383 | (void) fflush(stderr); |
| 384 | return(MagickTrue); |
| 385 | } |
| 386 | |
| 387 | /* |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 388 | ** SparseColorOption() parses the complex -sparse-color argument into an |
| 389 | ** an array of floating point values then calls SparseColorImage(). |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 390 | ** Argument is a complex mix of floating-point pixel coodinates, and color |
| 391 | ** specifications (or direct floating point numbers). The number of floats |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 392 | ** needed to represent a color varies depending on the current channel |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 393 | ** setting. |
| 394 | */ |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 395 | static Image *SparseColorOption(const Image *image, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 396 | const SparseColorMethod method,const char *arguments, |
| 397 | const MagickBooleanType color_from_image,ExceptionInfo *exception) |
| 398 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 399 | char |
| 400 | token[MaxTextExtent]; |
| 401 | |
| 402 | const char |
| 403 | *p; |
| 404 | |
| 405 | double |
| 406 | *sparse_arguments; |
| 407 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 408 | Image |
| 409 | *sparse_image; |
| 410 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 411 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 412 | color; |
| 413 | |
| 414 | MagickBooleanType |
| 415 | error; |
| 416 | |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 417 | register size_t |
| 418 | x; |
| 419 | |
| 420 | size_t |
| 421 | number_arguments, |
| 422 | number_colors; |
| 423 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 424 | assert(image != (Image *) NULL); |
| 425 | assert(image->signature == MagickSignature); |
| 426 | if (image->debug != MagickFalse) |
| 427 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 428 | assert(exception != (ExceptionInfo *) NULL); |
| 429 | assert(exception->signature == MagickSignature); |
| 430 | /* |
| 431 | Limit channels according to image - and add up number of color channel. |
| 432 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 433 | number_colors=0; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 434 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 435 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 436 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 437 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 438 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 439 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 440 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 441 | (image->colorspace == CMYKColorspace)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 442 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 443 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 444 | (image->matte != MagickFalse)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 445 | number_colors++; |
| 446 | |
| 447 | /* |
| 448 | Read string, to determine number of arguments needed, |
| 449 | */ |
| 450 | p=arguments; |
| 451 | x=0; |
| 452 | while( *p != '\0' ) |
| 453 | { |
| 454 | GetMagickToken(p,&p,token); |
| 455 | if ( token[0] == ',' ) continue; |
| 456 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 457 | if ( color_from_image ) { |
| 458 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 459 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 460 | "Color arg given, when colors are coming from image"); |
| 461 | return( (Image *)NULL); |
| 462 | } |
| 463 | x += number_colors; /* color argument */ |
| 464 | } |
| 465 | else { |
| 466 | x++; /* floating point argument */ |
| 467 | } |
| 468 | } |
| 469 | error=MagickTrue; |
| 470 | if ( color_from_image ) { |
| 471 | /* just the control points are being given */ |
| 472 | error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; |
| 473 | number_arguments=(x/2)*(2+number_colors); |
| 474 | } |
| 475 | else { |
| 476 | /* control points and color values */ |
| 477 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; |
| 478 | number_arguments=x; |
| 479 | } |
| 480 | if ( error ) { |
| 481 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 482 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 483 | "Invalid number of Arguments"); |
| 484 | return( (Image *)NULL); |
| 485 | } |
| 486 | |
| 487 | /* Allocate and fill in the floating point arguments */ |
| 488 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 489 | sizeof(*sparse_arguments)); |
| 490 | if (sparse_arguments == (double *) NULL) { |
| 491 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 492 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 493 | return( (Image *)NULL); |
| 494 | } |
| 495 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 496 | sizeof(*sparse_arguments)); |
| 497 | p=arguments; |
| 498 | x=0; |
| 499 | while( *p != '\0' && x < number_arguments ) { |
| 500 | /* X coordinate */ |
| 501 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 502 | if ( token[0] == '\0' ) break; |
| 503 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 504 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 505 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 506 | "Color found, instead of X-coord"); |
| 507 | error = MagickTrue; |
| 508 | break; |
| 509 | } |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 510 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 511 | /* Y coordinate */ |
| 512 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 513 | if ( token[0] == '\0' ) break; |
| 514 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 515 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 516 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 517 | "Color found, instead of Y-coord"); |
| 518 | error = MagickTrue; |
| 519 | break; |
| 520 | } |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 521 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 522 | /* color values for this control point */ |
| 523 | #if 0 |
| 524 | if ( (color_from_image ) { |
| 525 | /* get color from image */ |
| 526 | /* HOW??? */ |
| 527 | } |
| 528 | else |
| 529 | #endif |
| 530 | { |
| 531 | /* color name or function given in string argument */ |
| 532 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 533 | if ( token[0] == '\0' ) break; |
| 534 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 535 | /* Color string given */ |
| 536 | (void) QueryMagickColor(token,&color,exception); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 537 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 538 | sparse_arguments[x++] = QuantumScale*color.red; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 539 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 540 | sparse_arguments[x++] = QuantumScale*color.green; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 541 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 542 | sparse_arguments[x++] = QuantumScale*color.blue; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 543 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 544 | (image->colorspace == CMYKColorspace)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 545 | sparse_arguments[x++] = QuantumScale*color.black; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 546 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 547 | (image->matte != MagickFalse)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 548 | sparse_arguments[x++] = QuantumScale*color.alpha; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 549 | } |
| 550 | else { |
| 551 | /* Colors given as a set of floating point values - experimental */ |
| 552 | /* NB: token contains the first floating point value to use! */ |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 553 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 554 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 555 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 556 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 557 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 558 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 559 | token[0] = ','; /* used this token - get another */ |
| 560 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 561 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 562 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 563 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 564 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 565 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 566 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 567 | token[0] = ','; /* used this token - get another */ |
| 568 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 569 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 570 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 571 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 572 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 573 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 574 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 575 | token[0] = ','; /* used this token - get another */ |
| 576 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 577 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 578 | (image->colorspace == CMYKColorspace)) |
| 579 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 580 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 581 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 582 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 583 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 584 | token[0] = ','; /* used this token - get another */ |
| 585 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 586 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 587 | (image->matte != MagickFalse)) |
| 588 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 589 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 590 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 591 | break; |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 592 | sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 593 | token[0] = ','; /* used this token - get another */ |
| 594 | } |
| 595 | } |
| 596 | } |
| 597 | } |
| 598 | if ( number_arguments != x && !error ) { |
| 599 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
| 600 | "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error"); |
| 601 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 602 | return( (Image *)NULL); |
| 603 | } |
| 604 | if ( error ) |
| 605 | return( (Image *)NULL); |
| 606 | |
| 607 | /* Call the Interpolation function with the parsed arguments */ |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 608 | sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, |
| 609 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 610 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 611 | return( sparse_image ); |
| 612 | } |
| 613 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 614 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 615 | const char **argv,Image **image,ExceptionInfo *exception) |
| 616 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 617 | ChannelType |
| 618 | channel; |
| 619 | |
| 620 | const char |
| 621 | *format, |
| 622 | *option; |
| 623 | |
| 624 | DrawInfo |
| 625 | *draw_info; |
| 626 | |
| 627 | GeometryInfo |
| 628 | geometry_info; |
| 629 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 630 | Image |
| 631 | *region_image; |
| 632 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 633 | ImageInfo |
| 634 | *mogrify_info; |
| 635 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 636 | MagickStatusType |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 637 | status; |
| 638 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 639 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 640 | fill; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 641 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 642 | MagickStatusType |
| 643 | flags; |
| 644 | |
| 645 | QuantizeInfo |
| 646 | *quantize_info; |
| 647 | |
| 648 | RectangleInfo |
| 649 | geometry, |
| 650 | region_geometry; |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame] | 651 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 652 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 653 | i; |
| 654 | |
| 655 | /* |
| 656 | Initialize method variables. |
| 657 | */ |
| 658 | assert(image_info != (const ImageInfo *) NULL); |
| 659 | assert(image_info->signature == MagickSignature); |
| 660 | assert(image != (Image **) NULL); |
| 661 | assert((*image)->signature == MagickSignature); |
| 662 | if ((*image)->debug != MagickFalse) |
| 663 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); |
| 664 | if (argc < 0) |
| 665 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 666 | mogrify_info=CloneImageInfo(image_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 667 | draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL); |
| 668 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 669 | SetGeometryInfo(&geometry_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 670 | GetPixelInfo(*image,&fill); |
| 671 | SetPixelInfoPacket(*image,&(*image)->background_color,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 672 | channel=mogrify_info->channel; |
| 673 | format=GetImageOption(mogrify_info,"format"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 674 | SetGeometry(*image,®ion_geometry); |
| 675 | region_image=NewImageList(); |
| 676 | /* |
| 677 | Transmogrify the image. |
| 678 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 679 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 680 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 681 | Image |
| 682 | *mogrify_image; |
| 683 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 684 | ssize_t |
| 685 | count; |
| 686 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 687 | option=argv[i]; |
| 688 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 689 | continue; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 690 | count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option), |
| 691 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 692 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 693 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 694 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 695 | mogrify_image=(Image *)NULL; |
| 696 | switch (*(option+1)) |
| 697 | { |
| 698 | case 'a': |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 699 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 700 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 701 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 702 | /* |
| 703 | Adaptive blur image. |
| 704 | */ |
| 705 | (void) SyncImageSettings(mogrify_info,*image); |
| 706 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 707 | if ((flags & SigmaValue) == 0) |
| 708 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 709 | if ((flags & XiValue) == 0) |
| 710 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 711 | mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho, |
cristy | 4c11c2b | 2011-09-05 20:17:07 +0000 | [diff] [blame] | 712 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 713 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 714 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 715 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 716 | { |
| 717 | /* |
| 718 | Adaptive resize image. |
| 719 | */ |
| 720 | (void) SyncImageSettings(mogrify_info,*image); |
| 721 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 722 | mogrify_image=AdaptiveResizeImage(*image,geometry.width, |
cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame^] | 723 | geometry.height,(*image)->interpolate,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 724 | break; |
| 725 | } |
| 726 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 727 | { |
| 728 | /* |
| 729 | Adaptive sharpen image. |
| 730 | */ |
| 731 | (void) SyncImageSettings(mogrify_info,*image); |
| 732 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 733 | if ((flags & SigmaValue) == 0) |
| 734 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 735 | if ((flags & XiValue) == 0) |
| 736 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 737 | mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho, |
cristy | 4c11c2b | 2011-09-05 20:17:07 +0000 | [diff] [blame] | 738 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 739 | break; |
| 740 | } |
| 741 | if (LocaleCompare("affine",option+1) == 0) |
| 742 | { |
| 743 | /* |
| 744 | Affine matrix. |
| 745 | */ |
| 746 | if (*option == '+') |
| 747 | { |
| 748 | GetAffineMatrix(&draw_info->affine); |
| 749 | break; |
| 750 | } |
| 751 | (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); |
| 752 | break; |
| 753 | } |
| 754 | if (LocaleCompare("alpha",option+1) == 0) |
| 755 | { |
| 756 | AlphaChannelType |
| 757 | alpha_type; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 758 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 759 | (void) SyncImageSettings(mogrify_info,*image); |
| 760 | alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions, |
| 761 | MagickFalse,argv[i+1]); |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 762 | (void) SetImageAlphaChannel(*image,alpha_type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 763 | break; |
| 764 | } |
| 765 | if (LocaleCompare("annotate",option+1) == 0) |
| 766 | { |
| 767 | char |
| 768 | *text, |
| 769 | geometry[MaxTextExtent]; |
| 770 | |
| 771 | /* |
| 772 | Annotate image. |
| 773 | */ |
| 774 | (void) SyncImageSettings(mogrify_info,*image); |
| 775 | SetGeometryInfo(&geometry_info); |
| 776 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 777 | if ((flags & SigmaValue) == 0) |
| 778 | geometry_info.sigma=geometry_info.rho; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 779 | text=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 780 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 781 | if (text == (char *) NULL) |
| 782 | break; |
| 783 | (void) CloneString(&draw_info->text,text); |
| 784 | text=DestroyString(text); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 785 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 786 | geometry_info.xi,geometry_info.psi); |
| 787 | (void) CloneString(&draw_info->geometry,geometry); |
| 788 | draw_info->affine.sx=cos(DegreesToRadians( |
| 789 | fmod(geometry_info.rho,360.0))); |
| 790 | draw_info->affine.rx=sin(DegreesToRadians( |
| 791 | fmod(geometry_info.rho,360.0))); |
| 792 | draw_info->affine.ry=(-sin(DegreesToRadians( |
| 793 | fmod(geometry_info.sigma,360.0)))); |
| 794 | draw_info->affine.sy=cos(DegreesToRadians( |
| 795 | fmod(geometry_info.sigma,360.0))); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 796 | (void) AnnotateImage(*image,draw_info,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 797 | break; |
| 798 | } |
| 799 | if (LocaleCompare("antialias",option+1) == 0) |
| 800 | { |
| 801 | draw_info->stroke_antialias=(*option == '-') ? MagickTrue : |
| 802 | MagickFalse; |
| 803 | draw_info->text_antialias=(*option == '-') ? MagickTrue : |
| 804 | MagickFalse; |
| 805 | break; |
| 806 | } |
| 807 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 808 | { |
| 809 | /* |
| 810 | Auto Adjust Gamma of image based on its mean |
| 811 | */ |
| 812 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 9511120 | 2011-08-09 19:41:42 +0000 | [diff] [blame] | 813 | (void) AutoGammaImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 814 | break; |
| 815 | } |
| 816 | if (LocaleCompare("auto-level",option+1) == 0) |
| 817 | { |
| 818 | /* |
| 819 | Perfectly Normalize (max/min stretch) the image |
| 820 | */ |
| 821 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 9511120 | 2011-08-09 19:41:42 +0000 | [diff] [blame] | 822 | (void) AutoLevelImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 823 | break; |
| 824 | } |
| 825 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 826 | { |
| 827 | (void) SyncImageSettings(mogrify_info,*image); |
| 828 | switch ((*image)->orientation) |
| 829 | { |
| 830 | case TopRightOrientation: |
| 831 | { |
| 832 | mogrify_image=FlopImage(*image,exception); |
| 833 | break; |
| 834 | } |
| 835 | case BottomRightOrientation: |
| 836 | { |
| 837 | mogrify_image=RotateImage(*image,180.0,exception); |
| 838 | break; |
| 839 | } |
| 840 | case BottomLeftOrientation: |
| 841 | { |
| 842 | mogrify_image=FlipImage(*image,exception); |
| 843 | break; |
| 844 | } |
| 845 | case LeftTopOrientation: |
| 846 | { |
| 847 | mogrify_image=TransposeImage(*image,exception); |
| 848 | break; |
| 849 | } |
| 850 | case RightTopOrientation: |
| 851 | { |
| 852 | mogrify_image=RotateImage(*image,90.0,exception); |
| 853 | break; |
| 854 | } |
| 855 | case RightBottomOrientation: |
| 856 | { |
| 857 | mogrify_image=TransverseImage(*image,exception); |
| 858 | break; |
| 859 | } |
| 860 | case LeftBottomOrientation: |
| 861 | { |
| 862 | mogrify_image=RotateImage(*image,270.0,exception); |
| 863 | break; |
| 864 | } |
| 865 | default: |
| 866 | break; |
| 867 | } |
| 868 | if (mogrify_image != (Image *) NULL) |
| 869 | mogrify_image->orientation=TopLeftOrientation; |
| 870 | break; |
| 871 | } |
| 872 | break; |
| 873 | } |
| 874 | case 'b': |
| 875 | { |
| 876 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 877 | { |
| 878 | /* |
| 879 | Black threshold image. |
| 880 | */ |
| 881 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 882 | (void) BlackThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 883 | InheritException(exception,&(*image)->exception); |
| 884 | break; |
| 885 | } |
| 886 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 887 | { |
| 888 | /* |
| 889 | Blue shift image. |
| 890 | */ |
| 891 | (void) SyncImageSettings(mogrify_info,*image); |
| 892 | geometry_info.rho=1.5; |
| 893 | if (*option == '-') |
| 894 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 895 | mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception); |
| 896 | break; |
| 897 | } |
| 898 | if (LocaleCompare("blur",option+1) == 0) |
| 899 | { |
| 900 | /* |
| 901 | Gaussian blur image. |
| 902 | */ |
| 903 | (void) SyncImageSettings(mogrify_info,*image); |
| 904 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 905 | if ((flags & SigmaValue) == 0) |
| 906 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 907 | if ((flags & XiValue) == 0) |
| 908 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 909 | mogrify_image=BlurImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 910 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 911 | break; |
| 912 | } |
| 913 | if (LocaleCompare("border",option+1) == 0) |
| 914 | { |
| 915 | /* |
| 916 | Surround image with a border of solid color. |
| 917 | */ |
| 918 | (void) SyncImageSettings(mogrify_info,*image); |
| 919 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 920 | if ((flags & SigmaValue) == 0) |
| 921 | geometry.height=geometry.width; |
| 922 | mogrify_image=BorderImage(*image,&geometry,exception); |
| 923 | break; |
| 924 | } |
| 925 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 926 | { |
| 927 | if (*option == '+') |
| 928 | { |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 929 | (void) QueryColorDatabase(MogrifyBorderColor, |
| 930 | &draw_info->border_color,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 931 | break; |
| 932 | } |
| 933 | (void) QueryColorDatabase(argv[i+1],&draw_info->border_color, |
| 934 | exception); |
| 935 | break; |
| 936 | } |
| 937 | if (LocaleCompare("box",option+1) == 0) |
| 938 | { |
| 939 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 940 | exception); |
| 941 | break; |
| 942 | } |
| 943 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 944 | { |
| 945 | double |
| 946 | brightness, |
| 947 | contrast; |
| 948 | |
| 949 | GeometryInfo |
| 950 | geometry_info; |
| 951 | |
| 952 | MagickStatusType |
| 953 | flags; |
| 954 | |
| 955 | /* |
| 956 | Brightness / contrast image. |
| 957 | */ |
| 958 | (void) SyncImageSettings(mogrify_info,*image); |
| 959 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 960 | brightness=geometry_info.rho; |
| 961 | contrast=0.0; |
| 962 | if ((flags & SigmaValue) != 0) |
| 963 | contrast=geometry_info.sigma; |
cristy | 444eda6 | 2011-08-10 02:07:46 +0000 | [diff] [blame] | 964 | (void) BrightnessContrastImage(*image,brightness,contrast, |
| 965 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 966 | InheritException(exception,&(*image)->exception); |
| 967 | break; |
| 968 | } |
| 969 | break; |
| 970 | } |
| 971 | case 'c': |
| 972 | { |
| 973 | if (LocaleCompare("cdl",option+1) == 0) |
| 974 | { |
| 975 | char |
| 976 | *color_correction_collection; |
| 977 | |
| 978 | /* |
| 979 | Color correct with a color decision list. |
| 980 | */ |
| 981 | (void) SyncImageSettings(mogrify_info,*image); |
| 982 | color_correction_collection=FileToString(argv[i+1],~0,exception); |
| 983 | if (color_correction_collection == (char *) NULL) |
| 984 | break; |
cristy | 1bfa9f0 | 2011-08-11 02:35:43 +0000 | [diff] [blame] | 985 | (void) ColorDecisionListImage(*image,color_correction_collection, |
| 986 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 987 | InheritException(exception,&(*image)->exception); |
| 988 | break; |
| 989 | } |
| 990 | if (LocaleCompare("channel",option+1) == 0) |
| 991 | { |
| 992 | if (*option == '+') |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 993 | channel=DefaultChannels; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 994 | else |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 995 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 996 | SetPixelChannelMap(*image,channel); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 997 | break; |
| 998 | } |
| 999 | if (LocaleCompare("charcoal",option+1) == 0) |
| 1000 | { |
| 1001 | /* |
| 1002 | Charcoal image. |
| 1003 | */ |
| 1004 | (void) SyncImageSettings(mogrify_info,*image); |
| 1005 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1006 | if ((flags & SigmaValue) == 0) |
| 1007 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1008 | if ((flags & XiValue) == 0) |
| 1009 | geometry_info.xi=1.0; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1010 | mogrify_image=CharcoalImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1011 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1012 | break; |
| 1013 | } |
| 1014 | if (LocaleCompare("chop",option+1) == 0) |
| 1015 | { |
| 1016 | /* |
| 1017 | Chop the image. |
| 1018 | */ |
| 1019 | (void) SyncImageSettings(mogrify_info,*image); |
| 1020 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1021 | mogrify_image=ChopImage(*image,&geometry,exception); |
| 1022 | break; |
| 1023 | } |
| 1024 | if (LocaleCompare("clamp",option+1) == 0) |
| 1025 | { |
| 1026 | /* |
| 1027 | Clamp image. |
| 1028 | */ |
| 1029 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1030 | (void) ClampImage(*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1031 | InheritException(exception,&(*image)->exception); |
| 1032 | break; |
| 1033 | } |
| 1034 | if (LocaleCompare("clip",option+1) == 0) |
| 1035 | { |
| 1036 | (void) SyncImageSettings(mogrify_info,*image); |
| 1037 | if (*option == '+') |
| 1038 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1039 | (void) SetImageClipMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1040 | break; |
| 1041 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1042 | (void) ClipImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1043 | break; |
| 1044 | } |
| 1045 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1046 | { |
| 1047 | CacheView |
| 1048 | *mask_view; |
| 1049 | |
| 1050 | Image |
| 1051 | *mask_image; |
| 1052 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1053 | register Quantum |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1054 | *restrict q; |
| 1055 | |
| 1056 | register ssize_t |
| 1057 | x; |
| 1058 | |
| 1059 | ssize_t |
| 1060 | y; |
| 1061 | |
| 1062 | (void) SyncImageSettings(mogrify_info,*image); |
| 1063 | if (*option == '+') |
| 1064 | { |
| 1065 | /* |
| 1066 | Remove a mask. |
| 1067 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1068 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1069 | break; |
| 1070 | } |
| 1071 | /* |
| 1072 | Set the image mask. |
| 1073 | FUTURE: This Should Be a SetImageAlphaChannel() call, Or two. |
| 1074 | */ |
| 1075 | mask_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1076 | if (mask_image == (Image *) NULL) |
| 1077 | break; |
cristy | 574cc26 | 2011-08-05 01:23:58 +0000 | [diff] [blame] | 1078 | if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1079 | return(MagickFalse); |
| 1080 | mask_view=AcquireCacheView(mask_image); |
| 1081 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1082 | { |
| 1083 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1084 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 1085 | if (q == (Quantum *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1086 | break; |
| 1087 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1088 | { |
| 1089 | if (mask_image->matte == MagickFalse) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1090 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 1091 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1092 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1093 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1094 | q+=GetPixelChannels(mask_image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1095 | } |
| 1096 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
| 1097 | break; |
| 1098 | } |
| 1099 | mask_view=DestroyCacheView(mask_view); |
| 1100 | mask_image->matte=MagickTrue; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1101 | (void) SetImageClipMask(*image,mask_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1102 | InheritException(exception,&(*image)->exception); |
| 1103 | break; |
| 1104 | } |
| 1105 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1106 | { |
| 1107 | (void) SyncImageSettings(mogrify_info,*image); |
| 1108 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1109 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1110 | break; |
| 1111 | } |
| 1112 | if (LocaleCompare("colorize",option+1) == 0) |
| 1113 | { |
| 1114 | /* |
| 1115 | Colorize the image. |
| 1116 | */ |
| 1117 | (void) SyncImageSettings(mogrify_info,*image); |
| 1118 | mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill, |
| 1119 | exception); |
| 1120 | break; |
| 1121 | } |
| 1122 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1123 | { |
| 1124 | KernelInfo |
| 1125 | *kernel; |
| 1126 | |
| 1127 | (void) SyncImageSettings(mogrify_info,*image); |
| 1128 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1129 | if (kernel == (KernelInfo *) NULL) |
| 1130 | break; |
| 1131 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 1132 | kernel=DestroyKernelInfo(kernel); |
| 1133 | break; |
| 1134 | } |
| 1135 | if (LocaleCompare("colors",option+1) == 0) |
| 1136 | { |
| 1137 | /* |
| 1138 | Reduce the number of colors in the image. |
| 1139 | */ |
| 1140 | (void) SyncImageSettings(mogrify_info,*image); |
| 1141 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
| 1142 | if (quantize_info->number_colors == 0) |
| 1143 | break; |
| 1144 | if (((*image)->storage_class == DirectClass) || |
| 1145 | (*image)->colors > quantize_info->number_colors) |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1146 | (void) QuantizeImage(quantize_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1147 | else |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1148 | (void) CompressImageColormap(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1149 | break; |
| 1150 | } |
| 1151 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1152 | { |
| 1153 | ColorspaceType |
| 1154 | colorspace; |
| 1155 | |
| 1156 | (void) SyncImageSettings(mogrify_info,*image); |
| 1157 | if (*option == '+') |
| 1158 | { |
| 1159 | (void) TransformImageColorspace(*image,RGBColorspace); |
| 1160 | InheritException(exception,&(*image)->exception); |
| 1161 | break; |
| 1162 | } |
| 1163 | colorspace=(ColorspaceType) ParseCommandOption( |
| 1164 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 1165 | (void) TransformImageColorspace(*image,colorspace); |
| 1166 | InheritException(exception,&(*image)->exception); |
| 1167 | break; |
| 1168 | } |
| 1169 | if (LocaleCompare("contrast",option+1) == 0) |
| 1170 | { |
| 1171 | (void) SyncImageSettings(mogrify_info,*image); |
| 1172 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1173 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1174 | break; |
| 1175 | } |
| 1176 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1177 | { |
| 1178 | double |
| 1179 | black_point, |
| 1180 | white_point; |
| 1181 | |
| 1182 | MagickStatusType |
| 1183 | flags; |
| 1184 | |
| 1185 | /* |
| 1186 | Contrast stretch image. |
| 1187 | */ |
| 1188 | (void) SyncImageSettings(mogrify_info,*image); |
| 1189 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1190 | black_point=geometry_info.rho; |
| 1191 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1192 | black_point; |
| 1193 | if ((flags & PercentValue) != 0) |
| 1194 | { |
| 1195 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1196 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1197 | } |
| 1198 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1199 | white_point; |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1200 | (void) ContrastStretchImage(*image,black_point,white_point, |
| 1201 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1202 | InheritException(exception,&(*image)->exception); |
| 1203 | break; |
| 1204 | } |
| 1205 | if (LocaleCompare("convolve",option+1) == 0) |
| 1206 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1207 | KernelInfo |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1208 | *kernel_info; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1209 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1210 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1211 | kernel_info=AcquireKernelInfo(argv[i+1]); |
| 1212 | if (kernel_info == (KernelInfo *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1213 | break; |
cristy | 0a92238 | 2011-07-16 15:30:34 +0000 | [diff] [blame] | 1214 | kernel_info->bias=(*image)->bias; |
cristy | 5e6be1e | 2011-07-16 01:23:39 +0000 | [diff] [blame] | 1215 | mogrify_image=ConvolveImage(*image,kernel_info,exception); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1216 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1217 | break; |
| 1218 | } |
| 1219 | if (LocaleCompare("crop",option+1) == 0) |
| 1220 | { |
| 1221 | /* |
| 1222 | Crop a image to a smaller size |
| 1223 | */ |
| 1224 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1225 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1226 | break; |
| 1227 | } |
| 1228 | if (LocaleCompare("cycle",option+1) == 0) |
| 1229 | { |
| 1230 | /* |
| 1231 | Cycle an image colormap. |
| 1232 | */ |
| 1233 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1234 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]), |
| 1235 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1236 | break; |
| 1237 | } |
| 1238 | break; |
| 1239 | } |
| 1240 | case 'd': |
| 1241 | { |
| 1242 | if (LocaleCompare("decipher",option+1) == 0) |
| 1243 | { |
| 1244 | StringInfo |
| 1245 | *passkey; |
| 1246 | |
| 1247 | /* |
| 1248 | Decipher pixels. |
| 1249 | */ |
| 1250 | (void) SyncImageSettings(mogrify_info,*image); |
| 1251 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1252 | if (passkey != (StringInfo *) NULL) |
| 1253 | { |
| 1254 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1255 | passkey=DestroyStringInfo(passkey); |
| 1256 | } |
| 1257 | break; |
| 1258 | } |
| 1259 | if (LocaleCompare("density",option+1) == 0) |
| 1260 | { |
| 1261 | /* |
| 1262 | Set image density. |
| 1263 | */ |
| 1264 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1265 | break; |
| 1266 | } |
| 1267 | if (LocaleCompare("depth",option+1) == 0) |
| 1268 | { |
| 1269 | (void) SyncImageSettings(mogrify_info,*image); |
| 1270 | if (*option == '+') |
| 1271 | { |
| 1272 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH); |
| 1273 | break; |
| 1274 | } |
| 1275 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1])); |
| 1276 | break; |
| 1277 | } |
| 1278 | if (LocaleCompare("deskew",option+1) == 0) |
| 1279 | { |
| 1280 | double |
| 1281 | threshold; |
| 1282 | |
| 1283 | /* |
| 1284 | Straighten the image. |
| 1285 | */ |
| 1286 | (void) SyncImageSettings(mogrify_info,*image); |
| 1287 | if (*option == '+') |
| 1288 | threshold=40.0*QuantumRange/100.0; |
| 1289 | else |
| 1290 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 1291 | mogrify_image=DeskewImage(*image,threshold,exception); |
| 1292 | break; |
| 1293 | } |
| 1294 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1295 | { |
| 1296 | /* |
| 1297 | Reduce the speckles within an image. |
| 1298 | */ |
| 1299 | (void) SyncImageSettings(mogrify_info,*image); |
| 1300 | mogrify_image=DespeckleImage(*image,exception); |
| 1301 | break; |
| 1302 | } |
| 1303 | if (LocaleCompare("display",option+1) == 0) |
| 1304 | { |
| 1305 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1306 | break; |
| 1307 | } |
| 1308 | if (LocaleCompare("distort",option+1) == 0) |
| 1309 | { |
| 1310 | char |
| 1311 | *args, |
| 1312 | token[MaxTextExtent]; |
| 1313 | |
| 1314 | const char |
| 1315 | *p; |
| 1316 | |
| 1317 | DistortImageMethod |
| 1318 | method; |
| 1319 | |
| 1320 | double |
| 1321 | *arguments; |
| 1322 | |
| 1323 | register ssize_t |
| 1324 | x; |
| 1325 | |
| 1326 | size_t |
| 1327 | number_arguments; |
| 1328 | |
| 1329 | /* |
| 1330 | Distort image. |
| 1331 | */ |
| 1332 | (void) SyncImageSettings(mogrify_info,*image); |
| 1333 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, |
| 1334 | MagickFalse,argv[i+1]); |
| 1335 | if ( method == ResizeDistortion ) |
| 1336 | { |
| 1337 | /* Special Case - Argument is actually a resize geometry! |
| 1338 | ** Convert that to an appropriate distortion argument array. |
| 1339 | */ |
| 1340 | double |
| 1341 | resize_args[2]; |
| 1342 | (void) ParseRegionGeometry(*image,argv[i+2],&geometry, |
| 1343 | exception); |
| 1344 | resize_args[0]=(double)geometry.width; |
| 1345 | resize_args[1]=(double)geometry.height; |
| 1346 | mogrify_image=DistortImage(*image,method,(size_t)2, |
| 1347 | resize_args,MagickTrue,exception); |
| 1348 | break; |
| 1349 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1350 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1351 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1352 | if (args == (char *) NULL) |
| 1353 | break; |
| 1354 | p=(char *) args; |
| 1355 | for (x=0; *p != '\0'; x++) |
| 1356 | { |
| 1357 | GetMagickToken(p,&p,token); |
| 1358 | if (*token == ',') |
| 1359 | GetMagickToken(p,&p,token); |
| 1360 | } |
| 1361 | number_arguments=(size_t) x; |
| 1362 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1363 | sizeof(*arguments)); |
| 1364 | if (arguments == (double *) NULL) |
| 1365 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1366 | "MemoryAllocationFailed",(*image)->filename); |
| 1367 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1368 | sizeof(*arguments)); |
| 1369 | p=(char *) args; |
| 1370 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 1371 | { |
| 1372 | GetMagickToken(p,&p,token); |
| 1373 | if (*token == ',') |
| 1374 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1375 | arguments[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1376 | } |
| 1377 | args=DestroyString(args); |
| 1378 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
| 1379 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1380 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1381 | break; |
| 1382 | } |
| 1383 | if (LocaleCompare("dither",option+1) == 0) |
| 1384 | { |
| 1385 | if (*option == '+') |
| 1386 | { |
| 1387 | quantize_info->dither=MagickFalse; |
| 1388 | break; |
| 1389 | } |
| 1390 | quantize_info->dither=MagickTrue; |
| 1391 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
| 1392 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1393 | if (quantize_info->dither_method == NoDitherMethod) |
| 1394 | quantize_info->dither=MagickFalse; |
| 1395 | break; |
| 1396 | } |
| 1397 | if (LocaleCompare("draw",option+1) == 0) |
| 1398 | { |
| 1399 | /* |
| 1400 | Draw image. |
| 1401 | */ |
| 1402 | (void) SyncImageSettings(mogrify_info,*image); |
| 1403 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1404 | (void) DrawImage(*image,draw_info,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1405 | break; |
| 1406 | } |
| 1407 | break; |
| 1408 | } |
| 1409 | case 'e': |
| 1410 | { |
| 1411 | if (LocaleCompare("edge",option+1) == 0) |
| 1412 | { |
| 1413 | /* |
| 1414 | Enhance edges in the image. |
| 1415 | */ |
| 1416 | (void) SyncImageSettings(mogrify_info,*image); |
| 1417 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1418 | if ((flags & SigmaValue) == 0) |
| 1419 | geometry_info.sigma=1.0; |
cristy | 8ae632d | 2011-09-05 17:29:53 +0000 | [diff] [blame] | 1420 | mogrify_image=EdgeImage(*image,geometry_info.rho, |
| 1421 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1422 | break; |
| 1423 | } |
| 1424 | if (LocaleCompare("emboss",option+1) == 0) |
| 1425 | { |
| 1426 | /* |
| 1427 | Gaussian embossen image. |
| 1428 | */ |
| 1429 | (void) SyncImageSettings(mogrify_info,*image); |
| 1430 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1431 | if ((flags & SigmaValue) == 0) |
| 1432 | geometry_info.sigma=1.0; |
| 1433 | mogrify_image=EmbossImage(*image,geometry_info.rho, |
| 1434 | geometry_info.sigma,exception); |
| 1435 | break; |
| 1436 | } |
| 1437 | if (LocaleCompare("encipher",option+1) == 0) |
| 1438 | { |
| 1439 | StringInfo |
| 1440 | *passkey; |
| 1441 | |
| 1442 | /* |
| 1443 | Encipher pixels. |
| 1444 | */ |
| 1445 | (void) SyncImageSettings(mogrify_info,*image); |
| 1446 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1447 | if (passkey != (StringInfo *) NULL) |
| 1448 | { |
| 1449 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1450 | passkey=DestroyStringInfo(passkey); |
| 1451 | } |
| 1452 | break; |
| 1453 | } |
| 1454 | if (LocaleCompare("encoding",option+1) == 0) |
| 1455 | { |
| 1456 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1457 | break; |
| 1458 | } |
| 1459 | if (LocaleCompare("enhance",option+1) == 0) |
| 1460 | { |
| 1461 | /* |
| 1462 | Enhance image. |
| 1463 | */ |
| 1464 | (void) SyncImageSettings(mogrify_info,*image); |
| 1465 | mogrify_image=EnhanceImage(*image,exception); |
| 1466 | break; |
| 1467 | } |
| 1468 | if (LocaleCompare("equalize",option+1) == 0) |
| 1469 | { |
| 1470 | /* |
| 1471 | Equalize image. |
| 1472 | */ |
| 1473 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 6d8c3d7 | 2011-08-22 01:20:01 +0000 | [diff] [blame] | 1474 | (void) EqualizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1475 | break; |
| 1476 | } |
| 1477 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1478 | { |
| 1479 | double |
| 1480 | constant; |
| 1481 | |
| 1482 | MagickEvaluateOperator |
| 1483 | op; |
| 1484 | |
| 1485 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1486 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 1487 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1488 | constant=SiPrefixToDouble(argv[i+2],QuantumRange); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1489 | (void) EvaluateImage(*image,op,constant,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1490 | break; |
| 1491 | } |
| 1492 | if (LocaleCompare("extent",option+1) == 0) |
| 1493 | { |
| 1494 | /* |
| 1495 | Set the image extent. |
| 1496 | */ |
| 1497 | (void) SyncImageSettings(mogrify_info,*image); |
| 1498 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1499 | if (geometry.width == 0) |
| 1500 | geometry.width=(*image)->columns; |
| 1501 | if (geometry.height == 0) |
| 1502 | geometry.height=(*image)->rows; |
| 1503 | mogrify_image=ExtentImage(*image,&geometry,exception); |
| 1504 | break; |
| 1505 | } |
| 1506 | break; |
| 1507 | } |
| 1508 | case 'f': |
| 1509 | { |
| 1510 | if (LocaleCompare("family",option+1) == 0) |
| 1511 | { |
| 1512 | if (*option == '+') |
| 1513 | { |
| 1514 | if (draw_info->family != (char *) NULL) |
| 1515 | draw_info->family=DestroyString(draw_info->family); |
| 1516 | break; |
| 1517 | } |
| 1518 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1519 | break; |
| 1520 | } |
| 1521 | if (LocaleCompare("features",option+1) == 0) |
| 1522 | { |
| 1523 | if (*option == '+') |
| 1524 | { |
| 1525 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1526 | break; |
| 1527 | } |
| 1528 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1529 | break; |
| 1530 | } |
| 1531 | if (LocaleCompare("fill",option+1) == 0) |
| 1532 | { |
| 1533 | ExceptionInfo |
| 1534 | *sans; |
| 1535 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1536 | GetPixelInfo(*image,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1537 | if (*option == '+') |
| 1538 | { |
| 1539 | (void) QueryMagickColor("none",&fill,exception); |
| 1540 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 1541 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1542 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1543 | break; |
| 1544 | } |
| 1545 | sans=AcquireExceptionInfo(); |
| 1546 | (void) QueryMagickColor(argv[i+1],&fill,sans); |
| 1547 | status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans); |
| 1548 | sans=DestroyExceptionInfo(sans); |
| 1549 | if (status == MagickFalse) |
| 1550 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 1551 | exception); |
| 1552 | break; |
| 1553 | } |
| 1554 | if (LocaleCompare("flip",option+1) == 0) |
| 1555 | { |
| 1556 | /* |
| 1557 | Flip image scanlines. |
| 1558 | */ |
| 1559 | (void) SyncImageSettings(mogrify_info,*image); |
| 1560 | mogrify_image=FlipImage(*image,exception); |
| 1561 | break; |
| 1562 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1563 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1564 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1565 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1566 | target; |
| 1567 | |
| 1568 | /* |
| 1569 | Floodfill image. |
| 1570 | */ |
| 1571 | (void) SyncImageSettings(mogrify_info,*image); |
| 1572 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1573 | (void) QueryMagickColor(argv[i+2],&target,exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1574 | (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x, |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 1575 | geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1576 | break; |
| 1577 | } |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1578 | if (LocaleCompare("flop",option+1) == 0) |
| 1579 | { |
| 1580 | /* |
| 1581 | Flop image scanlines. |
| 1582 | */ |
| 1583 | (void) SyncImageSettings(mogrify_info,*image); |
| 1584 | mogrify_image=FlopImage(*image,exception); |
| 1585 | break; |
| 1586 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1587 | if (LocaleCompare("font",option+1) == 0) |
| 1588 | { |
| 1589 | if (*option == '+') |
| 1590 | { |
| 1591 | if (draw_info->font != (char *) NULL) |
| 1592 | draw_info->font=DestroyString(draw_info->font); |
| 1593 | break; |
| 1594 | } |
| 1595 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1596 | break; |
| 1597 | } |
| 1598 | if (LocaleCompare("format",option+1) == 0) |
| 1599 | { |
| 1600 | format=argv[i+1]; |
| 1601 | break; |
| 1602 | } |
| 1603 | if (LocaleCompare("frame",option+1) == 0) |
| 1604 | { |
| 1605 | FrameInfo |
| 1606 | frame_info; |
| 1607 | |
| 1608 | /* |
| 1609 | Surround image with an ornamental border. |
| 1610 | */ |
| 1611 | (void) SyncImageSettings(mogrify_info,*image); |
| 1612 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1613 | frame_info.width=geometry.width; |
| 1614 | frame_info.height=geometry.height; |
| 1615 | if ((flags & HeightValue) == 0) |
| 1616 | frame_info.height=geometry.width; |
| 1617 | frame_info.outer_bevel=geometry.x; |
| 1618 | frame_info.inner_bevel=geometry.y; |
| 1619 | frame_info.x=(ssize_t) frame_info.width; |
| 1620 | frame_info.y=(ssize_t) frame_info.height; |
| 1621 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1622 | frame_info.height=(*image)->rows+2*frame_info.height; |
| 1623 | mogrify_image=FrameImage(*image,&frame_info,exception); |
| 1624 | break; |
| 1625 | } |
| 1626 | if (LocaleCompare("function",option+1) == 0) |
| 1627 | { |
| 1628 | char |
| 1629 | *arguments, |
| 1630 | token[MaxTextExtent]; |
| 1631 | |
| 1632 | const char |
| 1633 | *p; |
| 1634 | |
| 1635 | double |
| 1636 | *parameters; |
| 1637 | |
| 1638 | MagickFunction |
| 1639 | function; |
| 1640 | |
| 1641 | register ssize_t |
| 1642 | x; |
| 1643 | |
| 1644 | size_t |
| 1645 | number_parameters; |
| 1646 | |
| 1647 | /* |
| 1648 | Function Modify Image Values |
| 1649 | */ |
| 1650 | (void) SyncImageSettings(mogrify_info,*image); |
| 1651 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, |
| 1652 | MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1653 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1654 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1655 | if (arguments == (char *) NULL) |
| 1656 | break; |
| 1657 | p=(char *) arguments; |
| 1658 | for (x=0; *p != '\0'; x++) |
| 1659 | { |
| 1660 | GetMagickToken(p,&p,token); |
| 1661 | if (*token == ',') |
| 1662 | GetMagickToken(p,&p,token); |
| 1663 | } |
| 1664 | number_parameters=(size_t) x; |
| 1665 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1666 | sizeof(*parameters)); |
| 1667 | if (parameters == (double *) NULL) |
| 1668 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1669 | "MemoryAllocationFailed",(*image)->filename); |
| 1670 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1671 | sizeof(*parameters)); |
| 1672 | p=(char *) arguments; |
| 1673 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
| 1674 | { |
| 1675 | GetMagickToken(p,&p,token); |
| 1676 | if (*token == ',') |
| 1677 | GetMagickToken(p,&p,token); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1678 | parameters[x]=InterpretLocaleValue(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1679 | } |
| 1680 | arguments=DestroyString(arguments); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1681 | (void) FunctionImage(*image,function,number_parameters,parameters, |
| 1682 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1683 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1684 | break; |
| 1685 | } |
| 1686 | break; |
| 1687 | } |
| 1688 | case 'g': |
| 1689 | { |
| 1690 | if (LocaleCompare("gamma",option+1) == 0) |
| 1691 | { |
| 1692 | /* |
| 1693 | Gamma image. |
| 1694 | */ |
| 1695 | (void) SyncImageSettings(mogrify_info,*image); |
| 1696 | if (*option == '+') |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1697 | (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1698 | else |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 1699 | (void) GammaImage(*image,InterpretLocaleValue(argv[i+1], |
| 1700 | (char **) NULL),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1701 | break; |
| 1702 | } |
| 1703 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1704 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1705 | { |
| 1706 | /* |
| 1707 | Gaussian blur image. |
| 1708 | */ |
| 1709 | (void) SyncImageSettings(mogrify_info,*image); |
| 1710 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1711 | if ((flags & SigmaValue) == 0) |
| 1712 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1713 | if ((flags & XiValue) == 0) |
| 1714 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1715 | mogrify_image=GaussianBlurImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1716 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1717 | break; |
| 1718 | } |
| 1719 | if (LocaleCompare("geometry",option+1) == 0) |
| 1720 | { |
| 1721 | /* |
| 1722 | Record Image offset, Resize last image. |
| 1723 | */ |
| 1724 | (void) SyncImageSettings(mogrify_info,*image); |
| 1725 | if (*option == '+') |
| 1726 | { |
| 1727 | if ((*image)->geometry != (char *) NULL) |
| 1728 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1729 | break; |
| 1730 | } |
| 1731 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1732 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1733 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1734 | else |
| 1735 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 1736 | (*image)->filter,(*image)->blur,exception); |
| 1737 | break; |
| 1738 | } |
| 1739 | if (LocaleCompare("gravity",option+1) == 0) |
| 1740 | { |
| 1741 | if (*option == '+') |
| 1742 | { |
| 1743 | draw_info->gravity=UndefinedGravity; |
| 1744 | break; |
| 1745 | } |
| 1746 | draw_info->gravity=(GravityType) ParseCommandOption( |
| 1747 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1748 | break; |
| 1749 | } |
| 1750 | break; |
| 1751 | } |
| 1752 | case 'h': |
| 1753 | { |
| 1754 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1755 | { |
| 1756 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1757 | break; |
| 1758 | } |
| 1759 | break; |
| 1760 | } |
| 1761 | case 'i': |
| 1762 | { |
| 1763 | if (LocaleCompare("identify",option+1) == 0) |
| 1764 | { |
| 1765 | char |
| 1766 | *text; |
| 1767 | |
| 1768 | (void) SyncImageSettings(mogrify_info,*image); |
| 1769 | if (format == (char *) NULL) |
| 1770 | { |
cristy | a403727 | 2011-08-28 15:11:39 +0000 | [diff] [blame] | 1771 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose, |
| 1772 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1773 | break; |
| 1774 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1775 | text=InterpretImageProperties(mogrify_info,*image,format, |
| 1776 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1777 | if (text == (char *) NULL) |
| 1778 | break; |
| 1779 | (void) fputs(text,stdout); |
| 1780 | (void) fputc('\n',stdout); |
| 1781 | text=DestroyString(text); |
| 1782 | break; |
| 1783 | } |
| 1784 | if (LocaleCompare("implode",option+1) == 0) |
| 1785 | { |
| 1786 | /* |
| 1787 | Implode image. |
| 1788 | */ |
| 1789 | (void) SyncImageSettings(mogrify_info,*image); |
| 1790 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1791 | mogrify_image=ImplodeImage(*image,geometry_info.rho,exception); |
| 1792 | break; |
| 1793 | } |
| 1794 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1795 | { |
| 1796 | if (*option == '+') |
| 1797 | (void) ParseGeometry("0",&geometry_info); |
| 1798 | else |
| 1799 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1800 | draw_info->interline_spacing=geometry_info.rho; |
| 1801 | break; |
| 1802 | } |
| 1803 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1804 | { |
| 1805 | if (*option == '+') |
| 1806 | (void) ParseGeometry("0",&geometry_info); |
| 1807 | else |
| 1808 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1809 | draw_info->interword_spacing=geometry_info.rho; |
| 1810 | break; |
| 1811 | } |
| 1812 | break; |
| 1813 | } |
| 1814 | case 'k': |
| 1815 | { |
| 1816 | if (LocaleCompare("kerning",option+1) == 0) |
| 1817 | { |
| 1818 | if (*option == '+') |
| 1819 | (void) ParseGeometry("0",&geometry_info); |
| 1820 | else |
| 1821 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1822 | draw_info->kerning=geometry_info.rho; |
| 1823 | break; |
| 1824 | } |
| 1825 | break; |
| 1826 | } |
| 1827 | case 'l': |
| 1828 | { |
| 1829 | if (LocaleCompare("lat",option+1) == 0) |
| 1830 | { |
| 1831 | /* |
| 1832 | Local adaptive threshold image. |
| 1833 | */ |
| 1834 | (void) SyncImageSettings(mogrify_info,*image); |
| 1835 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1836 | if ((flags & PercentValue) != 0) |
| 1837 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 1838 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
cristy | de5cc63 | 2011-07-18 14:47:00 +0000 | [diff] [blame] | 1839 | geometry_info.rho,(size_t) geometry_info.sigma,(double) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1840 | geometry_info.xi,exception); |
| 1841 | break; |
| 1842 | } |
| 1843 | if (LocaleCompare("level",option+1) == 0) |
| 1844 | { |
| 1845 | MagickRealType |
| 1846 | black_point, |
| 1847 | gamma, |
| 1848 | white_point; |
| 1849 | |
| 1850 | MagickStatusType |
| 1851 | flags; |
| 1852 | |
| 1853 | /* |
| 1854 | Parse levels. |
| 1855 | */ |
| 1856 | (void) SyncImageSettings(mogrify_info,*image); |
| 1857 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1858 | black_point=geometry_info.rho; |
| 1859 | white_point=(MagickRealType) QuantumRange; |
| 1860 | if ((flags & SigmaValue) != 0) |
| 1861 | white_point=geometry_info.sigma; |
| 1862 | gamma=1.0; |
| 1863 | if ((flags & XiValue) != 0) |
| 1864 | gamma=geometry_info.xi; |
| 1865 | if ((flags & PercentValue) != 0) |
| 1866 | { |
| 1867 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 1868 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 1869 | } |
| 1870 | if ((flags & SigmaValue) == 0) |
| 1871 | white_point=(MagickRealType) QuantumRange-black_point; |
| 1872 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1873 | (void) LevelizeImage(*image,black_point,white_point,gamma, |
| 1874 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1875 | else |
cristy | 01e9afd | 2011-08-10 17:38:41 +0000 | [diff] [blame] | 1876 | (void) LevelImage(*image,black_point,white_point,gamma, |
| 1877 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1878 | InheritException(exception,&(*image)->exception); |
| 1879 | break; |
| 1880 | } |
| 1881 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1882 | { |
| 1883 | char |
| 1884 | token[MaxTextExtent]; |
| 1885 | |
| 1886 | const char |
| 1887 | *p; |
| 1888 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1889 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1890 | black_point, |
| 1891 | white_point; |
| 1892 | |
| 1893 | p=(const char *) argv[i+1]; |
| 1894 | GetMagickToken(p,&p,token); /* get black point color */ |
| 1895 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1896 | (void) QueryMagickColor(token,&black_point,exception); |
| 1897 | else |
| 1898 | (void) QueryMagickColor("#000000",&black_point,exception); |
| 1899 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1900 | GetMagickToken(p,&p,token); |
| 1901 | if (*token == '\0') |
| 1902 | white_point=black_point; /* set everything to that color */ |
| 1903 | else |
| 1904 | { |
| 1905 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 1906 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 1907 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1908 | (void) QueryMagickColor(token,&white_point,exception); |
| 1909 | else |
| 1910 | (void) QueryMagickColor("#ffffff",&white_point,exception); |
| 1911 | } |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 1912 | (void) LevelImageColors(*image,&black_point,&white_point, |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1913 | *option == '+' ? MagickTrue : MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1914 | break; |
| 1915 | } |
| 1916 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 1917 | { |
| 1918 | double |
| 1919 | black_point, |
| 1920 | white_point; |
| 1921 | |
| 1922 | MagickStatusType |
| 1923 | flags; |
| 1924 | |
| 1925 | (void) SyncImageSettings(mogrify_info,*image); |
| 1926 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1927 | black_point=geometry_info.rho; |
| 1928 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 1929 | if ((flags & SigmaValue) != 0) |
| 1930 | white_point=geometry_info.sigma; |
| 1931 | if ((flags & PercentValue) != 0) |
| 1932 | { |
| 1933 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1934 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1935 | } |
| 1936 | if ((flags & SigmaValue) == 0) |
| 1937 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1938 | black_point; |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 1939 | (void) LinearStretchImage(*image,black_point,white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1940 | InheritException(exception,&(*image)->exception); |
| 1941 | break; |
| 1942 | } |
| 1943 | if (LocaleCompare("linewidth",option+1) == 0) |
| 1944 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1945 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 1946 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1947 | break; |
| 1948 | } |
| 1949 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 1950 | { |
| 1951 | /* |
| 1952 | Liquid rescale image. |
| 1953 | */ |
| 1954 | (void) SyncImageSettings(mogrify_info,*image); |
| 1955 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1956 | if ((flags & XValue) == 0) |
| 1957 | geometry.x=1; |
| 1958 | if ((flags & YValue) == 0) |
| 1959 | geometry.y=0; |
| 1960 | mogrify_image=LiquidRescaleImage(*image,geometry.width, |
| 1961 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 1962 | break; |
| 1963 | } |
| 1964 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 1965 | { |
| 1966 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1967 | break; |
| 1968 | } |
| 1969 | break; |
| 1970 | } |
| 1971 | case 'm': |
| 1972 | { |
| 1973 | if (LocaleCompare("map",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1974 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1975 | Image |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1976 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1977 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1978 | /* |
| 1979 | Transform image colors to match this set of colors. |
| 1980 | */ |
| 1981 | (void) SyncImageSettings(mogrify_info,*image); |
| 1982 | if (*option == '+') |
| 1983 | break; |
| 1984 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1985 | if (remap_image == (Image *) NULL) |
| 1986 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1987 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1988 | remap_image=DestroyImage(remap_image); |
| 1989 | break; |
| 1990 | } |
| 1991 | if (LocaleCompare("mask",option+1) == 0) |
| 1992 | { |
| 1993 | Image |
| 1994 | *mask; |
| 1995 | |
| 1996 | (void) SyncImageSettings(mogrify_info,*image); |
| 1997 | if (*option == '+') |
| 1998 | { |
| 1999 | /* |
| 2000 | Remove a mask. |
| 2001 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2002 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2003 | break; |
| 2004 | } |
| 2005 | /* |
| 2006 | Set the image mask. |
| 2007 | */ |
| 2008 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2009 | if (mask == (Image *) NULL) |
| 2010 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2011 | (void) SetImageMask(*image,mask,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2012 | mask=DestroyImage(mask); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2013 | break; |
| 2014 | } |
| 2015 | if (LocaleCompare("matte",option+1) == 0) |
| 2016 | { |
| 2017 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 2018 | SetAlphaChannel : DeactivateAlphaChannel,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2019 | break; |
| 2020 | } |
| 2021 | if (LocaleCompare("median",option+1) == 0) |
| 2022 | { |
| 2023 | /* |
| 2024 | Median filter image. |
| 2025 | */ |
| 2026 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2027 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2028 | if ((flags & SigmaValue) == 0) |
| 2029 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2030 | mogrify_image=StatisticImage(*image,MedianStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2031 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2032 | break; |
| 2033 | } |
| 2034 | if (LocaleCompare("mode",option+1) == 0) |
| 2035 | { |
| 2036 | /* |
| 2037 | Mode image. |
| 2038 | */ |
| 2039 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2040 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2041 | if ((flags & SigmaValue) == 0) |
| 2042 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2043 | mogrify_image=StatisticImage(*image,ModeStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2044 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2045 | break; |
| 2046 | } |
| 2047 | if (LocaleCompare("modulate",option+1) == 0) |
| 2048 | { |
| 2049 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2050 | (void) ModulateImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2051 | break; |
| 2052 | } |
| 2053 | if (LocaleCompare("monitor",option+1) == 0) |
| 2054 | { |
| 2055 | if (*option == '+') |
| 2056 | { |
| 2057 | (void) SetImageProgressMonitor(*image, |
| 2058 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2059 | break; |
| 2060 | } |
| 2061 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2062 | (void *) NULL); |
| 2063 | break; |
| 2064 | } |
| 2065 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2066 | { |
| 2067 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2068 | (void) SetImageType(*image,BilevelType,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2069 | break; |
| 2070 | } |
| 2071 | if (LocaleCompare("morphology",option+1) == 0) |
| 2072 | { |
| 2073 | char |
| 2074 | token[MaxTextExtent]; |
| 2075 | |
| 2076 | const char |
| 2077 | *p; |
| 2078 | |
| 2079 | KernelInfo |
| 2080 | *kernel; |
| 2081 | |
| 2082 | MorphologyMethod |
| 2083 | method; |
| 2084 | |
| 2085 | ssize_t |
| 2086 | iterations; |
| 2087 | |
| 2088 | /* |
| 2089 | Morphological Image Operation |
| 2090 | */ |
| 2091 | (void) SyncImageSettings(mogrify_info,*image); |
| 2092 | p=argv[i+1]; |
| 2093 | GetMagickToken(p,&p,token); |
| 2094 | method=(MorphologyMethod) ParseCommandOption(MagickMorphologyOptions, |
| 2095 | MagickFalse,token); |
| 2096 | iterations=1L; |
| 2097 | GetMagickToken(p,&p,token); |
| 2098 | if ((*p == ':') || (*p == ',')) |
| 2099 | GetMagickToken(p,&p,token); |
| 2100 | if ((*p != '\0')) |
| 2101 | iterations=(ssize_t) StringToLong(p); |
| 2102 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2103 | if (kernel == (KernelInfo *) NULL) |
| 2104 | { |
| 2105 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2106 | OptionError,"UnabletoParseKernel","morphology"); |
| 2107 | status=MagickFalse; |
| 2108 | break; |
| 2109 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2110 | mogrify_image=MorphologyImage(*image,method,iterations,kernel, |
| 2111 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2112 | kernel=DestroyKernelInfo(kernel); |
| 2113 | break; |
| 2114 | } |
| 2115 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2116 | { |
| 2117 | /* |
| 2118 | Motion blur image. |
| 2119 | */ |
| 2120 | (void) SyncImageSettings(mogrify_info,*image); |
| 2121 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2122 | if ((flags & SigmaValue) == 0) |
| 2123 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2124 | mogrify_image=MotionBlurImage(*image,geometry_info.rho, |
cristy | f7ef025 | 2011-09-09 14:50:06 +0000 | [diff] [blame] | 2125 | geometry_info.sigma,geometry_info.xi,geometry_info.psi, |
| 2126 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2127 | break; |
| 2128 | } |
| 2129 | break; |
| 2130 | } |
| 2131 | case 'n': |
| 2132 | { |
| 2133 | if (LocaleCompare("negate",option+1) == 0) |
| 2134 | { |
| 2135 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2136 | (void) NegateImage(*image,*option == '+' ? MagickTrue : |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 2137 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2138 | break; |
| 2139 | } |
| 2140 | if (LocaleCompare("noise",option+1) == 0) |
| 2141 | { |
| 2142 | (void) SyncImageSettings(mogrify_info,*image); |
| 2143 | if (*option == '-') |
| 2144 | { |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2145 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2146 | if ((flags & SigmaValue) == 0) |
| 2147 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2148 | mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2149 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2150 | } |
| 2151 | else |
| 2152 | { |
| 2153 | NoiseType |
| 2154 | noise; |
| 2155 | |
| 2156 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
| 2157 | MagickFalse,argv[i+1]); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 2158 | mogrify_image=AddNoiseImage(*image,noise,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2159 | } |
| 2160 | break; |
| 2161 | } |
| 2162 | if (LocaleCompare("normalize",option+1) == 0) |
| 2163 | { |
| 2164 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 2165 | (void) NormalizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2166 | break; |
| 2167 | } |
| 2168 | break; |
| 2169 | } |
| 2170 | case 'o': |
| 2171 | { |
| 2172 | if (LocaleCompare("opaque",option+1) == 0) |
| 2173 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2174 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2175 | target; |
| 2176 | |
| 2177 | (void) SyncImageSettings(mogrify_info,*image); |
| 2178 | (void) QueryMagickColor(argv[i+1],&target,exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 2179 | (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ? |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 2180 | MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2181 | break; |
| 2182 | } |
| 2183 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2184 | { |
| 2185 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 1302067 | 2011-07-08 02:33:26 +0000 | [diff] [blame] | 2186 | (void) OrderedPosterizeImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2187 | break; |
| 2188 | } |
| 2189 | break; |
| 2190 | } |
| 2191 | case 'p': |
| 2192 | { |
| 2193 | if (LocaleCompare("paint",option+1) == 0) |
| 2194 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2195 | (void) SyncImageSettings(mogrify_info,*image); |
| 2196 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 14973ba | 2011-08-27 23:48:07 +0000 | [diff] [blame] | 2197 | mogrify_image=OilPaintImage(*image,geometry_info.rho, |
| 2198 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2199 | break; |
| 2200 | } |
| 2201 | if (LocaleCompare("pen",option+1) == 0) |
| 2202 | { |
| 2203 | if (*option == '+') |
| 2204 | { |
| 2205 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 2206 | break; |
| 2207 | } |
| 2208 | (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception); |
| 2209 | break; |
| 2210 | } |
| 2211 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2212 | { |
| 2213 | if (*option == '+') |
| 2214 | (void) ParseGeometry("12",&geometry_info); |
| 2215 | else |
| 2216 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2217 | draw_info->pointsize=geometry_info.rho; |
| 2218 | break; |
| 2219 | } |
| 2220 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2221 | { |
| 2222 | double |
| 2223 | angle; |
| 2224 | |
| 2225 | RandomInfo |
| 2226 | *random_info; |
| 2227 | |
| 2228 | /* |
| 2229 | Simulate a Polaroid picture. |
| 2230 | */ |
| 2231 | (void) SyncImageSettings(mogrify_info,*image); |
| 2232 | random_info=AcquireRandomInfo(); |
| 2233 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2234 | random_info=DestroyRandomInfo(random_info); |
| 2235 | if (*option == '-') |
| 2236 | { |
| 2237 | SetGeometryInfo(&geometry_info); |
| 2238 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2239 | angle=geometry_info.rho; |
| 2240 | } |
cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame^] | 2241 | mogrify_image=PolaroidImage(*image,draw_info,angle, |
| 2242 | (*image)->interpolate,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2243 | break; |
| 2244 | } |
| 2245 | if (LocaleCompare("posterize",option+1) == 0) |
| 2246 | { |
| 2247 | /* |
| 2248 | Posterize image. |
| 2249 | */ |
| 2250 | (void) SyncImageSettings(mogrify_info,*image); |
| 2251 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2252 | quantize_info->dither,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2253 | break; |
| 2254 | } |
| 2255 | if (LocaleCompare("preview",option+1) == 0) |
| 2256 | { |
| 2257 | PreviewType |
| 2258 | preview_type; |
| 2259 | |
| 2260 | /* |
| 2261 | Preview image. |
| 2262 | */ |
| 2263 | (void) SyncImageSettings(mogrify_info,*image); |
| 2264 | if (*option == '+') |
| 2265 | preview_type=UndefinedPreview; |
| 2266 | else |
| 2267 | preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions, |
| 2268 | MagickFalse,argv[i+1]); |
| 2269 | mogrify_image=PreviewImage(*image,preview_type,exception); |
| 2270 | break; |
| 2271 | } |
| 2272 | if (LocaleCompare("profile",option+1) == 0) |
| 2273 | { |
| 2274 | const char |
| 2275 | *name; |
| 2276 | |
| 2277 | const StringInfo |
| 2278 | *profile; |
| 2279 | |
| 2280 | Image |
| 2281 | *profile_image; |
| 2282 | |
| 2283 | ImageInfo |
| 2284 | *profile_info; |
| 2285 | |
| 2286 | (void) SyncImageSettings(mogrify_info,*image); |
| 2287 | if (*option == '+') |
| 2288 | { |
| 2289 | /* |
| 2290 | Remove a profile from the image. |
| 2291 | */ |
| 2292 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
| 2293 | NULL,0,MagickTrue); |
| 2294 | InheritException(exception,&(*image)->exception); |
| 2295 | break; |
| 2296 | } |
| 2297 | /* |
| 2298 | Associate a profile with the image. |
| 2299 | */ |
| 2300 | profile_info=CloneImageInfo(mogrify_info); |
| 2301 | profile=GetImageProfile(*image,"iptc"); |
| 2302 | if (profile != (StringInfo *) NULL) |
| 2303 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2304 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2305 | profile_info=DestroyImageInfo(profile_info); |
| 2306 | if (profile_image == (Image *) NULL) |
| 2307 | { |
| 2308 | StringInfo |
| 2309 | *profile; |
| 2310 | |
| 2311 | profile_info=CloneImageInfo(mogrify_info); |
| 2312 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2313 | MaxTextExtent); |
| 2314 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
| 2315 | if (profile != (StringInfo *) NULL) |
| 2316 | { |
| 2317 | (void) ProfileImage(*image,profile_info->magick, |
| 2318 | GetStringInfoDatum(profile),(size_t) |
| 2319 | GetStringInfoLength(profile),MagickFalse); |
| 2320 | profile=DestroyStringInfo(profile); |
| 2321 | } |
| 2322 | profile_info=DestroyImageInfo(profile_info); |
| 2323 | break; |
| 2324 | } |
| 2325 | ResetImageProfileIterator(profile_image); |
| 2326 | name=GetNextImageProfile(profile_image); |
| 2327 | while (name != (const char *) NULL) |
| 2328 | { |
| 2329 | profile=GetImageProfile(profile_image,name); |
| 2330 | if (profile != (StringInfo *) NULL) |
| 2331 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
| 2332 | (size_t) GetStringInfoLength(profile),MagickFalse); |
| 2333 | name=GetNextImageProfile(profile_image); |
| 2334 | } |
| 2335 | profile_image=DestroyImage(profile_image); |
| 2336 | break; |
| 2337 | } |
| 2338 | break; |
| 2339 | } |
| 2340 | case 'q': |
| 2341 | { |
| 2342 | if (LocaleCompare("quantize",option+1) == 0) |
| 2343 | { |
| 2344 | if (*option == '+') |
| 2345 | { |
| 2346 | quantize_info->colorspace=UndefinedColorspace; |
| 2347 | break; |
| 2348 | } |
| 2349 | quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
| 2350 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2351 | break; |
| 2352 | } |
| 2353 | break; |
| 2354 | } |
| 2355 | case 'r': |
| 2356 | { |
| 2357 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2358 | { |
| 2359 | /* |
| 2360 | Radial blur image. |
| 2361 | */ |
| 2362 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 6435bd9 | 2011-09-10 02:10:07 +0000 | [diff] [blame] | 2363 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2364 | mogrify_image=RadialBlurImage(*image,geometry_info.rho, |
| 2365 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2366 | break; |
| 2367 | } |
| 2368 | if (LocaleCompare("raise",option+1) == 0) |
| 2369 | { |
| 2370 | /* |
| 2371 | Surround image with a raise of solid color. |
| 2372 | */ |
| 2373 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2374 | if ((flags & SigmaValue) == 0) |
| 2375 | geometry.height=geometry.width; |
| 2376 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
cristy | 6170ac3 | 2011-08-28 14:15:37 +0000 | [diff] [blame] | 2377 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2378 | break; |
| 2379 | } |
| 2380 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2381 | { |
| 2382 | /* |
| 2383 | Threshold image. |
| 2384 | */ |
| 2385 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2386 | (void) RandomThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2387 | break; |
| 2388 | } |
| 2389 | if (LocaleCompare("recolor",option+1) == 0) |
| 2390 | { |
| 2391 | KernelInfo |
| 2392 | *kernel; |
| 2393 | |
| 2394 | (void) SyncImageSettings(mogrify_info,*image); |
| 2395 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2396 | if (kernel == (KernelInfo *) NULL) |
| 2397 | break; |
| 2398 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 2399 | kernel=DestroyKernelInfo(kernel); |
| 2400 | break; |
| 2401 | } |
| 2402 | if (LocaleCompare("region",option+1) == 0) |
| 2403 | { |
| 2404 | (void) SyncImageSettings(mogrify_info,*image); |
| 2405 | if (region_image != (Image *) NULL) |
| 2406 | { |
| 2407 | /* |
| 2408 | Composite region. |
| 2409 | */ |
| 2410 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2411 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 2412 | region_geometry.x,region_geometry.y); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2413 | InheritException(exception,®ion_image->exception); |
| 2414 | *image=DestroyImage(*image); |
| 2415 | *image=region_image; |
| 2416 | region_image = (Image *) NULL; |
| 2417 | } |
| 2418 | if (*option == '+') |
| 2419 | break; |
| 2420 | /* |
| 2421 | Apply transformations to a selected region of the image. |
| 2422 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2423 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2424 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2425 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2426 | if (mogrify_image == (Image *) NULL) |
| 2427 | break; |
| 2428 | region_image=(*image); |
| 2429 | *image=mogrify_image; |
| 2430 | mogrify_image=(Image *) NULL; |
| 2431 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2432 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2433 | if (LocaleCompare("render",option+1) == 0) |
| 2434 | { |
| 2435 | (void) SyncImageSettings(mogrify_info,*image); |
| 2436 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2437 | break; |
| 2438 | } |
| 2439 | if (LocaleCompare("remap",option+1) == 0) |
| 2440 | { |
| 2441 | Image |
| 2442 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2443 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2444 | /* |
| 2445 | Transform image colors to match this set of colors. |
| 2446 | */ |
| 2447 | (void) SyncImageSettings(mogrify_info,*image); |
| 2448 | if (*option == '+') |
| 2449 | break; |
| 2450 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2451 | if (remap_image == (Image *) NULL) |
| 2452 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2453 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2454 | remap_image=DestroyImage(remap_image); |
| 2455 | break; |
| 2456 | } |
| 2457 | if (LocaleCompare("repage",option+1) == 0) |
| 2458 | { |
| 2459 | if (*option == '+') |
| 2460 | { |
| 2461 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2462 | break; |
| 2463 | } |
| 2464 | (void) ResetImagePage(*image,argv[i+1]); |
| 2465 | InheritException(exception,&(*image)->exception); |
| 2466 | break; |
| 2467 | } |
| 2468 | if (LocaleCompare("resample",option+1) == 0) |
| 2469 | { |
| 2470 | /* |
| 2471 | Resample image. |
| 2472 | */ |
| 2473 | (void) SyncImageSettings(mogrify_info,*image); |
| 2474 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2475 | if ((flags & SigmaValue) == 0) |
| 2476 | geometry_info.sigma=geometry_info.rho; |
| 2477 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
| 2478 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2479 | break; |
| 2480 | } |
| 2481 | if (LocaleCompare("resize",option+1) == 0) |
| 2482 | { |
| 2483 | /* |
| 2484 | Resize image. |
| 2485 | */ |
| 2486 | (void) SyncImageSettings(mogrify_info,*image); |
| 2487 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2488 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2489 | (*image)->filter,(*image)->blur,exception); |
| 2490 | break; |
| 2491 | } |
| 2492 | if (LocaleCompare("roll",option+1) == 0) |
| 2493 | { |
| 2494 | /* |
| 2495 | Roll image. |
| 2496 | */ |
| 2497 | (void) SyncImageSettings(mogrify_info,*image); |
| 2498 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2499 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2500 | break; |
| 2501 | } |
| 2502 | if (LocaleCompare("rotate",option+1) == 0) |
| 2503 | { |
| 2504 | char |
| 2505 | *geometry; |
| 2506 | |
| 2507 | /* |
| 2508 | Check for conditional image rotation. |
| 2509 | */ |
| 2510 | (void) SyncImageSettings(mogrify_info,*image); |
| 2511 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2512 | if ((*image)->columns <= (*image)->rows) |
| 2513 | break; |
| 2514 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2515 | if ((*image)->columns >= (*image)->rows) |
| 2516 | break; |
| 2517 | /* |
| 2518 | Rotate image. |
| 2519 | */ |
| 2520 | geometry=ConstantString(argv[i+1]); |
| 2521 | (void) SubstituteString(&geometry,">",""); |
| 2522 | (void) SubstituteString(&geometry,"<",""); |
| 2523 | (void) ParseGeometry(geometry,&geometry_info); |
| 2524 | geometry=DestroyString(geometry); |
| 2525 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
| 2526 | break; |
| 2527 | } |
| 2528 | break; |
| 2529 | } |
| 2530 | case 's': |
| 2531 | { |
| 2532 | if (LocaleCompare("sample",option+1) == 0) |
| 2533 | { |
| 2534 | /* |
| 2535 | Sample image with pixel replication. |
| 2536 | */ |
| 2537 | (void) SyncImageSettings(mogrify_info,*image); |
| 2538 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2539 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
| 2540 | exception); |
| 2541 | break; |
| 2542 | } |
| 2543 | if (LocaleCompare("scale",option+1) == 0) |
| 2544 | { |
| 2545 | /* |
| 2546 | Resize image. |
| 2547 | */ |
| 2548 | (void) SyncImageSettings(mogrify_info,*image); |
| 2549 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2550 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2551 | exception); |
| 2552 | break; |
| 2553 | } |
| 2554 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2555 | { |
| 2556 | /* |
| 2557 | Selectively blur pixels within a contrast threshold. |
| 2558 | */ |
| 2559 | (void) SyncImageSettings(mogrify_info,*image); |
| 2560 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2561 | if ((flags & PercentValue) != 0) |
| 2562 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2563 | mogrify_image=SelectiveBlurImage(*image,geometry_info.rho, |
cristy | 1e7aa31 | 2011-09-10 20:01:36 +0000 | [diff] [blame] | 2564 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2565 | break; |
| 2566 | } |
| 2567 | if (LocaleCompare("separate",option+1) == 0) |
| 2568 | { |
| 2569 | /* |
| 2570 | Break channels into separate images. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2571 | */ |
| 2572 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 2573 | mogrify_image=SeparateImages(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2574 | break; |
| 2575 | } |
| 2576 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2577 | { |
| 2578 | double |
| 2579 | threshold; |
| 2580 | |
| 2581 | /* |
| 2582 | Sepia-tone image. |
| 2583 | */ |
| 2584 | (void) SyncImageSettings(mogrify_info,*image); |
| 2585 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2586 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
| 2587 | break; |
| 2588 | } |
| 2589 | if (LocaleCompare("segment",option+1) == 0) |
| 2590 | { |
| 2591 | /* |
| 2592 | Segment image. |
| 2593 | */ |
| 2594 | (void) SyncImageSettings(mogrify_info,*image); |
| 2595 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2596 | if ((flags & SigmaValue) == 0) |
| 2597 | geometry_info.sigma=1.0; |
| 2598 | (void) SegmentImage(*image,(*image)->colorspace, |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2599 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 2600 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2601 | break; |
| 2602 | } |
| 2603 | if (LocaleCompare("set",option+1) == 0) |
| 2604 | { |
| 2605 | char |
| 2606 | *value; |
| 2607 | |
| 2608 | /* |
| 2609 | Set image option. |
| 2610 | */ |
| 2611 | if (*option == '+') |
| 2612 | { |
| 2613 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2614 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2615 | else |
| 2616 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2617 | { |
| 2618 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
| 2619 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2620 | } |
| 2621 | else |
| 2622 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2623 | break; |
| 2624 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2625 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2626 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2627 | if (value == (char *) NULL) |
| 2628 | break; |
| 2629 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2630 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2631 | exception); |
| 2632 | else |
| 2633 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2634 | { |
| 2635 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
| 2636 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
| 2637 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2638 | } |
| 2639 | else |
| 2640 | (void) SetImageProperty(*image,argv[i+1],value); |
| 2641 | value=DestroyString(value); |
| 2642 | break; |
| 2643 | } |
| 2644 | if (LocaleCompare("shade",option+1) == 0) |
| 2645 | { |
| 2646 | /* |
| 2647 | Shade image. |
| 2648 | */ |
| 2649 | (void) SyncImageSettings(mogrify_info,*image); |
| 2650 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2651 | if ((flags & SigmaValue) == 0) |
| 2652 | geometry_info.sigma=1.0; |
| 2653 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2654 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2655 | break; |
| 2656 | } |
| 2657 | if (LocaleCompare("shadow",option+1) == 0) |
| 2658 | { |
| 2659 | /* |
| 2660 | Shadow image. |
| 2661 | */ |
| 2662 | (void) SyncImageSettings(mogrify_info,*image); |
| 2663 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2664 | if ((flags & SigmaValue) == 0) |
| 2665 | geometry_info.sigma=1.0; |
| 2666 | if ((flags & XiValue) == 0) |
| 2667 | geometry_info.xi=4.0; |
| 2668 | if ((flags & PsiValue) == 0) |
| 2669 | geometry_info.psi=4.0; |
| 2670 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
| 2671 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 2672 | ceil(geometry_info.psi-0.5),exception); |
| 2673 | break; |
| 2674 | } |
| 2675 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2676 | { |
| 2677 | /* |
| 2678 | Sharpen image. |
| 2679 | */ |
| 2680 | (void) SyncImageSettings(mogrify_info,*image); |
| 2681 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2682 | if ((flags & SigmaValue) == 0) |
| 2683 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2684 | if ((flags & XiValue) == 0) |
| 2685 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2686 | mogrify_image=SharpenImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2687 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2688 | break; |
| 2689 | } |
| 2690 | if (LocaleCompare("shave",option+1) == 0) |
| 2691 | { |
| 2692 | /* |
| 2693 | Shave the image edges. |
| 2694 | */ |
| 2695 | (void) SyncImageSettings(mogrify_info,*image); |
| 2696 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2697 | mogrify_image=ShaveImage(*image,&geometry,exception); |
| 2698 | break; |
| 2699 | } |
| 2700 | if (LocaleCompare("shear",option+1) == 0) |
| 2701 | { |
| 2702 | /* |
| 2703 | Shear image. |
| 2704 | */ |
| 2705 | (void) SyncImageSettings(mogrify_info,*image); |
| 2706 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2707 | if ((flags & SigmaValue) == 0) |
| 2708 | geometry_info.sigma=geometry_info.rho; |
| 2709 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2710 | geometry_info.sigma,exception); |
| 2711 | break; |
| 2712 | } |
| 2713 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2714 | { |
| 2715 | /* |
| 2716 | Sigmoidal non-linearity contrast control. |
| 2717 | */ |
| 2718 | (void) SyncImageSettings(mogrify_info,*image); |
| 2719 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2720 | if ((flags & SigmaValue) == 0) |
| 2721 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 2722 | if ((flags & PercentValue) != 0) |
| 2723 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2724 | 100.0; |
cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 2725 | (void) SigmoidalContrastImage(*image,(*option == '-') ? |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2726 | MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma, |
| 2727 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2728 | break; |
| 2729 | } |
| 2730 | if (LocaleCompare("sketch",option+1) == 0) |
| 2731 | { |
| 2732 | /* |
| 2733 | Sketch image. |
| 2734 | */ |
| 2735 | (void) SyncImageSettings(mogrify_info,*image); |
| 2736 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2737 | if ((flags & SigmaValue) == 0) |
| 2738 | geometry_info.sigma=1.0; |
| 2739 | mogrify_image=SketchImage(*image,geometry_info.rho, |
cristy | f7ef025 | 2011-09-09 14:50:06 +0000 | [diff] [blame] | 2740 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2741 | break; |
| 2742 | } |
| 2743 | if (LocaleCompare("solarize",option+1) == 0) |
| 2744 | { |
| 2745 | double |
| 2746 | threshold; |
| 2747 | |
| 2748 | (void) SyncImageSettings(mogrify_info,*image); |
| 2749 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 2750 | (void) SolarizeImage(*image,threshold,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2751 | break; |
| 2752 | } |
| 2753 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2754 | { |
| 2755 | SparseColorMethod |
| 2756 | method; |
| 2757 | |
| 2758 | char |
| 2759 | *arguments; |
| 2760 | |
| 2761 | /* |
| 2762 | Sparse Color Interpolated Gradient |
| 2763 | */ |
| 2764 | (void) SyncImageSettings(mogrify_info,*image); |
| 2765 | method=(SparseColorMethod) ParseCommandOption( |
| 2766 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2767 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2768 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2769 | if (arguments == (char *) NULL) |
| 2770 | break; |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 2771 | mogrify_image=SparseColorOption(*image,method,arguments, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2772 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2773 | arguments=DestroyString(arguments); |
| 2774 | break; |
| 2775 | } |
| 2776 | if (LocaleCompare("splice",option+1) == 0) |
| 2777 | { |
| 2778 | /* |
| 2779 | Splice a solid color into the image. |
| 2780 | */ |
| 2781 | (void) SyncImageSettings(mogrify_info,*image); |
| 2782 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 2783 | mogrify_image=SpliceImage(*image,&geometry,exception); |
| 2784 | break; |
| 2785 | } |
| 2786 | if (LocaleCompare("spread",option+1) == 0) |
| 2787 | { |
| 2788 | /* |
| 2789 | Spread an image. |
| 2790 | */ |
| 2791 | (void) SyncImageSettings(mogrify_info,*image); |
| 2792 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame^] | 2793 | mogrify_image=SpreadImage(*image,geometry_info.rho, |
| 2794 | (*image)->interpolate,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2795 | break; |
| 2796 | } |
| 2797 | if (LocaleCompare("statistic",option+1) == 0) |
| 2798 | { |
| 2799 | StatisticType |
| 2800 | type; |
| 2801 | |
| 2802 | (void) SyncImageSettings(mogrify_info,*image); |
| 2803 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
| 2804 | MagickFalse,argv[i+1]); |
| 2805 | (void) ParseGeometry(argv[i+2],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2806 | mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho, |
| 2807 | (size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2808 | break; |
| 2809 | } |
| 2810 | if (LocaleCompare("stretch",option+1) == 0) |
| 2811 | { |
| 2812 | if (*option == '+') |
| 2813 | { |
| 2814 | draw_info->stretch=UndefinedStretch; |
| 2815 | break; |
| 2816 | } |
| 2817 | draw_info->stretch=(StretchType) ParseCommandOption( |
| 2818 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2819 | break; |
| 2820 | } |
| 2821 | if (LocaleCompare("strip",option+1) == 0) |
| 2822 | { |
| 2823 | /* |
| 2824 | Strip image of profiles and comments. |
| 2825 | */ |
| 2826 | (void) SyncImageSettings(mogrify_info,*image); |
| 2827 | (void) StripImage(*image); |
| 2828 | InheritException(exception,&(*image)->exception); |
| 2829 | break; |
| 2830 | } |
| 2831 | if (LocaleCompare("stroke",option+1) == 0) |
| 2832 | { |
| 2833 | ExceptionInfo |
| 2834 | *sans; |
| 2835 | |
| 2836 | if (*option == '+') |
| 2837 | { |
| 2838 | (void) QueryColorDatabase("none",&draw_info->stroke,exception); |
| 2839 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2840 | draw_info->stroke_pattern=DestroyImage( |
| 2841 | draw_info->stroke_pattern); |
| 2842 | break; |
| 2843 | } |
| 2844 | sans=AcquireExceptionInfo(); |
| 2845 | status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans); |
| 2846 | sans=DestroyExceptionInfo(sans); |
| 2847 | if (status == MagickFalse) |
| 2848 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2849 | exception); |
| 2850 | break; |
| 2851 | } |
| 2852 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2853 | { |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 2854 | draw_info->stroke_width=InterpretLocaleValue(argv[i+1], |
| 2855 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2856 | break; |
| 2857 | } |
| 2858 | if (LocaleCompare("style",option+1) == 0) |
| 2859 | { |
| 2860 | if (*option == '+') |
| 2861 | { |
| 2862 | draw_info->style=UndefinedStyle; |
| 2863 | break; |
| 2864 | } |
| 2865 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 2866 | MagickFalse,argv[i+1]); |
| 2867 | break; |
| 2868 | } |
| 2869 | if (LocaleCompare("swirl",option+1) == 0) |
| 2870 | { |
| 2871 | /* |
| 2872 | Swirl image. |
| 2873 | */ |
| 2874 | (void) SyncImageSettings(mogrify_info,*image); |
| 2875 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2876 | mogrify_image=SwirlImage(*image,geometry_info.rho,exception); |
| 2877 | break; |
| 2878 | } |
| 2879 | break; |
| 2880 | } |
| 2881 | case 't': |
| 2882 | { |
| 2883 | if (LocaleCompare("threshold",option+1) == 0) |
| 2884 | { |
| 2885 | double |
| 2886 | threshold; |
| 2887 | |
| 2888 | /* |
| 2889 | Threshold image. |
| 2890 | */ |
| 2891 | (void) SyncImageSettings(mogrify_info,*image); |
| 2892 | if (*option == '+') |
anthony | 247a86d | 2011-05-03 13:18:18 +0000 | [diff] [blame] | 2893 | threshold=(double) QuantumRange/2; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2894 | else |
| 2895 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2896 | (void) BilevelImage(*image,threshold); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2897 | InheritException(exception,&(*image)->exception); |
| 2898 | break; |
| 2899 | } |
| 2900 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2901 | { |
| 2902 | /* |
| 2903 | Thumbnail image. |
| 2904 | */ |
| 2905 | (void) SyncImageSettings(mogrify_info,*image); |
| 2906 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2907 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2908 | exception); |
| 2909 | break; |
| 2910 | } |
| 2911 | if (LocaleCompare("tile",option+1) == 0) |
| 2912 | { |
| 2913 | if (*option == '+') |
| 2914 | { |
| 2915 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2916 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2917 | break; |
| 2918 | } |
| 2919 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2920 | exception); |
| 2921 | break; |
| 2922 | } |
| 2923 | if (LocaleCompare("tint",option+1) == 0) |
| 2924 | { |
| 2925 | /* |
| 2926 | Tint the image. |
| 2927 | */ |
| 2928 | (void) SyncImageSettings(mogrify_info,*image); |
| 2929 | mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception); |
| 2930 | break; |
| 2931 | } |
| 2932 | if (LocaleCompare("transform",option+1) == 0) |
| 2933 | { |
| 2934 | /* |
| 2935 | Affine transform image. |
| 2936 | */ |
| 2937 | (void) SyncImageSettings(mogrify_info,*image); |
| 2938 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
| 2939 | exception); |
| 2940 | break; |
| 2941 | } |
| 2942 | if (LocaleCompare("transparent",option+1) == 0) |
| 2943 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2944 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2945 | target; |
| 2946 | |
| 2947 | (void) SyncImageSettings(mogrify_info,*image); |
| 2948 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2949 | (void) TransparentPaintImage(*image,&target,(Quantum) |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 2950 | TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue, |
| 2951 | &(*image)->exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2952 | break; |
| 2953 | } |
| 2954 | if (LocaleCompare("transpose",option+1) == 0) |
| 2955 | { |
| 2956 | /* |
| 2957 | Transpose image scanlines. |
| 2958 | */ |
| 2959 | (void) SyncImageSettings(mogrify_info,*image); |
| 2960 | mogrify_image=TransposeImage(*image,exception); |
| 2961 | break; |
| 2962 | } |
| 2963 | if (LocaleCompare("transverse",option+1) == 0) |
| 2964 | { |
| 2965 | /* |
| 2966 | Transverse image scanlines. |
| 2967 | */ |
| 2968 | (void) SyncImageSettings(mogrify_info,*image); |
| 2969 | mogrify_image=TransverseImage(*image,exception); |
| 2970 | break; |
| 2971 | } |
| 2972 | if (LocaleCompare("treedepth",option+1) == 0) |
| 2973 | { |
| 2974 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
| 2975 | break; |
| 2976 | } |
| 2977 | if (LocaleCompare("trim",option+1) == 0) |
| 2978 | { |
| 2979 | /* |
| 2980 | Trim image. |
| 2981 | */ |
| 2982 | (void) SyncImageSettings(mogrify_info,*image); |
| 2983 | mogrify_image=TrimImage(*image,exception); |
| 2984 | break; |
| 2985 | } |
| 2986 | if (LocaleCompare("type",option+1) == 0) |
| 2987 | { |
| 2988 | ImageType |
| 2989 | type; |
| 2990 | |
| 2991 | (void) SyncImageSettings(mogrify_info,*image); |
| 2992 | if (*option == '+') |
| 2993 | type=UndefinedType; |
| 2994 | else |
| 2995 | type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 2996 | argv[i+1]); |
| 2997 | (*image)->type=UndefinedType; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2998 | (void) SetImageType(*image,type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2999 | break; |
| 3000 | } |
| 3001 | break; |
| 3002 | } |
| 3003 | case 'u': |
| 3004 | { |
| 3005 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3006 | { |
| 3007 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 3008 | exception); |
| 3009 | break; |
| 3010 | } |
| 3011 | if (LocaleCompare("unique",option+1) == 0) |
| 3012 | { |
| 3013 | if (*option == '+') |
| 3014 | { |
| 3015 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
| 3016 | break; |
| 3017 | } |
| 3018 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
| 3019 | (void) SetImageArtifact(*image,"verbose","true"); |
| 3020 | break; |
| 3021 | } |
| 3022 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3023 | { |
| 3024 | /* |
| 3025 | Unique image colors. |
| 3026 | */ |
| 3027 | (void) SyncImageSettings(mogrify_info,*image); |
| 3028 | mogrify_image=UniqueImageColors(*image,exception); |
| 3029 | break; |
| 3030 | } |
| 3031 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3032 | { |
| 3033 | /* |
| 3034 | Unsharp mask image. |
| 3035 | */ |
| 3036 | (void) SyncImageSettings(mogrify_info,*image); |
| 3037 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3038 | if ((flags & SigmaValue) == 0) |
| 3039 | geometry_info.sigma=1.0; |
| 3040 | if ((flags & XiValue) == 0) |
| 3041 | geometry_info.xi=1.0; |
| 3042 | if ((flags & PsiValue) == 0) |
| 3043 | geometry_info.psi=0.05; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3044 | mogrify_image=UnsharpMaskImage(*image,geometry_info.rho, |
| 3045 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3046 | break; |
| 3047 | } |
| 3048 | break; |
| 3049 | } |
| 3050 | case 'v': |
| 3051 | { |
| 3052 | if (LocaleCompare("verbose",option+1) == 0) |
| 3053 | { |
| 3054 | (void) SetImageArtifact(*image,option+1, |
| 3055 | *option == '+' ? "false" : "true"); |
| 3056 | break; |
| 3057 | } |
| 3058 | if (LocaleCompare("vignette",option+1) == 0) |
| 3059 | { |
| 3060 | /* |
| 3061 | Vignette image. |
| 3062 | */ |
| 3063 | (void) SyncImageSettings(mogrify_info,*image); |
| 3064 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3065 | if ((flags & SigmaValue) == 0) |
| 3066 | geometry_info.sigma=1.0; |
| 3067 | if ((flags & XiValue) == 0) |
| 3068 | geometry_info.xi=0.1*(*image)->columns; |
| 3069 | if ((flags & PsiValue) == 0) |
| 3070 | geometry_info.psi=0.1*(*image)->rows; |
| 3071 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
| 3072 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3073 | ceil(geometry_info.psi-0.5),exception); |
| 3074 | break; |
| 3075 | } |
| 3076 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3077 | { |
| 3078 | if (*option == '+') |
| 3079 | { |
| 3080 | (void) SetImageVirtualPixelMethod(*image, |
| 3081 | UndefinedVirtualPixelMethod); |
| 3082 | break; |
| 3083 | } |
| 3084 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3085 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 3086 | argv[i+1])); |
| 3087 | break; |
| 3088 | } |
| 3089 | break; |
| 3090 | } |
| 3091 | case 'w': |
| 3092 | { |
| 3093 | if (LocaleCompare("wave",option+1) == 0) |
| 3094 | { |
| 3095 | /* |
| 3096 | Wave image. |
| 3097 | */ |
| 3098 | (void) SyncImageSettings(mogrify_info,*image); |
| 3099 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3100 | if ((flags & SigmaValue) == 0) |
| 3101 | geometry_info.sigma=1.0; |
| 3102 | mogrify_image=WaveImage(*image,geometry_info.rho, |
cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame^] | 3103 | geometry_info.sigma,(*image)->interpolate,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3104 | break; |
| 3105 | } |
| 3106 | if (LocaleCompare("weight",option+1) == 0) |
| 3107 | { |
| 3108 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
| 3109 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3110 | draw_info->weight=0; |
| 3111 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3112 | draw_info->weight=700; |
| 3113 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3114 | if (draw_info->weight <= 800) |
| 3115 | draw_info->weight+=100; |
| 3116 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3117 | if (draw_info->weight >= 100) |
| 3118 | draw_info->weight-=100; |
| 3119 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3120 | draw_info->weight=400; |
| 3121 | break; |
| 3122 | } |
| 3123 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3124 | { |
| 3125 | /* |
| 3126 | White threshold image. |
| 3127 | */ |
| 3128 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3129 | (void) WhiteThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3130 | InheritException(exception,&(*image)->exception); |
| 3131 | break; |
| 3132 | } |
| 3133 | break; |
| 3134 | } |
| 3135 | default: |
| 3136 | break; |
| 3137 | } |
| 3138 | /* |
| 3139 | Replace current image with any image that was generated |
| 3140 | */ |
| 3141 | if (mogrify_image != (Image *) NULL) |
| 3142 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3143 | i+=count; |
| 3144 | } |
| 3145 | if (region_image != (Image *) NULL) |
| 3146 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3147 | /* |
| 3148 | Composite transformed region onto image. |
| 3149 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3150 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3151 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3152 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 3153 | region_geometry.x,region_geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3154 | InheritException(exception,®ion_image->exception); |
| 3155 | *image=DestroyImage(*image); |
| 3156 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3157 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3158 | } |
| 3159 | /* |
| 3160 | Free resources. |
| 3161 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3162 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3163 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3164 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 3165 | status=(MagickStatusType) ((*image)->exception.severity == |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 3166 | UndefinedException ? 1 : 0); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3167 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3168 | } |
| 3169 | |
| 3170 | /* |
| 3171 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3172 | % % |
| 3173 | % % |
| 3174 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3175 | + 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] | 3176 | % % |
| 3177 | % % |
| 3178 | % % |
| 3179 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3180 | % |
| 3181 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3182 | % transforms include image scaling, image rotation, color reduction, and |
| 3183 | % others. The transmogrified image overwrites the original image. |
| 3184 | % |
| 3185 | % The format of the MogrifyImageCommand method is: |
| 3186 | % |
| 3187 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3188 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3189 | % |
| 3190 | % A description of each parameter follows: |
| 3191 | % |
| 3192 | % o image_info: the image info. |
| 3193 | % |
| 3194 | % o argc: the number of elements in the argument vector. |
| 3195 | % |
| 3196 | % o argv: A text array containing the command line arguments. |
| 3197 | % |
| 3198 | % o metadata: any metadata is returned here. |
| 3199 | % |
| 3200 | % o exception: return any errors or warnings in this structure. |
| 3201 | % |
| 3202 | */ |
| 3203 | |
| 3204 | static MagickBooleanType MogrifyUsage(void) |
| 3205 | { |
| 3206 | static const char |
| 3207 | *miscellaneous[]= |
| 3208 | { |
| 3209 | "-debug events display copious debugging information", |
| 3210 | "-help print program options", |
| 3211 | "-list type print a list of supported option arguments", |
| 3212 | "-log format format of debugging information", |
| 3213 | "-version print version information", |
| 3214 | (char *) NULL |
| 3215 | }, |
| 3216 | *operators[]= |
| 3217 | { |
| 3218 | "-adaptive-blur geometry", |
| 3219 | " adaptively blur pixels; decrease effect near edges", |
| 3220 | "-adaptive-resize geometry", |
| 3221 | " adaptively resize image using 'mesh' interpolation", |
| 3222 | "-adaptive-sharpen geometry", |
| 3223 | " adaptively sharpen pixels; increase effect near edges", |
| 3224 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3225 | " transparent, extract, background, or shape", |
| 3226 | "-annotate geometry text", |
| 3227 | " annotate the image with text", |
| 3228 | "-auto-gamma automagically adjust gamma level of image", |
| 3229 | "-auto-level automagically adjust color levels of image", |
| 3230 | "-auto-orient automagically orient (rotate) image", |
| 3231 | "-bench iterations measure performance", |
| 3232 | "-black-threshold value", |
| 3233 | " force all pixels below the threshold into black", |
| 3234 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3235 | "-blur geometry reduce image noise and reduce detail levels", |
| 3236 | "-border geometry surround image with a border of color", |
| 3237 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3238 | "-brightness-contrast geometry", |
| 3239 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3240 | "-cdl filename color correct with a color decision list", |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 3241 | "-charcoal geometry simulate a charcoal drawing", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3242 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3243 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3244 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3245 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3246 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3247 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3248 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3249 | "-contrast enhance or reduce the image contrast", |
| 3250 | "-contrast-stretch geometry", |
| 3251 | " improve contrast by `stretching' the intensity range", |
| 3252 | "-convolve coefficients", |
| 3253 | " apply a convolution kernel to the image", |
| 3254 | "-cycle amount cycle the image colormap", |
| 3255 | "-decipher filename convert cipher pixels to plain pixels", |
| 3256 | "-deskew threshold straighten an image", |
| 3257 | "-despeckle reduce the speckles within an image", |
| 3258 | "-distort method args", |
| 3259 | " distort images according to given method ad args", |
| 3260 | "-draw string annotate the image with a graphic primitive", |
| 3261 | "-edge radius apply a filter to detect edges in the image", |
| 3262 | "-encipher filename convert plain pixels to cipher pixels", |
| 3263 | "-emboss radius emboss an image", |
| 3264 | "-enhance apply a digital filter to enhance a noisy image", |
| 3265 | "-equalize perform histogram equalization to an image", |
| 3266 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3267 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3268 | "-extent geometry set the image size", |
| 3269 | "-extract geometry extract area from image", |
| 3270 | "-fft implements the discrete Fourier transform (DFT)", |
| 3271 | "-flip flip image vertically", |
| 3272 | "-floodfill geometry color", |
| 3273 | " floodfill the image with color", |
| 3274 | "-flop flop image horizontally", |
| 3275 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3276 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3277 | " apply function over image values", |
| 3278 | "-gamma value level of gamma correction", |
| 3279 | "-gaussian-blur geometry", |
| 3280 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3281 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3282 | "-identify identify the format and characteristics of the image", |
| 3283 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3284 | "-implode amount implode image pixels about the center", |
| 3285 | "-lat geometry local adaptive thresholding", |
| 3286 | "-layers method optimize, merge, or compare image layers", |
| 3287 | "-level value adjust the level of image contrast", |
| 3288 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3289 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3290 | "-linear-stretch geometry", |
| 3291 | " improve contrast by `stretching with saturation'", |
| 3292 | "-liquid-rescale geometry", |
| 3293 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3294 | "-median geometry apply a median filter to the image", |
glennrp | 30d2dc6 | 2011-06-25 03:17:16 +0000 | [diff] [blame] | 3295 | "-mode geometry make each pixel the 'predominant color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3296 | "-modulate value vary the brightness, saturation, and hue", |
| 3297 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3298 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3299 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3300 | "-motion-blur geometry", |
| 3301 | " simulate motion blur", |
| 3302 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3303 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3304 | "-normalize transform image to span the full range of colors", |
| 3305 | "-opaque color change this color to the fill color", |
| 3306 | "-ordered-dither NxN", |
| 3307 | " add a noise pattern to the image with specific", |
| 3308 | " amplitudes", |
| 3309 | "-paint radius simulate an oil painting", |
| 3310 | "-polaroid angle simulate a Polaroid picture", |
| 3311 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3312 | "-profile filename add, delete, or apply an image profile", |
| 3313 | "-quantize colorspace reduce colors in this colorspace", |
| 3314 | "-radial-blur angle radial blur the image", |
| 3315 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3316 | "-random-threshold low,high", |
| 3317 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3318 | "-region geometry apply options to a portion of the image", |
| 3319 | "-render render vector graphics", |
| 3320 | "-repage geometry size and location of an image canvas", |
| 3321 | "-resample geometry change the resolution of an image", |
| 3322 | "-resize geometry resize the image", |
| 3323 | "-roll geometry roll an image vertically or horizontally", |
| 3324 | "-rotate degrees apply Paeth rotation to the image", |
| 3325 | "-sample geometry scale image with pixel sampling", |
| 3326 | "-scale geometry scale the image", |
| 3327 | "-segment values segment an image", |
| 3328 | "-selective-blur geometry", |
| 3329 | " selectively blur pixels within a contrast threshold", |
| 3330 | "-sepia-tone threshold", |
| 3331 | " simulate a sepia-toned photo", |
| 3332 | "-set property value set an image property", |
| 3333 | "-shade degrees shade the image using a distant light source", |
| 3334 | "-shadow geometry simulate an image shadow", |
| 3335 | "-sharpen geometry sharpen the image", |
| 3336 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3337 | "-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] | 3338 | "-sigmoidal-contrast geometry", |
| 3339 | " increase the contrast without saturating highlights or shadows", |
| 3340 | "-sketch geometry simulate a pencil sketch", |
| 3341 | "-solarize threshold negate all pixels above the threshold level", |
| 3342 | "-sparse-color method args", |
| 3343 | " fill in a image based on a few color points", |
| 3344 | "-splice geometry splice the background color into the image", |
| 3345 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3346 | "-statistic type radius", |
| 3347 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3348 | "-strip strip image of all profiles and comments", |
| 3349 | "-swirl degrees swirl image pixels about the center", |
| 3350 | "-threshold value threshold the image", |
| 3351 | "-thumbnail geometry create a thumbnail of the image", |
| 3352 | "-tile filename tile image when filling a graphic primitive", |
| 3353 | "-tint value tint the image with the fill color", |
| 3354 | "-transform affine transform image", |
| 3355 | "-transparent color make this color transparent within the image", |
| 3356 | "-transpose flip image vertically and rotate 90 degrees", |
| 3357 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3358 | "-trim trim image edges", |
| 3359 | "-type type image type", |
| 3360 | "-unique-colors discard all but one of any pixel color", |
| 3361 | "-unsharp geometry sharpen the image", |
| 3362 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3363 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3364 | "-white-threshold value", |
| 3365 | " force all pixels above the threshold into white", |
| 3366 | (char *) NULL |
| 3367 | }, |
| 3368 | *sequence_operators[]= |
| 3369 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3370 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3371 | "-clut apply a color lookup table to the image", |
| 3372 | "-coalesce merge a sequence of images", |
| 3373 | "-combine combine a sequence of images", |
| 3374 | "-composite composite image", |
| 3375 | "-crop geometry cut out a rectangular region of the image", |
| 3376 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3377 | "-evaluate-sequence operator", |
| 3378 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3379 | "-flatten flatten a sequence of images", |
| 3380 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3381 | "-hald-clut apply a Hald color lookup table to the image", |
| 3382 | "-morph value morph an image sequence", |
| 3383 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3384 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3385 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3386 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3387 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3388 | "-write filename write images to this file", |
| 3389 | (char *) NULL |
| 3390 | }, |
| 3391 | *settings[]= |
| 3392 | { |
| 3393 | "-adjoin join images into a single multi-image file", |
| 3394 | "-affine matrix affine transform matrix", |
| 3395 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3396 | "-antialias remove pixel-aliasing", |
| 3397 | "-authenticate password", |
| 3398 | " decipher image with this password", |
| 3399 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3400 | "-background color background color", |
| 3401 | "-bias value add bias when convolving an image", |
| 3402 | "-black-point-compensation", |
| 3403 | " use black point compensation", |
| 3404 | "-blue-primary point chromaticity blue primary point", |
| 3405 | "-bordercolor color border color", |
| 3406 | "-caption string assign a caption to an image", |
| 3407 | "-channel type apply option to select image channels", |
| 3408 | "-colors value preferred number of colors in the image", |
| 3409 | "-colorspace type alternate image colorspace", |
| 3410 | "-comment string annotate image with comment", |
| 3411 | "-compose operator set image composite operator", |
| 3412 | "-compress type type of pixel compression when writing the image", |
| 3413 | "-define format:option", |
| 3414 | " define one or more image format options", |
| 3415 | "-delay value display the next image after pausing", |
| 3416 | "-density geometry horizontal and vertical density of the image", |
| 3417 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3418 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3419 | "-display server get image or font from this X server", |
| 3420 | "-dispose method layer disposal method", |
| 3421 | "-dither method apply error diffusion to image", |
| 3422 | "-encoding type text encoding type", |
| 3423 | "-endian type endianness (MSB or LSB) of the image", |
| 3424 | "-family name render text with this font family", |
| 3425 | "-fill color color to use when filling a graphic primitive", |
| 3426 | "-filter type use this filter when resizing an image", |
| 3427 | "-font name render text with this font", |
| 3428 | "-format \"string\" output formatted image characteristics", |
| 3429 | "-fuzz distance colors within this distance are considered equal", |
| 3430 | "-gravity type horizontal and vertical text placement", |
| 3431 | "-green-primary point chromaticity green primary point", |
| 3432 | "-intent type type of rendering intent when managing the image color", |
| 3433 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3434 | "-interline-spacing value", |
| 3435 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3436 | "-interpolate method pixel color interpolation method", |
| 3437 | "-interword-spacing value", |
| 3438 | " set the space between two words", |
| 3439 | "-kerning value set the space between two letters", |
| 3440 | "-label string assign a label to an image", |
| 3441 | "-limit type value pixel cache resource limit", |
| 3442 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3443 | "-mask filename associate a mask with the image", |
| 3444 | "-mattecolor color frame color", |
| 3445 | "-monitor monitor progress", |
| 3446 | "-orient type image orientation", |
| 3447 | "-page geometry size and location of an image canvas (setting)", |
| 3448 | "-ping efficiently determine image attributes", |
| 3449 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3450 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3451 | "-preview type image preview type", |
| 3452 | "-quality value JPEG/MIFF/PNG compression level", |
| 3453 | "-quiet suppress all warning messages", |
| 3454 | "-red-primary point chromaticity red primary point", |
| 3455 | "-regard-warnings pay attention to warning messages", |
| 3456 | "-remap filename transform image colors to match this set of colors", |
| 3457 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3458 | "-sampling-factor geometry", |
| 3459 | " horizontal and vertical sampling factor", |
| 3460 | "-scene value image scene number", |
| 3461 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3462 | "-size geometry width and height of image", |
| 3463 | "-stretch type render text with this font stretch", |
| 3464 | "-stroke color graphic primitive stroke color", |
| 3465 | "-strokewidth value graphic primitive stroke width", |
| 3466 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3467 | "-synchronize synchronize image to storage device", |
| 3468 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3469 | "-texture filename name of texture to tile onto the image background", |
| 3470 | "-tile-offset geometry", |
| 3471 | " tile offset", |
| 3472 | "-treedepth value color tree depth", |
| 3473 | "-transparent-color color", |
| 3474 | " transparent color", |
| 3475 | "-undercolor color annotation bounding box color", |
| 3476 | "-units type the units of image resolution", |
| 3477 | "-verbose print detailed information about the image", |
| 3478 | "-view FlashPix viewing transforms", |
| 3479 | "-virtual-pixel method", |
| 3480 | " virtual pixel access method", |
| 3481 | "-weight type render text with this font weight", |
| 3482 | "-white-point point chromaticity white point", |
| 3483 | (char *) NULL |
| 3484 | }, |
| 3485 | *stack_operators[]= |
| 3486 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3487 | "-delete indexes delete the image from the image sequence", |
| 3488 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3489 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3490 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3491 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3492 | "-swap indexes swap two images in the image sequence", |
| 3493 | (char *) NULL |
| 3494 | }; |
| 3495 | |
| 3496 | const char |
| 3497 | **p; |
| 3498 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3499 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3500 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3501 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3502 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3503 | GetClientName()); |
| 3504 | (void) printf("\nImage Settings:\n"); |
| 3505 | for (p=settings; *p != (char *) NULL; p++) |
| 3506 | (void) printf(" %s\n",*p); |
| 3507 | (void) printf("\nImage Operators:\n"); |
| 3508 | for (p=operators; *p != (char *) NULL; p++) |
| 3509 | (void) printf(" %s\n",*p); |
| 3510 | (void) printf("\nImage Sequence Operators:\n"); |
| 3511 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3512 | (void) printf(" %s\n",*p); |
| 3513 | (void) printf("\nImage Stack Operators:\n"); |
| 3514 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3515 | (void) printf(" %s\n",*p); |
| 3516 | (void) printf("\nMiscellaneous Options:\n"); |
| 3517 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3518 | (void) printf(" %s\n",*p); |
| 3519 | (void) printf( |
| 3520 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3521 | (void) printf( |
| 3522 | "number. To specify a particular image format, precede the filename\n"); |
| 3523 | (void) printf( |
| 3524 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3525 | (void) printf( |
| 3526 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3527 | (void) printf("'-' for standard input or output.\n"); |
| 3528 | return(MagickFalse); |
| 3529 | } |
| 3530 | |
| 3531 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3532 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3533 | { |
| 3534 | #define DestroyMogrify() \ |
| 3535 | { \ |
| 3536 | if (format != (char *) NULL) \ |
| 3537 | format=DestroyString(format); \ |
| 3538 | if (path != (char *) NULL) \ |
| 3539 | path=DestroyString(path); \ |
| 3540 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3541 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3542 | argv[i]=DestroyString(argv[i]); \ |
| 3543 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3544 | } |
| 3545 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3546 | { \ |
| 3547 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3548 | option); \ |
| 3549 | DestroyMogrify(); \ |
| 3550 | return(MagickFalse); \ |
| 3551 | } |
| 3552 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3553 | { \ |
| 3554 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3555 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3556 | DestroyMogrify(); \ |
| 3557 | return(MagickFalse); \ |
| 3558 | } |
| 3559 | |
| 3560 | char |
| 3561 | *format, |
| 3562 | *option, |
| 3563 | *path; |
| 3564 | |
| 3565 | Image |
| 3566 | *image; |
| 3567 | |
| 3568 | ImageStack |
| 3569 | image_stack[MaxImageStackDepth+1]; |
| 3570 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3571 | MagickBooleanType |
| 3572 | global_colormap; |
| 3573 | |
| 3574 | MagickBooleanType |
| 3575 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3576 | pend, |
| 3577 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3578 | |
| 3579 | MagickStatusType |
| 3580 | status; |
| 3581 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3582 | register ssize_t |
| 3583 | i; |
| 3584 | |
| 3585 | ssize_t |
| 3586 | j, |
| 3587 | k; |
| 3588 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3589 | /* |
| 3590 | Set defaults. |
| 3591 | */ |
| 3592 | assert(image_info != (ImageInfo *) NULL); |
| 3593 | assert(image_info->signature == MagickSignature); |
| 3594 | if (image_info->debug != MagickFalse) |
| 3595 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3596 | assert(exception != (ExceptionInfo *) NULL); |
| 3597 | if (argc == 2) |
| 3598 | { |
| 3599 | option=argv[1]; |
| 3600 | if ((LocaleCompare("version",option+1) == 0) || |
| 3601 | (LocaleCompare("-version",option+1) == 0)) |
| 3602 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3603 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3604 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 3605 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 3606 | GetMagickCopyright()); |
| 3607 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 3608 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3609 | return(MagickFalse); |
| 3610 | } |
| 3611 | } |
| 3612 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3613 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3614 | format=(char *) NULL; |
| 3615 | path=(char *) NULL; |
| 3616 | global_colormap=MagickFalse; |
| 3617 | k=0; |
| 3618 | j=1; |
| 3619 | NewImageStack(); |
| 3620 | option=(char *) NULL; |
| 3621 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3622 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3623 | status=MagickTrue; |
| 3624 | /* |
| 3625 | Parse command line. |
| 3626 | */ |
| 3627 | ReadCommandlLine(argc,&argv); |
| 3628 | status=ExpandFilenames(&argc,&argv); |
| 3629 | if (status == MagickFalse) |
| 3630 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3631 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3632 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3633 | { |
| 3634 | option=argv[i]; |
| 3635 | if (LocaleCompare(option,"(") == 0) |
| 3636 | { |
| 3637 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3638 | if (k == MaxImageStackDepth) |
| 3639 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3640 | option); |
| 3641 | PushImageStack(); |
| 3642 | continue; |
| 3643 | } |
| 3644 | if (LocaleCompare(option,")") == 0) |
| 3645 | { |
| 3646 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3647 | if (k == 0) |
| 3648 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3649 | PopImageStack(); |
| 3650 | continue; |
| 3651 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3652 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3653 | { |
| 3654 | char |
| 3655 | backup_filename[MaxTextExtent], |
| 3656 | *filename; |
| 3657 | |
| 3658 | Image |
| 3659 | *images; |
| 3660 | |
| 3661 | /* |
| 3662 | Option is a file name: begin by reading image from specified file. |
| 3663 | */ |
| 3664 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3665 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3666 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3667 | filename=argv[++i]; |
| 3668 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 3669 | images=ReadImages(image_info,exception); |
| 3670 | status&=(images != (Image *) NULL) && |
| 3671 | (exception->severity < ErrorException); |
| 3672 | if (images == (Image *) NULL) |
| 3673 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3674 | if (format != (char *) NULL) |
| 3675 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3676 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3677 | if (path != (char *) NULL) |
| 3678 | { |
| 3679 | GetPathComponent(option,TailPath,filename); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3680 | (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3681 | path,*DirectorySeparator,filename); |
| 3682 | } |
| 3683 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3684 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3685 | AppendImageStack(images); |
| 3686 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3687 | if (global_colormap != MagickFalse) |
| 3688 | { |
| 3689 | QuantizeInfo |
| 3690 | *quantize_info; |
| 3691 | |
| 3692 | quantize_info=AcquireQuantizeInfo(image_info); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3693 | (void) RemapImages(quantize_info,images,(Image *) NULL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3694 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3695 | } |
| 3696 | *backup_filename='\0'; |
| 3697 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3698 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3699 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3700 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3701 | i; |
| 3702 | |
| 3703 | /* |
| 3704 | Rename image file as backup. |
| 3705 | */ |
| 3706 | (void) CopyMagickString(backup_filename,image->filename, |
| 3707 | MaxTextExtent); |
| 3708 | for (i=0; i < 6; i++) |
| 3709 | { |
| 3710 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3711 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3712 | break; |
| 3713 | } |
| 3714 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
| 3715 | (rename(image->filename,backup_filename) != 0)) |
| 3716 | *backup_filename='\0'; |
| 3717 | } |
| 3718 | /* |
| 3719 | Write transmogrified image to disk. |
| 3720 | */ |
| 3721 | image_info->synchronize=MagickTrue; |
| 3722 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3723 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
| 3724 | (void) remove(backup_filename); |
| 3725 | RemoveAllImageStack(); |
| 3726 | continue; |
| 3727 | } |
| 3728 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3729 | switch (*(option+1)) |
| 3730 | { |
| 3731 | case 'a': |
| 3732 | { |
| 3733 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3734 | { |
| 3735 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3736 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3737 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3738 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3739 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3740 | break; |
| 3741 | } |
| 3742 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3743 | { |
| 3744 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3745 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3746 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3747 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3748 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3749 | break; |
| 3750 | } |
| 3751 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3752 | { |
| 3753 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3754 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3755 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3756 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3757 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3758 | break; |
| 3759 | } |
| 3760 | if (LocaleCompare("affine",option+1) == 0) |
| 3761 | { |
| 3762 | if (*option == '+') |
| 3763 | break; |
| 3764 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3765 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3766 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3767 | break; |
| 3768 | } |
| 3769 | if (LocaleCompare("alpha",option+1) == 0) |
| 3770 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3771 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3772 | type; |
| 3773 | |
| 3774 | if (*option == '+') |
| 3775 | break; |
| 3776 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3777 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3778 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3779 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3780 | if (type < 0) |
| 3781 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3782 | argv[i]); |
| 3783 | break; |
| 3784 | } |
| 3785 | if (LocaleCompare("annotate",option+1) == 0) |
| 3786 | { |
| 3787 | if (*option == '+') |
| 3788 | break; |
| 3789 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3790 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3791 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3792 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3793 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3794 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3795 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3796 | i++; |
| 3797 | break; |
| 3798 | } |
| 3799 | if (LocaleCompare("antialias",option+1) == 0) |
| 3800 | break; |
| 3801 | if (LocaleCompare("append",option+1) == 0) |
| 3802 | break; |
| 3803 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3804 | { |
| 3805 | if (*option == '+') |
| 3806 | break; |
| 3807 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3808 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3809 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3810 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3811 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3812 | break; |
| 3813 | } |
| 3814 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3815 | { |
| 3816 | if (*option == '+') |
| 3817 | break; |
| 3818 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3819 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3820 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3821 | break; |
| 3822 | } |
| 3823 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3824 | break; |
| 3825 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3826 | break; |
| 3827 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3828 | break; |
| 3829 | if (LocaleCompare("average",option+1) == 0) |
| 3830 | break; |
| 3831 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3832 | } |
| 3833 | case 'b': |
| 3834 | { |
| 3835 | if (LocaleCompare("background",option+1) == 0) |
| 3836 | { |
| 3837 | if (*option == '+') |
| 3838 | break; |
| 3839 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3840 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3841 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3842 | break; |
| 3843 | } |
| 3844 | if (LocaleCompare("bias",option+1) == 0) |
| 3845 | { |
| 3846 | if (*option == '+') |
| 3847 | break; |
| 3848 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3849 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3850 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3851 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3852 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3853 | break; |
| 3854 | } |
| 3855 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 3856 | break; |
| 3857 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 3858 | { |
| 3859 | if (*option == '+') |
| 3860 | break; |
| 3861 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3862 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3863 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3864 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3865 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3866 | break; |
| 3867 | } |
| 3868 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3869 | { |
| 3870 | if (*option == '+') |
| 3871 | break; |
| 3872 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3873 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3874 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3875 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3876 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3877 | break; |
| 3878 | } |
| 3879 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3880 | { |
| 3881 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3882 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3883 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3884 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3885 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3886 | break; |
| 3887 | } |
| 3888 | if (LocaleCompare("blur",option+1) == 0) |
| 3889 | { |
| 3890 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3891 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3892 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3893 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3894 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3895 | break; |
| 3896 | } |
| 3897 | if (LocaleCompare("border",option+1) == 0) |
| 3898 | { |
| 3899 | if (*option == '+') |
| 3900 | break; |
| 3901 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3902 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3903 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3904 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3905 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3906 | break; |
| 3907 | } |
| 3908 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3909 | { |
| 3910 | if (*option == '+') |
| 3911 | break; |
| 3912 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3913 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3914 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3915 | break; |
| 3916 | } |
| 3917 | if (LocaleCompare("box",option+1) == 0) |
| 3918 | { |
| 3919 | if (*option == '+') |
| 3920 | break; |
| 3921 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3922 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3923 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3924 | break; |
| 3925 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3926 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 3927 | { |
| 3928 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3929 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3930 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3931 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3932 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3933 | break; |
| 3934 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3935 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3936 | } |
| 3937 | case 'c': |
| 3938 | { |
| 3939 | if (LocaleCompare("cache",option+1) == 0) |
| 3940 | { |
| 3941 | if (*option == '+') |
| 3942 | break; |
| 3943 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3944 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3945 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3946 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3947 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3948 | break; |
| 3949 | } |
| 3950 | if (LocaleCompare("caption",option+1) == 0) |
| 3951 | { |
| 3952 | if (*option == '+') |
| 3953 | break; |
| 3954 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3955 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3956 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3957 | break; |
| 3958 | } |
| 3959 | if (LocaleCompare("channel",option+1) == 0) |
| 3960 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3961 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3962 | channel; |
| 3963 | |
| 3964 | if (*option == '+') |
| 3965 | break; |
| 3966 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3967 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3968 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3969 | channel=ParseChannelOption(argv[i]); |
| 3970 | if (channel < 0) |
| 3971 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 3972 | argv[i]); |
| 3973 | break; |
| 3974 | } |
| 3975 | if (LocaleCompare("cdl",option+1) == 0) |
| 3976 | { |
| 3977 | if (*option == '+') |
| 3978 | break; |
| 3979 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3980 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3981 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3982 | break; |
| 3983 | } |
| 3984 | if (LocaleCompare("charcoal",option+1) == 0) |
| 3985 | { |
| 3986 | if (*option == '+') |
| 3987 | break; |
| 3988 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3989 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3990 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3991 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3992 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3993 | break; |
| 3994 | } |
| 3995 | if (LocaleCompare("chop",option+1) == 0) |
| 3996 | { |
| 3997 | if (*option == '+') |
| 3998 | break; |
| 3999 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4000 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4001 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4002 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4003 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4004 | break; |
| 4005 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4006 | if (LocaleCompare("clamp",option+1) == 0) |
| 4007 | break; |
| 4008 | if (LocaleCompare("clip",option+1) == 0) |
| 4009 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4010 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4011 | { |
| 4012 | if (*option == '+') |
| 4013 | break; |
| 4014 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4015 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4016 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4017 | break; |
| 4018 | } |
| 4019 | if (LocaleCompare("clut",option+1) == 0) |
| 4020 | break; |
| 4021 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4022 | break; |
| 4023 | if (LocaleCompare("colorize",option+1) == 0) |
| 4024 | { |
| 4025 | if (*option == '+') |
| 4026 | break; |
| 4027 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4028 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4029 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4030 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4031 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4032 | break; |
| 4033 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4034 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4035 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4036 | KernelInfo |
| 4037 | *kernel_info; |
| 4038 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4039 | if (*option == '+') |
| 4040 | break; |
| 4041 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4042 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4043 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4044 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4045 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4046 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4047 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4048 | break; |
| 4049 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4050 | if (LocaleCompare("colors",option+1) == 0) |
| 4051 | { |
| 4052 | if (*option == '+') |
| 4053 | break; |
| 4054 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4055 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4056 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4057 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4058 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4059 | break; |
| 4060 | } |
| 4061 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4062 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4063 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4064 | colorspace; |
| 4065 | |
| 4066 | if (*option == '+') |
| 4067 | break; |
| 4068 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4069 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4070 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4071 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4072 | argv[i]); |
| 4073 | if (colorspace < 0) |
| 4074 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4075 | argv[i]); |
| 4076 | break; |
| 4077 | } |
| 4078 | if (LocaleCompare("combine",option+1) == 0) |
| 4079 | break; |
| 4080 | if (LocaleCompare("comment",option+1) == 0) |
| 4081 | { |
| 4082 | if (*option == '+') |
| 4083 | break; |
| 4084 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4085 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4086 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4087 | break; |
| 4088 | } |
| 4089 | if (LocaleCompare("composite",option+1) == 0) |
| 4090 | break; |
| 4091 | if (LocaleCompare("compress",option+1) == 0) |
| 4092 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4093 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4094 | compress; |
| 4095 | |
| 4096 | if (*option == '+') |
| 4097 | break; |
| 4098 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4099 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4100 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4101 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4102 | argv[i]); |
| 4103 | if (compress < 0) |
| 4104 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4105 | argv[i]); |
| 4106 | break; |
| 4107 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4108 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4109 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4110 | if (LocaleCompare("contrast",option+1) == 0) |
| 4111 | break; |
| 4112 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4113 | { |
| 4114 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4115 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4116 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4117 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4118 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4119 | break; |
| 4120 | } |
| 4121 | if (LocaleCompare("convolve",option+1) == 0) |
| 4122 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4123 | KernelInfo |
| 4124 | *kernel_info; |
| 4125 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4126 | if (*option == '+') |
| 4127 | break; |
| 4128 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4129 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4130 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4131 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4132 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4133 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4134 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4135 | break; |
| 4136 | } |
| 4137 | if (LocaleCompare("crop",option+1) == 0) |
| 4138 | { |
| 4139 | if (*option == '+') |
| 4140 | break; |
| 4141 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4142 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4143 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4144 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4145 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4146 | break; |
| 4147 | } |
| 4148 | if (LocaleCompare("cycle",option+1) == 0) |
| 4149 | { |
| 4150 | if (*option == '+') |
| 4151 | break; |
| 4152 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4153 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4154 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4155 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4156 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4157 | break; |
| 4158 | } |
| 4159 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4160 | } |
| 4161 | case 'd': |
| 4162 | { |
| 4163 | if (LocaleCompare("decipher",option+1) == 0) |
| 4164 | { |
| 4165 | if (*option == '+') |
| 4166 | break; |
| 4167 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4168 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4169 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4170 | break; |
| 4171 | } |
| 4172 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4173 | break; |
| 4174 | if (LocaleCompare("debug",option+1) == 0) |
| 4175 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4176 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4177 | event; |
| 4178 | |
| 4179 | if (*option == '+') |
| 4180 | break; |
| 4181 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4182 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4183 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4184 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4185 | if (event < 0) |
| 4186 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4187 | argv[i]); |
| 4188 | (void) SetLogEventMask(argv[i]); |
| 4189 | break; |
| 4190 | } |
| 4191 | if (LocaleCompare("define",option+1) == 0) |
| 4192 | { |
| 4193 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4194 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4195 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4196 | if (*option == '+') |
| 4197 | { |
| 4198 | const char |
| 4199 | *define; |
| 4200 | |
| 4201 | define=GetImageOption(image_info,argv[i]); |
| 4202 | if (define == (const char *) NULL) |
| 4203 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4204 | break; |
| 4205 | } |
| 4206 | break; |
| 4207 | } |
| 4208 | if (LocaleCompare("delay",option+1) == 0) |
| 4209 | { |
| 4210 | if (*option == '+') |
| 4211 | break; |
| 4212 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4213 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4214 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4215 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4216 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4217 | break; |
| 4218 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4219 | if (LocaleCompare("delete",option+1) == 0) |
| 4220 | { |
| 4221 | if (*option == '+') |
| 4222 | break; |
| 4223 | i++; |
| 4224 | if (i == (ssize_t) (argc-1)) |
| 4225 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4226 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4227 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4228 | break; |
| 4229 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4230 | if (LocaleCompare("density",option+1) == 0) |
| 4231 | { |
| 4232 | if (*option == '+') |
| 4233 | break; |
| 4234 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4235 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4236 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4237 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4238 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4239 | break; |
| 4240 | } |
| 4241 | if (LocaleCompare("depth",option+1) == 0) |
| 4242 | { |
| 4243 | if (*option == '+') |
| 4244 | break; |
| 4245 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4246 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4247 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4248 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4249 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4250 | break; |
| 4251 | } |
| 4252 | if (LocaleCompare("deskew",option+1) == 0) |
| 4253 | { |
| 4254 | if (*option == '+') |
| 4255 | break; |
| 4256 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4257 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4258 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4259 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4260 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4261 | break; |
| 4262 | } |
| 4263 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4264 | break; |
| 4265 | if (LocaleCompare("dft",option+1) == 0) |
| 4266 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4267 | if (LocaleCompare("direction",option+1) == 0) |
| 4268 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4269 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4270 | direction; |
| 4271 | |
| 4272 | if (*option == '+') |
| 4273 | break; |
| 4274 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4275 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4276 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4277 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4278 | argv[i]); |
| 4279 | if (direction < 0) |
| 4280 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4281 | argv[i]); |
| 4282 | break; |
| 4283 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4284 | if (LocaleCompare("display",option+1) == 0) |
| 4285 | { |
| 4286 | if (*option == '+') |
| 4287 | break; |
| 4288 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4289 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4290 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4291 | break; |
| 4292 | } |
| 4293 | if (LocaleCompare("dispose",option+1) == 0) |
| 4294 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4295 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4296 | dispose; |
| 4297 | |
| 4298 | if (*option == '+') |
| 4299 | break; |
| 4300 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4301 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4302 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4303 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4304 | if (dispose < 0) |
| 4305 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4306 | argv[i]); |
| 4307 | break; |
| 4308 | } |
| 4309 | if (LocaleCompare("distort",option+1) == 0) |
| 4310 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4311 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4312 | op; |
| 4313 | |
| 4314 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4315 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4316 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4317 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4318 | if (op < 0) |
| 4319 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4320 | argv[i]); |
| 4321 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4322 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4323 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4324 | break; |
| 4325 | } |
| 4326 | if (LocaleCompare("dither",option+1) == 0) |
| 4327 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4328 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4329 | method; |
| 4330 | |
| 4331 | if (*option == '+') |
| 4332 | break; |
| 4333 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4334 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4335 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4336 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4337 | if (method < 0) |
| 4338 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4339 | argv[i]); |
| 4340 | break; |
| 4341 | } |
| 4342 | if (LocaleCompare("draw",option+1) == 0) |
| 4343 | { |
| 4344 | if (*option == '+') |
| 4345 | break; |
| 4346 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4347 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4348 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4349 | break; |
| 4350 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4351 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4352 | { |
| 4353 | if (*option == '+') |
| 4354 | break; |
| 4355 | i++; |
| 4356 | if (i == (ssize_t) (argc-1)) |
| 4357 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4358 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4359 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4360 | break; |
| 4361 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4362 | if (LocaleCompare("duration",option+1) == 0) |
| 4363 | { |
| 4364 | if (*option == '+') |
| 4365 | break; |
| 4366 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4367 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4368 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4369 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4370 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4371 | break; |
| 4372 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4373 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4374 | } |
| 4375 | case 'e': |
| 4376 | { |
| 4377 | if (LocaleCompare("edge",option+1) == 0) |
| 4378 | { |
| 4379 | if (*option == '+') |
| 4380 | break; |
| 4381 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4382 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4383 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4384 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4385 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4386 | break; |
| 4387 | } |
| 4388 | if (LocaleCompare("emboss",option+1) == 0) |
| 4389 | { |
| 4390 | if (*option == '+') |
| 4391 | break; |
| 4392 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4393 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4394 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4395 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4396 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4397 | break; |
| 4398 | } |
| 4399 | if (LocaleCompare("encipher",option+1) == 0) |
| 4400 | { |
| 4401 | if (*option == '+') |
| 4402 | break; |
| 4403 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4404 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4405 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4406 | break; |
| 4407 | } |
| 4408 | if (LocaleCompare("encoding",option+1) == 0) |
| 4409 | { |
| 4410 | if (*option == '+') |
| 4411 | break; |
| 4412 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4413 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4414 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4415 | break; |
| 4416 | } |
| 4417 | if (LocaleCompare("endian",option+1) == 0) |
| 4418 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4419 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4420 | endian; |
| 4421 | |
| 4422 | if (*option == '+') |
| 4423 | break; |
| 4424 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4425 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4426 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4427 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4428 | if (endian < 0) |
| 4429 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4430 | argv[i]); |
| 4431 | break; |
| 4432 | } |
| 4433 | if (LocaleCompare("enhance",option+1) == 0) |
| 4434 | break; |
| 4435 | if (LocaleCompare("equalize",option+1) == 0) |
| 4436 | break; |
| 4437 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4438 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4439 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4440 | op; |
| 4441 | |
| 4442 | if (*option == '+') |
| 4443 | break; |
| 4444 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4445 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4446 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4447 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4448 | if (op < 0) |
| 4449 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4450 | argv[i]); |
| 4451 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4452 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4453 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4454 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4455 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4456 | break; |
| 4457 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4458 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4459 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4460 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4461 | op; |
| 4462 | |
| 4463 | if (*option == '+') |
| 4464 | break; |
| 4465 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4466 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4467 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4468 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4469 | if (op < 0) |
| 4470 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4471 | argv[i]); |
| 4472 | break; |
| 4473 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4474 | if (LocaleCompare("extent",option+1) == 0) |
| 4475 | { |
| 4476 | if (*option == '+') |
| 4477 | break; |
| 4478 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4479 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4480 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4481 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4482 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4483 | break; |
| 4484 | } |
| 4485 | if (LocaleCompare("extract",option+1) == 0) |
| 4486 | { |
| 4487 | if (*option == '+') |
| 4488 | break; |
| 4489 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4490 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4491 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4492 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4493 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4494 | break; |
| 4495 | } |
| 4496 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4497 | } |
| 4498 | case 'f': |
| 4499 | { |
| 4500 | if (LocaleCompare("family",option+1) == 0) |
| 4501 | { |
| 4502 | if (*option == '+') |
| 4503 | break; |
| 4504 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4505 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4506 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4507 | break; |
| 4508 | } |
| 4509 | if (LocaleCompare("fill",option+1) == 0) |
| 4510 | { |
| 4511 | if (*option == '+') |
| 4512 | break; |
| 4513 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4514 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4515 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4516 | break; |
| 4517 | } |
| 4518 | if (LocaleCompare("filter",option+1) == 0) |
| 4519 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4520 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4521 | filter; |
| 4522 | |
| 4523 | if (*option == '+') |
| 4524 | break; |
| 4525 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4526 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4527 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4528 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4529 | if (filter < 0) |
| 4530 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4531 | argv[i]); |
| 4532 | break; |
| 4533 | } |
| 4534 | if (LocaleCompare("flatten",option+1) == 0) |
| 4535 | break; |
| 4536 | if (LocaleCompare("flip",option+1) == 0) |
| 4537 | break; |
| 4538 | if (LocaleCompare("flop",option+1) == 0) |
| 4539 | break; |
| 4540 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4541 | { |
| 4542 | if (*option == '+') |
| 4543 | break; |
| 4544 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4545 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4546 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4547 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4548 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4549 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4550 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4551 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4552 | break; |
| 4553 | } |
| 4554 | if (LocaleCompare("font",option+1) == 0) |
| 4555 | { |
| 4556 | if (*option == '+') |
| 4557 | break; |
| 4558 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4559 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4560 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4561 | break; |
| 4562 | } |
| 4563 | if (LocaleCompare("format",option+1) == 0) |
| 4564 | { |
| 4565 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4566 | (void) CloneString(&format,(char *) NULL); |
| 4567 | if (*option == '+') |
| 4568 | break; |
| 4569 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4570 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4571 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4572 | (void) CloneString(&format,argv[i]); |
| 4573 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4574 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4575 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4576 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4577 | if (*image_info->magick == '\0') |
| 4578 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4579 | format); |
| 4580 | break; |
| 4581 | } |
| 4582 | if (LocaleCompare("frame",option+1) == 0) |
| 4583 | { |
| 4584 | if (*option == '+') |
| 4585 | break; |
| 4586 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4587 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4588 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4589 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4590 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4591 | break; |
| 4592 | } |
| 4593 | if (LocaleCompare("function",option+1) == 0) |
| 4594 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4595 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4596 | op; |
| 4597 | |
| 4598 | if (*option == '+') |
| 4599 | break; |
| 4600 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4601 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4602 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4603 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4604 | if (op < 0) |
| 4605 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4606 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4607 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4608 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4609 | break; |
| 4610 | } |
| 4611 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4612 | { |
| 4613 | if (*option == '+') |
| 4614 | break; |
| 4615 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4616 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4617 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4618 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4619 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4620 | break; |
| 4621 | } |
| 4622 | if (LocaleCompare("fx",option+1) == 0) |
| 4623 | { |
| 4624 | if (*option == '+') |
| 4625 | break; |
| 4626 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4627 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4628 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4629 | break; |
| 4630 | } |
| 4631 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4632 | } |
| 4633 | case 'g': |
| 4634 | { |
| 4635 | if (LocaleCompare("gamma",option+1) == 0) |
| 4636 | { |
| 4637 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4638 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4639 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4640 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4641 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4642 | break; |
| 4643 | } |
| 4644 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4645 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4646 | { |
| 4647 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4648 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4649 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4650 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4651 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4652 | break; |
| 4653 | } |
| 4654 | if (LocaleCompare("geometry",option+1) == 0) |
| 4655 | { |
| 4656 | if (*option == '+') |
| 4657 | break; |
| 4658 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4659 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4660 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4661 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4662 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4663 | break; |
| 4664 | } |
| 4665 | if (LocaleCompare("gravity",option+1) == 0) |
| 4666 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4667 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4668 | gravity; |
| 4669 | |
| 4670 | if (*option == '+') |
| 4671 | break; |
| 4672 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4673 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4674 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4675 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4676 | if (gravity < 0) |
| 4677 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4678 | argv[i]); |
| 4679 | break; |
| 4680 | } |
| 4681 | if (LocaleCompare("green-primary",option+1) == 0) |
| 4682 | { |
| 4683 | if (*option == '+') |
| 4684 | break; |
| 4685 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4686 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4687 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4688 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4689 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4690 | break; |
| 4691 | } |
| 4692 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4693 | } |
| 4694 | case 'h': |
| 4695 | { |
| 4696 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4697 | break; |
| 4698 | if ((LocaleCompare("help",option+1) == 0) || |
| 4699 | (LocaleCompare("-help",option+1) == 0)) |
| 4700 | return(MogrifyUsage()); |
| 4701 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4702 | } |
| 4703 | case 'i': |
| 4704 | { |
| 4705 | if (LocaleCompare("identify",option+1) == 0) |
| 4706 | break; |
| 4707 | if (LocaleCompare("idft",option+1) == 0) |
| 4708 | break; |
| 4709 | if (LocaleCompare("implode",option+1) == 0) |
| 4710 | { |
| 4711 | if (*option == '+') |
| 4712 | break; |
| 4713 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4714 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4715 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4716 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4717 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4718 | break; |
| 4719 | } |
| 4720 | if (LocaleCompare("intent",option+1) == 0) |
| 4721 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4722 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4723 | intent; |
| 4724 | |
| 4725 | if (*option == '+') |
| 4726 | break; |
| 4727 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4728 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4729 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4730 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4731 | if (intent < 0) |
| 4732 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4733 | argv[i]); |
| 4734 | break; |
| 4735 | } |
| 4736 | if (LocaleCompare("interlace",option+1) == 0) |
| 4737 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4738 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4739 | interlace; |
| 4740 | |
| 4741 | if (*option == '+') |
| 4742 | break; |
| 4743 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4744 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4745 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4746 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4747 | argv[i]); |
| 4748 | if (interlace < 0) |
| 4749 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4750 | argv[i]); |
| 4751 | break; |
| 4752 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4753 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4754 | { |
| 4755 | if (*option == '+') |
| 4756 | break; |
| 4757 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4758 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4759 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4760 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4761 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4762 | break; |
| 4763 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4764 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4765 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4766 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4767 | interpolate; |
| 4768 | |
| 4769 | if (*option == '+') |
| 4770 | break; |
| 4771 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4772 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4773 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4774 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4775 | argv[i]); |
| 4776 | if (interpolate < 0) |
| 4777 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4778 | argv[i]); |
| 4779 | break; |
| 4780 | } |
| 4781 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4782 | { |
| 4783 | if (*option == '+') |
| 4784 | break; |
| 4785 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4786 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4787 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4788 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4789 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4790 | break; |
| 4791 | } |
| 4792 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4793 | } |
| 4794 | case 'k': |
| 4795 | { |
| 4796 | if (LocaleCompare("kerning",option+1) == 0) |
| 4797 | { |
| 4798 | if (*option == '+') |
| 4799 | break; |
| 4800 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4801 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4802 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4803 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4804 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4805 | break; |
| 4806 | } |
| 4807 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4808 | } |
| 4809 | case 'l': |
| 4810 | { |
| 4811 | if (LocaleCompare("label",option+1) == 0) |
| 4812 | { |
| 4813 | if (*option == '+') |
| 4814 | break; |
| 4815 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4816 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4817 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4818 | break; |
| 4819 | } |
| 4820 | if (LocaleCompare("lat",option+1) == 0) |
| 4821 | { |
| 4822 | if (*option == '+') |
| 4823 | break; |
| 4824 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4825 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4826 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4827 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4828 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4829 | } |
| 4830 | if (LocaleCompare("layers",option+1) == 0) |
| 4831 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4832 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4833 | type; |
| 4834 | |
| 4835 | if (*option == '+') |
| 4836 | break; |
| 4837 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4838 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4839 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4840 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4841 | if (type < 0) |
| 4842 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4843 | argv[i]); |
| 4844 | break; |
| 4845 | } |
| 4846 | if (LocaleCompare("level",option+1) == 0) |
| 4847 | { |
| 4848 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4849 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4850 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4851 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4852 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4853 | break; |
| 4854 | } |
| 4855 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4856 | { |
| 4857 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4858 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4859 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4860 | break; |
| 4861 | } |
| 4862 | if (LocaleCompare("linewidth",option+1) == 0) |
| 4863 | { |
| 4864 | if (*option == '+') |
| 4865 | break; |
| 4866 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4867 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4868 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4869 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4870 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4871 | break; |
| 4872 | } |
| 4873 | if (LocaleCompare("limit",option+1) == 0) |
| 4874 | { |
| 4875 | char |
| 4876 | *p; |
| 4877 | |
| 4878 | double |
| 4879 | value; |
| 4880 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4881 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4882 | resource; |
| 4883 | |
| 4884 | if (*option == '+') |
| 4885 | break; |
| 4886 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4887 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4888 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4889 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4890 | argv[i]); |
| 4891 | if (resource < 0) |
| 4892 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4893 | argv[i]); |
| 4894 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4895 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4896 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 4897 | value=InterpretLocaleValue(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4898 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4899 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4900 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4901 | break; |
| 4902 | } |
| 4903 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4904 | { |
| 4905 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4906 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4907 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4908 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4909 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4910 | break; |
| 4911 | } |
| 4912 | if (LocaleCompare("list",option+1) == 0) |
| 4913 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4914 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4915 | list; |
| 4916 | |
| 4917 | if (*option == '+') |
| 4918 | break; |
| 4919 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4920 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4921 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4922 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4923 | if (list < 0) |
| 4924 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4925 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4926 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4927 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4928 | } |
| 4929 | if (LocaleCompare("log",option+1) == 0) |
| 4930 | { |
| 4931 | if (*option == '+') |
| 4932 | break; |
| 4933 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4934 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4935 | (strchr(argv[i],'%') == (char *) NULL)) |
| 4936 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4937 | break; |
| 4938 | } |
| 4939 | if (LocaleCompare("loop",option+1) == 0) |
| 4940 | { |
| 4941 | if (*option == '+') |
| 4942 | break; |
| 4943 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4944 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4945 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4946 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4947 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4948 | break; |
| 4949 | } |
| 4950 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4951 | } |
| 4952 | case 'm': |
| 4953 | { |
| 4954 | if (LocaleCompare("map",option+1) == 0) |
| 4955 | { |
| 4956 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 4957 | if (*option == '+') |
| 4958 | break; |
| 4959 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4960 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4961 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4962 | break; |
| 4963 | } |
| 4964 | if (LocaleCompare("mask",option+1) == 0) |
| 4965 | { |
| 4966 | if (*option == '+') |
| 4967 | break; |
| 4968 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4969 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4970 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4971 | break; |
| 4972 | } |
| 4973 | if (LocaleCompare("matte",option+1) == 0) |
| 4974 | break; |
| 4975 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 4976 | { |
| 4977 | if (*option == '+') |
| 4978 | break; |
| 4979 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4980 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4981 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4982 | break; |
| 4983 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 4984 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 4985 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 4986 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 4987 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4988 | if (LocaleCompare("modulate",option+1) == 0) |
| 4989 | { |
| 4990 | if (*option == '+') |
| 4991 | break; |
| 4992 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4993 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4994 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4995 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4996 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4997 | break; |
| 4998 | } |
| 4999 | if (LocaleCompare("median",option+1) == 0) |
| 5000 | { |
| 5001 | if (*option == '+') |
| 5002 | break; |
| 5003 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5004 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5005 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5006 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5007 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5008 | break; |
| 5009 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5010 | if (LocaleCompare("mode",option+1) == 0) |
| 5011 | { |
| 5012 | if (*option == '+') |
| 5013 | break; |
| 5014 | i++; |
| 5015 | if (i == (ssize_t) argc) |
| 5016 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5017 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5018 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5019 | break; |
| 5020 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5021 | if (LocaleCompare("monitor",option+1) == 0) |
| 5022 | break; |
| 5023 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5024 | break; |
| 5025 | if (LocaleCompare("morph",option+1) == 0) |
| 5026 | { |
| 5027 | if (*option == '+') |
| 5028 | break; |
| 5029 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5030 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5031 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5032 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5033 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5034 | break; |
| 5035 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5036 | if (LocaleCompare("morphology",option+1) == 0) |
| 5037 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5038 | char |
| 5039 | token[MaxTextExtent]; |
| 5040 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5041 | KernelInfo |
| 5042 | *kernel_info; |
| 5043 | |
| 5044 | ssize_t |
| 5045 | op; |
| 5046 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5047 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5048 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5049 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5050 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5051 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5052 | if (op < 0) |
| 5053 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5054 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5055 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5056 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5057 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5058 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5059 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5060 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5061 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5062 | break; |
| 5063 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5064 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5065 | break; |
| 5066 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5067 | { |
| 5068 | if (*option == '+') |
| 5069 | break; |
| 5070 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5071 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5072 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5073 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5074 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5075 | break; |
| 5076 | } |
| 5077 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5078 | } |
| 5079 | case 'n': |
| 5080 | { |
| 5081 | if (LocaleCompare("negate",option+1) == 0) |
| 5082 | break; |
| 5083 | if (LocaleCompare("noise",option+1) == 0) |
| 5084 | { |
| 5085 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5086 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5087 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5088 | if (*option == '+') |
| 5089 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5090 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5091 | noise; |
| 5092 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5093 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5094 | if (noise < 0) |
| 5095 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5096 | argv[i]); |
| 5097 | break; |
| 5098 | } |
| 5099 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5100 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5101 | break; |
| 5102 | } |
| 5103 | if (LocaleCompare("noop",option+1) == 0) |
| 5104 | break; |
| 5105 | if (LocaleCompare("normalize",option+1) == 0) |
| 5106 | break; |
| 5107 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5108 | } |
| 5109 | case 'o': |
| 5110 | { |
| 5111 | if (LocaleCompare("opaque",option+1) == 0) |
| 5112 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5113 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5114 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5115 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5116 | break; |
| 5117 | } |
| 5118 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5119 | { |
| 5120 | if (*option == '+') |
| 5121 | break; |
| 5122 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5123 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5124 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5125 | break; |
| 5126 | } |
| 5127 | if (LocaleCompare("orient",option+1) == 0) |
| 5128 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5129 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5130 | orientation; |
| 5131 | |
| 5132 | orientation=UndefinedOrientation; |
| 5133 | if (*option == '+') |
| 5134 | break; |
| 5135 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5136 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5137 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5138 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5139 | argv[i]); |
| 5140 | if (orientation < 0) |
| 5141 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5142 | argv[i]); |
| 5143 | break; |
| 5144 | } |
| 5145 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5146 | } |
| 5147 | case 'p': |
| 5148 | { |
| 5149 | if (LocaleCompare("page",option+1) == 0) |
| 5150 | { |
| 5151 | if (*option == '+') |
| 5152 | break; |
| 5153 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5154 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5155 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5156 | break; |
| 5157 | } |
| 5158 | if (LocaleCompare("paint",option+1) == 0) |
| 5159 | { |
| 5160 | if (*option == '+') |
| 5161 | break; |
| 5162 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5163 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5164 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5165 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5166 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5167 | break; |
| 5168 | } |
| 5169 | if (LocaleCompare("path",option+1) == 0) |
| 5170 | { |
| 5171 | (void) CloneString(&path,(char *) NULL); |
| 5172 | if (*option == '+') |
| 5173 | break; |
| 5174 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5175 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5176 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5177 | (void) CloneString(&path,argv[i]); |
| 5178 | break; |
| 5179 | } |
| 5180 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5181 | { |
| 5182 | if (*option == '+') |
| 5183 | break; |
| 5184 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5185 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5186 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5187 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5188 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5189 | break; |
| 5190 | } |
| 5191 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5192 | { |
| 5193 | if (*option == '+') |
| 5194 | break; |
| 5195 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5196 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5197 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5198 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5199 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5200 | break; |
| 5201 | } |
| 5202 | if (LocaleCompare("posterize",option+1) == 0) |
| 5203 | { |
| 5204 | if (*option == '+') |
| 5205 | break; |
| 5206 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5207 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5208 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5209 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5210 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5211 | break; |
| 5212 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5213 | if (LocaleCompare("precision",option+1) == 0) |
| 5214 | { |
| 5215 | if (*option == '+') |
| 5216 | break; |
| 5217 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5218 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5219 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5220 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5221 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5222 | break; |
| 5223 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5224 | if (LocaleCompare("print",option+1) == 0) |
| 5225 | { |
| 5226 | if (*option == '+') |
| 5227 | break; |
| 5228 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5229 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5230 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5231 | break; |
| 5232 | } |
| 5233 | if (LocaleCompare("process",option+1) == 0) |
| 5234 | { |
| 5235 | if (*option == '+') |
| 5236 | break; |
| 5237 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5238 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5239 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5240 | break; |
| 5241 | } |
| 5242 | if (LocaleCompare("profile",option+1) == 0) |
| 5243 | { |
| 5244 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5245 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5246 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5247 | break; |
| 5248 | } |
| 5249 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5250 | } |
| 5251 | case 'q': |
| 5252 | { |
| 5253 | if (LocaleCompare("quality",option+1) == 0) |
| 5254 | { |
| 5255 | if (*option == '+') |
| 5256 | break; |
| 5257 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5258 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5259 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5260 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5261 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5262 | break; |
| 5263 | } |
| 5264 | if (LocaleCompare("quantize",option+1) == 0) |
| 5265 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5266 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5267 | colorspace; |
| 5268 | |
| 5269 | if (*option == '+') |
| 5270 | break; |
| 5271 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5272 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5273 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5274 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5275 | argv[i]); |
| 5276 | if (colorspace < 0) |
| 5277 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5278 | argv[i]); |
| 5279 | break; |
| 5280 | } |
| 5281 | if (LocaleCompare("quiet",option+1) == 0) |
| 5282 | break; |
| 5283 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5284 | } |
| 5285 | case 'r': |
| 5286 | { |
| 5287 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5288 | { |
| 5289 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5290 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5291 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5292 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5293 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5294 | break; |
| 5295 | } |
| 5296 | if (LocaleCompare("raise",option+1) == 0) |
| 5297 | { |
| 5298 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5299 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5300 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5301 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5302 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5303 | break; |
| 5304 | } |
| 5305 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5306 | { |
| 5307 | if (*option == '+') |
| 5308 | break; |
| 5309 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5310 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5311 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5312 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5313 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5314 | break; |
| 5315 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5316 | if (LocaleCompare("recolor",option+1) == 0) |
| 5317 | { |
| 5318 | if (*option == '+') |
| 5319 | break; |
| 5320 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5321 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5322 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5323 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5324 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5325 | break; |
| 5326 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5327 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5328 | { |
| 5329 | if (*option == '+') |
| 5330 | break; |
| 5331 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5332 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5333 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5334 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5335 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5336 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5337 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5338 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5339 | if (LocaleCompare("region",option+1) == 0) |
| 5340 | { |
| 5341 | if (*option == '+') |
| 5342 | break; |
| 5343 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5344 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5345 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5346 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5347 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5348 | break; |
| 5349 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5350 | if (LocaleCompare("remap",option+1) == 0) |
| 5351 | { |
| 5352 | if (*option == '+') |
| 5353 | break; |
| 5354 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5355 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5356 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5357 | break; |
| 5358 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5359 | if (LocaleCompare("render",option+1) == 0) |
| 5360 | break; |
| 5361 | if (LocaleCompare("repage",option+1) == 0) |
| 5362 | { |
| 5363 | if (*option == '+') |
| 5364 | break; |
| 5365 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5366 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5367 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5368 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5369 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5370 | break; |
| 5371 | } |
| 5372 | if (LocaleCompare("resample",option+1) == 0) |
| 5373 | { |
| 5374 | if (*option == '+') |
| 5375 | break; |
| 5376 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5377 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5378 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5379 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5380 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5381 | break; |
| 5382 | } |
| 5383 | if (LocaleCompare("resize",option+1) == 0) |
| 5384 | { |
| 5385 | if (*option == '+') |
| 5386 | break; |
| 5387 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5388 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5389 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5390 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5391 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5392 | break; |
| 5393 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5394 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5395 | { |
| 5396 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5397 | break; |
| 5398 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5399 | if (LocaleCompare("reverse",option+1) == 0) |
| 5400 | break; |
| 5401 | if (LocaleCompare("roll",option+1) == 0) |
| 5402 | { |
| 5403 | if (*option == '+') |
| 5404 | break; |
| 5405 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5406 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5407 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5408 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5409 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5410 | break; |
| 5411 | } |
| 5412 | if (LocaleCompare("rotate",option+1) == 0) |
| 5413 | { |
| 5414 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5415 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5416 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5417 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5418 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5419 | break; |
| 5420 | } |
| 5421 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5422 | } |
| 5423 | case 's': |
| 5424 | { |
| 5425 | if (LocaleCompare("sample",option+1) == 0) |
| 5426 | { |
| 5427 | if (*option == '+') |
| 5428 | break; |
| 5429 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5430 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5431 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5432 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5433 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5434 | break; |
| 5435 | } |
| 5436 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5437 | { |
| 5438 | if (*option == '+') |
| 5439 | break; |
| 5440 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5441 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5442 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5443 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5444 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5445 | break; |
| 5446 | } |
| 5447 | if (LocaleCompare("scale",option+1) == 0) |
| 5448 | { |
| 5449 | if (*option == '+') |
| 5450 | break; |
| 5451 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5452 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5453 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5454 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5455 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5456 | break; |
| 5457 | } |
| 5458 | if (LocaleCompare("scene",option+1) == 0) |
| 5459 | { |
| 5460 | if (*option == '+') |
| 5461 | break; |
| 5462 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5463 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5464 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5465 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5466 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5467 | break; |
| 5468 | } |
| 5469 | if (LocaleCompare("seed",option+1) == 0) |
| 5470 | { |
| 5471 | if (*option == '+') |
| 5472 | break; |
| 5473 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5474 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5475 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5476 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5477 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5478 | break; |
| 5479 | } |
| 5480 | if (LocaleCompare("segment",option+1) == 0) |
| 5481 | { |
| 5482 | if (*option == '+') |
| 5483 | break; |
| 5484 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5485 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5486 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5487 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5488 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5489 | break; |
| 5490 | } |
| 5491 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5492 | { |
| 5493 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5494 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5495 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5496 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5497 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5498 | break; |
| 5499 | } |
| 5500 | if (LocaleCompare("separate",option+1) == 0) |
| 5501 | break; |
| 5502 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5503 | { |
| 5504 | if (*option == '+') |
| 5505 | break; |
| 5506 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5507 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5508 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5509 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5510 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5511 | break; |
| 5512 | } |
| 5513 | if (LocaleCompare("set",option+1) == 0) |
| 5514 | { |
| 5515 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5516 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5517 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5518 | if (*option == '+') |
| 5519 | break; |
| 5520 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5521 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5522 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5523 | break; |
| 5524 | } |
| 5525 | if (LocaleCompare("shade",option+1) == 0) |
| 5526 | { |
| 5527 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5528 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5529 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5530 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5531 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5532 | break; |
| 5533 | } |
| 5534 | if (LocaleCompare("shadow",option+1) == 0) |
| 5535 | { |
| 5536 | if (*option == '+') |
| 5537 | break; |
| 5538 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5539 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5540 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5541 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5542 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5543 | break; |
| 5544 | } |
| 5545 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5546 | { |
| 5547 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5548 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5549 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5550 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5551 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5552 | break; |
| 5553 | } |
| 5554 | if (LocaleCompare("shave",option+1) == 0) |
| 5555 | { |
| 5556 | if (*option == '+') |
| 5557 | break; |
| 5558 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5559 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5560 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5561 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5562 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5563 | break; |
| 5564 | } |
| 5565 | if (LocaleCompare("shear",option+1) == 0) |
| 5566 | { |
| 5567 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5568 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5569 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5570 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5571 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5572 | break; |
| 5573 | } |
| 5574 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5575 | { |
| 5576 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5577 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5578 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5579 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5580 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5581 | break; |
| 5582 | } |
| 5583 | if (LocaleCompare("size",option+1) == 0) |
| 5584 | { |
| 5585 | if (*option == '+') |
| 5586 | break; |
| 5587 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5588 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5589 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5590 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5591 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5592 | break; |
| 5593 | } |
| 5594 | if (LocaleCompare("sketch",option+1) == 0) |
| 5595 | { |
| 5596 | if (*option == '+') |
| 5597 | break; |
| 5598 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5599 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5600 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5601 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5602 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5603 | break; |
| 5604 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5605 | if (LocaleCompare("smush",option+1) == 0) |
| 5606 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5607 | i++; |
| 5608 | if (i == (ssize_t) argc) |
| 5609 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5610 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5611 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5612 | i++; |
| 5613 | break; |
| 5614 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5615 | if (LocaleCompare("solarize",option+1) == 0) |
| 5616 | { |
| 5617 | if (*option == '+') |
| 5618 | break; |
| 5619 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5620 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5621 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5622 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5623 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5624 | break; |
| 5625 | } |
| 5626 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5627 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5628 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5629 | op; |
| 5630 | |
| 5631 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5632 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5633 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5634 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5635 | if (op < 0) |
| 5636 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5637 | argv[i]); |
| 5638 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5639 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5640 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5641 | break; |
| 5642 | } |
| 5643 | if (LocaleCompare("spread",option+1) == 0) |
| 5644 | { |
| 5645 | if (*option == '+') |
| 5646 | break; |
| 5647 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5648 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5649 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5650 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5651 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5652 | break; |
| 5653 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5654 | if (LocaleCompare("statistic",option+1) == 0) |
| 5655 | { |
| 5656 | ssize_t |
| 5657 | op; |
| 5658 | |
| 5659 | if (*option == '+') |
| 5660 | break; |
| 5661 | i++; |
| 5662 | if (i == (ssize_t) argc) |
| 5663 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5664 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5665 | if (op < 0) |
| 5666 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5667 | argv[i]); |
| 5668 | i++; |
| 5669 | if (i == (ssize_t) (argc-1)) |
| 5670 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5671 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5672 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5673 | break; |
| 5674 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5675 | if (LocaleCompare("stretch",option+1) == 0) |
| 5676 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5677 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5678 | stretch; |
| 5679 | |
| 5680 | if (*option == '+') |
| 5681 | break; |
| 5682 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5683 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5684 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5685 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5686 | if (stretch < 0) |
| 5687 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5688 | argv[i]); |
| 5689 | break; |
| 5690 | } |
| 5691 | if (LocaleCompare("strip",option+1) == 0) |
| 5692 | break; |
| 5693 | if (LocaleCompare("stroke",option+1) == 0) |
| 5694 | { |
| 5695 | if (*option == '+') |
| 5696 | break; |
| 5697 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5698 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5699 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5700 | break; |
| 5701 | } |
| 5702 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5703 | { |
| 5704 | if (*option == '+') |
| 5705 | break; |
| 5706 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5707 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5708 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5709 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5710 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5711 | break; |
| 5712 | } |
| 5713 | if (LocaleCompare("style",option+1) == 0) |
| 5714 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5715 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5716 | style; |
| 5717 | |
| 5718 | if (*option == '+') |
| 5719 | break; |
| 5720 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5721 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5722 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5723 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5724 | if (style < 0) |
| 5725 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5726 | argv[i]); |
| 5727 | break; |
| 5728 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5729 | if (LocaleCompare("swap",option+1) == 0) |
| 5730 | { |
| 5731 | if (*option == '+') |
| 5732 | break; |
| 5733 | i++; |
| 5734 | if (i == (ssize_t) (argc-1)) |
| 5735 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5736 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5737 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5738 | break; |
| 5739 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5740 | if (LocaleCompare("swirl",option+1) == 0) |
| 5741 | { |
| 5742 | if (*option == '+') |
| 5743 | break; |
| 5744 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5745 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5746 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5747 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5748 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5749 | break; |
| 5750 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5751 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5752 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5753 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5754 | } |
| 5755 | case 't': |
| 5756 | { |
| 5757 | if (LocaleCompare("taint",option+1) == 0) |
| 5758 | break; |
| 5759 | if (LocaleCompare("texture",option+1) == 0) |
| 5760 | { |
| 5761 | if (*option == '+') |
| 5762 | break; |
| 5763 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5764 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5765 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5766 | break; |
| 5767 | } |
| 5768 | if (LocaleCompare("tile",option+1) == 0) |
| 5769 | { |
| 5770 | if (*option == '+') |
| 5771 | break; |
| 5772 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5773 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5774 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5775 | break; |
| 5776 | } |
| 5777 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5778 | { |
| 5779 | if (*option == '+') |
| 5780 | break; |
| 5781 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5782 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5783 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5784 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5785 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5786 | break; |
| 5787 | } |
| 5788 | if (LocaleCompare("tint",option+1) == 0) |
| 5789 | { |
| 5790 | if (*option == '+') |
| 5791 | break; |
| 5792 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5793 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5794 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5795 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5796 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5797 | break; |
| 5798 | } |
| 5799 | if (LocaleCompare("transform",option+1) == 0) |
| 5800 | break; |
| 5801 | if (LocaleCompare("transpose",option+1) == 0) |
| 5802 | break; |
| 5803 | if (LocaleCompare("transverse",option+1) == 0) |
| 5804 | break; |
| 5805 | if (LocaleCompare("threshold",option+1) == 0) |
| 5806 | { |
| 5807 | if (*option == '+') |
| 5808 | break; |
| 5809 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5810 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5811 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5812 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5813 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5814 | break; |
| 5815 | } |
| 5816 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5817 | { |
| 5818 | if (*option == '+') |
| 5819 | break; |
| 5820 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5821 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5822 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5823 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5824 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5825 | break; |
| 5826 | } |
| 5827 | if (LocaleCompare("transparent",option+1) == 0) |
| 5828 | { |
| 5829 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5830 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5831 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5832 | break; |
| 5833 | } |
| 5834 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 5835 | { |
| 5836 | if (*option == '+') |
| 5837 | break; |
| 5838 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5839 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5840 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5841 | break; |
| 5842 | } |
| 5843 | if (LocaleCompare("treedepth",option+1) == 0) |
| 5844 | { |
| 5845 | if (*option == '+') |
| 5846 | break; |
| 5847 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5848 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5849 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5850 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5851 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5852 | break; |
| 5853 | } |
| 5854 | if (LocaleCompare("trim",option+1) == 0) |
| 5855 | break; |
| 5856 | if (LocaleCompare("type",option+1) == 0) |
| 5857 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5858 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5859 | type; |
| 5860 | |
| 5861 | if (*option == '+') |
| 5862 | break; |
| 5863 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5864 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5865 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5866 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5867 | if (type < 0) |
| 5868 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5869 | argv[i]); |
| 5870 | break; |
| 5871 | } |
| 5872 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5873 | } |
| 5874 | case 'u': |
| 5875 | { |
| 5876 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5877 | { |
| 5878 | if (*option == '+') |
| 5879 | break; |
| 5880 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5881 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5882 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5883 | break; |
| 5884 | } |
| 5885 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5886 | break; |
| 5887 | if (LocaleCompare("units",option+1) == 0) |
| 5888 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5889 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5890 | units; |
| 5891 | |
| 5892 | if (*option == '+') |
| 5893 | break; |
| 5894 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5895 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5896 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5897 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5898 | argv[i]); |
| 5899 | if (units < 0) |
| 5900 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5901 | argv[i]); |
| 5902 | break; |
| 5903 | } |
| 5904 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5905 | { |
| 5906 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5907 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5908 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5909 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5910 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5911 | break; |
| 5912 | } |
| 5913 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5914 | } |
| 5915 | case 'v': |
| 5916 | { |
| 5917 | if (LocaleCompare("verbose",option+1) == 0) |
| 5918 | { |
| 5919 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 5920 | break; |
| 5921 | } |
| 5922 | if ((LocaleCompare("version",option+1) == 0) || |
| 5923 | (LocaleCompare("-version",option+1) == 0)) |
| 5924 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 5925 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5926 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 5927 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 5928 | GetMagickCopyright()); |
| 5929 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 5930 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5931 | break; |
| 5932 | } |
| 5933 | if (LocaleCompare("view",option+1) == 0) |
| 5934 | { |
| 5935 | if (*option == '+') |
| 5936 | break; |
| 5937 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5938 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5939 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5940 | break; |
| 5941 | } |
| 5942 | if (LocaleCompare("vignette",option+1) == 0) |
| 5943 | { |
| 5944 | if (*option == '+') |
| 5945 | break; |
| 5946 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5947 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5948 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5949 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5950 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5951 | break; |
| 5952 | } |
| 5953 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 5954 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5955 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5956 | method; |
| 5957 | |
| 5958 | if (*option == '+') |
| 5959 | break; |
| 5960 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5961 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5962 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5963 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5964 | argv[i]); |
| 5965 | if (method < 0) |
| 5966 | ThrowMogrifyException(OptionError, |
| 5967 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 5968 | break; |
| 5969 | } |
| 5970 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5971 | } |
| 5972 | case 'w': |
| 5973 | { |
| 5974 | if (LocaleCompare("wave",option+1) == 0) |
| 5975 | { |
| 5976 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5977 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5978 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5979 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5980 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5981 | break; |
| 5982 | } |
| 5983 | if (LocaleCompare("weight",option+1) == 0) |
| 5984 | { |
| 5985 | if (*option == '+') |
| 5986 | break; |
| 5987 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5988 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5989 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5990 | break; |
| 5991 | } |
| 5992 | if (LocaleCompare("white-point",option+1) == 0) |
| 5993 | { |
| 5994 | if (*option == '+') |
| 5995 | break; |
| 5996 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5997 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5998 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5999 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6000 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6001 | break; |
| 6002 | } |
| 6003 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6004 | { |
| 6005 | if (*option == '+') |
| 6006 | break; |
| 6007 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6008 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6009 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6010 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6011 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6012 | break; |
| 6013 | } |
| 6014 | if (LocaleCompare("write",option+1) == 0) |
| 6015 | { |
| 6016 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6017 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6018 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6019 | break; |
| 6020 | } |
| 6021 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6022 | } |
| 6023 | case '?': |
| 6024 | break; |
| 6025 | default: |
| 6026 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6027 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6028 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 6029 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6030 | if (fire != MagickFalse) |
| 6031 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6032 | } |
| 6033 | if (k != 0) |
| 6034 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6035 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6036 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6037 | DestroyMogrify(); |
| 6038 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6039 | } |
| 6040 | |
| 6041 | /* |
| 6042 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6043 | % % |
| 6044 | % % |
| 6045 | % % |
| 6046 | + M o g r i f y I m a g e I n f o % |
| 6047 | % % |
| 6048 | % % |
| 6049 | % % |
| 6050 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6051 | % |
| 6052 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6053 | % prescribed by command line options. |
| 6054 | % |
| 6055 | % The format of the MogrifyImageInfo method is: |
| 6056 | % |
| 6057 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6058 | % const char **argv,ExceptionInfo *exception) |
| 6059 | % |
| 6060 | % A description of each parameter follows: |
| 6061 | % |
| 6062 | % o image_info: the image info.. |
| 6063 | % |
| 6064 | % o argc: Specifies a pointer to an integer describing the number of |
| 6065 | % elements in the argument vector. |
| 6066 | % |
| 6067 | % o argv: Specifies a pointer to a text array containing the command line |
| 6068 | % arguments. |
| 6069 | % |
| 6070 | % o exception: return any errors or warnings in this structure. |
| 6071 | % |
| 6072 | */ |
| 6073 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6074 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6075 | { |
| 6076 | const char |
| 6077 | *option; |
| 6078 | |
| 6079 | GeometryInfo |
| 6080 | geometry_info; |
| 6081 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6082 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6083 | count; |
| 6084 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6085 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6086 | i; |
| 6087 | |
| 6088 | /* |
| 6089 | Initialize method variables. |
| 6090 | */ |
| 6091 | assert(image_info != (ImageInfo *) NULL); |
| 6092 | assert(image_info->signature == MagickSignature); |
| 6093 | if (image_info->debug != MagickFalse) |
| 6094 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6095 | image_info->filename); |
| 6096 | if (argc < 0) |
| 6097 | return(MagickTrue); |
| 6098 | /* |
| 6099 | Set the image settings. |
| 6100 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6101 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6102 | { |
| 6103 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6104 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6105 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6106 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6107 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6108 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6109 | break; |
| 6110 | switch (*(option+1)) |
| 6111 | { |
| 6112 | case 'a': |
| 6113 | { |
| 6114 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6115 | { |
| 6116 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6117 | break; |
| 6118 | } |
| 6119 | if (LocaleCompare("antialias",option+1) == 0) |
| 6120 | { |
| 6121 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6122 | break; |
| 6123 | } |
| 6124 | if (LocaleCompare("attenuate",option+1) == 0) |
| 6125 | { |
| 6126 | if (*option == '+') |
| 6127 | { |
| 6128 | (void) DeleteImageOption(image_info,option+1); |
| 6129 | break; |
| 6130 | } |
| 6131 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6132 | break; |
| 6133 | } |
| 6134 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6135 | { |
| 6136 | if (*option == '+') |
| 6137 | (void) CloneString(&image_info->authenticate,(char *) NULL); |
| 6138 | else |
| 6139 | (void) CloneString(&image_info->authenticate,argv[i+1]); |
| 6140 | break; |
| 6141 | } |
| 6142 | break; |
| 6143 | } |
| 6144 | case 'b': |
| 6145 | { |
| 6146 | if (LocaleCompare("background",option+1) == 0) |
| 6147 | { |
| 6148 | if (*option == '+') |
| 6149 | { |
| 6150 | (void) DeleteImageOption(image_info,option+1); |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6151 | (void) QueryColorDatabase(MogrifyBackgroundColor, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6152 | &image_info->background_color,exception); |
| 6153 | break; |
| 6154 | } |
| 6155 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6156 | (void) QueryColorDatabase(argv[i+1],&image_info->background_color, |
| 6157 | exception); |
| 6158 | break; |
| 6159 | } |
| 6160 | if (LocaleCompare("bias",option+1) == 0) |
| 6161 | { |
| 6162 | if (*option == '+') |
| 6163 | { |
| 6164 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6165 | break; |
| 6166 | } |
| 6167 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6168 | break; |
| 6169 | } |
| 6170 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6171 | { |
| 6172 | if (*option == '+') |
| 6173 | { |
| 6174 | (void) SetImageOption(image_info,option+1,"false"); |
| 6175 | break; |
| 6176 | } |
| 6177 | (void) SetImageOption(image_info,option+1,"true"); |
| 6178 | break; |
| 6179 | } |
| 6180 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6181 | { |
| 6182 | if (*option == '+') |
| 6183 | { |
| 6184 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6185 | break; |
| 6186 | } |
| 6187 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6188 | break; |
| 6189 | } |
| 6190 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6191 | { |
| 6192 | if (*option == '+') |
| 6193 | { |
| 6194 | (void) DeleteImageOption(image_info,option+1); |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6195 | (void) QueryColorDatabase(MogrifyBorderColor, |
| 6196 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6197 | break; |
| 6198 | } |
| 6199 | (void) QueryColorDatabase(argv[i+1],&image_info->border_color, |
| 6200 | exception); |
| 6201 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6202 | break; |
| 6203 | } |
| 6204 | if (LocaleCompare("box",option+1) == 0) |
| 6205 | { |
| 6206 | if (*option == '+') |
| 6207 | { |
| 6208 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6209 | break; |
| 6210 | } |
| 6211 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6212 | break; |
| 6213 | } |
| 6214 | break; |
| 6215 | } |
| 6216 | case 'c': |
| 6217 | { |
| 6218 | if (LocaleCompare("cache",option+1) == 0) |
| 6219 | { |
| 6220 | MagickSizeType |
| 6221 | limit; |
| 6222 | |
| 6223 | limit=MagickResourceInfinity; |
| 6224 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6225 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6226 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6227 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6228 | break; |
| 6229 | } |
| 6230 | if (LocaleCompare("caption",option+1) == 0) |
| 6231 | { |
| 6232 | if (*option == '+') |
| 6233 | { |
| 6234 | (void) DeleteImageOption(image_info,option+1); |
| 6235 | break; |
| 6236 | } |
| 6237 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6238 | break; |
| 6239 | } |
| 6240 | if (LocaleCompare("channel",option+1) == 0) |
| 6241 | { |
| 6242 | if (*option == '+') |
| 6243 | { |
| 6244 | image_info->channel=DefaultChannels; |
| 6245 | break; |
| 6246 | } |
| 6247 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6248 | break; |
| 6249 | } |
| 6250 | if (LocaleCompare("colors",option+1) == 0) |
| 6251 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6252 | image_info->colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6253 | break; |
| 6254 | } |
| 6255 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6256 | { |
| 6257 | if (*option == '+') |
| 6258 | { |
| 6259 | image_info->colorspace=UndefinedColorspace; |
| 6260 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6261 | break; |
| 6262 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6263 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6264 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6265 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6266 | break; |
| 6267 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6268 | if (LocaleCompare("comment",option+1) == 0) |
| 6269 | { |
| 6270 | if (*option == '+') |
| 6271 | { |
| 6272 | (void) DeleteImageOption(image_info,option+1); |
| 6273 | break; |
| 6274 | } |
| 6275 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6276 | break; |
| 6277 | } |
| 6278 | if (LocaleCompare("compose",option+1) == 0) |
| 6279 | { |
| 6280 | if (*option == '+') |
| 6281 | { |
| 6282 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6283 | break; |
| 6284 | } |
| 6285 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6286 | break; |
| 6287 | } |
| 6288 | if (LocaleCompare("compress",option+1) == 0) |
| 6289 | { |
| 6290 | if (*option == '+') |
| 6291 | { |
| 6292 | image_info->compression=UndefinedCompression; |
| 6293 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6294 | break; |
| 6295 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6296 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6297 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6298 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6299 | break; |
| 6300 | } |
| 6301 | break; |
| 6302 | } |
| 6303 | case 'd': |
| 6304 | { |
| 6305 | if (LocaleCompare("debug",option+1) == 0) |
| 6306 | { |
| 6307 | if (*option == '+') |
| 6308 | (void) SetLogEventMask("none"); |
| 6309 | else |
| 6310 | (void) SetLogEventMask(argv[i+1]); |
| 6311 | image_info->debug=IsEventLogging(); |
| 6312 | break; |
| 6313 | } |
| 6314 | if (LocaleCompare("define",option+1) == 0) |
| 6315 | { |
| 6316 | if (*option == '+') |
| 6317 | { |
| 6318 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6319 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6320 | else |
| 6321 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6322 | break; |
| 6323 | } |
| 6324 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6325 | { |
| 6326 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6327 | exception); |
| 6328 | break; |
| 6329 | } |
| 6330 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6331 | break; |
| 6332 | } |
| 6333 | if (LocaleCompare("delay",option+1) == 0) |
| 6334 | { |
| 6335 | if (*option == '+') |
| 6336 | { |
| 6337 | (void) SetImageOption(image_info,option+1,"0"); |
| 6338 | break; |
| 6339 | } |
| 6340 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6341 | break; |
| 6342 | } |
| 6343 | if (LocaleCompare("density",option+1) == 0) |
| 6344 | { |
| 6345 | /* |
| 6346 | Set image density. |
| 6347 | */ |
| 6348 | if (*option == '+') |
| 6349 | { |
| 6350 | if (image_info->density != (char *) NULL) |
| 6351 | image_info->density=DestroyString(image_info->density); |
| 6352 | (void) SetImageOption(image_info,option+1,"72"); |
| 6353 | break; |
| 6354 | } |
| 6355 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6356 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6357 | break; |
| 6358 | } |
| 6359 | if (LocaleCompare("depth",option+1) == 0) |
| 6360 | { |
| 6361 | if (*option == '+') |
| 6362 | { |
| 6363 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6364 | break; |
| 6365 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6366 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6367 | break; |
| 6368 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6369 | if (LocaleCompare("direction",option+1) == 0) |
| 6370 | { |
| 6371 | if (*option == '+') |
| 6372 | { |
| 6373 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6374 | break; |
| 6375 | } |
| 6376 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6377 | break; |
| 6378 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6379 | if (LocaleCompare("display",option+1) == 0) |
| 6380 | { |
| 6381 | if (*option == '+') |
| 6382 | { |
| 6383 | if (image_info->server_name != (char *) NULL) |
| 6384 | image_info->server_name=DestroyString( |
| 6385 | image_info->server_name); |
| 6386 | break; |
| 6387 | } |
| 6388 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6389 | break; |
| 6390 | } |
| 6391 | if (LocaleCompare("dispose",option+1) == 0) |
| 6392 | { |
| 6393 | if (*option == '+') |
| 6394 | { |
| 6395 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6396 | break; |
| 6397 | } |
| 6398 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6399 | break; |
| 6400 | } |
| 6401 | if (LocaleCompare("dither",option+1) == 0) |
| 6402 | { |
| 6403 | if (*option == '+') |
| 6404 | { |
| 6405 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6406 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6407 | break; |
| 6408 | } |
| 6409 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6410 | image_info->dither=MagickTrue; |
| 6411 | break; |
| 6412 | } |
| 6413 | break; |
| 6414 | } |
| 6415 | case 'e': |
| 6416 | { |
| 6417 | if (LocaleCompare("encoding",option+1) == 0) |
| 6418 | { |
| 6419 | if (*option == '+') |
| 6420 | { |
| 6421 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6422 | break; |
| 6423 | } |
| 6424 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6425 | break; |
| 6426 | } |
| 6427 | if (LocaleCompare("endian",option+1) == 0) |
| 6428 | { |
| 6429 | if (*option == '+') |
| 6430 | { |
| 6431 | image_info->endian=UndefinedEndian; |
| 6432 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6433 | break; |
| 6434 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6435 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6436 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6437 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6438 | break; |
| 6439 | } |
| 6440 | if (LocaleCompare("extract",option+1) == 0) |
| 6441 | { |
| 6442 | /* |
| 6443 | Set image extract geometry. |
| 6444 | */ |
| 6445 | if (*option == '+') |
| 6446 | { |
| 6447 | if (image_info->extract != (char *) NULL) |
| 6448 | image_info->extract=DestroyString(image_info->extract); |
| 6449 | break; |
| 6450 | } |
| 6451 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6452 | break; |
| 6453 | } |
| 6454 | break; |
| 6455 | } |
| 6456 | case 'f': |
| 6457 | { |
| 6458 | if (LocaleCompare("fill",option+1) == 0) |
| 6459 | { |
| 6460 | if (*option == '+') |
| 6461 | { |
| 6462 | (void) SetImageOption(image_info,option+1,"none"); |
| 6463 | break; |
| 6464 | } |
| 6465 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6466 | break; |
| 6467 | } |
| 6468 | if (LocaleCompare("filter",option+1) == 0) |
| 6469 | { |
| 6470 | if (*option == '+') |
| 6471 | { |
| 6472 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6473 | break; |
| 6474 | } |
| 6475 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6476 | break; |
| 6477 | } |
| 6478 | if (LocaleCompare("font",option+1) == 0) |
| 6479 | { |
| 6480 | if (*option == '+') |
| 6481 | { |
| 6482 | if (image_info->font != (char *) NULL) |
| 6483 | image_info->font=DestroyString(image_info->font); |
| 6484 | break; |
| 6485 | } |
| 6486 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6487 | break; |
| 6488 | } |
| 6489 | if (LocaleCompare("format",option+1) == 0) |
| 6490 | { |
| 6491 | register const char |
| 6492 | *q; |
| 6493 | |
| 6494 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6495 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6496 | image_info->ping=MagickFalse; |
| 6497 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6498 | break; |
| 6499 | } |
| 6500 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6501 | { |
| 6502 | if (*option == '+') |
| 6503 | { |
| 6504 | image_info->fuzz=0.0; |
| 6505 | (void) SetImageOption(image_info,option+1,"0"); |
| 6506 | break; |
| 6507 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6508 | image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6509 | 1.0); |
| 6510 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6511 | break; |
| 6512 | } |
| 6513 | break; |
| 6514 | } |
| 6515 | case 'g': |
| 6516 | { |
| 6517 | if (LocaleCompare("gravity",option+1) == 0) |
| 6518 | { |
| 6519 | if (*option == '+') |
| 6520 | { |
| 6521 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6522 | break; |
| 6523 | } |
| 6524 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6525 | break; |
| 6526 | } |
| 6527 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6528 | { |
| 6529 | if (*option == '+') |
| 6530 | { |
| 6531 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6532 | break; |
| 6533 | } |
| 6534 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6535 | break; |
| 6536 | } |
| 6537 | break; |
| 6538 | } |
| 6539 | case 'i': |
| 6540 | { |
| 6541 | if (LocaleCompare("intent",option+1) == 0) |
| 6542 | { |
| 6543 | if (*option == '+') |
| 6544 | { |
| 6545 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6546 | break; |
| 6547 | } |
| 6548 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6549 | break; |
| 6550 | } |
| 6551 | if (LocaleCompare("interlace",option+1) == 0) |
| 6552 | { |
| 6553 | if (*option == '+') |
| 6554 | { |
| 6555 | image_info->interlace=UndefinedInterlace; |
| 6556 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6557 | break; |
| 6558 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6559 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6560 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6561 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6562 | break; |
| 6563 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6564 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6565 | { |
| 6566 | if (*option == '+') |
| 6567 | { |
| 6568 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6569 | break; |
| 6570 | } |
| 6571 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6572 | break; |
| 6573 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6574 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6575 | { |
| 6576 | if (*option == '+') |
| 6577 | { |
| 6578 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6579 | break; |
| 6580 | } |
| 6581 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6582 | break; |
| 6583 | } |
| 6584 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6585 | { |
| 6586 | if (*option == '+') |
| 6587 | { |
| 6588 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6589 | break; |
| 6590 | } |
| 6591 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6592 | break; |
| 6593 | } |
| 6594 | break; |
| 6595 | } |
| 6596 | case 'k': |
| 6597 | { |
| 6598 | if (LocaleCompare("kerning",option+1) == 0) |
| 6599 | { |
| 6600 | if (*option == '+') |
| 6601 | { |
| 6602 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6603 | break; |
| 6604 | } |
| 6605 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6606 | break; |
| 6607 | } |
| 6608 | break; |
| 6609 | } |
| 6610 | case 'l': |
| 6611 | { |
| 6612 | if (LocaleCompare("label",option+1) == 0) |
| 6613 | { |
| 6614 | if (*option == '+') |
| 6615 | { |
| 6616 | (void) DeleteImageOption(image_info,option+1); |
| 6617 | break; |
| 6618 | } |
| 6619 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6620 | break; |
| 6621 | } |
| 6622 | if (LocaleCompare("limit",option+1) == 0) |
| 6623 | { |
| 6624 | MagickSizeType |
| 6625 | limit; |
| 6626 | |
| 6627 | ResourceType |
| 6628 | type; |
| 6629 | |
| 6630 | if (*option == '+') |
| 6631 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6632 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6633 | MagickFalse,argv[i+1]); |
| 6634 | limit=MagickResourceInfinity; |
| 6635 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6636 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6637 | (void) SetMagickResourceLimit(type,limit); |
| 6638 | break; |
| 6639 | } |
| 6640 | if (LocaleCompare("list",option+1) == 0) |
| 6641 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6642 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6643 | list; |
| 6644 | |
| 6645 | /* |
| 6646 | Display configuration list. |
| 6647 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6648 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6649 | switch (list) |
| 6650 | { |
| 6651 | case MagickCoderOptions: |
| 6652 | { |
| 6653 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6654 | break; |
| 6655 | } |
| 6656 | case MagickColorOptions: |
| 6657 | { |
| 6658 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6659 | break; |
| 6660 | } |
| 6661 | case MagickConfigureOptions: |
| 6662 | { |
| 6663 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6664 | break; |
| 6665 | } |
| 6666 | case MagickDelegateOptions: |
| 6667 | { |
| 6668 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6669 | break; |
| 6670 | } |
| 6671 | case MagickFontOptions: |
| 6672 | { |
| 6673 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6674 | break; |
| 6675 | } |
| 6676 | case MagickFormatOptions: |
| 6677 | { |
| 6678 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6679 | break; |
| 6680 | } |
| 6681 | case MagickLocaleOptions: |
| 6682 | { |
| 6683 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6684 | break; |
| 6685 | } |
| 6686 | case MagickLogOptions: |
| 6687 | { |
| 6688 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6689 | break; |
| 6690 | } |
| 6691 | case MagickMagicOptions: |
| 6692 | { |
| 6693 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6694 | break; |
| 6695 | } |
| 6696 | case MagickMimeOptions: |
| 6697 | { |
| 6698 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6699 | break; |
| 6700 | } |
| 6701 | case MagickModuleOptions: |
| 6702 | { |
| 6703 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6704 | break; |
| 6705 | } |
| 6706 | case MagickPolicyOptions: |
| 6707 | { |
| 6708 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6709 | break; |
| 6710 | } |
| 6711 | case MagickResourceOptions: |
| 6712 | { |
| 6713 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6714 | break; |
| 6715 | } |
| 6716 | case MagickThresholdOptions: |
| 6717 | { |
| 6718 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6719 | break; |
| 6720 | } |
| 6721 | default: |
| 6722 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6723 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6724 | exception); |
| 6725 | break; |
| 6726 | } |
| 6727 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6728 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6729 | } |
| 6730 | if (LocaleCompare("log",option+1) == 0) |
| 6731 | { |
| 6732 | if (*option == '+') |
| 6733 | break; |
| 6734 | (void) SetLogFormat(argv[i+1]); |
| 6735 | break; |
| 6736 | } |
| 6737 | if (LocaleCompare("loop",option+1) == 0) |
| 6738 | { |
| 6739 | if (*option == '+') |
| 6740 | { |
| 6741 | (void) SetImageOption(image_info,option+1,"0"); |
| 6742 | break; |
| 6743 | } |
| 6744 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6745 | break; |
| 6746 | } |
| 6747 | break; |
| 6748 | } |
| 6749 | case 'm': |
| 6750 | { |
| 6751 | if (LocaleCompare("matte",option+1) == 0) |
| 6752 | { |
| 6753 | if (*option == '+') |
| 6754 | { |
| 6755 | (void) SetImageOption(image_info,option+1,"false"); |
| 6756 | break; |
| 6757 | } |
| 6758 | (void) SetImageOption(image_info,option+1,"true"); |
| 6759 | break; |
| 6760 | } |
| 6761 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6762 | { |
| 6763 | if (*option == '+') |
| 6764 | { |
| 6765 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6766 | (void) QueryColorDatabase(MogrifyMatteColor, |
| 6767 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6768 | break; |
| 6769 | } |
| 6770 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6771 | (void) QueryColorDatabase(argv[i+1],&image_info->matte_color, |
| 6772 | exception); |
| 6773 | break; |
| 6774 | } |
| 6775 | if (LocaleCompare("monitor",option+1) == 0) |
| 6776 | { |
| 6777 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6778 | (void *) NULL); |
| 6779 | break; |
| 6780 | } |
| 6781 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6782 | { |
| 6783 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6784 | break; |
| 6785 | } |
| 6786 | break; |
| 6787 | } |
| 6788 | case 'o': |
| 6789 | { |
| 6790 | if (LocaleCompare("orient",option+1) == 0) |
| 6791 | { |
| 6792 | if (*option == '+') |
| 6793 | { |
| 6794 | image_info->orientation=UndefinedOrientation; |
| 6795 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6796 | break; |
| 6797 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6798 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6799 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6800 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6801 | break; |
| 6802 | } |
| 6803 | } |
| 6804 | case 'p': |
| 6805 | { |
| 6806 | if (LocaleCompare("page",option+1) == 0) |
| 6807 | { |
| 6808 | char |
| 6809 | *canonical_page, |
| 6810 | page[MaxTextExtent]; |
| 6811 | |
| 6812 | const char |
| 6813 | *image_option; |
| 6814 | |
| 6815 | MagickStatusType |
| 6816 | flags; |
| 6817 | |
| 6818 | RectangleInfo |
| 6819 | geometry; |
| 6820 | |
| 6821 | if (*option == '+') |
| 6822 | { |
| 6823 | (void) DeleteImageOption(image_info,option+1); |
| 6824 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6825 | break; |
| 6826 | } |
| 6827 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6828 | image_option=GetImageOption(image_info,"page"); |
| 6829 | if (image_option != (const char *) NULL) |
| 6830 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6831 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6832 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6833 | canonical_page=DestroyString(canonical_page); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6834 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6835 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6836 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6837 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6838 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6839 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6840 | (void) SetImageOption(image_info,option+1,page); |
| 6841 | (void) CloneString(&image_info->page,page); |
| 6842 | break; |
| 6843 | } |
| 6844 | if (LocaleCompare("pen",option+1) == 0) |
| 6845 | { |
| 6846 | if (*option == '+') |
| 6847 | { |
| 6848 | (void) SetImageOption(image_info,option+1,"none"); |
| 6849 | break; |
| 6850 | } |
| 6851 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6852 | break; |
| 6853 | } |
| 6854 | if (LocaleCompare("ping",option+1) == 0) |
| 6855 | { |
| 6856 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6857 | break; |
| 6858 | } |
| 6859 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6860 | { |
| 6861 | if (*option == '+') |
| 6862 | geometry_info.rho=0.0; |
| 6863 | else |
| 6864 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6865 | image_info->pointsize=geometry_info.rho; |
| 6866 | break; |
| 6867 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6868 | if (LocaleCompare("precision",option+1) == 0) |
| 6869 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6870 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6871 | break; |
| 6872 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6873 | if (LocaleCompare("preview",option+1) == 0) |
| 6874 | { |
| 6875 | /* |
| 6876 | Preview image. |
| 6877 | */ |
| 6878 | if (*option == '+') |
| 6879 | { |
| 6880 | image_info->preview_type=UndefinedPreview; |
| 6881 | break; |
| 6882 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6883 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6884 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6885 | break; |
| 6886 | } |
| 6887 | break; |
| 6888 | } |
| 6889 | case 'q': |
| 6890 | { |
| 6891 | if (LocaleCompare("quality",option+1) == 0) |
| 6892 | { |
| 6893 | /* |
| 6894 | Set image compression quality. |
| 6895 | */ |
| 6896 | if (*option == '+') |
| 6897 | { |
| 6898 | image_info->quality=UndefinedCompressionQuality; |
| 6899 | (void) SetImageOption(image_info,option+1,"0"); |
| 6900 | break; |
| 6901 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6902 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6903 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6904 | break; |
| 6905 | } |
| 6906 | if (LocaleCompare("quiet",option+1) == 0) |
| 6907 | { |
| 6908 | static WarningHandler |
| 6909 | warning_handler = (WarningHandler) NULL; |
| 6910 | |
| 6911 | if (*option == '+') |
| 6912 | { |
| 6913 | /* |
| 6914 | Restore error or warning messages. |
| 6915 | */ |
| 6916 | warning_handler=SetWarningHandler(warning_handler); |
| 6917 | break; |
| 6918 | } |
| 6919 | /* |
| 6920 | Suppress error or warning messages. |
| 6921 | */ |
| 6922 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6923 | break; |
| 6924 | } |
| 6925 | break; |
| 6926 | } |
| 6927 | case 'r': |
| 6928 | { |
| 6929 | if (LocaleCompare("red-primary",option+1) == 0) |
| 6930 | { |
| 6931 | if (*option == '+') |
| 6932 | { |
| 6933 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6934 | break; |
| 6935 | } |
| 6936 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6937 | break; |
| 6938 | } |
| 6939 | break; |
| 6940 | } |
| 6941 | case 's': |
| 6942 | { |
| 6943 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 6944 | { |
| 6945 | /* |
| 6946 | Set image sampling factor. |
| 6947 | */ |
| 6948 | if (*option == '+') |
| 6949 | { |
| 6950 | if (image_info->sampling_factor != (char *) NULL) |
| 6951 | image_info->sampling_factor=DestroyString( |
| 6952 | image_info->sampling_factor); |
| 6953 | break; |
| 6954 | } |
| 6955 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 6956 | break; |
| 6957 | } |
| 6958 | if (LocaleCompare("scene",option+1) == 0) |
| 6959 | { |
| 6960 | /* |
| 6961 | Set image scene. |
| 6962 | */ |
| 6963 | if (*option == '+') |
| 6964 | { |
| 6965 | image_info->scene=0; |
| 6966 | (void) SetImageOption(image_info,option+1,"0"); |
| 6967 | break; |
| 6968 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6969 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6970 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6971 | break; |
| 6972 | } |
| 6973 | if (LocaleCompare("seed",option+1) == 0) |
| 6974 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6975 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6976 | seed; |
| 6977 | |
| 6978 | if (*option == '+') |
| 6979 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6980 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6981 | SeedPseudoRandomGenerator(seed); |
| 6982 | break; |
| 6983 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6984 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6985 | SeedPseudoRandomGenerator(seed); |
| 6986 | break; |
| 6987 | } |
| 6988 | if (LocaleCompare("size",option+1) == 0) |
| 6989 | { |
| 6990 | if (*option == '+') |
| 6991 | { |
| 6992 | if (image_info->size != (char *) NULL) |
| 6993 | image_info->size=DestroyString(image_info->size); |
| 6994 | break; |
| 6995 | } |
| 6996 | (void) CloneString(&image_info->size,argv[i+1]); |
| 6997 | break; |
| 6998 | } |
| 6999 | if (LocaleCompare("stroke",option+1) == 0) |
| 7000 | { |
| 7001 | if (*option == '+') |
| 7002 | { |
| 7003 | (void) SetImageOption(image_info,option+1,"none"); |
| 7004 | break; |
| 7005 | } |
| 7006 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7007 | break; |
| 7008 | } |
| 7009 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7010 | { |
| 7011 | if (*option == '+') |
| 7012 | { |
| 7013 | (void) SetImageOption(image_info,option+1,"0"); |
| 7014 | break; |
| 7015 | } |
| 7016 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7017 | break; |
| 7018 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7019 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7020 | { |
| 7021 | if (*option == '+') |
| 7022 | { |
| 7023 | image_info->synchronize=MagickFalse; |
| 7024 | break; |
| 7025 | } |
| 7026 | image_info->synchronize=MagickTrue; |
| 7027 | break; |
| 7028 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7029 | break; |
| 7030 | } |
| 7031 | case 't': |
| 7032 | { |
| 7033 | if (LocaleCompare("taint",option+1) == 0) |
| 7034 | { |
| 7035 | if (*option == '+') |
| 7036 | { |
| 7037 | (void) SetImageOption(image_info,option+1,"false"); |
| 7038 | break; |
| 7039 | } |
| 7040 | (void) SetImageOption(image_info,option+1,"true"); |
| 7041 | break; |
| 7042 | } |
| 7043 | if (LocaleCompare("texture",option+1) == 0) |
| 7044 | { |
| 7045 | if (*option == '+') |
| 7046 | { |
| 7047 | if (image_info->texture != (char *) NULL) |
| 7048 | image_info->texture=DestroyString(image_info->texture); |
| 7049 | break; |
| 7050 | } |
| 7051 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7052 | break; |
| 7053 | } |
| 7054 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7055 | { |
| 7056 | if (*option == '+') |
| 7057 | { |
| 7058 | (void) SetImageOption(image_info,option+1,"0"); |
| 7059 | break; |
| 7060 | } |
| 7061 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7062 | break; |
| 7063 | } |
| 7064 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7065 | { |
| 7066 | if (*option == '+') |
| 7067 | { |
| 7068 | (void) QueryColorDatabase("none",&image_info->transparent_color, exception); |
| 7069 | (void) SetImageOption(image_info,option+1,"none"); |
| 7070 | break; |
| 7071 | } |
| 7072 | (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color, |
| 7073 | exception); |
| 7074 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7075 | break; |
| 7076 | } |
| 7077 | if (LocaleCompare("type",option+1) == 0) |
| 7078 | { |
| 7079 | if (*option == '+') |
| 7080 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7081 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7082 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7083 | break; |
| 7084 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7085 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7086 | MagickFalse,argv[i+1]); |
| 7087 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7088 | break; |
| 7089 | } |
| 7090 | break; |
| 7091 | } |
| 7092 | case 'u': |
| 7093 | { |
| 7094 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7095 | { |
| 7096 | if (*option == '+') |
| 7097 | { |
| 7098 | (void) DeleteImageOption(image_info,option+1); |
| 7099 | break; |
| 7100 | } |
| 7101 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7102 | break; |
| 7103 | } |
| 7104 | if (LocaleCompare("units",option+1) == 0) |
| 7105 | { |
| 7106 | if (*option == '+') |
| 7107 | { |
| 7108 | image_info->units=UndefinedResolution; |
| 7109 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7110 | break; |
| 7111 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7112 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7113 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7114 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7115 | break; |
| 7116 | } |
| 7117 | break; |
| 7118 | } |
| 7119 | case 'v': |
| 7120 | { |
| 7121 | if (LocaleCompare("verbose",option+1) == 0) |
| 7122 | { |
| 7123 | if (*option == '+') |
| 7124 | { |
| 7125 | image_info->verbose=MagickFalse; |
| 7126 | break; |
| 7127 | } |
| 7128 | image_info->verbose=MagickTrue; |
| 7129 | image_info->ping=MagickFalse; |
| 7130 | break; |
| 7131 | } |
| 7132 | if (LocaleCompare("view",option+1) == 0) |
| 7133 | { |
| 7134 | if (*option == '+') |
| 7135 | { |
| 7136 | if (image_info->view != (char *) NULL) |
| 7137 | image_info->view=DestroyString(image_info->view); |
| 7138 | break; |
| 7139 | } |
| 7140 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7141 | break; |
| 7142 | } |
| 7143 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7144 | { |
| 7145 | if (*option == '+') |
| 7146 | { |
| 7147 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7148 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7149 | break; |
| 7150 | } |
| 7151 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7152 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7153 | argv[i+1]); |
| 7154 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7155 | break; |
| 7156 | } |
| 7157 | break; |
| 7158 | } |
| 7159 | case 'w': |
| 7160 | { |
| 7161 | if (LocaleCompare("white-point",option+1) == 0) |
| 7162 | { |
| 7163 | if (*option == '+') |
| 7164 | { |
| 7165 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7166 | break; |
| 7167 | } |
| 7168 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7169 | break; |
| 7170 | } |
| 7171 | break; |
| 7172 | } |
| 7173 | default: |
| 7174 | break; |
| 7175 | } |
| 7176 | i+=count; |
| 7177 | } |
| 7178 | return(MagickTrue); |
| 7179 | } |
| 7180 | |
| 7181 | /* |
| 7182 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7183 | % % |
| 7184 | % % |
| 7185 | % % |
| 7186 | + M o g r i f y I m a g e L i s t % |
| 7187 | % % |
| 7188 | % % |
| 7189 | % % |
| 7190 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7191 | % |
| 7192 | % MogrifyImageList() applies any command line options that might affect the |
| 7193 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7194 | % |
| 7195 | % The format of the MogrifyImage method is: |
| 7196 | % |
| 7197 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7198 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7199 | % |
| 7200 | % A description of each parameter follows: |
| 7201 | % |
| 7202 | % o image_info: the image info.. |
| 7203 | % |
| 7204 | % o argc: Specifies a pointer to an integer describing the number of |
| 7205 | % elements in the argument vector. |
| 7206 | % |
| 7207 | % o argv: Specifies a pointer to a text array containing the command line |
| 7208 | % arguments. |
| 7209 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7210 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7211 | % |
| 7212 | % o exception: return any errors or warnings in this structure. |
| 7213 | % |
| 7214 | */ |
| 7215 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7216 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7217 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7218 | const char |
| 7219 | *option; |
| 7220 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7221 | ImageInfo |
| 7222 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7223 | |
| 7224 | MagickStatusType |
| 7225 | status; |
| 7226 | |
| 7227 | QuantizeInfo |
| 7228 | *quantize_info; |
| 7229 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7230 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7231 | i; |
| 7232 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7233 | ssize_t |
| 7234 | count, |
| 7235 | index; |
| 7236 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7237 | /* |
| 7238 | Apply options to the image list. |
| 7239 | */ |
| 7240 | assert(image_info != (ImageInfo *) NULL); |
| 7241 | assert(image_info->signature == MagickSignature); |
| 7242 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7243 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7244 | assert((*images)->signature == MagickSignature); |
| 7245 | if ((*images)->debug != MagickFalse) |
| 7246 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7247 | (*images)->filename); |
| 7248 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7249 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7250 | mogrify_info=CloneImageInfo(image_info); |
| 7251 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7252 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7253 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7254 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7255 | if (*images == (Image *) NULL) |
| 7256 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7257 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7258 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7259 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7260 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7261 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7262 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7263 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7264 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7265 | switch (*(option+1)) |
| 7266 | { |
| 7267 | case 'a': |
| 7268 | { |
| 7269 | if (LocaleCompare("affinity",option+1) == 0) |
| 7270 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7271 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7272 | if (*option == '+') |
| 7273 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7274 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7275 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7276 | break; |
| 7277 | } |
| 7278 | i++; |
| 7279 | break; |
| 7280 | } |
| 7281 | if (LocaleCompare("append",option+1) == 0) |
| 7282 | { |
| 7283 | Image |
| 7284 | *append_image; |
| 7285 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7286 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7287 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7288 | MagickFalse,exception); |
| 7289 | if (append_image == (Image *) NULL) |
| 7290 | { |
| 7291 | status=MagickFalse; |
| 7292 | break; |
| 7293 | } |
| 7294 | *images=DestroyImageList(*images); |
| 7295 | *images=append_image; |
| 7296 | break; |
| 7297 | } |
| 7298 | if (LocaleCompare("average",option+1) == 0) |
| 7299 | { |
| 7300 | Image |
| 7301 | *average_image; |
| 7302 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7303 | /* |
| 7304 | Average an image sequence (deprecated). |
| 7305 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7306 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7307 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7308 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7309 | if (average_image == (Image *) NULL) |
| 7310 | { |
| 7311 | status=MagickFalse; |
| 7312 | break; |
| 7313 | } |
| 7314 | *images=DestroyImageList(*images); |
| 7315 | *images=average_image; |
| 7316 | break; |
| 7317 | } |
| 7318 | break; |
| 7319 | } |
| 7320 | case 'c': |
| 7321 | { |
| 7322 | if (LocaleCompare("channel",option+1) == 0) |
| 7323 | { |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7324 | ChannelType |
| 7325 | channel; |
| 7326 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7327 | if (*option == '+') |
| 7328 | { |
| 7329 | channel=DefaultChannels; |
| 7330 | break; |
| 7331 | } |
| 7332 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 7333 | SetPixelChannelMap(*images,channel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7334 | break; |
| 7335 | } |
| 7336 | if (LocaleCompare("clut",option+1) == 0) |
| 7337 | { |
| 7338 | Image |
| 7339 | *clut_image, |
| 7340 | *image; |
| 7341 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7342 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7343 | image=RemoveFirstImageFromList(images); |
| 7344 | clut_image=RemoveFirstImageFromList(images); |
| 7345 | if (clut_image == (Image *) NULL) |
| 7346 | { |
| 7347 | status=MagickFalse; |
| 7348 | break; |
| 7349 | } |
cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame^] | 7350 | (void) ClutImage(image,clut_image,image->interpolate,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7351 | clut_image=DestroyImage(clut_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7352 | *images=DestroyImageList(*images); |
| 7353 | *images=image; |
| 7354 | break; |
| 7355 | } |
| 7356 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7357 | { |
| 7358 | Image |
| 7359 | *coalesce_image; |
| 7360 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7361 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7362 | coalesce_image=CoalesceImages(*images,exception); |
| 7363 | if (coalesce_image == (Image *) NULL) |
| 7364 | { |
| 7365 | status=MagickFalse; |
| 7366 | break; |
| 7367 | } |
| 7368 | *images=DestroyImageList(*images); |
| 7369 | *images=coalesce_image; |
| 7370 | break; |
| 7371 | } |
| 7372 | if (LocaleCompare("combine",option+1) == 0) |
| 7373 | { |
| 7374 | Image |
| 7375 | *combine_image; |
| 7376 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7377 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 7378 | combine_image=CombineImages(*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7379 | if (combine_image == (Image *) NULL) |
| 7380 | { |
| 7381 | status=MagickFalse; |
| 7382 | break; |
| 7383 | } |
| 7384 | *images=DestroyImageList(*images); |
| 7385 | *images=combine_image; |
| 7386 | break; |
| 7387 | } |
| 7388 | if (LocaleCompare("composite",option+1) == 0) |
| 7389 | { |
| 7390 | Image |
| 7391 | *mask_image, |
| 7392 | *composite_image, |
| 7393 | *image; |
| 7394 | |
| 7395 | RectangleInfo |
| 7396 | geometry; |
| 7397 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7398 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7399 | image=RemoveFirstImageFromList(images); |
| 7400 | composite_image=RemoveFirstImageFromList(images); |
| 7401 | if (composite_image == (Image *) NULL) |
| 7402 | { |
| 7403 | status=MagickFalse; |
| 7404 | break; |
| 7405 | } |
| 7406 | (void) TransformImage(&composite_image,(char *) NULL, |
| 7407 | composite_image->geometry); |
| 7408 | SetGeometry(composite_image,&geometry); |
| 7409 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7410 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7411 | &geometry); |
| 7412 | mask_image=RemoveFirstImageFromList(images); |
| 7413 | if (mask_image != (Image *) NULL) |
| 7414 | { |
| 7415 | if ((image->compose == DisplaceCompositeOp) || |
| 7416 | (image->compose == DistortCompositeOp)) |
| 7417 | { |
| 7418 | /* |
| 7419 | Merge Y displacement into X displacement image. |
| 7420 | */ |
| 7421 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
| 7422 | mask_image,0,0); |
| 7423 | mask_image=DestroyImage(mask_image); |
| 7424 | } |
| 7425 | else |
| 7426 | { |
| 7427 | /* |
| 7428 | Set a blending mask for the composition. |
| 7429 | */ |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7430 | /* POSIBLE ERROR; what if image->mask already set */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7431 | image->mask=mask_image; |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 7432 | (void) NegateImage(image->mask,MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7433 | } |
| 7434 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7435 | (void) CompositeImage(image,image->compose,composite_image, |
| 7436 | geometry.x,geometry.y); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7437 | if (mask_image != (Image *) NULL) |
| 7438 | mask_image=image->mask=DestroyImage(image->mask); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7439 | composite_image=DestroyImage(composite_image); |
| 7440 | InheritException(exception,&image->exception); |
| 7441 | *images=DestroyImageList(*images); |
| 7442 | *images=image; |
| 7443 | break; |
| 7444 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7445 | #if 0 |
| 7446 | This has been merged completely into MogrifyImage() |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7447 | if (LocaleCompare("crop",option+1) == 0) |
| 7448 | { |
| 7449 | MagickStatusType |
| 7450 | flags; |
| 7451 | |
| 7452 | RectangleInfo |
| 7453 | geometry; |
| 7454 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7455 | /* |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7456 | Crop Image. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7457 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7458 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7459 | flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception); |
| 7460 | if (((geometry.width == 0) && (geometry.height == 0)) || |
| 7461 | ((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 7462 | break; |
| 7463 | (void) TransformImages(images,argv[i+1],(char *) NULL); |
| 7464 | InheritException(exception,&(*images)->exception); |
| 7465 | break; |
| 7466 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7467 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7468 | break; |
| 7469 | } |
| 7470 | case 'd': |
| 7471 | { |
| 7472 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7473 | { |
| 7474 | Image |
| 7475 | *deconstruct_image; |
| 7476 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7477 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7478 | deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer, |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 7479 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7480 | if (deconstruct_image == (Image *) NULL) |
| 7481 | { |
| 7482 | status=MagickFalse; |
| 7483 | break; |
| 7484 | } |
| 7485 | *images=DestroyImageList(*images); |
| 7486 | *images=deconstruct_image; |
| 7487 | break; |
| 7488 | } |
| 7489 | if (LocaleCompare("delete",option+1) == 0) |
| 7490 | { |
| 7491 | if (*option == '+') |
| 7492 | DeleteImages(images,"-1",exception); |
| 7493 | else |
| 7494 | DeleteImages(images,argv[i+1],exception); |
| 7495 | break; |
| 7496 | } |
| 7497 | if (LocaleCompare("dither",option+1) == 0) |
| 7498 | { |
| 7499 | if (*option == '+') |
| 7500 | { |
| 7501 | quantize_info->dither=MagickFalse; |
| 7502 | break; |
| 7503 | } |
| 7504 | quantize_info->dither=MagickTrue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7505 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7506 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7507 | break; |
| 7508 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7509 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7510 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7511 | Image |
| 7512 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7513 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7514 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7515 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7516 | else |
| 7517 | { |
| 7518 | const char |
| 7519 | *p; |
| 7520 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7521 | size_t |
| 7522 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7523 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7524 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7525 | p=strchr(argv[i+1],','); |
| 7526 | if (p == (const char *) NULL) |
| 7527 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7528 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7529 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7530 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7531 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7532 | } |
| 7533 | AppendImageToList(images, duplicate_images); |
| 7534 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7535 | break; |
| 7536 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7537 | break; |
| 7538 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7539 | case 'e': |
| 7540 | { |
| 7541 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7542 | { |
| 7543 | Image |
| 7544 | *evaluate_image; |
| 7545 | |
| 7546 | MagickEvaluateOperator |
| 7547 | op; |
| 7548 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7549 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7550 | op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions, |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7551 | MagickFalse,argv[i+1]); |
| 7552 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7553 | if (evaluate_image == (Image *) NULL) |
| 7554 | { |
| 7555 | status=MagickFalse; |
| 7556 | break; |
| 7557 | } |
| 7558 | *images=DestroyImageList(*images); |
| 7559 | *images=evaluate_image; |
| 7560 | break; |
| 7561 | } |
| 7562 | break; |
| 7563 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7564 | case 'f': |
| 7565 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7566 | if (LocaleCompare("fft",option+1) == 0) |
| 7567 | { |
| 7568 | Image |
| 7569 | *fourier_image; |
| 7570 | |
| 7571 | /* |
| 7572 | Implements the discrete Fourier transform (DFT). |
| 7573 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7574 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7575 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7576 | MagickTrue : MagickFalse,exception); |
| 7577 | if (fourier_image == (Image *) NULL) |
| 7578 | break; |
| 7579 | *images=DestroyImage(*images); |
| 7580 | *images=fourier_image; |
| 7581 | break; |
| 7582 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7583 | if (LocaleCompare("flatten",option+1) == 0) |
| 7584 | { |
| 7585 | Image |
| 7586 | *flatten_image; |
| 7587 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7588 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7589 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7590 | if (flatten_image == (Image *) NULL) |
| 7591 | break; |
| 7592 | *images=DestroyImageList(*images); |
| 7593 | *images=flatten_image; |
| 7594 | break; |
| 7595 | } |
| 7596 | if (LocaleCompare("fx",option+1) == 0) |
| 7597 | { |
| 7598 | Image |
| 7599 | *fx_image; |
| 7600 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7601 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 7602 | fx_image=FxImage(*images,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7603 | if (fx_image == (Image *) NULL) |
| 7604 | { |
| 7605 | status=MagickFalse; |
| 7606 | break; |
| 7607 | } |
| 7608 | *images=DestroyImageList(*images); |
| 7609 | *images=fx_image; |
| 7610 | break; |
| 7611 | } |
| 7612 | break; |
| 7613 | } |
| 7614 | case 'h': |
| 7615 | { |
| 7616 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7617 | { |
| 7618 | Image |
| 7619 | *hald_image, |
| 7620 | *image; |
| 7621 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7622 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7623 | image=RemoveFirstImageFromList(images); |
| 7624 | hald_image=RemoveFirstImageFromList(images); |
| 7625 | if (hald_image == (Image *) NULL) |
| 7626 | { |
| 7627 | status=MagickFalse; |
| 7628 | break; |
| 7629 | } |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 7630 | (void) HaldClutImage(image,hald_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7631 | hald_image=DestroyImage(hald_image); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7632 | if (*images != (Image *) NULL) |
| 7633 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7634 | *images=image; |
| 7635 | break; |
| 7636 | } |
| 7637 | break; |
| 7638 | } |
| 7639 | case 'i': |
| 7640 | { |
| 7641 | if (LocaleCompare("ift",option+1) == 0) |
| 7642 | { |
| 7643 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7644 | *fourier_image, |
| 7645 | *magnitude_image, |
| 7646 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7647 | |
| 7648 | /* |
| 7649 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7650 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7651 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7652 | magnitude_image=RemoveFirstImageFromList(images); |
| 7653 | phase_image=RemoveFirstImageFromList(images); |
| 7654 | if (phase_image == (Image *) NULL) |
| 7655 | { |
| 7656 | status=MagickFalse; |
| 7657 | break; |
| 7658 | } |
| 7659 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7660 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7661 | if (fourier_image == (Image *) NULL) |
| 7662 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7663 | if (*images != (Image *) NULL) |
| 7664 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7665 | *images=fourier_image; |
| 7666 | break; |
| 7667 | } |
| 7668 | if (LocaleCompare("insert",option+1) == 0) |
| 7669 | { |
| 7670 | Image |
| 7671 | *p, |
| 7672 | *q; |
| 7673 | |
| 7674 | index=0; |
| 7675 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7676 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7677 | p=RemoveLastImageFromList(images); |
| 7678 | if (p == (Image *) NULL) |
| 7679 | { |
| 7680 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7681 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7682 | status=MagickFalse; |
| 7683 | break; |
| 7684 | } |
| 7685 | q=p; |
| 7686 | if (index == 0) |
| 7687 | PrependImageToList(images,q); |
| 7688 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7689 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7690 | AppendImageToList(images,q); |
| 7691 | else |
| 7692 | { |
| 7693 | q=GetImageFromList(*images,index-1); |
| 7694 | if (q == (Image *) NULL) |
| 7695 | { |
| 7696 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7697 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7698 | status=MagickFalse; |
| 7699 | break; |
| 7700 | } |
| 7701 | InsertImageInList(&q,p); |
| 7702 | } |
| 7703 | *images=GetFirstImageInList(q); |
| 7704 | break; |
| 7705 | } |
| 7706 | break; |
| 7707 | } |
| 7708 | case 'l': |
| 7709 | { |
| 7710 | if (LocaleCompare("layers",option+1) == 0) |
| 7711 | { |
| 7712 | Image |
| 7713 | *layers; |
| 7714 | |
| 7715 | ImageLayerMethod |
| 7716 | method; |
| 7717 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7718 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7719 | layers=(Image *) NULL; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7720 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7721 | MagickFalse,argv[i+1]); |
| 7722 | switch (method) |
| 7723 | { |
| 7724 | case CoalesceLayer: |
| 7725 | { |
| 7726 | layers=CoalesceImages(*images,exception); |
| 7727 | break; |
| 7728 | } |
| 7729 | case CompareAnyLayer: |
| 7730 | case CompareClearLayer: |
| 7731 | case CompareOverlayLayer: |
| 7732 | default: |
| 7733 | { |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7734 | layers=CompareImagesLayers(*images,method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7735 | break; |
| 7736 | } |
| 7737 | case MergeLayer: |
| 7738 | case FlattenLayer: |
| 7739 | case MosaicLayer: |
| 7740 | case TrimBoundsLayer: |
| 7741 | { |
| 7742 | layers=MergeImageLayers(*images,method,exception); |
| 7743 | break; |
| 7744 | } |
| 7745 | case DisposeLayer: |
| 7746 | { |
| 7747 | layers=DisposeImages(*images,exception); |
| 7748 | break; |
| 7749 | } |
| 7750 | case OptimizeImageLayer: |
| 7751 | { |
| 7752 | layers=OptimizeImageLayers(*images,exception); |
| 7753 | break; |
| 7754 | } |
| 7755 | case OptimizePlusLayer: |
| 7756 | { |
| 7757 | layers=OptimizePlusImageLayers(*images,exception); |
| 7758 | break; |
| 7759 | } |
| 7760 | case OptimizeTransLayer: |
| 7761 | { |
| 7762 | OptimizeImageTransparency(*images,exception); |
| 7763 | break; |
| 7764 | } |
| 7765 | case RemoveDupsLayer: |
| 7766 | { |
| 7767 | RemoveDuplicateLayers(images,exception); |
| 7768 | break; |
| 7769 | } |
| 7770 | case RemoveZeroLayer: |
| 7771 | { |
| 7772 | RemoveZeroDelayLayers(images,exception); |
| 7773 | break; |
| 7774 | } |
| 7775 | case OptimizeLayer: |
| 7776 | { |
| 7777 | /* |
| 7778 | General Purpose, GIF Animation Optimizer. |
| 7779 | */ |
| 7780 | layers=CoalesceImages(*images,exception); |
| 7781 | if (layers == (Image *) NULL) |
| 7782 | { |
| 7783 | status=MagickFalse; |
| 7784 | break; |
| 7785 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7786 | *images=DestroyImageList(*images); |
| 7787 | *images=layers; |
| 7788 | layers=OptimizeImageLayers(*images,exception); |
| 7789 | if (layers == (Image *) NULL) |
| 7790 | { |
| 7791 | status=MagickFalse; |
| 7792 | break; |
| 7793 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7794 | *images=DestroyImageList(*images); |
| 7795 | *images=layers; |
| 7796 | layers=(Image *) NULL; |
| 7797 | OptimizeImageTransparency(*images,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7798 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7799 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7800 | break; |
| 7801 | } |
| 7802 | case CompositeLayer: |
| 7803 | { |
| 7804 | CompositeOperator |
| 7805 | compose; |
| 7806 | |
| 7807 | Image |
| 7808 | *source; |
| 7809 | |
| 7810 | RectangleInfo |
| 7811 | geometry; |
| 7812 | |
| 7813 | /* |
| 7814 | Split image sequence at the first 'NULL:' image. |
| 7815 | */ |
| 7816 | source=(*images); |
| 7817 | while (source != (Image *) NULL) |
| 7818 | { |
| 7819 | source=GetNextImageInList(source); |
| 7820 | if ((source != (Image *) NULL) && |
| 7821 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7822 | break; |
| 7823 | } |
| 7824 | if (source != (Image *) NULL) |
| 7825 | { |
| 7826 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7827 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7828 | source=(Image *) NULL; |
| 7829 | else |
| 7830 | { |
| 7831 | /* |
| 7832 | Separate the two lists, junk the null: image. |
| 7833 | */ |
| 7834 | source=SplitImageList(source->previous); |
| 7835 | DeleteImageFromList(&source); |
| 7836 | } |
| 7837 | } |
| 7838 | if (source == (Image *) NULL) |
| 7839 | { |
| 7840 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7841 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7842 | status=MagickFalse; |
| 7843 | break; |
| 7844 | } |
| 7845 | /* |
| 7846 | Adjust offset with gravity and virtual canvas. |
| 7847 | */ |
| 7848 | SetGeometry(*images,&geometry); |
| 7849 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7850 | geometry.width=source->page.width != 0 ? |
| 7851 | source->page.width : source->columns; |
| 7852 | geometry.height=source->page.height != 0 ? |
| 7853 | source->page.height : source->rows; |
| 7854 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7855 | (*images)->page.width : (*images)->columns, |
| 7856 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7857 | (*images)->rows,(*images)->gravity,&geometry); |
| 7858 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7859 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7860 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7861 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7862 | MagickComposeOptions,MagickFalse,option); |
| 7863 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7864 | exception); |
| 7865 | source=DestroyImageList(source); |
| 7866 | break; |
| 7867 | } |
| 7868 | } |
| 7869 | if (layers == (Image *) NULL) |
| 7870 | break; |
| 7871 | InheritException(exception,&layers->exception); |
| 7872 | *images=DestroyImageList(*images); |
| 7873 | *images=layers; |
| 7874 | break; |
| 7875 | } |
| 7876 | break; |
| 7877 | } |
| 7878 | case 'm': |
| 7879 | { |
| 7880 | if (LocaleCompare("map",option+1) == 0) |
| 7881 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7882 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7883 | if (*option == '+') |
| 7884 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7885 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7886 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7887 | break; |
| 7888 | } |
| 7889 | i++; |
| 7890 | break; |
| 7891 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7892 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7893 | { |
| 7894 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7895 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7896 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7897 | /* |
| 7898 | Maximum image sequence (deprecated). |
| 7899 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7900 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7901 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7902 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7903 | { |
| 7904 | status=MagickFalse; |
| 7905 | break; |
| 7906 | } |
| 7907 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7908 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7909 | break; |
| 7910 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7911 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7912 | { |
| 7913 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7914 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7915 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7916 | /* |
| 7917 | Minimum image sequence (deprecated). |
| 7918 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7919 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7920 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7921 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7922 | { |
| 7923 | status=MagickFalse; |
| 7924 | break; |
| 7925 | } |
| 7926 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7927 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7928 | break; |
| 7929 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7930 | if (LocaleCompare("morph",option+1) == 0) |
| 7931 | { |
| 7932 | Image |
| 7933 | *morph_image; |
| 7934 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7935 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7936 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7937 | exception); |
| 7938 | if (morph_image == (Image *) NULL) |
| 7939 | { |
| 7940 | status=MagickFalse; |
| 7941 | break; |
| 7942 | } |
| 7943 | *images=DestroyImageList(*images); |
| 7944 | *images=morph_image; |
| 7945 | break; |
| 7946 | } |
| 7947 | if (LocaleCompare("mosaic",option+1) == 0) |
| 7948 | { |
| 7949 | Image |
| 7950 | *mosaic_image; |
| 7951 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7952 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7953 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 7954 | if (mosaic_image == (Image *) NULL) |
| 7955 | { |
| 7956 | status=MagickFalse; |
| 7957 | break; |
| 7958 | } |
| 7959 | *images=DestroyImageList(*images); |
| 7960 | *images=mosaic_image; |
| 7961 | break; |
| 7962 | } |
| 7963 | break; |
| 7964 | } |
| 7965 | case 'p': |
| 7966 | { |
| 7967 | if (LocaleCompare("print",option+1) == 0) |
| 7968 | { |
| 7969 | char |
| 7970 | *string; |
| 7971 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7972 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7973 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1], |
| 7974 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7975 | if (string == (char *) NULL) |
| 7976 | break; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 7977 | (void) FormatLocaleFile(stdout,"%s",string); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7978 | string=DestroyString(string); |
| 7979 | } |
| 7980 | if (LocaleCompare("process",option+1) == 0) |
| 7981 | { |
| 7982 | char |
| 7983 | **arguments; |
| 7984 | |
| 7985 | int |
| 7986 | j, |
| 7987 | number_arguments; |
| 7988 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7989 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7990 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 7991 | if (arguments == (char **) NULL) |
| 7992 | break; |
| 7993 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 7994 | { |
| 7995 | char |
| 7996 | breaker, |
| 7997 | quote, |
| 7998 | *token; |
| 7999 | |
| 8000 | const char |
| 8001 | *arguments; |
| 8002 | |
| 8003 | int |
| 8004 | next, |
| 8005 | status; |
| 8006 | |
| 8007 | size_t |
| 8008 | length; |
| 8009 | |
| 8010 | TokenInfo |
| 8011 | *token_info; |
| 8012 | |
| 8013 | /* |
| 8014 | Support old style syntax, filter="-option arg". |
| 8015 | */ |
| 8016 | length=strlen(argv[i+1]); |
| 8017 | token=(char *) NULL; |
cristy | 37e0b38 | 2011-06-07 13:31:21 +0000 | [diff] [blame] | 8018 | if (~length >= (MaxTextExtent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8019 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8020 | sizeof(*token)); |
| 8021 | if (token == (char *) NULL) |
| 8022 | break; |
| 8023 | next=0; |
| 8024 | arguments=argv[i+1]; |
| 8025 | token_info=AcquireTokenInfo(); |
| 8026 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8027 | "\"",'\0',&breaker,&next,"e); |
| 8028 | token_info=DestroyTokenInfo(token_info); |
| 8029 | if (status == 0) |
| 8030 | { |
| 8031 | const char |
| 8032 | *argv; |
| 8033 | |
| 8034 | argv=(&(arguments[next])); |
| 8035 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8036 | exception); |
| 8037 | } |
| 8038 | token=DestroyString(token); |
| 8039 | break; |
| 8040 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8041 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8042 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8043 | number_arguments-2,(const char **) arguments+2,exception); |
| 8044 | for (j=0; j < number_arguments; j++) |
| 8045 | arguments[j]=DestroyString(arguments[j]); |
| 8046 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8047 | break; |
| 8048 | } |
| 8049 | break; |
| 8050 | } |
| 8051 | case 'r': |
| 8052 | { |
| 8053 | if (LocaleCompare("reverse",option+1) == 0) |
| 8054 | { |
| 8055 | ReverseImageList(images); |
| 8056 | InheritException(exception,&(*images)->exception); |
| 8057 | break; |
| 8058 | } |
| 8059 | break; |
| 8060 | } |
| 8061 | case 's': |
| 8062 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8063 | if (LocaleCompare("smush",option+1) == 0) |
| 8064 | { |
| 8065 | Image |
| 8066 | *smush_image; |
| 8067 | |
| 8068 | ssize_t |
| 8069 | offset; |
| 8070 | |
| 8071 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8072 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8073 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8074 | MagickFalse,offset,exception); |
| 8075 | if (smush_image == (Image *) NULL) |
| 8076 | { |
| 8077 | status=MagickFalse; |
| 8078 | break; |
| 8079 | } |
| 8080 | *images=DestroyImageList(*images); |
| 8081 | *images=smush_image; |
| 8082 | break; |
| 8083 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8084 | if (LocaleCompare("swap",option+1) == 0) |
| 8085 | { |
| 8086 | Image |
| 8087 | *p, |
| 8088 | *q, |
| 8089 | *swap; |
| 8090 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8091 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8092 | swap_index; |
| 8093 | |
| 8094 | index=(-1); |
| 8095 | swap_index=(-2); |
| 8096 | if (*option != '+') |
| 8097 | { |
| 8098 | GeometryInfo |
| 8099 | geometry_info; |
| 8100 | |
| 8101 | MagickStatusType |
| 8102 | flags; |
| 8103 | |
| 8104 | swap_index=(-1); |
| 8105 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8106 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8107 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8108 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8109 | } |
| 8110 | p=GetImageFromList(*images,index); |
| 8111 | q=GetImageFromList(*images,swap_index); |
| 8112 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8113 | { |
| 8114 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8115 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8116 | status=MagickFalse; |
| 8117 | break; |
| 8118 | } |
| 8119 | if (p == q) |
| 8120 | break; |
| 8121 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8122 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8123 | ReplaceImageInList(&q,swap); |
| 8124 | *images=GetFirstImageInList(q); |
| 8125 | break; |
| 8126 | } |
| 8127 | break; |
| 8128 | } |
| 8129 | case 'w': |
| 8130 | { |
| 8131 | if (LocaleCompare("write",option+1) == 0) |
| 8132 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8133 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8134 | key[MaxTextExtent]; |
| 8135 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8136 | Image |
| 8137 | *write_images; |
| 8138 | |
| 8139 | ImageInfo |
| 8140 | *write_info; |
| 8141 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8142 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8143 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8144 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8145 | write_images=(*images); |
| 8146 | if (*option == '+') |
| 8147 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8148 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8149 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8150 | write_info=DestroyImageInfo(write_info); |
| 8151 | if (*option == '+') |
| 8152 | write_images=DestroyImageList(write_images); |
| 8153 | break; |
| 8154 | } |
| 8155 | break; |
| 8156 | } |
| 8157 | default: |
| 8158 | break; |
| 8159 | } |
| 8160 | i+=count; |
| 8161 | } |
| 8162 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8163 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8164 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8165 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8166 | } |
| 8167 | |
| 8168 | /* |
| 8169 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8170 | % % |
| 8171 | % % |
| 8172 | % % |
| 8173 | + M o g r i f y I m a g e s % |
| 8174 | % % |
| 8175 | % % |
| 8176 | % % |
| 8177 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8178 | % |
| 8179 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8180 | % prescribed by command line options. |
| 8181 | % |
| 8182 | % The format of the MogrifyImage method is: |
| 8183 | % |
| 8184 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8185 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8186 | % Image **images,Exceptioninfo *exception) |
| 8187 | % |
| 8188 | % A description of each parameter follows: |
| 8189 | % |
| 8190 | % o image_info: the image info.. |
| 8191 | % |
| 8192 | % o post: If true, post process image list operators otherwise pre-process. |
| 8193 | % |
| 8194 | % o argc: Specifies a pointer to an integer describing the number of |
| 8195 | % elements in the argument vector. |
| 8196 | % |
| 8197 | % o argv: Specifies a pointer to a text array containing the command line |
| 8198 | % arguments. |
| 8199 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8200 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8201 | % |
| 8202 | % o exception: return any errors or warnings in this structure. |
| 8203 | % |
| 8204 | */ |
| 8205 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8206 | const MagickBooleanType post,const int argc,const char **argv, |
| 8207 | Image **images,ExceptionInfo *exception) |
| 8208 | { |
| 8209 | #define MogrifyImageTag "Mogrify/Image" |
| 8210 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8211 | MagickStatusType |
| 8212 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8213 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8214 | MagickBooleanType |
| 8215 | proceed; |
| 8216 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8217 | size_t |
| 8218 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8219 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8220 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8221 | i; |
| 8222 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8223 | assert(image_info != (ImageInfo *) NULL); |
| 8224 | assert(image_info->signature == MagickSignature); |
| 8225 | if (images == (Image **) NULL) |
| 8226 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8227 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8228 | assert((*images)->signature == MagickSignature); |
| 8229 | if ((*images)->debug != MagickFalse) |
| 8230 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8231 | (*images)->filename); |
| 8232 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8233 | return(MagickTrue); |
| 8234 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8235 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8236 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8237 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8238 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8239 | (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc, |
| 8240 | post?"post":"pre"); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8241 | #endif |
| 8242 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8243 | /* |
| 8244 | Pre-process multi-image sequence operators |
| 8245 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8246 | if (post == MagickFalse) |
| 8247 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8248 | /* |
| 8249 | For each image, process simple single image operators |
| 8250 | */ |
| 8251 | i=0; |
| 8252 | n=GetImageListLength(*images); |
| 8253 | for (;;) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8254 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8255 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8256 | (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long) |
| 8257 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8258 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8259 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8260 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8261 | if (proceed == MagickFalse) |
| 8262 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8263 | if ( (*images)->next == (Image *) NULL ) |
| 8264 | break; |
| 8265 | *images=(*images)->next; |
| 8266 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8267 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8268 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8269 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8270 | (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long) |
| 8271 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8272 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8273 | |
| 8274 | /* |
| 8275 | Post-process, multi-image sequence operators |
| 8276 | */ |
| 8277 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8278 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8279 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8280 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8281 | } |