cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % M M OOO GGGGG RRRR IIIII FFFFF Y Y % |
| 7 | % MM MM O O G R R I F Y Y % |
| 8 | % M M M O O G GGG RRRR I FFF Y % |
| 9 | % M M O O G G R R I F Y % |
| 10 | % M M OOO GGGG R R IIIII F Y % |
| 11 | % % |
| 12 | % % |
| 13 | % MagickWand Module Methods % |
| 14 | % % |
| 15 | % Software Design % |
| 16 | % John Cristy % |
| 17 | % March 2000 % |
| 18 | % % |
| 19 | % % |
cristy | 7e41fe8 | 2010-12-04 23:12:08 +0000 | [diff] [blame] | 20 | % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 21 | % dedicated to making software imaging solutions freely available. % |
| 22 | % % |
| 23 | % You may not use this file except in compliance with the License. You may % |
| 24 | % obtain a copy of the License at % |
| 25 | % % |
| 26 | % http://www.imagemagick.org/script/license.php % |
| 27 | % % |
| 28 | % Unless required by applicable law or agreed to in writing, software % |
| 29 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 30 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 31 | % See the License for the specific language governing permissions and % |
| 32 | % limitations under the License. % |
| 33 | % % |
| 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 35 | % |
| 36 | % Use the mogrify program to resize an image, blur, crop, despeckle, dither, |
| 37 | % draw on, flip, join, re-sample, and much more. This tool is similiar to |
| 38 | % convert except that the original image file is overwritten (unless you |
| 39 | % change the file suffix with the -format option) with any changes you |
cristy | 6a917d9 | 2009-10-06 19:23:54 +0000 | [diff] [blame] | 40 | % request. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 41 | % |
| 42 | */ |
| 43 | |
| 44 | /* |
| 45 | Include declarations. |
| 46 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 47 | #include "MagickWand/studio.h" |
| 48 | #include "MagickWand/MagickWand.h" |
| 49 | #include "MagickWand/mogrify-private.h" |
| 50 | #undef DegreesToRadians |
| 51 | #undef RadiansToDegrees |
| 52 | #include "MagickCore/image-private.h" |
| 53 | #include "MagickCore/monitor-private.h" |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 54 | #include "MagickCore/string-private.h" |
cristy | 0740a98 | 2011-10-13 15:01:01 +0000 | [diff] [blame] | 55 | #include "MagickCore/thread-private.h" |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 56 | #include "MagickCore/utility-private.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 57 | |
| 58 | /* |
cristy | 154fa9d | 2011-08-05 14:25:15 +0000 | [diff] [blame] | 59 | Constant declaration. |
| 60 | */ |
cristy | 3a557c0 | 2011-08-06 19:48:02 +0000 | [diff] [blame] | 61 | static const char |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 62 | MogrifyBackgroundColor[] = "#ffffff", /* white */ |
| 63 | MogrifyBorderColor[] = "#dfdfdf", /* gray */ |
| 64 | MogrifyMatteColor[] = "#bdbdbd"; /* gray */ |
cristy | 154fa9d | 2011-08-05 14:25:15 +0000 | [diff] [blame] | 65 | |
| 66 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 67 | Define declarations. |
| 68 | */ |
| 69 | #define UndefinedCompressionQuality 0UL |
| 70 | |
| 71 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 72 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 73 | % % |
| 74 | % % |
| 75 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 76 | % M a g i c k C o m m a n d G e n e s i s % |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 77 | % % |
| 78 | % % |
| 79 | % % |
| 80 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 81 | % |
| 82 | % MagickCommandGenesis() applies image processing options to an image as |
| 83 | % prescribed by command line options. |
| 84 | % |
| 85 | % The format of the MagickCommandGenesis method is: |
| 86 | % |
| 87 | % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 88 | % MagickCommand command,int argc,char **argv,char **metadata, |
| 89 | % ExceptionInfo *exception) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 90 | % |
| 91 | % A description of each parameter follows: |
| 92 | % |
| 93 | % o image_info: the image info. |
| 94 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 95 | % o command: Choose from ConvertImageCommand, IdentifyImageCommand, |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 96 | % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 97 | % ConjureImageCommand, StreamImageCommand, ImportImageCommand, |
| 98 | % DisplayImageCommand, or AnimateImageCommand. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 99 | % |
| 100 | % o argc: Specifies a pointer to an integer describing the number of |
| 101 | % elements in the argument vector. |
| 102 | % |
| 103 | % o argv: Specifies a pointer to a text array containing the command line |
| 104 | % arguments. |
| 105 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 106 | % o metadata: any metadata is returned here. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 107 | % |
| 108 | % o exception: return any errors or warnings in this structure. |
| 109 | % |
| 110 | */ |
| 111 | WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
| 112 | MagickCommand command,int argc,char **argv,char **metadata, |
| 113 | ExceptionInfo *exception) |
| 114 | { |
| 115 | char |
| 116 | *option; |
| 117 | |
| 118 | double |
| 119 | duration, |
| 120 | elapsed_time, |
| 121 | user_time; |
| 122 | |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 123 | MagickBooleanType |
| 124 | concurrent, |
| 125 | regard_warnings, |
| 126 | status; |
| 127 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 128 | register ssize_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 129 | i; |
| 130 | |
| 131 | TimerInfo |
| 132 | *timer; |
| 133 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 134 | size_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 135 | iterations; |
| 136 | |
cristy | d0a94fa | 2010-03-12 14:18:11 +0000 | [diff] [blame] | 137 | (void) setlocale(LC_ALL,""); |
| 138 | (void) setlocale(LC_NUMERIC,"C"); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 139 | concurrent=MagickFalse; |
| 140 | duration=(-1.0); |
| 141 | iterations=1; |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 142 | status=MagickFalse; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 143 | regard_warnings=MagickFalse; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 144 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 145 | { |
| 146 | option=argv[i]; |
| 147 | if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) |
| 148 | continue; |
| 149 | if (LocaleCompare("bench",option+1) == 0) |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 150 | iterations=StringToUnsignedLong(argv[++i]); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 151 | if (LocaleCompare("concurrent",option+1) == 0) |
| 152 | concurrent=MagickTrue; |
| 153 | if (LocaleCompare("debug",option+1) == 0) |
| 154 | (void) SetLogEventMask(argv[++i]); |
| 155 | if (LocaleCompare("duration",option+1) == 0) |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 156 | duration=StringToDouble(argv[++i],(char **) NULL); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 157 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 158 | regard_warnings=MagickTrue; |
| 159 | } |
| 160 | timer=AcquireTimerInfo(); |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 161 | if (concurrent == MagickFalse) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 162 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 163 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 164 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 165 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 166 | continue; |
| 167 | if (duration > 0) |
| 168 | { |
| 169 | if (GetElapsedTime(timer) > duration) |
| 170 | continue; |
| 171 | (void) ContinueTimer(timer); |
| 172 | } |
| 173 | status=command(image_info,argc,argv,metadata,exception); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 174 | if (exception->severity != UndefinedException) |
| 175 | { |
| 176 | if ((exception->severity > ErrorException) || |
| 177 | (regard_warnings != MagickFalse)) |
| 178 | status=MagickTrue; |
| 179 | CatchException(exception); |
| 180 | } |
cristy | 3d1a551 | 2009-10-25 21:23:27 +0000 | [diff] [blame] | 181 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 182 | { |
| 183 | (void) fputs(*metadata,stdout); |
| 184 | (void) fputc('\n',stdout); |
| 185 | *metadata=DestroyString(*metadata); |
| 186 | } |
| 187 | } |
| 188 | } |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 189 | else |
| 190 | { |
| 191 | SetOpenMPNested(1); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 192 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 193 | # pragma omp parallel for shared(status) |
| 194 | #endif |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 195 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 196 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 197 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 198 | continue; |
| 199 | if (duration > 0) |
| 200 | { |
| 201 | if (GetElapsedTime(timer) > duration) |
| 202 | continue; |
| 203 | (void) ContinueTimer(timer); |
| 204 | } |
| 205 | status=command(image_info,argc,argv,metadata,exception); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 206 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 207 | # pragma omp critical (MagickCore_CommandGenesis) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 208 | #endif |
| 209 | { |
| 210 | if (exception->severity != UndefinedException) |
| 211 | { |
| 212 | if ((exception->severity > ErrorException) || |
| 213 | (regard_warnings != MagickFalse)) |
| 214 | status=MagickTrue; |
| 215 | CatchException(exception); |
| 216 | } |
| 217 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 218 | { |
| 219 | (void) fputs(*metadata,stdout); |
| 220 | (void) fputc('\n',stdout); |
| 221 | *metadata=DestroyString(*metadata); |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | } |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 226 | if (iterations > 1) |
| 227 | { |
| 228 | elapsed_time=GetElapsedTime(timer); |
| 229 | user_time=GetUserTime(timer); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 230 | (void) FormatLocaleFile(stderr, |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 231 | "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double) |
| 232 | iterations,1.0*iterations/elapsed_time,user_time,(double) |
| 233 | (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double) |
| 234 | (1000.0*(elapsed_time-floor(elapsed_time)))); |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 235 | (void) fflush(stderr); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 236 | } |
| 237 | timer=DestroyTimerInfo(timer); |
cristy | 1f9e1ed | 2009-11-18 04:09:38 +0000 | [diff] [blame] | 238 | return(status); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | /* |
| 242 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 243 | % % |
| 244 | % % |
| 245 | % % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 246 | + M o g r i f y I m a g e % |
| 247 | % % |
| 248 | % % |
| 249 | % % |
| 250 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 251 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 252 | % MogrifyImage() applies simple single image processing options to a single |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 253 | % image that may be part of a large list, but also handles any 'region' |
| 254 | % image handling. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 255 | % |
| 256 | % The image in the list may be modified in three different ways... |
| 257 | % |
| 258 | % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 259 | % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 260 | % * replace by a list of images (only the -separate option!) |
| 261 | % |
| 262 | % In each case the result is returned into the list, and a pointer to the |
| 263 | % modified image (last image added if replaced by a list of images) is |
| 264 | % returned. |
| 265 | % |
| 266 | % ASIDE: The -crop is present but restricted to non-tile single image crops |
| 267 | % |
| 268 | % This means if all the images are being processed (such as by |
| 269 | % MogrifyImages(), next image to be processed will be as per the pointer |
| 270 | % (*image)->next. Also the image list may grow as a result of some specific |
| 271 | % operations but as images are never merged or deleted, it will never shrink |
| 272 | % in length. Typically the list will remain the same length. |
| 273 | % |
| 274 | % WARNING: As the image pointed to may be replaced, the first image in the |
| 275 | % list may also change. GetFirstImageInList() should be used by caller if |
| 276 | % they wish return the Image pointer to the first image in list. |
| 277 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 278 | % |
| 279 | % The format of the MogrifyImage method is: |
| 280 | % |
| 281 | % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 282 | % const char **argv,Image **image) |
| 283 | % |
| 284 | % A description of each parameter follows: |
| 285 | % |
| 286 | % o image_info: the image info.. |
| 287 | % |
| 288 | % o argc: Specifies a pointer to an integer describing the number of |
| 289 | % elements in the argument vector. |
| 290 | % |
| 291 | % o argv: Specifies a pointer to a text array containing the command line |
| 292 | % arguments. |
| 293 | % |
| 294 | % o image: the image. |
| 295 | % |
| 296 | % o exception: return any errors or warnings in this structure. |
| 297 | % |
| 298 | */ |
| 299 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 300 | /* |
anthony | 0d0fd35 | 2011-10-04 11:09:07 +0000 | [diff] [blame] | 301 | GetImageCache() will read an image into a image cache if not already |
| 302 | present then return the image that is in the cache under that filename. |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 303 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 304 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 305 | ExceptionInfo *exception) |
| 306 | { |
| 307 | char |
| 308 | key[MaxTextExtent]; |
| 309 | |
| 310 | ExceptionInfo |
| 311 | *sans_exception; |
| 312 | |
| 313 | Image |
| 314 | *image; |
| 315 | |
| 316 | ImageInfo |
| 317 | *read_info; |
| 318 | |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 319 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 320 | sans_exception=AcquireExceptionInfo(); |
| 321 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 322 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 323 | if (image != (Image *) NULL) |
| 324 | return(image); |
| 325 | read_info=CloneImageInfo(image_info); |
| 326 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 327 | image=ReadImage(read_info,exception); |
| 328 | read_info=DestroyImageInfo(read_info); |
| 329 | if (image != (Image *) NULL) |
| 330 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 331 | return(image); |
| 332 | } |
| 333 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 334 | static MagickBooleanType IsPathWritable(const char *path) |
| 335 | { |
| 336 | if (IsPathAccessible(path) == MagickFalse) |
| 337 | return(MagickFalse); |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 338 | if (access_utf8(path,W_OK) != 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 339 | return(MagickFalse); |
| 340 | return(MagickTrue); |
| 341 | } |
| 342 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 343 | static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 344 | { |
| 345 | if (x > y) |
| 346 | return(x); |
| 347 | return(y); |
| 348 | } |
| 349 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 350 | static MagickBooleanType MonitorProgress(const char *text, |
| 351 | const MagickOffsetType offset,const MagickSizeType extent, |
| 352 | void *wand_unused(client_data)) |
| 353 | { |
| 354 | char |
| 355 | message[MaxTextExtent], |
| 356 | tag[MaxTextExtent]; |
| 357 | |
| 358 | const char |
| 359 | *locale_message; |
| 360 | |
| 361 | register char |
| 362 | *p; |
| 363 | |
| 364 | if (extent < 2) |
| 365 | return(MagickTrue); |
| 366 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 367 | p=strrchr(tag,'/'); |
| 368 | if (p != (char *) NULL) |
| 369 | *p='\0'; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 370 | (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 371 | locale_message=GetLocaleMessage(message); |
| 372 | if (locale_message == message) |
| 373 | locale_message=tag; |
| 374 | if (p == (char *) NULL) |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 375 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", |
| 376 | locale_message,(long) offset,(unsigned long) extent,(long) |
| 377 | (100L*offset/(extent-1))); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 378 | else |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 379 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 380 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 381 | (100L*offset/(extent-1))); |
| 382 | if (offset == (MagickOffsetType) (extent-1)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 383 | (void) FormatLocaleFile(stderr,"\n"); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 384 | (void) fflush(stderr); |
| 385 | return(MagickTrue); |
| 386 | } |
| 387 | |
anthony | 0d0fd35 | 2011-10-04 11:09:07 +0000 | [diff] [blame] | 388 | /* |
| 389 | SparseColorOption() parses the complex -sparse-color argument into an |
| 390 | an array of floating point values then calls SparseColorImage(). |
| 391 | Argument is a complex mix of floating-point pixel coodinates, and color |
| 392 | specifications (or direct floating point numbers). The number of floats |
| 393 | needed to represent a color varies depending on the current channel |
| 394 | setting. |
| 395 | */ |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 396 | static Image *SparseColorOption(const Image *image, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 397 | const SparseColorMethod method,const char *arguments, |
| 398 | const MagickBooleanType color_from_image,ExceptionInfo *exception) |
| 399 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 400 | char |
| 401 | token[MaxTextExtent]; |
| 402 | |
| 403 | const char |
| 404 | *p; |
| 405 | |
| 406 | double |
| 407 | *sparse_arguments; |
| 408 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 409 | Image |
| 410 | *sparse_image; |
| 411 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 412 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 413 | color; |
| 414 | |
| 415 | MagickBooleanType |
| 416 | error; |
| 417 | |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 418 | register size_t |
| 419 | x; |
| 420 | |
| 421 | size_t |
| 422 | number_arguments, |
| 423 | number_colors; |
| 424 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 425 | assert(image != (Image *) NULL); |
| 426 | assert(image->signature == MagickSignature); |
| 427 | if (image->debug != MagickFalse) |
| 428 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 429 | assert(exception != (ExceptionInfo *) NULL); |
| 430 | assert(exception->signature == MagickSignature); |
| 431 | /* |
| 432 | Limit channels according to image - and add up number of color channel. |
| 433 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 434 | number_colors=0; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 435 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 436 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 437 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 438 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 439 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 440 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 441 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 442 | (image->colorspace == CMYKColorspace)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 443 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 444 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 445 | (image->matte != MagickFalse)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 446 | number_colors++; |
| 447 | |
| 448 | /* |
| 449 | Read string, to determine number of arguments needed, |
| 450 | */ |
| 451 | p=arguments; |
| 452 | x=0; |
| 453 | while( *p != '\0' ) |
| 454 | { |
| 455 | GetMagickToken(p,&p,token); |
| 456 | if ( token[0] == ',' ) continue; |
| 457 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 458 | if ( color_from_image ) { |
| 459 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 460 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 461 | "Color arg given, when colors are coming from image"); |
| 462 | return( (Image *)NULL); |
| 463 | } |
| 464 | x += number_colors; /* color argument */ |
| 465 | } |
| 466 | else { |
| 467 | x++; /* floating point argument */ |
| 468 | } |
| 469 | } |
| 470 | error=MagickTrue; |
| 471 | if ( color_from_image ) { |
| 472 | /* just the control points are being given */ |
| 473 | error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; |
| 474 | number_arguments=(x/2)*(2+number_colors); |
| 475 | } |
| 476 | else { |
| 477 | /* control points and color values */ |
| 478 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; |
| 479 | number_arguments=x; |
| 480 | } |
| 481 | if ( error ) { |
| 482 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 483 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 484 | "Invalid number of Arguments"); |
| 485 | return( (Image *)NULL); |
| 486 | } |
| 487 | |
| 488 | /* Allocate and fill in the floating point arguments */ |
| 489 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 490 | sizeof(*sparse_arguments)); |
| 491 | if (sparse_arguments == (double *) NULL) { |
| 492 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 493 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 494 | return( (Image *)NULL); |
| 495 | } |
| 496 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 497 | sizeof(*sparse_arguments)); |
| 498 | p=arguments; |
| 499 | x=0; |
| 500 | while( *p != '\0' && x < number_arguments ) { |
| 501 | /* X coordinate */ |
| 502 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 503 | if ( token[0] == '\0' ) break; |
| 504 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 505 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 506 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 507 | "Color found, instead of X-coord"); |
| 508 | error = MagickTrue; |
| 509 | break; |
| 510 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 511 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 512 | /* Y coordinate */ |
| 513 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 514 | if ( token[0] == '\0' ) break; |
| 515 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 516 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 517 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 518 | "Color found, instead of Y-coord"); |
| 519 | error = MagickTrue; |
| 520 | break; |
| 521 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 522 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 523 | /* color values for this control point */ |
| 524 | #if 0 |
| 525 | if ( (color_from_image ) { |
| 526 | /* get color from image */ |
| 527 | /* HOW??? */ |
| 528 | } |
| 529 | else |
| 530 | #endif |
| 531 | { |
| 532 | /* color name or function given in string argument */ |
| 533 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 534 | if ( token[0] == '\0' ) break; |
| 535 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 536 | /* Color string given */ |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 537 | (void) QueryColorCompliance(token,AllCompliance,&color,exception); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 538 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 539 | sparse_arguments[x++] = QuantumScale*color.red; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 540 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 541 | sparse_arguments[x++] = QuantumScale*color.green; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 542 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 543 | sparse_arguments[x++] = QuantumScale*color.blue; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 544 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 545 | (image->colorspace == CMYKColorspace)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 546 | sparse_arguments[x++] = QuantumScale*color.black; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 547 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 548 | (image->matte != MagickFalse)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 549 | sparse_arguments[x++] = QuantumScale*color.alpha; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 550 | } |
| 551 | else { |
| 552 | /* Colors given as a set of floating point values - experimental */ |
| 553 | /* NB: token contains the first floating point value to use! */ |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 554 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 555 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 556 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 557 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 558 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 559 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 560 | token[0] = ','; /* used this token - get another */ |
| 561 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 562 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 563 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 564 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 565 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 566 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 567 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 568 | token[0] = ','; /* used this token - get another */ |
| 569 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 570 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 571 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 572 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 573 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 574 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 575 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 576 | token[0] = ','; /* used this token - get another */ |
| 577 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 578 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 579 | (image->colorspace == CMYKColorspace)) |
| 580 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 581 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 582 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 583 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 584 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 585 | token[0] = ','; /* used this token - get another */ |
| 586 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 587 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 588 | (image->matte != MagickFalse)) |
| 589 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 590 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 591 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 592 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 593 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 594 | token[0] = ','; /* used this token - get another */ |
| 595 | } |
| 596 | } |
| 597 | } |
| 598 | } |
| 599 | if ( number_arguments != x && !error ) { |
| 600 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
| 601 | "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error"); |
| 602 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 603 | return( (Image *)NULL); |
| 604 | } |
| 605 | if ( error ) |
| 606 | return( (Image *)NULL); |
| 607 | |
| 608 | /* Call the Interpolation function with the parsed arguments */ |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 609 | sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, |
| 610 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 611 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 612 | return( sparse_image ); |
| 613 | } |
| 614 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 615 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 616 | const char **argv,Image **image,ExceptionInfo *exception) |
| 617 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 618 | ChannelType |
| 619 | channel; |
| 620 | |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 621 | CompositeOperator |
| 622 | compose; |
| 623 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 624 | const char |
| 625 | *format, |
| 626 | *option; |
| 627 | |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 628 | double |
| 629 | attenuate; |
| 630 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 631 | DrawInfo |
| 632 | *draw_info; |
| 633 | |
| 634 | GeometryInfo |
| 635 | geometry_info; |
| 636 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 637 | Image |
| 638 | *region_image; |
| 639 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 640 | ImageInfo |
| 641 | *mogrify_info; |
| 642 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 643 | MagickStatusType |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 644 | status; |
| 645 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 646 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 647 | fill; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 648 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 649 | MagickStatusType |
| 650 | flags; |
| 651 | |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 652 | PixelInterpolateMethod |
| 653 | interpolate_method; |
| 654 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 655 | QuantizeInfo |
| 656 | *quantize_info; |
| 657 | |
| 658 | RectangleInfo |
| 659 | geometry, |
| 660 | region_geometry; |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame] | 661 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 662 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 663 | i; |
| 664 | |
| 665 | /* |
| 666 | Initialize method variables. |
| 667 | */ |
| 668 | assert(image_info != (const ImageInfo *) NULL); |
| 669 | assert(image_info->signature == MagickSignature); |
| 670 | assert(image != (Image **) NULL); |
| 671 | assert((*image)->signature == MagickSignature); |
| 672 | if ((*image)->debug != MagickFalse) |
| 673 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); |
| 674 | if (argc < 0) |
| 675 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 676 | mogrify_info=CloneImageInfo(image_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 677 | draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL); |
| 678 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 679 | SetGeometryInfo(&geometry_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 680 | GetPixelInfo(*image,&fill); |
cristy | 9d8c8ce | 2011-10-25 16:13:52 +0000 | [diff] [blame] | 681 | fill=(*image)->background_color; |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 682 | attenuate=1.0; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 683 | compose=(*image)->compose; |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 684 | interpolate_method=UndefinedInterpolatePixel; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 685 | channel=mogrify_info->channel; |
| 686 | format=GetImageOption(mogrify_info,"format"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 687 | SetGeometry(*image,®ion_geometry); |
| 688 | region_image=NewImageList(); |
| 689 | /* |
| 690 | Transmogrify the image. |
| 691 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 692 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 693 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 694 | Image |
| 695 | *mogrify_image; |
| 696 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 697 | ssize_t |
| 698 | count; |
| 699 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 700 | option=argv[i]; |
| 701 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 702 | continue; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 703 | count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option), |
| 704 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 705 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 706 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 707 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 708 | mogrify_image=(Image *)NULL; |
| 709 | switch (*(option+1)) |
| 710 | { |
| 711 | case 'a': |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 712 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 713 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 714 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 715 | /* |
| 716 | Adaptive blur image. |
| 717 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 718 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 719 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 720 | if ((flags & SigmaValue) == 0) |
| 721 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 722 | if ((flags & XiValue) == 0) |
| 723 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 724 | mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho, |
cristy | 4c11c2b | 2011-09-05 20:17:07 +0000 | [diff] [blame] | 725 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 726 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 727 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 728 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 729 | { |
| 730 | /* |
| 731 | Adaptive resize image. |
| 732 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 733 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 734 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 735 | mogrify_image=AdaptiveResizeImage(*image,geometry.width, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 736 | geometry.height,interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 737 | break; |
| 738 | } |
| 739 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 740 | { |
| 741 | /* |
| 742 | Adaptive sharpen image. |
| 743 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 744 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 745 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 746 | if ((flags & SigmaValue) == 0) |
| 747 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 748 | if ((flags & XiValue) == 0) |
| 749 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 750 | mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho, |
cristy | 4c11c2b | 2011-09-05 20:17:07 +0000 | [diff] [blame] | 751 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 752 | break; |
| 753 | } |
| 754 | if (LocaleCompare("affine",option+1) == 0) |
| 755 | { |
| 756 | /* |
| 757 | Affine matrix. |
| 758 | */ |
| 759 | if (*option == '+') |
| 760 | { |
| 761 | GetAffineMatrix(&draw_info->affine); |
| 762 | break; |
| 763 | } |
| 764 | (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); |
| 765 | break; |
| 766 | } |
| 767 | if (LocaleCompare("alpha",option+1) == 0) |
| 768 | { |
| 769 | AlphaChannelType |
| 770 | alpha_type; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 771 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 772 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 773 | alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions, |
| 774 | MagickFalse,argv[i+1]); |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 775 | (void) SetImageAlphaChannel(*image,alpha_type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 776 | break; |
| 777 | } |
| 778 | if (LocaleCompare("annotate",option+1) == 0) |
| 779 | { |
| 780 | char |
| 781 | *text, |
| 782 | geometry[MaxTextExtent]; |
| 783 | |
| 784 | /* |
| 785 | Annotate image. |
| 786 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 787 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 788 | SetGeometryInfo(&geometry_info); |
| 789 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 790 | if ((flags & SigmaValue) == 0) |
| 791 | geometry_info.sigma=geometry_info.rho; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 792 | text=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 793 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 794 | if (text == (char *) NULL) |
| 795 | break; |
| 796 | (void) CloneString(&draw_info->text,text); |
| 797 | text=DestroyString(text); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 798 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 799 | geometry_info.xi,geometry_info.psi); |
| 800 | (void) CloneString(&draw_info->geometry,geometry); |
| 801 | draw_info->affine.sx=cos(DegreesToRadians( |
| 802 | fmod(geometry_info.rho,360.0))); |
| 803 | draw_info->affine.rx=sin(DegreesToRadians( |
| 804 | fmod(geometry_info.rho,360.0))); |
| 805 | draw_info->affine.ry=(-sin(DegreesToRadians( |
| 806 | fmod(geometry_info.sigma,360.0)))); |
| 807 | draw_info->affine.sy=cos(DegreesToRadians( |
| 808 | fmod(geometry_info.sigma,360.0))); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 809 | (void) AnnotateImage(*image,draw_info,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 810 | break; |
| 811 | } |
| 812 | if (LocaleCompare("antialias",option+1) == 0) |
| 813 | { |
| 814 | draw_info->stroke_antialias=(*option == '-') ? MagickTrue : |
| 815 | MagickFalse; |
| 816 | draw_info->text_antialias=(*option == '-') ? MagickTrue : |
| 817 | MagickFalse; |
| 818 | break; |
| 819 | } |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 820 | if (LocaleCompare("attenuate",option+1) == 0) |
| 821 | { |
| 822 | if (*option == '+') |
| 823 | { |
| 824 | attenuate=1.0; |
| 825 | break; |
| 826 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 827 | attenuate=StringToDouble(argv[i+1],(char **) NULL); |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 828 | break; |
| 829 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 830 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 831 | { |
| 832 | /* |
| 833 | Auto Adjust Gamma of image based on its mean |
| 834 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 835 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9511120 | 2011-08-09 19:41:42 +0000 | [diff] [blame] | 836 | (void) AutoGammaImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 837 | break; |
| 838 | } |
| 839 | if (LocaleCompare("auto-level",option+1) == 0) |
| 840 | { |
| 841 | /* |
| 842 | Perfectly Normalize (max/min stretch) the image |
| 843 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 844 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9511120 | 2011-08-09 19:41:42 +0000 | [diff] [blame] | 845 | (void) AutoLevelImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 846 | break; |
| 847 | } |
| 848 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 849 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 850 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 851 | switch ((*image)->orientation) |
| 852 | { |
| 853 | case TopRightOrientation: |
| 854 | { |
| 855 | mogrify_image=FlopImage(*image,exception); |
| 856 | break; |
| 857 | } |
| 858 | case BottomRightOrientation: |
| 859 | { |
| 860 | mogrify_image=RotateImage(*image,180.0,exception); |
| 861 | break; |
| 862 | } |
| 863 | case BottomLeftOrientation: |
| 864 | { |
| 865 | mogrify_image=FlipImage(*image,exception); |
| 866 | break; |
| 867 | } |
| 868 | case LeftTopOrientation: |
| 869 | { |
| 870 | mogrify_image=TransposeImage(*image,exception); |
| 871 | break; |
| 872 | } |
| 873 | case RightTopOrientation: |
| 874 | { |
| 875 | mogrify_image=RotateImage(*image,90.0,exception); |
| 876 | break; |
| 877 | } |
| 878 | case RightBottomOrientation: |
| 879 | { |
| 880 | mogrify_image=TransverseImage(*image,exception); |
| 881 | break; |
| 882 | } |
| 883 | case LeftBottomOrientation: |
| 884 | { |
| 885 | mogrify_image=RotateImage(*image,270.0,exception); |
| 886 | break; |
| 887 | } |
| 888 | default: |
| 889 | break; |
| 890 | } |
| 891 | if (mogrify_image != (Image *) NULL) |
| 892 | mogrify_image->orientation=TopLeftOrientation; |
| 893 | break; |
| 894 | } |
| 895 | break; |
| 896 | } |
| 897 | case 'b': |
| 898 | { |
| 899 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 900 | { |
| 901 | /* |
| 902 | Black threshold image. |
| 903 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 904 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 905 | (void) BlackThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 906 | break; |
| 907 | } |
| 908 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 909 | { |
| 910 | /* |
| 911 | Blue shift image. |
| 912 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 913 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 914 | geometry_info.rho=1.5; |
| 915 | if (*option == '-') |
| 916 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 917 | mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception); |
| 918 | break; |
| 919 | } |
| 920 | if (LocaleCompare("blur",option+1) == 0) |
| 921 | { |
| 922 | /* |
| 923 | Gaussian blur image. |
| 924 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 925 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 926 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 927 | if ((flags & SigmaValue) == 0) |
| 928 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 929 | if ((flags & XiValue) == 0) |
| 930 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 931 | mogrify_image=BlurImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 932 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 933 | break; |
| 934 | } |
| 935 | if (LocaleCompare("border",option+1) == 0) |
| 936 | { |
| 937 | /* |
| 938 | Surround image with a border of solid color. |
| 939 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 940 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 941 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 942 | if ((flags & SigmaValue) == 0) |
| 943 | geometry.height=geometry.width; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 944 | mogrify_image=BorderImage(*image,&geometry,compose,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 945 | break; |
| 946 | } |
| 947 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 948 | { |
| 949 | if (*option == '+') |
| 950 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 951 | (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 952 | &draw_info->border_color,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 953 | break; |
| 954 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 955 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 956 | &draw_info->border_color,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 957 | break; |
| 958 | } |
| 959 | if (LocaleCompare("box",option+1) == 0) |
| 960 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 961 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 962 | &draw_info->undercolor,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 963 | break; |
| 964 | } |
| 965 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 966 | { |
| 967 | double |
| 968 | brightness, |
| 969 | contrast; |
| 970 | |
| 971 | GeometryInfo |
| 972 | geometry_info; |
| 973 | |
| 974 | MagickStatusType |
| 975 | flags; |
| 976 | |
| 977 | /* |
| 978 | Brightness / contrast image. |
| 979 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 980 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 981 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 982 | brightness=geometry_info.rho; |
| 983 | contrast=0.0; |
| 984 | if ((flags & SigmaValue) != 0) |
| 985 | contrast=geometry_info.sigma; |
cristy | 444eda6 | 2011-08-10 02:07:46 +0000 | [diff] [blame] | 986 | (void) BrightnessContrastImage(*image,brightness,contrast, |
| 987 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 988 | break; |
| 989 | } |
| 990 | break; |
| 991 | } |
| 992 | case 'c': |
| 993 | { |
| 994 | if (LocaleCompare("cdl",option+1) == 0) |
| 995 | { |
| 996 | char |
| 997 | *color_correction_collection; |
| 998 | |
| 999 | /* |
| 1000 | Color correct with a color decision list. |
| 1001 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1002 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1003 | color_correction_collection=FileToString(argv[i+1],~0,exception); |
| 1004 | if (color_correction_collection == (char *) NULL) |
| 1005 | break; |
cristy | 1bfa9f0 | 2011-08-11 02:35:43 +0000 | [diff] [blame] | 1006 | (void) ColorDecisionListImage(*image,color_correction_collection, |
| 1007 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1008 | break; |
| 1009 | } |
| 1010 | if (LocaleCompare("channel",option+1) == 0) |
| 1011 | { |
| 1012 | if (*option == '+') |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 1013 | channel=DefaultChannels; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1014 | else |
cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 1015 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1016 | SetPixelChannelMap(*image,channel); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1017 | break; |
| 1018 | } |
| 1019 | if (LocaleCompare("charcoal",option+1) == 0) |
| 1020 | { |
| 1021 | /* |
| 1022 | Charcoal image. |
| 1023 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1024 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1025 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1026 | if ((flags & SigmaValue) == 0) |
| 1027 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1028 | if ((flags & XiValue) == 0) |
| 1029 | geometry_info.xi=1.0; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1030 | mogrify_image=CharcoalImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1031 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1032 | break; |
| 1033 | } |
| 1034 | if (LocaleCompare("chop",option+1) == 0) |
| 1035 | { |
| 1036 | /* |
| 1037 | Chop the image. |
| 1038 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1039 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1040 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1041 | mogrify_image=ChopImage(*image,&geometry,exception); |
| 1042 | break; |
| 1043 | } |
| 1044 | if (LocaleCompare("clamp",option+1) == 0) |
| 1045 | { |
| 1046 | /* |
| 1047 | Clamp image. |
| 1048 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1049 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 092d71c | 2011-10-14 18:01:29 +0000 | [diff] [blame] | 1050 | (void) ClampImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1051 | break; |
| 1052 | } |
| 1053 | if (LocaleCompare("clip",option+1) == 0) |
| 1054 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1055 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1056 | if (*option == '+') |
| 1057 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1058 | (void) SetImageClipMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1059 | break; |
| 1060 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1061 | (void) ClipImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1062 | break; |
| 1063 | } |
| 1064 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1065 | { |
| 1066 | CacheView |
| 1067 | *mask_view; |
| 1068 | |
| 1069 | Image |
| 1070 | *mask_image; |
| 1071 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1072 | register Quantum |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1073 | *restrict q; |
| 1074 | |
| 1075 | register ssize_t |
| 1076 | x; |
| 1077 | |
| 1078 | ssize_t |
| 1079 | y; |
| 1080 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1081 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1082 | if (*option == '+') |
| 1083 | { |
| 1084 | /* |
| 1085 | Remove a mask. |
| 1086 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1087 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1088 | break; |
| 1089 | } |
| 1090 | /* |
| 1091 | Set the image mask. |
| 1092 | FUTURE: This Should Be a SetImageAlphaChannel() call, Or two. |
| 1093 | */ |
| 1094 | mask_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1095 | if (mask_image == (Image *) NULL) |
| 1096 | break; |
cristy | 574cc26 | 2011-08-05 01:23:58 +0000 | [diff] [blame] | 1097 | if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1098 | return(MagickFalse); |
| 1099 | mask_view=AcquireCacheView(mask_image); |
| 1100 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1101 | { |
| 1102 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1103 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 1104 | if (q == (Quantum *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1105 | break; |
| 1106 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1107 | { |
| 1108 | if (mask_image->matte == MagickFalse) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1109 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 1110 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1111 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1112 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1113 | q+=GetPixelChannels(mask_image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1114 | } |
| 1115 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
| 1116 | break; |
| 1117 | } |
| 1118 | mask_view=DestroyCacheView(mask_view); |
| 1119 | mask_image->matte=MagickTrue; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1120 | (void) SetImageClipMask(*image,mask_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1121 | break; |
| 1122 | } |
| 1123 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1124 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1125 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1126 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1127 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1128 | break; |
| 1129 | } |
| 1130 | if (LocaleCompare("colorize",option+1) == 0) |
| 1131 | { |
| 1132 | /* |
| 1133 | Colorize the image. |
| 1134 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1135 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | c7e6ff6 | 2011-10-03 13:46:11 +0000 | [diff] [blame] | 1136 | mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1137 | break; |
| 1138 | } |
| 1139 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1140 | { |
| 1141 | KernelInfo |
| 1142 | *kernel; |
| 1143 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1144 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1145 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1146 | if (kernel == (KernelInfo *) NULL) |
| 1147 | break; |
| 1148 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 1149 | kernel=DestroyKernelInfo(kernel); |
| 1150 | break; |
| 1151 | } |
| 1152 | if (LocaleCompare("colors",option+1) == 0) |
| 1153 | { |
| 1154 | /* |
| 1155 | Reduce the number of colors in the image. |
| 1156 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1157 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1158 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
| 1159 | if (quantize_info->number_colors == 0) |
| 1160 | break; |
| 1161 | if (((*image)->storage_class == DirectClass) || |
| 1162 | (*image)->colors > quantize_info->number_colors) |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1163 | (void) QuantizeImage(quantize_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1164 | else |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1165 | (void) CompressImageColormap(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1166 | break; |
| 1167 | } |
| 1168 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1169 | { |
| 1170 | ColorspaceType |
| 1171 | colorspace; |
| 1172 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1173 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1174 | if (*option == '+') |
| 1175 | { |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 1176 | (void) TransformImageColorspace(*image,RGBColorspace,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1177 | break; |
| 1178 | } |
| 1179 | colorspace=(ColorspaceType) ParseCommandOption( |
| 1180 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 1181 | (void) TransformImageColorspace(*image,colorspace,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1182 | break; |
| 1183 | } |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1184 | if (LocaleCompare("compose",option+1) == 0) |
| 1185 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1186 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1187 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 1188 | MagickFalse,argv[i+1]); |
| 1189 | break; |
| 1190 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1191 | if (LocaleCompare("contrast",option+1) == 0) |
| 1192 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1193 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1194 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1195 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1196 | break; |
| 1197 | } |
| 1198 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1199 | { |
| 1200 | double |
| 1201 | black_point, |
| 1202 | white_point; |
| 1203 | |
| 1204 | MagickStatusType |
| 1205 | flags; |
| 1206 | |
| 1207 | /* |
| 1208 | Contrast stretch image. |
| 1209 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1210 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1211 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1212 | black_point=geometry_info.rho; |
| 1213 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1214 | black_point; |
| 1215 | if ((flags & PercentValue) != 0) |
| 1216 | { |
| 1217 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1218 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1219 | } |
| 1220 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1221 | white_point; |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1222 | (void) ContrastStretchImage(*image,black_point,white_point, |
| 1223 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1224 | break; |
| 1225 | } |
| 1226 | if (LocaleCompare("convolve",option+1) == 0) |
| 1227 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1228 | KernelInfo |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1229 | *kernel_info; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1230 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1231 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1232 | kernel_info=AcquireKernelInfo(argv[i+1]); |
| 1233 | if (kernel_info == (KernelInfo *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1234 | break; |
cristy | 0a92238 | 2011-07-16 15:30:34 +0000 | [diff] [blame] | 1235 | kernel_info->bias=(*image)->bias; |
cristy | 5e6be1e | 2011-07-16 01:23:39 +0000 | [diff] [blame] | 1236 | mogrify_image=ConvolveImage(*image,kernel_info,exception); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1237 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1238 | break; |
| 1239 | } |
| 1240 | if (LocaleCompare("crop",option+1) == 0) |
| 1241 | { |
| 1242 | /* |
| 1243 | Crop a image to a smaller size |
| 1244 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1245 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1246 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1247 | break; |
| 1248 | } |
| 1249 | if (LocaleCompare("cycle",option+1) == 0) |
| 1250 | { |
| 1251 | /* |
| 1252 | Cycle an image colormap. |
| 1253 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1254 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1255 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]), |
| 1256 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1257 | break; |
| 1258 | } |
| 1259 | break; |
| 1260 | } |
| 1261 | case 'd': |
| 1262 | { |
| 1263 | if (LocaleCompare("decipher",option+1) == 0) |
| 1264 | { |
| 1265 | StringInfo |
| 1266 | *passkey; |
| 1267 | |
| 1268 | /* |
| 1269 | Decipher pixels. |
| 1270 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1271 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1272 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1273 | if (passkey != (StringInfo *) NULL) |
| 1274 | { |
| 1275 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1276 | passkey=DestroyStringInfo(passkey); |
| 1277 | } |
| 1278 | break; |
| 1279 | } |
| 1280 | if (LocaleCompare("density",option+1) == 0) |
| 1281 | { |
| 1282 | /* |
| 1283 | Set image density. |
| 1284 | */ |
| 1285 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1286 | break; |
| 1287 | } |
| 1288 | if (LocaleCompare("depth",option+1) == 0) |
| 1289 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1290 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1291 | if (*option == '+') |
| 1292 | { |
cristy | 8a11cb1 | 2011-10-19 23:53:34 +0000 | [diff] [blame] | 1293 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1294 | break; |
| 1295 | } |
cristy | 8a11cb1 | 2011-10-19 23:53:34 +0000 | [diff] [blame] | 1296 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]), |
| 1297 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1298 | break; |
| 1299 | } |
| 1300 | if (LocaleCompare("deskew",option+1) == 0) |
| 1301 | { |
| 1302 | double |
| 1303 | threshold; |
| 1304 | |
| 1305 | /* |
| 1306 | Straighten the image. |
| 1307 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1308 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1309 | if (*option == '+') |
| 1310 | threshold=40.0*QuantumRange/100.0; |
| 1311 | else |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 1312 | threshold=StringToDoubleInterval(argv[i+1],QuantumRange); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1313 | mogrify_image=DeskewImage(*image,threshold,exception); |
| 1314 | break; |
| 1315 | } |
| 1316 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1317 | { |
| 1318 | /* |
| 1319 | Reduce the speckles within an image. |
| 1320 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1321 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1322 | mogrify_image=DespeckleImage(*image,exception); |
| 1323 | break; |
| 1324 | } |
| 1325 | if (LocaleCompare("display",option+1) == 0) |
| 1326 | { |
| 1327 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1328 | break; |
| 1329 | } |
| 1330 | if (LocaleCompare("distort",option+1) == 0) |
| 1331 | { |
| 1332 | char |
| 1333 | *args, |
| 1334 | token[MaxTextExtent]; |
| 1335 | |
| 1336 | const char |
| 1337 | *p; |
| 1338 | |
| 1339 | DistortImageMethod |
| 1340 | method; |
| 1341 | |
| 1342 | double |
| 1343 | *arguments; |
| 1344 | |
| 1345 | register ssize_t |
| 1346 | x; |
| 1347 | |
| 1348 | size_t |
| 1349 | number_arguments; |
| 1350 | |
| 1351 | /* |
| 1352 | Distort image. |
| 1353 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1354 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1355 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, |
| 1356 | MagickFalse,argv[i+1]); |
| 1357 | if ( method == ResizeDistortion ) |
| 1358 | { |
| 1359 | /* Special Case - Argument is actually a resize geometry! |
| 1360 | ** Convert that to an appropriate distortion argument array. |
| 1361 | */ |
| 1362 | double |
| 1363 | resize_args[2]; |
| 1364 | (void) ParseRegionGeometry(*image,argv[i+2],&geometry, |
| 1365 | exception); |
| 1366 | resize_args[0]=(double)geometry.width; |
| 1367 | resize_args[1]=(double)geometry.height; |
| 1368 | mogrify_image=DistortImage(*image,method,(size_t)2, |
| 1369 | resize_args,MagickTrue,exception); |
| 1370 | break; |
| 1371 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1372 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1373 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1374 | if (args == (char *) NULL) |
| 1375 | break; |
| 1376 | p=(char *) args; |
| 1377 | for (x=0; *p != '\0'; x++) |
| 1378 | { |
| 1379 | GetMagickToken(p,&p,token); |
| 1380 | if (*token == ',') |
| 1381 | GetMagickToken(p,&p,token); |
| 1382 | } |
| 1383 | number_arguments=(size_t) x; |
| 1384 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1385 | sizeof(*arguments)); |
| 1386 | if (arguments == (double *) NULL) |
| 1387 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1388 | "MemoryAllocationFailed",(*image)->filename); |
| 1389 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1390 | sizeof(*arguments)); |
| 1391 | p=(char *) args; |
| 1392 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 1393 | { |
| 1394 | GetMagickToken(p,&p,token); |
| 1395 | if (*token == ',') |
| 1396 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 1397 | arguments[x]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1398 | } |
| 1399 | args=DestroyString(args); |
| 1400 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
| 1401 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1402 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1403 | break; |
| 1404 | } |
| 1405 | if (LocaleCompare("dither",option+1) == 0) |
| 1406 | { |
| 1407 | if (*option == '+') |
| 1408 | { |
| 1409 | quantize_info->dither=MagickFalse; |
| 1410 | break; |
| 1411 | } |
| 1412 | quantize_info->dither=MagickTrue; |
| 1413 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
| 1414 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1415 | if (quantize_info->dither_method == NoDitherMethod) |
| 1416 | quantize_info->dither=MagickFalse; |
| 1417 | break; |
| 1418 | } |
| 1419 | if (LocaleCompare("draw",option+1) == 0) |
| 1420 | { |
| 1421 | /* |
| 1422 | Draw image. |
| 1423 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1424 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1425 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1426 | (void) DrawImage(*image,draw_info,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1427 | break; |
| 1428 | } |
| 1429 | break; |
| 1430 | } |
| 1431 | case 'e': |
| 1432 | { |
| 1433 | if (LocaleCompare("edge",option+1) == 0) |
| 1434 | { |
| 1435 | /* |
| 1436 | Enhance edges in the image. |
| 1437 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1438 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1439 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1440 | if ((flags & SigmaValue) == 0) |
| 1441 | geometry_info.sigma=1.0; |
cristy | 8ae632d | 2011-09-05 17:29:53 +0000 | [diff] [blame] | 1442 | mogrify_image=EdgeImage(*image,geometry_info.rho, |
| 1443 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1444 | break; |
| 1445 | } |
| 1446 | if (LocaleCompare("emboss",option+1) == 0) |
| 1447 | { |
| 1448 | /* |
| 1449 | Gaussian embossen image. |
| 1450 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1451 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1452 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1453 | if ((flags & SigmaValue) == 0) |
| 1454 | geometry_info.sigma=1.0; |
| 1455 | mogrify_image=EmbossImage(*image,geometry_info.rho, |
| 1456 | geometry_info.sigma,exception); |
| 1457 | break; |
| 1458 | } |
| 1459 | if (LocaleCompare("encipher",option+1) == 0) |
| 1460 | { |
| 1461 | StringInfo |
| 1462 | *passkey; |
| 1463 | |
| 1464 | /* |
| 1465 | Encipher pixels. |
| 1466 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1467 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1468 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1469 | if (passkey != (StringInfo *) NULL) |
| 1470 | { |
| 1471 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1472 | passkey=DestroyStringInfo(passkey); |
| 1473 | } |
| 1474 | break; |
| 1475 | } |
| 1476 | if (LocaleCompare("encoding",option+1) == 0) |
| 1477 | { |
| 1478 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1479 | break; |
| 1480 | } |
| 1481 | if (LocaleCompare("enhance",option+1) == 0) |
| 1482 | { |
| 1483 | /* |
| 1484 | Enhance image. |
| 1485 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1486 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1487 | mogrify_image=EnhanceImage(*image,exception); |
| 1488 | break; |
| 1489 | } |
| 1490 | if (LocaleCompare("equalize",option+1) == 0) |
| 1491 | { |
| 1492 | /* |
| 1493 | Equalize image. |
| 1494 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1495 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 6d8c3d7 | 2011-08-22 01:20:01 +0000 | [diff] [blame] | 1496 | (void) EqualizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1497 | break; |
| 1498 | } |
| 1499 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1500 | { |
| 1501 | double |
| 1502 | constant; |
| 1503 | |
| 1504 | MagickEvaluateOperator |
| 1505 | op; |
| 1506 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1507 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1508 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 1509 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 1510 | constant=StringToDoubleInterval(argv[i+2],QuantumRange); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1511 | (void) EvaluateImage(*image,op,constant,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1512 | break; |
| 1513 | } |
| 1514 | if (LocaleCompare("extent",option+1) == 0) |
| 1515 | { |
| 1516 | /* |
| 1517 | Set the image extent. |
| 1518 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1519 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1520 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1521 | if (geometry.width == 0) |
| 1522 | geometry.width=(*image)->columns; |
| 1523 | if (geometry.height == 0) |
| 1524 | geometry.height=(*image)->rows; |
| 1525 | mogrify_image=ExtentImage(*image,&geometry,exception); |
| 1526 | break; |
| 1527 | } |
| 1528 | break; |
| 1529 | } |
| 1530 | case 'f': |
| 1531 | { |
| 1532 | if (LocaleCompare("family",option+1) == 0) |
| 1533 | { |
| 1534 | if (*option == '+') |
| 1535 | { |
| 1536 | if (draw_info->family != (char *) NULL) |
| 1537 | draw_info->family=DestroyString(draw_info->family); |
| 1538 | break; |
| 1539 | } |
| 1540 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1541 | break; |
| 1542 | } |
| 1543 | if (LocaleCompare("features",option+1) == 0) |
| 1544 | { |
| 1545 | if (*option == '+') |
| 1546 | { |
| 1547 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1548 | break; |
| 1549 | } |
| 1550 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1551 | break; |
| 1552 | } |
| 1553 | if (LocaleCompare("fill",option+1) == 0) |
| 1554 | { |
| 1555 | ExceptionInfo |
| 1556 | *sans; |
| 1557 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1558 | GetPixelInfo(*image,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1559 | if (*option == '+') |
| 1560 | { |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1561 | (void) QueryColorCompliance("none",AllCompliance,&fill, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1562 | exception); |
| 1563 | (void) QueryColorCompliance("none",AllCompliance, |
| 1564 | &draw_info->fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1565 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1566 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1567 | break; |
| 1568 | } |
| 1569 | sans=AcquireExceptionInfo(); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1570 | (void) QueryColorCompliance(argv[i+1],AllCompliance,&fill, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1571 | sans); |
| 1572 | status=QueryColorCompliance(argv[i+1],AllCompliance, |
| 1573 | &draw_info->fill,sans); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1574 | sans=DestroyExceptionInfo(sans); |
| 1575 | if (status == MagickFalse) |
| 1576 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 1577 | exception); |
| 1578 | break; |
| 1579 | } |
| 1580 | if (LocaleCompare("flip",option+1) == 0) |
| 1581 | { |
| 1582 | /* |
| 1583 | Flip image scanlines. |
| 1584 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1585 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1586 | mogrify_image=FlipImage(*image,exception); |
| 1587 | break; |
| 1588 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1589 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1590 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1591 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1592 | target; |
| 1593 | |
| 1594 | /* |
| 1595 | Floodfill image. |
| 1596 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1597 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1598 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1599 | (void) QueryColorCompliance(argv[i+2],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1600 | exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1601 | (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x, |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 1602 | geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1603 | break; |
| 1604 | } |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1605 | if (LocaleCompare("flop",option+1) == 0) |
| 1606 | { |
| 1607 | /* |
| 1608 | Flop image scanlines. |
| 1609 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1610 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1611 | mogrify_image=FlopImage(*image,exception); |
| 1612 | break; |
| 1613 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1614 | if (LocaleCompare("font",option+1) == 0) |
| 1615 | { |
| 1616 | if (*option == '+') |
| 1617 | { |
| 1618 | if (draw_info->font != (char *) NULL) |
| 1619 | draw_info->font=DestroyString(draw_info->font); |
| 1620 | break; |
| 1621 | } |
| 1622 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1623 | break; |
| 1624 | } |
| 1625 | if (LocaleCompare("format",option+1) == 0) |
| 1626 | { |
| 1627 | format=argv[i+1]; |
| 1628 | break; |
| 1629 | } |
| 1630 | if (LocaleCompare("frame",option+1) == 0) |
| 1631 | { |
| 1632 | FrameInfo |
| 1633 | frame_info; |
| 1634 | |
| 1635 | /* |
| 1636 | Surround image with an ornamental border. |
| 1637 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1638 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1639 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1640 | frame_info.width=geometry.width; |
| 1641 | frame_info.height=geometry.height; |
| 1642 | if ((flags & HeightValue) == 0) |
| 1643 | frame_info.height=geometry.width; |
| 1644 | frame_info.outer_bevel=geometry.x; |
| 1645 | frame_info.inner_bevel=geometry.y; |
| 1646 | frame_info.x=(ssize_t) frame_info.width; |
| 1647 | frame_info.y=(ssize_t) frame_info.height; |
| 1648 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1649 | frame_info.height=(*image)->rows+2*frame_info.height; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1650 | mogrify_image=FrameImage(*image,&frame_info,compose,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1651 | break; |
| 1652 | } |
| 1653 | if (LocaleCompare("function",option+1) == 0) |
| 1654 | { |
| 1655 | char |
| 1656 | *arguments, |
| 1657 | token[MaxTextExtent]; |
| 1658 | |
| 1659 | const char |
| 1660 | *p; |
| 1661 | |
| 1662 | double |
| 1663 | *parameters; |
| 1664 | |
| 1665 | MagickFunction |
| 1666 | function; |
| 1667 | |
| 1668 | register ssize_t |
| 1669 | x; |
| 1670 | |
| 1671 | size_t |
| 1672 | number_parameters; |
| 1673 | |
| 1674 | /* |
| 1675 | Function Modify Image Values |
| 1676 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1677 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1678 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, |
| 1679 | MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1680 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1681 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1682 | if (arguments == (char *) NULL) |
| 1683 | break; |
| 1684 | p=(char *) arguments; |
| 1685 | for (x=0; *p != '\0'; x++) |
| 1686 | { |
| 1687 | GetMagickToken(p,&p,token); |
| 1688 | if (*token == ',') |
| 1689 | GetMagickToken(p,&p,token); |
| 1690 | } |
| 1691 | number_parameters=(size_t) x; |
| 1692 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1693 | sizeof(*parameters)); |
| 1694 | if (parameters == (double *) NULL) |
| 1695 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1696 | "MemoryAllocationFailed",(*image)->filename); |
| 1697 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1698 | sizeof(*parameters)); |
| 1699 | p=(char *) arguments; |
| 1700 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
| 1701 | { |
| 1702 | GetMagickToken(p,&p,token); |
| 1703 | if (*token == ',') |
| 1704 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 1705 | parameters[x]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1706 | } |
| 1707 | arguments=DestroyString(arguments); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1708 | (void) FunctionImage(*image,function,number_parameters,parameters, |
| 1709 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1710 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1711 | break; |
| 1712 | } |
| 1713 | break; |
| 1714 | } |
| 1715 | case 'g': |
| 1716 | { |
| 1717 | if (LocaleCompare("gamma",option+1) == 0) |
| 1718 | { |
| 1719 | /* |
| 1720 | Gamma image. |
| 1721 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1722 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1723 | if (*option == '+') |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 1724 | (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1725 | else |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 1726 | (void) GammaImage(*image,StringToDouble(argv[i+1], |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 1727 | (char **) NULL),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1728 | break; |
| 1729 | } |
| 1730 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1731 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1732 | { |
| 1733 | /* |
| 1734 | Gaussian blur image. |
| 1735 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1736 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1737 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1738 | if ((flags & SigmaValue) == 0) |
| 1739 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1740 | if ((flags & XiValue) == 0) |
| 1741 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1742 | mogrify_image=GaussianBlurImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1743 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1744 | break; |
| 1745 | } |
| 1746 | if (LocaleCompare("geometry",option+1) == 0) |
| 1747 | { |
| 1748 | /* |
| 1749 | Record Image offset, Resize last image. |
| 1750 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1751 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1752 | if (*option == '+') |
| 1753 | { |
| 1754 | if ((*image)->geometry != (char *) NULL) |
| 1755 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1756 | break; |
| 1757 | } |
| 1758 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1759 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1760 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1761 | else |
| 1762 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 1763 | (*image)->filter,(*image)->blur,exception); |
| 1764 | break; |
| 1765 | } |
| 1766 | if (LocaleCompare("gravity",option+1) == 0) |
| 1767 | { |
| 1768 | if (*option == '+') |
| 1769 | { |
| 1770 | draw_info->gravity=UndefinedGravity; |
| 1771 | break; |
| 1772 | } |
| 1773 | draw_info->gravity=(GravityType) ParseCommandOption( |
| 1774 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1775 | break; |
| 1776 | } |
| 1777 | break; |
| 1778 | } |
| 1779 | case 'h': |
| 1780 | { |
| 1781 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1782 | { |
| 1783 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1784 | break; |
| 1785 | } |
| 1786 | break; |
| 1787 | } |
| 1788 | case 'i': |
| 1789 | { |
| 1790 | if (LocaleCompare("identify",option+1) == 0) |
| 1791 | { |
| 1792 | char |
| 1793 | *text; |
| 1794 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1795 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1796 | if (format == (char *) NULL) |
| 1797 | { |
cristy | a403727 | 2011-08-28 15:11:39 +0000 | [diff] [blame] | 1798 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose, |
| 1799 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1800 | break; |
| 1801 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1802 | text=InterpretImageProperties(mogrify_info,*image,format, |
| 1803 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1804 | if (text == (char *) NULL) |
| 1805 | break; |
| 1806 | (void) fputs(text,stdout); |
| 1807 | (void) fputc('\n',stdout); |
| 1808 | text=DestroyString(text); |
| 1809 | break; |
| 1810 | } |
| 1811 | if (LocaleCompare("implode",option+1) == 0) |
| 1812 | { |
| 1813 | /* |
| 1814 | Implode image. |
| 1815 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1816 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1817 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 76f512e | 2011-09-12 01:26:56 +0000 | [diff] [blame] | 1818 | mogrify_image=ImplodeImage(*image,geometry_info.rho, |
| 1819 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1820 | break; |
| 1821 | } |
| 1822 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1823 | { |
| 1824 | if (*option == '+') |
| 1825 | (void) ParseGeometry("0",&geometry_info); |
| 1826 | else |
| 1827 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1828 | draw_info->interline_spacing=geometry_info.rho; |
| 1829 | break; |
| 1830 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 1831 | if (LocaleCompare("interpolate",option+1) == 0) |
| 1832 | { |
| 1833 | interpolate_method=(PixelInterpolateMethod) ParseCommandOption( |
| 1834 | MagickInterpolateOptions,MagickFalse,argv[i+1]); |
| 1835 | break; |
| 1836 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1837 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1838 | { |
| 1839 | if (*option == '+') |
| 1840 | (void) ParseGeometry("0",&geometry_info); |
| 1841 | else |
| 1842 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1843 | draw_info->interword_spacing=geometry_info.rho; |
| 1844 | break; |
| 1845 | } |
| 1846 | break; |
| 1847 | } |
| 1848 | case 'k': |
| 1849 | { |
| 1850 | if (LocaleCompare("kerning",option+1) == 0) |
| 1851 | { |
| 1852 | if (*option == '+') |
| 1853 | (void) ParseGeometry("0",&geometry_info); |
| 1854 | else |
| 1855 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1856 | draw_info->kerning=geometry_info.rho; |
| 1857 | break; |
| 1858 | } |
| 1859 | break; |
| 1860 | } |
| 1861 | case 'l': |
| 1862 | { |
| 1863 | if (LocaleCompare("lat",option+1) == 0) |
| 1864 | { |
| 1865 | /* |
| 1866 | Local adaptive threshold image. |
| 1867 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1868 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1869 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1870 | if ((flags & PercentValue) != 0) |
| 1871 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 1872 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
cristy | de5cc63 | 2011-07-18 14:47:00 +0000 | [diff] [blame] | 1873 | geometry_info.rho,(size_t) geometry_info.sigma,(double) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1874 | geometry_info.xi,exception); |
| 1875 | break; |
| 1876 | } |
| 1877 | if (LocaleCompare("level",option+1) == 0) |
| 1878 | { |
| 1879 | MagickRealType |
| 1880 | black_point, |
| 1881 | gamma, |
| 1882 | white_point; |
| 1883 | |
| 1884 | MagickStatusType |
| 1885 | flags; |
| 1886 | |
| 1887 | /* |
| 1888 | Parse levels. |
| 1889 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1890 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1891 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1892 | black_point=geometry_info.rho; |
| 1893 | white_point=(MagickRealType) QuantumRange; |
| 1894 | if ((flags & SigmaValue) != 0) |
| 1895 | white_point=geometry_info.sigma; |
| 1896 | gamma=1.0; |
| 1897 | if ((flags & XiValue) != 0) |
| 1898 | gamma=geometry_info.xi; |
| 1899 | if ((flags & PercentValue) != 0) |
| 1900 | { |
| 1901 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 1902 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 1903 | } |
| 1904 | if ((flags & SigmaValue) == 0) |
| 1905 | white_point=(MagickRealType) QuantumRange-black_point; |
| 1906 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1907 | (void) LevelizeImage(*image,black_point,white_point,gamma, |
| 1908 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1909 | else |
cristy | 01e9afd | 2011-08-10 17:38:41 +0000 | [diff] [blame] | 1910 | (void) LevelImage(*image,black_point,white_point,gamma, |
| 1911 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1912 | break; |
| 1913 | } |
| 1914 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1915 | { |
| 1916 | char |
| 1917 | token[MaxTextExtent]; |
| 1918 | |
| 1919 | const char |
| 1920 | *p; |
| 1921 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1922 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1923 | black_point, |
| 1924 | white_point; |
| 1925 | |
| 1926 | p=(const char *) argv[i+1]; |
| 1927 | GetMagickToken(p,&p,token); /* get black point color */ |
| 1928 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1929 | (void) QueryColorCompliance(token,AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1930 | &black_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1931 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1932 | (void) QueryColorCompliance("#000000",AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1933 | &black_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1934 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1935 | GetMagickToken(p,&p,token); |
| 1936 | if (*token == '\0') |
| 1937 | white_point=black_point; /* set everything to that color */ |
| 1938 | else |
| 1939 | { |
| 1940 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 1941 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 1942 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1943 | (void) QueryColorCompliance(token,AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1944 | &white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1945 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1946 | (void) QueryColorCompliance("#ffffff",AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1947 | &white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1948 | } |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 1949 | (void) LevelImageColors(*image,&black_point,&white_point, |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1950 | *option == '+' ? MagickTrue : MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1951 | break; |
| 1952 | } |
| 1953 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 1954 | { |
| 1955 | double |
| 1956 | black_point, |
| 1957 | white_point; |
| 1958 | |
| 1959 | MagickStatusType |
| 1960 | flags; |
| 1961 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1962 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1963 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1964 | black_point=geometry_info.rho; |
| 1965 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 1966 | if ((flags & SigmaValue) != 0) |
| 1967 | white_point=geometry_info.sigma; |
| 1968 | if ((flags & PercentValue) != 0) |
| 1969 | { |
| 1970 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1971 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1972 | } |
| 1973 | if ((flags & SigmaValue) == 0) |
| 1974 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1975 | black_point; |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 1976 | (void) LinearStretchImage(*image,black_point,white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1977 | break; |
| 1978 | } |
| 1979 | if (LocaleCompare("linewidth",option+1) == 0) |
| 1980 | { |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 1981 | draw_info->stroke_width=StringToDouble(argv[i+1], |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1982 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1983 | break; |
| 1984 | } |
| 1985 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 1986 | { |
| 1987 | /* |
| 1988 | Liquid rescale image. |
| 1989 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1990 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1991 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1992 | if ((flags & XValue) == 0) |
| 1993 | geometry.x=1; |
| 1994 | if ((flags & YValue) == 0) |
| 1995 | geometry.y=0; |
| 1996 | mogrify_image=LiquidRescaleImage(*image,geometry.width, |
| 1997 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 1998 | break; |
| 1999 | } |
| 2000 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 2001 | { |
| 2002 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 2003 | break; |
| 2004 | } |
| 2005 | break; |
| 2006 | } |
| 2007 | case 'm': |
| 2008 | { |
| 2009 | if (LocaleCompare("map",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2010 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2011 | Image |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2012 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2013 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2014 | /* |
| 2015 | Transform image colors to match this set of colors. |
| 2016 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2017 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2018 | if (*option == '+') |
| 2019 | break; |
| 2020 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2021 | if (remap_image == (Image *) NULL) |
| 2022 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2023 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2024 | remap_image=DestroyImage(remap_image); |
| 2025 | break; |
| 2026 | } |
| 2027 | if (LocaleCompare("mask",option+1) == 0) |
| 2028 | { |
| 2029 | Image |
| 2030 | *mask; |
| 2031 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2032 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2033 | if (*option == '+') |
| 2034 | { |
| 2035 | /* |
| 2036 | Remove a mask. |
| 2037 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2038 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2039 | break; |
| 2040 | } |
| 2041 | /* |
| 2042 | Set the image mask. |
| 2043 | */ |
| 2044 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2045 | if (mask == (Image *) NULL) |
| 2046 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2047 | (void) SetImageMask(*image,mask,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2048 | mask=DestroyImage(mask); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2049 | break; |
| 2050 | } |
| 2051 | if (LocaleCompare("matte",option+1) == 0) |
| 2052 | { |
| 2053 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 2054 | SetAlphaChannel : DeactivateAlphaChannel,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2055 | break; |
| 2056 | } |
| 2057 | if (LocaleCompare("median",option+1) == 0) |
| 2058 | { |
| 2059 | /* |
| 2060 | Median filter image. |
| 2061 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2062 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2063 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2064 | if ((flags & SigmaValue) == 0) |
| 2065 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2066 | mogrify_image=StatisticImage(*image,MedianStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2067 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2068 | break; |
| 2069 | } |
| 2070 | if (LocaleCompare("mode",option+1) == 0) |
| 2071 | { |
| 2072 | /* |
| 2073 | Mode image. |
| 2074 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2075 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2076 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2077 | if ((flags & SigmaValue) == 0) |
| 2078 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2079 | mogrify_image=StatisticImage(*image,ModeStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2080 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2081 | break; |
| 2082 | } |
| 2083 | if (LocaleCompare("modulate",option+1) == 0) |
| 2084 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2085 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2086 | (void) ModulateImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2087 | break; |
| 2088 | } |
| 2089 | if (LocaleCompare("monitor",option+1) == 0) |
| 2090 | { |
| 2091 | if (*option == '+') |
| 2092 | { |
| 2093 | (void) SetImageProgressMonitor(*image, |
| 2094 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2095 | break; |
| 2096 | } |
| 2097 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2098 | (void *) NULL); |
| 2099 | break; |
| 2100 | } |
| 2101 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2102 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2103 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2104 | (void) SetImageType(*image,BilevelType,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2105 | break; |
| 2106 | } |
| 2107 | if (LocaleCompare("morphology",option+1) == 0) |
| 2108 | { |
| 2109 | char |
| 2110 | token[MaxTextExtent]; |
| 2111 | |
| 2112 | const char |
| 2113 | *p; |
| 2114 | |
| 2115 | KernelInfo |
| 2116 | *kernel; |
| 2117 | |
| 2118 | MorphologyMethod |
| 2119 | method; |
| 2120 | |
| 2121 | ssize_t |
| 2122 | iterations; |
| 2123 | |
| 2124 | /* |
| 2125 | Morphological Image Operation |
| 2126 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2127 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2128 | p=argv[i+1]; |
| 2129 | GetMagickToken(p,&p,token); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2130 | method=(MorphologyMethod) ParseCommandOption( |
| 2131 | MagickMorphologyOptions,MagickFalse,token); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2132 | iterations=1L; |
| 2133 | GetMagickToken(p,&p,token); |
| 2134 | if ((*p == ':') || (*p == ',')) |
| 2135 | GetMagickToken(p,&p,token); |
| 2136 | if ((*p != '\0')) |
| 2137 | iterations=(ssize_t) StringToLong(p); |
| 2138 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2139 | if (kernel == (KernelInfo *) NULL) |
| 2140 | { |
| 2141 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2142 | OptionError,"UnabletoParseKernel","morphology"); |
| 2143 | status=MagickFalse; |
| 2144 | break; |
| 2145 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2146 | mogrify_image=MorphologyImage(*image,method,iterations,kernel, |
| 2147 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2148 | kernel=DestroyKernelInfo(kernel); |
| 2149 | break; |
| 2150 | } |
| 2151 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2152 | { |
| 2153 | /* |
| 2154 | Motion blur image. |
| 2155 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2156 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2157 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2158 | if ((flags & SigmaValue) == 0) |
| 2159 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2160 | mogrify_image=MotionBlurImage(*image,geometry_info.rho, |
cristy | f7ef025 | 2011-09-09 14:50:06 +0000 | [diff] [blame] | 2161 | geometry_info.sigma,geometry_info.xi,geometry_info.psi, |
| 2162 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2163 | break; |
| 2164 | } |
| 2165 | break; |
| 2166 | } |
| 2167 | case 'n': |
| 2168 | { |
| 2169 | if (LocaleCompare("negate",option+1) == 0) |
| 2170 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2171 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2172 | (void) NegateImage(*image,*option == '+' ? MagickTrue : |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 2173 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2174 | break; |
| 2175 | } |
| 2176 | if (LocaleCompare("noise",option+1) == 0) |
| 2177 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2178 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2179 | if (*option == '-') |
| 2180 | { |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2181 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2182 | if ((flags & SigmaValue) == 0) |
| 2183 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2184 | mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2185 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2186 | } |
| 2187 | else |
| 2188 | { |
| 2189 | NoiseType |
| 2190 | noise; |
| 2191 | |
| 2192 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
| 2193 | MagickFalse,argv[i+1]); |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 2194 | mogrify_image=AddNoiseImage(*image,noise,attenuate,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2195 | } |
| 2196 | break; |
| 2197 | } |
| 2198 | if (LocaleCompare("normalize",option+1) == 0) |
| 2199 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2200 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 2201 | (void) NormalizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2202 | break; |
| 2203 | } |
| 2204 | break; |
| 2205 | } |
| 2206 | case 'o': |
| 2207 | { |
| 2208 | if (LocaleCompare("opaque",option+1) == 0) |
| 2209 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2210 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2211 | target; |
| 2212 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2213 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2214 | (void) QueryColorCompliance(argv[i+1],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2215 | exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 2216 | (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ? |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 2217 | MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2218 | break; |
| 2219 | } |
| 2220 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2221 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2222 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 1302067 | 2011-07-08 02:33:26 +0000 | [diff] [blame] | 2223 | (void) OrderedPosterizeImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2224 | break; |
| 2225 | } |
| 2226 | break; |
| 2227 | } |
| 2228 | case 'p': |
| 2229 | { |
| 2230 | if (LocaleCompare("paint",option+1) == 0) |
| 2231 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2232 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2233 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 14973ba | 2011-08-27 23:48:07 +0000 | [diff] [blame] | 2234 | mogrify_image=OilPaintImage(*image,geometry_info.rho, |
| 2235 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2236 | break; |
| 2237 | } |
| 2238 | if (LocaleCompare("pen",option+1) == 0) |
| 2239 | { |
| 2240 | if (*option == '+') |
| 2241 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2242 | (void) QueryColorCompliance("none",AllCompliance, |
| 2243 | &draw_info->fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2244 | break; |
| 2245 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2246 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 2247 | &draw_info->fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2248 | break; |
| 2249 | } |
| 2250 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2251 | { |
| 2252 | if (*option == '+') |
| 2253 | (void) ParseGeometry("12",&geometry_info); |
| 2254 | else |
| 2255 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2256 | draw_info->pointsize=geometry_info.rho; |
| 2257 | break; |
| 2258 | } |
| 2259 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2260 | { |
| 2261 | double |
| 2262 | angle; |
| 2263 | |
| 2264 | RandomInfo |
| 2265 | *random_info; |
| 2266 | |
| 2267 | /* |
| 2268 | Simulate a Polaroid picture. |
| 2269 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2270 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2271 | random_info=AcquireRandomInfo(); |
| 2272 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2273 | random_info=DestroyRandomInfo(random_info); |
| 2274 | if (*option == '-') |
| 2275 | { |
| 2276 | SetGeometryInfo(&geometry_info); |
| 2277 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2278 | angle=geometry_info.rho; |
| 2279 | } |
cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame] | 2280 | mogrify_image=PolaroidImage(*image,draw_info,angle, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2281 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2282 | break; |
| 2283 | } |
| 2284 | if (LocaleCompare("posterize",option+1) == 0) |
| 2285 | { |
| 2286 | /* |
| 2287 | Posterize image. |
| 2288 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2289 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2290 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2291 | quantize_info->dither,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2292 | break; |
| 2293 | } |
| 2294 | if (LocaleCompare("preview",option+1) == 0) |
| 2295 | { |
| 2296 | PreviewType |
| 2297 | preview_type; |
| 2298 | |
| 2299 | /* |
| 2300 | Preview image. |
| 2301 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2302 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2303 | if (*option == '+') |
| 2304 | preview_type=UndefinedPreview; |
| 2305 | else |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2306 | preview_type=(PreviewType) ParseCommandOption( |
| 2307 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2308 | mogrify_image=PreviewImage(*image,preview_type,exception); |
| 2309 | break; |
| 2310 | } |
| 2311 | if (LocaleCompare("profile",option+1) == 0) |
| 2312 | { |
| 2313 | const char |
| 2314 | *name; |
| 2315 | |
| 2316 | const StringInfo |
| 2317 | *profile; |
| 2318 | |
| 2319 | Image |
| 2320 | *profile_image; |
| 2321 | |
| 2322 | ImageInfo |
| 2323 | *profile_info; |
| 2324 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2325 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2326 | if (*option == '+') |
| 2327 | { |
| 2328 | /* |
| 2329 | Remove a profile from the image. |
| 2330 | */ |
| 2331 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
cristy | 092d71c | 2011-10-14 18:01:29 +0000 | [diff] [blame] | 2332 | NULL,0,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2333 | break; |
| 2334 | } |
| 2335 | /* |
| 2336 | Associate a profile with the image. |
| 2337 | */ |
| 2338 | profile_info=CloneImageInfo(mogrify_info); |
| 2339 | profile=GetImageProfile(*image,"iptc"); |
| 2340 | if (profile != (StringInfo *) NULL) |
| 2341 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2342 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2343 | profile_info=DestroyImageInfo(profile_info); |
| 2344 | if (profile_image == (Image *) NULL) |
| 2345 | { |
| 2346 | StringInfo |
| 2347 | *profile; |
| 2348 | |
| 2349 | profile_info=CloneImageInfo(mogrify_info); |
| 2350 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2351 | MaxTextExtent); |
| 2352 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
| 2353 | if (profile != (StringInfo *) NULL) |
| 2354 | { |
| 2355 | (void) ProfileImage(*image,profile_info->magick, |
| 2356 | GetStringInfoDatum(profile),(size_t) |
| 2357 | GetStringInfoLength(profile),MagickFalse); |
| 2358 | profile=DestroyStringInfo(profile); |
| 2359 | } |
| 2360 | profile_info=DestroyImageInfo(profile_info); |
| 2361 | break; |
| 2362 | } |
| 2363 | ResetImageProfileIterator(profile_image); |
| 2364 | name=GetNextImageProfile(profile_image); |
| 2365 | while (name != (const char *) NULL) |
| 2366 | { |
| 2367 | profile=GetImageProfile(profile_image,name); |
| 2368 | if (profile != (StringInfo *) NULL) |
| 2369 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
| 2370 | (size_t) GetStringInfoLength(profile),MagickFalse); |
| 2371 | name=GetNextImageProfile(profile_image); |
| 2372 | } |
| 2373 | profile_image=DestroyImage(profile_image); |
| 2374 | break; |
| 2375 | } |
| 2376 | break; |
| 2377 | } |
| 2378 | case 'q': |
| 2379 | { |
| 2380 | if (LocaleCompare("quantize",option+1) == 0) |
| 2381 | { |
| 2382 | if (*option == '+') |
| 2383 | { |
| 2384 | quantize_info->colorspace=UndefinedColorspace; |
| 2385 | break; |
| 2386 | } |
| 2387 | quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
| 2388 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2389 | break; |
| 2390 | } |
| 2391 | break; |
| 2392 | } |
| 2393 | case 'r': |
| 2394 | { |
| 2395 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2396 | { |
| 2397 | /* |
| 2398 | Radial blur image. |
| 2399 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2400 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 6435bd9 | 2011-09-10 02:10:07 +0000 | [diff] [blame] | 2401 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2402 | mogrify_image=RadialBlurImage(*image,geometry_info.rho, |
| 2403 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2404 | break; |
| 2405 | } |
| 2406 | if (LocaleCompare("raise",option+1) == 0) |
| 2407 | { |
| 2408 | /* |
| 2409 | Surround image with a raise of solid color. |
| 2410 | */ |
| 2411 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2412 | if ((flags & SigmaValue) == 0) |
| 2413 | geometry.height=geometry.width; |
| 2414 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
cristy | 6170ac3 | 2011-08-28 14:15:37 +0000 | [diff] [blame] | 2415 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2416 | break; |
| 2417 | } |
| 2418 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2419 | { |
| 2420 | /* |
| 2421 | Threshold image. |
| 2422 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2423 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2424 | (void) RandomThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2425 | break; |
| 2426 | } |
| 2427 | if (LocaleCompare("recolor",option+1) == 0) |
| 2428 | { |
| 2429 | KernelInfo |
| 2430 | *kernel; |
| 2431 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2432 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2433 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2434 | if (kernel == (KernelInfo *) NULL) |
| 2435 | break; |
| 2436 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 2437 | kernel=DestroyKernelInfo(kernel); |
| 2438 | break; |
| 2439 | } |
| 2440 | if (LocaleCompare("region",option+1) == 0) |
| 2441 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2442 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2443 | if (region_image != (Image *) NULL) |
| 2444 | { |
| 2445 | /* |
| 2446 | Composite region. |
| 2447 | */ |
| 2448 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2449 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 2450 | region_geometry.x,region_geometry.y,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2451 | *image=DestroyImage(*image); |
| 2452 | *image=region_image; |
| 2453 | region_image = (Image *) NULL; |
| 2454 | } |
| 2455 | if (*option == '+') |
| 2456 | break; |
| 2457 | /* |
| 2458 | Apply transformations to a selected region of the image. |
| 2459 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2460 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2461 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2462 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2463 | if (mogrify_image == (Image *) NULL) |
| 2464 | break; |
| 2465 | region_image=(*image); |
| 2466 | *image=mogrify_image; |
| 2467 | mogrify_image=(Image *) NULL; |
| 2468 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2469 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2470 | if (LocaleCompare("render",option+1) == 0) |
| 2471 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2472 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2473 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2474 | break; |
| 2475 | } |
| 2476 | if (LocaleCompare("remap",option+1) == 0) |
| 2477 | { |
| 2478 | Image |
| 2479 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2480 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2481 | /* |
| 2482 | Transform image colors to match this set of colors. |
| 2483 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2484 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2485 | if (*option == '+') |
| 2486 | break; |
| 2487 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2488 | if (remap_image == (Image *) NULL) |
| 2489 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2490 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2491 | remap_image=DestroyImage(remap_image); |
| 2492 | break; |
| 2493 | } |
| 2494 | if (LocaleCompare("repage",option+1) == 0) |
| 2495 | { |
| 2496 | if (*option == '+') |
| 2497 | { |
| 2498 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2499 | break; |
| 2500 | } |
| 2501 | (void) ResetImagePage(*image,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2502 | break; |
| 2503 | } |
| 2504 | if (LocaleCompare("resample",option+1) == 0) |
| 2505 | { |
| 2506 | /* |
| 2507 | Resample image. |
| 2508 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2509 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2510 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2511 | if ((flags & SigmaValue) == 0) |
| 2512 | geometry_info.sigma=geometry_info.rho; |
| 2513 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
| 2514 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2515 | break; |
| 2516 | } |
| 2517 | if (LocaleCompare("resize",option+1) == 0) |
| 2518 | { |
| 2519 | /* |
| 2520 | Resize image. |
| 2521 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2522 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2523 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2524 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2525 | (*image)->filter,(*image)->blur,exception); |
| 2526 | break; |
| 2527 | } |
| 2528 | if (LocaleCompare("roll",option+1) == 0) |
| 2529 | { |
| 2530 | /* |
| 2531 | Roll image. |
| 2532 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2533 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2534 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2535 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2536 | break; |
| 2537 | } |
| 2538 | if (LocaleCompare("rotate",option+1) == 0) |
| 2539 | { |
| 2540 | char |
| 2541 | *geometry; |
| 2542 | |
| 2543 | /* |
| 2544 | Check for conditional image rotation. |
| 2545 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2546 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2547 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2548 | if ((*image)->columns <= (*image)->rows) |
| 2549 | break; |
| 2550 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2551 | if ((*image)->columns >= (*image)->rows) |
| 2552 | break; |
| 2553 | /* |
| 2554 | Rotate image. |
| 2555 | */ |
| 2556 | geometry=ConstantString(argv[i+1]); |
| 2557 | (void) SubstituteString(&geometry,">",""); |
| 2558 | (void) SubstituteString(&geometry,"<",""); |
| 2559 | (void) ParseGeometry(geometry,&geometry_info); |
| 2560 | geometry=DestroyString(geometry); |
| 2561 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
| 2562 | break; |
| 2563 | } |
| 2564 | break; |
| 2565 | } |
| 2566 | case 's': |
| 2567 | { |
| 2568 | if (LocaleCompare("sample",option+1) == 0) |
| 2569 | { |
| 2570 | /* |
| 2571 | Sample image with pixel replication. |
| 2572 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2573 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2574 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2575 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
| 2576 | exception); |
| 2577 | break; |
| 2578 | } |
| 2579 | if (LocaleCompare("scale",option+1) == 0) |
| 2580 | { |
| 2581 | /* |
| 2582 | Resize image. |
| 2583 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2584 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2585 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2586 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2587 | exception); |
| 2588 | break; |
| 2589 | } |
| 2590 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2591 | { |
| 2592 | /* |
| 2593 | Selectively blur pixels within a contrast threshold. |
| 2594 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2595 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2596 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2597 | if ((flags & PercentValue) != 0) |
| 2598 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2599 | mogrify_image=SelectiveBlurImage(*image,geometry_info.rho, |
cristy | 1e7aa31 | 2011-09-10 20:01:36 +0000 | [diff] [blame] | 2600 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2601 | break; |
| 2602 | } |
| 2603 | if (LocaleCompare("separate",option+1) == 0) |
| 2604 | { |
| 2605 | /* |
| 2606 | Break channels into separate images. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2607 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2608 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 2609 | mogrify_image=SeparateImages(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2610 | break; |
| 2611 | } |
| 2612 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2613 | { |
| 2614 | double |
| 2615 | threshold; |
| 2616 | |
| 2617 | /* |
| 2618 | Sepia-tone image. |
| 2619 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2620 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 2621 | threshold=StringToDoubleInterval(argv[i+1],QuantumRange); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2622 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
| 2623 | break; |
| 2624 | } |
| 2625 | if (LocaleCompare("segment",option+1) == 0) |
| 2626 | { |
| 2627 | /* |
| 2628 | Segment image. |
| 2629 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2630 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2631 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2632 | if ((flags & SigmaValue) == 0) |
| 2633 | geometry_info.sigma=1.0; |
| 2634 | (void) SegmentImage(*image,(*image)->colorspace, |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2635 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 2636 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2637 | break; |
| 2638 | } |
| 2639 | if (LocaleCompare("set",option+1) == 0) |
| 2640 | { |
| 2641 | char |
| 2642 | *value; |
| 2643 | |
| 2644 | /* |
| 2645 | Set image option. |
| 2646 | */ |
| 2647 | if (*option == '+') |
| 2648 | { |
| 2649 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2650 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2651 | else |
| 2652 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2653 | { |
| 2654 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
| 2655 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2656 | } |
| 2657 | else |
| 2658 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2659 | break; |
| 2660 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2661 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2662 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2663 | if (value == (char *) NULL) |
| 2664 | break; |
| 2665 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2666 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2667 | exception); |
| 2668 | else |
| 2669 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2670 | { |
| 2671 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
| 2672 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
| 2673 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2674 | } |
| 2675 | else |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 2676 | (void) SetImageProperty(*image,argv[i+1],value,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2677 | value=DestroyString(value); |
| 2678 | break; |
| 2679 | } |
| 2680 | if (LocaleCompare("shade",option+1) == 0) |
| 2681 | { |
| 2682 | /* |
| 2683 | Shade image. |
| 2684 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2685 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2686 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2687 | if ((flags & SigmaValue) == 0) |
| 2688 | geometry_info.sigma=1.0; |
| 2689 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2690 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2691 | break; |
| 2692 | } |
| 2693 | if (LocaleCompare("shadow",option+1) == 0) |
| 2694 | { |
| 2695 | /* |
| 2696 | Shadow image. |
| 2697 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2698 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2699 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2700 | if ((flags & SigmaValue) == 0) |
| 2701 | geometry_info.sigma=1.0; |
| 2702 | if ((flags & XiValue) == 0) |
| 2703 | geometry_info.xi=4.0; |
| 2704 | if ((flags & PsiValue) == 0) |
| 2705 | geometry_info.psi=4.0; |
| 2706 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
| 2707 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 2708 | ceil(geometry_info.psi-0.5),exception); |
| 2709 | break; |
| 2710 | } |
| 2711 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2712 | { |
| 2713 | /* |
| 2714 | Sharpen image. |
| 2715 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2716 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2717 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2718 | if ((flags & SigmaValue) == 0) |
| 2719 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2720 | if ((flags & XiValue) == 0) |
| 2721 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2722 | mogrify_image=SharpenImage(*image,geometry_info.rho, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2723 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2724 | break; |
| 2725 | } |
| 2726 | if (LocaleCompare("shave",option+1) == 0) |
| 2727 | { |
| 2728 | /* |
| 2729 | Shave the image edges. |
| 2730 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2731 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2732 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2733 | mogrify_image=ShaveImage(*image,&geometry,exception); |
| 2734 | break; |
| 2735 | } |
| 2736 | if (LocaleCompare("shear",option+1) == 0) |
| 2737 | { |
| 2738 | /* |
| 2739 | Shear image. |
| 2740 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2741 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2742 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2743 | if ((flags & SigmaValue) == 0) |
| 2744 | geometry_info.sigma=geometry_info.rho; |
| 2745 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2746 | geometry_info.sigma,exception); |
| 2747 | break; |
| 2748 | } |
| 2749 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2750 | { |
| 2751 | /* |
| 2752 | Sigmoidal non-linearity contrast control. |
| 2753 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2754 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2755 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2756 | if ((flags & SigmaValue) == 0) |
| 2757 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 2758 | if ((flags & PercentValue) != 0) |
| 2759 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2760 | 100.0; |
cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 2761 | (void) SigmoidalContrastImage(*image,(*option == '-') ? |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2762 | MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma, |
| 2763 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2764 | break; |
| 2765 | } |
| 2766 | if (LocaleCompare("sketch",option+1) == 0) |
| 2767 | { |
| 2768 | /* |
| 2769 | Sketch image. |
| 2770 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2771 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2772 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2773 | if ((flags & SigmaValue) == 0) |
| 2774 | geometry_info.sigma=1.0; |
| 2775 | mogrify_image=SketchImage(*image,geometry_info.rho, |
cristy | f7ef025 | 2011-09-09 14:50:06 +0000 | [diff] [blame] | 2776 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2777 | break; |
| 2778 | } |
| 2779 | if (LocaleCompare("solarize",option+1) == 0) |
| 2780 | { |
| 2781 | double |
| 2782 | threshold; |
| 2783 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2784 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 2785 | threshold=StringToDoubleInterval(argv[i+1],QuantumRange); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 2786 | (void) SolarizeImage(*image,threshold,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2787 | break; |
| 2788 | } |
| 2789 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2790 | { |
| 2791 | SparseColorMethod |
| 2792 | method; |
| 2793 | |
| 2794 | char |
| 2795 | *arguments; |
| 2796 | |
| 2797 | /* |
| 2798 | Sparse Color Interpolated Gradient |
| 2799 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2800 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2801 | method=(SparseColorMethod) ParseCommandOption( |
| 2802 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2803 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2804 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2805 | if (arguments == (char *) NULL) |
| 2806 | break; |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 2807 | mogrify_image=SparseColorOption(*image,method,arguments, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2808 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2809 | arguments=DestroyString(arguments); |
| 2810 | break; |
| 2811 | } |
| 2812 | if (LocaleCompare("splice",option+1) == 0) |
| 2813 | { |
| 2814 | /* |
| 2815 | Splice a solid color into the image. |
| 2816 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2817 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2818 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 2819 | mogrify_image=SpliceImage(*image,&geometry,exception); |
| 2820 | break; |
| 2821 | } |
| 2822 | if (LocaleCompare("spread",option+1) == 0) |
| 2823 | { |
| 2824 | /* |
| 2825 | Spread an image. |
| 2826 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2827 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2828 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame] | 2829 | mogrify_image=SpreadImage(*image,geometry_info.rho, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2830 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2831 | break; |
| 2832 | } |
| 2833 | if (LocaleCompare("statistic",option+1) == 0) |
| 2834 | { |
| 2835 | StatisticType |
| 2836 | type; |
| 2837 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2838 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2839 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
| 2840 | MagickFalse,argv[i+1]); |
| 2841 | (void) ParseGeometry(argv[i+2],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2842 | mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho, |
| 2843 | (size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2844 | break; |
| 2845 | } |
| 2846 | if (LocaleCompare("stretch",option+1) == 0) |
| 2847 | { |
| 2848 | if (*option == '+') |
| 2849 | { |
| 2850 | draw_info->stretch=UndefinedStretch; |
| 2851 | break; |
| 2852 | } |
| 2853 | draw_info->stretch=(StretchType) ParseCommandOption( |
| 2854 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2855 | break; |
| 2856 | } |
| 2857 | if (LocaleCompare("strip",option+1) == 0) |
| 2858 | { |
| 2859 | /* |
| 2860 | Strip image of profiles and comments. |
| 2861 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2862 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 2863 | (void) StripImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2864 | break; |
| 2865 | } |
| 2866 | if (LocaleCompare("stroke",option+1) == 0) |
| 2867 | { |
| 2868 | ExceptionInfo |
| 2869 | *sans; |
| 2870 | |
| 2871 | if (*option == '+') |
| 2872 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2873 | (void) QueryColorCompliance("none",AllCompliance, |
| 2874 | &draw_info->stroke,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2875 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2876 | draw_info->stroke_pattern=DestroyImage( |
| 2877 | draw_info->stroke_pattern); |
| 2878 | break; |
| 2879 | } |
| 2880 | sans=AcquireExceptionInfo(); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2881 | status=QueryColorCompliance(argv[i+1],AllCompliance, |
| 2882 | &draw_info->stroke,sans); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2883 | sans=DestroyExceptionInfo(sans); |
| 2884 | if (status == MagickFalse) |
| 2885 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2886 | exception); |
| 2887 | break; |
| 2888 | } |
| 2889 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2890 | { |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 2891 | draw_info->stroke_width=StringToDouble(argv[i+1], |
cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 2892 | (char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2893 | break; |
| 2894 | } |
| 2895 | if (LocaleCompare("style",option+1) == 0) |
| 2896 | { |
| 2897 | if (*option == '+') |
| 2898 | { |
| 2899 | draw_info->style=UndefinedStyle; |
| 2900 | break; |
| 2901 | } |
| 2902 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 2903 | MagickFalse,argv[i+1]); |
| 2904 | break; |
| 2905 | } |
| 2906 | if (LocaleCompare("swirl",option+1) == 0) |
| 2907 | { |
| 2908 | /* |
| 2909 | Swirl image. |
| 2910 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2911 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2912 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 76f512e | 2011-09-12 01:26:56 +0000 | [diff] [blame] | 2913 | mogrify_image=SwirlImage(*image,geometry_info.rho, |
| 2914 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2915 | break; |
| 2916 | } |
| 2917 | break; |
| 2918 | } |
| 2919 | case 't': |
| 2920 | { |
| 2921 | if (LocaleCompare("threshold",option+1) == 0) |
| 2922 | { |
| 2923 | double |
| 2924 | threshold; |
| 2925 | |
| 2926 | /* |
| 2927 | Threshold image. |
| 2928 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2929 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2930 | if (*option == '+') |
anthony | 247a86d | 2011-05-03 13:18:18 +0000 | [diff] [blame] | 2931 | threshold=(double) QuantumRange/2; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2932 | else |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 2933 | threshold=StringToDoubleInterval(argv[i+1],QuantumRange); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 2934 | (void) BilevelImage(*image,threshold,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2935 | break; |
| 2936 | } |
| 2937 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2938 | { |
| 2939 | /* |
| 2940 | Thumbnail image. |
| 2941 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2942 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2943 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2944 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2945 | exception); |
| 2946 | break; |
| 2947 | } |
| 2948 | if (LocaleCompare("tile",option+1) == 0) |
| 2949 | { |
| 2950 | if (*option == '+') |
| 2951 | { |
| 2952 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2953 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2954 | break; |
| 2955 | } |
| 2956 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2957 | exception); |
| 2958 | break; |
| 2959 | } |
| 2960 | if (LocaleCompare("tint",option+1) == 0) |
| 2961 | { |
| 2962 | /* |
| 2963 | Tint the image. |
| 2964 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2965 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2966 | mogrify_image=TintImage(*image,argv[i+1],&fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2967 | break; |
| 2968 | } |
| 2969 | if (LocaleCompare("transform",option+1) == 0) |
| 2970 | { |
| 2971 | /* |
| 2972 | Affine transform image. |
| 2973 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2974 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2975 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
| 2976 | exception); |
| 2977 | break; |
| 2978 | } |
| 2979 | if (LocaleCompare("transparent",option+1) == 0) |
| 2980 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2981 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2982 | target; |
| 2983 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2984 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2985 | (void) QueryColorCompliance(argv[i+1],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2986 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2987 | (void) TransparentPaintImage(*image,&target,(Quantum) |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 2988 | TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue, |
cristy | 82d7af5 | 2011-10-16 16:26:41 +0000 | [diff] [blame] | 2989 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2990 | break; |
| 2991 | } |
| 2992 | if (LocaleCompare("transpose",option+1) == 0) |
| 2993 | { |
| 2994 | /* |
| 2995 | Transpose image scanlines. |
| 2996 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2997 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2998 | mogrify_image=TransposeImage(*image,exception); |
| 2999 | break; |
| 3000 | } |
| 3001 | if (LocaleCompare("transverse",option+1) == 0) |
| 3002 | { |
| 3003 | /* |
| 3004 | Transverse image scanlines. |
| 3005 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3006 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3007 | mogrify_image=TransverseImage(*image,exception); |
| 3008 | break; |
| 3009 | } |
| 3010 | if (LocaleCompare("treedepth",option+1) == 0) |
| 3011 | { |
| 3012 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
| 3013 | break; |
| 3014 | } |
| 3015 | if (LocaleCompare("trim",option+1) == 0) |
| 3016 | { |
| 3017 | /* |
| 3018 | Trim image. |
| 3019 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3020 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3021 | mogrify_image=TrimImage(*image,exception); |
| 3022 | break; |
| 3023 | } |
| 3024 | if (LocaleCompare("type",option+1) == 0) |
| 3025 | { |
| 3026 | ImageType |
| 3027 | type; |
| 3028 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3029 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3030 | if (*option == '+') |
| 3031 | type=UndefinedType; |
| 3032 | else |
| 3033 | type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 3034 | argv[i+1]); |
| 3035 | (*image)->type=UndefinedType; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3036 | (void) SetImageType(*image,type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3037 | break; |
| 3038 | } |
| 3039 | break; |
| 3040 | } |
| 3041 | case 'u': |
| 3042 | { |
| 3043 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3044 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 3045 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 3046 | &draw_info->undercolor,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3047 | break; |
| 3048 | } |
| 3049 | if (LocaleCompare("unique",option+1) == 0) |
| 3050 | { |
| 3051 | if (*option == '+') |
| 3052 | { |
| 3053 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
| 3054 | break; |
| 3055 | } |
| 3056 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
| 3057 | (void) SetImageArtifact(*image,"verbose","true"); |
| 3058 | break; |
| 3059 | } |
| 3060 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3061 | { |
| 3062 | /* |
| 3063 | Unique image colors. |
| 3064 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3065 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3066 | mogrify_image=UniqueImageColors(*image,exception); |
| 3067 | break; |
| 3068 | } |
| 3069 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3070 | { |
| 3071 | /* |
| 3072 | Unsharp mask image. |
| 3073 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3074 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3075 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3076 | if ((flags & SigmaValue) == 0) |
| 3077 | geometry_info.sigma=1.0; |
| 3078 | if ((flags & XiValue) == 0) |
| 3079 | geometry_info.xi=1.0; |
| 3080 | if ((flags & PsiValue) == 0) |
| 3081 | geometry_info.psi=0.05; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3082 | mogrify_image=UnsharpMaskImage(*image,geometry_info.rho, |
| 3083 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3084 | break; |
| 3085 | } |
| 3086 | break; |
| 3087 | } |
| 3088 | case 'v': |
| 3089 | { |
| 3090 | if (LocaleCompare("verbose",option+1) == 0) |
| 3091 | { |
| 3092 | (void) SetImageArtifact(*image,option+1, |
| 3093 | *option == '+' ? "false" : "true"); |
| 3094 | break; |
| 3095 | } |
| 3096 | if (LocaleCompare("vignette",option+1) == 0) |
| 3097 | { |
| 3098 | /* |
| 3099 | Vignette image. |
| 3100 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3101 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3102 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3103 | if ((flags & SigmaValue) == 0) |
| 3104 | geometry_info.sigma=1.0; |
| 3105 | if ((flags & XiValue) == 0) |
| 3106 | geometry_info.xi=0.1*(*image)->columns; |
| 3107 | if ((flags & PsiValue) == 0) |
| 3108 | geometry_info.psi=0.1*(*image)->rows; |
| 3109 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
| 3110 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3111 | ceil(geometry_info.psi-0.5),exception); |
| 3112 | break; |
| 3113 | } |
| 3114 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3115 | { |
| 3116 | if (*option == '+') |
| 3117 | { |
| 3118 | (void) SetImageVirtualPixelMethod(*image, |
| 3119 | UndefinedVirtualPixelMethod); |
| 3120 | break; |
| 3121 | } |
| 3122 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3123 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 3124 | argv[i+1])); |
| 3125 | break; |
| 3126 | } |
| 3127 | break; |
| 3128 | } |
| 3129 | case 'w': |
| 3130 | { |
| 3131 | if (LocaleCompare("wave",option+1) == 0) |
| 3132 | { |
| 3133 | /* |
| 3134 | Wave image. |
| 3135 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3136 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3137 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3138 | if ((flags & SigmaValue) == 0) |
| 3139 | geometry_info.sigma=1.0; |
| 3140 | mogrify_image=WaveImage(*image,geometry_info.rho, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 3141 | geometry_info.sigma,interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3142 | break; |
| 3143 | } |
| 3144 | if (LocaleCompare("weight",option+1) == 0) |
| 3145 | { |
| 3146 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
| 3147 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3148 | draw_info->weight=0; |
| 3149 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3150 | draw_info->weight=700; |
| 3151 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3152 | if (draw_info->weight <= 800) |
| 3153 | draw_info->weight+=100; |
| 3154 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3155 | if (draw_info->weight >= 100) |
| 3156 | draw_info->weight-=100; |
| 3157 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3158 | draw_info->weight=400; |
| 3159 | break; |
| 3160 | } |
| 3161 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3162 | { |
| 3163 | /* |
| 3164 | White threshold image. |
| 3165 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3166 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3167 | (void) WhiteThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3168 | break; |
| 3169 | } |
| 3170 | break; |
| 3171 | } |
| 3172 | default: |
| 3173 | break; |
| 3174 | } |
| 3175 | /* |
| 3176 | Replace current image with any image that was generated |
| 3177 | */ |
| 3178 | if (mogrify_image != (Image *) NULL) |
| 3179 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3180 | i+=count; |
| 3181 | } |
| 3182 | if (region_image != (Image *) NULL) |
| 3183 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3184 | /* |
| 3185 | Composite transformed region onto image. |
| 3186 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3187 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3188 | (void) CompositeImage(region_image,region_image->matte != |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3189 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 3190 | region_geometry.x,region_geometry.y,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3191 | *image=DestroyImage(*image); |
| 3192 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3193 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3194 | } |
| 3195 | /* |
| 3196 | Free resources. |
| 3197 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3198 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3199 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3200 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 82d7af5 | 2011-10-16 16:26:41 +0000 | [diff] [blame] | 3201 | status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3202 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3203 | } |
| 3204 | |
| 3205 | /* |
| 3206 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3207 | % % |
| 3208 | % % |
| 3209 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3210 | + 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] | 3211 | % % |
| 3212 | % % |
| 3213 | % % |
| 3214 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3215 | % |
| 3216 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3217 | % transforms include image scaling, image rotation, color reduction, and |
| 3218 | % others. The transmogrified image overwrites the original image. |
| 3219 | % |
| 3220 | % The format of the MogrifyImageCommand method is: |
| 3221 | % |
| 3222 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3223 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3224 | % |
| 3225 | % A description of each parameter follows: |
| 3226 | % |
| 3227 | % o image_info: the image info. |
| 3228 | % |
| 3229 | % o argc: the number of elements in the argument vector. |
| 3230 | % |
| 3231 | % o argv: A text array containing the command line arguments. |
| 3232 | % |
| 3233 | % o metadata: any metadata is returned here. |
| 3234 | % |
| 3235 | % o exception: return any errors or warnings in this structure. |
| 3236 | % |
| 3237 | */ |
| 3238 | |
| 3239 | static MagickBooleanType MogrifyUsage(void) |
| 3240 | { |
| 3241 | static const char |
| 3242 | *miscellaneous[]= |
| 3243 | { |
| 3244 | "-debug events display copious debugging information", |
| 3245 | "-help print program options", |
| 3246 | "-list type print a list of supported option arguments", |
| 3247 | "-log format format of debugging information", |
| 3248 | "-version print version information", |
| 3249 | (char *) NULL |
| 3250 | }, |
| 3251 | *operators[]= |
| 3252 | { |
| 3253 | "-adaptive-blur geometry", |
| 3254 | " adaptively blur pixels; decrease effect near edges", |
| 3255 | "-adaptive-resize geometry", |
| 3256 | " adaptively resize image using 'mesh' interpolation", |
| 3257 | "-adaptive-sharpen geometry", |
| 3258 | " adaptively sharpen pixels; increase effect near edges", |
| 3259 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3260 | " transparent, extract, background, or shape", |
| 3261 | "-annotate geometry text", |
| 3262 | " annotate the image with text", |
| 3263 | "-auto-gamma automagically adjust gamma level of image", |
| 3264 | "-auto-level automagically adjust color levels of image", |
| 3265 | "-auto-orient automagically orient (rotate) image", |
| 3266 | "-bench iterations measure performance", |
| 3267 | "-black-threshold value", |
| 3268 | " force all pixels below the threshold into black", |
| 3269 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3270 | "-blur geometry reduce image noise and reduce detail levels", |
| 3271 | "-border geometry surround image with a border of color", |
| 3272 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3273 | "-brightness-contrast geometry", |
| 3274 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3275 | "-cdl filename color correct with a color decision list", |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 3276 | "-charcoal geometry simulate a charcoal drawing", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3277 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3278 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3279 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3280 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3281 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3282 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3283 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3284 | "-contrast enhance or reduce the image contrast", |
| 3285 | "-contrast-stretch geometry", |
| 3286 | " improve contrast by `stretching' the intensity range", |
| 3287 | "-convolve coefficients", |
| 3288 | " apply a convolution kernel to the image", |
| 3289 | "-cycle amount cycle the image colormap", |
| 3290 | "-decipher filename convert cipher pixels to plain pixels", |
| 3291 | "-deskew threshold straighten an image", |
| 3292 | "-despeckle reduce the speckles within an image", |
| 3293 | "-distort method args", |
| 3294 | " distort images according to given method ad args", |
| 3295 | "-draw string annotate the image with a graphic primitive", |
| 3296 | "-edge radius apply a filter to detect edges in the image", |
| 3297 | "-encipher filename convert plain pixels to cipher pixels", |
| 3298 | "-emboss radius emboss an image", |
| 3299 | "-enhance apply a digital filter to enhance a noisy image", |
| 3300 | "-equalize perform histogram equalization to an image", |
| 3301 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3302 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3303 | "-extent geometry set the image size", |
| 3304 | "-extract geometry extract area from image", |
| 3305 | "-fft implements the discrete Fourier transform (DFT)", |
| 3306 | "-flip flip image vertically", |
| 3307 | "-floodfill geometry color", |
| 3308 | " floodfill the image with color", |
| 3309 | "-flop flop image horizontally", |
| 3310 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3311 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3312 | " apply function over image values", |
| 3313 | "-gamma value level of gamma correction", |
| 3314 | "-gaussian-blur geometry", |
| 3315 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3316 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3317 | "-identify identify the format and characteristics of the image", |
| 3318 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3319 | "-implode amount implode image pixels about the center", |
| 3320 | "-lat geometry local adaptive thresholding", |
| 3321 | "-layers method optimize, merge, or compare image layers", |
| 3322 | "-level value adjust the level of image contrast", |
| 3323 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3324 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3325 | "-linear-stretch geometry", |
| 3326 | " improve contrast by `stretching with saturation'", |
| 3327 | "-liquid-rescale geometry", |
| 3328 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3329 | "-median geometry apply a median filter to the image", |
glennrp | 30d2dc6 | 2011-06-25 03:17:16 +0000 | [diff] [blame] | 3330 | "-mode geometry make each pixel the 'predominant color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3331 | "-modulate value vary the brightness, saturation, and hue", |
| 3332 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3333 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3334 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3335 | "-motion-blur geometry", |
| 3336 | " simulate motion blur", |
| 3337 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3338 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3339 | "-normalize transform image to span the full range of colors", |
| 3340 | "-opaque color change this color to the fill color", |
| 3341 | "-ordered-dither NxN", |
| 3342 | " add a noise pattern to the image with specific", |
| 3343 | " amplitudes", |
| 3344 | "-paint radius simulate an oil painting", |
| 3345 | "-polaroid angle simulate a Polaroid picture", |
| 3346 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3347 | "-profile filename add, delete, or apply an image profile", |
| 3348 | "-quantize colorspace reduce colors in this colorspace", |
| 3349 | "-radial-blur angle radial blur the image", |
| 3350 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3351 | "-random-threshold low,high", |
| 3352 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3353 | "-region geometry apply options to a portion of the image", |
| 3354 | "-render render vector graphics", |
| 3355 | "-repage geometry size and location of an image canvas", |
| 3356 | "-resample geometry change the resolution of an image", |
| 3357 | "-resize geometry resize the image", |
| 3358 | "-roll geometry roll an image vertically or horizontally", |
| 3359 | "-rotate degrees apply Paeth rotation to the image", |
| 3360 | "-sample geometry scale image with pixel sampling", |
| 3361 | "-scale geometry scale the image", |
| 3362 | "-segment values segment an image", |
| 3363 | "-selective-blur geometry", |
| 3364 | " selectively blur pixels within a contrast threshold", |
| 3365 | "-sepia-tone threshold", |
| 3366 | " simulate a sepia-toned photo", |
| 3367 | "-set property value set an image property", |
| 3368 | "-shade degrees shade the image using a distant light source", |
| 3369 | "-shadow geometry simulate an image shadow", |
| 3370 | "-sharpen geometry sharpen the image", |
| 3371 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3372 | "-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] | 3373 | "-sigmoidal-contrast geometry", |
| 3374 | " increase the contrast without saturating highlights or shadows", |
| 3375 | "-sketch geometry simulate a pencil sketch", |
| 3376 | "-solarize threshold negate all pixels above the threshold level", |
| 3377 | "-sparse-color method args", |
| 3378 | " fill in a image based on a few color points", |
| 3379 | "-splice geometry splice the background color into the image", |
| 3380 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3381 | "-statistic type radius", |
| 3382 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3383 | "-strip strip image of all profiles and comments", |
| 3384 | "-swirl degrees swirl image pixels about the center", |
| 3385 | "-threshold value threshold the image", |
| 3386 | "-thumbnail geometry create a thumbnail of the image", |
| 3387 | "-tile filename tile image when filling a graphic primitive", |
| 3388 | "-tint value tint the image with the fill color", |
| 3389 | "-transform affine transform image", |
| 3390 | "-transparent color make this color transparent within the image", |
| 3391 | "-transpose flip image vertically and rotate 90 degrees", |
| 3392 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3393 | "-trim trim image edges", |
| 3394 | "-type type image type", |
| 3395 | "-unique-colors discard all but one of any pixel color", |
| 3396 | "-unsharp geometry sharpen the image", |
| 3397 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3398 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3399 | "-white-threshold value", |
| 3400 | " force all pixels above the threshold into white", |
| 3401 | (char *) NULL |
| 3402 | }, |
| 3403 | *sequence_operators[]= |
| 3404 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3405 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3406 | "-clut apply a color lookup table to the image", |
| 3407 | "-coalesce merge a sequence of images", |
| 3408 | "-combine combine a sequence of images", |
| 3409 | "-composite composite image", |
| 3410 | "-crop geometry cut out a rectangular region of the image", |
| 3411 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3412 | "-evaluate-sequence operator", |
| 3413 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3414 | "-flatten flatten a sequence of images", |
| 3415 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3416 | "-hald-clut apply a Hald color lookup table to the image", |
| 3417 | "-morph value morph an image sequence", |
| 3418 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3419 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3420 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3421 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3422 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3423 | "-write filename write images to this file", |
| 3424 | (char *) NULL |
| 3425 | }, |
| 3426 | *settings[]= |
| 3427 | { |
| 3428 | "-adjoin join images into a single multi-image file", |
| 3429 | "-affine matrix affine transform matrix", |
| 3430 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3431 | "-antialias remove pixel-aliasing", |
| 3432 | "-authenticate password", |
| 3433 | " decipher image with this password", |
| 3434 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3435 | "-background color background color", |
| 3436 | "-bias value add bias when convolving an image", |
| 3437 | "-black-point-compensation", |
| 3438 | " use black point compensation", |
| 3439 | "-blue-primary point chromaticity blue primary point", |
| 3440 | "-bordercolor color border color", |
| 3441 | "-caption string assign a caption to an image", |
| 3442 | "-channel type apply option to select image channels", |
| 3443 | "-colors value preferred number of colors in the image", |
| 3444 | "-colorspace type alternate image colorspace", |
| 3445 | "-comment string annotate image with comment", |
| 3446 | "-compose operator set image composite operator", |
| 3447 | "-compress type type of pixel compression when writing the image", |
| 3448 | "-define format:option", |
| 3449 | " define one or more image format options", |
| 3450 | "-delay value display the next image after pausing", |
| 3451 | "-density geometry horizontal and vertical density of the image", |
| 3452 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3453 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3454 | "-display server get image or font from this X server", |
| 3455 | "-dispose method layer disposal method", |
| 3456 | "-dither method apply error diffusion to image", |
| 3457 | "-encoding type text encoding type", |
| 3458 | "-endian type endianness (MSB or LSB) of the image", |
| 3459 | "-family name render text with this font family", |
| 3460 | "-fill color color to use when filling a graphic primitive", |
| 3461 | "-filter type use this filter when resizing an image", |
| 3462 | "-font name render text with this font", |
| 3463 | "-format \"string\" output formatted image characteristics", |
| 3464 | "-fuzz distance colors within this distance are considered equal", |
| 3465 | "-gravity type horizontal and vertical text placement", |
| 3466 | "-green-primary point chromaticity green primary point", |
| 3467 | "-intent type type of rendering intent when managing the image color", |
| 3468 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3469 | "-interline-spacing value", |
| 3470 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3471 | "-interpolate method pixel color interpolation method", |
| 3472 | "-interword-spacing value", |
| 3473 | " set the space between two words", |
| 3474 | "-kerning value set the space between two letters", |
| 3475 | "-label string assign a label to an image", |
| 3476 | "-limit type value pixel cache resource limit", |
| 3477 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3478 | "-mask filename associate a mask with the image", |
| 3479 | "-mattecolor color frame color", |
| 3480 | "-monitor monitor progress", |
| 3481 | "-orient type image orientation", |
| 3482 | "-page geometry size and location of an image canvas (setting)", |
| 3483 | "-ping efficiently determine image attributes", |
| 3484 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3485 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3486 | "-preview type image preview type", |
| 3487 | "-quality value JPEG/MIFF/PNG compression level", |
| 3488 | "-quiet suppress all warning messages", |
| 3489 | "-red-primary point chromaticity red primary point", |
| 3490 | "-regard-warnings pay attention to warning messages", |
| 3491 | "-remap filename transform image colors to match this set of colors", |
| 3492 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3493 | "-sampling-factor geometry", |
| 3494 | " horizontal and vertical sampling factor", |
| 3495 | "-scene value image scene number", |
| 3496 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3497 | "-size geometry width and height of image", |
| 3498 | "-stretch type render text with this font stretch", |
| 3499 | "-stroke color graphic primitive stroke color", |
| 3500 | "-strokewidth value graphic primitive stroke width", |
| 3501 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3502 | "-synchronize synchronize image to storage device", |
| 3503 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3504 | "-texture filename name of texture to tile onto the image background", |
| 3505 | "-tile-offset geometry", |
| 3506 | " tile offset", |
| 3507 | "-treedepth value color tree depth", |
| 3508 | "-transparent-color color", |
| 3509 | " transparent color", |
| 3510 | "-undercolor color annotation bounding box color", |
| 3511 | "-units type the units of image resolution", |
| 3512 | "-verbose print detailed information about the image", |
| 3513 | "-view FlashPix viewing transforms", |
| 3514 | "-virtual-pixel method", |
| 3515 | " virtual pixel access method", |
| 3516 | "-weight type render text with this font weight", |
| 3517 | "-white-point point chromaticity white point", |
| 3518 | (char *) NULL |
| 3519 | }, |
| 3520 | *stack_operators[]= |
| 3521 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3522 | "-delete indexes delete the image from the image sequence", |
| 3523 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3524 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3525 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3526 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3527 | "-swap indexes swap two images in the image sequence", |
| 3528 | (char *) NULL |
| 3529 | }; |
| 3530 | |
| 3531 | const char |
| 3532 | **p; |
| 3533 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3534 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3535 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3536 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3537 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3538 | GetClientName()); |
| 3539 | (void) printf("\nImage Settings:\n"); |
| 3540 | for (p=settings; *p != (char *) NULL; p++) |
| 3541 | (void) printf(" %s\n",*p); |
| 3542 | (void) printf("\nImage Operators:\n"); |
| 3543 | for (p=operators; *p != (char *) NULL; p++) |
| 3544 | (void) printf(" %s\n",*p); |
| 3545 | (void) printf("\nImage Sequence Operators:\n"); |
| 3546 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3547 | (void) printf(" %s\n",*p); |
| 3548 | (void) printf("\nImage Stack Operators:\n"); |
| 3549 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3550 | (void) printf(" %s\n",*p); |
| 3551 | (void) printf("\nMiscellaneous Options:\n"); |
| 3552 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3553 | (void) printf(" %s\n",*p); |
| 3554 | (void) printf( |
| 3555 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3556 | (void) printf( |
| 3557 | "number. To specify a particular image format, precede the filename\n"); |
| 3558 | (void) printf( |
| 3559 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3560 | (void) printf( |
| 3561 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3562 | (void) printf("'-' for standard input or output.\n"); |
| 3563 | return(MagickFalse); |
| 3564 | } |
| 3565 | |
| 3566 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3567 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3568 | { |
| 3569 | #define DestroyMogrify() \ |
| 3570 | { \ |
| 3571 | if (format != (char *) NULL) \ |
| 3572 | format=DestroyString(format); \ |
| 3573 | if (path != (char *) NULL) \ |
| 3574 | path=DestroyString(path); \ |
| 3575 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3576 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3577 | argv[i]=DestroyString(argv[i]); \ |
| 3578 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3579 | } |
| 3580 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3581 | { \ |
| 3582 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3583 | option); \ |
| 3584 | DestroyMogrify(); \ |
| 3585 | return(MagickFalse); \ |
| 3586 | } |
| 3587 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3588 | { \ |
| 3589 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3590 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3591 | DestroyMogrify(); \ |
| 3592 | return(MagickFalse); \ |
| 3593 | } |
| 3594 | |
| 3595 | char |
| 3596 | *format, |
| 3597 | *option, |
| 3598 | *path; |
| 3599 | |
| 3600 | Image |
| 3601 | *image; |
| 3602 | |
| 3603 | ImageStack |
| 3604 | image_stack[MaxImageStackDepth+1]; |
| 3605 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3606 | MagickBooleanType |
| 3607 | global_colormap; |
| 3608 | |
| 3609 | MagickBooleanType |
| 3610 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3611 | pend, |
| 3612 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3613 | |
| 3614 | MagickStatusType |
| 3615 | status; |
| 3616 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3617 | register ssize_t |
| 3618 | i; |
| 3619 | |
| 3620 | ssize_t |
| 3621 | j, |
| 3622 | k; |
| 3623 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3624 | /* |
| 3625 | Set defaults. |
| 3626 | */ |
| 3627 | assert(image_info != (ImageInfo *) NULL); |
| 3628 | assert(image_info->signature == MagickSignature); |
| 3629 | if (image_info->debug != MagickFalse) |
| 3630 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3631 | assert(exception != (ExceptionInfo *) NULL); |
| 3632 | if (argc == 2) |
| 3633 | { |
| 3634 | option=argv[1]; |
| 3635 | if ((LocaleCompare("version",option+1) == 0) || |
| 3636 | (LocaleCompare("-version",option+1) == 0)) |
| 3637 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3638 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3639 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 3640 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 3641 | GetMagickCopyright()); |
| 3642 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 3643 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3644 | return(MagickFalse); |
| 3645 | } |
| 3646 | } |
| 3647 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3648 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3649 | format=(char *) NULL; |
| 3650 | path=(char *) NULL; |
| 3651 | global_colormap=MagickFalse; |
| 3652 | k=0; |
| 3653 | j=1; |
| 3654 | NewImageStack(); |
| 3655 | option=(char *) NULL; |
| 3656 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3657 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3658 | status=MagickTrue; |
| 3659 | /* |
| 3660 | Parse command line. |
| 3661 | */ |
| 3662 | ReadCommandlLine(argc,&argv); |
| 3663 | status=ExpandFilenames(&argc,&argv); |
| 3664 | if (status == MagickFalse) |
| 3665 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3666 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3667 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3668 | { |
| 3669 | option=argv[i]; |
| 3670 | if (LocaleCompare(option,"(") == 0) |
| 3671 | { |
| 3672 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3673 | if (k == MaxImageStackDepth) |
| 3674 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3675 | option); |
| 3676 | PushImageStack(); |
| 3677 | continue; |
| 3678 | } |
| 3679 | if (LocaleCompare(option,")") == 0) |
| 3680 | { |
| 3681 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3682 | if (k == 0) |
| 3683 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3684 | PopImageStack(); |
| 3685 | continue; |
| 3686 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3687 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3688 | { |
| 3689 | char |
| 3690 | backup_filename[MaxTextExtent], |
| 3691 | *filename; |
| 3692 | |
| 3693 | Image |
| 3694 | *images; |
| 3695 | |
| 3696 | /* |
| 3697 | Option is a file name: begin by reading image from specified file. |
| 3698 | */ |
| 3699 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3700 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3701 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3702 | filename=argv[++i]; |
| 3703 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 3704 | images=ReadImages(image_info,exception); |
| 3705 | status&=(images != (Image *) NULL) && |
| 3706 | (exception->severity < ErrorException); |
| 3707 | if (images == (Image *) NULL) |
| 3708 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3709 | if (format != (char *) NULL) |
| 3710 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3711 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3712 | if (path != (char *) NULL) |
| 3713 | { |
| 3714 | GetPathComponent(option,TailPath,filename); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3715 | (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3716 | path,*DirectorySeparator,filename); |
| 3717 | } |
| 3718 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3719 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3720 | AppendImageStack(images); |
| 3721 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3722 | if (global_colormap != MagickFalse) |
| 3723 | { |
| 3724 | QuantizeInfo |
| 3725 | *quantize_info; |
| 3726 | |
| 3727 | quantize_info=AcquireQuantizeInfo(image_info); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3728 | (void) RemapImages(quantize_info,images,(Image *) NULL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3729 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3730 | } |
| 3731 | *backup_filename='\0'; |
| 3732 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3733 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3734 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3735 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3736 | i; |
| 3737 | |
| 3738 | /* |
| 3739 | Rename image file as backup. |
| 3740 | */ |
| 3741 | (void) CopyMagickString(backup_filename,image->filename, |
| 3742 | MaxTextExtent); |
| 3743 | for (i=0; i < 6; i++) |
| 3744 | { |
| 3745 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3746 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3747 | break; |
| 3748 | } |
| 3749 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
cristy | 320684d | 2011-09-23 14:55:47 +0000 | [diff] [blame] | 3750 | (rename_utf8(image->filename,backup_filename) != 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3751 | *backup_filename='\0'; |
| 3752 | } |
| 3753 | /* |
| 3754 | Write transmogrified image to disk. |
| 3755 | */ |
| 3756 | image_info->synchronize=MagickTrue; |
| 3757 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3758 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 3759 | (void) remove_utf8(backup_filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3760 | RemoveAllImageStack(); |
| 3761 | continue; |
| 3762 | } |
| 3763 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3764 | switch (*(option+1)) |
| 3765 | { |
| 3766 | case 'a': |
| 3767 | { |
| 3768 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3769 | { |
| 3770 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3771 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3772 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3773 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3774 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3775 | break; |
| 3776 | } |
| 3777 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3778 | { |
| 3779 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3780 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3781 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3782 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3783 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3784 | break; |
| 3785 | } |
| 3786 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3787 | { |
| 3788 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3789 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3790 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3791 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3792 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3793 | break; |
| 3794 | } |
| 3795 | if (LocaleCompare("affine",option+1) == 0) |
| 3796 | { |
| 3797 | if (*option == '+') |
| 3798 | break; |
| 3799 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3800 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3801 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3802 | break; |
| 3803 | } |
| 3804 | if (LocaleCompare("alpha",option+1) == 0) |
| 3805 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3806 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3807 | type; |
| 3808 | |
| 3809 | if (*option == '+') |
| 3810 | break; |
| 3811 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3812 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3813 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3814 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3815 | if (type < 0) |
| 3816 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3817 | argv[i]); |
| 3818 | break; |
| 3819 | } |
| 3820 | if (LocaleCompare("annotate",option+1) == 0) |
| 3821 | { |
| 3822 | if (*option == '+') |
| 3823 | break; |
| 3824 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3825 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3826 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3827 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3828 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3829 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3830 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3831 | i++; |
| 3832 | break; |
| 3833 | } |
| 3834 | if (LocaleCompare("antialias",option+1) == 0) |
| 3835 | break; |
| 3836 | if (LocaleCompare("append",option+1) == 0) |
| 3837 | break; |
| 3838 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3839 | { |
| 3840 | if (*option == '+') |
| 3841 | break; |
| 3842 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3843 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3844 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3845 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3846 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3847 | break; |
| 3848 | } |
| 3849 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3850 | { |
| 3851 | if (*option == '+') |
| 3852 | break; |
| 3853 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3854 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3855 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3856 | break; |
| 3857 | } |
| 3858 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3859 | break; |
| 3860 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3861 | break; |
| 3862 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3863 | break; |
| 3864 | if (LocaleCompare("average",option+1) == 0) |
| 3865 | break; |
| 3866 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3867 | } |
| 3868 | case 'b': |
| 3869 | { |
| 3870 | if (LocaleCompare("background",option+1) == 0) |
| 3871 | { |
| 3872 | if (*option == '+') |
| 3873 | break; |
| 3874 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3875 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3876 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3877 | break; |
| 3878 | } |
| 3879 | if (LocaleCompare("bias",option+1) == 0) |
| 3880 | { |
| 3881 | if (*option == '+') |
| 3882 | break; |
| 3883 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3884 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3885 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3886 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3887 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3888 | break; |
| 3889 | } |
| 3890 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 3891 | break; |
| 3892 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 3893 | { |
| 3894 | if (*option == '+') |
| 3895 | break; |
| 3896 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3897 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3898 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3899 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3900 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3901 | break; |
| 3902 | } |
| 3903 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3904 | { |
| 3905 | if (*option == '+') |
| 3906 | break; |
| 3907 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3908 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3909 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3910 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3911 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3912 | break; |
| 3913 | } |
| 3914 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3915 | { |
| 3916 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3917 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3918 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3919 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3920 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3921 | break; |
| 3922 | } |
| 3923 | if (LocaleCompare("blur",option+1) == 0) |
| 3924 | { |
| 3925 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3926 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3927 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3928 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3929 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3930 | break; |
| 3931 | } |
| 3932 | if (LocaleCompare("border",option+1) == 0) |
| 3933 | { |
| 3934 | if (*option == '+') |
| 3935 | break; |
| 3936 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3937 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3938 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3939 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3940 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3941 | break; |
| 3942 | } |
| 3943 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3944 | { |
| 3945 | if (*option == '+') |
| 3946 | break; |
| 3947 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3948 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3949 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3950 | break; |
| 3951 | } |
| 3952 | if (LocaleCompare("box",option+1) == 0) |
| 3953 | { |
| 3954 | if (*option == '+') |
| 3955 | break; |
| 3956 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3957 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3958 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3959 | break; |
| 3960 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3961 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 3962 | { |
| 3963 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3964 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3965 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3966 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3967 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3968 | break; |
| 3969 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3970 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3971 | } |
| 3972 | case 'c': |
| 3973 | { |
| 3974 | if (LocaleCompare("cache",option+1) == 0) |
| 3975 | { |
| 3976 | if (*option == '+') |
| 3977 | break; |
| 3978 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3979 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3980 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3981 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3982 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3983 | break; |
| 3984 | } |
| 3985 | if (LocaleCompare("caption",option+1) == 0) |
| 3986 | { |
| 3987 | if (*option == '+') |
| 3988 | break; |
| 3989 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3990 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3991 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3992 | break; |
| 3993 | } |
| 3994 | if (LocaleCompare("channel",option+1) == 0) |
| 3995 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3996 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3997 | channel; |
| 3998 | |
| 3999 | if (*option == '+') |
| 4000 | break; |
| 4001 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4002 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4003 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4004 | channel=ParseChannelOption(argv[i]); |
| 4005 | if (channel < 0) |
| 4006 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 4007 | argv[i]); |
| 4008 | break; |
| 4009 | } |
| 4010 | if (LocaleCompare("cdl",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-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4016 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4017 | break; |
| 4018 | } |
| 4019 | if (LocaleCompare("charcoal",option+1) == 0) |
| 4020 | { |
| 4021 | if (*option == '+') |
| 4022 | break; |
| 4023 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4024 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4025 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4026 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4027 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4028 | break; |
| 4029 | } |
| 4030 | if (LocaleCompare("chop",option+1) == 0) |
| 4031 | { |
| 4032 | if (*option == '+') |
| 4033 | break; |
| 4034 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4035 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4036 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4037 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4038 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4039 | break; |
| 4040 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4041 | if (LocaleCompare("clamp",option+1) == 0) |
| 4042 | break; |
| 4043 | if (LocaleCompare("clip",option+1) == 0) |
| 4044 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4045 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4046 | { |
| 4047 | if (*option == '+') |
| 4048 | break; |
| 4049 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4050 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4051 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4052 | break; |
| 4053 | } |
| 4054 | if (LocaleCompare("clut",option+1) == 0) |
| 4055 | break; |
| 4056 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4057 | break; |
| 4058 | if (LocaleCompare("colorize",option+1) == 0) |
| 4059 | { |
| 4060 | if (*option == '+') |
| 4061 | break; |
| 4062 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4063 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4064 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4065 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4066 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4067 | break; |
| 4068 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4069 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4070 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4071 | KernelInfo |
| 4072 | *kernel_info; |
| 4073 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4074 | if (*option == '+') |
| 4075 | break; |
| 4076 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4077 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4078 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4079 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4080 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4081 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4082 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4083 | break; |
| 4084 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4085 | if (LocaleCompare("colors",option+1) == 0) |
| 4086 | { |
| 4087 | if (*option == '+') |
| 4088 | break; |
| 4089 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4090 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4091 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4092 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4093 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4094 | break; |
| 4095 | } |
| 4096 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4097 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4098 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4099 | colorspace; |
| 4100 | |
| 4101 | if (*option == '+') |
| 4102 | break; |
| 4103 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4104 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4105 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4106 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4107 | argv[i]); |
| 4108 | if (colorspace < 0) |
| 4109 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4110 | argv[i]); |
| 4111 | break; |
| 4112 | } |
| 4113 | if (LocaleCompare("combine",option+1) == 0) |
| 4114 | break; |
| 4115 | if (LocaleCompare("comment",option+1) == 0) |
| 4116 | { |
| 4117 | if (*option == '+') |
| 4118 | break; |
| 4119 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4120 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4121 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4122 | break; |
| 4123 | } |
| 4124 | if (LocaleCompare("composite",option+1) == 0) |
| 4125 | break; |
| 4126 | if (LocaleCompare("compress",option+1) == 0) |
| 4127 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4128 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4129 | compress; |
| 4130 | |
| 4131 | if (*option == '+') |
| 4132 | break; |
| 4133 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4134 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4135 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4136 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4137 | argv[i]); |
| 4138 | if (compress < 0) |
| 4139 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4140 | argv[i]); |
| 4141 | break; |
| 4142 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4143 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4144 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4145 | if (LocaleCompare("contrast",option+1) == 0) |
| 4146 | break; |
| 4147 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4148 | { |
| 4149 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4150 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4151 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4152 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4153 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4154 | break; |
| 4155 | } |
| 4156 | if (LocaleCompare("convolve",option+1) == 0) |
| 4157 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4158 | KernelInfo |
| 4159 | *kernel_info; |
| 4160 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4161 | if (*option == '+') |
| 4162 | break; |
| 4163 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4164 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4165 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4166 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4167 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4168 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4169 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4170 | break; |
| 4171 | } |
| 4172 | if (LocaleCompare("crop",option+1) == 0) |
| 4173 | { |
| 4174 | if (*option == '+') |
| 4175 | break; |
| 4176 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4177 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4178 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4179 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4180 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4181 | break; |
| 4182 | } |
| 4183 | if (LocaleCompare("cycle",option+1) == 0) |
| 4184 | { |
| 4185 | if (*option == '+') |
| 4186 | break; |
| 4187 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4188 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4189 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4190 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4191 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4192 | break; |
| 4193 | } |
| 4194 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4195 | } |
| 4196 | case 'd': |
| 4197 | { |
| 4198 | if (LocaleCompare("decipher",option+1) == 0) |
| 4199 | { |
| 4200 | if (*option == '+') |
| 4201 | break; |
| 4202 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4203 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4204 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4205 | break; |
| 4206 | } |
| 4207 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4208 | break; |
| 4209 | if (LocaleCompare("debug",option+1) == 0) |
| 4210 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4211 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4212 | event; |
| 4213 | |
| 4214 | if (*option == '+') |
| 4215 | break; |
| 4216 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4217 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4218 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4219 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4220 | if (event < 0) |
| 4221 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4222 | argv[i]); |
| 4223 | (void) SetLogEventMask(argv[i]); |
| 4224 | break; |
| 4225 | } |
| 4226 | if (LocaleCompare("define",option+1) == 0) |
| 4227 | { |
| 4228 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4229 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4230 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4231 | if (*option == '+') |
| 4232 | { |
| 4233 | const char |
| 4234 | *define; |
| 4235 | |
| 4236 | define=GetImageOption(image_info,argv[i]); |
| 4237 | if (define == (const char *) NULL) |
| 4238 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4239 | break; |
| 4240 | } |
| 4241 | break; |
| 4242 | } |
| 4243 | if (LocaleCompare("delay",option+1) == 0) |
| 4244 | { |
| 4245 | if (*option == '+') |
| 4246 | break; |
| 4247 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4248 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4249 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4250 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4251 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4252 | break; |
| 4253 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4254 | if (LocaleCompare("delete",option+1) == 0) |
| 4255 | { |
| 4256 | if (*option == '+') |
| 4257 | break; |
| 4258 | i++; |
| 4259 | if (i == (ssize_t) (argc-1)) |
| 4260 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4261 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4262 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4263 | break; |
| 4264 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4265 | if (LocaleCompare("density",option+1) == 0) |
| 4266 | { |
| 4267 | if (*option == '+') |
| 4268 | break; |
| 4269 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4270 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4271 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4272 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4273 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4274 | break; |
| 4275 | } |
| 4276 | if (LocaleCompare("depth",option+1) == 0) |
| 4277 | { |
| 4278 | if (*option == '+') |
| 4279 | break; |
| 4280 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4281 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4282 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4283 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4284 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4285 | break; |
| 4286 | } |
| 4287 | if (LocaleCompare("deskew",option+1) == 0) |
| 4288 | { |
| 4289 | if (*option == '+') |
| 4290 | break; |
| 4291 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4292 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4293 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4294 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4295 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4296 | break; |
| 4297 | } |
| 4298 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4299 | break; |
| 4300 | if (LocaleCompare("dft",option+1) == 0) |
| 4301 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4302 | if (LocaleCompare("direction",option+1) == 0) |
| 4303 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4304 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4305 | direction; |
| 4306 | |
| 4307 | if (*option == '+') |
| 4308 | break; |
| 4309 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4310 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4311 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4312 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4313 | argv[i]); |
| 4314 | if (direction < 0) |
| 4315 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4316 | argv[i]); |
| 4317 | break; |
| 4318 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4319 | if (LocaleCompare("display",option+1) == 0) |
| 4320 | { |
| 4321 | if (*option == '+') |
| 4322 | break; |
| 4323 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4324 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4325 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4326 | break; |
| 4327 | } |
| 4328 | if (LocaleCompare("dispose",option+1) == 0) |
| 4329 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4330 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4331 | dispose; |
| 4332 | |
| 4333 | if (*option == '+') |
| 4334 | break; |
| 4335 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4336 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4337 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4338 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4339 | if (dispose < 0) |
| 4340 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4341 | argv[i]); |
| 4342 | break; |
| 4343 | } |
| 4344 | if (LocaleCompare("distort",option+1) == 0) |
| 4345 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4346 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4347 | op; |
| 4348 | |
| 4349 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4350 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4351 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4352 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4353 | if (op < 0) |
| 4354 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4355 | argv[i]); |
| 4356 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4357 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4358 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4359 | break; |
| 4360 | } |
| 4361 | if (LocaleCompare("dither",option+1) == 0) |
| 4362 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4363 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4364 | method; |
| 4365 | |
| 4366 | if (*option == '+') |
| 4367 | break; |
| 4368 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4369 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4370 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4371 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4372 | if (method < 0) |
| 4373 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4374 | argv[i]); |
| 4375 | break; |
| 4376 | } |
| 4377 | if (LocaleCompare("draw",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 | break; |
| 4385 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4386 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4387 | { |
| 4388 | if (*option == '+') |
| 4389 | break; |
| 4390 | i++; |
| 4391 | if (i == (ssize_t) (argc-1)) |
| 4392 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4393 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4394 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4395 | break; |
| 4396 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4397 | if (LocaleCompare("duration",option+1) == 0) |
| 4398 | { |
| 4399 | if (*option == '+') |
| 4400 | break; |
| 4401 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4402 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4403 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4404 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4405 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4406 | break; |
| 4407 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4408 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4409 | } |
| 4410 | case 'e': |
| 4411 | { |
| 4412 | if (LocaleCompare("edge",option+1) == 0) |
| 4413 | { |
| 4414 | if (*option == '+') |
| 4415 | break; |
| 4416 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4417 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4418 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4419 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4420 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4421 | break; |
| 4422 | } |
| 4423 | if (LocaleCompare("emboss",option+1) == 0) |
| 4424 | { |
| 4425 | if (*option == '+') |
| 4426 | break; |
| 4427 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4428 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4429 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4430 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4431 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4432 | break; |
| 4433 | } |
| 4434 | if (LocaleCompare("encipher",option+1) == 0) |
| 4435 | { |
| 4436 | if (*option == '+') |
| 4437 | break; |
| 4438 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4439 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4440 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4441 | break; |
| 4442 | } |
| 4443 | if (LocaleCompare("encoding",option+1) == 0) |
| 4444 | { |
| 4445 | if (*option == '+') |
| 4446 | break; |
| 4447 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4448 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4449 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4450 | break; |
| 4451 | } |
| 4452 | if (LocaleCompare("endian",option+1) == 0) |
| 4453 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4454 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4455 | endian; |
| 4456 | |
| 4457 | if (*option == '+') |
| 4458 | break; |
| 4459 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4460 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4461 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4462 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4463 | if (endian < 0) |
| 4464 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4465 | argv[i]); |
| 4466 | break; |
| 4467 | } |
| 4468 | if (LocaleCompare("enhance",option+1) == 0) |
| 4469 | break; |
| 4470 | if (LocaleCompare("equalize",option+1) == 0) |
| 4471 | break; |
| 4472 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4473 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4474 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4475 | op; |
| 4476 | |
| 4477 | if (*option == '+') |
| 4478 | break; |
| 4479 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4480 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4481 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4482 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4483 | if (op < 0) |
| 4484 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4485 | argv[i]); |
| 4486 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4487 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4488 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4489 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4490 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4491 | break; |
| 4492 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4493 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4494 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4495 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4496 | op; |
| 4497 | |
| 4498 | if (*option == '+') |
| 4499 | break; |
| 4500 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4501 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4502 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4503 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4504 | if (op < 0) |
| 4505 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4506 | argv[i]); |
| 4507 | break; |
| 4508 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4509 | if (LocaleCompare("extent",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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4517 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4518 | break; |
| 4519 | } |
| 4520 | if (LocaleCompare("extract",option+1) == 0) |
| 4521 | { |
| 4522 | if (*option == '+') |
| 4523 | break; |
| 4524 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4525 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4526 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4527 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4528 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4529 | break; |
| 4530 | } |
| 4531 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4532 | } |
| 4533 | case 'f': |
| 4534 | { |
| 4535 | if (LocaleCompare("family",option+1) == 0) |
| 4536 | { |
| 4537 | if (*option == '+') |
| 4538 | break; |
| 4539 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4540 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4541 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4542 | break; |
| 4543 | } |
| 4544 | if (LocaleCompare("fill",option+1) == 0) |
| 4545 | { |
| 4546 | if (*option == '+') |
| 4547 | break; |
| 4548 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4549 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4550 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4551 | break; |
| 4552 | } |
| 4553 | if (LocaleCompare("filter",option+1) == 0) |
| 4554 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4555 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4556 | filter; |
| 4557 | |
| 4558 | if (*option == '+') |
| 4559 | break; |
| 4560 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4561 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4562 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4563 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4564 | if (filter < 0) |
| 4565 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4566 | argv[i]); |
| 4567 | break; |
| 4568 | } |
| 4569 | if (LocaleCompare("flatten",option+1) == 0) |
| 4570 | break; |
| 4571 | if (LocaleCompare("flip",option+1) == 0) |
| 4572 | break; |
| 4573 | if (LocaleCompare("flop",option+1) == 0) |
| 4574 | break; |
| 4575 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4576 | { |
| 4577 | if (*option == '+') |
| 4578 | break; |
| 4579 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4580 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4581 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4582 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4583 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4584 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4585 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4586 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4587 | break; |
| 4588 | } |
| 4589 | if (LocaleCompare("font",option+1) == 0) |
| 4590 | { |
| 4591 | if (*option == '+') |
| 4592 | break; |
| 4593 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4594 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4595 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4596 | break; |
| 4597 | } |
| 4598 | if (LocaleCompare("format",option+1) == 0) |
| 4599 | { |
| 4600 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4601 | (void) CloneString(&format,(char *) NULL); |
| 4602 | if (*option == '+') |
| 4603 | break; |
| 4604 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4605 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4606 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4607 | (void) CloneString(&format,argv[i]); |
| 4608 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4609 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4610 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4611 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4612 | if (*image_info->magick == '\0') |
| 4613 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4614 | format); |
| 4615 | break; |
| 4616 | } |
| 4617 | if (LocaleCompare("frame",option+1) == 0) |
| 4618 | { |
| 4619 | if (*option == '+') |
| 4620 | break; |
| 4621 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4622 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4623 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4624 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4625 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4626 | break; |
| 4627 | } |
| 4628 | if (LocaleCompare("function",option+1) == 0) |
| 4629 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4630 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4631 | op; |
| 4632 | |
| 4633 | if (*option == '+') |
| 4634 | break; |
| 4635 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4636 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4637 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4638 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4639 | if (op < 0) |
| 4640 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4641 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4642 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4643 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4644 | break; |
| 4645 | } |
| 4646 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4647 | { |
| 4648 | if (*option == '+') |
| 4649 | break; |
| 4650 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4651 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4652 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4653 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4654 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4655 | break; |
| 4656 | } |
| 4657 | if (LocaleCompare("fx",option+1) == 0) |
| 4658 | { |
| 4659 | if (*option == '+') |
| 4660 | break; |
| 4661 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4662 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4663 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4664 | break; |
| 4665 | } |
| 4666 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4667 | } |
| 4668 | case 'g': |
| 4669 | { |
| 4670 | if (LocaleCompare("gamma",option+1) == 0) |
| 4671 | { |
| 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); |
| 4675 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4676 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4677 | break; |
| 4678 | } |
| 4679 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4680 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4681 | { |
| 4682 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4683 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4684 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4685 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4686 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4687 | break; |
| 4688 | } |
| 4689 | if (LocaleCompare("geometry",option+1) == 0) |
| 4690 | { |
| 4691 | if (*option == '+') |
| 4692 | break; |
| 4693 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4694 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4695 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4696 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4697 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4698 | break; |
| 4699 | } |
| 4700 | if (LocaleCompare("gravity",option+1) == 0) |
| 4701 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4702 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4703 | gravity; |
| 4704 | |
| 4705 | if (*option == '+') |
| 4706 | break; |
| 4707 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4708 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4709 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4710 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4711 | if (gravity < 0) |
| 4712 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4713 | argv[i]); |
| 4714 | break; |
| 4715 | } |
| 4716 | if (LocaleCompare("green-primary",option+1) == 0) |
| 4717 | { |
| 4718 | if (*option == '+') |
| 4719 | break; |
| 4720 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4721 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4722 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4723 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4724 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4725 | break; |
| 4726 | } |
| 4727 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4728 | } |
| 4729 | case 'h': |
| 4730 | { |
| 4731 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4732 | break; |
| 4733 | if ((LocaleCompare("help",option+1) == 0) || |
| 4734 | (LocaleCompare("-help",option+1) == 0)) |
| 4735 | return(MogrifyUsage()); |
| 4736 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4737 | } |
| 4738 | case 'i': |
| 4739 | { |
| 4740 | if (LocaleCompare("identify",option+1) == 0) |
| 4741 | break; |
| 4742 | if (LocaleCompare("idft",option+1) == 0) |
| 4743 | break; |
| 4744 | if (LocaleCompare("implode",option+1) == 0) |
| 4745 | { |
| 4746 | if (*option == '+') |
| 4747 | break; |
| 4748 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4749 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4750 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4751 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4752 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4753 | break; |
| 4754 | } |
| 4755 | if (LocaleCompare("intent",option+1) == 0) |
| 4756 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4757 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4758 | intent; |
| 4759 | |
| 4760 | if (*option == '+') |
| 4761 | break; |
| 4762 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4763 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4764 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4765 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4766 | if (intent < 0) |
| 4767 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4768 | argv[i]); |
| 4769 | break; |
| 4770 | } |
| 4771 | if (LocaleCompare("interlace",option+1) == 0) |
| 4772 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4773 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4774 | interlace; |
| 4775 | |
| 4776 | if (*option == '+') |
| 4777 | break; |
| 4778 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4779 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4780 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4781 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4782 | argv[i]); |
| 4783 | if (interlace < 0) |
| 4784 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4785 | argv[i]); |
| 4786 | break; |
| 4787 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4788 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4789 | { |
| 4790 | if (*option == '+') |
| 4791 | break; |
| 4792 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4793 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4794 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4795 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4796 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4797 | break; |
| 4798 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4799 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4800 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4801 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4802 | interpolate; |
| 4803 | |
| 4804 | if (*option == '+') |
| 4805 | break; |
| 4806 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4807 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4808 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4809 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4810 | argv[i]); |
| 4811 | if (interpolate < 0) |
| 4812 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4813 | argv[i]); |
| 4814 | break; |
| 4815 | } |
| 4816 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4817 | { |
| 4818 | if (*option == '+') |
| 4819 | break; |
| 4820 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4821 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4822 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4823 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4824 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4825 | break; |
| 4826 | } |
| 4827 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4828 | } |
| 4829 | case 'k': |
| 4830 | { |
| 4831 | if (LocaleCompare("kerning",option+1) == 0) |
| 4832 | { |
| 4833 | if (*option == '+') |
| 4834 | break; |
| 4835 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4836 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4837 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4838 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4839 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4840 | break; |
| 4841 | } |
| 4842 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4843 | } |
| 4844 | case 'l': |
| 4845 | { |
| 4846 | if (LocaleCompare("label",option+1) == 0) |
| 4847 | { |
| 4848 | if (*option == '+') |
| 4849 | break; |
| 4850 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4851 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4852 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4853 | break; |
| 4854 | } |
| 4855 | if (LocaleCompare("lat",option+1) == 0) |
| 4856 | { |
| 4857 | if (*option == '+') |
| 4858 | break; |
| 4859 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4860 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4861 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4862 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4863 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4864 | } |
| 4865 | if (LocaleCompare("layers",option+1) == 0) |
| 4866 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4867 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4868 | type; |
| 4869 | |
| 4870 | if (*option == '+') |
| 4871 | break; |
| 4872 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4873 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4874 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4875 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4876 | if (type < 0) |
| 4877 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4878 | argv[i]); |
| 4879 | break; |
| 4880 | } |
| 4881 | if (LocaleCompare("level",option+1) == 0) |
| 4882 | { |
| 4883 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4884 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4885 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4886 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4887 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4888 | break; |
| 4889 | } |
| 4890 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4891 | { |
| 4892 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4893 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4894 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4895 | break; |
| 4896 | } |
| 4897 | if (LocaleCompare("linewidth",option+1) == 0) |
| 4898 | { |
| 4899 | if (*option == '+') |
| 4900 | break; |
| 4901 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4902 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4903 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4904 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4905 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4906 | break; |
| 4907 | } |
| 4908 | if (LocaleCompare("limit",option+1) == 0) |
| 4909 | { |
| 4910 | char |
| 4911 | *p; |
| 4912 | |
| 4913 | double |
| 4914 | value; |
| 4915 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4916 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4917 | resource; |
| 4918 | |
| 4919 | if (*option == '+') |
| 4920 | break; |
| 4921 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4922 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4923 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4924 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4925 | argv[i]); |
| 4926 | if (resource < 0) |
| 4927 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4928 | argv[i]); |
| 4929 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4930 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4931 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 4932 | value=StringToDouble(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4933 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4934 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4935 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4936 | break; |
| 4937 | } |
| 4938 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4939 | { |
| 4940 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4941 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4942 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4943 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4944 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4945 | break; |
| 4946 | } |
| 4947 | if (LocaleCompare("list",option+1) == 0) |
| 4948 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4949 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4950 | list; |
| 4951 | |
| 4952 | if (*option == '+') |
| 4953 | break; |
| 4954 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4955 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4956 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4957 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4958 | if (list < 0) |
| 4959 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4960 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4961 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4962 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4963 | } |
| 4964 | if (LocaleCompare("log",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 | (strchr(argv[i],'%') == (char *) NULL)) |
| 4971 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4972 | break; |
| 4973 | } |
| 4974 | if (LocaleCompare("loop",option+1) == 0) |
| 4975 | { |
| 4976 | if (*option == '+') |
| 4977 | break; |
| 4978 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4979 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4980 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4981 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4982 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4983 | break; |
| 4984 | } |
| 4985 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4986 | } |
| 4987 | case 'm': |
| 4988 | { |
| 4989 | if (LocaleCompare("map",option+1) == 0) |
| 4990 | { |
| 4991 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 4992 | if (*option == '+') |
| 4993 | break; |
| 4994 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4995 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4996 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4997 | break; |
| 4998 | } |
| 4999 | if (LocaleCompare("mask",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 | break; |
| 5007 | } |
| 5008 | if (LocaleCompare("matte",option+1) == 0) |
| 5009 | break; |
| 5010 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 5011 | { |
| 5012 | if (*option == '+') |
| 5013 | break; |
| 5014 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5015 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5016 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5017 | break; |
| 5018 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5019 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5020 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5021 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5022 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5023 | if (LocaleCompare("modulate",option+1) == 0) |
| 5024 | { |
| 5025 | if (*option == '+') |
| 5026 | break; |
| 5027 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5028 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5029 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5030 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5031 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5032 | break; |
| 5033 | } |
| 5034 | if (LocaleCompare("median",option+1) == 0) |
| 5035 | { |
| 5036 | if (*option == '+') |
| 5037 | break; |
| 5038 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5039 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5040 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5041 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5042 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5043 | break; |
| 5044 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5045 | if (LocaleCompare("mode",option+1) == 0) |
| 5046 | { |
| 5047 | if (*option == '+') |
| 5048 | break; |
| 5049 | i++; |
| 5050 | if (i == (ssize_t) argc) |
| 5051 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5052 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5053 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5054 | break; |
| 5055 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5056 | if (LocaleCompare("monitor",option+1) == 0) |
| 5057 | break; |
| 5058 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5059 | break; |
| 5060 | if (LocaleCompare("morph",option+1) == 0) |
| 5061 | { |
| 5062 | if (*option == '+') |
| 5063 | break; |
| 5064 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5065 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5066 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5067 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5068 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5069 | break; |
| 5070 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5071 | if (LocaleCompare("morphology",option+1) == 0) |
| 5072 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5073 | char |
| 5074 | token[MaxTextExtent]; |
| 5075 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5076 | KernelInfo |
| 5077 | *kernel_info; |
| 5078 | |
| 5079 | ssize_t |
| 5080 | op; |
| 5081 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5082 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5083 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5084 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5085 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5086 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5087 | if (op < 0) |
| 5088 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5089 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5090 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5091 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5092 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5093 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5094 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5095 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5096 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5097 | break; |
| 5098 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5099 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5100 | break; |
| 5101 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5102 | { |
| 5103 | if (*option == '+') |
| 5104 | break; |
| 5105 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5106 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5107 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5108 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5109 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5110 | break; |
| 5111 | } |
| 5112 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5113 | } |
| 5114 | case 'n': |
| 5115 | { |
| 5116 | if (LocaleCompare("negate",option+1) == 0) |
| 5117 | break; |
| 5118 | if (LocaleCompare("noise",option+1) == 0) |
| 5119 | { |
| 5120 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5121 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5122 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5123 | if (*option == '+') |
| 5124 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5125 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5126 | noise; |
| 5127 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5128 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5129 | if (noise < 0) |
| 5130 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5131 | argv[i]); |
| 5132 | break; |
| 5133 | } |
| 5134 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5135 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5136 | break; |
| 5137 | } |
| 5138 | if (LocaleCompare("noop",option+1) == 0) |
| 5139 | break; |
| 5140 | if (LocaleCompare("normalize",option+1) == 0) |
| 5141 | break; |
| 5142 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5143 | } |
| 5144 | case 'o': |
| 5145 | { |
| 5146 | if (LocaleCompare("opaque",option+1) == 0) |
| 5147 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5148 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5149 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5150 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5151 | break; |
| 5152 | } |
| 5153 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5154 | { |
| 5155 | if (*option == '+') |
| 5156 | break; |
| 5157 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5158 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5159 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5160 | break; |
| 5161 | } |
| 5162 | if (LocaleCompare("orient",option+1) == 0) |
| 5163 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5164 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5165 | orientation; |
| 5166 | |
| 5167 | orientation=UndefinedOrientation; |
| 5168 | if (*option == '+') |
| 5169 | break; |
| 5170 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5171 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5172 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5173 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5174 | argv[i]); |
| 5175 | if (orientation < 0) |
| 5176 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5177 | argv[i]); |
| 5178 | break; |
| 5179 | } |
| 5180 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5181 | } |
| 5182 | case 'p': |
| 5183 | { |
| 5184 | if (LocaleCompare("page",option+1) == 0) |
| 5185 | { |
| 5186 | if (*option == '+') |
| 5187 | break; |
| 5188 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5189 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5190 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5191 | break; |
| 5192 | } |
| 5193 | if (LocaleCompare("paint",option+1) == 0) |
| 5194 | { |
| 5195 | if (*option == '+') |
| 5196 | break; |
| 5197 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5198 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5199 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5200 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5201 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5202 | break; |
| 5203 | } |
| 5204 | if (LocaleCompare("path",option+1) == 0) |
| 5205 | { |
| 5206 | (void) CloneString(&path,(char *) NULL); |
| 5207 | if (*option == '+') |
| 5208 | break; |
| 5209 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5210 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5211 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5212 | (void) CloneString(&path,argv[i]); |
| 5213 | break; |
| 5214 | } |
| 5215 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5216 | { |
| 5217 | if (*option == '+') |
| 5218 | break; |
| 5219 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5220 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5221 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5222 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5223 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5224 | break; |
| 5225 | } |
| 5226 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5227 | { |
| 5228 | if (*option == '+') |
| 5229 | break; |
| 5230 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5231 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5232 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5233 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5234 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5235 | break; |
| 5236 | } |
| 5237 | if (LocaleCompare("posterize",option+1) == 0) |
| 5238 | { |
| 5239 | if (*option == '+') |
| 5240 | break; |
| 5241 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5242 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5243 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5244 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5245 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5246 | break; |
| 5247 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5248 | if (LocaleCompare("precision",option+1) == 0) |
| 5249 | { |
| 5250 | if (*option == '+') |
| 5251 | break; |
| 5252 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5253 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5254 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5255 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5256 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5257 | break; |
| 5258 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5259 | if (LocaleCompare("print",option+1) == 0) |
| 5260 | { |
| 5261 | if (*option == '+') |
| 5262 | break; |
| 5263 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5264 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5265 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5266 | break; |
| 5267 | } |
| 5268 | if (LocaleCompare("process",option+1) == 0) |
| 5269 | { |
| 5270 | if (*option == '+') |
| 5271 | break; |
| 5272 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5273 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5274 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5275 | break; |
| 5276 | } |
| 5277 | if (LocaleCompare("profile",option+1) == 0) |
| 5278 | { |
| 5279 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5280 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5281 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5282 | break; |
| 5283 | } |
| 5284 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5285 | } |
| 5286 | case 'q': |
| 5287 | { |
| 5288 | if (LocaleCompare("quality",option+1) == 0) |
| 5289 | { |
| 5290 | if (*option == '+') |
| 5291 | break; |
| 5292 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5293 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5294 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5295 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5296 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5297 | break; |
| 5298 | } |
| 5299 | if (LocaleCompare("quantize",option+1) == 0) |
| 5300 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5301 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5302 | colorspace; |
| 5303 | |
| 5304 | if (*option == '+') |
| 5305 | break; |
| 5306 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5307 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5308 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5309 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5310 | argv[i]); |
| 5311 | if (colorspace < 0) |
| 5312 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5313 | argv[i]); |
| 5314 | break; |
| 5315 | } |
| 5316 | if (LocaleCompare("quiet",option+1) == 0) |
| 5317 | break; |
| 5318 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5319 | } |
| 5320 | case 'r': |
| 5321 | { |
| 5322 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5323 | { |
| 5324 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5325 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5326 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5327 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5328 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5329 | break; |
| 5330 | } |
| 5331 | if (LocaleCompare("raise",option+1) == 0) |
| 5332 | { |
| 5333 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5334 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5335 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5336 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5337 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5338 | break; |
| 5339 | } |
| 5340 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5341 | { |
| 5342 | if (*option == '+') |
| 5343 | break; |
| 5344 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5345 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5346 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5347 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5348 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5349 | break; |
| 5350 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5351 | if (LocaleCompare("recolor",option+1) == 0) |
| 5352 | { |
| 5353 | if (*option == '+') |
| 5354 | break; |
| 5355 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5356 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5357 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5358 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5359 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5360 | break; |
| 5361 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5362 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5363 | { |
| 5364 | if (*option == '+') |
| 5365 | break; |
| 5366 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5367 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5368 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5369 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5370 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5371 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5372 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5373 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5374 | if (LocaleCompare("region",option+1) == 0) |
| 5375 | { |
| 5376 | if (*option == '+') |
| 5377 | break; |
| 5378 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5379 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5380 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5381 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5382 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5383 | break; |
| 5384 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5385 | if (LocaleCompare("remap",option+1) == 0) |
| 5386 | { |
| 5387 | if (*option == '+') |
| 5388 | break; |
| 5389 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5390 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5391 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5392 | break; |
| 5393 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5394 | if (LocaleCompare("render",option+1) == 0) |
| 5395 | break; |
| 5396 | if (LocaleCompare("repage",option+1) == 0) |
| 5397 | { |
| 5398 | if (*option == '+') |
| 5399 | break; |
| 5400 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5401 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5402 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5403 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5404 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5405 | break; |
| 5406 | } |
| 5407 | if (LocaleCompare("resample",option+1) == 0) |
| 5408 | { |
| 5409 | if (*option == '+') |
| 5410 | break; |
| 5411 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5412 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5413 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5414 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5415 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5416 | break; |
| 5417 | } |
| 5418 | if (LocaleCompare("resize",option+1) == 0) |
| 5419 | { |
| 5420 | if (*option == '+') |
| 5421 | break; |
| 5422 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5423 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5424 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5425 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5426 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5427 | break; |
| 5428 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5429 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5430 | { |
| 5431 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5432 | break; |
| 5433 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5434 | if (LocaleCompare("reverse",option+1) == 0) |
| 5435 | break; |
| 5436 | if (LocaleCompare("roll",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("rotate",option+1) == 0) |
| 5448 | { |
| 5449 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5450 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5451 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5452 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5453 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5454 | break; |
| 5455 | } |
| 5456 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5457 | } |
| 5458 | case 's': |
| 5459 | { |
| 5460 | if (LocaleCompare("sample",option+1) == 0) |
| 5461 | { |
| 5462 | if (*option == '+') |
| 5463 | break; |
| 5464 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5465 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5466 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5467 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5468 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5469 | break; |
| 5470 | } |
| 5471 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5472 | { |
| 5473 | if (*option == '+') |
| 5474 | break; |
| 5475 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5476 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5477 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5478 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5479 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5480 | break; |
| 5481 | } |
| 5482 | if (LocaleCompare("scale",option+1) == 0) |
| 5483 | { |
| 5484 | if (*option == '+') |
| 5485 | break; |
| 5486 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5487 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5488 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5489 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5490 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5491 | break; |
| 5492 | } |
| 5493 | if (LocaleCompare("scene",option+1) == 0) |
| 5494 | { |
| 5495 | if (*option == '+') |
| 5496 | break; |
| 5497 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5498 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5499 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5500 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5501 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5502 | break; |
| 5503 | } |
| 5504 | if (LocaleCompare("seed",option+1) == 0) |
| 5505 | { |
| 5506 | if (*option == '+') |
| 5507 | break; |
| 5508 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5509 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5510 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5511 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5512 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5513 | break; |
| 5514 | } |
| 5515 | if (LocaleCompare("segment",option+1) == 0) |
| 5516 | { |
| 5517 | if (*option == '+') |
| 5518 | break; |
| 5519 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5520 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5521 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5522 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5523 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5524 | break; |
| 5525 | } |
| 5526 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5527 | { |
| 5528 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5529 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5530 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5531 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5532 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5533 | break; |
| 5534 | } |
| 5535 | if (LocaleCompare("separate",option+1) == 0) |
| 5536 | break; |
| 5537 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5538 | { |
| 5539 | if (*option == '+') |
| 5540 | break; |
| 5541 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5542 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5543 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5544 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5545 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5546 | break; |
| 5547 | } |
| 5548 | if (LocaleCompare("set",option+1) == 0) |
| 5549 | { |
| 5550 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5551 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5552 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5553 | if (*option == '+') |
| 5554 | break; |
| 5555 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5556 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5557 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5558 | break; |
| 5559 | } |
| 5560 | if (LocaleCompare("shade",option+1) == 0) |
| 5561 | { |
| 5562 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5563 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5564 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5565 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5566 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5567 | break; |
| 5568 | } |
| 5569 | if (LocaleCompare("shadow",option+1) == 0) |
| 5570 | { |
| 5571 | if (*option == '+') |
| 5572 | break; |
| 5573 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5574 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5575 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5576 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5577 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5578 | break; |
| 5579 | } |
| 5580 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5581 | { |
| 5582 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5583 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5584 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5585 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5586 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5587 | break; |
| 5588 | } |
| 5589 | if (LocaleCompare("shave",option+1) == 0) |
| 5590 | { |
| 5591 | if (*option == '+') |
| 5592 | break; |
| 5593 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5594 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5595 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5596 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5597 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5598 | break; |
| 5599 | } |
| 5600 | if (LocaleCompare("shear",option+1) == 0) |
| 5601 | { |
| 5602 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5603 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5604 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5605 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5606 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5607 | break; |
| 5608 | } |
| 5609 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5610 | { |
| 5611 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5612 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5613 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5614 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5615 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5616 | break; |
| 5617 | } |
| 5618 | if (LocaleCompare("size",option+1) == 0) |
| 5619 | { |
| 5620 | if (*option == '+') |
| 5621 | break; |
| 5622 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5623 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5624 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5625 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5626 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5627 | break; |
| 5628 | } |
| 5629 | if (LocaleCompare("sketch",option+1) == 0) |
| 5630 | { |
| 5631 | if (*option == '+') |
| 5632 | break; |
| 5633 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5634 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5635 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5636 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5637 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5638 | break; |
| 5639 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5640 | if (LocaleCompare("smush",option+1) == 0) |
| 5641 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5642 | i++; |
| 5643 | if (i == (ssize_t) argc) |
| 5644 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5645 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5646 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5647 | i++; |
| 5648 | break; |
| 5649 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5650 | if (LocaleCompare("solarize",option+1) == 0) |
| 5651 | { |
| 5652 | if (*option == '+') |
| 5653 | break; |
| 5654 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5655 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5656 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5657 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5658 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5659 | break; |
| 5660 | } |
| 5661 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5662 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5663 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5664 | op; |
| 5665 | |
| 5666 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5667 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5668 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5669 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5670 | if (op < 0) |
| 5671 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5672 | argv[i]); |
| 5673 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5674 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5675 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5676 | break; |
| 5677 | } |
| 5678 | if (LocaleCompare("spread",option+1) == 0) |
| 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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5684 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5685 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5686 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5687 | break; |
| 5688 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5689 | if (LocaleCompare("statistic",option+1) == 0) |
| 5690 | { |
| 5691 | ssize_t |
| 5692 | op; |
| 5693 | |
| 5694 | if (*option == '+') |
| 5695 | break; |
| 5696 | i++; |
| 5697 | if (i == (ssize_t) argc) |
| 5698 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5699 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5700 | if (op < 0) |
| 5701 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5702 | argv[i]); |
| 5703 | i++; |
| 5704 | if (i == (ssize_t) (argc-1)) |
| 5705 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5706 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5707 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5708 | break; |
| 5709 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5710 | if (LocaleCompare("stretch",option+1) == 0) |
| 5711 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5712 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5713 | stretch; |
| 5714 | |
| 5715 | if (*option == '+') |
| 5716 | break; |
| 5717 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5718 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5719 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5720 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5721 | if (stretch < 0) |
| 5722 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5723 | argv[i]); |
| 5724 | break; |
| 5725 | } |
| 5726 | if (LocaleCompare("strip",option+1) == 0) |
| 5727 | break; |
| 5728 | if (LocaleCompare("stroke",option+1) == 0) |
| 5729 | { |
| 5730 | if (*option == '+') |
| 5731 | break; |
| 5732 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5733 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5734 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5735 | break; |
| 5736 | } |
| 5737 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5738 | { |
| 5739 | if (*option == '+') |
| 5740 | break; |
| 5741 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5742 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5743 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5744 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5745 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5746 | break; |
| 5747 | } |
| 5748 | if (LocaleCompare("style",option+1) == 0) |
| 5749 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5750 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5751 | style; |
| 5752 | |
| 5753 | if (*option == '+') |
| 5754 | break; |
| 5755 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5756 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5757 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5758 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5759 | if (style < 0) |
| 5760 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5761 | argv[i]); |
| 5762 | break; |
| 5763 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5764 | if (LocaleCompare("swap",option+1) == 0) |
| 5765 | { |
| 5766 | if (*option == '+') |
| 5767 | break; |
| 5768 | i++; |
| 5769 | if (i == (ssize_t) (argc-1)) |
| 5770 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5771 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5772 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5773 | break; |
| 5774 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5775 | if (LocaleCompare("swirl",option+1) == 0) |
| 5776 | { |
| 5777 | if (*option == '+') |
| 5778 | break; |
| 5779 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5780 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5781 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5782 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5783 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5784 | break; |
| 5785 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5786 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5787 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5788 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5789 | } |
| 5790 | case 't': |
| 5791 | { |
| 5792 | if (LocaleCompare("taint",option+1) == 0) |
| 5793 | break; |
| 5794 | if (LocaleCompare("texture",option+1) == 0) |
| 5795 | { |
| 5796 | if (*option == '+') |
| 5797 | break; |
| 5798 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5799 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5800 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5801 | break; |
| 5802 | } |
| 5803 | if (LocaleCompare("tile",option+1) == 0) |
| 5804 | { |
| 5805 | if (*option == '+') |
| 5806 | break; |
| 5807 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5808 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5809 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5810 | break; |
| 5811 | } |
| 5812 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5813 | { |
| 5814 | if (*option == '+') |
| 5815 | break; |
| 5816 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5817 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5818 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5819 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5820 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5821 | break; |
| 5822 | } |
| 5823 | if (LocaleCompare("tint",option+1) == 0) |
| 5824 | { |
| 5825 | if (*option == '+') |
| 5826 | break; |
| 5827 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5828 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5829 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5830 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5831 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5832 | break; |
| 5833 | } |
| 5834 | if (LocaleCompare("transform",option+1) == 0) |
| 5835 | break; |
| 5836 | if (LocaleCompare("transpose",option+1) == 0) |
| 5837 | break; |
| 5838 | if (LocaleCompare("transverse",option+1) == 0) |
| 5839 | break; |
| 5840 | if (LocaleCompare("threshold",option+1) == 0) |
| 5841 | { |
| 5842 | if (*option == '+') |
| 5843 | break; |
| 5844 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5845 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5846 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5847 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5848 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5849 | break; |
| 5850 | } |
| 5851 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5852 | { |
| 5853 | if (*option == '+') |
| 5854 | break; |
| 5855 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5856 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5857 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5858 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5859 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5860 | break; |
| 5861 | } |
| 5862 | if (LocaleCompare("transparent",option+1) == 0) |
| 5863 | { |
| 5864 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5865 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5866 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5867 | break; |
| 5868 | } |
| 5869 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 5870 | { |
| 5871 | if (*option == '+') |
| 5872 | break; |
| 5873 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5874 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5875 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5876 | break; |
| 5877 | } |
| 5878 | if (LocaleCompare("treedepth",option+1) == 0) |
| 5879 | { |
| 5880 | if (*option == '+') |
| 5881 | break; |
| 5882 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5883 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5884 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5885 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5886 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5887 | break; |
| 5888 | } |
| 5889 | if (LocaleCompare("trim",option+1) == 0) |
| 5890 | break; |
| 5891 | if (LocaleCompare("type",option+1) == 0) |
| 5892 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5893 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5894 | type; |
| 5895 | |
| 5896 | if (*option == '+') |
| 5897 | break; |
| 5898 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5899 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5900 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5901 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5902 | if (type < 0) |
| 5903 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5904 | argv[i]); |
| 5905 | break; |
| 5906 | } |
| 5907 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5908 | } |
| 5909 | case 'u': |
| 5910 | { |
| 5911 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5912 | { |
| 5913 | if (*option == '+') |
| 5914 | break; |
| 5915 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5916 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5917 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5918 | break; |
| 5919 | } |
| 5920 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5921 | break; |
| 5922 | if (LocaleCompare("units",option+1) == 0) |
| 5923 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5924 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5925 | units; |
| 5926 | |
| 5927 | if (*option == '+') |
| 5928 | break; |
| 5929 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5930 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5931 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5932 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5933 | argv[i]); |
| 5934 | if (units < 0) |
| 5935 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5936 | argv[i]); |
| 5937 | break; |
| 5938 | } |
| 5939 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5940 | { |
| 5941 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5942 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5943 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5944 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5945 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5946 | break; |
| 5947 | } |
| 5948 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5949 | } |
| 5950 | case 'v': |
| 5951 | { |
| 5952 | if (LocaleCompare("verbose",option+1) == 0) |
| 5953 | { |
| 5954 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 5955 | break; |
| 5956 | } |
| 5957 | if ((LocaleCompare("version",option+1) == 0) || |
| 5958 | (LocaleCompare("-version",option+1) == 0)) |
| 5959 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 5960 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5961 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 5962 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 5963 | GetMagickCopyright()); |
| 5964 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 5965 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5966 | break; |
| 5967 | } |
| 5968 | if (LocaleCompare("view",option+1) == 0) |
| 5969 | { |
| 5970 | if (*option == '+') |
| 5971 | break; |
| 5972 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5973 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5974 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5975 | break; |
| 5976 | } |
| 5977 | if (LocaleCompare("vignette",option+1) == 0) |
| 5978 | { |
| 5979 | if (*option == '+') |
| 5980 | break; |
| 5981 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5982 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5983 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5984 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5985 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5986 | break; |
| 5987 | } |
| 5988 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 5989 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5990 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5991 | method; |
| 5992 | |
| 5993 | if (*option == '+') |
| 5994 | break; |
| 5995 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5996 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5997 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5998 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5999 | argv[i]); |
| 6000 | if (method < 0) |
| 6001 | ThrowMogrifyException(OptionError, |
| 6002 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 6003 | break; |
| 6004 | } |
| 6005 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6006 | } |
| 6007 | case 'w': |
| 6008 | { |
| 6009 | if (LocaleCompare("wave",option+1) == 0) |
| 6010 | { |
| 6011 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6012 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6013 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6014 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6015 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6016 | break; |
| 6017 | } |
| 6018 | if (LocaleCompare("weight",option+1) == 0) |
| 6019 | { |
| 6020 | if (*option == '+') |
| 6021 | break; |
| 6022 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6023 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6024 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6025 | break; |
| 6026 | } |
| 6027 | if (LocaleCompare("white-point",option+1) == 0) |
| 6028 | { |
| 6029 | if (*option == '+') |
| 6030 | break; |
| 6031 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6032 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6033 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6034 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6035 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6036 | break; |
| 6037 | } |
| 6038 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6039 | { |
| 6040 | if (*option == '+') |
| 6041 | break; |
| 6042 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6043 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6044 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6045 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6046 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6047 | break; |
| 6048 | } |
| 6049 | if (LocaleCompare("write",option+1) == 0) |
| 6050 | { |
| 6051 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6052 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6053 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6054 | break; |
| 6055 | } |
| 6056 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6057 | } |
| 6058 | case '?': |
| 6059 | break; |
| 6060 | default: |
| 6061 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6062 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6063 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 6064 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6065 | if (fire != MagickFalse) |
| 6066 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6067 | } |
| 6068 | if (k != 0) |
| 6069 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6070 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6071 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6072 | DestroyMogrify(); |
| 6073 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6074 | } |
| 6075 | |
| 6076 | /* |
| 6077 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6078 | % % |
| 6079 | % % |
| 6080 | % % |
| 6081 | + M o g r i f y I m a g e I n f o % |
| 6082 | % % |
| 6083 | % % |
| 6084 | % % |
| 6085 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6086 | % |
| 6087 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6088 | % prescribed by command line options. |
| 6089 | % |
| 6090 | % The format of the MogrifyImageInfo method is: |
| 6091 | % |
| 6092 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6093 | % const char **argv,ExceptionInfo *exception) |
| 6094 | % |
| 6095 | % A description of each parameter follows: |
| 6096 | % |
| 6097 | % o image_info: the image info.. |
| 6098 | % |
| 6099 | % o argc: Specifies a pointer to an integer describing the number of |
| 6100 | % elements in the argument vector. |
| 6101 | % |
| 6102 | % o argv: Specifies a pointer to a text array containing the command line |
| 6103 | % arguments. |
| 6104 | % |
| 6105 | % o exception: return any errors or warnings in this structure. |
| 6106 | % |
| 6107 | */ |
| 6108 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6109 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6110 | { |
| 6111 | const char |
| 6112 | *option; |
| 6113 | |
| 6114 | GeometryInfo |
| 6115 | geometry_info; |
| 6116 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6117 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6118 | count; |
| 6119 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6120 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6121 | i; |
| 6122 | |
| 6123 | /* |
| 6124 | Initialize method variables. |
| 6125 | */ |
| 6126 | assert(image_info != (ImageInfo *) NULL); |
| 6127 | assert(image_info->signature == MagickSignature); |
| 6128 | if (image_info->debug != MagickFalse) |
| 6129 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6130 | image_info->filename); |
| 6131 | if (argc < 0) |
| 6132 | return(MagickTrue); |
| 6133 | /* |
| 6134 | Set the image settings. |
| 6135 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6136 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6137 | { |
| 6138 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6139 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6140 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6141 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6142 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6143 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6144 | break; |
| 6145 | switch (*(option+1)) |
| 6146 | { |
| 6147 | case 'a': |
| 6148 | { |
| 6149 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6150 | { |
| 6151 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6152 | break; |
| 6153 | } |
| 6154 | if (LocaleCompare("antialias",option+1) == 0) |
| 6155 | { |
| 6156 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6157 | break; |
| 6158 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6159 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6160 | { |
| 6161 | if (*option == '+') |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 6162 | (void) DeleteImageOption(image_info,option+1); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6163 | else |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 6164 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6165 | break; |
| 6166 | } |
| 6167 | break; |
| 6168 | } |
| 6169 | case 'b': |
| 6170 | { |
| 6171 | if (LocaleCompare("background",option+1) == 0) |
| 6172 | { |
| 6173 | if (*option == '+') |
| 6174 | { |
| 6175 | (void) DeleteImageOption(image_info,option+1); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6176 | (void) QueryColorCompliance(MogrifyBackgroundColor, |
| 6177 | AllCompliance,&image_info->background_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6178 | break; |
| 6179 | } |
| 6180 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6181 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6182 | &image_info->background_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6183 | break; |
| 6184 | } |
| 6185 | if (LocaleCompare("bias",option+1) == 0) |
| 6186 | { |
| 6187 | if (*option == '+') |
| 6188 | { |
| 6189 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6190 | break; |
| 6191 | } |
| 6192 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6193 | break; |
| 6194 | } |
| 6195 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6196 | { |
| 6197 | if (*option == '+') |
| 6198 | { |
| 6199 | (void) SetImageOption(image_info,option+1,"false"); |
| 6200 | break; |
| 6201 | } |
| 6202 | (void) SetImageOption(image_info,option+1,"true"); |
| 6203 | break; |
| 6204 | } |
| 6205 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6206 | { |
| 6207 | if (*option == '+') |
| 6208 | { |
| 6209 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6210 | break; |
| 6211 | } |
| 6212 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6213 | break; |
| 6214 | } |
| 6215 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6216 | { |
| 6217 | if (*option == '+') |
| 6218 | { |
| 6219 | (void) DeleteImageOption(image_info,option+1); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6220 | (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6221 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6222 | break; |
| 6223 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6224 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6225 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6226 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6227 | break; |
| 6228 | } |
| 6229 | if (LocaleCompare("box",option+1) == 0) |
| 6230 | { |
| 6231 | if (*option == '+') |
| 6232 | { |
| 6233 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6234 | break; |
| 6235 | } |
| 6236 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6237 | break; |
| 6238 | } |
| 6239 | break; |
| 6240 | } |
| 6241 | case 'c': |
| 6242 | { |
| 6243 | if (LocaleCompare("cache",option+1) == 0) |
| 6244 | { |
| 6245 | MagickSizeType |
| 6246 | limit; |
| 6247 | |
| 6248 | limit=MagickResourceInfinity; |
| 6249 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 6250 | limit=(MagickSizeType) StringToDoubleInterval(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6251 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6252 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6253 | break; |
| 6254 | } |
| 6255 | if (LocaleCompare("caption",option+1) == 0) |
| 6256 | { |
| 6257 | if (*option == '+') |
| 6258 | { |
| 6259 | (void) DeleteImageOption(image_info,option+1); |
| 6260 | break; |
| 6261 | } |
| 6262 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6263 | break; |
| 6264 | } |
| 6265 | if (LocaleCompare("channel",option+1) == 0) |
| 6266 | { |
| 6267 | if (*option == '+') |
| 6268 | { |
| 6269 | image_info->channel=DefaultChannels; |
| 6270 | break; |
| 6271 | } |
| 6272 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6273 | break; |
| 6274 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6275 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6276 | { |
| 6277 | if (*option == '+') |
| 6278 | { |
| 6279 | image_info->colorspace=UndefinedColorspace; |
| 6280 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6281 | break; |
| 6282 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6283 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6284 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6285 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6286 | break; |
| 6287 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6288 | if (LocaleCompare("comment",option+1) == 0) |
| 6289 | { |
| 6290 | if (*option == '+') |
| 6291 | { |
| 6292 | (void) DeleteImageOption(image_info,option+1); |
| 6293 | break; |
| 6294 | } |
| 6295 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6296 | break; |
| 6297 | } |
| 6298 | if (LocaleCompare("compose",option+1) == 0) |
| 6299 | { |
| 6300 | if (*option == '+') |
| 6301 | { |
| 6302 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6303 | break; |
| 6304 | } |
| 6305 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6306 | break; |
| 6307 | } |
| 6308 | if (LocaleCompare("compress",option+1) == 0) |
| 6309 | { |
| 6310 | if (*option == '+') |
| 6311 | { |
| 6312 | image_info->compression=UndefinedCompression; |
| 6313 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6314 | break; |
| 6315 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6316 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6317 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6318 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6319 | break; |
| 6320 | } |
| 6321 | break; |
| 6322 | } |
| 6323 | case 'd': |
| 6324 | { |
| 6325 | if (LocaleCompare("debug",option+1) == 0) |
| 6326 | { |
| 6327 | if (*option == '+') |
| 6328 | (void) SetLogEventMask("none"); |
| 6329 | else |
| 6330 | (void) SetLogEventMask(argv[i+1]); |
| 6331 | image_info->debug=IsEventLogging(); |
| 6332 | break; |
| 6333 | } |
| 6334 | if (LocaleCompare("define",option+1) == 0) |
| 6335 | { |
| 6336 | if (*option == '+') |
| 6337 | { |
| 6338 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6339 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6340 | else |
| 6341 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6342 | break; |
| 6343 | } |
| 6344 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6345 | { |
| 6346 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6347 | exception); |
| 6348 | break; |
| 6349 | } |
| 6350 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6351 | break; |
| 6352 | } |
| 6353 | if (LocaleCompare("delay",option+1) == 0) |
| 6354 | { |
| 6355 | if (*option == '+') |
| 6356 | { |
| 6357 | (void) SetImageOption(image_info,option+1,"0"); |
| 6358 | break; |
| 6359 | } |
| 6360 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6361 | break; |
| 6362 | } |
| 6363 | if (LocaleCompare("density",option+1) == 0) |
| 6364 | { |
| 6365 | /* |
| 6366 | Set image density. |
| 6367 | */ |
| 6368 | if (*option == '+') |
| 6369 | { |
| 6370 | if (image_info->density != (char *) NULL) |
| 6371 | image_info->density=DestroyString(image_info->density); |
| 6372 | (void) SetImageOption(image_info,option+1,"72"); |
| 6373 | break; |
| 6374 | } |
| 6375 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6376 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6377 | break; |
| 6378 | } |
| 6379 | if (LocaleCompare("depth",option+1) == 0) |
| 6380 | { |
| 6381 | if (*option == '+') |
| 6382 | { |
| 6383 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6384 | break; |
| 6385 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6386 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6387 | break; |
| 6388 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6389 | if (LocaleCompare("direction",option+1) == 0) |
| 6390 | { |
| 6391 | if (*option == '+') |
| 6392 | { |
| 6393 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6394 | break; |
| 6395 | } |
| 6396 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6397 | break; |
| 6398 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6399 | if (LocaleCompare("display",option+1) == 0) |
| 6400 | { |
| 6401 | if (*option == '+') |
| 6402 | { |
| 6403 | if (image_info->server_name != (char *) NULL) |
| 6404 | image_info->server_name=DestroyString( |
| 6405 | image_info->server_name); |
| 6406 | break; |
| 6407 | } |
| 6408 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6409 | break; |
| 6410 | } |
| 6411 | if (LocaleCompare("dispose",option+1) == 0) |
| 6412 | { |
| 6413 | if (*option == '+') |
| 6414 | { |
| 6415 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6416 | break; |
| 6417 | } |
| 6418 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6419 | break; |
| 6420 | } |
| 6421 | if (LocaleCompare("dither",option+1) == 0) |
| 6422 | { |
| 6423 | if (*option == '+') |
| 6424 | { |
| 6425 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6426 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6427 | break; |
| 6428 | } |
| 6429 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6430 | image_info->dither=MagickTrue; |
| 6431 | break; |
| 6432 | } |
| 6433 | break; |
| 6434 | } |
| 6435 | case 'e': |
| 6436 | { |
| 6437 | if (LocaleCompare("encoding",option+1) == 0) |
| 6438 | { |
| 6439 | if (*option == '+') |
| 6440 | { |
| 6441 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6442 | break; |
| 6443 | } |
| 6444 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6445 | break; |
| 6446 | } |
| 6447 | if (LocaleCompare("endian",option+1) == 0) |
| 6448 | { |
| 6449 | if (*option == '+') |
| 6450 | { |
| 6451 | image_info->endian=UndefinedEndian; |
| 6452 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6453 | break; |
| 6454 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6455 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6456 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6457 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6458 | break; |
| 6459 | } |
| 6460 | if (LocaleCompare("extract",option+1) == 0) |
| 6461 | { |
| 6462 | /* |
| 6463 | Set image extract geometry. |
| 6464 | */ |
| 6465 | if (*option == '+') |
| 6466 | { |
| 6467 | if (image_info->extract != (char *) NULL) |
| 6468 | image_info->extract=DestroyString(image_info->extract); |
| 6469 | break; |
| 6470 | } |
| 6471 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6472 | break; |
| 6473 | } |
| 6474 | break; |
| 6475 | } |
| 6476 | case 'f': |
| 6477 | { |
| 6478 | if (LocaleCompare("fill",option+1) == 0) |
| 6479 | { |
| 6480 | if (*option == '+') |
| 6481 | { |
| 6482 | (void) SetImageOption(image_info,option+1,"none"); |
| 6483 | break; |
| 6484 | } |
| 6485 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6486 | break; |
| 6487 | } |
| 6488 | if (LocaleCompare("filter",option+1) == 0) |
| 6489 | { |
| 6490 | if (*option == '+') |
| 6491 | { |
| 6492 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6493 | break; |
| 6494 | } |
| 6495 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6496 | break; |
| 6497 | } |
| 6498 | if (LocaleCompare("font",option+1) == 0) |
| 6499 | { |
| 6500 | if (*option == '+') |
| 6501 | { |
| 6502 | if (image_info->font != (char *) NULL) |
| 6503 | image_info->font=DestroyString(image_info->font); |
| 6504 | break; |
| 6505 | } |
| 6506 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6507 | break; |
| 6508 | } |
| 6509 | if (LocaleCompare("format",option+1) == 0) |
| 6510 | { |
| 6511 | register const char |
| 6512 | *q; |
| 6513 | |
| 6514 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6515 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6516 | image_info->ping=MagickFalse; |
| 6517 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6518 | break; |
| 6519 | } |
| 6520 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6521 | { |
| 6522 | if (*option == '+') |
| 6523 | { |
| 6524 | image_info->fuzz=0.0; |
| 6525 | (void) SetImageOption(image_info,option+1,"0"); |
| 6526 | break; |
| 6527 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 6528 | image_info->fuzz=StringToDoubleInterval(argv[i+1],(double) |
| 6529 | QuantumRange+1.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6530 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6531 | break; |
| 6532 | } |
| 6533 | break; |
| 6534 | } |
| 6535 | case 'g': |
| 6536 | { |
| 6537 | if (LocaleCompare("gravity",option+1) == 0) |
| 6538 | { |
| 6539 | if (*option == '+') |
| 6540 | { |
| 6541 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6542 | break; |
| 6543 | } |
| 6544 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6545 | break; |
| 6546 | } |
| 6547 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6548 | { |
| 6549 | if (*option == '+') |
| 6550 | { |
| 6551 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6552 | break; |
| 6553 | } |
| 6554 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6555 | break; |
| 6556 | } |
| 6557 | break; |
| 6558 | } |
| 6559 | case 'i': |
| 6560 | { |
| 6561 | if (LocaleCompare("intent",option+1) == 0) |
| 6562 | { |
| 6563 | if (*option == '+') |
| 6564 | { |
| 6565 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6566 | break; |
| 6567 | } |
| 6568 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6569 | break; |
| 6570 | } |
| 6571 | if (LocaleCompare("interlace",option+1) == 0) |
| 6572 | { |
| 6573 | if (*option == '+') |
| 6574 | { |
| 6575 | image_info->interlace=UndefinedInterlace; |
| 6576 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6577 | break; |
| 6578 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6579 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6580 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6581 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6582 | break; |
| 6583 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6584 | if (LocaleCompare("interline-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 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6594 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6595 | { |
| 6596 | if (*option == '+') |
| 6597 | { |
| 6598 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6599 | break; |
| 6600 | } |
| 6601 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6602 | break; |
| 6603 | } |
| 6604 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6605 | { |
| 6606 | if (*option == '+') |
| 6607 | { |
| 6608 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6609 | break; |
| 6610 | } |
| 6611 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6612 | break; |
| 6613 | } |
| 6614 | break; |
| 6615 | } |
| 6616 | case 'k': |
| 6617 | { |
| 6618 | if (LocaleCompare("kerning",option+1) == 0) |
| 6619 | { |
| 6620 | if (*option == '+') |
| 6621 | { |
| 6622 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6623 | break; |
| 6624 | } |
| 6625 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6626 | break; |
| 6627 | } |
| 6628 | break; |
| 6629 | } |
| 6630 | case 'l': |
| 6631 | { |
| 6632 | if (LocaleCompare("label",option+1) == 0) |
| 6633 | { |
| 6634 | if (*option == '+') |
| 6635 | { |
| 6636 | (void) DeleteImageOption(image_info,option+1); |
| 6637 | break; |
| 6638 | } |
| 6639 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6640 | break; |
| 6641 | } |
| 6642 | if (LocaleCompare("limit",option+1) == 0) |
| 6643 | { |
| 6644 | MagickSizeType |
| 6645 | limit; |
| 6646 | |
| 6647 | ResourceType |
| 6648 | type; |
| 6649 | |
| 6650 | if (*option == '+') |
| 6651 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6652 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6653 | MagickFalse,argv[i+1]); |
| 6654 | limit=MagickResourceInfinity; |
| 6655 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame^] | 6656 | limit=(MagickSizeType) StringToDoubleInterval(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6657 | (void) SetMagickResourceLimit(type,limit); |
| 6658 | break; |
| 6659 | } |
| 6660 | if (LocaleCompare("list",option+1) == 0) |
| 6661 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6662 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6663 | list; |
| 6664 | |
| 6665 | /* |
| 6666 | Display configuration list. |
| 6667 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6668 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6669 | switch (list) |
| 6670 | { |
| 6671 | case MagickCoderOptions: |
| 6672 | { |
| 6673 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6674 | break; |
| 6675 | } |
| 6676 | case MagickColorOptions: |
| 6677 | { |
| 6678 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6679 | break; |
| 6680 | } |
| 6681 | case MagickConfigureOptions: |
| 6682 | { |
| 6683 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6684 | break; |
| 6685 | } |
| 6686 | case MagickDelegateOptions: |
| 6687 | { |
| 6688 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6689 | break; |
| 6690 | } |
| 6691 | case MagickFontOptions: |
| 6692 | { |
| 6693 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6694 | break; |
| 6695 | } |
| 6696 | case MagickFormatOptions: |
| 6697 | { |
| 6698 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6699 | break; |
| 6700 | } |
| 6701 | case MagickLocaleOptions: |
| 6702 | { |
| 6703 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6704 | break; |
| 6705 | } |
| 6706 | case MagickLogOptions: |
| 6707 | { |
| 6708 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6709 | break; |
| 6710 | } |
| 6711 | case MagickMagicOptions: |
| 6712 | { |
| 6713 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6714 | break; |
| 6715 | } |
| 6716 | case MagickMimeOptions: |
| 6717 | { |
| 6718 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6719 | break; |
| 6720 | } |
| 6721 | case MagickModuleOptions: |
| 6722 | { |
| 6723 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6724 | break; |
| 6725 | } |
| 6726 | case MagickPolicyOptions: |
| 6727 | { |
| 6728 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6729 | break; |
| 6730 | } |
| 6731 | case MagickResourceOptions: |
| 6732 | { |
| 6733 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6734 | break; |
| 6735 | } |
| 6736 | case MagickThresholdOptions: |
| 6737 | { |
| 6738 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6739 | break; |
| 6740 | } |
| 6741 | default: |
| 6742 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6743 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6744 | exception); |
| 6745 | break; |
| 6746 | } |
| 6747 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6748 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6749 | } |
| 6750 | if (LocaleCompare("log",option+1) == 0) |
| 6751 | { |
| 6752 | if (*option == '+') |
| 6753 | break; |
| 6754 | (void) SetLogFormat(argv[i+1]); |
| 6755 | break; |
| 6756 | } |
| 6757 | if (LocaleCompare("loop",option+1) == 0) |
| 6758 | { |
| 6759 | if (*option == '+') |
| 6760 | { |
| 6761 | (void) SetImageOption(image_info,option+1,"0"); |
| 6762 | break; |
| 6763 | } |
| 6764 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6765 | break; |
| 6766 | } |
| 6767 | break; |
| 6768 | } |
| 6769 | case 'm': |
| 6770 | { |
| 6771 | if (LocaleCompare("matte",option+1) == 0) |
| 6772 | { |
| 6773 | if (*option == '+') |
| 6774 | { |
| 6775 | (void) SetImageOption(image_info,option+1,"false"); |
| 6776 | break; |
| 6777 | } |
| 6778 | (void) SetImageOption(image_info,option+1,"true"); |
| 6779 | break; |
| 6780 | } |
| 6781 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6782 | { |
| 6783 | if (*option == '+') |
| 6784 | { |
| 6785 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6786 | (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance, |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6787 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6788 | break; |
| 6789 | } |
| 6790 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6791 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6792 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6793 | break; |
| 6794 | } |
| 6795 | if (LocaleCompare("monitor",option+1) == 0) |
| 6796 | { |
| 6797 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6798 | (void *) NULL); |
| 6799 | break; |
| 6800 | } |
| 6801 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6802 | { |
| 6803 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6804 | break; |
| 6805 | } |
| 6806 | break; |
| 6807 | } |
| 6808 | case 'o': |
| 6809 | { |
| 6810 | if (LocaleCompare("orient",option+1) == 0) |
| 6811 | { |
| 6812 | if (*option == '+') |
| 6813 | { |
| 6814 | image_info->orientation=UndefinedOrientation; |
| 6815 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6816 | break; |
| 6817 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6818 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6819 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6820 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6821 | break; |
| 6822 | } |
| 6823 | } |
| 6824 | case 'p': |
| 6825 | { |
| 6826 | if (LocaleCompare("page",option+1) == 0) |
| 6827 | { |
| 6828 | char |
| 6829 | *canonical_page, |
| 6830 | page[MaxTextExtent]; |
| 6831 | |
| 6832 | const char |
| 6833 | *image_option; |
| 6834 | |
| 6835 | MagickStatusType |
| 6836 | flags; |
| 6837 | |
| 6838 | RectangleInfo |
| 6839 | geometry; |
| 6840 | |
| 6841 | if (*option == '+') |
| 6842 | { |
| 6843 | (void) DeleteImageOption(image_info,option+1); |
| 6844 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6845 | break; |
| 6846 | } |
| 6847 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6848 | image_option=GetImageOption(image_info,"page"); |
| 6849 | if (image_option != (const char *) NULL) |
| 6850 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6851 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6852 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6853 | canonical_page=DestroyString(canonical_page); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6854 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6855 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6856 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6857 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6858 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6859 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6860 | (void) SetImageOption(image_info,option+1,page); |
| 6861 | (void) CloneString(&image_info->page,page); |
| 6862 | break; |
| 6863 | } |
| 6864 | if (LocaleCompare("pen",option+1) == 0) |
| 6865 | { |
| 6866 | if (*option == '+') |
| 6867 | { |
| 6868 | (void) SetImageOption(image_info,option+1,"none"); |
| 6869 | break; |
| 6870 | } |
| 6871 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6872 | break; |
| 6873 | } |
| 6874 | if (LocaleCompare("ping",option+1) == 0) |
| 6875 | { |
| 6876 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6877 | break; |
| 6878 | } |
| 6879 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6880 | { |
| 6881 | if (*option == '+') |
| 6882 | geometry_info.rho=0.0; |
| 6883 | else |
| 6884 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6885 | image_info->pointsize=geometry_info.rho; |
| 6886 | break; |
| 6887 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6888 | if (LocaleCompare("precision",option+1) == 0) |
| 6889 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6890 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6891 | break; |
| 6892 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6893 | if (LocaleCompare("preview",option+1) == 0) |
| 6894 | { |
| 6895 | /* |
| 6896 | Preview image. |
| 6897 | */ |
| 6898 | if (*option == '+') |
| 6899 | { |
| 6900 | image_info->preview_type=UndefinedPreview; |
| 6901 | break; |
| 6902 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6903 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6904 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6905 | break; |
| 6906 | } |
| 6907 | break; |
| 6908 | } |
| 6909 | case 'q': |
| 6910 | { |
| 6911 | if (LocaleCompare("quality",option+1) == 0) |
| 6912 | { |
| 6913 | /* |
| 6914 | Set image compression quality. |
| 6915 | */ |
| 6916 | if (*option == '+') |
| 6917 | { |
| 6918 | image_info->quality=UndefinedCompressionQuality; |
| 6919 | (void) SetImageOption(image_info,option+1,"0"); |
| 6920 | break; |
| 6921 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6922 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6923 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6924 | break; |
| 6925 | } |
| 6926 | if (LocaleCompare("quiet",option+1) == 0) |
| 6927 | { |
| 6928 | static WarningHandler |
| 6929 | warning_handler = (WarningHandler) NULL; |
| 6930 | |
| 6931 | if (*option == '+') |
| 6932 | { |
| 6933 | /* |
| 6934 | Restore error or warning messages. |
| 6935 | */ |
| 6936 | warning_handler=SetWarningHandler(warning_handler); |
| 6937 | break; |
| 6938 | } |
| 6939 | /* |
| 6940 | Suppress error or warning messages. |
| 6941 | */ |
| 6942 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6943 | break; |
| 6944 | } |
| 6945 | break; |
| 6946 | } |
| 6947 | case 'r': |
| 6948 | { |
| 6949 | if (LocaleCompare("red-primary",option+1) == 0) |
| 6950 | { |
| 6951 | if (*option == '+') |
| 6952 | { |
| 6953 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6954 | break; |
| 6955 | } |
| 6956 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6957 | break; |
| 6958 | } |
| 6959 | break; |
| 6960 | } |
| 6961 | case 's': |
| 6962 | { |
| 6963 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 6964 | { |
| 6965 | /* |
| 6966 | Set image sampling factor. |
| 6967 | */ |
| 6968 | if (*option == '+') |
| 6969 | { |
| 6970 | if (image_info->sampling_factor != (char *) NULL) |
| 6971 | image_info->sampling_factor=DestroyString( |
| 6972 | image_info->sampling_factor); |
| 6973 | break; |
| 6974 | } |
| 6975 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 6976 | break; |
| 6977 | } |
| 6978 | if (LocaleCompare("scene",option+1) == 0) |
| 6979 | { |
| 6980 | /* |
| 6981 | Set image scene. |
| 6982 | */ |
| 6983 | if (*option == '+') |
| 6984 | { |
| 6985 | image_info->scene=0; |
| 6986 | (void) SetImageOption(image_info,option+1,"0"); |
| 6987 | break; |
| 6988 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6989 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6990 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6991 | break; |
| 6992 | } |
| 6993 | if (LocaleCompare("seed",option+1) == 0) |
| 6994 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6995 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6996 | seed; |
| 6997 | |
| 6998 | if (*option == '+') |
| 6999 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7000 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7001 | SeedPseudoRandomGenerator(seed); |
| 7002 | break; |
| 7003 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7004 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7005 | SeedPseudoRandomGenerator(seed); |
| 7006 | break; |
| 7007 | } |
| 7008 | if (LocaleCompare("size",option+1) == 0) |
| 7009 | { |
| 7010 | if (*option == '+') |
| 7011 | { |
| 7012 | if (image_info->size != (char *) NULL) |
| 7013 | image_info->size=DestroyString(image_info->size); |
| 7014 | break; |
| 7015 | } |
| 7016 | (void) CloneString(&image_info->size,argv[i+1]); |
| 7017 | break; |
| 7018 | } |
| 7019 | if (LocaleCompare("stroke",option+1) == 0) |
| 7020 | { |
| 7021 | if (*option == '+') |
| 7022 | { |
| 7023 | (void) SetImageOption(image_info,option+1,"none"); |
| 7024 | break; |
| 7025 | } |
| 7026 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7027 | break; |
| 7028 | } |
| 7029 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7030 | { |
| 7031 | if (*option == '+') |
| 7032 | { |
| 7033 | (void) SetImageOption(image_info,option+1,"0"); |
| 7034 | break; |
| 7035 | } |
| 7036 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7037 | break; |
| 7038 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7039 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7040 | { |
| 7041 | if (*option == '+') |
| 7042 | { |
| 7043 | image_info->synchronize=MagickFalse; |
| 7044 | break; |
| 7045 | } |
| 7046 | image_info->synchronize=MagickTrue; |
| 7047 | break; |
| 7048 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7049 | break; |
| 7050 | } |
| 7051 | case 't': |
| 7052 | { |
| 7053 | if (LocaleCompare("taint",option+1) == 0) |
| 7054 | { |
| 7055 | if (*option == '+') |
| 7056 | { |
| 7057 | (void) SetImageOption(image_info,option+1,"false"); |
| 7058 | break; |
| 7059 | } |
| 7060 | (void) SetImageOption(image_info,option+1,"true"); |
| 7061 | break; |
| 7062 | } |
| 7063 | if (LocaleCompare("texture",option+1) == 0) |
| 7064 | { |
| 7065 | if (*option == '+') |
| 7066 | { |
| 7067 | if (image_info->texture != (char *) NULL) |
| 7068 | image_info->texture=DestroyString(image_info->texture); |
| 7069 | break; |
| 7070 | } |
| 7071 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7072 | break; |
| 7073 | } |
| 7074 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7075 | { |
| 7076 | if (*option == '+') |
| 7077 | { |
| 7078 | (void) SetImageOption(image_info,option+1,"0"); |
| 7079 | break; |
| 7080 | } |
| 7081 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7082 | break; |
| 7083 | } |
| 7084 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7085 | { |
| 7086 | if (*option == '+') |
| 7087 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 7088 | (void) QueryColorCompliance("none",AllCompliance, |
| 7089 | &image_info->transparent_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7090 | (void) SetImageOption(image_info,option+1,"none"); |
| 7091 | break; |
| 7092 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 7093 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 7094 | &image_info->transparent_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7095 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7096 | break; |
| 7097 | } |
| 7098 | if (LocaleCompare("type",option+1) == 0) |
| 7099 | { |
| 7100 | if (*option == '+') |
| 7101 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7102 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7103 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7104 | break; |
| 7105 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7106 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7107 | MagickFalse,argv[i+1]); |
| 7108 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7109 | break; |
| 7110 | } |
| 7111 | break; |
| 7112 | } |
| 7113 | case 'u': |
| 7114 | { |
| 7115 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7116 | { |
| 7117 | if (*option == '+') |
| 7118 | { |
| 7119 | (void) DeleteImageOption(image_info,option+1); |
| 7120 | break; |
| 7121 | } |
| 7122 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7123 | break; |
| 7124 | } |
| 7125 | if (LocaleCompare("units",option+1) == 0) |
| 7126 | { |
| 7127 | if (*option == '+') |
| 7128 | { |
| 7129 | image_info->units=UndefinedResolution; |
| 7130 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7131 | break; |
| 7132 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7133 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7134 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7135 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7136 | break; |
| 7137 | } |
| 7138 | break; |
| 7139 | } |
| 7140 | case 'v': |
| 7141 | { |
| 7142 | if (LocaleCompare("verbose",option+1) == 0) |
| 7143 | { |
| 7144 | if (*option == '+') |
| 7145 | { |
| 7146 | image_info->verbose=MagickFalse; |
| 7147 | break; |
| 7148 | } |
| 7149 | image_info->verbose=MagickTrue; |
| 7150 | image_info->ping=MagickFalse; |
| 7151 | break; |
| 7152 | } |
| 7153 | if (LocaleCompare("view",option+1) == 0) |
| 7154 | { |
| 7155 | if (*option == '+') |
| 7156 | { |
| 7157 | if (image_info->view != (char *) NULL) |
| 7158 | image_info->view=DestroyString(image_info->view); |
| 7159 | break; |
| 7160 | } |
| 7161 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7162 | break; |
| 7163 | } |
| 7164 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7165 | { |
| 7166 | if (*option == '+') |
| 7167 | { |
| 7168 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7169 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7170 | break; |
| 7171 | } |
| 7172 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7173 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7174 | argv[i+1]); |
| 7175 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7176 | break; |
| 7177 | } |
| 7178 | break; |
| 7179 | } |
| 7180 | case 'w': |
| 7181 | { |
| 7182 | if (LocaleCompare("white-point",option+1) == 0) |
| 7183 | { |
| 7184 | if (*option == '+') |
| 7185 | { |
| 7186 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7187 | break; |
| 7188 | } |
| 7189 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7190 | break; |
| 7191 | } |
| 7192 | break; |
| 7193 | } |
| 7194 | default: |
| 7195 | break; |
| 7196 | } |
| 7197 | i+=count; |
| 7198 | } |
| 7199 | return(MagickTrue); |
| 7200 | } |
| 7201 | |
| 7202 | /* |
| 7203 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7204 | % % |
| 7205 | % % |
| 7206 | % % |
| 7207 | + M o g r i f y I m a g e L i s t % |
| 7208 | % % |
| 7209 | % % |
| 7210 | % % |
| 7211 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7212 | % |
| 7213 | % MogrifyImageList() applies any command line options that might affect the |
| 7214 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7215 | % |
| 7216 | % The format of the MogrifyImage method is: |
| 7217 | % |
| 7218 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7219 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7220 | % |
| 7221 | % A description of each parameter follows: |
| 7222 | % |
| 7223 | % o image_info: the image info.. |
| 7224 | % |
| 7225 | % o argc: Specifies a pointer to an integer describing the number of |
| 7226 | % elements in the argument vector. |
| 7227 | % |
| 7228 | % o argv: Specifies a pointer to a text array containing the command line |
| 7229 | % arguments. |
| 7230 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7231 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7232 | % |
| 7233 | % o exception: return any errors or warnings in this structure. |
| 7234 | % |
| 7235 | */ |
| 7236 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7237 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7238 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7239 | const char |
| 7240 | *option; |
| 7241 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7242 | ImageInfo |
| 7243 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7244 | |
| 7245 | MagickStatusType |
| 7246 | status; |
| 7247 | |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7248 | PixelInterpolateMethod |
| 7249 | interpolate_method; |
| 7250 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7251 | QuantizeInfo |
| 7252 | *quantize_info; |
| 7253 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7254 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7255 | i; |
| 7256 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7257 | ssize_t |
| 7258 | count, |
| 7259 | index; |
| 7260 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7261 | /* |
| 7262 | Apply options to the image list. |
| 7263 | */ |
| 7264 | assert(image_info != (ImageInfo *) NULL); |
| 7265 | assert(image_info->signature == MagickSignature); |
| 7266 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7267 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7268 | assert((*images)->signature == MagickSignature); |
| 7269 | if ((*images)->debug != MagickFalse) |
| 7270 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7271 | (*images)->filename); |
| 7272 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7273 | return(MagickTrue); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7274 | interpolate_method=UndefinedInterpolatePixel; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7275 | mogrify_info=CloneImageInfo(image_info); |
| 7276 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7277 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7278 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7279 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7280 | if (*images == (Image *) NULL) |
| 7281 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7282 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7283 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7284 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7285 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7286 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7287 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7288 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7289 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7290 | switch (*(option+1)) |
| 7291 | { |
| 7292 | case 'a': |
| 7293 | { |
| 7294 | if (LocaleCompare("affinity",option+1) == 0) |
| 7295 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7296 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7297 | if (*option == '+') |
| 7298 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7299 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7300 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7301 | break; |
| 7302 | } |
| 7303 | i++; |
| 7304 | break; |
| 7305 | } |
| 7306 | if (LocaleCompare("append",option+1) == 0) |
| 7307 | { |
| 7308 | Image |
| 7309 | *append_image; |
| 7310 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7311 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7312 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7313 | MagickFalse,exception); |
| 7314 | if (append_image == (Image *) NULL) |
| 7315 | { |
| 7316 | status=MagickFalse; |
| 7317 | break; |
| 7318 | } |
| 7319 | *images=DestroyImageList(*images); |
| 7320 | *images=append_image; |
| 7321 | break; |
| 7322 | } |
| 7323 | if (LocaleCompare("average",option+1) == 0) |
| 7324 | { |
| 7325 | Image |
| 7326 | *average_image; |
| 7327 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7328 | /* |
| 7329 | Average an image sequence (deprecated). |
| 7330 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7331 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7332 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7333 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7334 | if (average_image == (Image *) NULL) |
| 7335 | { |
| 7336 | status=MagickFalse; |
| 7337 | break; |
| 7338 | } |
| 7339 | *images=DestroyImageList(*images); |
| 7340 | *images=average_image; |
| 7341 | break; |
| 7342 | } |
| 7343 | break; |
| 7344 | } |
| 7345 | case 'c': |
| 7346 | { |
| 7347 | if (LocaleCompare("channel",option+1) == 0) |
| 7348 | { |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7349 | ChannelType |
| 7350 | channel; |
| 7351 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7352 | if (*option == '+') |
| 7353 | { |
| 7354 | channel=DefaultChannels; |
| 7355 | break; |
| 7356 | } |
| 7357 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 7358 | SetPixelChannelMap(*images,channel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7359 | break; |
| 7360 | } |
| 7361 | if (LocaleCompare("clut",option+1) == 0) |
| 7362 | { |
| 7363 | Image |
| 7364 | *clut_image, |
| 7365 | *image; |
| 7366 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7367 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7368 | image=RemoveFirstImageFromList(images); |
| 7369 | clut_image=RemoveFirstImageFromList(images); |
| 7370 | if (clut_image == (Image *) NULL) |
| 7371 | { |
| 7372 | status=MagickFalse; |
| 7373 | break; |
| 7374 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7375 | (void) ClutImage(image,clut_image,interpolate_method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7376 | clut_image=DestroyImage(clut_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7377 | *images=DestroyImageList(*images); |
| 7378 | *images=image; |
| 7379 | break; |
| 7380 | } |
| 7381 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7382 | { |
| 7383 | Image |
| 7384 | *coalesce_image; |
| 7385 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7386 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7387 | coalesce_image=CoalesceImages(*images,exception); |
| 7388 | if (coalesce_image == (Image *) NULL) |
| 7389 | { |
| 7390 | status=MagickFalse; |
| 7391 | break; |
| 7392 | } |
| 7393 | *images=DestroyImageList(*images); |
| 7394 | *images=coalesce_image; |
| 7395 | break; |
| 7396 | } |
| 7397 | if (LocaleCompare("combine",option+1) == 0) |
| 7398 | { |
| 7399 | Image |
| 7400 | *combine_image; |
| 7401 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7402 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 7403 | combine_image=CombineImages(*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7404 | if (combine_image == (Image *) NULL) |
| 7405 | { |
| 7406 | status=MagickFalse; |
| 7407 | break; |
| 7408 | } |
| 7409 | *images=DestroyImageList(*images); |
| 7410 | *images=combine_image; |
| 7411 | break; |
| 7412 | } |
| 7413 | if (LocaleCompare("composite",option+1) == 0) |
| 7414 | { |
| 7415 | Image |
| 7416 | *mask_image, |
| 7417 | *composite_image, |
| 7418 | *image; |
| 7419 | |
| 7420 | RectangleInfo |
| 7421 | geometry; |
| 7422 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7423 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7424 | image=RemoveFirstImageFromList(images); |
| 7425 | composite_image=RemoveFirstImageFromList(images); |
| 7426 | if (composite_image == (Image *) NULL) |
| 7427 | { |
| 7428 | status=MagickFalse; |
| 7429 | break; |
| 7430 | } |
| 7431 | (void) TransformImage(&composite_image,(char *) NULL, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 7432 | composite_image->geometry,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7433 | SetGeometry(composite_image,&geometry); |
| 7434 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7435 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7436 | &geometry); |
| 7437 | mask_image=RemoveFirstImageFromList(images); |
| 7438 | if (mask_image != (Image *) NULL) |
| 7439 | { |
| 7440 | if ((image->compose == DisplaceCompositeOp) || |
| 7441 | (image->compose == DistortCompositeOp)) |
| 7442 | { |
| 7443 | /* |
| 7444 | Merge Y displacement into X displacement image. |
| 7445 | */ |
| 7446 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 7447 | mask_image,0,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7448 | mask_image=DestroyImage(mask_image); |
| 7449 | } |
| 7450 | else |
| 7451 | { |
| 7452 | /* |
| 7453 | Set a blending mask for the composition. |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7454 | Posible error, what if image->mask already set. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7455 | */ |
| 7456 | image->mask=mask_image; |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 7457 | (void) NegateImage(image->mask,MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7458 | } |
| 7459 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7460 | (void) CompositeImage(image,image->compose,composite_image, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 7461 | geometry.x,geometry.y,exception); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7462 | if (mask_image != (Image *) NULL) |
| 7463 | mask_image=image->mask=DestroyImage(image->mask); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7464 | composite_image=DestroyImage(composite_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7465 | *images=DestroyImageList(*images); |
| 7466 | *images=image; |
| 7467 | break; |
| 7468 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7469 | break; |
| 7470 | } |
| 7471 | case 'd': |
| 7472 | { |
| 7473 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7474 | { |
| 7475 | Image |
| 7476 | *deconstruct_image; |
| 7477 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7478 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7479 | deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer, |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 7480 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7481 | if (deconstruct_image == (Image *) NULL) |
| 7482 | { |
| 7483 | status=MagickFalse; |
| 7484 | break; |
| 7485 | } |
| 7486 | *images=DestroyImageList(*images); |
| 7487 | *images=deconstruct_image; |
| 7488 | break; |
| 7489 | } |
| 7490 | if (LocaleCompare("delete",option+1) == 0) |
| 7491 | { |
| 7492 | if (*option == '+') |
| 7493 | DeleteImages(images,"-1",exception); |
| 7494 | else |
| 7495 | DeleteImages(images,argv[i+1],exception); |
| 7496 | break; |
| 7497 | } |
| 7498 | if (LocaleCompare("dither",option+1) == 0) |
| 7499 | { |
| 7500 | if (*option == '+') |
| 7501 | { |
| 7502 | quantize_info->dither=MagickFalse; |
| 7503 | break; |
| 7504 | } |
| 7505 | quantize_info->dither=MagickTrue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7506 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7507 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7508 | break; |
| 7509 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7510 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7511 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7512 | Image |
| 7513 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7514 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7515 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7516 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7517 | else |
| 7518 | { |
| 7519 | const char |
| 7520 | *p; |
| 7521 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7522 | size_t |
| 7523 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7524 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7525 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7526 | p=strchr(argv[i+1],','); |
| 7527 | if (p == (const char *) NULL) |
| 7528 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7529 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7530 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7531 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7532 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7533 | } |
| 7534 | AppendImageToList(images, duplicate_images); |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7535 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7536 | break; |
| 7537 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7538 | break; |
| 7539 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7540 | case 'e': |
| 7541 | { |
| 7542 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7543 | { |
| 7544 | Image |
| 7545 | *evaluate_image; |
| 7546 | |
| 7547 | MagickEvaluateOperator |
| 7548 | op; |
| 7549 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7550 | (void) SyncImageSettings(mogrify_info,*images,exception); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7551 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 7552 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7553 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7554 | if (evaluate_image == (Image *) NULL) |
| 7555 | { |
| 7556 | status=MagickFalse; |
| 7557 | break; |
| 7558 | } |
| 7559 | *images=DestroyImageList(*images); |
| 7560 | *images=evaluate_image; |
| 7561 | break; |
| 7562 | } |
| 7563 | break; |
| 7564 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7565 | case 'f': |
| 7566 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7567 | if (LocaleCompare("fft",option+1) == 0) |
| 7568 | { |
| 7569 | Image |
| 7570 | *fourier_image; |
| 7571 | |
| 7572 | /* |
| 7573 | Implements the discrete Fourier transform (DFT). |
| 7574 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7575 | (void) SyncImageSettings(mogrify_info,*images,exception); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7576 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7577 | MagickTrue : MagickFalse,exception); |
| 7578 | if (fourier_image == (Image *) NULL) |
| 7579 | break; |
| 7580 | *images=DestroyImage(*images); |
| 7581 | *images=fourier_image; |
| 7582 | break; |
| 7583 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7584 | if (LocaleCompare("flatten",option+1) == 0) |
| 7585 | { |
| 7586 | Image |
| 7587 | *flatten_image; |
| 7588 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7589 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7590 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7591 | if (flatten_image == (Image *) NULL) |
| 7592 | break; |
| 7593 | *images=DestroyImageList(*images); |
| 7594 | *images=flatten_image; |
| 7595 | break; |
| 7596 | } |
| 7597 | if (LocaleCompare("fx",option+1) == 0) |
| 7598 | { |
| 7599 | Image |
| 7600 | *fx_image; |
| 7601 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7602 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 7603 | fx_image=FxImage(*images,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7604 | if (fx_image == (Image *) NULL) |
| 7605 | { |
| 7606 | status=MagickFalse; |
| 7607 | break; |
| 7608 | } |
| 7609 | *images=DestroyImageList(*images); |
| 7610 | *images=fx_image; |
| 7611 | break; |
| 7612 | } |
| 7613 | break; |
| 7614 | } |
| 7615 | case 'h': |
| 7616 | { |
| 7617 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7618 | { |
| 7619 | Image |
| 7620 | *hald_image, |
| 7621 | *image; |
| 7622 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7623 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7624 | image=RemoveFirstImageFromList(images); |
| 7625 | hald_image=RemoveFirstImageFromList(images); |
| 7626 | if (hald_image == (Image *) NULL) |
| 7627 | { |
| 7628 | status=MagickFalse; |
| 7629 | break; |
| 7630 | } |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 7631 | (void) HaldClutImage(image,hald_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7632 | hald_image=DestroyImage(hald_image); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7633 | if (*images != (Image *) NULL) |
| 7634 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7635 | *images=image; |
| 7636 | break; |
| 7637 | } |
| 7638 | break; |
| 7639 | } |
| 7640 | case 'i': |
| 7641 | { |
| 7642 | if (LocaleCompare("ift",option+1) == 0) |
| 7643 | { |
| 7644 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7645 | *fourier_image, |
| 7646 | *magnitude_image, |
| 7647 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7648 | |
| 7649 | /* |
| 7650 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7651 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7652 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7653 | magnitude_image=RemoveFirstImageFromList(images); |
| 7654 | phase_image=RemoveFirstImageFromList(images); |
| 7655 | if (phase_image == (Image *) NULL) |
| 7656 | { |
| 7657 | status=MagickFalse; |
| 7658 | break; |
| 7659 | } |
| 7660 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7661 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7662 | if (fourier_image == (Image *) NULL) |
| 7663 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7664 | if (*images != (Image *) NULL) |
| 7665 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7666 | *images=fourier_image; |
| 7667 | break; |
| 7668 | } |
| 7669 | if (LocaleCompare("insert",option+1) == 0) |
| 7670 | { |
| 7671 | Image |
| 7672 | *p, |
| 7673 | *q; |
| 7674 | |
| 7675 | index=0; |
| 7676 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7677 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7678 | p=RemoveLastImageFromList(images); |
| 7679 | if (p == (Image *) NULL) |
| 7680 | { |
| 7681 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7682 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7683 | status=MagickFalse; |
| 7684 | break; |
| 7685 | } |
| 7686 | q=p; |
| 7687 | if (index == 0) |
| 7688 | PrependImageToList(images,q); |
| 7689 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7690 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7691 | AppendImageToList(images,q); |
| 7692 | else |
| 7693 | { |
| 7694 | q=GetImageFromList(*images,index-1); |
| 7695 | if (q == (Image *) NULL) |
| 7696 | { |
| 7697 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7698 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7699 | status=MagickFalse; |
| 7700 | break; |
| 7701 | } |
| 7702 | InsertImageInList(&q,p); |
| 7703 | } |
| 7704 | *images=GetFirstImageInList(q); |
| 7705 | break; |
| 7706 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7707 | if (LocaleCompare("interpolate",option+1) == 0) |
| 7708 | { |
| 7709 | interpolate_method=(PixelInterpolateMethod) ParseCommandOption( |
| 7710 | MagickInterpolateOptions,MagickFalse,argv[i+1]); |
| 7711 | break; |
| 7712 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7713 | break; |
| 7714 | } |
| 7715 | case 'l': |
| 7716 | { |
| 7717 | if (LocaleCompare("layers",option+1) == 0) |
| 7718 | { |
| 7719 | Image |
| 7720 | *layers; |
| 7721 | |
| 7722 | ImageLayerMethod |
| 7723 | method; |
| 7724 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7725 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7726 | layers=(Image *) NULL; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7727 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7728 | MagickFalse,argv[i+1]); |
| 7729 | switch (method) |
| 7730 | { |
| 7731 | case CoalesceLayer: |
| 7732 | { |
| 7733 | layers=CoalesceImages(*images,exception); |
| 7734 | break; |
| 7735 | } |
| 7736 | case CompareAnyLayer: |
| 7737 | case CompareClearLayer: |
| 7738 | case CompareOverlayLayer: |
| 7739 | default: |
| 7740 | { |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7741 | layers=CompareImagesLayers(*images,method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7742 | break; |
| 7743 | } |
| 7744 | case MergeLayer: |
| 7745 | case FlattenLayer: |
| 7746 | case MosaicLayer: |
| 7747 | case TrimBoundsLayer: |
| 7748 | { |
| 7749 | layers=MergeImageLayers(*images,method,exception); |
| 7750 | break; |
| 7751 | } |
| 7752 | case DisposeLayer: |
| 7753 | { |
| 7754 | layers=DisposeImages(*images,exception); |
| 7755 | break; |
| 7756 | } |
| 7757 | case OptimizeImageLayer: |
| 7758 | { |
| 7759 | layers=OptimizeImageLayers(*images,exception); |
| 7760 | break; |
| 7761 | } |
| 7762 | case OptimizePlusLayer: |
| 7763 | { |
| 7764 | layers=OptimizePlusImageLayers(*images,exception); |
| 7765 | break; |
| 7766 | } |
| 7767 | case OptimizeTransLayer: |
| 7768 | { |
| 7769 | OptimizeImageTransparency(*images,exception); |
| 7770 | break; |
| 7771 | } |
| 7772 | case RemoveDupsLayer: |
| 7773 | { |
| 7774 | RemoveDuplicateLayers(images,exception); |
| 7775 | break; |
| 7776 | } |
| 7777 | case RemoveZeroLayer: |
| 7778 | { |
| 7779 | RemoveZeroDelayLayers(images,exception); |
| 7780 | break; |
| 7781 | } |
| 7782 | case OptimizeLayer: |
| 7783 | { |
| 7784 | /* |
| 7785 | General Purpose, GIF Animation Optimizer. |
| 7786 | */ |
| 7787 | layers=CoalesceImages(*images,exception); |
| 7788 | if (layers == (Image *) NULL) |
| 7789 | { |
| 7790 | status=MagickFalse; |
| 7791 | break; |
| 7792 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7793 | *images=DestroyImageList(*images); |
| 7794 | *images=layers; |
| 7795 | layers=OptimizeImageLayers(*images,exception); |
| 7796 | if (layers == (Image *) NULL) |
| 7797 | { |
| 7798 | status=MagickFalse; |
| 7799 | break; |
| 7800 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7801 | *images=DestroyImageList(*images); |
| 7802 | *images=layers; |
| 7803 | layers=(Image *) NULL; |
| 7804 | OptimizeImageTransparency(*images,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7805 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7806 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7807 | break; |
| 7808 | } |
| 7809 | case CompositeLayer: |
| 7810 | { |
| 7811 | CompositeOperator |
| 7812 | compose; |
| 7813 | |
| 7814 | Image |
| 7815 | *source; |
| 7816 | |
| 7817 | RectangleInfo |
| 7818 | geometry; |
| 7819 | |
| 7820 | /* |
| 7821 | Split image sequence at the first 'NULL:' image. |
| 7822 | */ |
| 7823 | source=(*images); |
| 7824 | while (source != (Image *) NULL) |
| 7825 | { |
| 7826 | source=GetNextImageInList(source); |
| 7827 | if ((source != (Image *) NULL) && |
| 7828 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7829 | break; |
| 7830 | } |
| 7831 | if (source != (Image *) NULL) |
| 7832 | { |
| 7833 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7834 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7835 | source=(Image *) NULL; |
| 7836 | else |
| 7837 | { |
| 7838 | /* |
| 7839 | Separate the two lists, junk the null: image. |
| 7840 | */ |
| 7841 | source=SplitImageList(source->previous); |
| 7842 | DeleteImageFromList(&source); |
| 7843 | } |
| 7844 | } |
| 7845 | if (source == (Image *) NULL) |
| 7846 | { |
| 7847 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7848 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7849 | status=MagickFalse; |
| 7850 | break; |
| 7851 | } |
| 7852 | /* |
| 7853 | Adjust offset with gravity and virtual canvas. |
| 7854 | */ |
| 7855 | SetGeometry(*images,&geometry); |
| 7856 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7857 | geometry.width=source->page.width != 0 ? |
| 7858 | source->page.width : source->columns; |
| 7859 | geometry.height=source->page.height != 0 ? |
| 7860 | source->page.height : source->rows; |
| 7861 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7862 | (*images)->page.width : (*images)->columns, |
| 7863 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7864 | (*images)->rows,(*images)->gravity,&geometry); |
| 7865 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7866 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7867 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7868 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7869 | MagickComposeOptions,MagickFalse,option); |
| 7870 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7871 | exception); |
| 7872 | source=DestroyImageList(source); |
| 7873 | break; |
| 7874 | } |
| 7875 | } |
| 7876 | if (layers == (Image *) NULL) |
| 7877 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7878 | *images=DestroyImageList(*images); |
| 7879 | *images=layers; |
| 7880 | break; |
| 7881 | } |
| 7882 | break; |
| 7883 | } |
| 7884 | case 'm': |
| 7885 | { |
| 7886 | if (LocaleCompare("map",option+1) == 0) |
| 7887 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7888 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7889 | if (*option == '+') |
| 7890 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7891 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7892 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7893 | break; |
| 7894 | } |
| 7895 | i++; |
| 7896 | break; |
| 7897 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7898 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7899 | { |
| 7900 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7901 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7902 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7903 | /* |
| 7904 | Maximum image sequence (deprecated). |
| 7905 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7906 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7907 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7908 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7909 | { |
| 7910 | status=MagickFalse; |
| 7911 | break; |
| 7912 | } |
| 7913 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7914 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7915 | break; |
| 7916 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7917 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7918 | { |
| 7919 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7920 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7921 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7922 | /* |
| 7923 | Minimum image sequence (deprecated). |
| 7924 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7925 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7926 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7927 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7928 | { |
| 7929 | status=MagickFalse; |
| 7930 | break; |
| 7931 | } |
| 7932 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7933 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7934 | break; |
| 7935 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7936 | if (LocaleCompare("morph",option+1) == 0) |
| 7937 | { |
| 7938 | Image |
| 7939 | *morph_image; |
| 7940 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7941 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7942 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7943 | exception); |
| 7944 | if (morph_image == (Image *) NULL) |
| 7945 | { |
| 7946 | status=MagickFalse; |
| 7947 | break; |
| 7948 | } |
| 7949 | *images=DestroyImageList(*images); |
| 7950 | *images=morph_image; |
| 7951 | break; |
| 7952 | } |
| 7953 | if (LocaleCompare("mosaic",option+1) == 0) |
| 7954 | { |
| 7955 | Image |
| 7956 | *mosaic_image; |
| 7957 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7958 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7959 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 7960 | if (mosaic_image == (Image *) NULL) |
| 7961 | { |
| 7962 | status=MagickFalse; |
| 7963 | break; |
| 7964 | } |
| 7965 | *images=DestroyImageList(*images); |
| 7966 | *images=mosaic_image; |
| 7967 | break; |
| 7968 | } |
| 7969 | break; |
| 7970 | } |
| 7971 | case 'p': |
| 7972 | { |
| 7973 | if (LocaleCompare("print",option+1) == 0) |
| 7974 | { |
| 7975 | char |
| 7976 | *string; |
| 7977 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7978 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7979 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1], |
| 7980 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7981 | if (string == (char *) NULL) |
| 7982 | break; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 7983 | (void) FormatLocaleFile(stdout,"%s",string); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7984 | string=DestroyString(string); |
| 7985 | } |
| 7986 | if (LocaleCompare("process",option+1) == 0) |
| 7987 | { |
| 7988 | char |
| 7989 | **arguments; |
| 7990 | |
| 7991 | int |
| 7992 | j, |
| 7993 | number_arguments; |
| 7994 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7995 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7996 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 7997 | if (arguments == (char **) NULL) |
| 7998 | break; |
| 7999 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 8000 | { |
| 8001 | char |
| 8002 | breaker, |
| 8003 | quote, |
| 8004 | *token; |
| 8005 | |
| 8006 | const char |
| 8007 | *arguments; |
| 8008 | |
| 8009 | int |
| 8010 | next, |
| 8011 | status; |
| 8012 | |
| 8013 | size_t |
| 8014 | length; |
| 8015 | |
| 8016 | TokenInfo |
| 8017 | *token_info; |
| 8018 | |
| 8019 | /* |
| 8020 | Support old style syntax, filter="-option arg". |
| 8021 | */ |
| 8022 | length=strlen(argv[i+1]); |
| 8023 | token=(char *) NULL; |
cristy | 37e0b38 | 2011-06-07 13:31:21 +0000 | [diff] [blame] | 8024 | if (~length >= (MaxTextExtent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8025 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8026 | sizeof(*token)); |
| 8027 | if (token == (char *) NULL) |
| 8028 | break; |
| 8029 | next=0; |
| 8030 | arguments=argv[i+1]; |
| 8031 | token_info=AcquireTokenInfo(); |
| 8032 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8033 | "\"",'\0',&breaker,&next,"e); |
| 8034 | token_info=DestroyTokenInfo(token_info); |
| 8035 | if (status == 0) |
| 8036 | { |
| 8037 | const char |
| 8038 | *argv; |
| 8039 | |
| 8040 | argv=(&(arguments[next])); |
| 8041 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8042 | exception); |
| 8043 | } |
| 8044 | token=DestroyString(token); |
| 8045 | break; |
| 8046 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8047 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8048 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8049 | number_arguments-2,(const char **) arguments+2,exception); |
| 8050 | for (j=0; j < number_arguments; j++) |
| 8051 | arguments[j]=DestroyString(arguments[j]); |
| 8052 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8053 | break; |
| 8054 | } |
| 8055 | break; |
| 8056 | } |
| 8057 | case 'r': |
| 8058 | { |
| 8059 | if (LocaleCompare("reverse",option+1) == 0) |
| 8060 | { |
| 8061 | ReverseImageList(images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8062 | break; |
| 8063 | } |
| 8064 | break; |
| 8065 | } |
| 8066 | case 's': |
| 8067 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8068 | if (LocaleCompare("smush",option+1) == 0) |
| 8069 | { |
| 8070 | Image |
| 8071 | *smush_image; |
| 8072 | |
| 8073 | ssize_t |
| 8074 | offset; |
| 8075 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8076 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8077 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8078 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8079 | MagickFalse,offset,exception); |
| 8080 | if (smush_image == (Image *) NULL) |
| 8081 | { |
| 8082 | status=MagickFalse; |
| 8083 | break; |
| 8084 | } |
| 8085 | *images=DestroyImageList(*images); |
| 8086 | *images=smush_image; |
| 8087 | break; |
| 8088 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8089 | if (LocaleCompare("swap",option+1) == 0) |
| 8090 | { |
| 8091 | Image |
| 8092 | *p, |
| 8093 | *q, |
| 8094 | *swap; |
| 8095 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8096 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8097 | swap_index; |
| 8098 | |
| 8099 | index=(-1); |
| 8100 | swap_index=(-2); |
| 8101 | if (*option != '+') |
| 8102 | { |
| 8103 | GeometryInfo |
| 8104 | geometry_info; |
| 8105 | |
| 8106 | MagickStatusType |
| 8107 | flags; |
| 8108 | |
| 8109 | swap_index=(-1); |
| 8110 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8111 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8112 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8113 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8114 | } |
| 8115 | p=GetImageFromList(*images,index); |
| 8116 | q=GetImageFromList(*images,swap_index); |
| 8117 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8118 | { |
| 8119 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8120 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8121 | status=MagickFalse; |
| 8122 | break; |
| 8123 | } |
| 8124 | if (p == q) |
| 8125 | break; |
| 8126 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8127 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8128 | ReplaceImageInList(&q,swap); |
| 8129 | *images=GetFirstImageInList(q); |
| 8130 | break; |
| 8131 | } |
| 8132 | break; |
| 8133 | } |
| 8134 | case 'w': |
| 8135 | { |
| 8136 | if (LocaleCompare("write",option+1) == 0) |
| 8137 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8138 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8139 | key[MaxTextExtent]; |
| 8140 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8141 | Image |
| 8142 | *write_images; |
| 8143 | |
| 8144 | ImageInfo |
| 8145 | *write_info; |
| 8146 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8147 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8148 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8149 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8150 | write_images=(*images); |
| 8151 | if (*option == '+') |
| 8152 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8153 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8154 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8155 | write_info=DestroyImageInfo(write_info); |
| 8156 | if (*option == '+') |
| 8157 | write_images=DestroyImageList(write_images); |
| 8158 | break; |
| 8159 | } |
| 8160 | break; |
| 8161 | } |
| 8162 | default: |
| 8163 | break; |
| 8164 | } |
| 8165 | i+=count; |
| 8166 | } |
| 8167 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8168 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8169 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8170 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8171 | } |
| 8172 | |
| 8173 | /* |
| 8174 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8175 | % % |
| 8176 | % % |
| 8177 | % % |
| 8178 | + M o g r i f y I m a g e s % |
| 8179 | % % |
| 8180 | % % |
| 8181 | % % |
| 8182 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8183 | % |
| 8184 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8185 | % prescribed by command line options. |
| 8186 | % |
| 8187 | % The format of the MogrifyImage method is: |
| 8188 | % |
| 8189 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8190 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8191 | % Image **images,Exceptioninfo *exception) |
| 8192 | % |
| 8193 | % A description of each parameter follows: |
| 8194 | % |
| 8195 | % o image_info: the image info.. |
| 8196 | % |
| 8197 | % o post: If true, post process image list operators otherwise pre-process. |
| 8198 | % |
| 8199 | % o argc: Specifies a pointer to an integer describing the number of |
| 8200 | % elements in the argument vector. |
| 8201 | % |
| 8202 | % o argv: Specifies a pointer to a text array containing the command line |
| 8203 | % arguments. |
| 8204 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8205 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8206 | % |
| 8207 | % o exception: return any errors or warnings in this structure. |
| 8208 | % |
| 8209 | */ |
| 8210 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8211 | const MagickBooleanType post,const int argc,const char **argv, |
| 8212 | Image **images,ExceptionInfo *exception) |
| 8213 | { |
| 8214 | #define MogrifyImageTag "Mogrify/Image" |
| 8215 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8216 | MagickStatusType |
| 8217 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8218 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8219 | MagickBooleanType |
| 8220 | proceed; |
| 8221 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8222 | size_t |
| 8223 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8224 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8225 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8226 | i; |
| 8227 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8228 | assert(image_info != (ImageInfo *) NULL); |
| 8229 | assert(image_info->signature == MagickSignature); |
| 8230 | if (images == (Image **) NULL) |
| 8231 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8232 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8233 | assert((*images)->signature == MagickSignature); |
| 8234 | if ((*images)->debug != MagickFalse) |
| 8235 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8236 | (*images)->filename); |
| 8237 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8238 | return(MagickTrue); |
| 8239 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8240 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8241 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8242 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8243 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8244 | (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc, |
| 8245 | post?"post":"pre"); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8246 | #endif |
| 8247 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8248 | /* |
| 8249 | Pre-process multi-image sequence operators |
| 8250 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8251 | if (post == MagickFalse) |
| 8252 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8253 | /* |
| 8254 | For each image, process simple single image operators |
| 8255 | */ |
| 8256 | i=0; |
| 8257 | n=GetImageListLength(*images); |
cristy | 9f027d1 | 2011-09-21 01:17:17 +0000 | [diff] [blame] | 8258 | for ( ; ; ) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8259 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8260 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8261 | (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long) |
| 8262 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8263 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8264 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8265 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8266 | if (proceed == MagickFalse) |
| 8267 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8268 | if ( (*images)->next == (Image *) NULL ) |
| 8269 | break; |
| 8270 | *images=(*images)->next; |
| 8271 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8272 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8273 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8274 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8275 | (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long) |
| 8276 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8277 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8278 | |
| 8279 | /* |
| 8280 | Post-process, multi-image sequence operators |
| 8281 | */ |
| 8282 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8283 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8284 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8285 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8286 | } |