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 | 45ef08f | 2012-12-07 13:13:34 +0000 | [diff] [blame] | 20 | % Copyright 1999-2013 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" |
cristy | d79e236 | 2013-01-06 23:01:40 +0000 | [diff] [blame] | 49 | #include "MagickWand/mogrify-private.h" |
cristy | e80f9cb | 2013-01-09 01:09:31 +0000 | [diff] [blame^] | 50 | #include "MagickCore/image-private.h" |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 51 | #include "MagickCore/monitor-private.h" |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 52 | #include "MagickCore/string-private.h" |
cristy | 0740a98 | 2011-10-13 15:01:01 +0000 | [diff] [blame] | 53 | #include "MagickCore/thread-private.h" |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 54 | #include "MagickCore/utility-private.h" |
cristy | 03e8317 | 2012-03-25 22:41:06 +0000 | [diff] [blame] | 55 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 56 | /* |
cristy | 154fa9d | 2011-08-05 14:25:15 +0000 | [diff] [blame] | 57 | Constant declaration. |
| 58 | */ |
cristy | 3a557c0 | 2011-08-06 19:48:02 +0000 | [diff] [blame] | 59 | static const char |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 60 | MogrifyBackgroundColor[] = "#ffffff", /* white */ |
| 61 | MogrifyBorderColor[] = "#dfdfdf", /* gray */ |
| 62 | MogrifyMatteColor[] = "#bdbdbd"; /* gray */ |
cristy | 154fa9d | 2011-08-05 14:25:15 +0000 | [diff] [blame] | 63 | |
| 64 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 65 | Define declarations. |
| 66 | */ |
| 67 | #define UndefinedCompressionQuality 0UL |
| 68 | |
| 69 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 70 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 71 | % % |
| 72 | % % |
| 73 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 74 | % 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] | 75 | % % |
| 76 | % % |
| 77 | % % |
| 78 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 79 | % |
| 80 | % MagickCommandGenesis() applies image processing options to an image as |
| 81 | % prescribed by command line options. |
| 82 | % |
| 83 | % The format of the MagickCommandGenesis method is: |
| 84 | % |
| 85 | % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 86 | % MagickCommand command,int argc,char **argv,char **metadata, |
| 87 | % ExceptionInfo *exception) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 88 | % |
| 89 | % A description of each parameter follows: |
| 90 | % |
| 91 | % o image_info: the image info. |
| 92 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 93 | % o command: Choose from ConvertImageCommand, IdentifyImageCommand, |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 94 | % MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 95 | % ConjureImageCommand, StreamImageCommand, ImportImageCommand, |
| 96 | % DisplayImageCommand, or AnimateImageCommand. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 97 | % |
| 98 | % o argc: Specifies a pointer to an integer describing the number of |
| 99 | % elements in the argument vector. |
| 100 | % |
| 101 | % o argv: Specifies a pointer to a text array containing the command line |
| 102 | % arguments. |
| 103 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 104 | % o metadata: any metadata is returned here. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 105 | % |
| 106 | % o exception: return any errors or warnings in this structure. |
| 107 | % |
| 108 | */ |
| 109 | WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
| 110 | MagickCommand command,int argc,char **argv,char **metadata, |
| 111 | ExceptionInfo *exception) |
| 112 | { |
| 113 | char |
| 114 | *option; |
| 115 | |
| 116 | double |
| 117 | duration, |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 118 | serial; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 119 | |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 120 | MagickBooleanType |
| 121 | concurrent, |
| 122 | regard_warnings, |
| 123 | status; |
| 124 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 125 | register ssize_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 126 | i; |
| 127 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 128 | size_t |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 129 | iterations, |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 130 | number_threads; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 131 | |
cristy | 118fc66 | 2012-02-11 00:02:25 +0000 | [diff] [blame] | 132 | ssize_t |
| 133 | n; |
| 134 | |
cristy | d0a94fa | 2010-03-12 14:18:11 +0000 | [diff] [blame] | 135 | (void) setlocale(LC_ALL,""); |
| 136 | (void) setlocale(LC_NUMERIC,"C"); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 137 | concurrent=MagickFalse; |
| 138 | duration=(-1.0); |
| 139 | iterations=1; |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 140 | status=MagickFalse; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 141 | regard_warnings=MagickFalse; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 142 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 143 | { |
| 144 | option=argv[i]; |
| 145 | if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) |
| 146 | continue; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 147 | if (LocaleCompare("-bench",option) == 0) |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 148 | iterations=StringToUnsignedLong(argv[++i]); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 149 | if (LocaleCompare("-concurrent",option) == 0) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 150 | concurrent=MagickTrue; |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 151 | if (LocaleCompare("-debug",option) == 0) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 152 | (void) SetLogEventMask(argv[++i]); |
cristy | 9305363 | 2013-01-06 23:55:19 +0000 | [diff] [blame] | 153 | if (LocaleCompare("-distribute-cache",option) == 0) |
cristy | 8f7950e | 2013-01-07 14:58:48 +0000 | [diff] [blame] | 154 | { |
cristy | e80f9cb | 2013-01-09 01:09:31 +0000 | [diff] [blame^] | 155 | PixelCacheServer(StringToUnsignedLong(argv[++i])); |
cristy | 8f7950e | 2013-01-07 14:58:48 +0000 | [diff] [blame] | 156 | exit(0); |
| 157 | } |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 158 | if (LocaleCompare("-duration",option) == 0) |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 159 | duration=StringToDouble(argv[++i],(char **) NULL); |
anthony | 8226e72 | 2012-04-05 14:25:46 +0000 | [diff] [blame] | 160 | if (LocaleCompare("-regard-warnings",option) == 0) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 161 | regard_warnings=MagickTrue; |
| 162 | } |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 163 | if (iterations == 1) |
| 164 | { |
| 165 | status=command(image_info,argc,argv,metadata,exception); |
| 166 | if (exception->severity != UndefinedException) |
| 167 | { |
| 168 | if ((exception->severity > ErrorException) || |
| 169 | (regard_warnings != MagickFalse)) |
| 170 | status=MagickTrue; |
| 171 | CatchException(exception); |
| 172 | } |
| 173 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 174 | { |
| 175 | (void) fputs(*metadata,stdout); |
| 176 | (void) fputc('\n',stdout); |
| 177 | *metadata=DestroyString(*metadata); |
| 178 | } |
| 179 | return(status); |
| 180 | } |
cristy | feeb98d | 2012-05-09 16:32:12 +0000 | [diff] [blame] | 181 | number_threads=GetOpenMPMaximumThreads(); |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 182 | serial=0.0; |
cristy | 118fc66 | 2012-02-11 00:02:25 +0000 | [diff] [blame] | 183 | for (n=1; n <= (ssize_t) number_threads; n++) |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 184 | { |
| 185 | double |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 186 | e, |
| 187 | parallel, |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 188 | user_time; |
| 189 | |
| 190 | TimerInfo |
| 191 | *timer; |
| 192 | |
cristy | 00f8723 | 2012-05-09 13:12:34 +0000 | [diff] [blame] | 193 | (void) SetMagickResourceLimit(ThreadResource,(MagickSizeType) n); |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 194 | timer=AcquireTimerInfo(); |
| 195 | if (concurrent == MagickFalse) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 196 | { |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 197 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 198 | { |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 199 | if (status != MagickFalse) |
| 200 | continue; |
| 201 | if (duration > 0) |
| 202 | { |
| 203 | if (GetElapsedTime(timer) > duration) |
| 204 | continue; |
| 205 | (void) ContinueTimer(timer); |
| 206 | } |
| 207 | status=command(image_info,argc,argv,metadata,exception); |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 208 | if (exception->severity != UndefinedException) |
| 209 | { |
| 210 | if ((exception->severity > ErrorException) || |
| 211 | (regard_warnings != MagickFalse)) |
| 212 | status=MagickTrue; |
| 213 | CatchException(exception); |
| 214 | } |
| 215 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 216 | { |
| 217 | (void) fputs(*metadata,stdout); |
| 218 | (void) fputc('\n',stdout); |
| 219 | *metadata=DestroyString(*metadata); |
| 220 | } |
| 221 | } |
| 222 | } |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 223 | else |
| 224 | { |
| 225 | SetOpenMPNested(1); |
| 226 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
| 227 | # pragma omp parallel for shared(status) |
| 228 | #endif |
| 229 | for (i=0; i < (ssize_t) iterations; i++) |
| 230 | { |
| 231 | if (status != MagickFalse) |
| 232 | continue; |
| 233 | if (duration > 0) |
| 234 | { |
| 235 | if (GetElapsedTime(timer) > duration) |
| 236 | continue; |
| 237 | (void) ContinueTimer(timer); |
| 238 | } |
| 239 | status=command(image_info,argc,argv,metadata,exception); |
| 240 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
| 241 | # pragma omp critical (MagickCore_CommandGenesis) |
| 242 | #endif |
| 243 | { |
| 244 | if (exception->severity != UndefinedException) |
| 245 | { |
| 246 | if ((exception->severity > ErrorException) || |
| 247 | (regard_warnings != MagickFalse)) |
| 248 | status=MagickTrue; |
| 249 | CatchException(exception); |
| 250 | } |
| 251 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 252 | { |
| 253 | (void) fputs(*metadata,stdout); |
| 254 | (void) fputc('\n',stdout); |
| 255 | *metadata=DestroyString(*metadata); |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | } |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 260 | user_time=GetUserTime(timer); |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 261 | parallel=GetElapsedTime(timer); |
| 262 | e=1.0; |
| 263 | if (n == 1) |
| 264 | serial=parallel; |
| 265 | else |
| 266 | e=((1.0/(1.0/((serial/(serial+parallel))+(1.0-(serial/(serial+parallel)))/ |
| 267 | (double) n)))-(1.0/(double) n))/(1.0-1.0/(double) n); |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 268 | (void) FormatLocaleFile(stderr, |
cristy | 91ce84d | 2011-12-09 23:02:25 +0000 | [diff] [blame] | 269 | "Performance[%.20g]: %.20gi %0.3fips %0.3fe %0.3fu %lu:%02lu.%03lu\n", |
cristy | 8ea926d | 2011-12-09 12:25:04 +0000 | [diff] [blame] | 270 | (double) n,(double) iterations,(double) iterations/parallel,e, |
| 271 | user_time,(unsigned long) (parallel/60.0),(unsigned long) |
| 272 | floor(fmod(parallel,60.0)),(unsigned long) |
| 273 | (1000.0*(parallel-floor(parallel))+0.5)); |
cristy | c2e3aeb | 2011-12-09 11:09:38 +0000 | [diff] [blame] | 274 | timer=DestroyTimerInfo(timer); |
| 275 | } |
cristy | 1f9e1ed | 2009-11-18 04:09:38 +0000 | [diff] [blame] | 276 | return(status); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | /* |
| 280 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 281 | % % |
| 282 | % % |
| 283 | % % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 284 | + M o g r i f y I m a g e % |
| 285 | % % |
| 286 | % % |
| 287 | % % |
| 288 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 289 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 290 | % MogrifyImage() applies simple single image processing options to a single |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 291 | % image that may be part of a large list, but also handles any 'region' |
| 292 | % image handling. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 293 | % |
| 294 | % The image in the list may be modified in three different ways... |
| 295 | % |
| 296 | % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 297 | % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 298 | % * replace by a list of images (only the -separate option!) |
| 299 | % |
| 300 | % In each case the result is returned into the list, and a pointer to the |
| 301 | % modified image (last image added if replaced by a list of images) is |
| 302 | % returned. |
| 303 | % |
| 304 | % ASIDE: The -crop is present but restricted to non-tile single image crops |
| 305 | % |
| 306 | % This means if all the images are being processed (such as by |
| 307 | % MogrifyImages(), next image to be processed will be as per the pointer |
| 308 | % (*image)->next. Also the image list may grow as a result of some specific |
| 309 | % operations but as images are never merged or deleted, it will never shrink |
| 310 | % in length. Typically the list will remain the same length. |
| 311 | % |
| 312 | % WARNING: As the image pointed to may be replaced, the first image in the |
| 313 | % list may also change. GetFirstImageInList() should be used by caller if |
| 314 | % they wish return the Image pointer to the first image in list. |
| 315 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 316 | % |
| 317 | % The format of the MogrifyImage method is: |
| 318 | % |
| 319 | % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 320 | % const char **argv,Image **image) |
| 321 | % |
| 322 | % A description of each parameter follows: |
| 323 | % |
| 324 | % o image_info: the image info.. |
| 325 | % |
| 326 | % o argc: Specifies a pointer to an integer describing the number of |
| 327 | % elements in the argument vector. |
| 328 | % |
| 329 | % o argv: Specifies a pointer to a text array containing the command line |
| 330 | % arguments. |
| 331 | % |
| 332 | % o image: the image. |
| 333 | % |
| 334 | % o exception: return any errors or warnings in this structure. |
| 335 | % |
| 336 | */ |
| 337 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 338 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 339 | ExceptionInfo *exception) |
| 340 | { |
| 341 | char |
| 342 | key[MaxTextExtent]; |
| 343 | |
| 344 | ExceptionInfo |
| 345 | *sans_exception; |
| 346 | |
| 347 | Image |
| 348 | *image; |
| 349 | |
| 350 | ImageInfo |
| 351 | *read_info; |
| 352 | |
cristy | fcd785b | 2011-11-08 01:48:33 +0000 | [diff] [blame] | 353 | /* |
anthony | 32d85bf | 2012-02-15 14:54:59 +0000 | [diff] [blame] | 354 | Read an image into a image cache (for repeated usage) if not already in |
| 355 | cache. Then return the image that is in the cache. |
cristy | fcd785b | 2011-11-08 01:48:33 +0000 | [diff] [blame] | 356 | */ |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 357 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 358 | sans_exception=AcquireExceptionInfo(); |
| 359 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 360 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 361 | if (image != (Image *) NULL) |
| 362 | return(image); |
| 363 | read_info=CloneImageInfo(image_info); |
| 364 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 365 | image=ReadImage(read_info,exception); |
| 366 | read_info=DestroyImageInfo(read_info); |
| 367 | if (image != (Image *) NULL) |
| 368 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 369 | return(image); |
| 370 | } |
| 371 | |
cristy | ba3c570 | 2012-06-27 13:30:13 +0000 | [diff] [blame] | 372 | static inline MagickBooleanType IsPathWritable(const char *path) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 373 | { |
| 374 | if (IsPathAccessible(path) == MagickFalse) |
| 375 | return(MagickFalse); |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 376 | if (access_utf8(path,W_OK) != 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 377 | return(MagickFalse); |
| 378 | return(MagickTrue); |
| 379 | } |
| 380 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 381 | static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 382 | { |
| 383 | if (x > y) |
| 384 | return(x); |
| 385 | return(y); |
| 386 | } |
| 387 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 388 | static MagickBooleanType MonitorProgress(const char *text, |
| 389 | const MagickOffsetType offset,const MagickSizeType extent, |
| 390 | void *wand_unused(client_data)) |
| 391 | { |
| 392 | char |
| 393 | message[MaxTextExtent], |
| 394 | tag[MaxTextExtent]; |
| 395 | |
| 396 | const char |
| 397 | *locale_message; |
| 398 | |
| 399 | register char |
| 400 | *p; |
| 401 | |
| 402 | if (extent < 2) |
| 403 | return(MagickTrue); |
| 404 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 405 | p=strrchr(tag,'/'); |
| 406 | if (p != (char *) NULL) |
| 407 | *p='\0'; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 408 | (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 409 | locale_message=GetLocaleMessage(message); |
| 410 | if (locale_message == message) |
| 411 | locale_message=tag; |
| 412 | if (p == (char *) NULL) |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 413 | (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", |
| 414 | locale_message,(long) offset,(unsigned long) extent,(long) |
| 415 | (100L*offset/(extent-1))); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 416 | else |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 417 | (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 418 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 419 | (100L*offset/(extent-1))); |
| 420 | if (offset == (MagickOffsetType) (extent-1)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 421 | (void) FormatLocaleFile(stderr,"\n"); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 422 | (void) fflush(stderr); |
| 423 | return(MagickTrue); |
| 424 | } |
| 425 | |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 426 | static Image *SparseColorOption(const Image *image, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 427 | const SparseColorMethod method,const char *arguments, |
| 428 | const MagickBooleanType color_from_image,ExceptionInfo *exception) |
| 429 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 430 | char |
| 431 | token[MaxTextExtent]; |
| 432 | |
| 433 | const char |
| 434 | *p; |
| 435 | |
| 436 | double |
| 437 | *sparse_arguments; |
| 438 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 439 | Image |
| 440 | *sparse_image; |
| 441 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 442 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 443 | color; |
| 444 | |
| 445 | MagickBooleanType |
| 446 | error; |
| 447 | |
cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 448 | register size_t |
| 449 | x; |
| 450 | |
| 451 | size_t |
| 452 | number_arguments, |
| 453 | number_colors; |
| 454 | |
cristy | f4425a7 | 2011-11-08 01:52:04 +0000 | [diff] [blame] | 455 | /* |
| 456 | SparseColorOption() parses the complex -sparse-color argument into an an |
| 457 | array of floating point values then calls SparseColorImage(). Argument is |
| 458 | a complex mix of floating-point pixel coodinates, and color specifications |
| 459 | (or direct floating point numbers). The number of floats needed to |
| 460 | represent a color varies depending on the current channel setting. |
| 461 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 462 | assert(image != (Image *) NULL); |
| 463 | assert(image->signature == MagickSignature); |
| 464 | if (image->debug != MagickFalse) |
| 465 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 466 | assert(exception != (ExceptionInfo *) NULL); |
| 467 | assert(exception->signature == MagickSignature); |
| 468 | /* |
| 469 | Limit channels according to image - and add up number of color channel. |
| 470 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 471 | number_colors=0; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 472 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 473 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 474 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 475 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 476 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 477 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 478 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 479 | (image->colorspace == CMYKColorspace)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 480 | number_colors++; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 481 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 482 | (image->alpha_trait == BlendPixelTrait)) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 483 | number_colors++; |
| 484 | |
| 485 | /* |
| 486 | Read string, to determine number of arguments needed, |
| 487 | */ |
| 488 | p=arguments; |
| 489 | x=0; |
| 490 | while( *p != '\0' ) |
| 491 | { |
| 492 | GetMagickToken(p,&p,token); |
| 493 | if ( token[0] == ',' ) continue; |
| 494 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 495 | if ( color_from_image ) { |
| 496 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | e5b3965 | 2012-04-21 05:37:29 +0000 | [diff] [blame] | 497 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 498 | "Color arg given, when colors are coming from image"); |
| 499 | return( (Image *)NULL); |
| 500 | } |
| 501 | x += number_colors; /* color argument */ |
| 502 | } |
| 503 | else { |
| 504 | x++; /* floating point argument */ |
| 505 | } |
| 506 | } |
| 507 | error=MagickTrue; |
| 508 | if ( color_from_image ) { |
| 509 | /* just the control points are being given */ |
| 510 | error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; |
| 511 | number_arguments=(x/2)*(2+number_colors); |
| 512 | } |
| 513 | else { |
| 514 | /* control points and color values */ |
| 515 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; |
| 516 | number_arguments=x; |
| 517 | } |
| 518 | if ( error ) { |
| 519 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | e5b3965 | 2012-04-21 05:37:29 +0000 | [diff] [blame] | 520 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 521 | "Invalid number of Arguments"); |
| 522 | return( (Image *)NULL); |
| 523 | } |
| 524 | |
| 525 | /* Allocate and fill in the floating point arguments */ |
| 526 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 527 | sizeof(*sparse_arguments)); |
| 528 | if (sparse_arguments == (double *) NULL) { |
| 529 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 530 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 531 | return( (Image *)NULL); |
| 532 | } |
| 533 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 534 | sizeof(*sparse_arguments)); |
| 535 | p=arguments; |
| 536 | x=0; |
| 537 | while( *p != '\0' && x < number_arguments ) { |
| 538 | /* X coordinate */ |
| 539 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 540 | if ( token[0] == '\0' ) break; |
| 541 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 542 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | e5b3965 | 2012-04-21 05:37:29 +0000 | [diff] [blame] | 543 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 544 | "Color found, instead of X-coord"); |
| 545 | error = MagickTrue; |
| 546 | break; |
| 547 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 548 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 549 | /* Y coordinate */ |
| 550 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 551 | if ( token[0] == '\0' ) break; |
| 552 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 553 | (void) ThrowMagickException(exception,GetMagickModule(), |
anthony | e5b3965 | 2012-04-21 05:37:29 +0000 | [diff] [blame] | 554 | OptionError, "InvalidArgument", "'%s': %s", "sparse-color", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 555 | "Color found, instead of Y-coord"); |
| 556 | error = MagickTrue; |
| 557 | break; |
| 558 | } |
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 | /* color values for this control point */ |
| 561 | #if 0 |
| 562 | if ( (color_from_image ) { |
| 563 | /* get color from image */ |
| 564 | /* HOW??? */ |
| 565 | } |
| 566 | else |
| 567 | #endif |
| 568 | { |
| 569 | /* color name or function given in string argument */ |
| 570 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 571 | if ( token[0] == '\0' ) break; |
| 572 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 573 | /* Color string given */ |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 574 | (void) QueryColorCompliance(token,AllCompliance,&color,exception); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 575 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 576 | sparse_arguments[x++] = QuantumScale*color.red; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 577 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 578 | sparse_arguments[x++] = QuantumScale*color.green; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 579 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 580 | sparse_arguments[x++] = QuantumScale*color.blue; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 581 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 582 | (image->colorspace == CMYKColorspace)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 583 | sparse_arguments[x++] = QuantumScale*color.black; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 584 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 585 | (image->alpha_trait == BlendPixelTrait)) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 586 | sparse_arguments[x++] = QuantumScale*color.alpha; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 587 | } |
| 588 | else { |
| 589 | /* Colors given as a set of floating point values - experimental */ |
| 590 | /* NB: token contains the first floating point value to use! */ |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 591 | if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 592 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 593 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 594 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 595 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 596 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 597 | token[0] = ','; /* used this token - get another */ |
| 598 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 599 | if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 600 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 601 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 602 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 603 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 604 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 605 | token[0] = ','; /* used this token - get another */ |
| 606 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 607 | if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 608 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 609 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 610 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 611 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 612 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 613 | token[0] = ','; /* used this token - get another */ |
| 614 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 615 | if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 616 | (image->colorspace == CMYKColorspace)) |
| 617 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 618 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 619 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 620 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 621 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 622 | token[0] = ','; /* used this token - get another */ |
| 623 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 624 | if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 625 | (image->alpha_trait == BlendPixelTrait)) |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 626 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 627 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 628 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 629 | break; |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 630 | sparse_arguments[x++]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 631 | token[0] = ','; /* used this token - get another */ |
| 632 | } |
| 633 | } |
| 634 | } |
| 635 | } |
| 636 | if ( number_arguments != x && !error ) { |
| 637 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
anthony | e5b3965 | 2012-04-21 05:37:29 +0000 | [diff] [blame] | 638 | "InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error"); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 639 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 640 | return( (Image *)NULL); |
| 641 | } |
| 642 | if ( error ) |
| 643 | return( (Image *)NULL); |
| 644 | |
| 645 | /* Call the Interpolation function with the parsed arguments */ |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 646 | sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, |
| 647 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 648 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 649 | return( sparse_image ); |
| 650 | } |
| 651 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 652 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 653 | const char **argv,Image **image,ExceptionInfo *exception) |
| 654 | { |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 655 | CompositeOperator |
| 656 | compose; |
| 657 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 658 | const char |
| 659 | *format, |
| 660 | *option; |
| 661 | |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 662 | double |
| 663 | attenuate; |
| 664 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 665 | DrawInfo |
| 666 | *draw_info; |
| 667 | |
| 668 | GeometryInfo |
| 669 | geometry_info; |
| 670 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 671 | Image |
| 672 | *region_image; |
| 673 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 674 | ImageInfo |
| 675 | *mogrify_info; |
| 676 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 677 | MagickStatusType |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 678 | status; |
| 679 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 680 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 681 | fill; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 682 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 683 | MagickStatusType |
| 684 | flags; |
| 685 | |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 686 | PixelInterpolateMethod |
| 687 | interpolate_method; |
| 688 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 689 | QuantizeInfo |
| 690 | *quantize_info; |
| 691 | |
| 692 | RectangleInfo |
| 693 | geometry, |
| 694 | region_geometry; |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame] | 695 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 696 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 697 | i; |
| 698 | |
| 699 | /* |
| 700 | Initialize method variables. |
| 701 | */ |
| 702 | assert(image_info != (const ImageInfo *) NULL); |
| 703 | assert(image_info->signature == MagickSignature); |
| 704 | assert(image != (Image **) NULL); |
| 705 | assert((*image)->signature == MagickSignature); |
| 706 | if ((*image)->debug != MagickFalse) |
| 707 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); |
| 708 | if (argc < 0) |
| 709 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 710 | mogrify_info=CloneImageInfo(image_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 711 | draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL); |
| 712 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 713 | SetGeometryInfo(&geometry_info); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 714 | GetPixelInfo(*image,&fill); |
cristy | 9d8c8ce | 2011-10-25 16:13:52 +0000 | [diff] [blame] | 715 | fill=(*image)->background_color; |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 716 | attenuate=1.0; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 717 | compose=(*image)->compose; |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 718 | interpolate_method=UndefinedInterpolatePixel; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 719 | format=GetImageOption(mogrify_info,"format"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 720 | SetGeometry(*image,®ion_geometry); |
| 721 | region_image=NewImageList(); |
| 722 | /* |
| 723 | Transmogrify the image. |
| 724 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 725 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 726 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 727 | Image |
| 728 | *mogrify_image; |
| 729 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 730 | ssize_t |
| 731 | count; |
| 732 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 733 | option=argv[i]; |
| 734 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 735 | continue; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 736 | count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option), |
| 737 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 738 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 739 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 740 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 741 | mogrify_image=(Image *)NULL; |
| 742 | switch (*(option+1)) |
| 743 | { |
| 744 | case 'a': |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 745 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 746 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 747 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 748 | /* |
| 749 | Adaptive blur image. |
| 750 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 751 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 752 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 753 | if ((flags & SigmaValue) == 0) |
| 754 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 755 | mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 756 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 757 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 758 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 759 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 760 | { |
| 761 | /* |
| 762 | Adaptive resize image. |
| 763 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 764 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 765 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 766 | mogrify_image=AdaptiveResizeImage(*image,geometry.width, |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 767 | geometry.height,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 768 | break; |
| 769 | } |
| 770 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 771 | { |
| 772 | /* |
| 773 | Adaptive sharpen image. |
| 774 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 775 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 776 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 777 | if ((flags & SigmaValue) == 0) |
| 778 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 779 | mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 780 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 781 | break; |
| 782 | } |
| 783 | if (LocaleCompare("affine",option+1) == 0) |
| 784 | { |
| 785 | /* |
| 786 | Affine matrix. |
| 787 | */ |
| 788 | if (*option == '+') |
| 789 | { |
| 790 | GetAffineMatrix(&draw_info->affine); |
| 791 | break; |
| 792 | } |
| 793 | (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); |
| 794 | break; |
| 795 | } |
| 796 | if (LocaleCompare("alpha",option+1) == 0) |
| 797 | { |
cristy | b15b06c | 2012-08-28 11:36:48 +0000 | [diff] [blame] | 798 | AlphaChannelOption |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 799 | alpha_type; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 800 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 801 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 8cdfb34 | 2012-11-11 21:44:36 +0000 | [diff] [blame] | 802 | alpha_type=(AlphaChannelOption) ParseCommandOption( |
| 803 | MagickAlphaChannelOptions,MagickFalse,argv[i+1]); |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 804 | (void) SetImageAlphaChannel(*image,alpha_type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 805 | break; |
| 806 | } |
| 807 | if (LocaleCompare("annotate",option+1) == 0) |
| 808 | { |
| 809 | char |
| 810 | *text, |
| 811 | geometry[MaxTextExtent]; |
| 812 | |
| 813 | /* |
| 814 | Annotate image. |
| 815 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 816 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 817 | SetGeometryInfo(&geometry_info); |
| 818 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 819 | if ((flags & SigmaValue) == 0) |
| 820 | geometry_info.sigma=geometry_info.rho; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 821 | text=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 822 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 823 | if (text == (char *) NULL) |
| 824 | break; |
| 825 | (void) CloneString(&draw_info->text,text); |
| 826 | text=DestroyString(text); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 827 | (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 828 | geometry_info.xi,geometry_info.psi); |
| 829 | (void) CloneString(&draw_info->geometry,geometry); |
| 830 | draw_info->affine.sx=cos(DegreesToRadians( |
| 831 | fmod(geometry_info.rho,360.0))); |
| 832 | draw_info->affine.rx=sin(DegreesToRadians( |
| 833 | fmod(geometry_info.rho,360.0))); |
| 834 | draw_info->affine.ry=(-sin(DegreesToRadians( |
| 835 | fmod(geometry_info.sigma,360.0)))); |
| 836 | draw_info->affine.sy=cos(DegreesToRadians( |
| 837 | fmod(geometry_info.sigma,360.0))); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 838 | (void) AnnotateImage(*image,draw_info,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 839 | break; |
| 840 | } |
| 841 | if (LocaleCompare("antialias",option+1) == 0) |
| 842 | { |
| 843 | draw_info->stroke_antialias=(*option == '-') ? MagickTrue : |
| 844 | MagickFalse; |
| 845 | draw_info->text_antialias=(*option == '-') ? MagickTrue : |
| 846 | MagickFalse; |
| 847 | break; |
| 848 | } |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 849 | if (LocaleCompare("attenuate",option+1) == 0) |
| 850 | { |
| 851 | if (*option == '+') |
| 852 | { |
| 853 | attenuate=1.0; |
| 854 | break; |
| 855 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 856 | attenuate=StringToDouble(argv[i+1],(char **) NULL); |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 857 | break; |
| 858 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 859 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 860 | { |
| 861 | /* |
| 862 | Auto Adjust Gamma of image based on its mean |
| 863 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 864 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9511120 | 2011-08-09 19:41:42 +0000 | [diff] [blame] | 865 | (void) AutoGammaImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 866 | break; |
| 867 | } |
| 868 | if (LocaleCompare("auto-level",option+1) == 0) |
| 869 | { |
| 870 | /* |
| 871 | Perfectly Normalize (max/min stretch) the image |
| 872 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 873 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9511120 | 2011-08-09 19:41:42 +0000 | [diff] [blame] | 874 | (void) AutoLevelImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 875 | break; |
| 876 | } |
| 877 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 878 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 879 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | fa5f6c7 | 2013-01-01 14:37:35 +0000 | [diff] [blame] | 880 | mogrify_image=AutoOrientImage(*image,(*image)->orientation, |
| 881 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 882 | break; |
| 883 | } |
| 884 | break; |
| 885 | } |
| 886 | case 'b': |
| 887 | { |
| 888 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 889 | { |
| 890 | /* |
| 891 | Black threshold image. |
| 892 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 893 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 894 | (void) BlackThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 895 | break; |
| 896 | } |
| 897 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 898 | { |
| 899 | /* |
| 900 | Blue shift image. |
| 901 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 902 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 903 | geometry_info.rho=1.5; |
| 904 | if (*option == '-') |
| 905 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 906 | mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception); |
| 907 | break; |
| 908 | } |
| 909 | if (LocaleCompare("blur",option+1) == 0) |
| 910 | { |
| 911 | /* |
| 912 | Gaussian blur image. |
| 913 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 914 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 915 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 916 | if ((flags & SigmaValue) == 0) |
| 917 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 918 | if ((flags & XiValue) == 0) |
| 919 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 920 | mogrify_image=BlurImage(*image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 921 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 922 | break; |
| 923 | } |
| 924 | if (LocaleCompare("border",option+1) == 0) |
| 925 | { |
| 926 | /* |
| 927 | Surround image with a border of solid color. |
| 928 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 929 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 930 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 931 | mogrify_image=BorderImage(*image,&geometry,compose,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 932 | break; |
| 933 | } |
| 934 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 935 | { |
| 936 | if (*option == '+') |
| 937 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 938 | (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 939 | &draw_info->border_color,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 940 | break; |
| 941 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 942 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 943 | &draw_info->border_color,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 944 | break; |
| 945 | } |
| 946 | if (LocaleCompare("box",option+1) == 0) |
| 947 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 948 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 949 | &draw_info->undercolor,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 950 | break; |
| 951 | } |
| 952 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 953 | { |
| 954 | double |
| 955 | brightness, |
| 956 | contrast; |
| 957 | |
| 958 | GeometryInfo |
| 959 | geometry_info; |
| 960 | |
| 961 | MagickStatusType |
| 962 | flags; |
| 963 | |
| 964 | /* |
| 965 | Brightness / contrast image. |
| 966 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 967 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 968 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 969 | brightness=geometry_info.rho; |
| 970 | contrast=0.0; |
| 971 | if ((flags & SigmaValue) != 0) |
| 972 | contrast=geometry_info.sigma; |
cristy | 444eda6 | 2011-08-10 02:07:46 +0000 | [diff] [blame] | 973 | (void) BrightnessContrastImage(*image,brightness,contrast, |
| 974 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 975 | break; |
| 976 | } |
| 977 | break; |
| 978 | } |
| 979 | case 'c': |
| 980 | { |
| 981 | if (LocaleCompare("cdl",option+1) == 0) |
| 982 | { |
| 983 | char |
| 984 | *color_correction_collection; |
| 985 | |
| 986 | /* |
| 987 | Color correct with a color decision list. |
| 988 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 989 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 990 | color_correction_collection=FileToString(argv[i+1],~0,exception); |
| 991 | if (color_correction_collection == (char *) NULL) |
| 992 | break; |
cristy | 1bfa9f0 | 2011-08-11 02:35:43 +0000 | [diff] [blame] | 993 | (void) ColorDecisionListImage(*image,color_correction_collection, |
| 994 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 995 | break; |
| 996 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 997 | if (LocaleCompare("charcoal",option+1) == 0) |
| 998 | { |
| 999 | /* |
| 1000 | Charcoal image. |
| 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 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1004 | if ((flags & SigmaValue) == 0) |
| 1005 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 1006 | if ((flags & XiValue) == 0) |
| 1007 | geometry_info.xi=1.0; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1008 | mogrify_image=CharcoalImage(*image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1009 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1010 | break; |
| 1011 | } |
| 1012 | if (LocaleCompare("chop",option+1) == 0) |
| 1013 | { |
| 1014 | /* |
| 1015 | Chop the image. |
| 1016 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1017 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1018 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1019 | mogrify_image=ChopImage(*image,&geometry,exception); |
| 1020 | break; |
| 1021 | } |
cristy | 7884a93 | 2012-11-04 14:33:51 +0000 | [diff] [blame] | 1022 | if (LocaleCompare("perceptible",option+1) == 0) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1023 | { |
| 1024 | /* |
cristy | 7884a93 | 2012-11-04 14:33:51 +0000 | [diff] [blame] | 1025 | Perceptible image. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1026 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1027 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 7884a93 | 2012-11-04 14:33:51 +0000 | [diff] [blame] | 1028 | (void) PerceptibleImage(*image,StringToDouble(argv[i+1], |
| 1029 | (char **) NULL),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1030 | break; |
| 1031 | } |
| 1032 | if (LocaleCompare("clip",option+1) == 0) |
| 1033 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1034 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1035 | if (*option == '+') |
| 1036 | { |
cristy | 10a6c61 | 2012-01-29 21:41:05 +0000 | [diff] [blame] | 1037 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1038 | break; |
| 1039 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1040 | (void) ClipImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1041 | break; |
| 1042 | } |
| 1043 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1044 | { |
| 1045 | CacheView |
| 1046 | *mask_view; |
| 1047 | |
| 1048 | Image |
| 1049 | *mask_image; |
| 1050 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1051 | register Quantum |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1052 | *restrict q; |
| 1053 | |
| 1054 | register ssize_t |
| 1055 | x; |
| 1056 | |
| 1057 | ssize_t |
| 1058 | y; |
| 1059 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1060 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1061 | if (*option == '+') |
| 1062 | { |
| 1063 | /* |
| 1064 | Remove a mask. |
| 1065 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1066 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1067 | break; |
| 1068 | } |
| 1069 | /* |
| 1070 | Set the image mask. |
| 1071 | FUTURE: This Should Be a SetImageAlphaChannel() call, Or two. |
| 1072 | */ |
| 1073 | mask_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1074 | if (mask_image == (Image *) NULL) |
| 1075 | break; |
cristy | 574cc26 | 2011-08-05 01:23:58 +0000 | [diff] [blame] | 1076 | if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1077 | return(MagickFalse); |
cristy | 46ff267 | 2012-12-14 15:32:26 +0000 | [diff] [blame] | 1078 | mask_view=AcquireAuthenticCacheView(mask_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1079 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1080 | { |
| 1081 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1082 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 1083 | if (q == (Quantum *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1084 | break; |
| 1085 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1086 | { |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 1087 | if (mask_image->alpha_trait != BlendPixelTrait) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1088 | SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); |
| 1089 | SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1090 | SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); |
| 1091 | SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1092 | q+=GetPixelChannels(mask_image); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1093 | } |
| 1094 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
| 1095 | break; |
| 1096 | } |
| 1097 | mask_view=DestroyCacheView(mask_view); |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 1098 | mask_image->alpha_trait=BlendPixelTrait; |
cristy | 10a6c61 | 2012-01-29 21:41:05 +0000 | [diff] [blame] | 1099 | (void) SetImageMask(*image,mask_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1100 | break; |
| 1101 | } |
| 1102 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1103 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1104 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1105 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1106 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1107 | break; |
| 1108 | } |
| 1109 | if (LocaleCompare("colorize",option+1) == 0) |
| 1110 | { |
| 1111 | /* |
| 1112 | Colorize the image. |
| 1113 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1114 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | c7e6ff6 | 2011-10-03 13:46:11 +0000 | [diff] [blame] | 1115 | mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1116 | break; |
| 1117 | } |
| 1118 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1119 | { |
| 1120 | KernelInfo |
| 1121 | *kernel; |
| 1122 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1123 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1124 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1125 | if (kernel == (KernelInfo *) NULL) |
| 1126 | break; |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1127 | /* FUTURE: check on size of the matrix */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1128 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 1129 | kernel=DestroyKernelInfo(kernel); |
| 1130 | break; |
| 1131 | } |
| 1132 | if (LocaleCompare("colors",option+1) == 0) |
| 1133 | { |
| 1134 | /* |
| 1135 | Reduce the number of colors in the image. |
| 1136 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1137 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1138 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
| 1139 | if (quantize_info->number_colors == 0) |
| 1140 | break; |
| 1141 | if (((*image)->storage_class == DirectClass) || |
| 1142 | (*image)->colors > quantize_info->number_colors) |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1143 | (void) QuantizeImage(quantize_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1144 | else |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1145 | (void) CompressImageColormap(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1146 | break; |
| 1147 | } |
| 1148 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1149 | { |
| 1150 | ColorspaceType |
| 1151 | colorspace; |
| 1152 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1153 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1154 | if (*option == '+') |
| 1155 | { |
cristy | c511e88 | 2012-04-16 21:11:14 +0000 | [diff] [blame] | 1156 | (void) TransformImageColorspace(*image,sRGBColorspace, |
| 1157 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1158 | break; |
| 1159 | } |
| 1160 | colorspace=(ColorspaceType) ParseCommandOption( |
| 1161 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 1162 | (void) TransformImageColorspace(*image,colorspace,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1163 | break; |
| 1164 | } |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1165 | if (LocaleCompare("compose",option+1) == 0) |
| 1166 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1167 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1168 | compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions, |
| 1169 | MagickFalse,argv[i+1]); |
| 1170 | break; |
| 1171 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1172 | if (LocaleCompare("contrast",option+1) == 0) |
| 1173 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1174 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1175 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1176 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1177 | break; |
| 1178 | } |
| 1179 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1180 | { |
| 1181 | double |
| 1182 | black_point, |
| 1183 | white_point; |
| 1184 | |
| 1185 | MagickStatusType |
| 1186 | flags; |
| 1187 | |
| 1188 | /* |
| 1189 | Contrast stretch image. |
| 1190 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1191 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1192 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1193 | black_point=geometry_info.rho; |
| 1194 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1195 | black_point; |
| 1196 | if ((flags & PercentValue) != 0) |
| 1197 | { |
| 1198 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1199 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1200 | } |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 1201 | white_point=(double) (*image)->columns*(*image)->rows- |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1202 | white_point; |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 1203 | (void) ContrastStretchImage(*image,black_point,white_point, |
| 1204 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1205 | break; |
| 1206 | } |
| 1207 | if (LocaleCompare("convolve",option+1) == 0) |
| 1208 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1209 | KernelInfo |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1210 | *kernel_info; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1211 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1212 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1213 | kernel_info=AcquireKernelInfo(argv[i+1]); |
| 1214 | if (kernel_info == (KernelInfo *) NULL) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1215 | break; |
anthony | f46d426 | 2012-03-26 03:30:34 +0000 | [diff] [blame] | 1216 | /* kernel_info->bias=(*image)->bias; -- FUTURE: check this path! */ |
cristy | a12d8ba | 2012-04-29 16:33:41 +0000 | [diff] [blame] | 1217 | mogrify_image=MorphologyImage(*image,CorrelateMorphology,1, |
| 1218 | kernel_info,exception); |
cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1219 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1220 | break; |
| 1221 | } |
| 1222 | if (LocaleCompare("crop",option+1) == 0) |
| 1223 | { |
| 1224 | /* |
| 1225 | Crop a image to a smaller size |
| 1226 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1227 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1228 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1229 | break; |
| 1230 | } |
| 1231 | if (LocaleCompare("cycle",option+1) == 0) |
| 1232 | { |
| 1233 | /* |
| 1234 | Cycle an image colormap. |
| 1235 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1236 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1237 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1]), |
| 1238 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1239 | break; |
| 1240 | } |
| 1241 | break; |
| 1242 | } |
| 1243 | case 'd': |
| 1244 | { |
| 1245 | if (LocaleCompare("decipher",option+1) == 0) |
| 1246 | { |
| 1247 | StringInfo |
| 1248 | *passkey; |
| 1249 | |
| 1250 | /* |
| 1251 | Decipher pixels. |
| 1252 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1253 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1254 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1255 | if (passkey != (StringInfo *) NULL) |
| 1256 | { |
| 1257 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1258 | passkey=DestroyStringInfo(passkey); |
| 1259 | } |
| 1260 | break; |
| 1261 | } |
| 1262 | if (LocaleCompare("density",option+1) == 0) |
| 1263 | { |
| 1264 | /* |
| 1265 | Set image density. |
| 1266 | */ |
| 1267 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1268 | break; |
| 1269 | } |
| 1270 | if (LocaleCompare("depth",option+1) == 0) |
| 1271 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1272 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1273 | if (*option == '+') |
| 1274 | { |
cristy | 8a11cb1 | 2011-10-19 23:53:34 +0000 | [diff] [blame] | 1275 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1276 | break; |
| 1277 | } |
cristy | 8a11cb1 | 2011-10-19 23:53:34 +0000 | [diff] [blame] | 1278 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1]), |
| 1279 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1280 | break; |
| 1281 | } |
| 1282 | if (LocaleCompare("deskew",option+1) == 0) |
| 1283 | { |
| 1284 | double |
| 1285 | threshold; |
| 1286 | |
| 1287 | /* |
| 1288 | Straighten the image. |
| 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 | threshold=40.0*QuantumRange/100.0; |
| 1293 | else |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 1294 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 1295 | 1.0); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1296 | mogrify_image=DeskewImage(*image,threshold,exception); |
| 1297 | break; |
| 1298 | } |
| 1299 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1300 | { |
| 1301 | /* |
| 1302 | Reduce the speckles within an image. |
| 1303 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1304 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1305 | mogrify_image=DespeckleImage(*image,exception); |
| 1306 | break; |
| 1307 | } |
| 1308 | if (LocaleCompare("display",option+1) == 0) |
| 1309 | { |
| 1310 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1311 | break; |
| 1312 | } |
| 1313 | if (LocaleCompare("distort",option+1) == 0) |
| 1314 | { |
| 1315 | char |
| 1316 | *args, |
| 1317 | token[MaxTextExtent]; |
| 1318 | |
| 1319 | const char |
| 1320 | *p; |
| 1321 | |
| 1322 | DistortImageMethod |
| 1323 | method; |
| 1324 | |
| 1325 | double |
| 1326 | *arguments; |
| 1327 | |
| 1328 | register ssize_t |
| 1329 | x; |
| 1330 | |
| 1331 | size_t |
| 1332 | number_arguments; |
| 1333 | |
| 1334 | /* |
| 1335 | Distort image. |
| 1336 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1337 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1338 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, |
| 1339 | MagickFalse,argv[i+1]); |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1340 | if (method == ResizeDistortion) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1341 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1342 | double |
| 1343 | resize_args[2]; |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1344 | |
| 1345 | /* |
| 1346 | Special Case - Argument is actually a resize geometry! |
| 1347 | Convert that to an appropriate distortion argument array. |
| 1348 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1349 | (void) ParseRegionGeometry(*image,argv[i+2],&geometry, |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1350 | exception); |
| 1351 | resize_args[0]=(double) geometry.width; |
| 1352 | resize_args[1]=(double) geometry.height; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1353 | mogrify_image=DistortImage(*image,method,(size_t)2, |
cristy | 5683587 | 2011-11-06 01:19:13 +0000 | [diff] [blame] | 1354 | resize_args,MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1355 | break; |
| 1356 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1357 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1358 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1359 | if (args == (char *) NULL) |
| 1360 | break; |
| 1361 | p=(char *) args; |
| 1362 | for (x=0; *p != '\0'; x++) |
| 1363 | { |
| 1364 | GetMagickToken(p,&p,token); |
| 1365 | if (*token == ',') |
| 1366 | GetMagickToken(p,&p,token); |
| 1367 | } |
| 1368 | number_arguments=(size_t) x; |
| 1369 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1370 | sizeof(*arguments)); |
| 1371 | if (arguments == (double *) NULL) |
| 1372 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1373 | "MemoryAllocationFailed",(*image)->filename); |
| 1374 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1375 | sizeof(*arguments)); |
| 1376 | p=(char *) args; |
| 1377 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 1378 | { |
| 1379 | GetMagickToken(p,&p,token); |
| 1380 | if (*token == ',') |
| 1381 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1382 | arguments[x]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1383 | } |
| 1384 | args=DestroyString(args); |
| 1385 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
| 1386 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1387 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1388 | break; |
| 1389 | } |
| 1390 | if (LocaleCompare("dither",option+1) == 0) |
| 1391 | { |
| 1392 | if (*option == '+') |
| 1393 | { |
cristy | cbda611 | 2012-05-27 20:57:16 +0000 | [diff] [blame] | 1394 | quantize_info->dither_method=NoDitherMethod; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1395 | break; |
| 1396 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1397 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
| 1398 | MagickDitherOptions,MagickFalse,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1399 | break; |
| 1400 | } |
| 1401 | if (LocaleCompare("draw",option+1) == 0) |
| 1402 | { |
| 1403 | /* |
| 1404 | Draw image. |
| 1405 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1406 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1407 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1408 | (void) DrawImage(*image,draw_info,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1409 | break; |
| 1410 | } |
| 1411 | break; |
| 1412 | } |
| 1413 | case 'e': |
| 1414 | { |
| 1415 | if (LocaleCompare("edge",option+1) == 0) |
| 1416 | { |
| 1417 | /* |
| 1418 | Enhance edges in the image. |
| 1419 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1420 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1421 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1422 | if ((flags & SigmaValue) == 0) |
| 1423 | geometry_info.sigma=1.0; |
cristy | 8ae632d | 2011-09-05 17:29:53 +0000 | [diff] [blame] | 1424 | mogrify_image=EdgeImage(*image,geometry_info.rho, |
| 1425 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1426 | break; |
| 1427 | } |
| 1428 | if (LocaleCompare("emboss",option+1) == 0) |
| 1429 | { |
| 1430 | /* |
cristy | d89705a | 2012-01-20 02:52:24 +0000 | [diff] [blame] | 1431 | Emboss image. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1432 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1433 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1434 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1435 | if ((flags & SigmaValue) == 0) |
| 1436 | geometry_info.sigma=1.0; |
| 1437 | mogrify_image=EmbossImage(*image,geometry_info.rho, |
| 1438 | geometry_info.sigma,exception); |
| 1439 | break; |
| 1440 | } |
| 1441 | if (LocaleCompare("encipher",option+1) == 0) |
| 1442 | { |
| 1443 | StringInfo |
| 1444 | *passkey; |
| 1445 | |
| 1446 | /* |
| 1447 | Encipher pixels. |
| 1448 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1449 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1450 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1451 | if (passkey != (StringInfo *) NULL) |
| 1452 | { |
| 1453 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1454 | passkey=DestroyStringInfo(passkey); |
| 1455 | } |
| 1456 | break; |
| 1457 | } |
| 1458 | if (LocaleCompare("encoding",option+1) == 0) |
| 1459 | { |
| 1460 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1461 | break; |
| 1462 | } |
| 1463 | if (LocaleCompare("enhance",option+1) == 0) |
| 1464 | { |
| 1465 | /* |
| 1466 | Enhance image. |
| 1467 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1468 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1469 | mogrify_image=EnhanceImage(*image,exception); |
| 1470 | break; |
| 1471 | } |
| 1472 | if (LocaleCompare("equalize",option+1) == 0) |
| 1473 | { |
| 1474 | /* |
| 1475 | Equalize image. |
| 1476 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1477 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 6d8c3d7 | 2011-08-22 01:20:01 +0000 | [diff] [blame] | 1478 | (void) EqualizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1479 | break; |
| 1480 | } |
| 1481 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1482 | { |
| 1483 | double |
| 1484 | constant; |
| 1485 | |
| 1486 | MagickEvaluateOperator |
| 1487 | op; |
| 1488 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1489 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1490 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 1491 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 1492 | constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+ |
| 1493 | 1.0); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1494 | (void) EvaluateImage(*image,op,constant,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1495 | break; |
| 1496 | } |
| 1497 | if (LocaleCompare("extent",option+1) == 0) |
| 1498 | { |
| 1499 | /* |
| 1500 | Set the image extent. |
| 1501 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1502 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1503 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1504 | if (geometry.width == 0) |
| 1505 | geometry.width=(*image)->columns; |
| 1506 | if (geometry.height == 0) |
| 1507 | geometry.height=(*image)->rows; |
| 1508 | mogrify_image=ExtentImage(*image,&geometry,exception); |
| 1509 | break; |
| 1510 | } |
| 1511 | break; |
| 1512 | } |
| 1513 | case 'f': |
| 1514 | { |
| 1515 | if (LocaleCompare("family",option+1) == 0) |
| 1516 | { |
| 1517 | if (*option == '+') |
| 1518 | { |
| 1519 | if (draw_info->family != (char *) NULL) |
| 1520 | draw_info->family=DestroyString(draw_info->family); |
| 1521 | break; |
| 1522 | } |
| 1523 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1524 | break; |
| 1525 | } |
| 1526 | if (LocaleCompare("features",option+1) == 0) |
| 1527 | { |
| 1528 | if (*option == '+') |
| 1529 | { |
| 1530 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1531 | break; |
| 1532 | } |
| 1533 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1534 | break; |
| 1535 | } |
| 1536 | if (LocaleCompare("fill",option+1) == 0) |
| 1537 | { |
| 1538 | ExceptionInfo |
| 1539 | *sans; |
| 1540 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1541 | PixelInfo |
| 1542 | color; |
| 1543 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1544 | GetPixelInfo(*image,&fill); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1545 | if (*option == '+') |
| 1546 | { |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1547 | (void) QueryColorCompliance("none",AllCompliance,&fill, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1548 | exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1549 | draw_info->fill=fill; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1550 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1551 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1552 | break; |
| 1553 | } |
| 1554 | sans=AcquireExceptionInfo(); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1555 | status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1556 | sans=DestroyExceptionInfo(sans); |
| 1557 | if (status == MagickFalse) |
| 1558 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 1559 | exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1560 | else |
| 1561 | draw_info->fill=fill=color; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1562 | break; |
| 1563 | } |
| 1564 | if (LocaleCompare("flip",option+1) == 0) |
| 1565 | { |
| 1566 | /* |
| 1567 | Flip image scanlines. |
| 1568 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1569 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1570 | mogrify_image=FlipImage(*image,exception); |
| 1571 | break; |
| 1572 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1573 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1574 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1575 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1576 | target; |
| 1577 | |
| 1578 | /* |
| 1579 | Floodfill image. |
| 1580 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1581 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1582 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1583 | (void) QueryColorCompliance(argv[i+2],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1584 | exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1585 | (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x, |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 1586 | geometry.y,*option == '-' ? MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1587 | break; |
| 1588 | } |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1589 | if (LocaleCompare("flop",option+1) == 0) |
| 1590 | { |
| 1591 | /* |
| 1592 | Flop image scanlines. |
| 1593 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1594 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1595 | mogrify_image=FlopImage(*image,exception); |
| 1596 | break; |
| 1597 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1598 | if (LocaleCompare("font",option+1) == 0) |
| 1599 | { |
| 1600 | if (*option == '+') |
| 1601 | { |
| 1602 | if (draw_info->font != (char *) NULL) |
| 1603 | draw_info->font=DestroyString(draw_info->font); |
| 1604 | break; |
| 1605 | } |
| 1606 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1607 | break; |
| 1608 | } |
| 1609 | if (LocaleCompare("format",option+1) == 0) |
| 1610 | { |
| 1611 | format=argv[i+1]; |
| 1612 | break; |
| 1613 | } |
| 1614 | if (LocaleCompare("frame",option+1) == 0) |
| 1615 | { |
| 1616 | FrameInfo |
| 1617 | frame_info; |
| 1618 | |
| 1619 | /* |
| 1620 | Surround image with an ornamental border. |
| 1621 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1622 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1623 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1624 | frame_info.width=geometry.width; |
| 1625 | frame_info.height=geometry.height; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1626 | frame_info.outer_bevel=geometry.x; |
| 1627 | frame_info.inner_bevel=geometry.y; |
| 1628 | frame_info.x=(ssize_t) frame_info.width; |
| 1629 | frame_info.y=(ssize_t) frame_info.height; |
| 1630 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1631 | frame_info.height=(*image)->rows+2*frame_info.height; |
cristy | 633f0c6 | 2011-09-15 13:27:36 +0000 | [diff] [blame] | 1632 | mogrify_image=FrameImage(*image,&frame_info,compose,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1633 | break; |
| 1634 | } |
| 1635 | if (LocaleCompare("function",option+1) == 0) |
| 1636 | { |
| 1637 | char |
| 1638 | *arguments, |
| 1639 | token[MaxTextExtent]; |
| 1640 | |
| 1641 | const char |
| 1642 | *p; |
| 1643 | |
| 1644 | double |
| 1645 | *parameters; |
| 1646 | |
| 1647 | MagickFunction |
| 1648 | function; |
| 1649 | |
| 1650 | register ssize_t |
| 1651 | x; |
| 1652 | |
| 1653 | size_t |
| 1654 | number_parameters; |
| 1655 | |
| 1656 | /* |
| 1657 | Function Modify Image Values |
| 1658 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1659 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1660 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, |
| 1661 | MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1662 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 1663 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1664 | if (arguments == (char *) NULL) |
| 1665 | break; |
| 1666 | p=(char *) arguments; |
| 1667 | for (x=0; *p != '\0'; x++) |
| 1668 | { |
| 1669 | GetMagickToken(p,&p,token); |
| 1670 | if (*token == ',') |
| 1671 | GetMagickToken(p,&p,token); |
| 1672 | } |
| 1673 | number_parameters=(size_t) x; |
| 1674 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1675 | sizeof(*parameters)); |
| 1676 | if (parameters == (double *) NULL) |
| 1677 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1678 | "MemoryAllocationFailed",(*image)->filename); |
| 1679 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1680 | sizeof(*parameters)); |
| 1681 | p=(char *) arguments; |
| 1682 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
| 1683 | { |
| 1684 | GetMagickToken(p,&p,token); |
| 1685 | if (*token == ',') |
| 1686 | GetMagickToken(p,&p,token); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1687 | parameters[x]=StringToDouble(token,(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1688 | } |
| 1689 | arguments=DestroyString(arguments); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1690 | (void) FunctionImage(*image,function,number_parameters,parameters, |
| 1691 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1692 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1693 | break; |
| 1694 | } |
| 1695 | break; |
| 1696 | } |
| 1697 | case 'g': |
| 1698 | { |
| 1699 | if (LocaleCompare("gamma",option+1) == 0) |
| 1700 | { |
| 1701 | /* |
| 1702 | Gamma image. |
| 1703 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1704 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1705 | if (*option == '+') |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1706 | (*image)->gamma=StringToDouble(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1707 | else |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 1708 | (void) GammaImage(*image,StringToDouble(argv[i+1], |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 1709 | (char **) NULL),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1710 | break; |
| 1711 | } |
| 1712 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1713 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1714 | { |
| 1715 | /* |
| 1716 | Gaussian blur image. |
| 1717 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1718 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1719 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1720 | if ((flags & SigmaValue) == 0) |
| 1721 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1722 | mogrify_image=GaussianBlurImage(*image,geometry_info.rho, |
cristy | d89705a | 2012-01-20 02:52:24 +0000 | [diff] [blame] | 1723 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1724 | break; |
| 1725 | } |
| 1726 | if (LocaleCompare("geometry",option+1) == 0) |
| 1727 | { |
| 1728 | /* |
| 1729 | Record Image offset, Resize last image. |
| 1730 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1731 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1732 | if (*option == '+') |
| 1733 | { |
| 1734 | if ((*image)->geometry != (char *) NULL) |
| 1735 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1736 | break; |
| 1737 | } |
| 1738 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1739 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1740 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1741 | else |
| 1742 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 1743 | (*image)->filter,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1744 | break; |
| 1745 | } |
| 1746 | if (LocaleCompare("gravity",option+1) == 0) |
| 1747 | { |
| 1748 | if (*option == '+') |
| 1749 | { |
| 1750 | draw_info->gravity=UndefinedGravity; |
| 1751 | break; |
| 1752 | } |
| 1753 | draw_info->gravity=(GravityType) ParseCommandOption( |
| 1754 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1755 | break; |
| 1756 | } |
| 1757 | break; |
| 1758 | } |
| 1759 | case 'h': |
| 1760 | { |
| 1761 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1762 | { |
| 1763 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1764 | break; |
| 1765 | } |
| 1766 | break; |
| 1767 | } |
| 1768 | case 'i': |
| 1769 | { |
| 1770 | if (LocaleCompare("identify",option+1) == 0) |
| 1771 | { |
| 1772 | char |
| 1773 | *text; |
| 1774 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1775 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1776 | if (format == (char *) NULL) |
| 1777 | { |
cristy | a403727 | 2011-08-28 15:11:39 +0000 | [diff] [blame] | 1778 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose, |
| 1779 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1780 | break; |
| 1781 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1782 | text=InterpretImageProperties(mogrify_info,*image,format, |
| 1783 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1784 | if (text == (char *) NULL) |
| 1785 | break; |
| 1786 | (void) fputs(text,stdout); |
| 1787 | (void) fputc('\n',stdout); |
| 1788 | text=DestroyString(text); |
| 1789 | break; |
| 1790 | } |
| 1791 | if (LocaleCompare("implode",option+1) == 0) |
| 1792 | { |
| 1793 | /* |
| 1794 | Implode image. |
| 1795 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1796 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1797 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 76f512e | 2011-09-12 01:26:56 +0000 | [diff] [blame] | 1798 | mogrify_image=ImplodeImage(*image,geometry_info.rho, |
| 1799 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1800 | break; |
| 1801 | } |
| 1802 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1803 | { |
| 1804 | if (*option == '+') |
| 1805 | (void) ParseGeometry("0",&geometry_info); |
| 1806 | else |
| 1807 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1808 | draw_info->interline_spacing=geometry_info.rho; |
| 1809 | break; |
| 1810 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 1811 | if (LocaleCompare("interpolate",option+1) == 0) |
| 1812 | { |
| 1813 | interpolate_method=(PixelInterpolateMethod) ParseCommandOption( |
| 1814 | MagickInterpolateOptions,MagickFalse,argv[i+1]); |
| 1815 | break; |
| 1816 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1817 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1818 | { |
| 1819 | if (*option == '+') |
| 1820 | (void) ParseGeometry("0",&geometry_info); |
| 1821 | else |
| 1822 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1823 | draw_info->interword_spacing=geometry_info.rho; |
| 1824 | break; |
| 1825 | } |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 1826 | if (LocaleCompare("interpolative-resize",option+1) == 0) |
| 1827 | { |
| 1828 | /* |
| 1829 | Interpolative resize image. |
| 1830 | */ |
| 1831 | (void) SyncImageSettings(mogrify_info,*image,exception); |
| 1832 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1833 | mogrify_image=InterpolativeResizeImage(*image,geometry.width, |
| 1834 | geometry.height,interpolate_method,exception); |
| 1835 | break; |
| 1836 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1837 | break; |
| 1838 | } |
| 1839 | case 'k': |
| 1840 | { |
| 1841 | if (LocaleCompare("kerning",option+1) == 0) |
| 1842 | { |
| 1843 | if (*option == '+') |
| 1844 | (void) ParseGeometry("0",&geometry_info); |
| 1845 | else |
| 1846 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1847 | draw_info->kerning=geometry_info.rho; |
| 1848 | break; |
| 1849 | } |
| 1850 | break; |
| 1851 | } |
| 1852 | case 'l': |
| 1853 | { |
| 1854 | if (LocaleCompare("lat",option+1) == 0) |
| 1855 | { |
| 1856 | /* |
| 1857 | Local adaptive threshold image. |
| 1858 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1859 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1860 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1861 | if ((flags & PercentValue) != 0) |
| 1862 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 1863 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
cristy | de5cc63 | 2011-07-18 14:47:00 +0000 | [diff] [blame] | 1864 | geometry_info.rho,(size_t) geometry_info.sigma,(double) |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1865 | geometry_info.xi,exception); |
| 1866 | break; |
| 1867 | } |
| 1868 | if (LocaleCompare("level",option+1) == 0) |
| 1869 | { |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 1870 | double |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1871 | black_point, |
| 1872 | gamma, |
| 1873 | white_point; |
| 1874 | |
| 1875 | MagickStatusType |
| 1876 | flags; |
| 1877 | |
| 1878 | /* |
| 1879 | Parse levels. |
| 1880 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1881 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1882 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1883 | black_point=geometry_info.rho; |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 1884 | white_point=(double) QuantumRange; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1885 | if ((flags & SigmaValue) != 0) |
| 1886 | white_point=geometry_info.sigma; |
| 1887 | gamma=1.0; |
| 1888 | if ((flags & XiValue) != 0) |
| 1889 | gamma=geometry_info.xi; |
| 1890 | if ((flags & PercentValue) != 0) |
| 1891 | { |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 1892 | black_point*=(double) (QuantumRange/100.0); |
| 1893 | white_point*=(double) (QuantumRange/100.0); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1894 | } |
| 1895 | if ((flags & SigmaValue) == 0) |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 1896 | white_point=(double) QuantumRange-black_point; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1897 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1898 | (void) LevelizeImage(*image,black_point,white_point,gamma, |
| 1899 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1900 | else |
cristy | 01e9afd | 2011-08-10 17:38:41 +0000 | [diff] [blame] | 1901 | (void) LevelImage(*image,black_point,white_point,gamma, |
| 1902 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1903 | break; |
| 1904 | } |
| 1905 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1906 | { |
| 1907 | char |
| 1908 | token[MaxTextExtent]; |
| 1909 | |
| 1910 | const char |
| 1911 | *p; |
| 1912 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1913 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1914 | black_point, |
| 1915 | white_point; |
| 1916 | |
| 1917 | p=(const char *) argv[i+1]; |
| 1918 | GetMagickToken(p,&p,token); /* get black point color */ |
| 1919 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1920 | (void) QueryColorCompliance(token,AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1921 | &black_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1922 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1923 | (void) QueryColorCompliance("#000000",AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1924 | &black_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1925 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1926 | GetMagickToken(p,&p,token); |
| 1927 | if (*token == '\0') |
| 1928 | white_point=black_point; /* set everything to that color */ |
| 1929 | else |
| 1930 | { |
| 1931 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 1932 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 1933 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1934 | (void) QueryColorCompliance(token,AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1935 | &white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1936 | else |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 1937 | (void) QueryColorCompliance("#ffffff",AllCompliance, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 1938 | &white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1939 | } |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 1940 | (void) LevelImageColors(*image,&black_point,&white_point, |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 1941 | *option == '+' ? MagickTrue : MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1942 | break; |
| 1943 | } |
| 1944 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 1945 | { |
| 1946 | double |
| 1947 | black_point, |
| 1948 | white_point; |
| 1949 | |
| 1950 | MagickStatusType |
| 1951 | flags; |
| 1952 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1953 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1954 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1955 | black_point=geometry_info.rho; |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 1956 | white_point=(double) (*image)->columns*(*image)->rows; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1957 | if ((flags & SigmaValue) != 0) |
| 1958 | white_point=geometry_info.sigma; |
| 1959 | if ((flags & PercentValue) != 0) |
| 1960 | { |
| 1961 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1962 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1963 | } |
| 1964 | if ((flags & SigmaValue) == 0) |
cristy | a19f1d7 | 2012-08-07 18:24:38 +0000 | [diff] [blame] | 1965 | white_point=(double) (*image)->columns*(*image)->rows- |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1966 | black_point; |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 1967 | (void) LinearStretchImage(*image,black_point,white_point,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1968 | break; |
| 1969 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1970 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 1971 | { |
| 1972 | /* |
| 1973 | Liquid rescale image. |
| 1974 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 1975 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1976 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1977 | if ((flags & XValue) == 0) |
| 1978 | geometry.x=1; |
| 1979 | if ((flags & YValue) == 0) |
| 1980 | geometry.y=0; |
| 1981 | mogrify_image=LiquidRescaleImage(*image,geometry.width, |
| 1982 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 1983 | break; |
| 1984 | } |
| 1985 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 1986 | { |
| 1987 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1988 | break; |
| 1989 | } |
| 1990 | break; |
| 1991 | } |
| 1992 | case 'm': |
| 1993 | { |
| 1994 | if (LocaleCompare("map",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1995 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1996 | Image |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1997 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1998 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1999 | /* |
| 2000 | Transform image colors to match this set of colors. |
| 2001 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2002 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2003 | if (*option == '+') |
| 2004 | break; |
| 2005 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2006 | if (remap_image == (Image *) NULL) |
| 2007 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2008 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2009 | remap_image=DestroyImage(remap_image); |
| 2010 | break; |
| 2011 | } |
| 2012 | if (LocaleCompare("mask",option+1) == 0) |
| 2013 | { |
| 2014 | Image |
| 2015 | *mask; |
| 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 | { |
| 2020 | /* |
| 2021 | Remove a mask. |
| 2022 | */ |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2023 | (void) SetImageMask(*image,(Image *) NULL,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2024 | break; |
| 2025 | } |
| 2026 | /* |
| 2027 | Set the image mask. |
| 2028 | */ |
| 2029 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2030 | if (mask == (Image *) NULL) |
| 2031 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2032 | (void) SetImageMask(*image,mask,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2033 | mask=DestroyImage(mask); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2034 | break; |
| 2035 | } |
| 2036 | if (LocaleCompare("matte",option+1) == 0) |
| 2037 | { |
| 2038 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
cristy | 6324088 | 2011-08-05 19:05:27 +0000 | [diff] [blame] | 2039 | SetAlphaChannel : DeactivateAlphaChannel,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2040 | break; |
| 2041 | } |
| 2042 | if (LocaleCompare("median",option+1) == 0) |
| 2043 | { |
| 2044 | /* |
| 2045 | Median filter image. |
| 2046 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2047 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2048 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2049 | if ((flags & SigmaValue) == 0) |
| 2050 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2051 | mogrify_image=StatisticImage(*image,MedianStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2052 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2053 | break; |
| 2054 | } |
| 2055 | if (LocaleCompare("mode",option+1) == 0) |
| 2056 | { |
| 2057 | /* |
| 2058 | Mode image. |
| 2059 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2060 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2061 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2062 | if ((flags & SigmaValue) == 0) |
| 2063 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2064 | mogrify_image=StatisticImage(*image,ModeStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2065 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2066 | break; |
| 2067 | } |
| 2068 | if (LocaleCompare("modulate",option+1) == 0) |
| 2069 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2070 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2071 | (void) ModulateImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2072 | break; |
| 2073 | } |
| 2074 | if (LocaleCompare("monitor",option+1) == 0) |
| 2075 | { |
| 2076 | if (*option == '+') |
| 2077 | { |
| 2078 | (void) SetImageProgressMonitor(*image, |
| 2079 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2080 | break; |
| 2081 | } |
| 2082 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2083 | (void *) NULL); |
| 2084 | break; |
| 2085 | } |
| 2086 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2087 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2088 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2089 | (void) SetImageType(*image,BilevelType,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2090 | break; |
| 2091 | } |
| 2092 | if (LocaleCompare("morphology",option+1) == 0) |
| 2093 | { |
| 2094 | char |
| 2095 | token[MaxTextExtent]; |
| 2096 | |
| 2097 | const char |
| 2098 | *p; |
| 2099 | |
| 2100 | KernelInfo |
| 2101 | *kernel; |
| 2102 | |
| 2103 | MorphologyMethod |
| 2104 | method; |
| 2105 | |
| 2106 | ssize_t |
| 2107 | iterations; |
| 2108 | |
| 2109 | /* |
| 2110 | Morphological Image Operation |
| 2111 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2112 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2113 | p=argv[i+1]; |
| 2114 | GetMagickToken(p,&p,token); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2115 | method=(MorphologyMethod) ParseCommandOption( |
| 2116 | MagickMorphologyOptions,MagickFalse,token); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2117 | iterations=1L; |
| 2118 | GetMagickToken(p,&p,token); |
| 2119 | if ((*p == ':') || (*p == ',')) |
| 2120 | GetMagickToken(p,&p,token); |
| 2121 | if ((*p != '\0')) |
| 2122 | iterations=(ssize_t) StringToLong(p); |
| 2123 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2124 | if (kernel == (KernelInfo *) NULL) |
| 2125 | { |
| 2126 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2127 | OptionError,"UnabletoParseKernel","morphology"); |
| 2128 | status=MagickFalse; |
| 2129 | break; |
| 2130 | } |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2131 | mogrify_image=MorphologyImage(*image,method,iterations,kernel, |
| 2132 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2133 | kernel=DestroyKernelInfo(kernel); |
| 2134 | break; |
| 2135 | } |
| 2136 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2137 | { |
| 2138 | /* |
| 2139 | Motion blur image. |
| 2140 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2141 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2142 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2143 | if ((flags & SigmaValue) == 0) |
| 2144 | geometry_info.sigma=1.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2145 | mogrify_image=MotionBlurImage(*image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2146 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2147 | break; |
| 2148 | } |
| 2149 | break; |
| 2150 | } |
| 2151 | case 'n': |
| 2152 | { |
| 2153 | if (LocaleCompare("negate",option+1) == 0) |
| 2154 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2155 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2156 | (void) NegateImage(*image,*option == '+' ? MagickTrue : |
cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 2157 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2158 | break; |
| 2159 | } |
| 2160 | if (LocaleCompare("noise",option+1) == 0) |
| 2161 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2162 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2163 | if (*option == '-') |
| 2164 | { |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2165 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2166 | if ((flags & SigmaValue) == 0) |
| 2167 | geometry_info.sigma=geometry_info.rho; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2168 | mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t) |
cristy | f36cbcb | 2011-09-07 13:28:22 +0000 | [diff] [blame] | 2169 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2170 | } |
| 2171 | else |
| 2172 | { |
| 2173 | NoiseType |
| 2174 | noise; |
| 2175 | |
| 2176 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
| 2177 | MagickFalse,argv[i+1]); |
cristy | 9ed1f81 | 2011-10-08 02:00:08 +0000 | [diff] [blame] | 2178 | mogrify_image=AddNoiseImage(*image,noise,attenuate,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2179 | } |
| 2180 | break; |
| 2181 | } |
| 2182 | if (LocaleCompare("normalize",option+1) == 0) |
| 2183 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2184 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | e23ec9d | 2011-08-16 18:15:40 +0000 | [diff] [blame] | 2185 | (void) NormalizeImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2186 | break; |
| 2187 | } |
| 2188 | break; |
| 2189 | } |
| 2190 | case 'o': |
| 2191 | { |
| 2192 | if (LocaleCompare("opaque",option+1) == 0) |
| 2193 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2194 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2195 | target; |
| 2196 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2197 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2198 | (void) QueryColorCompliance(argv[i+1],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2199 | exception); |
cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 2200 | (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ? |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 2201 | MagickFalse : MagickTrue,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2202 | break; |
| 2203 | } |
| 2204 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2205 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2206 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 1302067 | 2011-07-08 02:33:26 +0000 | [diff] [blame] | 2207 | (void) OrderedPosterizeImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2208 | break; |
| 2209 | } |
| 2210 | break; |
| 2211 | } |
| 2212 | case 'p': |
| 2213 | { |
| 2214 | if (LocaleCompare("paint",option+1) == 0) |
| 2215 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2216 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2217 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 14973ba | 2011-08-27 23:48:07 +0000 | [diff] [blame] | 2218 | mogrify_image=OilPaintImage(*image,geometry_info.rho, |
| 2219 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2220 | break; |
| 2221 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2222 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2223 | { |
| 2224 | if (*option == '+') |
| 2225 | (void) ParseGeometry("12",&geometry_info); |
| 2226 | else |
| 2227 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2228 | draw_info->pointsize=geometry_info.rho; |
| 2229 | break; |
| 2230 | } |
| 2231 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2232 | { |
cristy | e9e3d38 | 2011-12-14 01:50:13 +0000 | [diff] [blame] | 2233 | const char |
| 2234 | *caption; |
| 2235 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2236 | double |
| 2237 | angle; |
| 2238 | |
| 2239 | RandomInfo |
| 2240 | *random_info; |
| 2241 | |
| 2242 | /* |
| 2243 | Simulate a Polaroid picture. |
| 2244 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2245 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2246 | random_info=AcquireRandomInfo(); |
| 2247 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2248 | random_info=DestroyRandomInfo(random_info); |
| 2249 | if (*option == '-') |
| 2250 | { |
| 2251 | SetGeometryInfo(&geometry_info); |
| 2252 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2253 | angle=geometry_info.rho; |
| 2254 | } |
cristy | e9e3d38 | 2011-12-14 01:50:13 +0000 | [diff] [blame] | 2255 | caption=GetImageProperty(*image,"caption",exception); |
| 2256 | mogrify_image=PolaroidImage(*image,draw_info,caption,angle, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2257 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2258 | break; |
| 2259 | } |
| 2260 | if (LocaleCompare("posterize",option+1) == 0) |
| 2261 | { |
| 2262 | /* |
| 2263 | Posterize image. |
| 2264 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2265 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2266 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
cristy | cbda611 | 2012-05-27 20:57:16 +0000 | [diff] [blame] | 2267 | quantize_info->dither_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2268 | break; |
| 2269 | } |
| 2270 | if (LocaleCompare("preview",option+1) == 0) |
| 2271 | { |
| 2272 | PreviewType |
| 2273 | preview_type; |
| 2274 | |
| 2275 | /* |
| 2276 | Preview image. |
| 2277 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2278 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2279 | if (*option == '+') |
| 2280 | preview_type=UndefinedPreview; |
| 2281 | else |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2282 | preview_type=(PreviewType) ParseCommandOption( |
| 2283 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2284 | mogrify_image=PreviewImage(*image,preview_type,exception); |
| 2285 | break; |
| 2286 | } |
| 2287 | if (LocaleCompare("profile",option+1) == 0) |
| 2288 | { |
| 2289 | const char |
| 2290 | *name; |
| 2291 | |
| 2292 | const StringInfo |
| 2293 | *profile; |
| 2294 | |
| 2295 | Image |
| 2296 | *profile_image; |
| 2297 | |
| 2298 | ImageInfo |
| 2299 | *profile_info; |
| 2300 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2301 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2302 | if (*option == '+') |
| 2303 | { |
| 2304 | /* |
| 2305 | Remove a profile from the image. |
| 2306 | */ |
| 2307 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
cristy | 092d71c | 2011-10-14 18:01:29 +0000 | [diff] [blame] | 2308 | NULL,0,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2309 | break; |
| 2310 | } |
| 2311 | /* |
| 2312 | Associate a profile with the image. |
| 2313 | */ |
| 2314 | profile_info=CloneImageInfo(mogrify_info); |
| 2315 | profile=GetImageProfile(*image,"iptc"); |
| 2316 | if (profile != (StringInfo *) NULL) |
| 2317 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2318 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2319 | profile_info=DestroyImageInfo(profile_info); |
| 2320 | if (profile_image == (Image *) NULL) |
| 2321 | { |
| 2322 | StringInfo |
| 2323 | *profile; |
| 2324 | |
| 2325 | profile_info=CloneImageInfo(mogrify_info); |
| 2326 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2327 | MaxTextExtent); |
| 2328 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
| 2329 | if (profile != (StringInfo *) NULL) |
| 2330 | { |
| 2331 | (void) ProfileImage(*image,profile_info->magick, |
| 2332 | GetStringInfoDatum(profile),(size_t) |
cristy | 3fac9ec | 2011-11-17 18:04:39 +0000 | [diff] [blame] | 2333 | GetStringInfoLength(profile),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2334 | profile=DestroyStringInfo(profile); |
| 2335 | } |
| 2336 | profile_info=DestroyImageInfo(profile_info); |
| 2337 | break; |
| 2338 | } |
| 2339 | ResetImageProfileIterator(profile_image); |
| 2340 | name=GetNextImageProfile(profile_image); |
| 2341 | while (name != (const char *) NULL) |
| 2342 | { |
| 2343 | profile=GetImageProfile(profile_image,name); |
| 2344 | if (profile != (StringInfo *) NULL) |
| 2345 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
cristy | 3fac9ec | 2011-11-17 18:04:39 +0000 | [diff] [blame] | 2346 | (size_t) GetStringInfoLength(profile),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2347 | name=GetNextImageProfile(profile_image); |
| 2348 | } |
| 2349 | profile_image=DestroyImage(profile_image); |
| 2350 | break; |
| 2351 | } |
| 2352 | break; |
| 2353 | } |
| 2354 | case 'q': |
| 2355 | { |
| 2356 | if (LocaleCompare("quantize",option+1) == 0) |
| 2357 | { |
| 2358 | if (*option == '+') |
| 2359 | { |
| 2360 | quantize_info->colorspace=UndefinedColorspace; |
| 2361 | break; |
| 2362 | } |
| 2363 | quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
| 2364 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2365 | break; |
| 2366 | } |
| 2367 | break; |
| 2368 | } |
| 2369 | case 'r': |
| 2370 | { |
| 2371 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2372 | { |
| 2373 | /* |
| 2374 | Radial blur image. |
| 2375 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2376 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 6435bd9 | 2011-09-10 02:10:07 +0000 | [diff] [blame] | 2377 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2378 | mogrify_image=RadialBlurImage(*image,geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2379 | break; |
| 2380 | } |
| 2381 | if (LocaleCompare("raise",option+1) == 0) |
| 2382 | { |
| 2383 | /* |
| 2384 | Surround image with a raise of solid color. |
| 2385 | */ |
| 2386 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2387 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
cristy | 6170ac3 | 2011-08-28 14:15:37 +0000 | [diff] [blame] | 2388 | MagickFalse,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2389 | break; |
| 2390 | } |
| 2391 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2392 | { |
| 2393 | /* |
| 2394 | Threshold image. |
| 2395 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2396 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2397 | (void) RandomThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2398 | break; |
| 2399 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2400 | if (LocaleCompare("region",option+1) == 0) |
| 2401 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2402 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2403 | if (region_image != (Image *) NULL) |
| 2404 | { |
| 2405 | /* |
| 2406 | Composite region. |
| 2407 | */ |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 2408 | (void) CompositeImage(region_image,*image, |
| 2409 | region_image->alpha_trait == BlendPixelTrait ? |
| 2410 | CopyCompositeOp : OverCompositeOp,MagickTrue, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 2411 | region_geometry.x,region_geometry.y,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2412 | *image=DestroyImage(*image); |
| 2413 | *image=region_image; |
| 2414 | region_image = (Image *) NULL; |
| 2415 | } |
| 2416 | if (*option == '+') |
| 2417 | break; |
| 2418 | /* |
| 2419 | Apply transformations to a selected region of the image. |
| 2420 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2421 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2422 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2423 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2424 | if (mogrify_image == (Image *) NULL) |
| 2425 | break; |
| 2426 | region_image=(*image); |
| 2427 | *image=mogrify_image; |
| 2428 | mogrify_image=(Image *) NULL; |
| 2429 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2430 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2431 | if (LocaleCompare("render",option+1) == 0) |
| 2432 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2433 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2434 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2435 | break; |
| 2436 | } |
| 2437 | if (LocaleCompare("remap",option+1) == 0) |
| 2438 | { |
| 2439 | Image |
| 2440 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2441 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2442 | /* |
| 2443 | Transform image colors to match this set of colors. |
| 2444 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2445 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2446 | if (*option == '+') |
| 2447 | break; |
| 2448 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2449 | if (remap_image == (Image *) NULL) |
| 2450 | break; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2451 | (void) RemapImage(quantize_info,*image,remap_image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2452 | remap_image=DestroyImage(remap_image); |
| 2453 | break; |
| 2454 | } |
| 2455 | if (LocaleCompare("repage",option+1) == 0) |
| 2456 | { |
| 2457 | if (*option == '+') |
| 2458 | { |
| 2459 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2460 | break; |
| 2461 | } |
| 2462 | (void) ResetImagePage(*image,argv[i+1]); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2463 | break; |
| 2464 | } |
| 2465 | if (LocaleCompare("resample",option+1) == 0) |
| 2466 | { |
| 2467 | /* |
| 2468 | Resample image. |
| 2469 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2470 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2471 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2472 | if ((flags & SigmaValue) == 0) |
| 2473 | geometry_info.sigma=geometry_info.rho; |
| 2474 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2475 | geometry_info.sigma,(*image)->filter,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2476 | break; |
| 2477 | } |
| 2478 | if (LocaleCompare("resize",option+1) == 0) |
| 2479 | { |
| 2480 | /* |
| 2481 | Resize image. |
| 2482 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2483 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2484 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2485 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2486 | (*image)->filter,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2487 | break; |
| 2488 | } |
| 2489 | if (LocaleCompare("roll",option+1) == 0) |
| 2490 | { |
| 2491 | /* |
| 2492 | Roll image. |
| 2493 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2494 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2495 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2496 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2497 | break; |
| 2498 | } |
| 2499 | if (LocaleCompare("rotate",option+1) == 0) |
| 2500 | { |
| 2501 | char |
| 2502 | *geometry; |
| 2503 | |
| 2504 | /* |
| 2505 | Check for conditional image rotation. |
| 2506 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2507 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2508 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2509 | if ((*image)->columns <= (*image)->rows) |
| 2510 | break; |
| 2511 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2512 | if ((*image)->columns >= (*image)->rows) |
| 2513 | break; |
| 2514 | /* |
| 2515 | Rotate image. |
| 2516 | */ |
| 2517 | geometry=ConstantString(argv[i+1]); |
| 2518 | (void) SubstituteString(&geometry,">",""); |
| 2519 | (void) SubstituteString(&geometry,"<",""); |
| 2520 | (void) ParseGeometry(geometry,&geometry_info); |
| 2521 | geometry=DestroyString(geometry); |
| 2522 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
| 2523 | break; |
| 2524 | } |
| 2525 | break; |
| 2526 | } |
| 2527 | case 's': |
| 2528 | { |
| 2529 | if (LocaleCompare("sample",option+1) == 0) |
| 2530 | { |
| 2531 | /* |
| 2532 | Sample image with pixel replication. |
| 2533 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2534 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2535 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2536 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
| 2537 | exception); |
| 2538 | break; |
| 2539 | } |
| 2540 | if (LocaleCompare("scale",option+1) == 0) |
| 2541 | { |
| 2542 | /* |
| 2543 | Resize image. |
| 2544 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2545 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2546 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2547 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2548 | exception); |
| 2549 | break; |
| 2550 | } |
| 2551 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2552 | { |
| 2553 | /* |
| 2554 | Selectively blur pixels within a contrast threshold. |
| 2555 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2556 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2557 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2558 | if ((flags & PercentValue) != 0) |
| 2559 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2560 | mogrify_image=SelectiveBlurImage(*image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2561 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2562 | break; |
| 2563 | } |
| 2564 | if (LocaleCompare("separate",option+1) == 0) |
| 2565 | { |
| 2566 | /* |
| 2567 | Break channels into separate images. |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2568 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2569 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | dfdb19e | 2012-03-21 22:22:24 +0000 | [diff] [blame] | 2570 | mogrify_image=SeparateImages(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2571 | break; |
| 2572 | } |
| 2573 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2574 | { |
| 2575 | double |
| 2576 | threshold; |
| 2577 | |
| 2578 | /* |
| 2579 | Sepia-tone image. |
| 2580 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2581 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2582 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 2583 | 1.0); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2584 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
| 2585 | break; |
| 2586 | } |
| 2587 | if (LocaleCompare("segment",option+1) == 0) |
| 2588 | { |
| 2589 | /* |
| 2590 | Segment image. |
| 2591 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2592 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2593 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2594 | if ((flags & SigmaValue) == 0) |
| 2595 | geometry_info.sigma=1.0; |
| 2596 | (void) SegmentImage(*image,(*image)->colorspace, |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2597 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma, |
| 2598 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2599 | break; |
| 2600 | } |
| 2601 | if (LocaleCompare("set",option+1) == 0) |
| 2602 | { |
| 2603 | char |
| 2604 | *value; |
| 2605 | |
| 2606 | /* |
| 2607 | Set image option. |
| 2608 | */ |
| 2609 | if (*option == '+') |
| 2610 | { |
| 2611 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2612 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2613 | else |
| 2614 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2615 | { |
| 2616 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
| 2617 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2618 | } |
| 2619 | else |
| 2620 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2621 | break; |
| 2622 | } |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2623 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2624 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2625 | if (value == (char *) NULL) |
| 2626 | break; |
| 2627 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2628 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2629 | exception); |
| 2630 | else |
| 2631 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2632 | { |
| 2633 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
| 2634 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
| 2635 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2636 | } |
| 2637 | else |
cristy | d15e659 | 2011-10-15 00:13:06 +0000 | [diff] [blame] | 2638 | (void) SetImageProperty(*image,argv[i+1],value,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2639 | value=DestroyString(value); |
| 2640 | break; |
| 2641 | } |
| 2642 | if (LocaleCompare("shade",option+1) == 0) |
| 2643 | { |
| 2644 | /* |
| 2645 | Shade image. |
| 2646 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2647 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2648 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2649 | if ((flags & SigmaValue) == 0) |
| 2650 | geometry_info.sigma=1.0; |
| 2651 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2652 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2653 | break; |
| 2654 | } |
| 2655 | if (LocaleCompare("shadow",option+1) == 0) |
| 2656 | { |
| 2657 | /* |
| 2658 | Shadow image. |
| 2659 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2660 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2661 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2662 | if ((flags & SigmaValue) == 0) |
| 2663 | geometry_info.sigma=1.0; |
| 2664 | if ((flags & XiValue) == 0) |
| 2665 | geometry_info.xi=4.0; |
| 2666 | if ((flags & PsiValue) == 0) |
| 2667 | geometry_info.psi=4.0; |
| 2668 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2669 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5), |
| 2670 | (ssize_t) ceil(geometry_info.psi-0.5),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2671 | break; |
| 2672 | } |
| 2673 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2674 | { |
| 2675 | /* |
| 2676 | Sharpen image. |
| 2677 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2678 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2679 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2680 | if ((flags & SigmaValue) == 0) |
| 2681 | geometry_info.sigma=1.0; |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 2682 | if ((flags & XiValue) == 0) |
| 2683 | geometry_info.xi=0.0; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2684 | mogrify_image=SharpenImage(*image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2685 | geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2686 | break; |
| 2687 | } |
| 2688 | if (LocaleCompare("shave",option+1) == 0) |
| 2689 | { |
| 2690 | /* |
| 2691 | Shave the image edges. |
| 2692 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2693 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2694 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2695 | mogrify_image=ShaveImage(*image,&geometry,exception); |
| 2696 | break; |
| 2697 | } |
| 2698 | if (LocaleCompare("shear",option+1) == 0) |
| 2699 | { |
| 2700 | /* |
| 2701 | Shear image. |
| 2702 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2703 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2704 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2705 | if ((flags & SigmaValue) == 0) |
| 2706 | geometry_info.sigma=geometry_info.rho; |
| 2707 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2708 | geometry_info.sigma,exception); |
| 2709 | break; |
| 2710 | } |
| 2711 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2712 | { |
| 2713 | /* |
| 2714 | Sigmoidal non-linearity contrast control. |
| 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=(double) QuantumRange/2.0; |
| 2720 | if ((flags & PercentValue) != 0) |
| 2721 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2722 | 100.0; |
cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 2723 | (void) SigmoidalContrastImage(*image,(*option == '-') ? |
cristy | 33bd515 | 2011-08-24 01:42:24 +0000 | [diff] [blame] | 2724 | MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma, |
| 2725 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2726 | break; |
| 2727 | } |
| 2728 | if (LocaleCompare("sketch",option+1) == 0) |
| 2729 | { |
| 2730 | /* |
| 2731 | Sketch image. |
| 2732 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2733 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2734 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2735 | if ((flags & SigmaValue) == 0) |
| 2736 | geometry_info.sigma=1.0; |
| 2737 | mogrify_image=SketchImage(*image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 2738 | geometry_info.sigma,geometry_info.xi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2739 | break; |
| 2740 | } |
| 2741 | if (LocaleCompare("solarize",option+1) == 0) |
| 2742 | { |
| 2743 | double |
| 2744 | threshold; |
| 2745 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2746 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2747 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 2748 | 1.0); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 2749 | (void) SolarizeImage(*image,threshold,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2750 | break; |
| 2751 | } |
| 2752 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2753 | { |
| 2754 | SparseColorMethod |
| 2755 | method; |
| 2756 | |
| 2757 | char |
| 2758 | *arguments; |
| 2759 | |
| 2760 | /* |
| 2761 | Sparse Color Interpolated Gradient |
| 2762 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2763 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2764 | method=(SparseColorMethod) ParseCommandOption( |
| 2765 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2766 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2], |
| 2767 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2768 | if (arguments == (char *) NULL) |
| 2769 | break; |
cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 2770 | mogrify_image=SparseColorOption(*image,method,arguments, |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2771 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2772 | arguments=DestroyString(arguments); |
| 2773 | break; |
| 2774 | } |
| 2775 | if (LocaleCompare("splice",option+1) == 0) |
| 2776 | { |
| 2777 | /* |
| 2778 | Splice a solid color into the image. |
| 2779 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2780 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2781 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 2782 | mogrify_image=SpliceImage(*image,&geometry,exception); |
| 2783 | break; |
| 2784 | } |
| 2785 | if (LocaleCompare("spread",option+1) == 0) |
| 2786 | { |
| 2787 | /* |
| 2788 | Spread an image. |
| 2789 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2790 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2791 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame] | 2792 | mogrify_image=SpreadImage(*image,geometry_info.rho, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2793 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2794 | break; |
| 2795 | } |
| 2796 | if (LocaleCompare("statistic",option+1) == 0) |
| 2797 | { |
| 2798 | StatisticType |
| 2799 | type; |
| 2800 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2801 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2802 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
| 2803 | MagickFalse,argv[i+1]); |
| 2804 | (void) ParseGeometry(argv[i+2],&geometry_info); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2805 | mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho, |
| 2806 | (size_t) geometry_info.sigma,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2807 | break; |
| 2808 | } |
| 2809 | if (LocaleCompare("stretch",option+1) == 0) |
| 2810 | { |
| 2811 | if (*option == '+') |
| 2812 | { |
| 2813 | draw_info->stretch=UndefinedStretch; |
| 2814 | break; |
| 2815 | } |
| 2816 | draw_info->stretch=(StretchType) ParseCommandOption( |
| 2817 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2818 | break; |
| 2819 | } |
| 2820 | if (LocaleCompare("strip",option+1) == 0) |
| 2821 | { |
| 2822 | /* |
| 2823 | Strip image of profiles and comments. |
| 2824 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2825 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 2826 | (void) StripImage(*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2827 | break; |
| 2828 | } |
| 2829 | if (LocaleCompare("stroke",option+1) == 0) |
| 2830 | { |
| 2831 | ExceptionInfo |
| 2832 | *sans; |
| 2833 | |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2834 | PixelInfo |
| 2835 | color; |
| 2836 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2837 | if (*option == '+') |
| 2838 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2839 | (void) QueryColorCompliance("none",AllCompliance, |
| 2840 | &draw_info->stroke,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2841 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2842 | draw_info->stroke_pattern=DestroyImage( |
| 2843 | draw_info->stroke_pattern); |
| 2844 | break; |
| 2845 | } |
| 2846 | sans=AcquireExceptionInfo(); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2847 | status=QueryColorCompliance(argv[i+1],AllCompliance,&color,sans); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2848 | sans=DestroyExceptionInfo(sans); |
| 2849 | if (status == MagickFalse) |
| 2850 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2851 | exception); |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 2852 | else |
| 2853 | draw_info->stroke=color; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2854 | break; |
| 2855 | } |
| 2856 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2857 | { |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2858 | draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2859 | break; |
| 2860 | } |
| 2861 | if (LocaleCompare("style",option+1) == 0) |
| 2862 | { |
| 2863 | if (*option == '+') |
| 2864 | { |
| 2865 | draw_info->style=UndefinedStyle; |
| 2866 | break; |
| 2867 | } |
| 2868 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 2869 | MagickFalse,argv[i+1]); |
| 2870 | break; |
| 2871 | } |
| 2872 | if (LocaleCompare("swirl",option+1) == 0) |
| 2873 | { |
| 2874 | /* |
| 2875 | Swirl image. |
| 2876 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2877 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2878 | (void) ParseGeometry(argv[i+1],&geometry_info); |
cristy | 76f512e | 2011-09-12 01:26:56 +0000 | [diff] [blame] | 2879 | mogrify_image=SwirlImage(*image,geometry_info.rho, |
| 2880 | interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2881 | break; |
| 2882 | } |
| 2883 | break; |
| 2884 | } |
| 2885 | case 't': |
| 2886 | { |
| 2887 | if (LocaleCompare("threshold",option+1) == 0) |
| 2888 | { |
| 2889 | double |
| 2890 | threshold; |
| 2891 | |
| 2892 | /* |
| 2893 | Threshold image. |
| 2894 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2895 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2896 | if (*option == '+') |
anthony | 247a86d | 2011-05-03 13:18:18 +0000 | [diff] [blame] | 2897 | threshold=(double) QuantumRange/2; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2898 | else |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 2899 | threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ |
| 2900 | 1.0); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 2901 | (void) BilevelImage(*image,threshold,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2902 | break; |
| 2903 | } |
| 2904 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2905 | { |
| 2906 | /* |
| 2907 | Thumbnail image. |
| 2908 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2909 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2910 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2911 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2912 | exception); |
| 2913 | break; |
| 2914 | } |
| 2915 | if (LocaleCompare("tile",option+1) == 0) |
| 2916 | { |
| 2917 | if (*option == '+') |
| 2918 | { |
| 2919 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2920 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2921 | break; |
| 2922 | } |
| 2923 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2924 | exception); |
| 2925 | break; |
| 2926 | } |
| 2927 | if (LocaleCompare("tint",option+1) == 0) |
| 2928 | { |
| 2929 | /* |
| 2930 | Tint the image. |
| 2931 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2932 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 2933 | mogrify_image=TintImage(*image,argv[i+1],&fill,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2934 | break; |
| 2935 | } |
| 2936 | if (LocaleCompare("transform",option+1) == 0) |
| 2937 | { |
| 2938 | /* |
| 2939 | Affine transform image. |
| 2940 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2941 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2942 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
| 2943 | exception); |
| 2944 | break; |
| 2945 | } |
| 2946 | if (LocaleCompare("transparent",option+1) == 0) |
| 2947 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2948 | PixelInfo |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2949 | target; |
| 2950 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2951 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 269c941 | 2011-10-13 23:41:15 +0000 | [diff] [blame] | 2952 | (void) QueryColorCompliance(argv[i+1],AllCompliance,&target, |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2953 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2954 | (void) TransparentPaintImage(*image,&target,(Quantum) |
cristy | 189e84c | 2011-08-27 18:08:53 +0000 | [diff] [blame] | 2955 | TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue, |
cristy | 82d7af5 | 2011-10-16 16:26:41 +0000 | [diff] [blame] | 2956 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2957 | break; |
| 2958 | } |
| 2959 | if (LocaleCompare("transpose",option+1) == 0) |
| 2960 | { |
| 2961 | /* |
| 2962 | Transpose image scanlines. |
| 2963 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2964 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2965 | mogrify_image=TransposeImage(*image,exception); |
| 2966 | break; |
| 2967 | } |
| 2968 | if (LocaleCompare("transverse",option+1) == 0) |
| 2969 | { |
| 2970 | /* |
| 2971 | Transverse image scanlines. |
| 2972 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2973 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2974 | mogrify_image=TransverseImage(*image,exception); |
| 2975 | break; |
| 2976 | } |
| 2977 | if (LocaleCompare("treedepth",option+1) == 0) |
| 2978 | { |
| 2979 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
| 2980 | break; |
| 2981 | } |
| 2982 | if (LocaleCompare("trim",option+1) == 0) |
| 2983 | { |
| 2984 | /* |
| 2985 | Trim image. |
| 2986 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2987 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2988 | mogrify_image=TrimImage(*image,exception); |
| 2989 | break; |
| 2990 | } |
| 2991 | if (LocaleCompare("type",option+1) == 0) |
| 2992 | { |
| 2993 | ImageType |
| 2994 | type; |
| 2995 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 2996 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2997 | if (*option == '+') |
| 2998 | type=UndefinedType; |
| 2999 | else |
| 3000 | type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 3001 | argv[i+1]); |
| 3002 | (*image)->type=UndefinedType; |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3003 | (void) SetImageType(*image,type,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3004 | break; |
| 3005 | } |
| 3006 | break; |
| 3007 | } |
| 3008 | case 'u': |
| 3009 | { |
| 3010 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3011 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 3012 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 3013 | &draw_info->undercolor,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3014 | break; |
| 3015 | } |
| 3016 | if (LocaleCompare("unique",option+1) == 0) |
| 3017 | { |
| 3018 | if (*option == '+') |
| 3019 | { |
| 3020 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
| 3021 | break; |
| 3022 | } |
| 3023 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
| 3024 | (void) SetImageArtifact(*image,"verbose","true"); |
| 3025 | break; |
| 3026 | } |
| 3027 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3028 | { |
| 3029 | /* |
| 3030 | Unique image colors. |
| 3031 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3032 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3033 | mogrify_image=UniqueImageColors(*image,exception); |
| 3034 | break; |
| 3035 | } |
| 3036 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3037 | { |
| 3038 | /* |
| 3039 | Unsharp mask image. |
| 3040 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3041 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3042 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3043 | if ((flags & SigmaValue) == 0) |
| 3044 | geometry_info.sigma=1.0; |
| 3045 | if ((flags & XiValue) == 0) |
| 3046 | geometry_info.xi=1.0; |
| 3047 | if ((flags & PsiValue) == 0) |
| 3048 | geometry_info.psi=0.05; |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3049 | mogrify_image=UnsharpMaskImage(*image,geometry_info.rho, |
| 3050 | geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3051 | break; |
| 3052 | } |
| 3053 | break; |
| 3054 | } |
| 3055 | case 'v': |
| 3056 | { |
| 3057 | if (LocaleCompare("verbose",option+1) == 0) |
| 3058 | { |
| 3059 | (void) SetImageArtifact(*image,option+1, |
| 3060 | *option == '+' ? "false" : "true"); |
| 3061 | break; |
| 3062 | } |
| 3063 | if (LocaleCompare("vignette",option+1) == 0) |
| 3064 | { |
| 3065 | /* |
| 3066 | Vignette image. |
| 3067 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3068 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3069 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3070 | if ((flags & SigmaValue) == 0) |
| 3071 | geometry_info.sigma=1.0; |
| 3072 | if ((flags & XiValue) == 0) |
| 3073 | geometry_info.xi=0.1*(*image)->columns; |
| 3074 | if ((flags & PsiValue) == 0) |
| 3075 | geometry_info.psi=0.1*(*image)->rows; |
| 3076 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
cristy | aa2c16c | 2012-03-25 22:21:35 +0000 | [diff] [blame] | 3077 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5), |
| 3078 | (ssize_t) ceil(geometry_info.psi-0.5),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3079 | break; |
| 3080 | } |
| 3081 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3082 | { |
| 3083 | if (*option == '+') |
| 3084 | { |
| 3085 | (void) SetImageVirtualPixelMethod(*image, |
cristy | 387430f | 2012-02-07 13:09:46 +0000 | [diff] [blame] | 3086 | UndefinedVirtualPixelMethod,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3087 | break; |
| 3088 | } |
| 3089 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3090 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 387430f | 2012-02-07 13:09:46 +0000 | [diff] [blame] | 3091 | argv[i+1]),exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3092 | break; |
| 3093 | } |
| 3094 | break; |
| 3095 | } |
| 3096 | case 'w': |
| 3097 | { |
| 3098 | if (LocaleCompare("wave",option+1) == 0) |
| 3099 | { |
| 3100 | /* |
| 3101 | Wave image. |
| 3102 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3103 | (void) SyncImageSettings(mogrify_info,*image,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3104 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3105 | if ((flags & SigmaValue) == 0) |
| 3106 | geometry_info.sigma=1.0; |
| 3107 | mogrify_image=WaveImage(*image,geometry_info.rho, |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 3108 | geometry_info.sigma,interpolate_method,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3109 | break; |
| 3110 | } |
| 3111 | if (LocaleCompare("weight",option+1) == 0) |
| 3112 | { |
| 3113 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
| 3114 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3115 | draw_info->weight=0; |
| 3116 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3117 | draw_info->weight=700; |
| 3118 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3119 | if (draw_info->weight <= 800) |
| 3120 | draw_info->weight+=100; |
| 3121 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3122 | if (draw_info->weight >= 100) |
| 3123 | draw_info->weight-=100; |
| 3124 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3125 | draw_info->weight=400; |
| 3126 | break; |
| 3127 | } |
| 3128 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3129 | { |
| 3130 | /* |
| 3131 | White threshold image. |
| 3132 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3133 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3134 | (void) WhiteThresholdImage(*image,argv[i+1],exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3135 | break; |
| 3136 | } |
| 3137 | break; |
| 3138 | } |
| 3139 | default: |
| 3140 | break; |
| 3141 | } |
| 3142 | /* |
| 3143 | Replace current image with any image that was generated |
| 3144 | */ |
| 3145 | if (mogrify_image != (Image *) NULL) |
| 3146 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3147 | i+=count; |
| 3148 | } |
| 3149 | if (region_image != (Image *) NULL) |
| 3150 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3151 | /* |
| 3152 | Composite transformed region onto image. |
| 3153 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 3154 | (void) SyncImageSettings(mogrify_info,*image,exception); |
cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 3155 | (void) CompositeImage(region_image,*image, |
| 3156 | region_image->alpha_trait == BlendPixelTrait ? CopyCompositeOp : |
| 3157 | OverCompositeOp,MagickTrue,region_geometry.x,region_geometry.y, |
| 3158 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3159 | *image=DestroyImage(*image); |
| 3160 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3161 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3162 | } |
| 3163 | /* |
| 3164 | Free resources. |
| 3165 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3166 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3167 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3168 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 82d7af5 | 2011-10-16 16:26:41 +0000 | [diff] [blame] | 3169 | status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3170 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3171 | } |
| 3172 | |
| 3173 | /* |
| 3174 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3175 | % % |
| 3176 | % % |
| 3177 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3178 | + 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] | 3179 | % % |
| 3180 | % % |
| 3181 | % % |
| 3182 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3183 | % |
| 3184 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3185 | % transforms include image scaling, image rotation, color reduction, and |
| 3186 | % others. The transmogrified image overwrites the original image. |
| 3187 | % |
| 3188 | % The format of the MogrifyImageCommand method is: |
| 3189 | % |
| 3190 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3191 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3192 | % |
| 3193 | % A description of each parameter follows: |
| 3194 | % |
| 3195 | % o image_info: the image info. |
| 3196 | % |
| 3197 | % o argc: the number of elements in the argument vector. |
| 3198 | % |
| 3199 | % o argv: A text array containing the command line arguments. |
| 3200 | % |
| 3201 | % o metadata: any metadata is returned here. |
| 3202 | % |
| 3203 | % o exception: return any errors or warnings in this structure. |
| 3204 | % |
| 3205 | */ |
| 3206 | |
| 3207 | static MagickBooleanType MogrifyUsage(void) |
| 3208 | { |
| 3209 | static const char |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3210 | *channel_operators[]= |
| 3211 | { |
cristy | 5f257b2 | 2012-03-07 00:27:29 +0000 | [diff] [blame] | 3212 | "-channel-fx expression", |
cristy | d04e7bf | 2012-03-03 19:19:12 +0000 | [diff] [blame] | 3213 | " exchange, extract, or transfer one or more image channels", |
cristy | dfdb19e | 2012-03-21 22:22:24 +0000 | [diff] [blame] | 3214 | "-separate separate an image channel into a grayscale image", |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3215 | (char *) NULL |
| 3216 | }, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3217 | *miscellaneous[]= |
| 3218 | { |
| 3219 | "-debug events display copious debugging information", |
cristy | 9305363 | 2013-01-06 23:55:19 +0000 | [diff] [blame] | 3220 | "-distribute-cache port", |
cristy | d79e236 | 2013-01-06 23:01:40 +0000 | [diff] [blame] | 3221 | " distributed pixel cache spanning one or more servers", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3222 | "-help print program options", |
| 3223 | "-list type print a list of supported option arguments", |
| 3224 | "-log format format of debugging information", |
| 3225 | "-version print version information", |
| 3226 | (char *) NULL |
| 3227 | }, |
| 3228 | *operators[]= |
| 3229 | { |
| 3230 | "-adaptive-blur geometry", |
| 3231 | " adaptively blur pixels; decrease effect near edges", |
| 3232 | "-adaptive-resize geometry", |
| 3233 | " adaptively resize image using 'mesh' interpolation", |
| 3234 | "-adaptive-sharpen geometry", |
| 3235 | " adaptively sharpen pixels; increase effect near edges", |
| 3236 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3237 | " transparent, extract, background, or shape", |
| 3238 | "-annotate geometry text", |
| 3239 | " annotate the image with text", |
| 3240 | "-auto-gamma automagically adjust gamma level of image", |
| 3241 | "-auto-level automagically adjust color levels of image", |
| 3242 | "-auto-orient automagically orient (rotate) image", |
| 3243 | "-bench iterations measure performance", |
| 3244 | "-black-threshold value", |
| 3245 | " force all pixels below the threshold into black", |
| 3246 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3247 | "-blur geometry reduce image noise and reduce detail levels", |
| 3248 | "-border geometry surround image with a border of color", |
| 3249 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3250 | "-brightness-contrast geometry", |
| 3251 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3252 | "-cdl filename color correct with a color decision list", |
cristy | 05c0c9a | 2011-09-05 23:16:13 +0000 | [diff] [blame] | 3253 | "-charcoal geometry simulate a charcoal drawing", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3254 | "-chop geometry remove pixels from the image interior", |
cristy | 1df2089 | 2012-11-04 01:06:40 +0000 | [diff] [blame] | 3255 | "-clamp keep pixel values in range (0-QuantumRange)", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3256 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3257 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3258 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3259 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3260 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3261 | "-contrast enhance or reduce the image contrast", |
| 3262 | "-contrast-stretch geometry", |
anthony | e5b3965 | 2012-04-21 05:37:29 +0000 | [diff] [blame] | 3263 | " improve contrast by 'stretching' the intensity range", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3264 | "-convolve coefficients", |
| 3265 | " apply a convolution kernel to the image", |
| 3266 | "-cycle amount cycle the image colormap", |
| 3267 | "-decipher filename convert cipher pixels to plain pixels", |
| 3268 | "-deskew threshold straighten an image", |
| 3269 | "-despeckle reduce the speckles within an image", |
| 3270 | "-distort method args", |
| 3271 | " distort images according to given method ad args", |
| 3272 | "-draw string annotate the image with a graphic primitive", |
| 3273 | "-edge radius apply a filter to detect edges in the image", |
| 3274 | "-encipher filename convert plain pixels to cipher pixels", |
| 3275 | "-emboss radius emboss an image", |
| 3276 | "-enhance apply a digital filter to enhance a noisy image", |
| 3277 | "-equalize perform histogram equalization to an image", |
| 3278 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3279 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3280 | "-extent geometry set the image size", |
| 3281 | "-extract geometry extract area from image", |
| 3282 | "-fft implements the discrete Fourier transform (DFT)", |
| 3283 | "-flip flip image vertically", |
| 3284 | "-floodfill geometry color", |
| 3285 | " floodfill the image with color", |
| 3286 | "-flop flop image horizontally", |
| 3287 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3288 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3289 | " apply function over image values", |
| 3290 | "-gamma value level of gamma correction", |
| 3291 | "-gaussian-blur geometry", |
| 3292 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3293 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3294 | "-identify identify the format and characteristics of the image", |
| 3295 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3296 | "-implode amount implode image pixels about the center", |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3297 | "-interpolative-resize geometry", |
| 3298 | " resize image using interpolation", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3299 | "-lat geometry local adaptive thresholding", |
| 3300 | "-layers method optimize, merge, or compare image layers", |
| 3301 | "-level value adjust the level of image contrast", |
| 3302 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3303 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3304 | "-linear-stretch geometry", |
anthony | e5b3965 | 2012-04-21 05:37:29 +0000 | [diff] [blame] | 3305 | " improve contrast by 'stretching with saturation'", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3306 | "-liquid-rescale geometry", |
| 3307 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3308 | "-median geometry apply a median filter to the image", |
cristy | b4671fc | 2012-11-04 15:02:10 +0000 | [diff] [blame] | 3309 | "-mode geometry make each pixel the 'predominant color' of the", |
| 3310 | " neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3311 | "-modulate value vary the brightness, saturation, and hue", |
| 3312 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3313 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3314 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3315 | "-motion-blur geometry", |
| 3316 | " simulate motion blur", |
| 3317 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3318 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3319 | "-normalize transform image to span the full range of colors", |
| 3320 | "-opaque color change this color to the fill color", |
| 3321 | "-ordered-dither NxN", |
| 3322 | " add a noise pattern to the image with specific", |
| 3323 | " amplitudes", |
| 3324 | "-paint radius simulate an oil painting", |
cristy | 3d629e2 | 2012-11-04 01:32:13 +0000 | [diff] [blame] | 3325 | "-perceptible epsilon", |
cristy | b4671fc | 2012-11-04 15:02:10 +0000 | [diff] [blame] | 3326 | " pixel value less than |epsilon| become epsilon or", |
| 3327 | " -epsilon", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3328 | "-polaroid angle simulate a Polaroid picture", |
| 3329 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3330 | "-profile filename add, delete, or apply an image profile", |
| 3331 | "-quantize colorspace reduce colors in this colorspace", |
| 3332 | "-radial-blur angle radial blur the image", |
| 3333 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3334 | "-random-threshold low,high", |
| 3335 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3336 | "-region geometry apply options to a portion of the image", |
| 3337 | "-render render vector graphics", |
| 3338 | "-repage geometry size and location of an image canvas", |
| 3339 | "-resample geometry change the resolution of an image", |
| 3340 | "-resize geometry resize the image", |
| 3341 | "-roll geometry roll an image vertically or horizontally", |
| 3342 | "-rotate degrees apply Paeth rotation to the image", |
| 3343 | "-sample geometry scale image with pixel sampling", |
| 3344 | "-scale geometry scale the image", |
| 3345 | "-segment values segment an image", |
| 3346 | "-selective-blur geometry", |
| 3347 | " selectively blur pixels within a contrast threshold", |
| 3348 | "-sepia-tone threshold", |
| 3349 | " simulate a sepia-toned photo", |
| 3350 | "-set property value set an image property", |
| 3351 | "-shade degrees shade the image using a distant light source", |
| 3352 | "-shadow geometry simulate an image shadow", |
| 3353 | "-sharpen geometry sharpen the image", |
| 3354 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3355 | "-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] | 3356 | "-sigmoidal-contrast geometry", |
cristy | b4671fc | 2012-11-04 15:02:10 +0000 | [diff] [blame] | 3357 | " increase the contrast without saturating highlights or", |
| 3358 | " shadows", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3359 | "-sketch geometry simulate a pencil sketch", |
| 3360 | "-solarize threshold negate all pixels above the threshold level", |
| 3361 | "-sparse-color method args", |
| 3362 | " fill in a image based on a few color points", |
| 3363 | "-splice geometry splice the background color into the image", |
| 3364 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3365 | "-statistic type radius", |
| 3366 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3367 | "-strip strip image of all profiles and comments", |
| 3368 | "-swirl degrees swirl image pixels about the center", |
| 3369 | "-threshold value threshold the image", |
| 3370 | "-thumbnail geometry create a thumbnail of the image", |
| 3371 | "-tile filename tile image when filling a graphic primitive", |
| 3372 | "-tint value tint the image with the fill color", |
| 3373 | "-transform affine transform image", |
| 3374 | "-transparent color make this color transparent within the image", |
| 3375 | "-transpose flip image vertically and rotate 90 degrees", |
| 3376 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3377 | "-trim trim image edges", |
| 3378 | "-type type image type", |
| 3379 | "-unique-colors discard all but one of any pixel color", |
| 3380 | "-unsharp geometry sharpen the image", |
| 3381 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3382 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3383 | "-white-threshold value", |
| 3384 | " force all pixels above the threshold into white", |
| 3385 | (char *) NULL |
| 3386 | }, |
| 3387 | *sequence_operators[]= |
| 3388 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3389 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3390 | "-clut apply a color lookup table to the image", |
| 3391 | "-coalesce merge a sequence of images", |
| 3392 | "-combine combine a sequence of images", |
| 3393 | "-composite composite image", |
| 3394 | "-crop geometry cut out a rectangular region of the image", |
| 3395 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3396 | "-evaluate-sequence operator", |
| 3397 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3398 | "-flatten flatten a sequence of images", |
| 3399 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3400 | "-hald-clut apply a Hald color lookup table to the image", |
| 3401 | "-morph value morph an image sequence", |
| 3402 | "-mosaic create a mosaic from an image sequence", |
cristy | 8cdfb34 | 2012-11-11 21:44:36 +0000 | [diff] [blame] | 3403 | "-poly terms build a polynomial from the image sequence and the corresponding", |
cristy | dbc2da9 | 2012-11-12 13:16:07 +0000 | [diff] [blame] | 3404 | " terms (coefficients and degree pairs).", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3405 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3406 | "-process arguments process the image with a custom image filter", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3407 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3408 | "-write filename write images to this file", |
| 3409 | (char *) NULL |
| 3410 | }, |
| 3411 | *settings[]= |
| 3412 | { |
| 3413 | "-adjoin join images into a single multi-image file", |
| 3414 | "-affine matrix affine transform matrix", |
| 3415 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3416 | "-antialias remove pixel-aliasing", |
| 3417 | "-authenticate password", |
| 3418 | " decipher image with this password", |
| 3419 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3420 | "-background color background color", |
| 3421 | "-bias value add bias when convolving an image", |
| 3422 | "-black-point-compensation", |
| 3423 | " use black point compensation", |
| 3424 | "-blue-primary point chromaticity blue primary point", |
| 3425 | "-bordercolor color border color", |
| 3426 | "-caption string assign a caption to an image", |
| 3427 | "-channel type apply option to select image channels", |
| 3428 | "-colors value preferred number of colors in the image", |
| 3429 | "-colorspace type alternate image colorspace", |
| 3430 | "-comment string annotate image with comment", |
| 3431 | "-compose operator set image composite operator", |
| 3432 | "-compress type type of pixel compression when writing the image", |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3433 | "-define format:option=value", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3434 | " define one or more image format options", |
| 3435 | "-delay value display the next image after pausing", |
| 3436 | "-density geometry horizontal and vertical density of the image", |
| 3437 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3438 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3439 | "-display server get image or font from this X server", |
| 3440 | "-dispose method layer disposal method", |
| 3441 | "-dither method apply error diffusion to image", |
| 3442 | "-encoding type text encoding type", |
| 3443 | "-endian type endianness (MSB or LSB) of the image", |
| 3444 | "-family name render text with this font family", |
cristy | 1415422 | 2012-06-15 23:21:49 +0000 | [diff] [blame] | 3445 | "-features distance analyze image features (e.g. contrast, correlation)", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3446 | "-fill color color to use when filling a graphic primitive", |
| 3447 | "-filter type use this filter when resizing an image", |
| 3448 | "-font name render text with this font", |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3449 | "-format \"string\" output formatted image characteristics", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3450 | "-fuzz distance colors within this distance are considered equal", |
| 3451 | "-gravity type horizontal and vertical text placement", |
| 3452 | "-green-primary point chromaticity green primary point", |
| 3453 | "-intent type type of rendering intent when managing the image color", |
| 3454 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3455 | "-interline-spacing value", |
| 3456 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3457 | "-interpolate method pixel color interpolation method", |
| 3458 | "-interword-spacing value", |
| 3459 | " set the space between two words", |
| 3460 | "-kerning value set the space between two letters", |
| 3461 | "-label string assign a label to an image", |
| 3462 | "-limit type value pixel cache resource limit", |
| 3463 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3464 | "-mask filename associate a mask with the image", |
| 3465 | "-mattecolor color frame color", |
| 3466 | "-monitor monitor progress", |
| 3467 | "-orient type image orientation", |
| 3468 | "-page geometry size and location of an image canvas (setting)", |
| 3469 | "-ping efficiently determine image attributes", |
| 3470 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3471 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3472 | "-preview type image preview type", |
| 3473 | "-quality value JPEG/MIFF/PNG compression level", |
| 3474 | "-quiet suppress all warning messages", |
| 3475 | "-red-primary point chromaticity red primary point", |
| 3476 | "-regard-warnings pay attention to warning messages", |
| 3477 | "-remap filename transform image colors to match this set of colors", |
| 3478 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3479 | "-sampling-factor geometry", |
| 3480 | " horizontal and vertical sampling factor", |
| 3481 | "-scene value image scene number", |
| 3482 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3483 | "-size geometry width and height of image", |
| 3484 | "-stretch type render text with this font stretch", |
| 3485 | "-stroke color graphic primitive stroke color", |
| 3486 | "-strokewidth value graphic primitive stroke width", |
| 3487 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3488 | "-synchronize synchronize image to storage device", |
| 3489 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3490 | "-texture filename name of texture to tile onto the image background", |
| 3491 | "-tile-offset geometry", |
| 3492 | " tile offset", |
| 3493 | "-treedepth value color tree depth", |
| 3494 | "-transparent-color color", |
| 3495 | " transparent color", |
| 3496 | "-undercolor color annotation bounding box color", |
| 3497 | "-units type the units of image resolution", |
| 3498 | "-verbose print detailed information about the image", |
| 3499 | "-view FlashPix viewing transforms", |
| 3500 | "-virtual-pixel method", |
| 3501 | " virtual pixel access method", |
| 3502 | "-weight type render text with this font weight", |
| 3503 | "-white-point point chromaticity white point", |
| 3504 | (char *) NULL |
| 3505 | }, |
| 3506 | *stack_operators[]= |
| 3507 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3508 | "-delete indexes delete the image from the image sequence", |
| 3509 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3510 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3511 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3512 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3513 | "-swap indexes swap two images in the image sequence", |
| 3514 | (char *) NULL |
| 3515 | }; |
| 3516 | |
| 3517 | const char |
| 3518 | **p; |
| 3519 | |
cristy | 4f7a613 | 2012-12-23 00:35:19 +0000 | [diff] [blame] | 3520 | ListMagickVersion(stdout); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3521 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3522 | GetClientName()); |
| 3523 | (void) printf("\nImage Settings:\n"); |
| 3524 | for (p=settings; *p != (char *) NULL; p++) |
| 3525 | (void) printf(" %s\n",*p); |
| 3526 | (void) printf("\nImage Operators:\n"); |
| 3527 | for (p=operators; *p != (char *) NULL; p++) |
| 3528 | (void) printf(" %s\n",*p); |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3529 | (void) printf("\nImage Channel Operators:\n"); |
| 3530 | for (p=channel_operators; *p != (char *) NULL; p++) |
| 3531 | (void) printf(" %s\n",*p); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3532 | (void) printf("\nImage Sequence Operators:\n"); |
| 3533 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3534 | (void) printf(" %s\n",*p); |
| 3535 | (void) printf("\nImage Stack Operators:\n"); |
| 3536 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3537 | (void) printf(" %s\n",*p); |
| 3538 | (void) printf("\nMiscellaneous Options:\n"); |
| 3539 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3540 | (void) printf(" %s\n",*p); |
| 3541 | (void) printf( |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 3542 | "\nBy default, the image format of 'file' is determined by its magic\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3543 | (void) printf( |
| 3544 | "number. To specify a particular image format, precede the filename\n"); |
| 3545 | (void) printf( |
| 3546 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3547 | (void) printf( |
| 3548 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3549 | (void) printf("'-' for standard input or output.\n"); |
| 3550 | return(MagickFalse); |
| 3551 | } |
| 3552 | |
| 3553 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3554 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3555 | { |
| 3556 | #define DestroyMogrify() \ |
| 3557 | { \ |
| 3558 | if (format != (char *) NULL) \ |
| 3559 | format=DestroyString(format); \ |
| 3560 | if (path != (char *) NULL) \ |
| 3561 | path=DestroyString(path); \ |
| 3562 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3563 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3564 | argv[i]=DestroyString(argv[i]); \ |
| 3565 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3566 | } |
| 3567 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3568 | { \ |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 3569 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3570 | option); \ |
| 3571 | DestroyMogrify(); \ |
| 3572 | return(MagickFalse); \ |
| 3573 | } |
| 3574 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3575 | { \ |
| 3576 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
anthony | e5b3965 | 2012-04-21 05:37:29 +0000 | [diff] [blame] | 3577 | "InvalidArgument","'%s': %s",argument,option); \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3578 | DestroyMogrify(); \ |
| 3579 | return(MagickFalse); \ |
| 3580 | } |
| 3581 | |
| 3582 | char |
| 3583 | *format, |
| 3584 | *option, |
| 3585 | *path; |
| 3586 | |
| 3587 | Image |
| 3588 | *image; |
| 3589 | |
| 3590 | ImageStack |
| 3591 | image_stack[MaxImageStackDepth+1]; |
| 3592 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3593 | MagickBooleanType |
| 3594 | global_colormap; |
| 3595 | |
| 3596 | MagickBooleanType |
| 3597 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3598 | pend, |
| 3599 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3600 | |
| 3601 | MagickStatusType |
| 3602 | status; |
| 3603 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3604 | register ssize_t |
| 3605 | i; |
| 3606 | |
| 3607 | ssize_t |
| 3608 | j, |
| 3609 | k; |
| 3610 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3611 | /* |
| 3612 | Set defaults. |
| 3613 | */ |
| 3614 | assert(image_info != (ImageInfo *) NULL); |
| 3615 | assert(image_info->signature == MagickSignature); |
| 3616 | if (image_info->debug != MagickFalse) |
| 3617 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3618 | assert(exception != (ExceptionInfo *) NULL); |
| 3619 | if (argc == 2) |
| 3620 | { |
| 3621 | option=argv[1]; |
| 3622 | if ((LocaleCompare("version",option+1) == 0) || |
| 3623 | (LocaleCompare("-version",option+1) == 0)) |
| 3624 | { |
cristy | 4f7a613 | 2012-12-23 00:35:19 +0000 | [diff] [blame] | 3625 | ListMagickVersion(stdout); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3626 | return(MagickFalse); |
| 3627 | } |
| 3628 | } |
| 3629 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3630 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3631 | format=(char *) NULL; |
| 3632 | path=(char *) NULL; |
| 3633 | global_colormap=MagickFalse; |
| 3634 | k=0; |
| 3635 | j=1; |
| 3636 | NewImageStack(); |
| 3637 | option=(char *) NULL; |
| 3638 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3639 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3640 | status=MagickTrue; |
| 3641 | /* |
| 3642 | Parse command line. |
| 3643 | */ |
| 3644 | ReadCommandlLine(argc,&argv); |
| 3645 | status=ExpandFilenames(&argc,&argv); |
| 3646 | if (status == MagickFalse) |
| 3647 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3648 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3649 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3650 | { |
| 3651 | option=argv[i]; |
| 3652 | if (LocaleCompare(option,"(") == 0) |
| 3653 | { |
| 3654 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3655 | if (k == MaxImageStackDepth) |
| 3656 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3657 | option); |
| 3658 | PushImageStack(); |
| 3659 | continue; |
| 3660 | } |
| 3661 | if (LocaleCompare(option,")") == 0) |
| 3662 | { |
| 3663 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3664 | if (k == 0) |
| 3665 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3666 | PopImageStack(); |
| 3667 | continue; |
| 3668 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3669 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3670 | { |
| 3671 | char |
| 3672 | backup_filename[MaxTextExtent], |
| 3673 | *filename; |
| 3674 | |
| 3675 | Image |
| 3676 | *images; |
| 3677 | |
| 3678 | /* |
| 3679 | Option is a file name: begin by reading image from specified file. |
| 3680 | */ |
| 3681 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3682 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3683 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3684 | filename=argv[++i]; |
cristy | 1b58f25 | 2012-03-01 01:41:41 +0000 | [diff] [blame] | 3685 | images=ReadImages(image_info,filename,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3686 | status&=(images != (Image *) NULL) && |
| 3687 | (exception->severity < ErrorException); |
| 3688 | if (images == (Image *) NULL) |
| 3689 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3690 | if (format != (char *) NULL) |
| 3691 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3692 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3693 | if (path != (char *) NULL) |
| 3694 | { |
| 3695 | GetPathComponent(option,TailPath,filename); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3696 | (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3697 | path,*DirectorySeparator,filename); |
| 3698 | } |
| 3699 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3700 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3701 | AppendImageStack(images); |
| 3702 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3703 | if (global_colormap != MagickFalse) |
| 3704 | { |
| 3705 | QuantizeInfo |
| 3706 | *quantize_info; |
| 3707 | |
| 3708 | quantize_info=AcquireQuantizeInfo(image_info); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 3709 | (void) RemapImages(quantize_info,images,(Image *) NULL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3710 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3711 | } |
| 3712 | *backup_filename='\0'; |
| 3713 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3714 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3715 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3716 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3717 | i; |
| 3718 | |
| 3719 | /* |
| 3720 | Rename image file as backup. |
| 3721 | */ |
| 3722 | (void) CopyMagickString(backup_filename,image->filename, |
| 3723 | MaxTextExtent); |
| 3724 | for (i=0; i < 6; i++) |
| 3725 | { |
| 3726 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3727 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3728 | break; |
| 3729 | } |
| 3730 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
cristy | 320684d | 2011-09-23 14:55:47 +0000 | [diff] [blame] | 3731 | (rename_utf8(image->filename,backup_filename) != 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3732 | *backup_filename='\0'; |
| 3733 | } |
| 3734 | /* |
| 3735 | Write transmogrified image to disk. |
| 3736 | */ |
| 3737 | image_info->synchronize=MagickTrue; |
| 3738 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3739 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
cristy | 18c6c27 | 2011-09-23 14:40:37 +0000 | [diff] [blame] | 3740 | (void) remove_utf8(backup_filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3741 | RemoveAllImageStack(); |
| 3742 | continue; |
| 3743 | } |
| 3744 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3745 | switch (*(option+1)) |
| 3746 | { |
| 3747 | case 'a': |
| 3748 | { |
| 3749 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3750 | { |
| 3751 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3752 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3753 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3754 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3755 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3756 | break; |
| 3757 | } |
| 3758 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3759 | { |
| 3760 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3761 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3762 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3763 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3764 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3765 | break; |
| 3766 | } |
| 3767 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3768 | { |
| 3769 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3770 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3771 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3772 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3773 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3774 | break; |
| 3775 | } |
| 3776 | if (LocaleCompare("affine",option+1) == 0) |
| 3777 | { |
| 3778 | if (*option == '+') |
| 3779 | break; |
| 3780 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3781 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3782 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3783 | break; |
| 3784 | } |
| 3785 | if (LocaleCompare("alpha",option+1) == 0) |
| 3786 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3787 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3788 | type; |
| 3789 | |
| 3790 | if (*option == '+') |
| 3791 | break; |
| 3792 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3793 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3794 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 288a353 | 2012-08-28 00:19:44 +0000 | [diff] [blame] | 3795 | type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3796 | if (type < 0) |
cristy | b15b06c | 2012-08-28 11:36:48 +0000 | [diff] [blame] | 3797 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelOption", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3798 | argv[i]); |
| 3799 | break; |
| 3800 | } |
| 3801 | if (LocaleCompare("annotate",option+1) == 0) |
| 3802 | { |
| 3803 | if (*option == '+') |
| 3804 | break; |
| 3805 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3806 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3807 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3808 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3809 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3810 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3811 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3812 | i++; |
| 3813 | break; |
| 3814 | } |
| 3815 | if (LocaleCompare("antialias",option+1) == 0) |
| 3816 | break; |
| 3817 | if (LocaleCompare("append",option+1) == 0) |
| 3818 | break; |
| 3819 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3820 | { |
| 3821 | if (*option == '+') |
| 3822 | break; |
| 3823 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3824 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3825 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3826 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3827 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3828 | break; |
| 3829 | } |
| 3830 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3831 | { |
| 3832 | if (*option == '+') |
| 3833 | break; |
| 3834 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3835 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3836 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3837 | break; |
| 3838 | } |
| 3839 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3840 | break; |
| 3841 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3842 | break; |
| 3843 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3844 | break; |
| 3845 | if (LocaleCompare("average",option+1) == 0) |
| 3846 | break; |
| 3847 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3848 | } |
| 3849 | case 'b': |
| 3850 | { |
| 3851 | if (LocaleCompare("background",option+1) == 0) |
| 3852 | { |
| 3853 | if (*option == '+') |
| 3854 | break; |
| 3855 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3856 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3857 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3858 | break; |
| 3859 | } |
| 3860 | if (LocaleCompare("bias",option+1) == 0) |
| 3861 | { |
| 3862 | if (*option == '+') |
| 3863 | break; |
| 3864 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3865 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3866 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3867 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3868 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3869 | break; |
| 3870 | } |
| 3871 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 3872 | break; |
| 3873 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 3874 | { |
| 3875 | if (*option == '+') |
| 3876 | break; |
| 3877 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3878 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3879 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3880 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3881 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3882 | break; |
| 3883 | } |
| 3884 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 3885 | { |
| 3886 | if (*option == '+') |
| 3887 | break; |
| 3888 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3889 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3890 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3891 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3892 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3893 | break; |
| 3894 | } |
| 3895 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3896 | { |
| 3897 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3898 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3899 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3900 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3901 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3902 | break; |
| 3903 | } |
| 3904 | if (LocaleCompare("blur",option+1) == 0) |
| 3905 | { |
| 3906 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3907 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3908 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3909 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3910 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3911 | break; |
| 3912 | } |
| 3913 | if (LocaleCompare("border",option+1) == 0) |
| 3914 | { |
| 3915 | if (*option == '+') |
| 3916 | break; |
| 3917 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3918 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3919 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3920 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3921 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3922 | break; |
| 3923 | } |
| 3924 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3925 | { |
| 3926 | if (*option == '+') |
| 3927 | break; |
| 3928 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3929 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3930 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3931 | break; |
| 3932 | } |
| 3933 | if (LocaleCompare("box",option+1) == 0) |
| 3934 | { |
| 3935 | if (*option == '+') |
| 3936 | break; |
| 3937 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3938 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3939 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3940 | break; |
| 3941 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3942 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 3943 | { |
| 3944 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3945 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3946 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3947 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3948 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3949 | break; |
| 3950 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3951 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3952 | } |
| 3953 | case 'c': |
| 3954 | { |
| 3955 | if (LocaleCompare("cache",option+1) == 0) |
| 3956 | { |
| 3957 | if (*option == '+') |
| 3958 | break; |
| 3959 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3960 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3961 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3962 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3963 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3964 | break; |
| 3965 | } |
| 3966 | if (LocaleCompare("caption",option+1) == 0) |
| 3967 | { |
| 3968 | if (*option == '+') |
| 3969 | break; |
| 3970 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3971 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3972 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3973 | break; |
| 3974 | } |
| 3975 | if (LocaleCompare("channel",option+1) == 0) |
| 3976 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3977 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3978 | channel; |
| 3979 | |
| 3980 | if (*option == '+') |
| 3981 | break; |
| 3982 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3983 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3984 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3985 | channel=ParseChannelOption(argv[i]); |
| 3986 | if (channel < 0) |
| 3987 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 3988 | argv[i]); |
| 3989 | break; |
| 3990 | } |
cristy | 5f257b2 | 2012-03-07 00:27:29 +0000 | [diff] [blame] | 3991 | if (LocaleCompare("channel-fx",option+1) == 0) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 3992 | { |
| 3993 | ssize_t |
| 3994 | channel; |
| 3995 | |
| 3996 | if (*option == '+') |
| 3997 | break; |
| 3998 | i++; |
| 3999 | if (i == (ssize_t) (argc-1)) |
| 4000 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 953c4bd | 2012-02-24 01:04:04 +0000 | [diff] [blame] | 4001 | channel=ParsePixelChannelOption(argv[i]); |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 4002 | if (channel < 0) |
| 4003 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 4004 | argv[i]); |
| 4005 | break; |
| 4006 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4007 | if (LocaleCompare("cdl",option+1) == 0) |
| 4008 | { |
| 4009 | if (*option == '+') |
| 4010 | break; |
| 4011 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4012 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4013 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4014 | break; |
| 4015 | } |
| 4016 | if (LocaleCompare("charcoal",option+1) == 0) |
| 4017 | { |
| 4018 | if (*option == '+') |
| 4019 | break; |
| 4020 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4021 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4022 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4023 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4024 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4025 | break; |
| 4026 | } |
| 4027 | if (LocaleCompare("chop",option+1) == 0) |
| 4028 | { |
| 4029 | if (*option == '+') |
| 4030 | break; |
| 4031 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4032 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4033 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4034 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4035 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4036 | break; |
| 4037 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4038 | if (LocaleCompare("clamp",option+1) == 0) |
| 4039 | break; |
| 4040 | if (LocaleCompare("clip",option+1) == 0) |
| 4041 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4042 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4043 | { |
| 4044 | if (*option == '+') |
| 4045 | break; |
| 4046 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4047 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4048 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4049 | break; |
| 4050 | } |
| 4051 | if (LocaleCompare("clut",option+1) == 0) |
| 4052 | break; |
| 4053 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4054 | break; |
| 4055 | if (LocaleCompare("colorize",option+1) == 0) |
| 4056 | { |
| 4057 | if (*option == '+') |
| 4058 | break; |
| 4059 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4060 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4061 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4062 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4063 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4064 | break; |
| 4065 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4066 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4067 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4068 | KernelInfo |
| 4069 | *kernel_info; |
| 4070 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4071 | if (*option == '+') |
| 4072 | break; |
| 4073 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4074 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4075 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4076 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4077 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4078 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4079 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4080 | break; |
| 4081 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4082 | if (LocaleCompare("colors",option+1) == 0) |
| 4083 | { |
| 4084 | if (*option == '+') |
| 4085 | break; |
| 4086 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4087 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4088 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4089 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4090 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4091 | break; |
| 4092 | } |
| 4093 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4094 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4095 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4096 | colorspace; |
| 4097 | |
| 4098 | if (*option == '+') |
| 4099 | break; |
| 4100 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4101 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4102 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4103 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4104 | argv[i]); |
| 4105 | if (colorspace < 0) |
| 4106 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4107 | argv[i]); |
| 4108 | break; |
| 4109 | } |
| 4110 | if (LocaleCompare("combine",option+1) == 0) |
cristy | 46f354c | 2012-07-04 13:31:29 +0000 | [diff] [blame] | 4111 | { |
| 4112 | ssize_t |
| 4113 | colorspace; |
| 4114 | |
| 4115 | if (*option == '+') |
| 4116 | break; |
| 4117 | i++; |
| 4118 | if (i == (ssize_t) argc) |
| 4119 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4120 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
| 4121 | argv[i]); |
| 4122 | if (colorspace < 0) |
| 4123 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4124 | argv[i]); |
| 4125 | break; |
| 4126 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4127 | if (LocaleCompare("comment",option+1) == 0) |
| 4128 | { |
| 4129 | if (*option == '+') |
| 4130 | break; |
| 4131 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4132 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4133 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4134 | break; |
| 4135 | } |
| 4136 | if (LocaleCompare("composite",option+1) == 0) |
| 4137 | break; |
| 4138 | if (LocaleCompare("compress",option+1) == 0) |
| 4139 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4140 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4141 | compress; |
| 4142 | |
| 4143 | if (*option == '+') |
| 4144 | break; |
| 4145 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4146 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4147 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4148 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4149 | argv[i]); |
| 4150 | if (compress < 0) |
| 4151 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4152 | argv[i]); |
| 4153 | break; |
| 4154 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4155 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4156 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4157 | if (LocaleCompare("contrast",option+1) == 0) |
| 4158 | break; |
| 4159 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4160 | { |
| 4161 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4162 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4163 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4164 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4165 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4166 | break; |
| 4167 | } |
| 4168 | if (LocaleCompare("convolve",option+1) == 0) |
| 4169 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4170 | KernelInfo |
| 4171 | *kernel_info; |
| 4172 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4173 | if (*option == '+') |
| 4174 | break; |
| 4175 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4176 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4177 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4178 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4179 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4180 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4181 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4182 | break; |
| 4183 | } |
| 4184 | if (LocaleCompare("crop",option+1) == 0) |
| 4185 | { |
| 4186 | if (*option == '+') |
| 4187 | break; |
| 4188 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4189 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4190 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4191 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4192 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4193 | break; |
| 4194 | } |
| 4195 | if (LocaleCompare("cycle",option+1) == 0) |
| 4196 | { |
| 4197 | if (*option == '+') |
| 4198 | break; |
| 4199 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4200 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4201 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4202 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4203 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4204 | break; |
| 4205 | } |
| 4206 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4207 | } |
| 4208 | case 'd': |
| 4209 | { |
| 4210 | if (LocaleCompare("decipher",option+1) == 0) |
| 4211 | { |
| 4212 | if (*option == '+') |
| 4213 | break; |
| 4214 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4215 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4216 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4217 | break; |
| 4218 | } |
| 4219 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4220 | break; |
| 4221 | if (LocaleCompare("debug",option+1) == 0) |
| 4222 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4223 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4224 | event; |
| 4225 | |
| 4226 | if (*option == '+') |
| 4227 | break; |
| 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); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4231 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4232 | if (event < 0) |
| 4233 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4234 | argv[i]); |
| 4235 | (void) SetLogEventMask(argv[i]); |
| 4236 | break; |
| 4237 | } |
| 4238 | if (LocaleCompare("define",option+1) == 0) |
| 4239 | { |
| 4240 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4241 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4242 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4243 | if (*option == '+') |
| 4244 | { |
| 4245 | const char |
| 4246 | *define; |
| 4247 | |
| 4248 | define=GetImageOption(image_info,argv[i]); |
| 4249 | if (define == (const char *) NULL) |
| 4250 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4251 | break; |
| 4252 | } |
| 4253 | break; |
| 4254 | } |
| 4255 | if (LocaleCompare("delay",option+1) == 0) |
| 4256 | { |
| 4257 | if (*option == '+') |
| 4258 | break; |
| 4259 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4260 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4261 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4262 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4263 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4264 | break; |
| 4265 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4266 | if (LocaleCompare("delete",option+1) == 0) |
| 4267 | { |
| 4268 | if (*option == '+') |
| 4269 | break; |
| 4270 | i++; |
| 4271 | if (i == (ssize_t) (argc-1)) |
| 4272 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4273 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4274 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4275 | break; |
| 4276 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4277 | if (LocaleCompare("density",option+1) == 0) |
| 4278 | { |
| 4279 | if (*option == '+') |
| 4280 | break; |
| 4281 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4282 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4283 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4284 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4285 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4286 | break; |
| 4287 | } |
| 4288 | if (LocaleCompare("depth",option+1) == 0) |
| 4289 | { |
| 4290 | if (*option == '+') |
| 4291 | break; |
| 4292 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4293 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4294 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4295 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4296 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4297 | break; |
| 4298 | } |
| 4299 | if (LocaleCompare("deskew",option+1) == 0) |
| 4300 | { |
| 4301 | if (*option == '+') |
| 4302 | break; |
| 4303 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4304 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4305 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4306 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4307 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4308 | break; |
| 4309 | } |
| 4310 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4311 | break; |
| 4312 | if (LocaleCompare("dft",option+1) == 0) |
| 4313 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4314 | if (LocaleCompare("direction",option+1) == 0) |
| 4315 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4316 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4317 | direction; |
| 4318 | |
| 4319 | if (*option == '+') |
| 4320 | break; |
| 4321 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4322 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4323 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4324 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4325 | argv[i]); |
| 4326 | if (direction < 0) |
| 4327 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4328 | argv[i]); |
| 4329 | break; |
| 4330 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4331 | if (LocaleCompare("display",option+1) == 0) |
| 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); |
| 4338 | break; |
| 4339 | } |
| 4340 | if (LocaleCompare("dispose",option+1) == 0) |
| 4341 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4342 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4343 | dispose; |
| 4344 | |
| 4345 | if (*option == '+') |
| 4346 | break; |
| 4347 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4348 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4349 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4350 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4351 | if (dispose < 0) |
| 4352 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4353 | argv[i]); |
| 4354 | break; |
| 4355 | } |
| 4356 | if (LocaleCompare("distort",option+1) == 0) |
| 4357 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4358 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4359 | op; |
| 4360 | |
| 4361 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4362 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4363 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4364 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4365 | if (op < 0) |
| 4366 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4367 | argv[i]); |
| 4368 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4369 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4370 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4371 | break; |
| 4372 | } |
| 4373 | if (LocaleCompare("dither",option+1) == 0) |
| 4374 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4375 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4376 | method; |
| 4377 | |
| 4378 | if (*option == '+') |
| 4379 | break; |
| 4380 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4381 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4382 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4383 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4384 | if (method < 0) |
| 4385 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4386 | argv[i]); |
| 4387 | break; |
| 4388 | } |
| 4389 | if (LocaleCompare("draw",option+1) == 0) |
| 4390 | { |
| 4391 | if (*option == '+') |
| 4392 | break; |
| 4393 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4394 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4395 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4396 | break; |
| 4397 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4398 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4399 | { |
| 4400 | if (*option == '+') |
| 4401 | break; |
| 4402 | i++; |
| 4403 | if (i == (ssize_t) (argc-1)) |
| 4404 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4405 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4406 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4407 | break; |
| 4408 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4409 | if (LocaleCompare("duration",option+1) == 0) |
| 4410 | { |
| 4411 | if (*option == '+') |
| 4412 | break; |
| 4413 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4414 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4415 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4416 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4417 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4418 | break; |
| 4419 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4420 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4421 | } |
| 4422 | case 'e': |
| 4423 | { |
| 4424 | if (LocaleCompare("edge",option+1) == 0) |
| 4425 | { |
| 4426 | if (*option == '+') |
| 4427 | break; |
| 4428 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4429 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4430 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4431 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4432 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4433 | break; |
| 4434 | } |
| 4435 | if (LocaleCompare("emboss",option+1) == 0) |
| 4436 | { |
| 4437 | if (*option == '+') |
| 4438 | break; |
| 4439 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4440 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4441 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4442 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4443 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4444 | break; |
| 4445 | } |
| 4446 | if (LocaleCompare("encipher",option+1) == 0) |
| 4447 | { |
| 4448 | if (*option == '+') |
| 4449 | break; |
| 4450 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4451 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4452 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4453 | break; |
| 4454 | } |
| 4455 | if (LocaleCompare("encoding",option+1) == 0) |
| 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); |
| 4462 | break; |
| 4463 | } |
| 4464 | if (LocaleCompare("endian",option+1) == 0) |
| 4465 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4466 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4467 | endian; |
| 4468 | |
| 4469 | if (*option == '+') |
| 4470 | break; |
| 4471 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4472 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4473 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4474 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4475 | if (endian < 0) |
| 4476 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4477 | argv[i]); |
| 4478 | break; |
| 4479 | } |
| 4480 | if (LocaleCompare("enhance",option+1) == 0) |
| 4481 | break; |
| 4482 | if (LocaleCompare("equalize",option+1) == 0) |
| 4483 | break; |
| 4484 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4485 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4486 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4487 | op; |
| 4488 | |
| 4489 | if (*option == '+') |
| 4490 | break; |
| 4491 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4492 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4493 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4494 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4495 | if (op < 0) |
| 4496 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4497 | argv[i]); |
| 4498 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4499 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4500 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4501 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4502 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4503 | break; |
| 4504 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4505 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4506 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4507 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4508 | op; |
| 4509 | |
| 4510 | if (*option == '+') |
| 4511 | break; |
| 4512 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4513 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4514 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4515 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4516 | if (op < 0) |
| 4517 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4518 | argv[i]); |
| 4519 | break; |
| 4520 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4521 | if (LocaleCompare("extent",option+1) == 0) |
| 4522 | { |
| 4523 | if (*option == '+') |
| 4524 | break; |
| 4525 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4526 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4527 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4528 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4529 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4530 | break; |
| 4531 | } |
| 4532 | if (LocaleCompare("extract",option+1) == 0) |
| 4533 | { |
| 4534 | if (*option == '+') |
| 4535 | break; |
| 4536 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4537 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4538 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4539 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4540 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4541 | break; |
| 4542 | } |
| 4543 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4544 | } |
| 4545 | case 'f': |
| 4546 | { |
| 4547 | if (LocaleCompare("family",option+1) == 0) |
| 4548 | { |
| 4549 | if (*option == '+') |
| 4550 | break; |
| 4551 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4552 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4553 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4554 | break; |
| 4555 | } |
cristy | 1415422 | 2012-06-15 23:21:49 +0000 | [diff] [blame] | 4556 | if (LocaleCompare("features",option+1) == 0) |
| 4557 | { |
| 4558 | if (*option == '+') |
| 4559 | break; |
| 4560 | i++; |
| 4561 | if (i == (ssize_t) (argc-1)) |
| 4562 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4563 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4564 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4565 | break; |
| 4566 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4567 | if (LocaleCompare("fill",option+1) == 0) |
| 4568 | { |
| 4569 | if (*option == '+') |
| 4570 | break; |
| 4571 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4572 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4573 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4574 | break; |
| 4575 | } |
| 4576 | if (LocaleCompare("filter",option+1) == 0) |
| 4577 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4578 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4579 | filter; |
| 4580 | |
| 4581 | if (*option == '+') |
| 4582 | break; |
| 4583 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4584 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4585 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4586 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4587 | if (filter < 0) |
| 4588 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4589 | argv[i]); |
| 4590 | break; |
| 4591 | } |
| 4592 | if (LocaleCompare("flatten",option+1) == 0) |
| 4593 | break; |
| 4594 | if (LocaleCompare("flip",option+1) == 0) |
| 4595 | break; |
| 4596 | if (LocaleCompare("flop",option+1) == 0) |
| 4597 | break; |
| 4598 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4599 | { |
| 4600 | if (*option == '+') |
| 4601 | break; |
| 4602 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4603 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4604 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4605 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4606 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4607 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4608 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4609 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4610 | break; |
| 4611 | } |
| 4612 | if (LocaleCompare("font",option+1) == 0) |
| 4613 | { |
| 4614 | if (*option == '+') |
| 4615 | break; |
| 4616 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4617 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4618 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4619 | break; |
| 4620 | } |
| 4621 | if (LocaleCompare("format",option+1) == 0) |
| 4622 | { |
| 4623 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4624 | (void) CloneString(&format,(char *) NULL); |
| 4625 | if (*option == '+') |
| 4626 | break; |
| 4627 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4628 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4629 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4630 | (void) CloneString(&format,argv[i]); |
| 4631 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4632 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4633 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4634 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4635 | if (*image_info->magick == '\0') |
| 4636 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4637 | format); |
| 4638 | break; |
| 4639 | } |
| 4640 | if (LocaleCompare("frame",option+1) == 0) |
| 4641 | { |
| 4642 | if (*option == '+') |
| 4643 | break; |
| 4644 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4645 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4646 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4647 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4648 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4649 | break; |
| 4650 | } |
| 4651 | if (LocaleCompare("function",option+1) == 0) |
| 4652 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4653 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4654 | op; |
| 4655 | |
| 4656 | if (*option == '+') |
| 4657 | break; |
| 4658 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4659 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4660 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4661 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4662 | if (op < 0) |
| 4663 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4664 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4665 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4666 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4667 | break; |
| 4668 | } |
| 4669 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4670 | { |
| 4671 | if (*option == '+') |
| 4672 | break; |
| 4673 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4674 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4675 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4676 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4677 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4678 | break; |
| 4679 | } |
| 4680 | if (LocaleCompare("fx",option+1) == 0) |
| 4681 | { |
| 4682 | if (*option == '+') |
| 4683 | break; |
| 4684 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4685 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4686 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4687 | break; |
| 4688 | } |
| 4689 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4690 | } |
| 4691 | case 'g': |
| 4692 | { |
| 4693 | if (LocaleCompare("gamma",option+1) == 0) |
| 4694 | { |
| 4695 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4696 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4697 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4698 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4699 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4700 | break; |
| 4701 | } |
| 4702 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4703 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4704 | { |
| 4705 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4706 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4707 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4708 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4709 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4710 | break; |
| 4711 | } |
| 4712 | if (LocaleCompare("geometry",option+1) == 0) |
| 4713 | { |
| 4714 | if (*option == '+') |
| 4715 | break; |
| 4716 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4717 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4718 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4719 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4720 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4721 | break; |
| 4722 | } |
| 4723 | if (LocaleCompare("gravity",option+1) == 0) |
| 4724 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4725 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4726 | gravity; |
| 4727 | |
| 4728 | if (*option == '+') |
| 4729 | break; |
| 4730 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4731 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4732 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4733 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4734 | if (gravity < 0) |
| 4735 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4736 | argv[i]); |
| 4737 | break; |
| 4738 | } |
| 4739 | if (LocaleCompare("green-primary",option+1) == 0) |
| 4740 | { |
| 4741 | if (*option == '+') |
| 4742 | break; |
| 4743 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4744 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4745 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4746 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4747 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4748 | break; |
| 4749 | } |
| 4750 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4751 | } |
| 4752 | case 'h': |
| 4753 | { |
| 4754 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4755 | break; |
| 4756 | if ((LocaleCompare("help",option+1) == 0) || |
| 4757 | (LocaleCompare("-help",option+1) == 0)) |
| 4758 | return(MogrifyUsage()); |
| 4759 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4760 | } |
| 4761 | case 'i': |
| 4762 | { |
| 4763 | if (LocaleCompare("identify",option+1) == 0) |
| 4764 | break; |
| 4765 | if (LocaleCompare("idft",option+1) == 0) |
| 4766 | break; |
| 4767 | if (LocaleCompare("implode",option+1) == 0) |
| 4768 | { |
| 4769 | if (*option == '+') |
| 4770 | break; |
| 4771 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4772 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4773 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4774 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4775 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4776 | break; |
| 4777 | } |
| 4778 | if (LocaleCompare("intent",option+1) == 0) |
| 4779 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4780 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4781 | intent; |
| 4782 | |
| 4783 | if (*option == '+') |
| 4784 | break; |
| 4785 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4786 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4787 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4788 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4789 | if (intent < 0) |
| 4790 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4791 | argv[i]); |
| 4792 | break; |
| 4793 | } |
| 4794 | if (LocaleCompare("interlace",option+1) == 0) |
| 4795 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4796 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4797 | interlace; |
| 4798 | |
| 4799 | if (*option == '+') |
| 4800 | break; |
| 4801 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4802 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4803 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4804 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4805 | argv[i]); |
| 4806 | if (interlace < 0) |
| 4807 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4808 | argv[i]); |
| 4809 | break; |
| 4810 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4811 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4812 | { |
| 4813 | if (*option == '+') |
| 4814 | break; |
| 4815 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4816 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4817 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4818 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4819 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4820 | break; |
| 4821 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4822 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4823 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4824 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4825 | interpolate; |
| 4826 | |
| 4827 | if (*option == '+') |
| 4828 | break; |
| 4829 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4830 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4831 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4832 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4833 | argv[i]); |
| 4834 | if (interpolate < 0) |
| 4835 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4836 | argv[i]); |
| 4837 | break; |
| 4838 | } |
| 4839 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4840 | { |
| 4841 | if (*option == '+') |
| 4842 | break; |
| 4843 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4844 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4845 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4846 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4847 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4848 | break; |
| 4849 | } |
| 4850 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4851 | } |
| 4852 | case 'k': |
| 4853 | { |
| 4854 | if (LocaleCompare("kerning",option+1) == 0) |
| 4855 | { |
| 4856 | if (*option == '+') |
| 4857 | break; |
| 4858 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4859 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4860 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4861 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4862 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4863 | break; |
| 4864 | } |
| 4865 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4866 | } |
| 4867 | case 'l': |
| 4868 | { |
| 4869 | if (LocaleCompare("label",option+1) == 0) |
| 4870 | { |
| 4871 | if (*option == '+') |
| 4872 | break; |
| 4873 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4874 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4875 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4876 | break; |
| 4877 | } |
| 4878 | if (LocaleCompare("lat",option+1) == 0) |
| 4879 | { |
| 4880 | if (*option == '+') |
| 4881 | break; |
| 4882 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4883 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4884 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4885 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4886 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4887 | } |
| 4888 | if (LocaleCompare("layers",option+1) == 0) |
| 4889 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4890 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4891 | type; |
| 4892 | |
| 4893 | if (*option == '+') |
| 4894 | break; |
| 4895 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4896 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4897 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4898 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4899 | if (type < 0) |
| 4900 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4901 | argv[i]); |
| 4902 | break; |
| 4903 | } |
| 4904 | if (LocaleCompare("level",option+1) == 0) |
| 4905 | { |
| 4906 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4907 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4908 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4909 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4910 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4911 | break; |
| 4912 | } |
| 4913 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4914 | { |
| 4915 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4916 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4917 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4918 | break; |
| 4919 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4920 | if (LocaleCompare("limit",option+1) == 0) |
| 4921 | { |
| 4922 | char |
| 4923 | *p; |
| 4924 | |
| 4925 | double |
| 4926 | value; |
| 4927 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4928 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4929 | resource; |
| 4930 | |
| 4931 | if (*option == '+') |
| 4932 | break; |
| 4933 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4934 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4935 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4936 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4937 | argv[i]); |
| 4938 | if (resource < 0) |
| 4939 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4940 | argv[i]); |
| 4941 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4942 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4943 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 4944 | value=StringToDouble(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4945 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4946 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4947 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4948 | break; |
| 4949 | } |
| 4950 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4951 | { |
| 4952 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4953 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4954 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4955 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4956 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4957 | break; |
| 4958 | } |
| 4959 | if (LocaleCompare("list",option+1) == 0) |
| 4960 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4961 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4962 | list; |
| 4963 | |
| 4964 | if (*option == '+') |
| 4965 | break; |
| 4966 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4967 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4968 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4969 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4970 | if (list < 0) |
| 4971 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4972 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4973 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4974 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4975 | } |
| 4976 | if (LocaleCompare("log",option+1) == 0) |
| 4977 | { |
| 4978 | if (*option == '+') |
| 4979 | break; |
| 4980 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4981 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4982 | (strchr(argv[i],'%') == (char *) NULL)) |
| 4983 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4984 | break; |
| 4985 | } |
| 4986 | if (LocaleCompare("loop",option+1) == 0) |
| 4987 | { |
| 4988 | if (*option == '+') |
| 4989 | break; |
| 4990 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4991 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4992 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4993 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4994 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4995 | break; |
| 4996 | } |
| 4997 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4998 | } |
| 4999 | case 'm': |
| 5000 | { |
| 5001 | if (LocaleCompare("map",option+1) == 0) |
| 5002 | { |
| 5003 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 5004 | if (*option == '+') |
| 5005 | break; |
| 5006 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5007 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5008 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5009 | break; |
| 5010 | } |
| 5011 | if (LocaleCompare("mask",option+1) == 0) |
| 5012 | { |
| 5013 | if (*option == '+') |
| 5014 | break; |
| 5015 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5016 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5017 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5018 | break; |
| 5019 | } |
| 5020 | if (LocaleCompare("matte",option+1) == 0) |
| 5021 | break; |
| 5022 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 5023 | { |
| 5024 | if (*option == '+') |
| 5025 | break; |
| 5026 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5027 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5028 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5029 | break; |
| 5030 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5031 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5032 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5033 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5034 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5035 | if (LocaleCompare("modulate",option+1) == 0) |
| 5036 | { |
| 5037 | if (*option == '+') |
| 5038 | break; |
| 5039 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5040 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5041 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5042 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5043 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5044 | break; |
| 5045 | } |
| 5046 | if (LocaleCompare("median",option+1) == 0) |
| 5047 | { |
| 5048 | if (*option == '+') |
| 5049 | break; |
| 5050 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5051 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5052 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5053 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5054 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5055 | break; |
| 5056 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5057 | if (LocaleCompare("mode",option+1) == 0) |
| 5058 | { |
| 5059 | if (*option == '+') |
| 5060 | break; |
| 5061 | i++; |
| 5062 | if (i == (ssize_t) argc) |
| 5063 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5064 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5065 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5066 | break; |
| 5067 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5068 | if (LocaleCompare("monitor",option+1) == 0) |
| 5069 | break; |
| 5070 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5071 | break; |
| 5072 | if (LocaleCompare("morph",option+1) == 0) |
| 5073 | { |
| 5074 | if (*option == '+') |
| 5075 | break; |
| 5076 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5077 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5078 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5079 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5080 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5081 | break; |
| 5082 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5083 | if (LocaleCompare("morphology",option+1) == 0) |
| 5084 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5085 | char |
| 5086 | token[MaxTextExtent]; |
| 5087 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5088 | KernelInfo |
| 5089 | *kernel_info; |
| 5090 | |
| 5091 | ssize_t |
| 5092 | op; |
| 5093 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5094 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5095 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5096 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5097 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5098 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5099 | if (op < 0) |
| 5100 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5101 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5102 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5103 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5104 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5105 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5106 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5107 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5108 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5109 | break; |
| 5110 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5111 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5112 | break; |
| 5113 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5114 | { |
| 5115 | if (*option == '+') |
| 5116 | break; |
| 5117 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5118 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5119 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5120 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5121 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5122 | break; |
| 5123 | } |
| 5124 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5125 | } |
| 5126 | case 'n': |
| 5127 | { |
| 5128 | if (LocaleCompare("negate",option+1) == 0) |
| 5129 | break; |
| 5130 | if (LocaleCompare("noise",option+1) == 0) |
| 5131 | { |
| 5132 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5133 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5134 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5135 | if (*option == '+') |
| 5136 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5137 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5138 | noise; |
| 5139 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5140 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5141 | if (noise < 0) |
| 5142 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5143 | argv[i]); |
| 5144 | break; |
| 5145 | } |
| 5146 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5147 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5148 | break; |
| 5149 | } |
| 5150 | if (LocaleCompare("noop",option+1) == 0) |
| 5151 | break; |
| 5152 | if (LocaleCompare("normalize",option+1) == 0) |
| 5153 | break; |
| 5154 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5155 | } |
| 5156 | case 'o': |
| 5157 | { |
| 5158 | if (LocaleCompare("opaque",option+1) == 0) |
| 5159 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5160 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5161 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5162 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5163 | break; |
| 5164 | } |
| 5165 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5166 | { |
| 5167 | if (*option == '+') |
| 5168 | break; |
| 5169 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5170 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5171 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5172 | break; |
| 5173 | } |
| 5174 | if (LocaleCompare("orient",option+1) == 0) |
| 5175 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5176 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5177 | orientation; |
| 5178 | |
| 5179 | orientation=UndefinedOrientation; |
| 5180 | if (*option == '+') |
| 5181 | break; |
| 5182 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5183 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5184 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5185 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5186 | argv[i]); |
| 5187 | if (orientation < 0) |
| 5188 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5189 | argv[i]); |
| 5190 | break; |
| 5191 | } |
| 5192 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5193 | } |
| 5194 | case 'p': |
| 5195 | { |
| 5196 | if (LocaleCompare("page",option+1) == 0) |
| 5197 | { |
| 5198 | if (*option == '+') |
| 5199 | break; |
| 5200 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5201 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5202 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5203 | break; |
| 5204 | } |
| 5205 | if (LocaleCompare("paint",option+1) == 0) |
| 5206 | { |
| 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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5213 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5214 | break; |
| 5215 | } |
| 5216 | if (LocaleCompare("path",option+1) == 0) |
| 5217 | { |
| 5218 | (void) CloneString(&path,(char *) NULL); |
| 5219 | if (*option == '+') |
| 5220 | break; |
| 5221 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5222 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5223 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5224 | (void) CloneString(&path,argv[i]); |
| 5225 | break; |
| 5226 | } |
cristy | ab2b40a | 2012-11-04 01:43:29 +0000 | [diff] [blame] | 5227 | if (LocaleCompare("perceptible",option+1) == 0) |
| 5228 | { |
| 5229 | if (*option == '+') |
| 5230 | break; |
| 5231 | i++; |
| 5232 | if (i == (ssize_t) argc) |
| 5233 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5234 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5235 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5236 | break; |
| 5237 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5238 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5239 | { |
| 5240 | if (*option == '+') |
| 5241 | break; |
| 5242 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5243 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5244 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5245 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5246 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5247 | break; |
| 5248 | } |
| 5249 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5250 | { |
| 5251 | if (*option == '+') |
| 5252 | break; |
| 5253 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5254 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5255 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5256 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5257 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5258 | break; |
| 5259 | } |
cristy | 8cdfb34 | 2012-11-11 21:44:36 +0000 | [diff] [blame] | 5260 | if (LocaleCompare("poly",option+1) == 0) |
| 5261 | { |
| 5262 | if (*option == '+') |
| 5263 | break; |
| 5264 | i++; |
| 5265 | if (i == (ssize_t) argc) |
| 5266 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5267 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5268 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5269 | break; |
| 5270 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5271 | if (LocaleCompare("posterize",option+1) == 0) |
| 5272 | { |
| 5273 | if (*option == '+') |
| 5274 | break; |
| 5275 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5276 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5277 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5278 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5279 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5280 | break; |
| 5281 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5282 | if (LocaleCompare("precision",option+1) == 0) |
| 5283 | { |
| 5284 | if (*option == '+') |
| 5285 | break; |
| 5286 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5287 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5288 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5289 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5290 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5291 | break; |
| 5292 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5293 | if (LocaleCompare("print",option+1) == 0) |
| 5294 | { |
| 5295 | if (*option == '+') |
| 5296 | break; |
| 5297 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5298 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5299 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5300 | break; |
| 5301 | } |
| 5302 | if (LocaleCompare("process",option+1) == 0) |
| 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); |
| 5309 | break; |
| 5310 | } |
| 5311 | if (LocaleCompare("profile",option+1) == 0) |
| 5312 | { |
| 5313 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5314 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5315 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5316 | break; |
| 5317 | } |
| 5318 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5319 | } |
| 5320 | case 'q': |
| 5321 | { |
| 5322 | if (LocaleCompare("quality",option+1) == 0) |
| 5323 | { |
| 5324 | if (*option == '+') |
| 5325 | break; |
| 5326 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5327 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5328 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5329 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5330 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5331 | break; |
| 5332 | } |
| 5333 | if (LocaleCompare("quantize",option+1) == 0) |
| 5334 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5335 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5336 | colorspace; |
| 5337 | |
| 5338 | if (*option == '+') |
| 5339 | break; |
| 5340 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5341 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5342 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5343 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5344 | argv[i]); |
| 5345 | if (colorspace < 0) |
| 5346 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5347 | argv[i]); |
| 5348 | break; |
| 5349 | } |
| 5350 | if (LocaleCompare("quiet",option+1) == 0) |
| 5351 | break; |
| 5352 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5353 | } |
| 5354 | case 'r': |
| 5355 | { |
| 5356 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5357 | { |
| 5358 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5359 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5360 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5361 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5362 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5363 | break; |
| 5364 | } |
| 5365 | if (LocaleCompare("raise",option+1) == 0) |
| 5366 | { |
| 5367 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5368 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5369 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5370 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5371 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5372 | break; |
| 5373 | } |
| 5374 | if (LocaleCompare("random-threshold",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 | } |
| 5385 | if (LocaleCompare("red-primary",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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5391 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5392 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5393 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5394 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5395 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5396 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5397 | if (LocaleCompare("region",option+1) == 0) |
| 5398 | { |
| 5399 | if (*option == '+') |
| 5400 | break; |
| 5401 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5402 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5403 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5404 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5405 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5406 | break; |
| 5407 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5408 | if (LocaleCompare("remap",option+1) == 0) |
| 5409 | { |
| 5410 | if (*option == '+') |
| 5411 | break; |
| 5412 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5413 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5414 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5415 | break; |
| 5416 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5417 | if (LocaleCompare("render",option+1) == 0) |
| 5418 | break; |
| 5419 | if (LocaleCompare("repage",option+1) == 0) |
| 5420 | { |
| 5421 | if (*option == '+') |
| 5422 | break; |
| 5423 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5424 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5425 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5426 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5427 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5428 | break; |
| 5429 | } |
| 5430 | if (LocaleCompare("resample",option+1) == 0) |
| 5431 | { |
| 5432 | if (*option == '+') |
| 5433 | break; |
| 5434 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5435 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5436 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5437 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5438 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5439 | break; |
| 5440 | } |
| 5441 | if (LocaleCompare("resize",option+1) == 0) |
| 5442 | { |
| 5443 | if (*option == '+') |
| 5444 | break; |
| 5445 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5446 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5447 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5448 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5449 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5450 | break; |
| 5451 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5452 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5453 | { |
| 5454 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5455 | break; |
| 5456 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5457 | if (LocaleCompare("reverse",option+1) == 0) |
| 5458 | break; |
| 5459 | if (LocaleCompare("roll",option+1) == 0) |
| 5460 | { |
| 5461 | if (*option == '+') |
| 5462 | break; |
| 5463 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5464 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5465 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5466 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5467 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5468 | break; |
| 5469 | } |
| 5470 | if (LocaleCompare("rotate",option+1) == 0) |
| 5471 | { |
| 5472 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5473 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5474 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5475 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5476 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5477 | break; |
| 5478 | } |
| 5479 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5480 | } |
| 5481 | case 's': |
| 5482 | { |
| 5483 | if (LocaleCompare("sample",option+1) == 0) |
| 5484 | { |
| 5485 | if (*option == '+') |
| 5486 | break; |
| 5487 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5488 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5489 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5490 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5491 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5492 | break; |
| 5493 | } |
| 5494 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5495 | { |
| 5496 | if (*option == '+') |
| 5497 | break; |
| 5498 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5499 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5500 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5501 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5502 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5503 | break; |
| 5504 | } |
| 5505 | if (LocaleCompare("scale",option+1) == 0) |
| 5506 | { |
| 5507 | if (*option == '+') |
| 5508 | break; |
| 5509 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5510 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5511 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5512 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5513 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5514 | break; |
| 5515 | } |
| 5516 | if (LocaleCompare("scene",option+1) == 0) |
| 5517 | { |
| 5518 | if (*option == '+') |
| 5519 | break; |
| 5520 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5521 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5522 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5523 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5524 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5525 | break; |
| 5526 | } |
| 5527 | if (LocaleCompare("seed",option+1) == 0) |
| 5528 | { |
| 5529 | if (*option == '+') |
| 5530 | break; |
| 5531 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5532 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5533 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5534 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5535 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5536 | break; |
| 5537 | } |
| 5538 | if (LocaleCompare("segment",option+1) == 0) |
| 5539 | { |
| 5540 | if (*option == '+') |
| 5541 | break; |
| 5542 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5543 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5544 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5545 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5546 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5547 | break; |
| 5548 | } |
| 5549 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5550 | { |
| 5551 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5552 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5553 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5554 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5555 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5556 | break; |
| 5557 | } |
| 5558 | if (LocaleCompare("separate",option+1) == 0) |
| 5559 | break; |
| 5560 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5561 | { |
| 5562 | if (*option == '+') |
| 5563 | break; |
| 5564 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5565 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5566 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5567 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5568 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5569 | break; |
| 5570 | } |
| 5571 | if (LocaleCompare("set",option+1) == 0) |
| 5572 | { |
| 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 (*option == '+') |
| 5577 | break; |
| 5578 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5579 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5580 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5581 | break; |
| 5582 | } |
| 5583 | if (LocaleCompare("shade",option+1) == 0) |
| 5584 | { |
| 5585 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5586 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5587 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5588 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5589 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5590 | break; |
| 5591 | } |
| 5592 | if (LocaleCompare("shadow",option+1) == 0) |
| 5593 | { |
| 5594 | if (*option == '+') |
| 5595 | break; |
| 5596 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5597 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5598 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5599 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5600 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5601 | break; |
| 5602 | } |
| 5603 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5604 | { |
| 5605 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5606 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5607 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5608 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5609 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5610 | break; |
| 5611 | } |
| 5612 | if (LocaleCompare("shave",option+1) == 0) |
| 5613 | { |
| 5614 | if (*option == '+') |
| 5615 | break; |
| 5616 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5617 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5618 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5619 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5620 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5621 | break; |
| 5622 | } |
| 5623 | if (LocaleCompare("shear",option+1) == 0) |
| 5624 | { |
| 5625 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5626 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5627 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5628 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5629 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5630 | break; |
| 5631 | } |
| 5632 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5633 | { |
| 5634 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5635 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5636 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5637 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5638 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5639 | break; |
| 5640 | } |
| 5641 | if (LocaleCompare("size",option+1) == 0) |
| 5642 | { |
| 5643 | if (*option == '+') |
| 5644 | break; |
| 5645 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5646 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5647 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5648 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5649 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5650 | break; |
| 5651 | } |
| 5652 | if (LocaleCompare("sketch",option+1) == 0) |
| 5653 | { |
| 5654 | if (*option == '+') |
| 5655 | break; |
| 5656 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5657 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5658 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5659 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5660 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5661 | break; |
| 5662 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5663 | if (LocaleCompare("smush",option+1) == 0) |
| 5664 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5665 | i++; |
| 5666 | if (i == (ssize_t) argc) |
| 5667 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5668 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5669 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5670 | i++; |
| 5671 | break; |
| 5672 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5673 | if (LocaleCompare("solarize",option+1) == 0) |
| 5674 | { |
| 5675 | if (*option == '+') |
| 5676 | break; |
| 5677 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5678 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5679 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5680 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5681 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5682 | break; |
| 5683 | } |
| 5684 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5685 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5686 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5687 | op; |
| 5688 | |
| 5689 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5690 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5691 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5692 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5693 | if (op < 0) |
| 5694 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5695 | argv[i]); |
| 5696 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5697 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5698 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5699 | break; |
| 5700 | } |
| 5701 | if (LocaleCompare("spread",option+1) == 0) |
| 5702 | { |
| 5703 | if (*option == '+') |
| 5704 | break; |
| 5705 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5706 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5707 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5708 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5709 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5710 | break; |
| 5711 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5712 | if (LocaleCompare("statistic",option+1) == 0) |
| 5713 | { |
| 5714 | ssize_t |
| 5715 | op; |
| 5716 | |
| 5717 | if (*option == '+') |
| 5718 | break; |
| 5719 | i++; |
| 5720 | if (i == (ssize_t) argc) |
| 5721 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5722 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5723 | if (op < 0) |
| 5724 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5725 | argv[i]); |
| 5726 | i++; |
| 5727 | if (i == (ssize_t) (argc-1)) |
| 5728 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5729 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5730 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5731 | break; |
| 5732 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5733 | if (LocaleCompare("stretch",option+1) == 0) |
| 5734 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5735 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5736 | stretch; |
| 5737 | |
| 5738 | if (*option == '+') |
| 5739 | break; |
| 5740 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5741 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5742 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5743 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5744 | if (stretch < 0) |
| 5745 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5746 | argv[i]); |
| 5747 | break; |
| 5748 | } |
| 5749 | if (LocaleCompare("strip",option+1) == 0) |
| 5750 | break; |
| 5751 | if (LocaleCompare("stroke",option+1) == 0) |
| 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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5757 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5758 | break; |
| 5759 | } |
| 5760 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5761 | { |
| 5762 | if (*option == '+') |
| 5763 | break; |
| 5764 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5765 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5766 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5767 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5768 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5769 | break; |
| 5770 | } |
| 5771 | if (LocaleCompare("style",option+1) == 0) |
| 5772 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5773 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5774 | style; |
| 5775 | |
| 5776 | if (*option == '+') |
| 5777 | break; |
| 5778 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5779 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5780 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5781 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5782 | if (style < 0) |
| 5783 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5784 | argv[i]); |
| 5785 | break; |
| 5786 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5787 | if (LocaleCompare("swap",option+1) == 0) |
| 5788 | { |
| 5789 | if (*option == '+') |
| 5790 | break; |
| 5791 | i++; |
| 5792 | if (i == (ssize_t) (argc-1)) |
| 5793 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5794 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5795 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5796 | break; |
| 5797 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5798 | if (LocaleCompare("swirl",option+1) == 0) |
| 5799 | { |
| 5800 | if (*option == '+') |
| 5801 | break; |
| 5802 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5803 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5804 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5805 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5806 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5807 | break; |
| 5808 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5809 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5810 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5811 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5812 | } |
| 5813 | case 't': |
| 5814 | { |
| 5815 | if (LocaleCompare("taint",option+1) == 0) |
| 5816 | break; |
| 5817 | if (LocaleCompare("texture",option+1) == 0) |
| 5818 | { |
| 5819 | if (*option == '+') |
| 5820 | break; |
| 5821 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5822 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5823 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5824 | break; |
| 5825 | } |
| 5826 | if (LocaleCompare("tile",option+1) == 0) |
| 5827 | { |
| 5828 | if (*option == '+') |
| 5829 | break; |
| 5830 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5831 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5832 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5833 | break; |
| 5834 | } |
| 5835 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5836 | { |
| 5837 | if (*option == '+') |
| 5838 | break; |
| 5839 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5840 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5841 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5842 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5843 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5844 | break; |
| 5845 | } |
| 5846 | if (LocaleCompare("tint",option+1) == 0) |
| 5847 | { |
| 5848 | if (*option == '+') |
| 5849 | break; |
| 5850 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5851 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5852 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5853 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5854 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5855 | break; |
| 5856 | } |
| 5857 | if (LocaleCompare("transform",option+1) == 0) |
| 5858 | break; |
| 5859 | if (LocaleCompare("transpose",option+1) == 0) |
| 5860 | break; |
| 5861 | if (LocaleCompare("transverse",option+1) == 0) |
| 5862 | break; |
| 5863 | if (LocaleCompare("threshold",option+1) == 0) |
| 5864 | { |
| 5865 | if (*option == '+') |
| 5866 | break; |
| 5867 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5868 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5869 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5870 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5871 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5872 | break; |
| 5873 | } |
| 5874 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5875 | { |
| 5876 | if (*option == '+') |
| 5877 | break; |
| 5878 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5879 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5880 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5881 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5882 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5883 | break; |
| 5884 | } |
| 5885 | if (LocaleCompare("transparent",option+1) == 0) |
| 5886 | { |
| 5887 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5888 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5889 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5890 | break; |
| 5891 | } |
| 5892 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 5893 | { |
| 5894 | if (*option == '+') |
| 5895 | break; |
| 5896 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5897 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5898 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5899 | break; |
| 5900 | } |
| 5901 | if (LocaleCompare("treedepth",option+1) == 0) |
| 5902 | { |
| 5903 | if (*option == '+') |
| 5904 | break; |
| 5905 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5906 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5907 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5908 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5909 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5910 | break; |
| 5911 | } |
| 5912 | if (LocaleCompare("trim",option+1) == 0) |
| 5913 | break; |
| 5914 | if (LocaleCompare("type",option+1) == 0) |
| 5915 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5916 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5917 | type; |
| 5918 | |
| 5919 | if (*option == '+') |
| 5920 | break; |
| 5921 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5922 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5923 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5924 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5925 | if (type < 0) |
| 5926 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5927 | argv[i]); |
| 5928 | break; |
| 5929 | } |
| 5930 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5931 | } |
| 5932 | case 'u': |
| 5933 | { |
| 5934 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5935 | { |
| 5936 | if (*option == '+') |
| 5937 | break; |
| 5938 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5939 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5940 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5941 | break; |
| 5942 | } |
| 5943 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5944 | break; |
| 5945 | if (LocaleCompare("units",option+1) == 0) |
| 5946 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5947 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5948 | units; |
| 5949 | |
| 5950 | if (*option == '+') |
| 5951 | break; |
| 5952 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5953 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5954 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5955 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5956 | argv[i]); |
| 5957 | if (units < 0) |
| 5958 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5959 | argv[i]); |
| 5960 | break; |
| 5961 | } |
| 5962 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5963 | { |
| 5964 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5965 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5966 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5967 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5968 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5969 | break; |
| 5970 | } |
| 5971 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5972 | } |
| 5973 | case 'v': |
| 5974 | { |
| 5975 | if (LocaleCompare("verbose",option+1) == 0) |
| 5976 | { |
| 5977 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 5978 | break; |
| 5979 | } |
| 5980 | if ((LocaleCompare("version",option+1) == 0) || |
| 5981 | (LocaleCompare("-version",option+1) == 0)) |
| 5982 | { |
cristy | 4f7a613 | 2012-12-23 00:35:19 +0000 | [diff] [blame] | 5983 | ListMagickVersion(stdout); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5984 | break; |
| 5985 | } |
| 5986 | if (LocaleCompare("view",option+1) == 0) |
| 5987 | { |
| 5988 | if (*option == '+') |
| 5989 | break; |
| 5990 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5991 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5992 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5993 | break; |
| 5994 | } |
| 5995 | if (LocaleCompare("vignette",option+1) == 0) |
| 5996 | { |
| 5997 | if (*option == '+') |
| 5998 | break; |
| 5999 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6000 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6001 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6002 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6003 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6004 | break; |
| 6005 | } |
| 6006 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 6007 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6008 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6009 | method; |
| 6010 | |
| 6011 | if (*option == '+') |
| 6012 | break; |
| 6013 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6014 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6015 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6016 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6017 | argv[i]); |
| 6018 | if (method < 0) |
| 6019 | ThrowMogrifyException(OptionError, |
| 6020 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 6021 | break; |
| 6022 | } |
| 6023 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6024 | } |
| 6025 | case 'w': |
| 6026 | { |
| 6027 | if (LocaleCompare("wave",option+1) == 0) |
| 6028 | { |
| 6029 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6030 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6031 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6032 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6033 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6034 | break; |
| 6035 | } |
| 6036 | if (LocaleCompare("weight",option+1) == 0) |
| 6037 | { |
| 6038 | if (*option == '+') |
| 6039 | break; |
| 6040 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6041 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6042 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6043 | break; |
| 6044 | } |
| 6045 | if (LocaleCompare("white-point",option+1) == 0) |
| 6046 | { |
| 6047 | if (*option == '+') |
| 6048 | break; |
| 6049 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6050 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6051 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6052 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6053 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6054 | break; |
| 6055 | } |
| 6056 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6057 | { |
| 6058 | if (*option == '+') |
| 6059 | break; |
| 6060 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6061 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6062 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6063 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6064 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6065 | break; |
| 6066 | } |
| 6067 | if (LocaleCompare("write",option+1) == 0) |
| 6068 | { |
| 6069 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6070 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6071 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6072 | break; |
| 6073 | } |
| 6074 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6075 | } |
| 6076 | case '?': |
| 6077 | break; |
| 6078 | default: |
| 6079 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6080 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6081 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 6082 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6083 | if (fire != MagickFalse) |
| 6084 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6085 | } |
| 6086 | if (k != 0) |
| 6087 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6088 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6089 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6090 | DestroyMogrify(); |
| 6091 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6092 | } |
| 6093 | |
| 6094 | /* |
| 6095 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6096 | % % |
| 6097 | % % |
| 6098 | % % |
| 6099 | + M o g r i f y I m a g e I n f o % |
| 6100 | % % |
| 6101 | % % |
| 6102 | % % |
| 6103 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6104 | % |
| 6105 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6106 | % prescribed by command line options. |
| 6107 | % |
| 6108 | % The format of the MogrifyImageInfo method is: |
| 6109 | % |
| 6110 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6111 | % const char **argv,ExceptionInfo *exception) |
| 6112 | % |
| 6113 | % A description of each parameter follows: |
| 6114 | % |
| 6115 | % o image_info: the image info.. |
| 6116 | % |
| 6117 | % o argc: Specifies a pointer to an integer describing the number of |
| 6118 | % elements in the argument vector. |
| 6119 | % |
| 6120 | % o argv: Specifies a pointer to a text array containing the command line |
| 6121 | % arguments. |
| 6122 | % |
| 6123 | % o exception: return any errors or warnings in this structure. |
| 6124 | % |
| 6125 | */ |
| 6126 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6127 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6128 | { |
| 6129 | const char |
| 6130 | *option; |
| 6131 | |
| 6132 | GeometryInfo |
| 6133 | geometry_info; |
| 6134 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6135 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6136 | count; |
| 6137 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6138 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6139 | i; |
| 6140 | |
| 6141 | /* |
| 6142 | Initialize method variables. |
| 6143 | */ |
| 6144 | assert(image_info != (ImageInfo *) NULL); |
| 6145 | assert(image_info->signature == MagickSignature); |
| 6146 | if (image_info->debug != MagickFalse) |
| 6147 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6148 | image_info->filename); |
| 6149 | if (argc < 0) |
| 6150 | return(MagickTrue); |
| 6151 | /* |
| 6152 | Set the image settings. |
| 6153 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6154 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6155 | { |
| 6156 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6157 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6158 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6159 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6160 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6161 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6162 | break; |
| 6163 | switch (*(option+1)) |
| 6164 | { |
| 6165 | case 'a': |
| 6166 | { |
| 6167 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6168 | { |
| 6169 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6170 | break; |
| 6171 | } |
| 6172 | if (LocaleCompare("antialias",option+1) == 0) |
| 6173 | { |
| 6174 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6175 | break; |
| 6176 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6177 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6178 | { |
| 6179 | if (*option == '+') |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 6180 | (void) DeleteImageOption(image_info,option+1); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6181 | else |
anthony | 1afdc7a | 2011-10-05 11:54:28 +0000 | [diff] [blame] | 6182 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6183 | break; |
| 6184 | } |
| 6185 | break; |
| 6186 | } |
| 6187 | case 'b': |
| 6188 | { |
| 6189 | if (LocaleCompare("background",option+1) == 0) |
| 6190 | { |
| 6191 | if (*option == '+') |
| 6192 | { |
| 6193 | (void) DeleteImageOption(image_info,option+1); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6194 | (void) QueryColorCompliance(MogrifyBackgroundColor, |
| 6195 | AllCompliance,&image_info->background_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6196 | break; |
| 6197 | } |
| 6198 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6199 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6200 | &image_info->background_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6201 | break; |
| 6202 | } |
| 6203 | if (LocaleCompare("bias",option+1) == 0) |
| 6204 | { |
| 6205 | if (*option == '+') |
| 6206 | { |
| 6207 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6208 | break; |
| 6209 | } |
| 6210 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6211 | break; |
| 6212 | } |
| 6213 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6214 | { |
| 6215 | if (*option == '+') |
| 6216 | { |
| 6217 | (void) SetImageOption(image_info,option+1,"false"); |
| 6218 | break; |
| 6219 | } |
| 6220 | (void) SetImageOption(image_info,option+1,"true"); |
| 6221 | break; |
| 6222 | } |
| 6223 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6224 | { |
| 6225 | if (*option == '+') |
| 6226 | { |
| 6227 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6228 | break; |
| 6229 | } |
| 6230 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6231 | break; |
| 6232 | } |
| 6233 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6234 | { |
| 6235 | if (*option == '+') |
| 6236 | { |
| 6237 | (void) DeleteImageOption(image_info,option+1); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6238 | (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6239 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6240 | break; |
| 6241 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6242 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6243 | &image_info->border_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6244 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6245 | break; |
| 6246 | } |
| 6247 | if (LocaleCompare("box",option+1) == 0) |
| 6248 | { |
| 6249 | if (*option == '+') |
| 6250 | { |
| 6251 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6252 | break; |
| 6253 | } |
| 6254 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6255 | break; |
| 6256 | } |
| 6257 | break; |
| 6258 | } |
| 6259 | case 'c': |
| 6260 | { |
| 6261 | if (LocaleCompare("cache",option+1) == 0) |
| 6262 | { |
| 6263 | MagickSizeType |
| 6264 | limit; |
| 6265 | |
| 6266 | limit=MagickResourceInfinity; |
| 6267 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 6268 | limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1], |
| 6269 | 100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6270 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6271 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6272 | break; |
| 6273 | } |
| 6274 | if (LocaleCompare("caption",option+1) == 0) |
| 6275 | { |
| 6276 | if (*option == '+') |
| 6277 | { |
| 6278 | (void) DeleteImageOption(image_info,option+1); |
| 6279 | break; |
| 6280 | } |
| 6281 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6282 | break; |
| 6283 | } |
| 6284 | if (LocaleCompare("channel",option+1) == 0) |
| 6285 | { |
| 6286 | if (*option == '+') |
| 6287 | { |
| 6288 | image_info->channel=DefaultChannels; |
cristy | dfdb19e | 2012-03-21 22:22:24 +0000 | [diff] [blame] | 6289 | (void) SetImageOption(image_info,option+1,"default"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6290 | break; |
| 6291 | } |
| 6292 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
cristy | dfdb19e | 2012-03-21 22:22:24 +0000 | [diff] [blame] | 6293 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6294 | break; |
| 6295 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6296 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6297 | { |
| 6298 | if (*option == '+') |
| 6299 | { |
| 6300 | image_info->colorspace=UndefinedColorspace; |
| 6301 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6302 | break; |
| 6303 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6304 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6305 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6306 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6307 | break; |
| 6308 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6309 | if (LocaleCompare("comment",option+1) == 0) |
| 6310 | { |
| 6311 | if (*option == '+') |
| 6312 | { |
| 6313 | (void) DeleteImageOption(image_info,option+1); |
| 6314 | break; |
| 6315 | } |
| 6316 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6317 | break; |
| 6318 | } |
| 6319 | if (LocaleCompare("compose",option+1) == 0) |
| 6320 | { |
| 6321 | if (*option == '+') |
| 6322 | { |
| 6323 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6324 | break; |
| 6325 | } |
| 6326 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6327 | break; |
| 6328 | } |
| 6329 | if (LocaleCompare("compress",option+1) == 0) |
| 6330 | { |
| 6331 | if (*option == '+') |
| 6332 | { |
| 6333 | image_info->compression=UndefinedCompression; |
| 6334 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6335 | break; |
| 6336 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6337 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6338 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6339 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6340 | break; |
| 6341 | } |
| 6342 | break; |
| 6343 | } |
| 6344 | case 'd': |
| 6345 | { |
| 6346 | if (LocaleCompare("debug",option+1) == 0) |
| 6347 | { |
| 6348 | if (*option == '+') |
| 6349 | (void) SetLogEventMask("none"); |
| 6350 | else |
| 6351 | (void) SetLogEventMask(argv[i+1]); |
| 6352 | image_info->debug=IsEventLogging(); |
| 6353 | break; |
| 6354 | } |
| 6355 | if (LocaleCompare("define",option+1) == 0) |
| 6356 | { |
| 6357 | if (*option == '+') |
| 6358 | { |
| 6359 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6360 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6361 | else |
| 6362 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6363 | break; |
| 6364 | } |
| 6365 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6366 | { |
| 6367 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6368 | exception); |
| 6369 | break; |
| 6370 | } |
| 6371 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6372 | break; |
| 6373 | } |
| 6374 | if (LocaleCompare("delay",option+1) == 0) |
| 6375 | { |
| 6376 | if (*option == '+') |
| 6377 | { |
| 6378 | (void) SetImageOption(image_info,option+1,"0"); |
| 6379 | break; |
| 6380 | } |
| 6381 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6382 | break; |
| 6383 | } |
| 6384 | if (LocaleCompare("density",option+1) == 0) |
| 6385 | { |
| 6386 | /* |
| 6387 | Set image density. |
| 6388 | */ |
| 6389 | if (*option == '+') |
| 6390 | { |
| 6391 | if (image_info->density != (char *) NULL) |
| 6392 | image_info->density=DestroyString(image_info->density); |
| 6393 | (void) SetImageOption(image_info,option+1,"72"); |
| 6394 | break; |
| 6395 | } |
| 6396 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6397 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6398 | break; |
| 6399 | } |
| 6400 | if (LocaleCompare("depth",option+1) == 0) |
| 6401 | { |
| 6402 | if (*option == '+') |
| 6403 | { |
| 6404 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6405 | break; |
| 6406 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6407 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6408 | break; |
| 6409 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6410 | if (LocaleCompare("direction",option+1) == 0) |
| 6411 | { |
| 6412 | if (*option == '+') |
| 6413 | { |
| 6414 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6415 | break; |
| 6416 | } |
| 6417 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6418 | break; |
| 6419 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6420 | if (LocaleCompare("display",option+1) == 0) |
| 6421 | { |
| 6422 | if (*option == '+') |
| 6423 | { |
| 6424 | if (image_info->server_name != (char *) NULL) |
| 6425 | image_info->server_name=DestroyString( |
| 6426 | image_info->server_name); |
| 6427 | break; |
| 6428 | } |
| 6429 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6430 | break; |
| 6431 | } |
| 6432 | if (LocaleCompare("dispose",option+1) == 0) |
| 6433 | { |
| 6434 | if (*option == '+') |
| 6435 | { |
| 6436 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6437 | break; |
| 6438 | } |
| 6439 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6440 | break; |
| 6441 | } |
| 6442 | if (LocaleCompare("dither",option+1) == 0) |
| 6443 | { |
| 6444 | if (*option == '+') |
| 6445 | { |
| 6446 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6447 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6448 | break; |
| 6449 | } |
| 6450 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6451 | image_info->dither=MagickTrue; |
| 6452 | break; |
| 6453 | } |
| 6454 | break; |
| 6455 | } |
| 6456 | case 'e': |
| 6457 | { |
| 6458 | if (LocaleCompare("encoding",option+1) == 0) |
| 6459 | { |
| 6460 | if (*option == '+') |
| 6461 | { |
| 6462 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6463 | break; |
| 6464 | } |
| 6465 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6466 | break; |
| 6467 | } |
| 6468 | if (LocaleCompare("endian",option+1) == 0) |
| 6469 | { |
| 6470 | if (*option == '+') |
| 6471 | { |
| 6472 | image_info->endian=UndefinedEndian; |
| 6473 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6474 | break; |
| 6475 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6476 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6477 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6478 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6479 | break; |
| 6480 | } |
| 6481 | if (LocaleCompare("extract",option+1) == 0) |
| 6482 | { |
| 6483 | /* |
| 6484 | Set image extract geometry. |
| 6485 | */ |
| 6486 | if (*option == '+') |
| 6487 | { |
| 6488 | if (image_info->extract != (char *) NULL) |
| 6489 | image_info->extract=DestroyString(image_info->extract); |
| 6490 | break; |
| 6491 | } |
| 6492 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6493 | break; |
| 6494 | } |
| 6495 | break; |
| 6496 | } |
| 6497 | case 'f': |
| 6498 | { |
| 6499 | if (LocaleCompare("fill",option+1) == 0) |
| 6500 | { |
| 6501 | if (*option == '+') |
| 6502 | { |
| 6503 | (void) SetImageOption(image_info,option+1,"none"); |
| 6504 | break; |
| 6505 | } |
| 6506 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6507 | break; |
| 6508 | } |
| 6509 | if (LocaleCompare("filter",option+1) == 0) |
| 6510 | { |
| 6511 | if (*option == '+') |
| 6512 | { |
| 6513 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6514 | break; |
| 6515 | } |
| 6516 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6517 | break; |
| 6518 | } |
| 6519 | if (LocaleCompare("font",option+1) == 0) |
| 6520 | { |
| 6521 | if (*option == '+') |
| 6522 | { |
| 6523 | if (image_info->font != (char *) NULL) |
| 6524 | image_info->font=DestroyString(image_info->font); |
| 6525 | break; |
| 6526 | } |
| 6527 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6528 | break; |
| 6529 | } |
| 6530 | if (LocaleCompare("format",option+1) == 0) |
| 6531 | { |
| 6532 | register const char |
| 6533 | *q; |
| 6534 | |
| 6535 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6536 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6537 | image_info->ping=MagickFalse; |
| 6538 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6539 | break; |
| 6540 | } |
| 6541 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6542 | { |
| 6543 | if (*option == '+') |
| 6544 | { |
| 6545 | image_info->fuzz=0.0; |
| 6546 | (void) SetImageOption(image_info,option+1,"0"); |
| 6547 | break; |
| 6548 | } |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 6549 | image_info->fuzz=StringToDoubleInterval(argv[i+1],(double) |
| 6550 | QuantumRange+1.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6551 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6552 | break; |
| 6553 | } |
| 6554 | break; |
| 6555 | } |
| 6556 | case 'g': |
| 6557 | { |
| 6558 | if (LocaleCompare("gravity",option+1) == 0) |
| 6559 | { |
| 6560 | if (*option == '+') |
| 6561 | { |
| 6562 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6563 | break; |
| 6564 | } |
| 6565 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6566 | break; |
| 6567 | } |
| 6568 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6569 | { |
| 6570 | if (*option == '+') |
| 6571 | { |
| 6572 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6573 | break; |
| 6574 | } |
| 6575 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6576 | break; |
| 6577 | } |
| 6578 | break; |
| 6579 | } |
| 6580 | case 'i': |
| 6581 | { |
| 6582 | if (LocaleCompare("intent",option+1) == 0) |
| 6583 | { |
| 6584 | if (*option == '+') |
| 6585 | { |
| 6586 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6587 | break; |
| 6588 | } |
| 6589 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6590 | break; |
| 6591 | } |
| 6592 | if (LocaleCompare("interlace",option+1) == 0) |
| 6593 | { |
| 6594 | if (*option == '+') |
| 6595 | { |
| 6596 | image_info->interlace=UndefinedInterlace; |
| 6597 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6598 | break; |
| 6599 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6600 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6601 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6602 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6603 | break; |
| 6604 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6605 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6606 | { |
| 6607 | if (*option == '+') |
| 6608 | { |
| 6609 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6610 | break; |
| 6611 | } |
| 6612 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6613 | break; |
| 6614 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6615 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6616 | { |
| 6617 | if (*option == '+') |
| 6618 | { |
| 6619 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6620 | break; |
| 6621 | } |
| 6622 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6623 | break; |
| 6624 | } |
| 6625 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6626 | { |
| 6627 | if (*option == '+') |
| 6628 | { |
| 6629 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6630 | break; |
| 6631 | } |
| 6632 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6633 | break; |
| 6634 | } |
| 6635 | break; |
| 6636 | } |
| 6637 | case 'k': |
| 6638 | { |
| 6639 | if (LocaleCompare("kerning",option+1) == 0) |
| 6640 | { |
| 6641 | if (*option == '+') |
| 6642 | { |
| 6643 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6644 | break; |
| 6645 | } |
| 6646 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6647 | break; |
| 6648 | } |
| 6649 | break; |
| 6650 | } |
| 6651 | case 'l': |
| 6652 | { |
| 6653 | if (LocaleCompare("label",option+1) == 0) |
| 6654 | { |
| 6655 | if (*option == '+') |
| 6656 | { |
| 6657 | (void) DeleteImageOption(image_info,option+1); |
| 6658 | break; |
| 6659 | } |
| 6660 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6661 | break; |
| 6662 | } |
| 6663 | if (LocaleCompare("limit",option+1) == 0) |
| 6664 | { |
| 6665 | MagickSizeType |
| 6666 | limit; |
| 6667 | |
| 6668 | ResourceType |
| 6669 | type; |
| 6670 | |
| 6671 | if (*option == '+') |
| 6672 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6673 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6674 | MagickFalse,argv[i+1]); |
| 6675 | limit=MagickResourceInfinity; |
| 6676 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | c062734 | 2011-11-18 21:15:24 +0000 | [diff] [blame] | 6677 | limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6678 | (void) SetMagickResourceLimit(type,limit); |
| 6679 | break; |
| 6680 | } |
| 6681 | if (LocaleCompare("list",option+1) == 0) |
| 6682 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6683 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6684 | list; |
| 6685 | |
| 6686 | /* |
| 6687 | Display configuration list. |
| 6688 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6689 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6690 | switch (list) |
| 6691 | { |
| 6692 | case MagickCoderOptions: |
| 6693 | { |
| 6694 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6695 | break; |
| 6696 | } |
| 6697 | case MagickColorOptions: |
| 6698 | { |
| 6699 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6700 | break; |
| 6701 | } |
| 6702 | case MagickConfigureOptions: |
| 6703 | { |
| 6704 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6705 | break; |
| 6706 | } |
| 6707 | case MagickDelegateOptions: |
| 6708 | { |
| 6709 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6710 | break; |
| 6711 | } |
| 6712 | case MagickFontOptions: |
| 6713 | { |
| 6714 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6715 | break; |
| 6716 | } |
| 6717 | case MagickFormatOptions: |
| 6718 | { |
| 6719 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6720 | break; |
| 6721 | } |
| 6722 | case MagickLocaleOptions: |
| 6723 | { |
| 6724 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6725 | break; |
| 6726 | } |
| 6727 | case MagickLogOptions: |
| 6728 | { |
| 6729 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6730 | break; |
| 6731 | } |
| 6732 | case MagickMagicOptions: |
| 6733 | { |
| 6734 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6735 | break; |
| 6736 | } |
| 6737 | case MagickMimeOptions: |
| 6738 | { |
| 6739 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6740 | break; |
| 6741 | } |
| 6742 | case MagickModuleOptions: |
| 6743 | { |
| 6744 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6745 | break; |
| 6746 | } |
| 6747 | case MagickPolicyOptions: |
| 6748 | { |
| 6749 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6750 | break; |
| 6751 | } |
| 6752 | case MagickResourceOptions: |
| 6753 | { |
| 6754 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6755 | break; |
| 6756 | } |
| 6757 | case MagickThresholdOptions: |
| 6758 | { |
| 6759 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6760 | break; |
| 6761 | } |
| 6762 | default: |
| 6763 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6764 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6765 | exception); |
| 6766 | break; |
| 6767 | } |
| 6768 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6769 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6770 | } |
| 6771 | if (LocaleCompare("log",option+1) == 0) |
| 6772 | { |
| 6773 | if (*option == '+') |
| 6774 | break; |
| 6775 | (void) SetLogFormat(argv[i+1]); |
| 6776 | break; |
| 6777 | } |
| 6778 | if (LocaleCompare("loop",option+1) == 0) |
| 6779 | { |
| 6780 | if (*option == '+') |
| 6781 | { |
| 6782 | (void) SetImageOption(image_info,option+1,"0"); |
| 6783 | break; |
| 6784 | } |
| 6785 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6786 | break; |
| 6787 | } |
| 6788 | break; |
| 6789 | } |
| 6790 | case 'm': |
| 6791 | { |
| 6792 | if (LocaleCompare("matte",option+1) == 0) |
| 6793 | { |
| 6794 | if (*option == '+') |
| 6795 | { |
| 6796 | (void) SetImageOption(image_info,option+1,"false"); |
| 6797 | break; |
| 6798 | } |
| 6799 | (void) SetImageOption(image_info,option+1,"true"); |
| 6800 | break; |
| 6801 | } |
| 6802 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6803 | { |
| 6804 | if (*option == '+') |
| 6805 | { |
| 6806 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6807 | (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance, |
cristy | 638895a | 2011-08-06 23:19:14 +0000 | [diff] [blame] | 6808 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6809 | break; |
| 6810 | } |
| 6811 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 6812 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 6813 | &image_info->matte_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6814 | break; |
| 6815 | } |
| 6816 | if (LocaleCompare("monitor",option+1) == 0) |
| 6817 | { |
| 6818 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6819 | (void *) NULL); |
| 6820 | break; |
| 6821 | } |
| 6822 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6823 | { |
| 6824 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6825 | break; |
| 6826 | } |
| 6827 | break; |
| 6828 | } |
| 6829 | case 'o': |
| 6830 | { |
| 6831 | if (LocaleCompare("orient",option+1) == 0) |
| 6832 | { |
| 6833 | if (*option == '+') |
| 6834 | { |
| 6835 | image_info->orientation=UndefinedOrientation; |
| 6836 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6837 | break; |
| 6838 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6839 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6840 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6841 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6842 | break; |
| 6843 | } |
| 6844 | } |
| 6845 | case 'p': |
| 6846 | { |
| 6847 | if (LocaleCompare("page",option+1) == 0) |
| 6848 | { |
| 6849 | char |
| 6850 | *canonical_page, |
| 6851 | page[MaxTextExtent]; |
| 6852 | |
| 6853 | const char |
| 6854 | *image_option; |
| 6855 | |
| 6856 | MagickStatusType |
| 6857 | flags; |
| 6858 | |
| 6859 | RectangleInfo |
| 6860 | geometry; |
| 6861 | |
| 6862 | if (*option == '+') |
| 6863 | { |
| 6864 | (void) DeleteImageOption(image_info,option+1); |
| 6865 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6866 | break; |
| 6867 | } |
| 6868 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6869 | image_option=GetImageOption(image_info,"page"); |
| 6870 | if (image_option != (const char *) NULL) |
| 6871 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6872 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6873 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6874 | canonical_page=DestroyString(canonical_page); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6875 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6876 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6877 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6878 | (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6879 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6880 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6881 | (void) SetImageOption(image_info,option+1,page); |
| 6882 | (void) CloneString(&image_info->page,page); |
| 6883 | break; |
| 6884 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6885 | if (LocaleCompare("ping",option+1) == 0) |
| 6886 | { |
| 6887 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6888 | break; |
| 6889 | } |
| 6890 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6891 | { |
| 6892 | if (*option == '+') |
| 6893 | geometry_info.rho=0.0; |
| 6894 | else |
| 6895 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6896 | image_info->pointsize=geometry_info.rho; |
| 6897 | break; |
| 6898 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6899 | if (LocaleCompare("precision",option+1) == 0) |
| 6900 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6901 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6902 | break; |
| 6903 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6904 | if (LocaleCompare("preview",option+1) == 0) |
| 6905 | { |
| 6906 | /* |
| 6907 | Preview image. |
| 6908 | */ |
| 6909 | if (*option == '+') |
| 6910 | { |
| 6911 | image_info->preview_type=UndefinedPreview; |
| 6912 | break; |
| 6913 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6914 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6915 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6916 | break; |
| 6917 | } |
| 6918 | break; |
| 6919 | } |
| 6920 | case 'q': |
| 6921 | { |
| 6922 | if (LocaleCompare("quality",option+1) == 0) |
| 6923 | { |
| 6924 | /* |
| 6925 | Set image compression quality. |
| 6926 | */ |
| 6927 | if (*option == '+') |
| 6928 | { |
| 6929 | image_info->quality=UndefinedCompressionQuality; |
| 6930 | (void) SetImageOption(image_info,option+1,"0"); |
| 6931 | break; |
| 6932 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6933 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6934 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6935 | break; |
| 6936 | } |
| 6937 | if (LocaleCompare("quiet",option+1) == 0) |
| 6938 | { |
| 6939 | static WarningHandler |
| 6940 | warning_handler = (WarningHandler) NULL; |
| 6941 | |
| 6942 | if (*option == '+') |
| 6943 | { |
| 6944 | /* |
| 6945 | Restore error or warning messages. |
| 6946 | */ |
| 6947 | warning_handler=SetWarningHandler(warning_handler); |
| 6948 | break; |
| 6949 | } |
| 6950 | /* |
| 6951 | Suppress error or warning messages. |
| 6952 | */ |
| 6953 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6954 | break; |
| 6955 | } |
| 6956 | break; |
| 6957 | } |
| 6958 | case 'r': |
| 6959 | { |
| 6960 | if (LocaleCompare("red-primary",option+1) == 0) |
| 6961 | { |
| 6962 | if (*option == '+') |
| 6963 | { |
| 6964 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6965 | break; |
| 6966 | } |
| 6967 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6968 | break; |
| 6969 | } |
| 6970 | break; |
| 6971 | } |
| 6972 | case 's': |
| 6973 | { |
| 6974 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 6975 | { |
| 6976 | /* |
| 6977 | Set image sampling factor. |
| 6978 | */ |
| 6979 | if (*option == '+') |
| 6980 | { |
| 6981 | if (image_info->sampling_factor != (char *) NULL) |
| 6982 | image_info->sampling_factor=DestroyString( |
| 6983 | image_info->sampling_factor); |
| 6984 | break; |
| 6985 | } |
| 6986 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 6987 | break; |
| 6988 | } |
| 6989 | if (LocaleCompare("scene",option+1) == 0) |
| 6990 | { |
| 6991 | /* |
| 6992 | Set image scene. |
| 6993 | */ |
| 6994 | if (*option == '+') |
| 6995 | { |
| 6996 | image_info->scene=0; |
| 6997 | (void) SetImageOption(image_info,option+1,"0"); |
| 6998 | break; |
| 6999 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7000 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7001 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7002 | break; |
| 7003 | } |
| 7004 | if (LocaleCompare("seed",option+1) == 0) |
| 7005 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7006 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7007 | seed; |
| 7008 | |
| 7009 | if (*option == '+') |
| 7010 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7011 | seed=(size_t) time((time_t *) NULL); |
cristy | d7761bb | 2012-04-14 01:42:05 +0000 | [diff] [blame] | 7012 | SetRandomSecretKey(seed); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7013 | break; |
| 7014 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7015 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | d7761bb | 2012-04-14 01:42:05 +0000 | [diff] [blame] | 7016 | SetRandomSecretKey(seed); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7017 | break; |
| 7018 | } |
| 7019 | if (LocaleCompare("size",option+1) == 0) |
| 7020 | { |
| 7021 | if (*option == '+') |
| 7022 | { |
| 7023 | if (image_info->size != (char *) NULL) |
| 7024 | image_info->size=DestroyString(image_info->size); |
| 7025 | break; |
| 7026 | } |
| 7027 | (void) CloneString(&image_info->size,argv[i+1]); |
| 7028 | break; |
| 7029 | } |
| 7030 | if (LocaleCompare("stroke",option+1) == 0) |
| 7031 | { |
| 7032 | if (*option == '+') |
| 7033 | { |
| 7034 | (void) SetImageOption(image_info,option+1,"none"); |
| 7035 | break; |
| 7036 | } |
| 7037 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7038 | break; |
| 7039 | } |
| 7040 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7041 | { |
| 7042 | if (*option == '+') |
| 7043 | { |
| 7044 | (void) SetImageOption(image_info,option+1,"0"); |
| 7045 | break; |
| 7046 | } |
| 7047 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7048 | break; |
| 7049 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7050 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7051 | { |
| 7052 | if (*option == '+') |
| 7053 | { |
| 7054 | image_info->synchronize=MagickFalse; |
| 7055 | break; |
| 7056 | } |
| 7057 | image_info->synchronize=MagickTrue; |
| 7058 | break; |
| 7059 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7060 | break; |
| 7061 | } |
| 7062 | case 't': |
| 7063 | { |
| 7064 | if (LocaleCompare("taint",option+1) == 0) |
| 7065 | { |
| 7066 | if (*option == '+') |
| 7067 | { |
| 7068 | (void) SetImageOption(image_info,option+1,"false"); |
| 7069 | break; |
| 7070 | } |
| 7071 | (void) SetImageOption(image_info,option+1,"true"); |
| 7072 | break; |
| 7073 | } |
| 7074 | if (LocaleCompare("texture",option+1) == 0) |
| 7075 | { |
| 7076 | if (*option == '+') |
| 7077 | { |
| 7078 | if (image_info->texture != (char *) NULL) |
| 7079 | image_info->texture=DestroyString(image_info->texture); |
| 7080 | break; |
| 7081 | } |
| 7082 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7083 | break; |
| 7084 | } |
| 7085 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7086 | { |
| 7087 | if (*option == '+') |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 7088 | (void) SetImageOption(image_info,option+1,"0"); |
| 7089 | else |
| 7090 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7091 | break; |
| 7092 | } |
| 7093 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7094 | { |
| 7095 | if (*option == '+') |
| 7096 | { |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 7097 | (void) QueryColorCompliance("none",AllCompliance, |
| 7098 | &image_info->transparent_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7099 | (void) SetImageOption(image_info,option+1,"none"); |
| 7100 | break; |
| 7101 | } |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 7102 | (void) QueryColorCompliance(argv[i+1],AllCompliance, |
| 7103 | &image_info->transparent_color,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7104 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7105 | break; |
| 7106 | } |
| 7107 | if (LocaleCompare("type",option+1) == 0) |
| 7108 | { |
| 7109 | if (*option == '+') |
| 7110 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7111 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7112 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7113 | break; |
| 7114 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7115 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7116 | MagickFalse,argv[i+1]); |
| 7117 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7118 | break; |
| 7119 | } |
| 7120 | break; |
| 7121 | } |
| 7122 | case 'u': |
| 7123 | { |
| 7124 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7125 | { |
| 7126 | if (*option == '+') |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 7127 | (void) DeleteImageOption(image_info,option+1); |
| 7128 | else |
| 7129 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7130 | break; |
| 7131 | } |
| 7132 | if (LocaleCompare("units",option+1) == 0) |
| 7133 | { |
| 7134 | if (*option == '+') |
| 7135 | { |
| 7136 | image_info->units=UndefinedResolution; |
| 7137 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7138 | break; |
| 7139 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7140 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7141 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7142 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7143 | break; |
| 7144 | } |
| 7145 | break; |
| 7146 | } |
| 7147 | case 'v': |
| 7148 | { |
| 7149 | if (LocaleCompare("verbose",option+1) == 0) |
| 7150 | { |
| 7151 | if (*option == '+') |
| 7152 | { |
| 7153 | image_info->verbose=MagickFalse; |
| 7154 | break; |
| 7155 | } |
| 7156 | image_info->verbose=MagickTrue; |
| 7157 | image_info->ping=MagickFalse; |
| 7158 | break; |
| 7159 | } |
| 7160 | if (LocaleCompare("view",option+1) == 0) |
| 7161 | { |
| 7162 | if (*option == '+') |
| 7163 | { |
| 7164 | if (image_info->view != (char *) NULL) |
| 7165 | image_info->view=DestroyString(image_info->view); |
| 7166 | break; |
| 7167 | } |
| 7168 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7169 | break; |
| 7170 | } |
| 7171 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7172 | { |
| 7173 | if (*option == '+') |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 7174 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7175 | else |
| 7176 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7177 | break; |
| 7178 | } |
| 7179 | break; |
| 7180 | } |
| 7181 | case 'w': |
| 7182 | { |
| 7183 | if (LocaleCompare("white-point",option+1) == 0) |
| 7184 | { |
| 7185 | if (*option == '+') |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 7186 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7187 | else |
| 7188 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7189 | break; |
| 7190 | } |
| 7191 | break; |
| 7192 | } |
| 7193 | default: |
| 7194 | break; |
| 7195 | } |
| 7196 | i+=count; |
| 7197 | } |
| 7198 | return(MagickTrue); |
| 7199 | } |
| 7200 | |
| 7201 | /* |
| 7202 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7203 | % % |
| 7204 | % % |
| 7205 | % % |
| 7206 | + M o g r i f y I m a g e L i s t % |
| 7207 | % % |
| 7208 | % % |
| 7209 | % % |
| 7210 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7211 | % |
| 7212 | % MogrifyImageList() applies any command line options that might affect the |
| 7213 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7214 | % |
| 7215 | % The format of the MogrifyImage method is: |
| 7216 | % |
| 7217 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7218 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7219 | % |
| 7220 | % A description of each parameter follows: |
| 7221 | % |
| 7222 | % o image_info: the image info.. |
| 7223 | % |
| 7224 | % o argc: Specifies a pointer to an integer describing the number of |
| 7225 | % elements in the argument vector. |
| 7226 | % |
| 7227 | % o argv: Specifies a pointer to a text array containing the command line |
| 7228 | % arguments. |
| 7229 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7230 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7231 | % |
| 7232 | % o exception: return any errors or warnings in this structure. |
| 7233 | % |
| 7234 | */ |
| 7235 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7236 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7237 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7238 | const char |
| 7239 | *option; |
| 7240 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7241 | ImageInfo |
| 7242 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7243 | |
| 7244 | MagickStatusType |
| 7245 | status; |
| 7246 | |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7247 | PixelInterpolateMethod |
| 7248 | interpolate_method; |
| 7249 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7250 | QuantizeInfo |
| 7251 | *quantize_info; |
| 7252 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7253 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7254 | i; |
| 7255 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7256 | ssize_t |
| 7257 | count, |
| 7258 | index; |
| 7259 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7260 | /* |
| 7261 | Apply options to the image list. |
| 7262 | */ |
| 7263 | assert(image_info != (ImageInfo *) NULL); |
| 7264 | assert(image_info->signature == MagickSignature); |
| 7265 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7266 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7267 | assert((*images)->signature == MagickSignature); |
| 7268 | if ((*images)->debug != MagickFalse) |
| 7269 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7270 | (*images)->filename); |
| 7271 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7272 | return(MagickTrue); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7273 | interpolate_method=UndefinedInterpolatePixel; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7274 | mogrify_info=CloneImageInfo(image_info); |
| 7275 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7276 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7277 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7278 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7279 | if (*images == (Image *) NULL) |
| 7280 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7281 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7282 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7283 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7284 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7285 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7286 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7287 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7288 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7289 | switch (*(option+1)) |
| 7290 | { |
| 7291 | case 'a': |
| 7292 | { |
| 7293 | if (LocaleCompare("affinity",option+1) == 0) |
| 7294 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7295 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7296 | if (*option == '+') |
| 7297 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7298 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7299 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7300 | break; |
| 7301 | } |
| 7302 | i++; |
| 7303 | break; |
| 7304 | } |
| 7305 | if (LocaleCompare("append",option+1) == 0) |
| 7306 | { |
| 7307 | Image |
| 7308 | *append_image; |
| 7309 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7310 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7311 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7312 | MagickFalse,exception); |
| 7313 | if (append_image == (Image *) NULL) |
| 7314 | { |
| 7315 | status=MagickFalse; |
| 7316 | break; |
| 7317 | } |
| 7318 | *images=DestroyImageList(*images); |
| 7319 | *images=append_image; |
| 7320 | break; |
| 7321 | } |
| 7322 | if (LocaleCompare("average",option+1) == 0) |
| 7323 | { |
| 7324 | Image |
| 7325 | *average_image; |
| 7326 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7327 | /* |
| 7328 | Average an image sequence (deprecated). |
| 7329 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7330 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7331 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7332 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7333 | if (average_image == (Image *) NULL) |
| 7334 | { |
| 7335 | status=MagickFalse; |
| 7336 | break; |
| 7337 | } |
| 7338 | *images=DestroyImageList(*images); |
| 7339 | *images=average_image; |
| 7340 | break; |
| 7341 | } |
| 7342 | break; |
| 7343 | } |
| 7344 | case 'c': |
| 7345 | { |
cristy | 5f257b2 | 2012-03-07 00:27:29 +0000 | [diff] [blame] | 7346 | if (LocaleCompare("channel-fx",option+1) == 0) |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 7347 | { |
cristy | d04e7bf | 2012-03-03 19:19:12 +0000 | [diff] [blame] | 7348 | Image |
| 7349 | *channel_image; |
| 7350 | |
| 7351 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 5f257b2 | 2012-03-07 00:27:29 +0000 | [diff] [blame] | 7352 | channel_image=ChannelFxImage(*images,argv[i+1],exception); |
cristy | d04e7bf | 2012-03-03 19:19:12 +0000 | [diff] [blame] | 7353 | if (channel_image == (Image *) NULL) |
| 7354 | { |
| 7355 | status=MagickFalse; |
| 7356 | break; |
| 7357 | } |
| 7358 | *images=DestroyImageList(*images); |
| 7359 | *images=channel_image; |
cristy | 87c02f4 | 2012-02-24 00:19:10 +0000 | [diff] [blame] | 7360 | break; |
| 7361 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7362 | if (LocaleCompare("clut",option+1) == 0) |
| 7363 | { |
| 7364 | Image |
| 7365 | *clut_image, |
| 7366 | *image; |
| 7367 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7368 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7369 | image=RemoveFirstImageFromList(images); |
| 7370 | clut_image=RemoveFirstImageFromList(images); |
| 7371 | if (clut_image == (Image *) NULL) |
| 7372 | { |
| 7373 | status=MagickFalse; |
| 7374 | break; |
| 7375 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7376 | (void) ClutImage(image,clut_image,interpolate_method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7377 | clut_image=DestroyImage(clut_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7378 | *images=DestroyImageList(*images); |
| 7379 | *images=image; |
| 7380 | break; |
| 7381 | } |
| 7382 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7383 | { |
| 7384 | Image |
| 7385 | *coalesce_image; |
| 7386 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7387 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7388 | coalesce_image=CoalesceImages(*images,exception); |
| 7389 | if (coalesce_image == (Image *) NULL) |
| 7390 | { |
| 7391 | status=MagickFalse; |
| 7392 | break; |
| 7393 | } |
| 7394 | *images=DestroyImageList(*images); |
| 7395 | *images=coalesce_image; |
| 7396 | break; |
| 7397 | } |
| 7398 | if (LocaleCompare("combine",option+1) == 0) |
| 7399 | { |
cristy | 46f354c | 2012-07-04 13:31:29 +0000 | [diff] [blame] | 7400 | ColorspaceType |
| 7401 | colorspace; |
| 7402 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7403 | Image |
| 7404 | *combine_image; |
| 7405 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7406 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 46f354c | 2012-07-04 13:31:29 +0000 | [diff] [blame] | 7407 | colorspace=(ColorspaceType) ParseCommandOption( |
| 7408 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 7409 | combine_image=CombineImages(*images,colorspace,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7410 | if (combine_image == (Image *) NULL) |
| 7411 | { |
| 7412 | status=MagickFalse; |
| 7413 | break; |
| 7414 | } |
| 7415 | *images=DestroyImageList(*images); |
| 7416 | *images=combine_image; |
| 7417 | break; |
| 7418 | } |
| 7419 | if (LocaleCompare("composite",option+1) == 0) |
| 7420 | { |
cristy | 542a95b | 2012-04-03 19:30:58 +0000 | [diff] [blame] | 7421 | const char |
| 7422 | *value; |
| 7423 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7424 | Image |
| 7425 | *mask_image, |
| 7426 | *composite_image, |
| 7427 | *image; |
| 7428 | |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 7429 | MagickBooleanType |
| 7430 | clip_to_self; |
| 7431 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7432 | RectangleInfo |
| 7433 | geometry; |
| 7434 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7435 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 542a95b | 2012-04-03 19:30:58 +0000 | [diff] [blame] | 7436 | value=GetImageOption(mogrify_info,"compose:clip-to-self"); |
| 7437 | if (value == (const char *) NULL) |
| 7438 | clip_to_self=MagickTrue; |
| 7439 | else |
| 7440 | clip_to_self=IsStringTrue(GetImageOption(mogrify_info, |
| 7441 | "compose:clip-to-self")); /* if this is true */ |
anthony | 7bcfe7f | 2012-03-30 14:01:22 +0000 | [diff] [blame] | 7442 | if (IsMagickFalse(clip_to_self)) /* or */ |
| 7443 | clip_to_self=IfMagickFalse(IsStringNotFalse(GetImageOption( |
cristy | d9ecd04 | 2012-06-17 18:26:12 +0000 | [diff] [blame] | 7444 | mogrify_info,"compose:outside-overlay"))) ? MagickTrue : MagickFalse; /* this false */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7445 | image=RemoveFirstImageFromList(images); |
| 7446 | composite_image=RemoveFirstImageFromList(images); |
| 7447 | if (composite_image == (Image *) NULL) |
| 7448 | { |
| 7449 | status=MagickFalse; |
| 7450 | break; |
| 7451 | } |
| 7452 | (void) TransformImage(&composite_image,(char *) NULL, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 7453 | composite_image->geometry,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7454 | SetGeometry(composite_image,&geometry); |
| 7455 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7456 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7457 | &geometry); |
| 7458 | mask_image=RemoveFirstImageFromList(images); |
| 7459 | if (mask_image != (Image *) NULL) |
| 7460 | { |
| 7461 | if ((image->compose == DisplaceCompositeOp) || |
| 7462 | (image->compose == DistortCompositeOp)) |
| 7463 | { |
| 7464 | /* |
| 7465 | Merge Y displacement into X displacement image. |
| 7466 | */ |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 7467 | (void) CompositeImage(composite_image,mask_image, |
cristy | 3917240 | 2012-03-30 13:04:39 +0000 | [diff] [blame] | 7468 | CopyGreenCompositeOp,MagickTrue,0,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7469 | mask_image=DestroyImage(mask_image); |
| 7470 | } |
| 7471 | else |
| 7472 | { |
| 7473 | /* |
anthony | 80c3775 | 2012-01-16 01:03:11 +0000 | [diff] [blame] | 7474 | Set a blending mask for the composition. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7475 | */ |
cristy | 10a6c61 | 2012-01-29 21:41:05 +0000 | [diff] [blame] | 7476 | (void) NegateImage(mask_image,MagickFalse,exception); |
cristy | 665e18f | 2012-05-17 12:39:54 +0000 | [diff] [blame] | 7477 | (void) SetImageMask(composite_image,mask_image,exception); |
cristy | 10a6c61 | 2012-01-29 21:41:05 +0000 | [diff] [blame] | 7478 | mask_image=DestroyImage(mask_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7479 | } |
| 7480 | } |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 7481 | (void) CompositeImage(image,composite_image,image->compose, |
cristy | 3917240 | 2012-03-30 13:04:39 +0000 | [diff] [blame] | 7482 | clip_to_self,geometry.x,geometry.y,exception); |
cristy | 10a6c61 | 2012-01-29 21:41:05 +0000 | [diff] [blame] | 7483 | (void) SetImageMask(image,(Image *) NULL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7484 | composite_image=DestroyImage(composite_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7485 | *images=DestroyImageList(*images); |
| 7486 | *images=image; |
| 7487 | break; |
| 7488 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7489 | break; |
| 7490 | } |
| 7491 | case 'd': |
| 7492 | { |
| 7493 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7494 | { |
| 7495 | Image |
| 7496 | *deconstruct_image; |
| 7497 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7498 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7499 | deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer, |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 7500 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7501 | if (deconstruct_image == (Image *) NULL) |
| 7502 | { |
| 7503 | status=MagickFalse; |
| 7504 | break; |
| 7505 | } |
| 7506 | *images=DestroyImageList(*images); |
| 7507 | *images=deconstruct_image; |
| 7508 | break; |
| 7509 | } |
| 7510 | if (LocaleCompare("delete",option+1) == 0) |
| 7511 | { |
| 7512 | if (*option == '+') |
| 7513 | DeleteImages(images,"-1",exception); |
| 7514 | else |
| 7515 | DeleteImages(images,argv[i+1],exception); |
| 7516 | break; |
| 7517 | } |
| 7518 | if (LocaleCompare("dither",option+1) == 0) |
| 7519 | { |
| 7520 | if (*option == '+') |
| 7521 | { |
cristy | cbda611 | 2012-05-27 20:57:16 +0000 | [diff] [blame] | 7522 | quantize_info->dither_method=NoDitherMethod; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7523 | break; |
| 7524 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7525 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7526 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7527 | break; |
| 7528 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7529 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7530 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7531 | Image |
| 7532 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7533 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7534 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7535 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7536 | else |
| 7537 | { |
| 7538 | const char |
| 7539 | *p; |
| 7540 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7541 | size_t |
| 7542 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7543 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7544 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7545 | p=strchr(argv[i+1],','); |
| 7546 | if (p == (const char *) NULL) |
| 7547 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7548 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7549 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7550 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7551 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7552 | } |
| 7553 | AppendImageToList(images, duplicate_images); |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7554 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7555 | break; |
| 7556 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7557 | break; |
| 7558 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7559 | case 'e': |
| 7560 | { |
| 7561 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7562 | { |
| 7563 | Image |
| 7564 | *evaluate_image; |
| 7565 | |
| 7566 | MagickEvaluateOperator |
| 7567 | op; |
| 7568 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7569 | (void) SyncImageSettings(mogrify_info,*images,exception); |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7570 | op=(MagickEvaluateOperator) ParseCommandOption( |
| 7571 | MagickEvaluateOptions,MagickFalse,argv[i+1]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7572 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7573 | if (evaluate_image == (Image *) NULL) |
| 7574 | { |
| 7575 | status=MagickFalse; |
| 7576 | break; |
| 7577 | } |
| 7578 | *images=DestroyImageList(*images); |
| 7579 | *images=evaluate_image; |
| 7580 | break; |
| 7581 | } |
| 7582 | break; |
| 7583 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7584 | case 'f': |
| 7585 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7586 | if (LocaleCompare("fft",option+1) == 0) |
| 7587 | { |
| 7588 | Image |
| 7589 | *fourier_image; |
| 7590 | |
| 7591 | /* |
| 7592 | Implements the discrete Fourier transform (DFT). |
| 7593 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7594 | (void) SyncImageSettings(mogrify_info,*images,exception); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7595 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7596 | MagickTrue : MagickFalse,exception); |
| 7597 | if (fourier_image == (Image *) NULL) |
| 7598 | break; |
| 7599 | *images=DestroyImage(*images); |
| 7600 | *images=fourier_image; |
| 7601 | break; |
| 7602 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7603 | if (LocaleCompare("flatten",option+1) == 0) |
| 7604 | { |
| 7605 | Image |
| 7606 | *flatten_image; |
| 7607 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7608 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7609 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7610 | if (flatten_image == (Image *) NULL) |
| 7611 | break; |
| 7612 | *images=DestroyImageList(*images); |
| 7613 | *images=flatten_image; |
| 7614 | break; |
| 7615 | } |
| 7616 | if (LocaleCompare("fx",option+1) == 0) |
| 7617 | { |
| 7618 | Image |
| 7619 | *fx_image; |
| 7620 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7621 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 7622 | fx_image=FxImage(*images,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7623 | if (fx_image == (Image *) NULL) |
| 7624 | { |
| 7625 | status=MagickFalse; |
| 7626 | break; |
| 7627 | } |
| 7628 | *images=DestroyImageList(*images); |
| 7629 | *images=fx_image; |
| 7630 | break; |
| 7631 | } |
| 7632 | break; |
| 7633 | } |
| 7634 | case 'h': |
| 7635 | { |
| 7636 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7637 | { |
| 7638 | Image |
| 7639 | *hald_image, |
| 7640 | *image; |
| 7641 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7642 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7643 | image=RemoveFirstImageFromList(images); |
| 7644 | hald_image=RemoveFirstImageFromList(images); |
| 7645 | if (hald_image == (Image *) NULL) |
| 7646 | { |
| 7647 | status=MagickFalse; |
| 7648 | break; |
| 7649 | } |
cristy | 7c0a0a4 | 2011-08-23 17:57:25 +0000 | [diff] [blame] | 7650 | (void) HaldClutImage(image,hald_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7651 | hald_image=DestroyImage(hald_image); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7652 | if (*images != (Image *) NULL) |
| 7653 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7654 | *images=image; |
| 7655 | break; |
| 7656 | } |
| 7657 | break; |
| 7658 | } |
| 7659 | case 'i': |
| 7660 | { |
| 7661 | if (LocaleCompare("ift",option+1) == 0) |
| 7662 | { |
| 7663 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7664 | *fourier_image, |
| 7665 | *magnitude_image, |
| 7666 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7667 | |
| 7668 | /* |
| 7669 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7670 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7671 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7672 | magnitude_image=RemoveFirstImageFromList(images); |
| 7673 | phase_image=RemoveFirstImageFromList(images); |
| 7674 | if (phase_image == (Image *) NULL) |
| 7675 | { |
| 7676 | status=MagickFalse; |
| 7677 | break; |
| 7678 | } |
| 7679 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7680 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7681 | if (fourier_image == (Image *) NULL) |
| 7682 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7683 | if (*images != (Image *) NULL) |
| 7684 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7685 | *images=fourier_image; |
| 7686 | break; |
| 7687 | } |
| 7688 | if (LocaleCompare("insert",option+1) == 0) |
| 7689 | { |
| 7690 | Image |
| 7691 | *p, |
| 7692 | *q; |
| 7693 | |
| 7694 | index=0; |
| 7695 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7696 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7697 | p=RemoveLastImageFromList(images); |
| 7698 | if (p == (Image *) NULL) |
| 7699 | { |
| 7700 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 7701 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7702 | status=MagickFalse; |
| 7703 | break; |
| 7704 | } |
| 7705 | q=p; |
| 7706 | if (index == 0) |
| 7707 | PrependImageToList(images,q); |
| 7708 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7709 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7710 | AppendImageToList(images,q); |
| 7711 | else |
| 7712 | { |
| 7713 | q=GetImageFromList(*images,index-1); |
| 7714 | if (q == (Image *) NULL) |
| 7715 | { |
| 7716 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 7717 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7718 | status=MagickFalse; |
| 7719 | break; |
| 7720 | } |
| 7721 | InsertImageInList(&q,p); |
| 7722 | } |
| 7723 | *images=GetFirstImageInList(q); |
| 7724 | break; |
| 7725 | } |
cristy | 28474bf | 2011-09-11 23:32:52 +0000 | [diff] [blame] | 7726 | if (LocaleCompare("interpolate",option+1) == 0) |
| 7727 | { |
| 7728 | interpolate_method=(PixelInterpolateMethod) ParseCommandOption( |
| 7729 | MagickInterpolateOptions,MagickFalse,argv[i+1]); |
| 7730 | break; |
| 7731 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7732 | break; |
| 7733 | } |
| 7734 | case 'l': |
| 7735 | { |
| 7736 | if (LocaleCompare("layers",option+1) == 0) |
| 7737 | { |
| 7738 | Image |
| 7739 | *layers; |
| 7740 | |
cristy | a041706 | 2012-09-02 23:34:56 +0000 | [diff] [blame] | 7741 | LayerMethod |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7742 | method; |
| 7743 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7744 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7745 | layers=(Image *) NULL; |
cristy | a041706 | 2012-09-02 23:34:56 +0000 | [diff] [blame] | 7746 | method=(LayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7747 | MagickFalse,argv[i+1]); |
| 7748 | switch (method) |
| 7749 | { |
| 7750 | case CoalesceLayer: |
| 7751 | { |
| 7752 | layers=CoalesceImages(*images,exception); |
| 7753 | break; |
| 7754 | } |
| 7755 | case CompareAnyLayer: |
| 7756 | case CompareClearLayer: |
| 7757 | case CompareOverlayLayer: |
| 7758 | default: |
| 7759 | { |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7760 | layers=CompareImagesLayers(*images,method,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7761 | break; |
| 7762 | } |
| 7763 | case MergeLayer: |
| 7764 | case FlattenLayer: |
| 7765 | case MosaicLayer: |
| 7766 | case TrimBoundsLayer: |
| 7767 | { |
| 7768 | layers=MergeImageLayers(*images,method,exception); |
| 7769 | break; |
| 7770 | } |
| 7771 | case DisposeLayer: |
| 7772 | { |
| 7773 | layers=DisposeImages(*images,exception); |
| 7774 | break; |
| 7775 | } |
| 7776 | case OptimizeImageLayer: |
| 7777 | { |
| 7778 | layers=OptimizeImageLayers(*images,exception); |
| 7779 | break; |
| 7780 | } |
| 7781 | case OptimizePlusLayer: |
| 7782 | { |
| 7783 | layers=OptimizePlusImageLayers(*images,exception); |
| 7784 | break; |
| 7785 | } |
| 7786 | case OptimizeTransLayer: |
| 7787 | { |
| 7788 | OptimizeImageTransparency(*images,exception); |
| 7789 | break; |
| 7790 | } |
| 7791 | case RemoveDupsLayer: |
| 7792 | { |
| 7793 | RemoveDuplicateLayers(images,exception); |
| 7794 | break; |
| 7795 | } |
| 7796 | case RemoveZeroLayer: |
| 7797 | { |
| 7798 | RemoveZeroDelayLayers(images,exception); |
| 7799 | break; |
| 7800 | } |
| 7801 | case OptimizeLayer: |
| 7802 | { |
| 7803 | /* |
| 7804 | General Purpose, GIF Animation Optimizer. |
| 7805 | */ |
| 7806 | layers=CoalesceImages(*images,exception); |
| 7807 | if (layers == (Image *) NULL) |
| 7808 | { |
| 7809 | status=MagickFalse; |
| 7810 | break; |
| 7811 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7812 | *images=DestroyImageList(*images); |
| 7813 | *images=layers; |
| 7814 | layers=OptimizeImageLayers(*images,exception); |
| 7815 | if (layers == (Image *) NULL) |
| 7816 | { |
| 7817 | status=MagickFalse; |
| 7818 | break; |
| 7819 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7820 | *images=DestroyImageList(*images); |
| 7821 | *images=layers; |
| 7822 | layers=(Image *) NULL; |
| 7823 | OptimizeImageTransparency(*images,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7824 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7825 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7826 | break; |
| 7827 | } |
| 7828 | case CompositeLayer: |
| 7829 | { |
| 7830 | CompositeOperator |
| 7831 | compose; |
| 7832 | |
| 7833 | Image |
| 7834 | *source; |
| 7835 | |
| 7836 | RectangleInfo |
| 7837 | geometry; |
| 7838 | |
| 7839 | /* |
| 7840 | Split image sequence at the first 'NULL:' image. |
| 7841 | */ |
| 7842 | source=(*images); |
| 7843 | while (source != (Image *) NULL) |
| 7844 | { |
| 7845 | source=GetNextImageInList(source); |
| 7846 | if ((source != (Image *) NULL) && |
| 7847 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7848 | break; |
| 7849 | } |
| 7850 | if (source != (Image *) NULL) |
| 7851 | { |
| 7852 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7853 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7854 | source=(Image *) NULL; |
| 7855 | else |
| 7856 | { |
| 7857 | /* |
| 7858 | Separate the two lists, junk the null: image. |
| 7859 | */ |
| 7860 | source=SplitImageList(source->previous); |
| 7861 | DeleteImageFromList(&source); |
| 7862 | } |
| 7863 | } |
| 7864 | if (source == (Image *) NULL) |
| 7865 | { |
| 7866 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7867 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7868 | status=MagickFalse; |
| 7869 | break; |
| 7870 | } |
| 7871 | /* |
| 7872 | Adjust offset with gravity and virtual canvas. |
| 7873 | */ |
| 7874 | SetGeometry(*images,&geometry); |
| 7875 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7876 | geometry.width=source->page.width != 0 ? |
| 7877 | source->page.width : source->columns; |
| 7878 | geometry.height=source->page.height != 0 ? |
| 7879 | source->page.height : source->rows; |
| 7880 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7881 | (*images)->page.width : (*images)->columns, |
| 7882 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7883 | (*images)->rows,(*images)->gravity,&geometry); |
| 7884 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7885 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7886 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7887 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7888 | MagickComposeOptions,MagickFalse,option); |
| 7889 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7890 | exception); |
| 7891 | source=DestroyImageList(source); |
| 7892 | break; |
| 7893 | } |
| 7894 | } |
| 7895 | if (layers == (Image *) NULL) |
| 7896 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7897 | *images=DestroyImageList(*images); |
| 7898 | *images=layers; |
| 7899 | break; |
| 7900 | } |
| 7901 | break; |
| 7902 | } |
| 7903 | case 'm': |
| 7904 | { |
| 7905 | if (LocaleCompare("map",option+1) == 0) |
| 7906 | { |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7907 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7908 | if (*option == '+') |
| 7909 | { |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 7910 | (void) RemapImages(quantize_info,*images,(Image *) NULL, |
| 7911 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7912 | break; |
| 7913 | } |
| 7914 | i++; |
| 7915 | break; |
| 7916 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7917 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7918 | { |
| 7919 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7920 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7921 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7922 | /* |
| 7923 | Maximum image sequence (deprecated). |
| 7924 | */ |
cristy | 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 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7927 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7928 | { |
| 7929 | status=MagickFalse; |
| 7930 | break; |
| 7931 | } |
| 7932 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7933 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7934 | break; |
| 7935 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7936 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7937 | { |
| 7938 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7939 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7940 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7941 | /* |
| 7942 | Minimum image sequence (deprecated). |
| 7943 | */ |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7944 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7945 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7946 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7947 | { |
| 7948 | status=MagickFalse; |
| 7949 | break; |
| 7950 | } |
| 7951 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7952 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7953 | break; |
| 7954 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7955 | if (LocaleCompare("morph",option+1) == 0) |
| 7956 | { |
| 7957 | Image |
| 7958 | *morph_image; |
| 7959 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7960 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7961 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7962 | exception); |
| 7963 | if (morph_image == (Image *) NULL) |
| 7964 | { |
| 7965 | status=MagickFalse; |
| 7966 | break; |
| 7967 | } |
| 7968 | *images=DestroyImageList(*images); |
| 7969 | *images=morph_image; |
| 7970 | break; |
| 7971 | } |
| 7972 | if (LocaleCompare("mosaic",option+1) == 0) |
| 7973 | { |
| 7974 | Image |
| 7975 | *mosaic_image; |
| 7976 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 7977 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7978 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 7979 | if (mosaic_image == (Image *) NULL) |
| 7980 | { |
| 7981 | status=MagickFalse; |
| 7982 | break; |
| 7983 | } |
| 7984 | *images=DestroyImageList(*images); |
| 7985 | *images=mosaic_image; |
| 7986 | break; |
| 7987 | } |
| 7988 | break; |
| 7989 | } |
| 7990 | case 'p': |
| 7991 | { |
cristy | 02016cf | 2012-11-13 01:14:41 +0000 | [diff] [blame] | 7992 | if (LocaleCompare("poly",option+1) == 0) |
| 7993 | { |
| 7994 | char |
| 7995 | *args, |
| 7996 | token[MaxTextExtent]; |
| 7997 | |
| 7998 | const char |
| 7999 | *p; |
| 8000 | |
| 8001 | double |
| 8002 | *arguments; |
| 8003 | |
| 8004 | Image |
| 8005 | *polynomial_image; |
| 8006 | |
| 8007 | register ssize_t |
| 8008 | x; |
| 8009 | |
| 8010 | size_t |
| 8011 | number_arguments; |
| 8012 | |
| 8013 | /* |
| 8014 | Polynomial image. |
| 8015 | */ |
| 8016 | (void) SyncImageSettings(mogrify_info,*images,exception); |
| 8017 | args=InterpretImageProperties(mogrify_info,*images,argv[i+1], |
| 8018 | exception); |
| 8019 | if (args == (char *) NULL) |
| 8020 | break; |
| 8021 | p=(char *) args; |
| 8022 | for (x=0; *p != '\0'; x++) |
| 8023 | { |
| 8024 | GetMagickToken(p,&p,token); |
| 8025 | if (*token == ',') |
| 8026 | GetMagickToken(p,&p,token); |
| 8027 | } |
| 8028 | number_arguments=(size_t) x; |
| 8029 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 8030 | sizeof(*arguments)); |
| 8031 | if (arguments == (double *) NULL) |
| 8032 | ThrowWandFatalException(ResourceLimitFatalError, |
| 8033 | "MemoryAllocationFailed",(*images)->filename); |
| 8034 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 8035 | sizeof(*arguments)); |
| 8036 | p=(char *) args; |
| 8037 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 8038 | { |
| 8039 | GetMagickToken(p,&p,token); |
| 8040 | if (*token == ',') |
| 8041 | GetMagickToken(p,&p,token); |
| 8042 | arguments[x]=StringToDouble(token,(char **) NULL); |
| 8043 | } |
| 8044 | args=DestroyString(args); |
| 8045 | polynomial_image=PolynomialImage(*images,number_arguments >> 1, |
| 8046 | arguments,exception); |
| 8047 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 8048 | if (polynomial_image == (Image *) NULL) |
| 8049 | { |
| 8050 | status=MagickFalse; |
| 8051 | break; |
| 8052 | } |
| 8053 | *images=DestroyImageList(*images); |
| 8054 | *images=polynomial_image; |
| 8055 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8056 | if (LocaleCompare("print",option+1) == 0) |
| 8057 | { |
| 8058 | char |
| 8059 | *string; |
| 8060 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8061 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 8062 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1], |
| 8063 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8064 | if (string == (char *) NULL) |
| 8065 | break; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8066 | (void) FormatLocaleFile(stdout,"%s",string); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8067 | string=DestroyString(string); |
| 8068 | } |
| 8069 | if (LocaleCompare("process",option+1) == 0) |
| 8070 | { |
| 8071 | char |
| 8072 | **arguments; |
| 8073 | |
| 8074 | int |
| 8075 | j, |
| 8076 | number_arguments; |
| 8077 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8078 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8079 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 8080 | if (arguments == (char **) NULL) |
| 8081 | break; |
| 8082 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 8083 | { |
| 8084 | char |
| 8085 | breaker, |
| 8086 | quote, |
| 8087 | *token; |
| 8088 | |
| 8089 | const char |
| 8090 | *arguments; |
| 8091 | |
| 8092 | int |
| 8093 | next, |
| 8094 | status; |
| 8095 | |
| 8096 | size_t |
| 8097 | length; |
| 8098 | |
| 8099 | TokenInfo |
| 8100 | *token_info; |
| 8101 | |
| 8102 | /* |
| 8103 | Support old style syntax, filter="-option arg". |
| 8104 | */ |
| 8105 | length=strlen(argv[i+1]); |
| 8106 | token=(char *) NULL; |
cristy | 37e0b38 | 2011-06-07 13:31:21 +0000 | [diff] [blame] | 8107 | if (~length >= (MaxTextExtent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8108 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8109 | sizeof(*token)); |
| 8110 | if (token == (char *) NULL) |
| 8111 | break; |
| 8112 | next=0; |
| 8113 | arguments=argv[i+1]; |
| 8114 | token_info=AcquireTokenInfo(); |
| 8115 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8116 | "\"",'\0',&breaker,&next,"e); |
| 8117 | token_info=DestroyTokenInfo(token_info); |
| 8118 | if (status == 0) |
| 8119 | { |
| 8120 | const char |
| 8121 | *argv; |
| 8122 | |
| 8123 | argv=(&(arguments[next])); |
| 8124 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8125 | exception); |
| 8126 | } |
| 8127 | token=DestroyString(token); |
| 8128 | break; |
| 8129 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8130 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8131 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8132 | number_arguments-2,(const char **) arguments+2,exception); |
| 8133 | for (j=0; j < number_arguments; j++) |
| 8134 | arguments[j]=DestroyString(arguments[j]); |
| 8135 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8136 | break; |
| 8137 | } |
| 8138 | break; |
| 8139 | } |
| 8140 | case 'r': |
| 8141 | { |
| 8142 | if (LocaleCompare("reverse",option+1) == 0) |
| 8143 | { |
| 8144 | ReverseImageList(images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8145 | break; |
| 8146 | } |
| 8147 | break; |
| 8148 | } |
| 8149 | case 's': |
| 8150 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8151 | if (LocaleCompare("smush",option+1) == 0) |
| 8152 | { |
| 8153 | Image |
| 8154 | *smush_image; |
| 8155 | |
| 8156 | ssize_t |
| 8157 | offset; |
| 8158 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8159 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8160 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8161 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8162 | MagickFalse,offset,exception); |
| 8163 | if (smush_image == (Image *) NULL) |
| 8164 | { |
| 8165 | status=MagickFalse; |
| 8166 | break; |
| 8167 | } |
| 8168 | *images=DestroyImageList(*images); |
| 8169 | *images=smush_image; |
| 8170 | break; |
| 8171 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8172 | if (LocaleCompare("swap",option+1) == 0) |
| 8173 | { |
| 8174 | Image |
| 8175 | *p, |
| 8176 | *q, |
| 8177 | *swap; |
| 8178 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8179 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8180 | swap_index; |
| 8181 | |
| 8182 | index=(-1); |
| 8183 | swap_index=(-2); |
| 8184 | if (*option != '+') |
| 8185 | { |
| 8186 | GeometryInfo |
| 8187 | geometry_info; |
| 8188 | |
| 8189 | MagickStatusType |
| 8190 | flags; |
| 8191 | |
| 8192 | swap_index=(-1); |
| 8193 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8194 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8195 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8196 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8197 | } |
| 8198 | p=GetImageFromList(*images,index); |
| 8199 | q=GetImageFromList(*images,swap_index); |
| 8200 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8201 | { |
| 8202 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 8203 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8204 | status=MagickFalse; |
| 8205 | break; |
| 8206 | } |
| 8207 | if (p == q) |
| 8208 | break; |
| 8209 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8210 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8211 | ReplaceImageInList(&q,swap); |
| 8212 | *images=GetFirstImageInList(q); |
| 8213 | break; |
| 8214 | } |
| 8215 | break; |
| 8216 | } |
| 8217 | case 'w': |
| 8218 | { |
| 8219 | if (LocaleCompare("write",option+1) == 0) |
| 8220 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8221 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8222 | key[MaxTextExtent]; |
| 8223 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8224 | Image |
| 8225 | *write_images; |
| 8226 | |
| 8227 | ImageInfo |
| 8228 | *write_info; |
| 8229 | |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 8230 | (void) SyncImagesSettings(mogrify_info,*images,exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8231 | (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8232 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8233 | write_images=(*images); |
| 8234 | if (*option == '+') |
| 8235 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8236 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8237 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8238 | write_info=DestroyImageInfo(write_info); |
| 8239 | if (*option == '+') |
| 8240 | write_images=DestroyImageList(write_images); |
| 8241 | break; |
| 8242 | } |
| 8243 | break; |
| 8244 | } |
| 8245 | default: |
| 8246 | break; |
| 8247 | } |
| 8248 | i+=count; |
| 8249 | } |
| 8250 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8251 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8252 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8253 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8254 | } |
| 8255 | |
| 8256 | /* |
| 8257 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8258 | % % |
| 8259 | % % |
| 8260 | % % |
| 8261 | + M o g r i f y I m a g e s % |
| 8262 | % % |
| 8263 | % % |
| 8264 | % % |
| 8265 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8266 | % |
| 8267 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8268 | % prescribed by command line options. |
| 8269 | % |
| 8270 | % The format of the MogrifyImage method is: |
| 8271 | % |
| 8272 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8273 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8274 | % Image **images,Exceptioninfo *exception) |
| 8275 | % |
| 8276 | % A description of each parameter follows: |
| 8277 | % |
| 8278 | % o image_info: the image info.. |
| 8279 | % |
| 8280 | % o post: If true, post process image list operators otherwise pre-process. |
| 8281 | % |
| 8282 | % o argc: Specifies a pointer to an integer describing the number of |
| 8283 | % elements in the argument vector. |
| 8284 | % |
| 8285 | % o argv: Specifies a pointer to a text array containing the command line |
| 8286 | % arguments. |
| 8287 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8288 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8289 | % |
| 8290 | % o exception: return any errors or warnings in this structure. |
| 8291 | % |
| 8292 | */ |
| 8293 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8294 | const MagickBooleanType post,const int argc,const char **argv, |
| 8295 | Image **images,ExceptionInfo *exception) |
| 8296 | { |
| 8297 | #define MogrifyImageTag "Mogrify/Image" |
| 8298 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8299 | MagickStatusType |
| 8300 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8301 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8302 | MagickBooleanType |
| 8303 | proceed; |
| 8304 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8305 | size_t |
| 8306 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8307 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8308 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8309 | i; |
| 8310 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8311 | assert(image_info != (ImageInfo *) NULL); |
| 8312 | assert(image_info->signature == MagickSignature); |
| 8313 | if (images == (Image **) NULL) |
| 8314 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8315 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8316 | assert((*images)->signature == MagickSignature); |
| 8317 | if ((*images)->debug != MagickFalse) |
| 8318 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8319 | (*images)->filename); |
| 8320 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8321 | return(MagickTrue); |
| 8322 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8323 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8324 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8325 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8326 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8327 | (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc, |
| 8328 | post?"post":"pre"); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8329 | #endif |
| 8330 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8331 | /* |
| 8332 | Pre-process multi-image sequence operators |
| 8333 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8334 | if (post == MagickFalse) |
| 8335 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8336 | /* |
| 8337 | For each image, process simple single image operators |
| 8338 | */ |
| 8339 | i=0; |
| 8340 | n=GetImageListLength(*images); |
cristy | 9f027d1 | 2011-09-21 01:17:17 +0000 | [diff] [blame] | 8341 | for ( ; ; ) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8342 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8343 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8344 | (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long) |
| 8345 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8346 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8347 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8348 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8349 | if (proceed == MagickFalse) |
| 8350 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8351 | if ( (*images)->next == (Image *) NULL ) |
| 8352 | break; |
| 8353 | *images=(*images)->next; |
| 8354 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8355 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8356 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8357 | #if 0 |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8358 | (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long) |
| 8359 | GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8360 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8361 | |
| 8362 | /* |
| 8363 | Post-process, multi-image sequence operators |
| 8364 | */ |
| 8365 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8366 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8367 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8368 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8369 | } |